├── Algorithms
├── String-Processing
│ ├── .keep
│ └── LongestRepeatedSubsequence.java
├── Hashing
│ └── cuckoo_hashing.cpp
├── BitMasking
│ ├── Check Odd or Even
│ │ ├── README.md
│ │ └── check.cpp
│ ├── Check Power of 2
│ │ ├── README.md
│ │ └── check_power.cpp
│ ├── Check ith bit
│ │ ├── README.md
│ │ └── check_ith_bit.cpp
│ ├── Convert Number to Binary
│ │ ├── README.md
│ │ └── convert.cpp
│ ├── Flip ith bit
│ │ ├── README.md
│ │ └── flip.cpp
│ ├── Turn Off First Set Bit
│ │ ├── README.md
│ │ └── solution.cpp
│ ├── Return First Set Bit
│ │ ├── README.md
│ │ └── solution.cpp
│ ├── Turn Off ith bit
│ │ ├── README.md
│ │ └── turn_off_ith_bit.cpp
│ ├── Turn On ith bit
│ │ ├── README.md
│ │ └── turn_on_ith_bit.cpp
│ └── Clear All Bits from MSB
│ │ ├── README.md
│ │ └── solution.cpp
├── Graphs
│ └── KosaRaju-Strongly_Connected_Components
│ │ └── input.txt
├── Recursion
│ └── Chess.java
├── Dynamic-Programming
│ ├── LBS.java
│ ├── MPC.java
│ └── min_steps_to_1.cpp
├── Trees
│ └── Binary tree
│ │ └── isBST.java
├── Computational-Geometry
│ ├── Convex-Hull
│ │ └── convex_hull_jarvis.cpp
│ └── Lines
│ │ └── line_segments_intersection.cpp
├── Sorting
│ ├── selection_sort.py
│ ├── bubble_sort.py
│ └── insertion_sort.py
└── Searching
│ └── linear_search.py
├── Problem Solutions
├── CodeChef
│ ├── COOK117A
│ │ └── A
│ │ │ ├── in4.txt
│ │ │ ├── in3.txt
│ │ │ ├── in2.txt
│ │ │ └── in.txt
│ ├── GW19MOS
│ │ ├── C
│ │ │ ├── in2.txt
│ │ │ └── in.txt
│ │ ├── D
│ │ │ └── in.txt
│ │ └── B
│ │ │ └── in.txt
│ ├── LTIME83A
│ │ ├── MEXUM
│ │ │ ├── in3.txt
│ │ │ ├── in2.txt
│ │ │ ├── in5.txt
│ │ │ ├── in.txt
│ │ │ └── in4.txt
│ │ ├── HXR
│ │ │ └── in.txt
│ │ ├── SHUFFLE
│ │ │ └── in.txt
│ │ └── TRIQRY
│ │ │ └── in.txt
│ ├── RC122020
│ │ ├── RECNDROT
│ │ │ ├── in2.txt
│ │ │ ├── in3
│ │ │ ├── in.txt
│ │ │ └── in4.txt
│ │ ├── RECNDSTR
│ │ │ └── in.txt
│ │ ├── RECNDNUM
│ │ │ ├── in.txt
│ │ │ ├── in2.txt
│ │ │ └── in3.txt
│ │ └── RECNDNOS
│ │ │ └── in.txt
│ ├── PRACTICE
│ │ ├── EID.py
│ │ ├── AVG.py
│ │ ├── CHGM1.py
│ │ ├── CPAIRS.py
│ │ ├── Hashing
│ │ │ ├── GOOGOL05.cpp
│ │ │ ├── NPLQ19D.cpp
│ │ │ └── INLO31.cpp
│ │ └── Trees
│ │ │ └── CHEFDETE.cpp
│ ├── JULY19A
│ │ └── MMAX.py
│ ├── AUG19B
│ │ └── MSNSADM1.py
│ ├── CACD2020
│ │ ├── PPPR.cpp
│ │ └── MODME.cpp
│ ├── JAN18
│ │ ├── KILLKTH.py
│ │ └── RECTANGL.cpp
│ ├── KH19MOS
│ │ └── RANDID.cpp
│ ├── OCT19B
│ │ ├── S10E_soln.py
│ │ └── MARM_soln.py
│ ├── BitChef 1.0
│ │ └── CHEFLOL.cpp
│ ├── JULY17
│ │ └── CALC.cpp
│ ├── AGPR2020
│ │ └── CANDY.cpp
│ ├── CHPTRS01
│ │ ├── CSCARE.py
│ │ └── FUNRUN.cpp
│ ├── AM19MOS
│ │ └── USANBOLT.cpp
│ ├── JULY18B
│ │ └── PINS.cpp
│ ├── ZCO Practice Contest
│ │ ├── ZCO14003.cpp
│ │ └── ZCO13001.cpp
│ ├── AUG19A
│ │ └── DSTAPLS.cpp
│ ├── COOK90
│ │ └── SURVIVE.cpp
│ ├── LTIME77B
│ │ └── HIT_soln.py
│ ├── COOK106A
│ │ └── GCDSET.cpp
│ ├── LTIME56
│ │ └── L56GAME.cpp
│ └── APRIL20A
│ │ └── STRNO.cpp
├── Codeforces
│ ├── Div 3 Rounds
│ │ ├── 634 Div 3
│ │ │ ├── A
│ │ │ │ ├── out.txt
│ │ │ │ ├── in.txt
│ │ │ │ └── A.cpp
│ │ │ ├── C
│ │ │ │ ├── in2.txt
│ │ │ │ └── in.txt
│ │ │ ├── B
│ │ │ │ └── in.txt
│ │ │ ├── E
│ │ │ │ └── in.txt
│ │ │ └── D
│ │ │ │ └── in.txt
│ │ ├── 641 Div 3
│ │ │ ├── C
│ │ │ │ ├── in.txt
│ │ │ │ └── C.cpp
│ │ │ ├── D
│ │ │ │ └── in.txt
│ │ │ ├── A
│ │ │ │ ├── in.txt
│ │ │ │ └── A.cpp
│ │ │ └── B
│ │ │ │ └── in.txt
│ │ ├── 636 Div 3
│ │ │ ├── B
│ │ │ │ └── in.txt
│ │ │ ├── D
│ │ │ │ ├── in3.txt
│ │ │ │ ├── in2.txt
│ │ │ │ └── in.txt
│ │ │ ├── A
│ │ │ │ ├── in.txt
│ │ │ │ └── A.cpp
│ │ │ └── C
│ │ │ │ └── in.txt
│ │ ├── 611 Div 3
│ │ │ ├── A.cpp
│ │ │ └── B.cpp
│ │ ├── 629 Div 3
│ │ │ └── A.cpp
│ │ ├── 575 Div 3
│ │ │ └── A.cpp
│ │ ├── 598 Div 3
│ │ │ └── A.cpp
│ │ ├── 582 Div 3 Virtual
│ │ │ ├── A.cpp
│ │ │ └── B.cpp
│ │ └── 496 Virtual
│ │ │ └── B.cpp
│ ├── Div 2 Rounds
│ │ ├── 643 Div 2
│ │ │ ├── C
│ │ │ │ ├── in1.txt
│ │ │ │ ├── in2.txt
│ │ │ │ └── in3.txt
│ │ │ ├── D
│ │ │ │ ├── in1.txt
│ │ │ │ ├── in2.txt
│ │ │ │ ├── in3.txt
│ │ │ │ └── D.cpp
│ │ │ ├── B
│ │ │ │ ├── in.txt
│ │ │ │ └── B.cpp
│ │ │ └── A
│ │ │ │ └── in.txt
│ │ ├── 635 Div 2
│ │ │ ├── C
│ │ │ │ ├── in5.txt
│ │ │ │ ├── in2.txt
│ │ │ │ ├── in.txt
│ │ │ │ ├── in4.txt
│ │ │ │ ├── in3.txt
│ │ │ │ ├── in_counter_2.txt
│ │ │ │ └── in_counter.txt
│ │ │ ├── A
│ │ │ │ ├── in.txt
│ │ │ │ └── A.cpp
│ │ │ ├── B
│ │ │ │ ├── in.txt
│ │ │ │ └── B.cpp
│ │ │ └── D
│ │ │ │ └── in.txt
│ │ ├── 641 Div 2
│ │ │ ├── C
│ │ │ │ ├── in3.txt
│ │ │ │ ├── in.txt
│ │ │ │ ├── in4.txt
│ │ │ │ └── in2.txt
│ │ │ ├── A
│ │ │ │ └── in.txt
│ │ │ └── B
│ │ │ │ └── in.txt
│ │ ├── 637 Div 2
│ │ │ ├── D
│ │ │ │ ├── in.txt
│ │ │ │ ├── in2.txt
│ │ │ │ └── in3.txt
│ │ │ ├── C
│ │ │ │ ├── in2.txt
│ │ │ │ └── in.txt
│ │ │ ├── B
│ │ │ │ └── in.txt
│ │ │ └── A
│ │ │ │ └── A.cpp
│ │ ├── 638 Div 2 Virtual
│ │ │ ├── A
│ │ │ │ ├── in.txt
│ │ │ │ └── A.cpp
│ │ │ ├── C
│ │ │ │ ├── in2.txt
│ │ │ │ └── in.txt
│ │ │ └── B
│ │ │ │ └── in.txt
│ │ ├── 633 Div 2 Virtual
│ │ │ ├── C
│ │ │ │ ├── in2.txt
│ │ │ │ └── in.txt
│ │ │ ├── B
│ │ │ │ └── in.txt
│ │ │ └── A
│ │ │ │ └── A.cpp
│ │ ├── 621 Div 2 Virtual
│ │ │ ├── B
│ │ │ │ ├── in2.txt
│ │ │ │ └── in.txt
│ │ │ └── A
│ │ │ │ ├── in.txt
│ │ │ │ └── A.cpp
│ │ ├── 645 Div 2
│ │ │ ├── A
│ │ │ │ ├── in1.txt
│ │ │ │ └── A.cpp
│ │ │ ├── C
│ │ │ │ ├── in2.txt
│ │ │ │ └── in1.txt
│ │ │ └── B
│ │ │ │ └── in1.txt
│ │ ├── 196 Div 2
│ │ │ └── A.cpp
│ │ ├── 628 Div 2
│ │ │ ├── A.cpp
│ │ │ └── B.cpp
│ │ ├── 464 Div 2
│ │ │ ├── 1.cpp
│ │ │ └── 2.cpp
│ │ ├── 576 Div 2
│ │ │ └── B.cpp
│ │ ├── 613 Div 2 Virtual
│ │ │ └── A.cpp
│ │ ├── 596 Div 2
│ │ │ └── A.cpp
│ │ ├── 258 Div 2 Virtual
│ │ │ └── A.cpp
│ │ ├── 632 Div 2
│ │ │ └── A.cpp
│ │ ├── 608 Div 2
│ │ │ └── A.cpp
│ │ ├── 646 Div 2
│ │ │ └── C
│ │ │ │ └── C.cpp
│ │ ├── Hello 2018
│ │ │ └── A.cpp
│ │ ├── 251 Div 2 Virtual
│ │ │ └── B.cpp
│ │ ├── 519 Virtual
│ │ │ └── C.cpp
│ │ ├── 581 Div 2 Virtual
│ │ │ └── A.cpp
│ │ ├── 499 Div 2 Virtual
│ │ │ └── A.cpp
│ │ └── 561 Div 2
│ │ │ └── A.cpp
│ ├── Educational Rounds
│ │ ├── Round 86
│ │ │ ├── A
│ │ │ │ ├── in2.txt
│ │ │ │ ├── in.txt
│ │ │ │ └── A.cpp
│ │ │ ├── D
│ │ │ │ ├── in1.txt
│ │ │ │ ├── in3.txt
│ │ │ │ ├── in4.txt
│ │ │ │ ├── in5.txt
│ │ │ │ ├── in6.txt
│ │ │ │ └── in2.txt
│ │ │ ├── B
│ │ │ │ └── in.txt
│ │ │ └── C
│ │ │ │ └── in.txt
│ │ ├── Round 84 Virtual
│ │ │ └── A.cpp
│ │ ├── Round 80
│ │ │ ├── B.cpp
│ │ │ └── A.cpp
│ │ ├── Round 87
│ │ │ ├── C
│ │ │ │ └── C.cpp
│ │ │ └── A
│ │ │ │ └── A.cpp
│ │ ├── Round 71
│ │ │ └── A.cpp
│ │ ├── Round 69
│ │ │ └── A.cpp
│ │ └── Round 85
│ │ │ └── B.cpp
│ ├── Div 4 Rounds
│ │ └── 640 Div 4
│ │ │ ├── F
│ │ │ ├── in2.txt
│ │ │ ├── in3.txt
│ │ │ └── in.txt
│ │ │ ├── A
│ │ │ └── in.txt
│ │ │ ├── G
│ │ │ ├── in2.txt
│ │ │ └── in.txt
│ │ │ ├── C
│ │ │ └── in.txt
│ │ │ ├── B
│ │ │ └── in.txt
│ │ │ ├── E
│ │ │ └── in.txt
│ │ │ └── D
│ │ │ └── in.txt
│ ├── Discord Bot Random
│ │ ├── in.txt
│ │ └── 755C_2.cpp
│ ├── Southern and Volga Russia Qualifier 2019-2020
│ │ └── info
│ ├── Tags
│ │ ├── implementation
│ │ │ ├── 281A.cpp
│ │ │ ├── 791A.cpp
│ │ │ ├── 4A.cpp
│ │ │ ├── 50A.cpp
│ │ │ ├── 266A.cpp
│ │ │ ├── 71A.cpp
│ │ │ ├── 96A.py
│ │ │ ├── 158A.cpp
│ │ │ ├── 1A.cpp
│ │ │ ├── A-1016.cpp
│ │ │ ├── 231A.cpp
│ │ │ ├── 58A.cpp
│ │ │ ├── 116A.cpp
│ │ │ ├── 282A.cpp
│ │ │ ├── 282A.py
│ │ │ ├── 263A.cpp
│ │ │ ├── 96A.cpp
│ │ │ ├── 361A.cpp
│ │ │ ├── 200B.cpp
│ │ │ ├── 334A.cpp
│ │ │ ├── 546A.cpp
│ │ │ ├── 104A.cpp
│ │ │ ├── 467A.cpp
│ │ │ ├── 133A.cpp
│ │ │ ├── 118A.py
│ │ │ ├── 276A.cpp
│ │ │ ├── 102B.cpp
│ │ │ ├── 61A.cpp
│ │ │ ├── 266B.cpp
│ │ │ ├── 118A.cpp
│ │ │ ├── 112A.cpp
│ │ │ ├── 158A.py
│ │ │ ├── 92A.cpp
│ │ │ ├── 69A.cpp
│ │ │ ├── 160A-better.cpp
│ │ │ ├── 129A.cpp
│ │ │ └── 336A.cpp
│ │ ├── dp
│ │ │ └── 35D.cpp
│ │ └── strings
│ │ │ └── 71A.cpp
│ ├── Kotlin
│ │ ├── Kotlin Heroes: Practice 4
│ │ │ └── A+B.kt
│ │ └── Kotlin Heroes: Episode 4
│ │ │ └── A.kt
│ ├── Concept Building Practice
│ │ ├── 236A.c
│ │ ├── 231A.c
│ │ └── 900A.cpp
│ ├── Global Rounds
│ │ ├── Round 7
│ │ │ ├── B.cpp
│ │ │ └── C.cpp
│ │ └── Round 6
│ │ │ └── B.cpp
│ ├── Other Rounds
│ │ ├── 2019-2020 ICPC NERC Southern and Volga Russian Regional Contest
│ │ │ └── F.cpp
│ │ ├── Good Bye 2019
│ │ │ └── C.cpp
│ │ └── Hello 2020
│ │ │ ├── C.cpp
│ │ │ └── A.cpp
│ └── Speed Building Practice
│ │ ├── template.cpp
│ │ ├── 1180A.cpp
│ │ ├── 1194A.cpp
│ │ └── 1195B.cpp
├── CodeJam
│ ├── 2019
│ │ └── Round 2
│ │ │ └── New Elements: Part 2
│ │ │ └── in.txt
│ └── 2020
│ │ ├── Round 1B
│ │ ├── Expogo
│ │ │ ├── in2.txt
│ │ │ └── in.txt
│ │ └── Blindfolded_Bullseye
│ │ │ └── solution.cpp
│ │ ├── Round 1A
│ │ └── PatternMatching
│ │ │ ├── in3.txt
│ │ │ ├── in4.txt
│ │ │ ├── in2.txt
│ │ │ └── in.txt
│ │ └── Round 1C
│ │ ├── A
│ │ └── in.txt
│ │ └── C
│ │ └── in.txt
├── AtCoder
│ ├── Beginner-Contests
│ │ ├── ABC165 Virtual
│ │ │ ├── B
│ │ │ │ ├── in1.txt
│ │ │ │ ├── in3.txt
│ │ │ │ ├── in2.txt
│ │ │ │ └── B.cpp
│ │ │ ├── D
│ │ │ │ ├── in.txt
│ │ │ │ ├── in2.txt
│ │ │ │ └── D.cpp
│ │ │ ├── A
│ │ │ │ ├── in2.txt
│ │ │ │ ├── in1.txt
│ │ │ │ ├── in3.txt
│ │ │ │ └── A.cpp
│ │ │ └── C
│ │ │ │ ├── in3.txt
│ │ │ │ ├── in.txt
│ │ │ │ └── in2.txt
│ │ ├── ABC167
│ │ │ ├── D
│ │ │ │ ├── in3.txt
│ │ │ │ ├── in.txt
│ │ │ │ └── in2.txt
│ │ │ ├── C
│ │ │ │ ├── in.txt
│ │ │ │ ├── in2.txt
│ │ │ │ └── in3.txt
│ │ │ └── A
│ │ │ │ └── A.cpp
│ │ ├── ABC169 Virtual
│ │ │ ├── D
│ │ │ │ ├── in1.txt
│ │ │ │ ├── in2.txt
│ │ │ │ ├── in3.txt
│ │ │ │ ├── in4.txt
│ │ │ │ └── in5.txt
│ │ │ ├── C
│ │ │ │ ├── in1.txt
│ │ │ │ ├── in2.txt
│ │ │ │ ├── in3.txt
│ │ │ │ └── C.cpp
│ │ │ ├── E
│ │ │ │ ├── in1.txt
│ │ │ │ └── in2.txt
│ │ │ └── A
│ │ │ │ └── A.cpp
│ │ ├── ABC151
│ │ │ ├── A.cpp
│ │ │ ├── B.cpp
│ │ │ └── C.cpp
│ │ ├── ABC144
│ │ │ ├── A.cpp
│ │ │ ├── C.cpp
│ │ │ ├── B.cpp
│ │ │ └── D.cpp
│ │ ├── ABC150
│ │ │ ├── A.cpp
│ │ │ ├── D.py
│ │ │ └── B.cpp
│ │ ├── ABC147
│ │ │ ├── A.cpp
│ │ │ └── B.cpp
│ │ └── ABC166
│ │ │ ├── A
│ │ │ └── A.cpp
│ │ │ └── E
│ │ │ └── E.cpp
│ └── Grand-Contests
│ │ └── AGC026
│ │ └── A.cpp
├── Geeksforgeeks
│ └── 21_Days_Challenge
│ │ └── 1-Maths
│ │ └── maximum_squares.cpp
├── Interviewbit
│ ├── Bit Manipulation
│ │ ├── Number of 1 Bits.cpp
│ │ ├── Single Number.cpp
│ │ └── Min XOR Value.cpp
│ ├── Math
│ │ ├── Greatest Common Divisor.cpp
│ │ ├── Palindrome Integer.cpp
│ │ ├── FizzBuzz.cpp
│ │ └── Reverse Integer.cpp
│ ├── Hashing
│ │ └── Diffk II.cpp
│ ├── Two Pointers
│ │ └── Intersection of Sorted Arrays.cpp
│ ├── Strings
│ │ └── Amazing Subarrays.cpp
│ └── Binary Search
│ │ └── power_function.cpp
├── LeetCode
│ ├── Dynamic Programming
│ │ ├── 877-stone-game.cpp
│ │ ├── 338-counting-bits.cpp
│ │ └── 1227-airplane-seat-assignment-probability.cpp
│ ├── Hashing
│ │ └── 771-Jewels-and-Stones.cpp
│ ├── Weekly Contests
│ │ ├── 92
│ │ │ └── 868.Transpose-Matrix.cpp
│ │ ├── 143
│ │ │ ├── 1104.Path-in-Zigzag-Labelled-Binary-Tree.cpp
│ │ │ └── 1103.Distribute-Candies-to-People.cpp
│ │ ├── 166
│ │ │ └── A.cpp
│ │ └── 179
│ │ │ ├── A.cpp
│ │ │ └── B.cpp
│ ├── Biweekly Contests
│ │ ├── 3
│ │ │ └── 1099.Two-Sum-Less-Than-K.cpp
│ │ └── 15
│ │ │ └── A.cpp
│ └── Array
│ │ ├── 215-Kth-largest.cpp
│ │ ├── 1-Two-Sum_hashing.cpp
│ │ └── 1-Two-Sum_sorting.cpp
├── URI
│ ├── 1001.cpp
│ ├── 1002.cpp
│ ├── 1015.cpp
│ ├── 2344.cpp
│ └── 2251.cpp
├── SPOJ
│ ├── SAMER08F.cpp
│ ├── AE00.cpp
│ ├── BEENUMS.cpp
│ ├── ARMY.cpp
│ ├── LASTDIG.cpp
│ ├── thelastdigit.cpp
│ ├── DP
│ │ └── ANARC09A.cpp
│ ├── OFFSIDE.cpp
│ └── Wine trading in Gergovia.cpp
├── HackerRank
│ ├── Interview Preparation Kit
│ │ └── Warm-Up
│ │ │ ├── Sock Merchant.cpp
│ │ │ ├── Counting Valleys.cpp
│ │ │ ├── Jumping on the clouds.cpp
│ │ │ └── Repeated String.cpp
│ └── Problem Solving
│ │ ├── Jim and the orders.cpp
│ │ ├── Poker Nim.cpp
│ │ ├── GradingStudents.py
│ │ ├── Introduction to Nim Game.cpp
│ │ ├── Nimble game.cpp
│ │ └── Journey-to-the-moon.cpp
├── HackerEarth
│ ├── Month Easy Contests
│ │ └── MAY 19
│ │ │ ├── A.cpp
│ │ │ └── B.cpp
│ └── Practice
│ │ └── Arrays
│ │ └── Monk_and_Rotation.cpp
├── e-olymp
│ └── ADA October 18 Binary Search
│ │ ├── README.md
│ │ ├── rank.cpp
│ │ ├── binary_search.cpp
│ │ └── binary_search_2.cpp
├── TopCoder
│ ├── TCC 2018
│ │ └── A.cpp
│ ├── SRM 737
│ │ └── B_Incomplete.cpp
│ ├── TCO 2020
│ │ └── 1A
│ │ │ └── A.cpp
│ ├── SRM 738
│ │ └── B_Incomplete.cpp
│ └── TCC India Final 2018
│ │ └── A.cpp
├── CodeDrills
│ ├── 92A.cpp
│ └── 282B.cpp
├── fbHackerCup
│ └── 2018-Qualification-Round
│ │ └── 2-Interception.cpp
└── KickStart
│ └── 2019
│ └── Round F
│ └── B.cpp
├── Data Structures
├── Linked-Lists
│ ├── SumLists.java
│ ├── Palindrome.java
│ ├── Intersection.java
│ └── DeleteMiddleNode.java
├── Trie
│ └── README.md
├── Stacks
│ └── stack_paren_balanced.py
└── Trees
│ └── Generic Tree
│ └── GenericTreeClient.java
├── Templates
└── STL
│ └── helper_routines.cpp
└── .gitignore
/Algorithms/String-Processing/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Algorithms/Hashing/cuckoo_hashing.cpp:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/COOK117A/A/in4.txt:
--------------------------------------------------------------------------------
1 | 1
2 | ab
3 | ac
4 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/GW19MOS/C/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 1 1
3 | 1
4 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/LTIME83A/MEXUM/in3.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 1
3 | 1
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/634 Div 3/A/out.txt:
--------------------------------------------------------------------------------
1 | 2
2 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/COOK117A/A/in3.txt:
--------------------------------------------------------------------------------
1 | 1
2 | adefb
3 | bdefa
4 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/GW19MOS/D/in.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 0 0
3 | 1 0
4 | 0 1
5 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/LTIME83A/MEXUM/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 4
3 | 1 2 3 4
4 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/LTIME83A/MEXUM/in5.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 6
3 | 1 1 1 2 2 3
--------------------------------------------------------------------------------
/Problem Solutions/CodeJam/2020/Round 1B/Expogo/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 7 10
3 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/643 Div 2/C/in1.txt:
--------------------------------------------------------------------------------
1 | 1 2 3 4
2 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/643 Div 2/C/in2.txt:
--------------------------------------------------------------------------------
1 | 1 2 2 5
2 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/643 Div 2/D/in1.txt:
--------------------------------------------------------------------------------
1 | 3 7
2 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/643 Div 2/D/in2.txt:
--------------------------------------------------------------------------------
1 | 3 4
2 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/643 Div 2/D/in3.txt:
--------------------------------------------------------------------------------
1 | 3 8
2 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/B/in1.txt:
--------------------------------------------------------------------------------
1 | 103
2 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/D/in.txt:
--------------------------------------------------------------------------------
1 | 5 7 4
2 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC167/D/in3.txt:
--------------------------------------------------------------------------------
1 | 2 4
2 | 2 1
3 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/D/in1.txt:
--------------------------------------------------------------------------------
1 | 24
2 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/D/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/D/in3.txt:
--------------------------------------------------------------------------------
1 | 64
2 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/RC122020/RECNDROT/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 4
3 | 1 3 4 2
4 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/RC122020/RECNDROT/in3:
--------------------------------------------------------------------------------
1 | 1
2 | 5
3 | 4 3 2 4 1
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/635 Div 2/C/in5.txt:
--------------------------------------------------------------------------------
1 | 2 1
2 | 1 2
3 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/641 Div 2/C/in3.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 1 1
3 |
--------------------------------------------------------------------------------
/Problem Solutions/Geeksforgeeks/21_Days_Challenge/1-Maths/maximum_squares.cpp:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/A/in2.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 5 7
3 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/B/in3.txt:
--------------------------------------------------------------------------------
1 | 1333333333
2 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/D/in2.txt:
--------------------------------------------------------------------------------
1 | 11 10 9
2 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC167/D/in.txt:
--------------------------------------------------------------------------------
1 | 4 5
2 | 3 2 4 1
3 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/C/in1.txt:
--------------------------------------------------------------------------------
1 | 198 1.10
2 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/C/in2.txt:
--------------------------------------------------------------------------------
1 | 1 0.01
2 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/D/in4.txt:
--------------------------------------------------------------------------------
1 | 1000000007
2 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/COOK117A/A/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | adefbadefb
3 | bdefabdefa
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/637 Div 2/D/in.txt:
--------------------------------------------------------------------------------
1 | 1 7
2 | 0000000
3 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/641 Div 2/C/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 10 24 40 80
3 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/641 Div 2/C/in4.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 199999 199967
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/A/in1.txt:
--------------------------------------------------------------------------------
1 | 7
2 | 500 600
3 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/A/in3.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 11 11
3 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/D/in5.txt:
--------------------------------------------------------------------------------
1 | 997764507000
2 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/LTIME83A/MEXUM/in.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 2
3 | 1 1
4 | 3
5 | 1 2 1
6 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/638 Div 2 Virtual/A/in.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 2
3 | 4
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/634 Div 3/C/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 5
3 | 1 1 1 1 1
4 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/B/in2.txt:
--------------------------------------------------------------------------------
1 | 1000000000000000000
2 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/C/in3.txt:
--------------------------------------------------------------------------------
1 | 10 10 1
2 | 1 10 9 1
3 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/E/in1.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 1 2
3 | 2 3
4 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/RC122020/RECNDSTR/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | a
3 | ab
4 | abcd
5 | aaaaa
6 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/633 Div 2 Virtual/C/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 3
3 | 14 10 9
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/635 Div 2/C/in2.txt:
--------------------------------------------------------------------------------
1 | 4 1
2 | 1 2
3 | 1 3
4 | 2 4
5 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/637 Div 2/D/in2.txt:
--------------------------------------------------------------------------------
1 | 2 5
2 | 0010010
3 | 0010010
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/641 Div 2/A/in.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 5 1
3 | 8 2
4 | 3 4
5 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/643 Div 2/C/in3.txt:
--------------------------------------------------------------------------------
1 | 500000 500000 500000 500000
2 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/641 Div 3/C/in.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 1
3 | 5
4 | 499993
5 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/A/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 1 1
3 | 10 100
4 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/C/in3.txt:
--------------------------------------------------------------------------------
1 | 1000000000000000 9.99
2 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/LTIME83A/HXR/in.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 3 2
3 | 1 2 3
4 | 1 2
5 | 2 3
6 | 1 3
7 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/LTIME83A/SHUFFLE/in.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 4 1
3 | 1 4 2 3
4 | 4 2
5 | 1 4 2 3
6 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/RC122020/RECNDNUM/in.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 0 1
3 | 1 1
4 | 2 1
5 | 1 3
6 | 4 6
7 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/RC122020/RECNDNUM/in2.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 1 1
3 | 1 2
4 | 1 3
5 | 1 4
6 | 1 5
7 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeJam/2020/Round 1A/PatternMatching/in3.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | CO*DE
4 | C*EDE
5 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeJam/2020/Round 1B/Expogo/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 2 3
3 | -2 -3
4 | 3 0
5 | -1 1
6 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/621 Div 2 Virtual/B/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 1 1000000000
3 | 1
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/636 Div 3/B/in.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 2
3 | 4
4 | 6
5 | 8
6 | 10
7 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/636 Div 3/D/in3.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 8 7
3 | 6 1 1 7 6 3 4 6
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 4 Rounds/640 Div 4/F/in2.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 0 0 1
3 | 0 1 0
4 | 1 0 0
5 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 4 Rounds/640 Div 4/F/in3.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 0 2 0
3 | 0 0 2
4 | 2 0 0
5 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/D/in1.txt:
--------------------------------------------------------------------------------
1 | 4 3
2 | 1 2 2 3
3 | 4 1 1
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/D/in3.txt:
--------------------------------------------------------------------------------
1 | 5 1
2 | 1 1 1 1 1
3 | 5
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/D/in4.txt:
--------------------------------------------------------------------------------
1 | 5 1
2 | 1 1 1 1 1
3 | 1
4 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC167/D/in2.txt:
--------------------------------------------------------------------------------
1 | 6 727202214173249351
2 | 6 5 2 5 3 2
3 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/COOK117A/A/in.txt:
--------------------------------------------------------------------------------
1 | 1
2 | aabbccddeeffgghhiiii
3 | aacccceeeeefffffffij
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/637 Div 2/C/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 10
3 | 10 6 7 8 9 4 5 1 2 3
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/638 Div 2 Virtual/C/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 10 3
3 | aaaaaaaaaa
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/641 Div 3/D/in.txt:
--------------------------------------------------------------------------------
1 | 6
2 | 1
3 | 2
4 | 3
5 | 4
6 | 5
7 | 6
8 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/B/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 00
3 | 01
4 | 111
5 | 110
6 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/D/in5.txt:
--------------------------------------------------------------------------------
1 | 5 5
2 | 1 2 3 4 5
3 | 1 1 1 1 1
4 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/D/in6.txt:
--------------------------------------------------------------------------------
1 | 5 5
2 | 1 2 3 4 5
3 | 5 5 5 1 1
4 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/RC122020/RECNDROT/in.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 2
3 | 2 1
4 | 2
5 | 1 2
6 | 5
7 | 1 3 2 1 2
8 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/RC122020/RECNDROT/in4.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 7
3 | 3 4 6 5 7 1 2
4 | 7
5 | 3 4 6 5 7 1 2
6 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/637 Div 2/D/in3.txt:
--------------------------------------------------------------------------------
1 | 3 5
2 | 0100001
3 | 1001001
4 | 1010011
5 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/645 Div 2/A/in1.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 1 1
3 | 1 3
4 | 2 2
5 | 3 3
6 | 5 3
7 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/634 Div 3/B/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 7 5 3
3 | 6 1 1
4 | 6 6 1
5 | 5 2 2
6 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 4 Rounds/640 Div 4/A/in.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 5009
3 | 7
4 | 9876
5 | 10000
6 | 10
7 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 4 Rounds/640 Div 4/G/in2.txt:
--------------------------------------------------------------------------------
1 | 6
2 | 10
3 | 2
4 | 4
5 | 6
6 | 7
7 | 13
8 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/A/in.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 1 3
3 | 391 555
4 | 0 0
5 | 9 4
6 |
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Check Odd or Even/README.md:
--------------------------------------------------------------------------------
1 | # Check Odd or Even
2 | Check if the given number is odd or even
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC167/C/in.txt:
--------------------------------------------------------------------------------
1 | 3 3 10
2 | 60 2 2 4
3 | 70 8 7 9
4 | 50 2 3 9
5 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC167/C/in2.txt:
--------------------------------------------------------------------------------
1 | 3 3 10
2 | 100 3 1 4
3 | 100 1 5 9
4 | 100 2 6 5
5 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/635 Div 2/C/in.txt:
--------------------------------------------------------------------------------
1 | 7 4
2 | 1 2
3 | 1 3
4 | 1 4
5 | 3 5
6 | 3 6
7 | 4 7
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/641 Div 2/C/in2.txt:
--------------------------------------------------------------------------------
1 | 10
2 | 540 648 810 648 720 540 594 864 972 648
3 |
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Check Power of 2/README.md:
--------------------------------------------------------------------------------
1 | # Check Power of 2
2 | check if given number is a power of 2 or not
--------------------------------------------------------------------------------
/Algorithms/Graphs/KosaRaju-Strongly_Connected_Components/input.txt:
--------------------------------------------------------------------------------
1 | 5 5
2 | 1 0
3 | 2 1
4 | 0 2
5 | 0 3
6 | 3 4
7 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/C/in.txt:
--------------------------------------------------------------------------------
1 | 3 4 3
2 | 1 3 3 100
3 | 1 2 2 10
4 | 2 3 2 10
5 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/E/in2.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 100 100
3 | 10 10000
4 | 1 1000000000
5 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeJam/2020/Round 1A/PatternMatching/in4.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 2
3 | A*C*E
4 | *B*D*
5 | 2
6 | **Q**
7 | *A*
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/633 Div 2 Virtual/B/in.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 6
3 | 5 -2 4 8 6 5
4 | 4
5 | 8 1 4 2
6 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/645 Div 2/C/in2.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 1 1 5 5
3 | 1 1 6 6
4 | 1 1 4 7
5 | 1 1 7 4
6 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/D/in2.txt:
--------------------------------------------------------------------------------
1 | 6 10
2 | 5 8 1 10 8 7
3 | 6 6 4 4 3 2 2 2 1 1
4 |
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Check ith bit/README.md:
--------------------------------------------------------------------------------
1 | # Check ith Bit
2 | Check the ith bit of a given number
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Convert Number to Binary/README.md:
--------------------------------------------------------------------------------
1 | # Convert Number to Binary
2 | Convert the given integer to binary
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Flip ith bit/README.md:
--------------------------------------------------------------------------------
1 | # Flip ith bit
2 | Flip the ith bit of a given number.
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/LTIME83A/MEXUM/in4.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 10
3 | 1 2 4 4 4 5 6 7 8 9
4 | 4
5 | 1 2 5 6
6 | 6
7 | 1 1 1 2 2 3
--------------------------------------------------------------------------------
/Problem Solutions/CodeJam/2020/Round 1A/PatternMatching/in2.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 5
3 | A*B
4 | AA*BB
5 | AAB*BBB
6 | A*BB
7 | AA*B
8 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeJam/2020/Round 1C/A/in.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 4 4 SSSS
3 | 3 0 SNSS
4 | 2 10 NSNNSN
5 | 0 1 S
6 | 2 7 SSSSSSSS
7 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Discord Bot Random/in.txt:
--------------------------------------------------------------------------------
1 | 5 5 4 3
2 | 1 2 4 3 2
3 | 1 2
4 | 2 3
5 | 3 4
6 | 4 1
7 | 4 5
8 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/635 Div 2/C/in4.txt:
--------------------------------------------------------------------------------
1 | 8 3
2 | 7 5
3 | 1 7
4 | 6 1
5 | 3 7
6 | 8 3
7 | 2 1
8 | 4 5
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/634 Div 3/A/in.txt:
--------------------------------------------------------------------------------
1 | 6
2 | 7
3 | 1
4 | 2
5 | 3
6 | 2000000000
7 | 763243547
8 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/RC122020/RECNDNOS/in.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 5
3 | 1 2 2 1 2
4 | 6
5 | 1 1 1 1 1 1
6 | 8
7 | 1 2 2 2 3 4 2 1
8 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/RC122020/RECNDNUM/in3.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 0 1000
3 | 1 1000
4 | 2 1000
5 | 3 1000
6 | 4 1000
7 | 5 1000
8 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/621 Div 2 Virtual/A/in.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 4 5
3 | 1 0 3 2
4 | 2 2
5 | 100 1
6 | 1 8
7 | 0
8 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/633 Div 2 Virtual/C/in.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 4
3 | 1 7 6 5
4 | 5
5 | 1 2 3 4 5
6 | 2
7 | 0 -4
8 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/635 Div 2/C/in3.txt:
--------------------------------------------------------------------------------
1 | 8 5
2 | 7 5
3 | 1 7
4 | 6 1
5 | 3 7
6 | 8 3
7 | 2 1
8 | 4 5
9 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/645 Div 2/C/in1.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 1 1 2 2
3 | 1 2 2 4
4 | 179 1 179 100000
5 | 5 7 5 7
6 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/636 Div 3/A/in.txt:
--------------------------------------------------------------------------------
1 | 7
2 | 3
3 | 6
4 | 7
5 | 21
6 | 28
7 | 999999999
8 | 999999984
9 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Southern and Volga Russia Qualifier 2019-2020/info:
--------------------------------------------------------------------------------
1 | Added some soltions to a contest in cf gym
2 |
--------------------------------------------------------------------------------
/Algorithms/Recursion/Chess.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sahilbansal17/Competitive_Coding/HEAD/Algorithms/Recursion/Chess.java
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/GW19MOS/C/in.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 3 3
3 | 1 1 1
4 | 2 2 2
5 | 3 3 3
6 | 3 4
7 | 1 1 4
8 | 2 2 2
9 | 3 3 3
10 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 4 Rounds/640 Div 4/F/in.txt:
--------------------------------------------------------------------------------
1 | 7
2 | 1 3 5
3 | 1 1 1
4 | 3 9 3
5 | 0 1 0
6 | 3 1 2
7 | 0 0 3
8 | 2 0 0
9 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/643 Div 2/B/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 3
3 | 1 1 1
4 | 5
5 | 2 3 1 2 2
6 | 7
7 | 10 2 2 2 2 2 2
8 | 4
9 | 2 2 1 1
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/641 Div 3/A/in.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 1 100
3 | 2 2
4 | 5 5
5 | 2 1000000000
6 | 1000000000 1000000000
7 |
8 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 4 Rounds/640 Div 4/C/in.txt:
--------------------------------------------------------------------------------
1 | 6
2 | 3 7
3 | 4 12
4 | 2 1000000000
5 | 7 97
6 | 1000000000 1000000000
7 | 2 1
8 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 4 Rounds/640 Div 4/G/in.txt:
--------------------------------------------------------------------------------
1 | 10
2 | 1
3 | 2
4 | 3
5 | 4
6 | 5
7 | 6
8 | 7
9 | 8
10 | 9
11 | 10
12 |
--------------------------------------------------------------------------------
/Algorithms/Dynamic-Programming/LBS.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sahilbansal17/Competitive_Coding/HEAD/Algorithms/Dynamic-Programming/LBS.java
--------------------------------------------------------------------------------
/Algorithms/Dynamic-Programming/MPC.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sahilbansal17/Competitive_Coding/HEAD/Algorithms/Dynamic-Programming/MPC.java
--------------------------------------------------------------------------------
/Algorithms/Trees/Binary tree/isBST.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sahilbansal17/Competitive_Coding/HEAD/Algorithms/Trees/Binary tree/isBST.java
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/GW19MOS/B/in.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 3
3 | 1 100 3
4 | 10
5 | 1
6 | 2
7 | 3
8 | 4
9 | 5
10 | 6
11 | 7
12 | 8
13 | 9
14 | 10
--------------------------------------------------------------------------------
/Data Structures/Linked-Lists/SumLists.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sahilbansal17/Competitive_Coding/HEAD/Data Structures/Linked-Lists/SumLists.java
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/621 Div 2 Virtual/B/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 2 4
3 | 1 3
4 | 3 12
5 | 3 4 5
6 | 1 5
7 | 5
8 | 2 10
9 | 15 4
10 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/635 Div 2/A/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 1 3 5 7
3 | 1 5 5 7
4 | 100000 200000 300000 400000
5 | 1 1 977539810 977539810
6 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/635 Div 2/B/in.txt:
--------------------------------------------------------------------------------
1 | 7
2 | 100 3 4
3 | 189 3 4
4 | 64 2 3
5 | 63 2 3
6 | 30 27 7
7 | 10 9 1
8 | 69117 21 2
9 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/641 Div 2/B/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 4
3 | 5 3 4 6
4 | 7
5 | 1 4 2 3 6 4 9
6 | 5
7 | 5 4 3 2 1
8 | 1
9 | 9
10 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/634 Div 3/C/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 7
3 | 4 2 4 1 4 3 4
4 | 5
5 | 2 1 5 4 3
6 | 1
7 | 1
8 | 4
9 | 1 1 1 3
10 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/636 Div 3/D/in2.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 2 1
3 | 1 1
4 | 18 100
5 | 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 5 5
6 | 4 2
7 | 1 1 1 2
--------------------------------------------------------------------------------
/Data Structures/Linked-Lists/Palindrome.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sahilbansal17/Competitive_Coding/HEAD/Data Structures/Linked-Lists/Palindrome.java
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/LTIME83A/TRIQRY/in.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 6 3
3 | 1 2
4 | 14 7
5 | 6 3
6 | 8 7
7 | 11 10
8 | 14 2
9 | 0 10
10 | 2 12
11 | 11 21
12 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeJam/2020/Round 1C/C/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 1 3
3 | 1
4 | 5 2
5 | 10 5 359999999999 123456789 10
6 | 2 3
7 | 8 4
8 | 3 2
9 | 1 2 3
10 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 4 Rounds/640 Div 4/B/in.txt:
--------------------------------------------------------------------------------
1 | 8
2 | 10 3
3 | 100 4
4 | 8 7
5 | 97 2
6 | 8 8
7 | 3 10
8 | 5 3
9 | 1000000000 9
10 |
--------------------------------------------------------------------------------
/Problem Solutions/Interviewbit/Bit Manipulation/Number of 1 Bits.cpp:
--------------------------------------------------------------------------------
1 | int Solution::numSetBits(unsigned int A) {
2 | return __builtin_popcount(A);
3 | }
--------------------------------------------------------------------------------
/Data Structures/Linked-Lists/Intersection.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sahilbansal17/Competitive_Coding/HEAD/Data Structures/Linked-Lists/Intersection.java
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/638 Div 2 Virtual/B/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 4 2
3 | 1 2 2 1
4 | 4 3
5 | 1 2 2 1
6 | 3 2
7 | 1 2 3
8 | 4 4
9 | 4 3 4 2
10 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/643 Div 2/A/in.txt:
--------------------------------------------------------------------------------
1 | 8
2 | 1 4
3 | 487 1
4 | 487 2
5 | 487 3
6 | 487 4
7 | 487 5
8 | 487 6
9 | 487 123712084
10 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/645 Div 2/B/in1.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 5
3 | 1 1 2 2 1
4 | 6
5 | 2 3 4 5 6 7
6 | 6
7 | 1 5 4 5 1 9
8 | 5
9 | 1 2 3 5 6
10 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/C/in.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 4 6 5
3 | 1 1
4 | 1 3
5 | 1 5
6 | 1 7
7 | 1 9
8 | 7 10 2
9 | 7 8
10 | 100 200
11 |
--------------------------------------------------------------------------------
/Algorithms/Dynamic-Programming/min_steps_to_1.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sahilbansal17/Competitive_Coding/HEAD/Algorithms/Dynamic-Programming/min_steps_to_1.cpp
--------------------------------------------------------------------------------
/Data Structures/Linked-Lists/DeleteMiddleNode.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sahilbansal17/Competitive_Coding/HEAD/Data Structures/Linked-Lists/DeleteMiddleNode.java
--------------------------------------------------------------------------------
/Problem Solutions/CodeJam/2020/Round 1A/PatternMatching/in.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 5
3 | *CONUTS
4 | *COCONUTS
5 | *OCONUTS
6 | *CONUTS
7 | *S
8 | 2
9 | *XZ
10 | *XYZ
11 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/635 Div 2/C/in_counter_2.txt:
--------------------------------------------------------------------------------
1 | 11 3
2 | 1 2
3 | 1 3
4 | 1 4
5 | 2 5
6 | 5 8
7 | 3 6
8 | 6 9
9 | 9 10
10 | 10 11
11 | 4 7
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/637 Div 2/C/in.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 5
3 | 2 3 4 5 1
4 | 1
5 | 1
6 | 3
7 | 1 3 2
8 | 4
9 | 4 2 3 1
10 | 5
11 | 1 5 2 4 3
12 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/636 Div 3/D/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 4 2
3 | 1 2 1 2
4 | 4 3
5 | 1 2 2 1
6 | 8 7
7 | 6 1 1 7 6 3 4 6
8 | 6 6
9 | 5 2 6 1 3 4
10 |
--------------------------------------------------------------------------------
/Problem Solutions/Interviewbit/Math/Greatest Common Divisor.cpp:
--------------------------------------------------------------------------------
1 | int Solution::gcd(int A, int B) {
2 | if (B == 0) {
3 | return A;
4 | }
5 | return gcd(B, A % B);
6 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 4 Rounds/640 Div 4/E/in.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 9
3 | 3 1 4 1 5 9 2 6 5
4 | 3
5 | 1 1 2
6 | 5
7 | 1 1 1 1 1
8 | 8
9 | 8 7 6 5 4 3 2 1
10 | 1
11 | 1
12 |
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Dynamic Programming/877-stone-game.cpp:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public:
3 | bool stoneGame(vector& piles) {
4 | return true;
5 | }
6 | };
--------------------------------------------------------------------------------
/Algorithms/String-Processing/LongestRepeatedSubsequence.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sahilbansal17/Competitive_Coding/HEAD/Algorithms/String-Processing/LongestRepeatedSubsequence.java
--------------------------------------------------------------------------------
/Problem Solutions/CodeJam/2019/Round 2/New Elements: Part 2/in.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 3
3 | 1 1
4 | 1 2
5 | 2 1
6 | 4
7 | 1 2
8 | 2 1
9 | 4 2
10 | 2 4
11 | 3
12 | 1 2
13 | 1 3
14 | 2 3
15 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/634 Div 3/E/in.txt:
--------------------------------------------------------------------------------
1 | 6
2 | 8
3 | 1 1 2 2 3 2 1 1
4 | 3
5 | 1 3 3
6 | 4
7 | 1 10 10 1
8 | 1
9 | 26
10 | 2
11 | 2 1
12 | 3
13 | 1 1 1
14 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/638 Div 2 Virtual/C/in.txt:
--------------------------------------------------------------------------------
1 | 6
2 | 4 2
3 | baba
4 | 5 2
5 | baacb
6 | 5 3
7 | baacb
8 | 5 3
9 | aaaaa
10 | 6 4
11 | aaxxzz
12 | 7 1
13 | phoenix
14 |
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Turn Off First Set Bit/README.md:
--------------------------------------------------------------------------------
1 | # Turn Off First Set Bit
2 | You are given an integer Ni. You need to make first set bit of binary representation of N to 0 and return the updated N.
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/634 Div 3/D/in.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 154873296
3 | 386592714
4 | 729641835
5 | 863725149
6 | 975314628
7 | 412968357
8 | 631457982
9 | 598236471
10 | 247189563
11 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/635 Div 2/C/in_counter.txt:
--------------------------------------------------------------------------------
1 | 15 5
2 | 1 2
3 | 2 3
4 | 1 4
5 | 4 5
6 | 5 6
7 | 6 7
8 | 7 8
9 | 8 9
10 | 9 10
11 | 10 11
12 | 11 12
13 | 12 13
14 | 12 14
15 | 12 15
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/636 Div 3/C/in.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 5
3 | 1 2 3 -1 -2
4 | 4
5 | -1 -2 -1 -3
6 | 10
7 | -2 8 3 8 -4 -15 5 -2 -3 1
8 | 6
9 | 1 -1000000000 1 -1000000000 1 -1000000000
10 |
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Flip ith bit/flip.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int main(){
4 | int n, i;
5 | cin >> n >> i;
6 | n = n ^ (1<
2 | using namespace std;
3 |
4 | int main () {
5 |
6 | int a, b;
7 | cin >> a >> b;
8 | cout << "X = " << (a + b) << endl;
9 |
10 | return 0;
11 | }
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Check Odd or Even/check.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int main(){
4 | int n;
5 | cin >> n;
6 | if(n&1) cout << "odd";
7 | else cout << "even";
8 | return 0;
9 | }
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Return First Set Bit/README.md:
--------------------------------------------------------------------------------
1 | # Return First Set Bit
2 | You are given an integer N. You need to return an integer M, in which only one bit is set which at position of lowest set bit of N (from right to left).
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/637 Div 2/B/in.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 8 6
3 | 1 2 4 1 2 4 1 2
4 | 5 3
5 | 3 2 3 2 1
6 | 10 4
7 | 4 3 4 3 2 3 2 1 0 1
8 | 15 7
9 | 3 7 4 8 2 3 4 5 21 2 3 4 2 1 3
10 | 7 5
11 | 1 2 3 4 5 6 1
12 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/641 Div 3/B/in.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 2 1
3 | 1 2
4 | 3 4
5 | 5 5
6 | 5 5 6 6 5
7 | 1 2 5 4 3
8 | 5 3
9 | 1 2 3 4 5
10 | 10 9 10 10 9
11 | 4 0
12 | 2 2 4 3
13 | 2 4 2 3
14 | 4 4
15 | 1 2 2 1
16 | 4 4 5 4
17 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 4 Rounds/640 Div 4/D/in.txt:
--------------------------------------------------------------------------------
1 | 7
2 | 11
3 | 3 1 4 1 5 9 2 6 5 3 5
4 | 1
5 | 1000
6 | 3
7 | 1 1 1
8 | 13
9 | 1 2 3 4 5 6 7 8 9 10 11 12 13
10 | 2
11 | 2 1
12 | 6
13 | 1 1 1 1 1 1
14 | 7
15 | 1 1 1 1 1 1 1
16 |
--------------------------------------------------------------------------------
/Problem Solutions/Interviewbit/Bit Manipulation/Single Number.cpp:
--------------------------------------------------------------------------------
1 | int Solution::singleNumber(const vector &A) {
2 | int res = 0;
3 | int n = A.size();
4 | for (int i = 0; i < n; ++i) {
5 | res ^= A[i];
6 | }
7 | return res;
8 | }
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/C/in2.txt:
--------------------------------------------------------------------------------
1 | 4 6 10
2 | 2 4 1 86568
3 | 1 4 0 90629
4 | 2 3 0 90310
5 | 3 4 1 29211
6 | 3 4 3 78537
7 | 3 4 2 8580
8 | 1 2 1 96263
9 | 1 4 2 2156
10 | 1 2 0 94325
11 | 1 4 3 94328
12 |
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Turn Off ith bit/README.md:
--------------------------------------------------------------------------------
1 | # Turn Off ith bit
2 | You are given two integers N and i. You need to make ith bit of binary representation of N to 0 and return the updated N.
3 | Counting of bits start from 0 from right to left.
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Turn On ith bit/README.md:
--------------------------------------------------------------------------------
1 | # Turn On ith bit
2 | You are given two integers N and i. You need to make ith bit of binary representation of N to 1 and return the updated N.
3 | Counting of bits start from 0 from right to left.
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/281A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main(void){
5 | char c;
6 | cin>>c;
7 | c = toupper(c);
8 | cout<>c)
10 | cout<
2 | using namespace std;
3 |
4 | int main() {
5 | int n;cin>>n;
6 | while(n!=0){
7 | cout<<((n*(n+1)*(2*n+1))/6)<>n;
9 | }
10 | return 0;
11 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/635 Div 2/D/in.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 2 2 3
3 | 7 8
4 | 6 3
5 | 3 1 4
6 | 1 1 1
7 | 1
8 | 1
9 | 1000000000
10 | 2 2 2
11 | 1 2
12 | 5 4
13 | 6 7
14 | 2 2 2
15 | 1 2
16 | 3 4
17 | 6 7
18 | 3 4 1
19 | 3 2 1
20 | 7 3 3 4
21 | 6
22 |
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Clear All Bits from MSB/README.md:
--------------------------------------------------------------------------------
1 | # Clear all bits from MSB
2 | You are given two integers N and i. You need to clear all bits from MSB to ith bit (start i from right to left) and return the updated N.
3 | Counting of bits start from 0 from right to left.
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Check ith bit/check_ith_bit.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int main(){
4 | int n, i;
5 | cin >> n >> i;
6 | if(n & (1<<(i-1)))
7 | cout << 1;
8 | else
9 | cout << 0;
10 | return 0;
11 | }
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Return First Set Bit/solution.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int returnFirstSetBit(int n){
4 | return (n&-n);
5 | }
6 | int main() {
7 | int n;
8 | cin >> n;
9 | cout<< returnFirstSetBit(n) <
2 | using namespace std;
3 |
4 | int main() {
5 | int n;cin>>n;
6 | int count=0;
7 | for(int i=1;i<=n;i++){
8 | for(int j=i;j<=n/i;j++){
9 | count++;
10 | }
11 | }
12 | cout<
2 | using namespace std;
3 | int turnOffFirstSetBit(int n){
4 | return n-(n&-n);
5 | }
6 | int main() {
7 | int n;
8 | cin >> n;
9 | cout<< turnOffFirstSetBit(n) < &A) {
2 | int n = A.size();
3 | int res = INT_MAX;
4 | sort(A.begin(), A.end());
5 | for (int i = 0; i < n - 1; ++i) {
6 | res = min(res, A[i] ^ A[i + 1]);
7 | }
8 | return res;
9 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/791A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int main(){
4 |
5 | int a,b,count=0;
6 | cin>>a>>b;
7 | while(a<=b){
8 | a = a*3;
9 | b = b*2;
10 | count++;
11 | }
12 | cout<
2 | #include
3 |
4 | using namespace std;
5 |
6 | int main() {
7 |
8 | double raio, n = 3.14159;
9 | cin >> raio;
10 | double saida = n * pow(raio, 2);
11 | printf("A=%.4f", saida);
12 | cout << endl;
13 | return 0;
14 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/4A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main(void){
5 | int w;
6 | cin>>w;
7 | if(w > 2){
8 | if(w % 2 == 0){
9 | cout<<"YES";
10 | }
11 | else{
12 | cout<<"NO";
13 | }
14 | }
15 | else{
16 | cout<<"NO";
17 | }
18 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/PRACTICE/EID.py:
--------------------------------------------------------------------------------
1 | t = int(input())
2 |
3 | for _ in range(t):
4 | n = int(input())
5 | nums = list(map(int, input().split()))
6 | nums = sorted(nums)
7 | res = nums[1] - nums[0]
8 | for i in range(1, n - 1):
9 | res = min(res, nums[i + 1] - nums[i])
10 | print(res)
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/50A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main(void){
5 | int m,n;
6 | cin>>m>>n;
7 | int dominoes = 0;
8 | if(n >= 2){
9 | dominoes = m*(n/2) + ((n - 2*(n/2)) * m)/2;
10 | }
11 | else{
12 | dominoes = m/2;
13 | }
14 | cout<
2 | using namespace std;
3 | int clearAllBits(int n, int i){
4 | int mask = (1<> n >> i;
10 | cout<< clearAllBits(n, i) <
2 | using namespace std;
3 |
4 | int main(void){
5 | int n;
6 | cin>>n;
7 | string s;
8 | cin>>s;
9 | int count = 0;
10 | for(int i = 0; i < n; i ++){
11 | if(s[i] == s[i+1])
12 | count ++;
13 | }
14 | cout< ar) {
2 | unordered_map cnt;
3 | for (int i = 0; i < n; ++i) {
4 | ++cnt[ar[i]];
5 | }
6 | int res = 0;
7 | for (auto val : cnt) {
8 | res += (val.second) / 2;
9 | }
10 | return res;
11 | }
--------------------------------------------------------------------------------
/Problem Solutions/HackerEarth/Month Easy Contests/MAY 19/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main() {
5 | int t;
6 | cin >> t;
7 |
8 | int n;
9 | for (int i = 0; i < t; i ++) {
10 | cin >> n;
11 |
12 | cout << (n - 2)/4 + 1 << endl;
13 | }
14 | return 0;
15 | }
16 |
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Dynamic Programming/338-counting-bits.cpp:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public:
3 | vector countBits(int num) {
4 | vector setBits(num + 1, 0);
5 | for (int i = 1; i <= num; ++i) {
6 | setBits[i] = (i & 1) ? 1 + setBits[i/2] : setBits[i/2];
7 | }
8 | return setBits;
9 | }
10 | };
--------------------------------------------------------------------------------
/Problem Solutions/URI/1015.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using namespace std;
5 |
6 | int main() {
7 |
8 | float x1, y1, x2, y2;
9 | cin >> x1 >> y1;
10 | cin >> x2 >> y2;
11 | float saida = sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2));
12 | printf("%.4f", saida);
13 | cout << endl;
14 | return 0;
15 | }
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Turn Off ith bit/turn_off_ith_bit.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int turnOffIthBit(int n, int i){
4 | if(n & (1<> n >> i;
12 | cout<< turnOffIthBit(n, i) <
2 | using namespace std;
3 | int turnOnIthBit(int n, int i){
4 | if(n & (1<> n >> i;
12 | cout<< turnOnIthBit(n, i) <
2 | using namespace std;
3 |
4 | int main(void){
5 | int n;
6 | cin>>n;
7 | while(n--){
8 | string s;
9 | cin>>s;
10 | if(s.size() > 10){
11 | cout<
2 |
3 | int main()
4 | {
5 | int n;
6 | scanf("%d", &n);
7 | if (n > 85) {
8 | printf("A\n");
9 | } else if (n > 60) {
10 | printf("B\n");
11 | } else if (n > 35) {
12 | printf("C\n");
13 | } else {
14 | printf("D\n");
15 | }
16 |
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC151/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 |
6 | int main() {
7 |
8 | FAST_IO;
9 |
10 | char ch;
11 | cin >> ch;
12 |
13 | ++ch;
14 | cout << ch << endl;
15 |
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/Problem Solutions/HackerRank/Interview Preparation Kit/Warm-Up/Counting Valleys.cpp:
--------------------------------------------------------------------------------
1 | int countingValleys(int n, string s) {
2 | int cur = 0;
3 | int res = 0;
4 | for (int i = 0; i < n; ++i) {
5 | if (s[i] == 'U') {
6 | ++cur;
7 | if (cur == 0) {
8 | ++res;
9 | }
10 | } else {
11 | --cur;
12 | }
13 | }
14 | return res;
15 | }
16 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/PRACTICE/AVG.py:
--------------------------------------------------------------------------------
1 | t = int(input())
2 |
3 | for _ in range(t):
4 | l = input().split()
5 | n = int(l[0])
6 | k = int(l[1])
7 | v = int(l[2])
8 | nums = map(int, input().split())
9 | tot = sum(nums)
10 | rem = (n+k)*v - tot
11 | if (rem > 0 and rem % k == 0):
12 | print(rem//k)
13 | else:
14 | print(-1)
15 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/PRACTICE/CHGM1.py:
--------------------------------------------------------------------------------
1 | t = int(input())
2 | for _ in range(t):
3 | n = int(input())
4 | nums = list(map(int, input().split()))
5 | ans = -1000000
6 | cur = 0
7 | for i in range(0, len(nums)):
8 | cur += nums[i]
9 | if (cur > ans):
10 | ans = cur
11 | if (cur < 0):
12 | cur = 0
13 | print(ans)
--------------------------------------------------------------------------------
/Problem Solutions/Interviewbit/Math/Palindrome Integer.cpp:
--------------------------------------------------------------------------------
1 | int Solution::isPalindrome(int A) {
2 | if (A < 0) {
3 | return 0;
4 | }
5 | int reverse = 0;
6 | int copyOfA = A;
7 | while (A) {
8 | int rem = A % 10;
9 | reverse *= 10;
10 | reverse += rem;
11 | A /= 10;
12 | }
13 | if (reverse == copyOfA) {
14 | return 1;
15 | }
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/PRACTICE/CPAIRS.py:
--------------------------------------------------------------------------------
1 | t = int(input())
2 |
3 | for _ in range(t):
4 | n = int(input())
5 | nums = list(map(int, input().split()))
6 | count_odd = 0
7 | res = 0
8 | for i in range(n - 1, 0, -1):
9 | if (nums[i] & 1):
10 | count_odd += 1
11 | if (not(nums[i - 1] & 1)):
12 | res += count_odd
13 | print(res)
--------------------------------------------------------------------------------
/Algorithms/Computational-Geometry/Convex-Hull/convex_hull_jarvis.cpp:
--------------------------------------------------------------------------------
1 | // https://practice.geeksforgeeks.org/problems/convex-hull/0
2 | // https://www.geeksforgeeks.org/convex-hull-set-1-jarviss-algorithm-or-wrapping/
3 |
4 | // C++ code to implement Convex Hull: Jarivs algorithm
5 |
6 | #include
7 | using namespace std;
8 |
9 | int main () {
10 |
11 |
12 | return 0;
13 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Kotlin/Kotlin Heroes: Practice 4/A+B.kt:
--------------------------------------------------------------------------------
1 | import java.util.Scanner
2 |
3 | fun add(a: Int, b: Int) : Int {
4 | return a+b
5 | }
6 |
7 | fun main() {
8 | val reader = Scanner(System.`in`)
9 | val testcases = reader.nextInt()
10 | for (i in 1..testcases) {
11 | val a = reader.nextInt()
12 | val b = reader.nextInt()
13 | println(add(a, b))
14 | }
15 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/96A.py:
--------------------------------------------------------------------------------
1 | # take the string as input
2 | s = input()
3 |
4 | # if we find a substring '1111111' or '0000000' in s, then print 'YES' otherwise 'NO'
5 | # in otherwise if we don't find any of these, print 'NO' otherwise 'YES'
6 | seven1 = '1111111'
7 | seven0 = '0000000'
8 | if(s.find(seven1) == -1 and s.find(seven0) == -1):
9 | print("NO")
10 | else:
11 | print("YES")
--------------------------------------------------------------------------------
/Problem Solutions/Interviewbit/Hashing/Diffk II.cpp:
--------------------------------------------------------------------------------
1 | int Solution::diffPossible(const vector &A, int k) {
2 | int n = A.size();
3 | unordered_map cnt;
4 | for (int i = 0; i < n; ++i) {
5 | ++cnt[A[i]];
6 | if (A[i] - k != A[i] && cnt[A[i] - k] > 0) {
7 | return 1;
8 | }
9 | if (A[i] - k == A[i] && cnt[A[i]] > 1) {
10 | return 1;
11 | }
12 | }
13 | return 0;
14 | }
--------------------------------------------------------------------------------
/Problem Solutions/URI/2251.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main()
5 | {
6 | int n, tab[31], c = 1;
7 | for (int i = 0; i < 31; i++) {
8 | tab[i] = pow(2, i) - 1;
9 | }
10 | while (1) {
11 | scanf("%d", &n);
12 | if (!n) {
13 | break;
14 | }
15 | printf("Teste %d\n%d\n\n", c++, tab[n]);
16 | }
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/Algorithms/Computational-Geometry/Lines/line_segments_intersection.cpp:
--------------------------------------------------------------------------------
1 | // https://practice.geeksforgeeks.org/problems/check-if-two-line-segments-intersect/0
2 | // https://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/
3 |
4 | // C++ program to check if two lines segments intersect
5 |
6 | #include
7 | using namespace std;
8 |
9 | int main () {
10 |
11 |
12 |
13 | return 0;
14 | }
15 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/AUG19B/ MSNSADM1.py:
--------------------------------------------------------------------------------
1 | # cook your dish here
2 | test = int(input())
3 | while test:
4 | n = int(input())
5 | a = list(map(int, input().split()))
6 | b = list(map(int, input().split()))
7 | score = []
8 | for i in range(0, n):
9 | k = 20*a[i] - 10*b[i]
10 | score.append(k)
11 | if k < 0:
12 | score[i] = 0
13 | print(max(score))
14 | test -= 1
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/158A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 |
5 | int main(void){
6 | int n, k;
7 | cin>>n>>k;
8 | int array[n];
9 | for(int i = 0;i < n; i ++){
10 | cin>>array[i];
11 | }
12 | int count = 0;
13 | for(int i = 0;i < n; i ++){
14 | if((array[i] >= array[k-1]) && (array[i] > 0)){
15 | count++;
16 | }
17 | }
18 | cout<
2 | using namespace std;
3 |
4 | int main(void){
5 | long long int n, m, a, row;
6 | cin>>n>>m>>a;
7 | long long int rows, cols;
8 | if(n % a == 0){
9 | rows = n/a;
10 | }
11 | else{
12 | rows = n/a + 1;
13 | }
14 | if(m % a == 0){
15 | cols = m/a;
16 | }
17 | else{
18 | cols = m/a + 1;
19 | }
20 | cout<
2 | using namespace std;
3 |
4 | int main(void){
5 | ios_base::sync_with_stdio(false);
6 | cin.tie(NULL);
7 |
8 | int n, m, sum = 0;
9 | cin>>n>>m;
10 | for(int i = 0; i < n; i ++){
11 | int a;
12 | cin>>a;
13 | sum += a;
14 | cout<= m){
17 | sum = sum % m;
18 | }
19 | }
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/231A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main(void){
5 | int n, a, b, c;
6 | cin>>n;
7 | int count = 0;
8 | while(n--){
9 | cin>>a>>b>>c;
10 | if(a == 1 && b == 1)
11 | count ++;
12 | else if( a == 1 && c == 1)
13 | count ++;
14 | else if(b == 1 && c == 1)
15 | count ++;
16 | else
17 | continue;
18 | }
19 | cout<
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | int main() {
6 | FAST_IO;
7 |
8 | int a, b;
9 | cin >> a >> b;
10 |
11 | if (a <= 9 && b <= 9) {
12 | cout << a*b << endl;
13 | return 0;
14 | }
15 | cout << "-1" << endl;
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/CACD2020/PPPR.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 | typedef long long ll;
6 |
7 | int main(){
8 |
9 | FAST_IO;
10 |
11 | ll t;
12 | cin >> t;
13 |
14 | int a, b;
15 | while (t--) {
16 | cin >> a >> b;
17 | cout << "1" << endl;
18 | }
19 |
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC150/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 |
6 | int main() {
7 |
8 | FAST_IO;
9 |
10 | int k, x;
11 | cin >> k >> x;
12 |
13 | if (k*500 >= x) {
14 | cout << "Yes" << endl;
15 | } else {
16 | cout << "No" << endl;
17 | }
18 |
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/196 Div 2/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int main()
4 | {
5 | int n, m, arr[100]={0};
6 | cin>>n>>m;
7 |
8 | for (int i = 0; i < m; ++i)
9 | {
10 | cin>>arr[i];
11 | }
12 |
13 | int result = INT_MAX;
14 |
15 | sort(arr, arr+m);
16 |
17 | for(int i=0;i<=m-n;i++)
18 | {
19 | result = min(result, arr[i+n-1]-arr[i]);
20 | }
21 |
22 | cout<
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 |
6 | int main() {
7 |
8 | FAST_IO;
9 |
10 | int t;
11 | cin >> t;
12 |
13 | while (t--) {
14 | int x;
15 | cin >> x;
16 |
17 | cout << 1 << " " << x - 1 << endl;
18 | }
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/Problem Solutions/Interviewbit/Math/FizzBuzz.cpp:
--------------------------------------------------------------------------------
1 | vector Solution::fizzBuzz(int A) {
2 | vector res;
3 | for (int i = 1; i <= A; ++i) {
4 | if (i % 3 == 0 && i % 5 == 0) {
5 | res.push_back("FizzBuzz");
6 | } else if (i % 3 == 0) {
7 | res.push_back("Fizz");
8 | } else if (i % 5 == 0) {
9 | res.push_back("Buzz");
10 | } else {
11 | res.push_back(to_string(i));
12 | }
13 | }
14 | return res;
15 | }
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Convert Number to Binary/convert.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int convert(int n){
4 | int res = 0;
5 | unsigned int mask = 1<<15;
6 | while(mask > 0){
7 | res *= 10;
8 | if(n & mask) res += 1;
9 | else res += 0;
10 | mask = mask >> 1;
11 | }
12 | return res;
13 | }
14 | int main(){
15 | int n;
16 | cin >> n;
17 | cout << convert(n);
18 | return 0;
19 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/611 Div 3/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 |
9 | int t;
10 | cin >> t;
11 |
12 | int h, m;
13 | while (t--) {
14 | cin >> h >> m;
15 | int cur = h*60 + m;
16 | cout << 24*60 - cur << endl;
17 | }
18 |
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/58A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main(void){
5 | ios_base::sync_with_stdio(false);
6 | cin.tie(NULL);
7 | string s;
8 | cin>>s;
9 | string word = "hello";
10 | int count = 0, j = 0;
11 | for(int i = 0; i < s.size(); i ++){
12 | if(s[i] == word[j]){
13 | j++;
14 | count++;
15 | }
16 | }
17 | if(count == 5)
18 | cout<<"YES";
19 | else
20 | cout<<"NO";
21 | return 0;
22 | }
--------------------------------------------------------------------------------
/Problem Solutions/Interviewbit/Math/Reverse Integer.cpp:
--------------------------------------------------------------------------------
1 | typedef long long ll;
2 | int Solution::reverse(int A) {
3 | bool neg = 0;
4 | if (A < 0) {
5 | neg = 1;
6 | A *= -1;
7 | }
8 | ll reverse = 0;
9 | while (A) {
10 | ll rem = A % 10;
11 | reverse *= 10;
12 | reverse += rem;
13 | A /= 10;
14 | }
15 | if (reverse > 1ll * INT_MAX) {
16 | return 0;
17 | }
18 | if (neg) {
19 | reverse *= -1;
20 | }
21 | return reverse;
22 | }
--------------------------------------------------------------------------------
/Algorithms/Sorting/selection_sort.py:
--------------------------------------------------------------------------------
1 |
2 | def selectionSort(a):
3 | min_index = -1
4 | for i in range(len(a) - 1):
5 | min_index = i;
6 | for j in range(i + 1, len(a)):
7 | if(a[j] < a[min_index]):
8 | min_index = j
9 | a[min_index], a[i] = a[i], a[min_index]
10 | return a
11 |
12 | arr = list(map(int, input("Enter the array elements: ").split()))
13 | print(f"Array before sorting: {arr}")
14 | arr = selectionSort(arr)
15 | print(f"Array after sorting: {arr}")
16 |
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Hashing/771-Jewels-and-Stones.cpp:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public:
3 | int numJewelsInStones(string J, string S) {
4 | unordered_set jewels;
5 | for (auto jewel: J) {
6 | jewels.insert(jewel);
7 | }
8 | int res = 0;
9 | for (auto stone: S) {
10 | if (jewels.find(stone) != jewels.end()) {
11 | ++res;
12 | }
13 | }
14 | return res;
15 | }
16 | };
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/JAN18/KILLKTH.py:
--------------------------------------------------------------------------------
1 | #only for 1st and 2nd subtask
2 | def get_all_substrings(string):
3 | length = len(string)
4 | for i in range(length):
5 | for j in range(i + 1, length + 1):
6 | yield(string[i:j])
7 | a=list(get_all_substrings(input()))
8 | a.sort()
9 | x="".join(a)
10 | g=0
11 | t=int(input())
12 | for q in range(t):
13 | p,m=[int(e) for e in input().split(" ")]
14 | k=int((p*g)%m)
15 | print(x[k])
16 | g+=ord(x[k])
17 |
--------------------------------------------------------------------------------
/Templates/STL/helper_routines.cpp:
--------------------------------------------------------------------------------
1 | void readArray(vector& arr, int n) {
2 | arr.resize(n);
3 | for (auto &a: arr) {
4 | cin >> a;
5 | }
6 | }
7 |
8 | void readParallelArrays(vector& arr1, vector& arr2, int n) {
9 | arr1.resize(n);
10 | arr2.resize(n);
11 | for (int i = 0; i < n; ++i) {
12 | cin >> arr1[i];
13 | cin >> arr2[i];
14 | }
15 | }
16 |
17 | void sortArray(vector& arr) {
18 | sort(arr.begin(), arr.end());
19 | }
--------------------------------------------------------------------------------
/Problem Solutions/HackerRank/Interview Preparation Kit/Warm-Up/Jumping on the clouds.cpp:
--------------------------------------------------------------------------------
1 | int jumpingOnClouds(vector c) {
2 | int n = c.size();
3 | vector dp(n, 10000);
4 | dp[0] = 0;
5 | for (int i = 1; i < n; ++i) {
6 | if (c[i] == 1) {
7 | continue;
8 | }
9 | if (i - 1 >= 0) {
10 | dp[i] = min(dp[i], dp[i - 1] + 1);
11 | }
12 | if (i - 2 >= 0) {
13 | dp[i] = min(dp[i], dp[i - 2] + 1);
14 | }
15 | }
16 | return dp[n - 1];
17 | }
18 |
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Weekly Contests/92/868.Transpose-Matrix.cpp:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public:
3 | vector> transpose(vector>& A) {
4 | int rows = A.size();
5 | int cols = A[0].size();
6 |
7 | vector > a_transpose(cols, vector (rows));
8 | for(int i = 0; i < rows; i ++){
9 | for(int j = 0; j < cols; j ++){
10 | a_transpose[j][i] = A[i][j];
11 | }
12 | }
13 |
14 | return a_transpose;
15 | }
16 | };
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/116A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main(void){
5 | ios_base::sync_with_stdio(false);
6 | cin.tie(NULL);
7 | int n;
8 | cin>>n;
9 | int a[n], b[n];
10 | for(int i = 0; i < n; i ++)
11 | cin>>a[i]>>b[i];
12 | int max = 0;
13 | int inside = 0;
14 | for(int i = 0; i < n; i ++){
15 | inside -= a[i];
16 | inside += b[i];
17 | if(max < inside)
18 | max = inside;
19 | }
20 | cout<
2 |
3 | using namespace std;
4 |
5 | int main(){
6 |
7 |
8 | #ifndef ONLINE_JUDGE
9 | freopen("input.txt","r",stdin);
10 | freopen("output.txt","w",stdout);
11 | #endif
12 |
13 | int t,a,b,c,d;
14 | cin >> t;
15 |
16 | while(t--){
17 |
18 | cin >> a >> b >> c >> d;
19 |
20 | if((a ^ b ^ c ^ d) == 0){
21 | cout << "YES\n";
22 | }
23 | else{
24 | cout << "NO\n";
25 | }
26 |
27 | }
28 |
29 | return 0;
30 | }
--------------------------------------------------------------------------------
/Problem Solutions/Interviewbit/Two Pointers/Intersection of Sorted Arrays.cpp:
--------------------------------------------------------------------------------
1 | vector Solution::intersect(const vector &A, const vector &B) {
2 | int n = A.size();
3 | int m = B.size();
4 | int i = 0;
5 | int j = 0;
6 | vector res;
7 | while (i < n && j < m) {
8 | if (A[i] < B[j]) {
9 | ++i;
10 | } else if (A[i] > B[j]) {
11 | ++j;
12 | } else {
13 | res.push_back(A[i]);
14 | ++i;
15 | ++j;
16 | }
17 | }
18 | return res;
19 | }
20 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/633 Div 2 Virtual/A/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | int n;
9 | cin >> n;
10 |
11 | cout << n << endl;
12 | }
13 |
14 | int main() {
15 | FAST_IO;
16 |
17 | int t;
18 | cin >> t;
19 |
20 | while (t--) {
21 | solve();
22 | }
23 |
24 | return 0;
25 | }
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC144/C.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | int main() {
6 | FAST_IO;
7 |
8 | ll n;
9 | cin >> n;
10 |
11 | ll res = 1e13;
12 | for (int i = 1; i <= sqrt(n); ++i) {
13 | if (n % i == 0) {
14 | res = min(res, (i - 1) + (n/i - 1));
15 | }
16 | }
17 | cout << res << endl;
18 | return 0;
19 | }
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC147/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 |
6 | int main() {
7 |
8 | FAST_IO;
9 |
10 | int a[3];
11 | for (int i = 0; i < 3; ++i) {
12 | cin >> a[i];
13 | }
14 | if (a[0] + a[1] + a[2] >= 22) {
15 | cout << "bust" << endl;
16 | } else {
17 | cout << "win" << endl;
18 | }
19 |
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/Problem Solutions/e-olymp/ADA October 18 Binary Search/README.md:
--------------------------------------------------------------------------------
1 | # ADA October 18 - Binary Search
2 |
3 | [Link to the contest](https://www.e-olymp.com/en/contests/13949)
4 |
5 | ## Solved problems
6 | 1. [Rank](https://www.e-olymp.com/en/contests/13949/problems/137350)
7 | 2. [Binary Search](https://www.e-olymp.com/en/contests/13949/problems/137351)
8 | 3. [Binary Search I](https://www.e-olymp.com/en/contests/13949/problems/137352)
9 | 4. [n-th term divisible by a or b](https://www.e-olymp.com/en/contests/13949/problems/137353)
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Weekly Contests/166/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | class Solution {
5 | public:
6 | int subtractProductAndSum(int n) {
7 | int prod = 1, sum = 0;
8 | while (n) {
9 | prod *= (n % 10);
10 | sum += (n % 10);
11 | n /= 10;
12 | }
13 | return prod - sum;
14 | }
15 | };
16 |
17 | int main() {
18 | Solution solver;
19 | cout << solver.subtractProductAndSum(4421) << '\n';
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/Algorithms/BitMasking/Check Power of 2/check_power.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int check(int n){
4 | if(n==0) return 0;
5 | if((n&(n-1)) == 0) return 1;
6 | else return -1;
7 | }
8 | int main(){
9 | int n;
10 | cin >> n;
11 | if(check(n) == 0){
12 | cout << "Number is 0";
13 | }
14 | else if(check(n) == -1){
15 | cout << "Number is not a power of 2";
16 | }
17 | else{
18 | cout << "Number is a power of 2";
19 | }
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/282A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main(void){
5 | int n, x = 0;
6 | cin>>n;
7 | while(n --){
8 | string s;
9 | int add = 0, subtract = 0;
10 | cin>>s;
11 | for(int i = 0; i < 3; i ++){
12 | if(s[i] == '+'){
13 | add = 1;
14 | break;
15 | }
16 | else if(s[i] == '-'){
17 | subtract = 1;
18 | break;
19 | }
20 | }
21 | if(add)
22 | x++;
23 | if(subtract)
24 | x--;
25 | }
26 | cout<
2 | #include
3 | using namespace std;
4 | int main(void){
5 | int k;cin>>k;
6 | while(k != -1){
7 | // the sequence is quite observable as 1 7 19 37 61 ..., Nth term will be 3*n^2 - 3*n + 1
8 | float n;
9 | n = ( 1 - sqrt( 1 + ((4*(k-1))/3) ) )/2;//finding the value of n
10 | if(n - int(n))
11 | cout<<"N"<>k;
15 | }
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/Problem Solutions/HackerRank/Problem Solving/Jim and the orders.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main()
5 | {
6 | int n;
7 | cin >> n;
8 | vector> order;
9 | for (int i = 0; i < n; i++)
10 | {
11 | int t, d;
12 | cin >> t >> d;
13 | order.push_back({t + d, i + 1});
14 | }
15 | sort(order.begin(), order.end());
16 | for (int i = 0; i < n; i++)
17 | {
18 | cout << order[i].second << " ";
19 | }
20 | return 0;
21 | }
22 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/282A.py:
--------------------------------------------------------------------------------
1 | # take no of statements as input
2 | n = int(input())
3 |
4 | # value of x initially
5 | x = 0
6 |
7 | # take statements as input and process them
8 | for i in range(n):
9 | command = input()
10 | # print(command)
11 |
12 | # if 2nd character of string is +, then x is to be incremented
13 | # otherwise x is to be decremented
14 | if(command[1] == '+'):
15 | x += 1
16 | else:
17 | x -= 1
18 |
19 | # print the value of x
20 | print(x)
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC147/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 |
6 | int main() {
7 |
8 | FAST_IO;
9 |
10 | string s;
11 | cin >> s;
12 |
13 | int l = s.length();
14 | int res = 0;
15 | for (int i = 0; i < l/2; ++i) {
16 | if (i != l - i - 1 && s[i] != s[l - i - 1]) {
17 | ++res;
18 | }
19 | }
20 | cout << res << endl;
21 | return 0;
22 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/PRACTICE/Hashing/GOOGOL05.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 |
5 | int main () {
6 | FAST_IO;
7 |
8 | int n;
9 | cin >> n;
10 |
11 | map cnt;
12 | string dept;
13 | for (int i = 0; i < n; ++i) {
14 | cin >> dept;
15 | ++cnt[dept];
16 | }
17 |
18 | for (auto it: cnt) {
19 | cout << it.first << " " << it.second << endl;
20 | }
21 | return 0;
22 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/464 Div 2/1.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #define mod 1000000007
3 | #define ll long long
4 | using namespace std;
5 | int main()
6 | {
7 | int t,i,j,n;
8 | scanf("%d",&n);
9 | int arr[n];
10 | for(i=0;i>arr[i];
12 | arr[i]--;
13 | }
14 | for(i=0;i
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | int a, b, c, d;
9 | cin >> a >> b >> c >> d;
10 |
11 | cout << b << " " << c << " " << c << endl;
12 |
13 | }
14 |
15 | int main() {
16 | FAST_IO;
17 |
18 | int t;
19 | cin >> t;
20 |
21 | while (t--) {
22 | solve();
23 | }
24 |
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC150/D.py:
--------------------------------------------------------------------------------
1 | # gives wrong answer
2 |
3 | import math
4 |
5 | l = input().split()
6 | n = int(l[0])
7 | m = int(l[1])
8 |
9 | a = list(map(int, input().split()))
10 |
11 | d = a[0]/2
12 | lcm = a[0]/2
13 |
14 | n = len(a)
15 |
16 | def gcd(a, b):
17 | if (b == 0):
18 | return a
19 | return gcd(b, a % b)
20 |
21 | for i in range(1, n):
22 | d = gcd(lcm, a[i]/2)
23 | lcm = ((a[i]/2) * lcm)/d
24 |
25 | multiples = m//lcm
26 | odd_multiples = math.ceil((1.0*multiples)/2)
27 | print(odd_multiples)
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Concept Building Practice/236A.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | int main()
4 | {
5 | char str[100];
6 | scanf("%s",str);
7 | int ascii[26]={0};
8 | int y = strlen(str);
9 | for(int i=0;i
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | // #define MULTIPLE_TESTS 1
6 |
7 | void solve() {
8 | ll a, b;
9 | cin >> a >> b;
10 | cout << a*b << endl;
11 | }
12 |
13 | int main() {
14 | FAST_IO;
15 | int t = 1;
16 | #ifdef MULTIPLE_TESTS
17 | cin >> t;
18 | #endif
19 |
20 | while (t--) {
21 | solve();
22 | }
23 |
24 | return 0;
25 | }
--------------------------------------------------------------------------------
/Problem Solutions/HackerEarth/Month Easy Contests/MAY 19/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | typedef long long ll;
5 | int main() {
6 | int t;
7 | cin >> t;
8 |
9 | int x, y, a, b;
10 | for (int i = 0; i < t; i ++) {
11 | cin >> x >> y >> a >> b;
12 |
13 | ll total = 1ll*x*y;
14 | ll sum = a + b;
15 | if (total == sum) {
16 | cout << "Yes" << endl;
17 | }
18 | else {
19 | cout << "No" << endl;
20 | }
21 | }
22 | return 0;
23 | }
24 |
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Biweekly Contests/3/1099.Two-Sum-Less-Than-K.cpp:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public:
3 | int twoSumLessThanK(vector& A, int K) {
4 | int n = A.size();
5 | int bestSum = -1;
6 | for (int i = 0; i < n; i ++) {
7 | for (int j = i + 1; j < n; j ++) {
8 | int currentSum = A[i] + A[j];
9 | if (currentSum > bestSum && currentSum < K) {
10 | bestSum = currentSum;
11 | }
12 | }
13 | }
14 | return bestSum;
15 | }
16 | };
--------------------------------------------------------------------------------
/Data Structures/Stacks/stack_paren_balanced.py:
--------------------------------------------------------------------------------
1 | s=input()
2 | l=[]
3 | def is_match(a,b):
4 | if a=="(" and b==")":
5 | return True
6 | if a=="{" and b=="}":
7 | return True
8 | if a=="[" and b=="]":
9 | return True
10 | flag=True
11 | for i in range(0,len(s)):
12 | if s[i] in "({[" and flag==True:
13 | l.append(s[i])
14 | else:
15 | if len(l)==0:
16 | flag=False
17 | else:
18 | top=l.pop()
19 | if not is_match(top,s[i]):
20 | flag=False
21 | if len(l)==0 and flag:
22 | print(True)
23 | else:
24 | print(False)
25 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC144/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | int main() {
6 | FAST_IO;
7 |
8 | int n;
9 | cin >> n;
10 |
11 | for (int i = 1; i <= 9; ++i) {
12 | for (int j = 1; j <= 9; ++j) {
13 | if (i*j == n) {
14 | cout << "Yes" << endl;
15 | return 0;
16 | }
17 | }
18 | }
19 | cout << "No" << endl;
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/CACD2020/MODME.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 | typedef long long ll;
6 |
7 | int main(){
8 |
9 | FAST_IO;
10 |
11 | ll t;
12 | cin >> t;
13 |
14 | ll n, m;
15 | while (t--) {
16 | cin >> n >> m;
17 | if (n % (m + 1) == 0) {
18 | cout << "B";
19 | } else {
20 | cout << "A";
21 | }
22 | cout << endl;
23 | }
24 |
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/KH19MOS/RANDID.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 | typedef long long ll;
6 |
7 | void solve() {
8 | int n, q;
9 | cin >> n >> q;
10 |
11 | double res = n + q - n/(q + 1.);
12 | cout << fixed;
13 | cout << setprecision(9) << res << endl;
14 | }
15 | int main() {
16 |
17 | FAST_IO;
18 |
19 | int t;
20 | cin >> t;
21 |
22 | while (t--) {
23 | solve();
24 | }
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC150/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 |
6 | int main() {
7 |
8 | FAST_IO;
9 |
10 | int n;
11 | cin >> n;
12 |
13 | string s;
14 | cin >> s;
15 |
16 | int cnt = 0;
17 | for (int i = 0; i <= n - 3; ++i) {
18 | string temp = s.substr(i, 3);
19 | if (temp == "ABC") {
20 | ++cnt;
21 | }
22 | }
23 | cout << cnt << endl;
24 |
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/464 Div 2/2.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #define mod 1000000007
3 | #define ll long long
4 | using namespace std;
5 | int main()
6 | {
7 | int t,i,j;
8 | ll n,k;
9 | cin>>n>>k;
10 | ll arr[k];
11 | for(i=0;i>arr[i];
13 |
14 | long long maxx=0,maxi;
15 | for(i=0;imaxx)
18 | {
19 | maxx=(n/arr[i])*arr[i];
20 | maxi=i+1;
21 | }
22 | }
23 | if(maxx==0)
24 | cout<<1<<" 0";
25 | else
26 | cout<
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | int x;
9 | cin >> x;
10 |
11 | int res = x/2;
12 | if (x % 2 == 0) {
13 | --res;
14 | }
15 | cout << res << endl;
16 | }
17 |
18 | int main() {
19 | FAST_IO;
20 |
21 | int t;
22 | cin >> t;
23 |
24 | while (t--) {
25 | solve();
26 | }
27 |
28 | return 0;
29 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/576 Div 2/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | class Solution {
7 | public:
8 | double solve(double h, double l) {
9 | double ans = (l*l - h*h)/(2.0*h);
10 | return ans;
11 | }
12 | };
13 |
14 | int main() {
15 | FAST_IO;
16 | double h, l;
17 | cin >> h >> l;
18 |
19 | Solution solver;
20 | cout << fixed;
21 | cout << setprecision(10);
22 | cout << solver.solve(h, l) << endl;
23 | return 0;
24 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/613 Div 2 Virtual/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 |
9 | int n;
10 | cin >> n;
11 |
12 | int c1 = 0, c2 = 0;
13 | string s;
14 | cin >> s;
15 |
16 | for (int i = 0; i < n; ++i) {
17 | if (s[i] == 'L') {
18 | --c1;
19 | } else {
20 | ++c2;
21 | }
22 | }
23 | cout << c2 - c1 + 1 << endl;
24 |
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/629 Div 3/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 |
9 | int t;
10 | cin >> t;
11 |
12 | ll a, b;
13 | ll res;
14 | while (t--) {
15 | cin >> a >> b;
16 |
17 | if (a % b == 0) {
18 | cout << 0 << endl;
19 | } else {
20 | res = b*(a/b + 1) - a;
21 | cout << res << endl;
22 | }
23 | }
24 |
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 84 Virtual/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | void solve() {
7 | ll n, k;
8 | cin >> n >> k;
9 |
10 | if (n >= k*k && (n - k) % 2 == 0) {
11 | cout << "YES" << endl;
12 | } else {
13 | cout << "NO" << endl;
14 | }
15 | }
16 | int main() {
17 | FAST_IO;
18 |
19 | int t;
20 | cin >> t;
21 | while (t--) {
22 | solve();
23 | }
24 |
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Weekly Contests/143/1104.Path-in-Zigzag-Labelled-Binary-Tree.cpp:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public:
3 | vector pathInZigZagTree(int label) {
4 | int n = floor(log2(1.0*label));
5 | vector res;
6 | int p = pow(2, n);
7 | res.push_back(label);
8 | while (label > 1) {
9 | label /= 2;
10 | int diff = p - label - 1;
11 | p/= 2;
12 | label = p + diff;
13 | res.push_back(label);
14 | }
15 | reverse(res.begin(), res.end());
16 | return res;
17 | }
18 | };
--------------------------------------------------------------------------------
/Problem Solutions/SPOJ/ARMY.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | int main() {
6 | int t;cin>>t;
7 | while(t--){
8 | int ng,nm;cin>>ng>>nm;
9 | int array1[ng],array2[nm];
10 | for(int i=0;i>array1[i];
12 | for(int i=0;i>array2[i];
14 | sort(array1,array1+ng);
15 | sort(array2,array2+nm);
16 | if(array1[ng-1]>=array2[nm-1]){
17 | cout<<"Godzilla"<
2 | #include
3 | int main()
4 | {
5 | int t;
6 | std::cin >> t;
7 | for (int i = 0; i < t; i++)
8 | {
9 | int n, k, a, b = 0;
10 | std::cin >> n >> k;
11 | for (int j = 0; j < n; j++)
12 | {
13 | std::cin >> a;
14 | b = b ^ a;
15 | }
16 | if (b == 0)
17 | {
18 | std::cout << "Second \n";
19 | }
20 | else
21 | {
22 | std::cout << "First \n";
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Problem Solutions/TopCoder/TCC 2018/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | class SimpleDarts{
5 | private:
6 |
7 | public:
8 | int highestScore(int f){
9 | int score = 0;
10 | if(f > 18){
11 | score = 3*f + 3*(f - 1) + 3*(f - 2);
12 | }
13 | if(f == 18){
14 | score = 54 + 51 + 50;
15 | }
16 | if(f < 18 && f > 9){
17 | score = 50 + 3*f + 3*(f - 1);
18 | }
19 | if(f <= 9){
20 | score = 50 + 25 + 3*f;
21 | }
22 | return score;
23 | }
24 | };
25 |
26 | int main(){
27 |
28 | SimpleDarts a;
29 |
30 | cout << "\n" << a.highestScore(20) << "\n";
31 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/OCT19B/S10E_soln.py:
--------------------------------------------------------------------------------
1 | if __name__ == '__main__':
2 | t = int(input())
3 | while t != 0:
4 | n = int(input())
5 | x = [int(_) for _ in input().split()]
6 |
7 | good = 0
8 | for i in range(len(x)):
9 | a = i-5
10 | if a < 0:
11 | a = 0
12 |
13 | seq = x[a:i]
14 | if seq:
15 | mx = min(seq)
16 | if x[i] < mx:
17 | good += 1
18 | else:
19 | good += 1
20 |
21 | print(good)
22 |
23 | t -= 1
24 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 80/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 |
9 | int t;
10 | cin >> t;
11 |
12 | ll a, b;
13 | while (t--) {
14 | cin >> a >> b;
15 |
16 | ll cur = 9;
17 | ll res = 0;
18 | while (cur <= b) {
19 | res += a;
20 | cur = cur*10 + 9;
21 | }
22 |
23 | cout << res << endl;
24 | }
25 |
26 | return 0;
27 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeDrills/92A.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Code Drills recommendation:
3 | * https://code-drills.com/recommendations/491fc07f-8605-42a2-8a2a-8c2b33ae7add
4 | */
5 |
6 | #include
7 | using namespace std;
8 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
9 | int main() {
10 | FAST_IO;
11 | int n, m;
12 | cin >> n >> m;
13 |
14 | int cur = 1;
15 | int done = 0;
16 | while (done + cur <= m) {
17 | done += cur;
18 | ++cur;
19 | if (cur == n + 1) {
20 | cur = 1;
21 | }
22 | }
23 |
24 | cout << m - done << endl;
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/628 Div 2/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 |
6 | int main() {
7 |
8 | FAST_IO;
9 |
10 | int t;
11 | cin >> t;
12 |
13 | while (t--) {
14 | int n;
15 | cin >> n;
16 |
17 | unordered_set s;
18 | int x;
19 | for (int i = 0; i < n; ++i) {
20 | cin >> x;
21 | s.insert(x);
22 | }
23 |
24 | cout << s.size() << endl;
25 | }
26 | return 0;
27 | }
--------------------------------------------------------------------------------
/Algorithms/Searching/linear_search.py:
--------------------------------------------------------------------------------
1 | # Name : Nabanita Dash
2 | # Email ID : dashnabanita@gmail.com
3 |
4 | # Find an element in an array using linear search
5 |
6 | # Code
7 | def linear_search(arr, x):
8 | n = len(arr)
9 | for i in range (0, n):
10 | if (arr[i] == x):
11 | print("The element is found at the position ",i)
12 | print("The element is not present in the array")
13 |
14 | # Test-Case
15 | arr = [34, 56, 51, 980, 67838, 4, 07, 17]
16 | x = 07
17 | result = linear_search(arr, x)
18 |
19 | # Time-Complexity
20 | # Worst Case : O(n)
21 |
22 | # Space-Complexity
23 | # O(1)
24 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC166/A/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | string s;
9 | cin >> s;
10 |
11 | if (s[1] == 'B') {
12 | cout << "ARC" << endl;
13 | } else {
14 | cout << "ABC" << endl;
15 | }
16 |
17 | }
18 |
19 | int main() {
20 | FAST_IO;
21 |
22 | int t;
23 | // cin >> t;
24 | t = 1;
25 | while (t--) {
26 | solve();
27 | }
28 |
29 | return 0;
30 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/BitChef 1.0/CHEFLOL.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 |
9 | int t;
10 | cin >> t;
11 |
12 | int n;
13 | while (t --) {
14 | cin >> n;
15 | ll res = 0;
16 | ll x;
17 | for (int i = 0; i < n; ++i) {
18 | cin >> x;
19 | if (x > 0) {
20 | res += x;
21 | }
22 | }
23 | cout << res << endl;
24 | }
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 87/C/C.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | const double PI = 3.141592653589793238;
8 |
9 | void solve() {
10 | double n;
11 | cin >> n;
12 |
13 | cout << fixed << setprecision(10);
14 | cout << 1/(tan(PI/(2*n))) << endl;
15 |
16 | }
17 |
18 | int main() {
19 | FAST_IO;
20 |
21 | int t;
22 | cin >> t;
23 |
24 | while (t--) {
25 | solve();
26 | }
27 |
28 | return 0;
29 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/611 Div 3/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 |
9 | int t;
10 | cin >> t;
11 |
12 | while (t--) {
13 | ll n, k;
14 | cin >> n >> k;
15 |
16 | if (n % k == 0) {
17 | cout << n << endl;
18 | } else {
19 | ll res = (n/k) * k;
20 | res += min(k/2, n - res);
21 | cout << res << endl;
22 | }
23 | }
24 |
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/D/D.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | ll a, b, n;
9 | cin >> a >> b >> n;
10 |
11 | ll x = min(b - 1, n);
12 |
13 | ll res = floor((1.0*a*x)/b) - a*floor((1.0 * x)/b);
14 | cout << res << endl;
15 | }
16 |
17 | int main() {
18 | FAST_IO;
19 |
20 | int t;
21 | // cin >> t;
22 | t = 1;
23 |
24 | while (t--) {
25 | solve();
26 | }
27 |
28 | return 0;
29 | }
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC169 Virtual/C/C.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | // #define MULTIPLE_TESTS 1
6 |
7 | void solve() {
8 | ll a;
9 | double b;
10 | cin >> a >> b;
11 | ll res = round(b*100);
12 | res *= a;
13 | res /= 100;
14 | cout << res << endl;
15 | }
16 |
17 | int main() {
18 | FAST_IO;
19 | int t = 1;
20 | #ifdef MULTIPLE_TESTS
21 | cin >> t;
22 | #endif
23 |
24 | while (t--) {
25 | solve();
26 | }
27 | return 0;
28 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/JULY17/CALC.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | long long energy(long long num_presses_second_button, long long total_energy, long long energy_reduced_per_click){
5 | long long n, b, x;
6 | n = total_energy;
7 | b = energy_reduced_per_click;
8 | x = num_presses_second_button;
9 | return x*(n - x*b);
10 | }
11 |
12 | int main(){
13 | int t;
14 | cin >> t;
15 |
16 | int n, b;
17 | while(t --){
18 | cin >> n >> b;
19 | int second_button_clicks = n/b/2;
20 | cout << max(energy(second_button_clicks, n, b), energy(second_button_clicks + 1, n, b)) << "\n";
21 | }
22 | return 0;
23 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/OCT19B/MARM_soln.py:
--------------------------------------------------------------------------------
1 | if __name__ == '__main__':
2 | t = int(input())
3 |
4 | while t != 0:
5 | n, k = map(int, input().split())
6 | arr = [int(_) for _ in input().split()]
7 | mid = int(n / 2)
8 |
9 | if k > 3 * n:
10 | mx = (k % (3 * n))
11 | else:
12 | mx = k
13 |
14 | mx2 = int(n / 2) + 1
15 | for i in range(mx):
16 | arr[i % n] = (arr[i % n]) ^ (arr[n - (i % n) - 1])
17 | if n % 2 != 0 and i < mx2 and k > 3 * n:
18 | arr[mid] = 0
19 |
20 | print(*arr)
21 |
22 | t -= 1
23 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/PRACTICE/Trees/CHEFDETE.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 |
5 | void solve() {
6 | int n;
7 | cin >> n;
8 |
9 | vector marked(n + 1, 0);
10 | int x;
11 | for (int i = 1; i <= n; ++i) {
12 | cin >> x;
13 | marked[x] = 1;
14 | }
15 | for (int i = 1; i <= n; ++i) {
16 | if (!marked[i]) {
17 | cout << i << " ";
18 | }
19 | }
20 | cout << endl;
21 | }
22 |
23 | int main () {
24 | FAST_IO;
25 |
26 | solve();
27 | return 0;
28 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 86/A/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | ll x, y, a, b;
9 | cin >> x >> y >> a >> b;
10 |
11 | ll mn = min(x, y);
12 | ll mx = max(x, y);
13 |
14 | ll res = (mx - mn)*a + min(mn*b, 2*mn*a);
15 | cout << res << endl;
16 | }
17 |
18 | int main() {
19 | FAST_IO;
20 |
21 | int t;
22 | cin >> t;
23 |
24 | while (t--) {
25 | solve();
26 | }
27 |
28 | return 0;
29 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/AGPR2020/CANDY.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 | typedef long long ll;
6 | const ll MOD = 1000000007LL;
7 | const ll MAX = 100010LL;
8 |
9 | int main() {
10 |
11 | FAST_IO;
12 |
13 | ll t;
14 | cin >> t;
15 |
16 | while (t--) {
17 | ll n, k;
18 | cin >> n >> k;
19 |
20 | ll res = n;
21 | res += (n/2) * k;
22 | if (n & 1) {
23 | res += 2*k;
24 | }
25 | cout << res << endl;
26 | }
27 |
28 | return 0;
29 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Concept Building Practice/231A.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main()
3 | {
4 | //declaring a integer n
5 | int n;
6 | //scaning the value of that integer which will tell number of times we have to take input
7 | scanf("%d",&n);
8 | //declaring one more integer which will be used as counter
9 | int k=0;
10 | //for loop because we have n line input
11 | for(int i=0;i=2)//our main condition
16 | {
17 | k++;//our counter
18 | }
19 | }
20 | printf("%d",k);//printing the count value which is our answer
21 | return 0;
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/PRACTICE/Hashing/NPLQ19D.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 |
5 | int main () {
6 | FAST_IO;
7 |
8 | int n;
9 | cin >> n;
10 |
11 | while (n--) {
12 | string s;
13 | cin >> s;
14 |
15 | int l = s.length();
16 | int vis[26] = {0};
17 | for (int i = 0; i < l; ++i) {
18 | if (!vis[s[i] - 'a']) {
19 | cout << s[i];
20 | vis[s[i] - 'a'] = 1;
21 | }
22 | }
23 | cout << endl;
24 | }
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Global Rounds/Round 7/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 | typedef long long ll;
6 |
7 | int main() {
8 | FAST_IO;
9 |
10 | int n;
11 | cin >> n;
12 |
13 | vector b(n);
14 | for (int i = 0; i < n; ++i) {
15 | cin >> b[i];
16 | }
17 |
18 | cout << b[0] << " ";
19 | ll maxi = b[0];
20 | for (int i = 1; i < n; ++i) {
21 | cout << maxi + b[i] << " ";
22 | maxi = max(maxi, maxi + b[i]);
23 | }
24 | cout << endl;
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Other Rounds/2019-2020 ICPC NERC Southern and Volga Russian Regional Contest/F.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Problem Link: https://codeforces.com/contest/1250/problem/F
3 | */
4 | #include
5 | using namespace std;
6 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
7 | typedef long long ll;
8 |
9 | int main() {
10 | FAST_IO;
11 |
12 | int n;
13 | cin >> n;
14 |
15 | int res = 4*n;
16 | for (int i = 1; i <= sqrt(n); ++i) {
17 | if (n % i == 0) {
18 | res = min(res, 2*(i + n/i));
19 | }
20 | }
21 | cout << res << endl;
22 | return 0;
23 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/263A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int mod(int);
5 |
6 | int main(void){
7 | int array[5][5];
8 | for(int i = 0; i < 5;i ++)
9 | for (int j = 0; j < 5;j ++)
10 | cin>>array[i][j];
11 | int a = 53, b = 24;
12 | for(int i = 0; i < 5; i ++){
13 | for(int j = 0; j < 5;j ++){
14 | if(array[i][j] == 1){
15 | a = i;
16 | b = j;
17 | }
18 | }
19 | }
20 | a += 1;
21 | b += 1;
22 | //cout<<"a = "<
2 | using namespace std;
3 |
4 | int main(void){
5 | string s;
6 | cin>>s;
7 | int count = 0;
8 | int flag = 0;
9 | for(int i = 0; i < s.size() - 1; i ++){
10 | if(s[i] == '0' && s[i+1] == '0'){
11 | count++;
12 | if(count >= 6){
13 | flag = 1;
14 | break;
15 | }
16 | }
17 | else if(s[i] == '1' && s[i+1] == '1'){
18 | count++;
19 | if(count >= 6){
20 | flag = 1;
21 | break;
22 | }
23 | }
24 | else
25 | count = 0;
26 | }
27 | if(flag == 1){
28 | cout<<"YES";
29 | }
30 | else{
31 | cout<<"NO";
32 | }
33 | return 0;
34 | }
--------------------------------------------------------------------------------
/Problem Solutions/HackerRank/Problem Solving/GradingStudents.py:
--------------------------------------------------------------------------------
1 | # Solution for Grading Students Problem in Problem Solving Section
2 | # Link to the problem: https://www.hackerrank.com/challenges/grading/problem
3 |
4 | n = int(input())
5 | for i in range(n):
6 | num = int(input())
7 | first = int(num/10)
8 | second = num%10
9 | if(second == 0):
10 | checkNum = first*10
11 | elif(second > 5):
12 | checkNum = first*10 + 10
13 | else:
14 | checkNum = first*10 + 5
15 | if(num < 38):
16 | print(num)
17 | elif(checkNum - num < 3):
18 | print(checkNum)
19 | else:
20 | print(num)
21 |
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Array/215-Kth-largest.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * References:
3 | * https://www.geeksforgeeks.org/make_heap-in-cpp-stl/
4 | * https://www.geeksforgeeks.org/heap-using-stl-c/
5 | */
6 |
7 |
8 | class Solution {
9 | public:
10 | int findKthLargest(vector& nums, int k) {
11 | // sort(nums.begin(), nums.end());
12 | // int n = nums.size();
13 | // return nums[n - k];
14 | make_heap(nums.begin(), nums.end());
15 | for (int i = 0; i < k - 1; ++i) {
16 | pop_heap(nums.begin(), nums.end());
17 | nums.pop_back();
18 | }
19 | return nums.front();
20 | }
21 | };
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Weekly Contests/179/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | class Solution {
4 | public:
5 | string generateTheString(int n) {
6 | string res;
7 | if (n & 1) {
8 | for (int i = 0; i < n; ++i) {
9 | res += 'a';
10 | }
11 | } else {
12 | for (int i = 0; i < n - 1; ++i) {
13 | res += 'a';
14 | }
15 | res += 'b';
16 | }
17 | return res;
18 | }
19 | };
20 |
21 | int main () {
22 | Solution solver;
23 | cout << solver.generateTheString(3) << endl;
24 | return 0;
25 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/dp/35D.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | using namespace std;
5 |
6 | int main() {
7 | freopen("input.txt", "r", stdin);
8 | freopen("output.txt", "w", stdout);
9 | int n, x;
10 | cin >> n >> x;
11 |
12 | vector c(n, 0), food(n);
13 | for (int i = 0; i < n; ++i) {
14 | cin >> c[i];
15 | food[i] = c[i]*(n - i);
16 | }
17 |
18 | sort(food.begin(), food.end());
19 | int sum = 0, cur = 0;
20 | while (cur < n && sum + food[cur] <= x) {
21 | sum += food[cur];
22 | ++cur;
23 | }
24 | cout << cur << endl;
25 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/596 Div 2/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 | int x, y;
9 | cin >> x >> y;
10 |
11 | if (y == x + 1) {
12 | cout << x << "9 ";
13 | cout << y << "0" << endl;
14 | } else if (y == x) {
15 | cout << x << "1 ";
16 | cout << y << "2" << endl;
17 | } else if (x == 9 && y == 1) {
18 | cout << 99 << " " << 100 << endl;
19 | } else {
20 | cout << "-1" << endl;
21 | }
22 |
23 | return 0;
24 | }
--------------------------------------------------------------------------------
/Data Structures/Trees/Generic Tree/GenericTreeClient.java:
--------------------------------------------------------------------------------
1 | //This class implements a simple client for the Generic tree.
2 |
3 | public class GenericTreeClient {
4 |
5 | public static void main(String[] args) {
6 | // sample input for the generic tree - 50 3 40 2 20 0 15 0 80 0 10 1 19 0
7 |
8 | // generic tree declaration
9 | GenericTree tree = new GenericTree();
10 |
11 | // this method displays the tree
12 | tree.display();
13 | System.out.println("*******************************");
14 |
15 | // this method displays the tree in level order
16 | tree.LevelOrder();
17 | System.out.println("*******************************");
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/CHPTRS01/CSCARE.py:
--------------------------------------------------------------------------------
1 | # PASSES SUBTASK 1 in O(N^2)
2 | t = int(input())
3 | for _ in range(t):
4 | x = int(input())
5 | n = int(input())
6 | A = list(map(int, input().split()))
7 | m = int(input())
8 | B = list(map(int, input().split()))
9 | res = 0
10 | for i in range(0, m - n + 1):
11 | possible = True
12 | diff = abs(A[0] - B[i])
13 | if (diff > x):
14 | continue
15 | for k in range(0, n):
16 | if (abs(A[k] - B[i + k]) != diff):
17 | possible = False
18 | break
19 | if (possible):
20 | res += 1
21 | print(res)
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/641 Div 3/A/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | ll n, m;
9 | cin >> n >> m;
10 |
11 | if (n == 1) {
12 | cout << 0 << endl;
13 | } else if (n == 2) {
14 | cout << m << endl;
15 | } else {
16 | cout << 2*m << endl;
17 | }
18 |
19 | }
20 |
21 | int main() {
22 | FAST_IO;
23 |
24 | int t;
25 | cin >> t;
26 |
27 | while (t--) {
28 | solve();
29 | }
30 |
31 | return 0;
32 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Educational Rounds/Round 80/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 |
9 | int t;
10 | cin >> t;
11 | while (t--) {
12 | int n, d;
13 | cin >> n >> d;
14 |
15 | int mid = n/2;
16 | int cnt = mid + ceil((1.0*d)/(mid + 1));
17 | // cout << cnt << " ";
18 | if (cnt <= n) {
19 | cout << "YES" << endl;
20 | } else {
21 | cout << "NO" << endl;
22 | }
23 | }
24 |
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/575 Div 3/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | class Solution {
7 | public:
8 | void solve(int q) {
9 | ll a, b, c;
10 | ll res;
11 | for (int i = 0; i < q; ++i) {
12 | cin >> a >> b >> c;
13 | res = a + b + c;
14 | if (res & 1) {
15 | --res;
16 | }
17 | cout << res/2 << endl;
18 | }
19 | }
20 | };
21 |
22 | int main() {
23 |
24 | FAST_IO;
25 | int q;
26 | cin >> q;
27 |
28 | Solution solver;
29 | solver.solve(q);
30 | return 0;
31 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/598 Div 3/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 | int q;
9 | cin >> q;
10 |
11 | ll a, b, n, s;
12 | while (q--) {
13 | cin >> a >> b >> n >> s;
14 |
15 | ll req = s/n;
16 | ll used = min(req, a);
17 | ll res = used*n;
18 | ll rem = s - res;
19 | if (rem <= b) {
20 | cout << "YES" << endl;
21 | } else {
22 | cout << "NO" << endl;
23 | }
24 | }
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/Problem Solutions/HackerRank/Interview Preparation Kit/Warm-Up/Repeated String.cpp:
--------------------------------------------------------------------------------
1 | typedef long ll;
2 | long repeatedString(string s, long n) {
3 | int len = s.length();
4 | vector cnt(len + 1, 0);
5 | if (s[0] == 'a') {
6 | ++cnt[0];
7 | }
8 | for (int i = 1; i < len; ++i) {
9 | if (s[i] == 'a') {
10 | cnt[i] = cnt[i - 1] + 1;
11 | } else {
12 | cnt[i] = cnt[i - 1];
13 | }
14 | }
15 | if (n <= 1ll * len) {
16 | return cnt[n - 1];
17 | }
18 |
19 | ll blocks = n / len;
20 | ll res = blocks * cnt[len - 1];
21 |
22 | int rem = n % len;
23 | if (rem != 0) {
24 | res += cnt[rem - 1];
25 | }
26 |
27 | return res;
28 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/361A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FOR(i,a,b) for(int i = a; i < b; i ++)
4 | #define RFOR(i,a,b) for(int i = a; i >= b; i --)
5 | #define ln "\n"
6 | #define debug1(x) cout<"<"<"<>n>>k;
15 | FOR(i,0,n){
16 | FOR(j,0,n){
17 | if(i == j){
18 | cout< distributeCandies(int candies, int num_people) {
4 | int current = 1, index = 0;
5 | vector res(num_people, 0);
6 | while (candies) {
7 | if (current <= candies) {
8 | res[index] += current;
9 | candies -= current;
10 | } else {
11 | res[index] += candies;
12 | candies = 0;
13 | }
14 | index ++;
15 | index %= num_people;
16 | current ++;
17 | }
18 | return res;
19 | }
20 | };
--------------------------------------------------------------------------------
/Problem Solutions/SPOJ/LASTDIG.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int mod(int,int);//modular function
4 | int main() {
5 | //will be using modular exponentiation (check wikipedia for details over the algo)
6 | int t;cin>>t;
7 | while(t--){
8 | int a,b;cin>>a>>b;//we need to find last digit of a^b
9 | cout<
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 | #define TESTCASES 1
7 |
8 | void solve() {
9 | int n, m;
10 | cin >> n >> m;
11 |
12 | int x = ceil((1.0*n*m)/2);
13 | cout << x << endl;
14 |
15 | }
16 |
17 | int32_t main() {
18 | FAST_IO;
19 |
20 | int t;
21 | #ifdef TESTCASES
22 | cin >> t;
23 | #endif
24 |
25 | #ifndef TESTCASES
26 | t = 1;
27 | #endif
28 |
29 | while (t--) {
30 | solve();
31 | }
32 |
33 | return 0;
34 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/200B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FOR(i,a,b) for(int i = a; i < b; i ++)
4 | #define RFOR(i,a,b) for(int i = a; i >= b; i --)
5 | #define ln "\n"
6 | #define debug1(x) cout<"<"<"<>n;
15 | int array[n];
16 | FOR(i,0,n){
17 | cin>>array[i];
18 | }
19 | int sum = 0;
20 | FOR(i,0,n){
21 | sum += array[i];
22 | }
23 | cout<
2 | using namespace std;
3 | #define FOR(i,a,b) for(int i = a; i < b; i ++)
4 | #define RFOR(i,a,b) for(int i = a; i >= b; i --)
5 | #define ln "\n"
6 | #define debug1(x) cout<"<"<"<>n;
15 | int left = 1, right = n*n;
16 | FOR(i,0,n){
17 | for(int j = 1; j <= n/2; j ++){
18 | cout<
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 | const int MAX = 2e5 + 10;
7 |
8 | int main() {
9 | FAST_IO;
10 |
11 | int n;
12 | cin >> n;
13 |
14 | set s;
15 | int x;
16 | int res = 0;
17 | for (int i = 0; i < n; ++i) {
18 | cin >> x;
19 | --x;
20 | if (x == i) {
21 | ++res;
22 | } else {
23 | s.insert(x);
24 | }
25 | }
26 |
27 | res += s.size()/2;
28 | cout << res << endl;
29 | return 0;
30 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/582 Div 3 Virtual/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 | int n;
9 | cin >> n;
10 |
11 | vector a(n);
12 | for (int i = 0; i < n; ++i) {
13 | cin >> a[i];
14 | }
15 |
16 | int res = n;
17 | for (int i = 0; i < n; ++i) {
18 | int cnt = 0;
19 | for (int j = 0; j < n; ++j) {
20 | int diff = a[i] - a[j];
21 | if (diff & 1) {
22 | ++cnt;
23 | }
24 | }
25 | res = min(res, cnt);
26 | }
27 | cout << res << endl;
28 | return 0;
29 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/546A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FOR(i,a,b) for(int i = a; i < b; i ++)
4 | #define RFOR(i,a,b) for(int i = a; i >= b; i --)
5 | #define ln "\n"
6 | #define debug1(x) cout<"<"<"<>k>>n>>w;
15 | int cost = 0, i = 0;
16 | while(w--){
17 | i++;
18 | cost += i*k;
19 | }
20 | //debug1(cost);
21 | if(cost > n)
22 | cout<<(cost - n)<
2 | using namespace std;
3 | #define FOR(i,a,b) for(int i = a; i < b; i ++)
4 | #define RFOR(i,a,b) for(int i = a; i >= b; i --)
5 | #define ln "\n"
6 | #define debug1(x) cout<"<"<"<>n;
15 | n -= 10;
16 | if(n >= 2 && n <= 9){
17 | cout<<4;
18 | }
19 | else if(n == 10){
20 | cout<<15;
21 | }
22 | else if(n == 1 || n == 11){
23 | cout<<4;
24 | }
25 | else
26 | cout<<0;
27 | return 0;
28 | }
--------------------------------------------------------------------------------
/Problem Solutions/e-olymp/ADA October 18 Binary Search/rank.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Problem Link: https://www.e-olymp.com/en/contests/13949/problems/137350
3 | */
4 |
5 | #include
6 | using namespace std;
7 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
8 | typedef long long ll;
9 |
10 | int main() {
11 | FAST_IO;
12 |
13 | int n, x;
14 | cin >> n;
15 |
16 | vector a(n);
17 | for (int i = 0; i < n; ++i) {
18 | cin >> a[i];
19 | }
20 |
21 | cin >> x;
22 |
23 | reverse(a.begin(), a.end());
24 | int idx = lower_bound(a.begin(), a.end(), x) - a.begin();
25 | cout << n - idx + 1 << endl;
26 | return 0;
27 | }
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC165 Virtual/B/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | ll X;
9 | cin >> X;
10 |
11 | ll cur = 100;
12 | for (int i = 1; i <= 3760; ++i) {
13 | cur *= 1.01;
14 | if (cur >= X) {
15 | cout << i << endl;
16 | break;
17 | }
18 | }
19 | }
20 |
21 | int main() {
22 | FAST_IO;
23 |
24 | int t;
25 | // cin >> t;
26 | t = 1;
27 |
28 | while (t--) {
29 | solve();
30 | }
31 |
32 | return 0;
33 | }
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC167/A/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | string s, t;
9 | cin >> s >> t;
10 |
11 | for (char ch = 'a'; ch <= 'z'; ++ch) {
12 | if (s + ch == t) {
13 | cout << "Yes" << endl;
14 | return;
15 | }
16 | }
17 | cout << "No" << endl;
18 | }
19 |
20 | int main() {
21 | FAST_IO;
22 |
23 | int t;
24 | // cin >> t;
25 | t = 1;
26 |
27 | while (t--) {
28 | solve();
29 | }
30 |
31 | return 0;
32 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/636 Div 3/A/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | ll n;
9 | cin >> n;
10 |
11 | ll pow = 2;
12 | ll cur = 3;
13 | while (1) {
14 | if (n % cur == 0) {
15 | cout << n/cur << endl;
16 | break;
17 | }
18 | pow *= 2;
19 | cur += pow;
20 | }
21 | }
22 |
23 | int main() {
24 | FAST_IO;
25 |
26 | int t;
27 | cin >> t;
28 |
29 | while (t--) {
30 | solve();
31 | }
32 |
33 | return 0;
34 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/AM19MOS/USANBOLT.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 |
9 | int t;
10 | cin >> t;
11 |
12 | while (t--) {
13 | double f, t, d, b;
14 | cin >> f >> d >> t >> b;
15 |
16 | double tiger = sqrt(2*(f + d)/t);
17 | double bolt = f/b;
18 | // cout << tiger << " " << bolt << endl;
19 | if (tiger - bolt > 1e-6) {
20 | cout << "Bolt" << endl;
21 | } else {
22 | cout << "Tiger" << endl;
23 | }
24 | }
25 |
26 | return 0;
27 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/JULY18B/PINS.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main(){
5 |
6 | int total_cases, pin_number;
7 | scanf("%d", &total_cases);
8 |
9 | int num_zeroes;
10 | for(int case_no = 0; case_no < total_cases; case_no ++){
11 | scanf("%d", &pin_number);
12 | // simply divide the pin number by 2 to get the number of zeroes in the denominator
13 | num_zeroes = pin_number / 2;
14 | // numerator is always 1, denominator starts with 1
15 | printf("1 1");
16 | // print the required number of zeroes
17 | for(int zero_count = 0; zero_count < num_zeroes; zero_count ++){
18 | cout << "0";
19 | }
20 | printf("\n");
21 | }
22 |
23 | return 0;
24 | }
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Weekly Contests/179/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | class Solution {
4 | public:
5 | int numTimesAllBlue(vector& light) {
6 | int res = 0;
7 | int max = 0;
8 | int n = light.size();
9 | for (int i = 0; i < n; ++i) {
10 | if (light[i] > max) {
11 | max = light[i];
12 | }
13 | if (max == i + 1) {
14 | ++res;
15 | }
16 | }
17 | return res;
18 | }
19 | };
20 | int main () {
21 | Solution solver;
22 | vector lights = {1, 2, 3, 4};
23 | cout << solver.numTimesAllBlue(lights) << endl;
24 | return 0;
25 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 3 Rounds/641 Div 3/C/C.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | ll n;
9 | cin >> n;
10 |
11 | ll cur = 3;
12 | ll res = 0;
13 | ll k = 1;
14 | while (cur <= n) {
15 | ll term = (cur + cur - 2) * 2;
16 | res += term*k;
17 | cur += 2;
18 | ++k;
19 | }
20 | cout << res << endl;
21 | }
22 |
23 | int main() {
24 | FAST_IO;
25 |
26 | int t;
27 | cin >> t;
28 |
29 | while (t--) {
30 | solve();
31 | }
32 |
33 | return 0;
34 | }
--------------------------------------------------------------------------------
/Problem Solutions/LeetCode/Array/1-Two-Sum_hashing.cpp:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public:
3 | vector twoSum(vector& nums, int target) {
4 | int n = nums.size();
5 | // unordered_set seen;
6 | unordered_map seenIndex;
7 | vector res;
8 | for (int idx = 0; idx < n; ++idx) {
9 | int num = nums[idx];
10 | int other = target - num;
11 | if (seenIndex.find(other) != seenIndex.end()) {
12 | res.push_back(idx);
13 | res.push_back(seenIndex[other]);
14 | return res;
15 | }
16 | seenIndex[num] = idx;
17 | }
18 | return res;
19 | }
20 | };
--------------------------------------------------------------------------------
/Problem Solutions/SPOJ/thelastdigit.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | int mod(int,int);//modular function
4 | int main() {
5 | //will be using modular exponentiation (check wikipedia for details over the algo)
6 | int t;cin>>t;
7 | while(t--){
8 | int a,b;cin>>a>>b;//we need to find last digit of a^b
9 | cout<
2 | using namespace std;
3 |
4 | int balance( string x )
5 | {
6 | stack s;
7 | int ret = 0;
8 | for ( int i = 0; i < x.size(); ++i )
9 | {
10 | char c = x[ i ];
11 | if ( c == '{' )
12 | s.push( c );
13 | else if ( !s.empty() && s.top() == '{' )
14 | s.pop();
15 | else {
16 | ret++;
17 | s.push( '{' );
18 | }
19 | }
20 | ret += s.size() / 2;
21 | return ret;
22 | }
23 |
24 | int main()
25 | {
26 | int i = 1;
27 | while ( true )
28 | {
29 | string x;
30 | cin >> x;
31 | if ( x.find( '-' ) != string::npos )
32 | return 0;
33 | cout << "\n" << i++ << ". " << balance( x );
34 |
35 | }
36 | return 0;
37 | }
38 |
--------------------------------------------------------------------------------
/Problem Solutions/AtCoder/Beginner-Contests/ABC151/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | #define endl "\n"
5 |
6 | int main() {
7 |
8 | FAST_IO;
9 |
10 | int n, k, m;
11 | cin >> n >> k >> m;
12 |
13 | int req = n*m;
14 |
15 | vector a(n);
16 | int sum = 0;
17 | for (int i = 0; i < n - 1; ++i) {
18 | cin >> a[i];
19 | sum += a[i];
20 | }
21 |
22 | int res = req - sum;
23 | if (res <= 0) {
24 | res = 0;
25 | }
26 | if (res > k) {
27 | cout << "-1" << endl;
28 | } else {
29 | cout << res << endl;
30 | }
31 | return 0;
32 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Kotlin/Kotlin Heroes: Episode 4/A.kt:
--------------------------------------------------------------------------------
1 | import java.util.*
2 | import kotlin.math.*
3 |
4 | private fun readLn() = readLine()!! // string line
5 | private fun readInt() = readLn().toInt() // single int
6 | private fun readLong() = readLn().toLong()
7 | private fun readStrings() = readLn().split(" ") // list of strings
8 | private fun readInts() = readStrings().map { it.toInt() } // list of ints
9 | private fun readLongs() = readStrings().map { it.toLong() } // list of ints
10 |
11 | fun main() {
12 | val T = readInt()
13 | for (t in 0 until T) {
14 | var (n, k) = readInts()
15 | var x = n/(1 + k + k*k + k*k*k)
16 | println("${x} ${x*k} ${x*k*k} ${x*k*k*k}")
17 | }
18 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/467A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FOR(i,a,b) for(int i = a; i < b; i ++)
4 | #define RFOR(i,a,b) for(int i = a; i >= b; i --)
5 | #define ln "\n"
6 | #define debug1(x) cout<"<"<"<>n;
15 | int array[n][2];
16 | FOR(i,0,n){
17 | FOR(j,0,2)
18 | cin>>array[i][j];
19 | }
20 | int count = 0;
21 | FOR(i,0,n){
22 | if(array[i][1] - array[i][0] >= 2){
23 | count++;
24 | }
25 | }
26 | cout<
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | class Solution {
7 | public:
8 | ll solve(int n, vector a) {
9 | ll res = 0;
10 | sort(a.begin(), a.end());
11 | for (int i = 0; i < n; ++i) {
12 | res = max(res, a[i]*(n - i));
13 | }
14 | return res;
15 | }
16 | };
17 |
18 | int main() {
19 |
20 | FAST_IO;
21 | int n;
22 | cin >> n;
23 |
24 | vectora(n);
25 | for (int i = 0; i < n; ++i) {
26 | cin >> a[i];
27 | }
28 |
29 | Solution solver;
30 | cout << solver.solve(n, a) << endl;
31 | return 0;
32 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Speed Building Practice/template.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Competitive Coding repository: https://github.com/sahilbansal17/Competitive_Coding
3 | */
4 |
5 | #include
6 | using namespace std;
7 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
8 | typedef long long ll;
9 |
10 | class Solution {
11 | public:
12 |
13 | };
14 |
15 | int main() {
16 |
17 | FAST_IO;
18 |
19 | #ifndef ONLINE_JUDGE
20 | freopen("/Users/sahilbansal/Desktop/input.txt", "r", stdin);
21 | freopen("/Users/sahilbansal/Desktop/output.txt", "w", stdout);
22 | freopen("/Users/sahilbansal/Desktop/error.txt", "w", stderr);
23 | #endif
24 |
25 | Solution solver;
26 |
27 | return 0;
28 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/133A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FOR(i,a,b) for(int i = a; i < b; i ++)
4 | #define RFOR(i,a,b) for(int i = a; i >= b; i --)
5 | #define ln "\n"
6 | #define debug1(x) cout<"<"<"<>s;
15 | int flag = 0;
16 | FOR(i,0,s.size()){
17 | if(s[i] == 'H' || s[i] == 'Q' || s[i] == '9'){
18 | cout<<"YES";
19 | flag = 1;
20 | break;
21 | }
22 | else{
23 | ;
24 | }
25 | }
26 | if(!flag)
27 | cout<<"NO";
28 | return 0;
29 | }
--------------------------------------------------------------------------------
/Problem Solutions/Interviewbit/Binary Search/power_function.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | typedef long long ll;
4 |
5 | class Solution {
6 | public:
7 | int pow(int x, int n, int d);
8 | };
9 |
10 | int Solution::pow(int x, int n, int d) {
11 | ll res = 1;
12 | ll xx = 1ll*x;
13 | while (n) {
14 | if (n & 1) {
15 | res *= xx;
16 | res %= d;
17 | }
18 | xx *= xx;
19 | xx %= d;
20 | n >>= 1;
21 | }
22 | res = (res + d) % d;
23 | return (int)res;
24 | }
25 |
26 | int main() {
27 | int x = 3;
28 | int n = 5;
29 | int d = 10000000007;
30 | Solution solver;
31 | cout << solver.pow(x, n, d) << endl; // 243
32 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Speed Building Practice/1180A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | class Solution {
7 | public:
8 | int solve(int n) {
9 | return 2*n*n - (2*n - 1);
10 | }
11 | };
12 |
13 | int main() {
14 |
15 | FAST_IO;
16 |
17 | #ifndef ONLINE_JUDGE
18 | freopen("/Users/sahilbansal/Desktop/input.txt", "r", stdin);
19 | freopen("/Users/sahilbansal/Desktop/output.txt", "w", stdout);
20 | freopen("/Users/sahilbansal/Desktop/error.txt", "w", stderr);
21 | #endif
22 |
23 | int n;
24 | cin >> n;
25 | Solution solver;
26 | cout << solver.solve(n) << endl;
27 | return 0;
28 | }
--------------------------------------------------------------------------------
/Problem Solutions/HackerEarth/Practice/Arrays/Monk_and_Rotation.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Problem Link: https://www.hackerearth.com/practice/data-structures/arrays/1-d/practice-problems/algorithm/monk-and-rotation-3/
3 | */
4 |
5 | #include
6 | using namespace std;
7 |
8 | int main() {
9 | int t;
10 | cin >> t;
11 |
12 | for (int i = 0; i < t; ++i) {
13 | int n, k;
14 | cin >> n >> k;
15 |
16 | int a[n];
17 | for (int j = 0; j < n; ++j) {
18 | cin >> a[j];
19 | }
20 |
21 | k %= n;
22 | int j = (n - k + n) % n;
23 | int done = 0;
24 | while (done != n) {
25 | cout << a[j] << " ";
26 | ++done;
27 | j = (j + 1) % n;
28 | }
29 | cout << endl;
30 | }
31 | return 0;
32 | }
--------------------------------------------------------------------------------
/Problem Solutions/TopCoder/SRM 737/B_Incomplete.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | typedef long long ll;
5 | typedef vector vi;
6 | typedef pair pii;
7 | #define fl(i, a, b) for(int i(a); i < (b); i ++)
8 | #define rep(i, n) fl(i, 0, n)
9 | #define rfl(i, a, b) for(int i(a); i >= (b); i --)
10 | #define srt(v) sort((v).begin(), (v).end())
11 | #define pb push_back
12 | #define mp make_pair
13 | #define F first
14 | #define S second
15 | const ll MOD = 1000000007LL;
16 |
17 | class AliceAndBobMedium{
18 | public:
19 |
20 | };
21 |
22 | int main(){
23 |
24 | AliceAndBobMedium a;
25 |
26 | cout << "\n" << a. << "\n";
27 | }
--------------------------------------------------------------------------------
/Problem Solutions/fbHackerCup/2018-Qualification-Round/2-Interception.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | int main(){
5 |
6 | #ifndef ONLINE_JUDGE
7 | freopen("/Users/sahilbansal/Downloads/interception.txt", "r", stdin);
8 | freopen("/Users/sahilbansal/Desktop/output.txt", "w", stdout);
9 | #endif
10 |
11 | int test_cases, N, coeff;
12 | scanf("%d", &test_cases);
13 |
14 | for(int case_no = 1; case_no <= test_cases; case_no ++){
15 | printf("Case #%d: ", case_no);
16 | scanf("%d", &N);
17 | for(int i = 0; i <= N; i ++){
18 | scanf("%d", &coeff);
19 | }
20 | if(N & 1){
21 | printf("1\n0.0");
22 | }
23 | else{
24 | printf("0");
25 | }
26 | printf("\n");
27 | }
28 |
29 | return 0;
30 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/118A.py:
--------------------------------------------------------------------------------
1 | # Take string input
2 | s = input()
3 |
4 | # lowercase vowels to be deleted
5 | # vowels = ['a', 'o', 'y', 'e', 'u', 'i']
6 |
7 | # Append upper case in the same list using list comprehension technique
8 | # vowels[6:] = [v.upper() for v in vowels]
9 |
10 | # make a transition table for the translate function
11 | trans_table = str.maketrans('', '', 'aeiouyAEIOUY')
12 |
13 | # delete all the vowels from string s
14 | s = s.translate(trans_table)
15 |
16 | # convert string to lower case
17 | s = s.lower()
18 |
19 | # inset "." in between every character of s using join method
20 | s = ".".join(s)
21 |
22 | # insert "." in the beginning of the string
23 | s = "." + s
24 |
25 | print(s)
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/258 Div 2 Virtual/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | class Solution {
7 | public:
8 | string solve(int n, int m) {
9 | int cnt = n*m;
10 | int steps = 0;
11 | while (cnt > 0) {
12 | --n;
13 | --m;
14 | cnt = n*m;
15 | ++steps;
16 | }
17 | if (steps & 1) {
18 | return "Akshat";
19 | }
20 | return "Malvika";
21 | }
22 | };
23 |
24 | int main() {
25 |
26 | FAST_IO;
27 | int n, m;
28 | cin >> n >> m;
29 |
30 | Solution solver;
31 | string res = solver.solve(n, m);
32 | cout << res << endl;
33 | return 0;
34 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/276A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FOR(i,a,b) for(int i = a; i < b; i ++)
4 | #define RFOR(i,a,b) for(int i = a; i >= b; i --)
5 | #define ln "\n"
6 | #define debug1(x) cout<"<"<"<>n>>k;
16 | while(n--){
17 | int f,t;
18 | cin>>f>>t;
19 | int joy = 0;
20 | if(t > k)
21 | joy = f - (t - k);
22 | else
23 | joy = f;
24 | if(joy > max_joy)
25 | max_joy = joy;
26 | }
27 | cout<
2 | #include
3 | #include
4 | int main()
5 | {
6 | int g;
7 | std::cin >> g;
8 | std::vector ans;
9 | for (int i = 0; i < g; i++)
10 | {
11 | int n;
12 | std::cin >> n;
13 | int s = 0, t;
14 | for (int j = 0; j < n; j++)
15 | {
16 | std::cin >> t;
17 | s = s ^ t;
18 | }
19 | if (s == 0)
20 | {
21 | std::cout << "Second"
22 | << "\n";
23 | }
24 | else
25 | {
26 | std::cout << "First"
27 | << "\n";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Div 2 Rounds/632 Div 2/A.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 | #define endl '\n'
6 |
7 | void solve() {
8 | int n, m;
9 | cin >> n >> m;
10 |
11 | cout << 'W';
12 | for (int i = 1; i < m; ++i) {
13 | cout << 'B';
14 | }
15 | cout << endl;
16 | for (int i = 1; i < n; ++i) {
17 | for (int j = 0; j < m; ++j) {
18 | cout << 'B';
19 | }
20 | cout << endl;
21 | }
22 | }
23 | int main() {
24 | FAST_IO;
25 |
26 | int t;
27 | cin >> t;
28 |
29 | while (t--) {
30 | solve();
31 | }
32 |
33 | return 0;
34 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/AUG19A/DSTAPLS.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * https://www.codechef.com/AUG19A/problems/DSTAPLS
3 | */
4 |
5 | #include
6 | using namespace std;
7 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
8 | typedef long long ll;
9 |
10 | class Solution {
11 | public:
12 | bool solve(ll n, ll k) {
13 | ll iterations = n/k;
14 | return (iterations % k);
15 | }
16 | };
17 |
18 | int main() {
19 | FAST_IO;
20 | int t;
21 | cin >> t;
22 |
23 | for (int i = 0; i < t; ++i) {
24 | ll n, k;
25 | cin >> n >> k;
26 | Solution solver;
27 | if (solver.solve(n, k)) {
28 | cout << "YES" << endl;
29 | } else {
30 | cout << "NO" << endl;
31 | }
32 | }
33 |
34 | return 0;
35 | }
--------------------------------------------------------------------------------
/Problem Solutions/CodeChef/COOK90/SURVIVE.cpp:
--------------------------------------------------------------------------------
1 | /* author : sahilbansal17
2 | date : 21st Jan, 2018
3 | */
4 |
5 | #include
6 |
7 | using namespace std;
8 |
9 |
10 | int main(){
11 |
12 |
13 | #ifndef ONLINE_JUDGE
14 | freopen("input.txt","r",stdin);
15 | freopen("output.txt","w",stdout);
16 | #endif
17 |
18 | int t,n,k,s,res;
19 |
20 | cin >> t;
21 |
22 | while(t--){
23 | cin >> n >> k >> s;
24 |
25 | if(n >= k && s < 7){
26 | res = ceil((1.0*k*s)/n);
27 | }
28 | else if(n < k || ((n == k) && s > 7) ){
29 | res = -1;
30 | }
31 | else{
32 | if(n*6 - k*7 < 0){
33 | res = -1;
34 | }
35 | else{
36 | res = ceil((1.0*k*s)/n);
37 | }
38 | }
39 | cout << res << "\n";
40 | }
41 |
42 | return 0;
43 | }
--------------------------------------------------------------------------------
/Problem Solutions/HackerRank/Problem Solving/Nimble game.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | int main()
5 | {
6 | int t;
7 | std::cin >> t;
8 | for (int i = 0; i < t; i++)
9 | {
10 | int n, a = 0, b;
11 | std::cin >> n;
12 | for (int j = 0; j < n; j++)
13 | {
14 | std::cin >> b;
15 | if (j > 0 && b % 2 == 1)
16 | {
17 | a = a ^ j;
18 | }
19 | }
20 | if (a == 0)
21 | {
22 | std::cout << "Second"
23 | << "\n";
24 | }
25 | else
26 | {
27 | std::cout << "First"
28 | << "\n";
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Global Rounds/Round 6/B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
4 | typedef long long ll;
5 |
6 | int main() {
7 | FAST_IO;
8 |
9 | int n;
10 | cin >> n;
11 |
12 | ll x;
13 | for (int i = 0; i < n; ++i) {
14 | cin >> x;
15 |
16 | bool done = false;
17 | for (int k = 1; k <= 6; ++k) {
18 | if ((x - 7 + k) % 14 == 0 && (x + k - 7) != 0) {
19 | cout << "YES" << endl;
20 | done = true;
21 | break;
22 | }
23 | }
24 | if (!done) {
25 | cout << "NO" << endl;
26 | }
27 | }
28 |
29 | return 0;
30 | }
--------------------------------------------------------------------------------
/Problem Solutions/Codeforces/Tags/implementation/102B.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #define FOR(i,a,b) for(int i = a; i < b; i ++)
4 | #define RFOR(i,a,b) for(int i = a; i >= b; i --)
5 | #define ln "\n"
6 | #define debug1(x) cout<"<"<"<>s;
15 | int count = 0;
16 | long long int sum;
17 | int n = s.size();
18 | while(n != 1)
19 | {
20 | sum = 0;
21 | FOR(i,0,n)
22 | sum += s[i] - '0';
23 | s = to_string(sum);
24 | n = s.size();
25 | //debug1(n);
26 | count++;
27 | }
28 | cout<
2 | using namespace std;
3 | #define FOR(i,a,b) for(int i = a; i < b; i ++)
4 | #define RFOR(i,a,b) for(int i = a; i >= b; i --)
5 | #define ln "\n"
6 | #define debug1(x) cout<"<"<"<>a>>b;
15 | //string c;
16 | char c[a.size()];
17 | FOR(i,0,a.size()){
18 | if((a[i] == '0' && b[i] == '1') || (a[i] == '1' && b[i] == '0')){
19 | c[i] = '1';
20 | }
21 | else{
22 | c[i] = '0';
23 | }
24 | }
25 | FOR(i,0,a.size()){
26 | cout<