├── .gitignore ├── Programming_Languages.java ├── tempCodeRunnerFile.c ├── tempCodeRunnerFile.py ├── tempCodeRunnerFile.cpp ├── Odd_Repeat.bin ├── Hardest_Problem_Bet.bin ├── cutting recepies.c ├── lucky-four.py ├── lapindrome.py ├── packaging_cupcakes.c ├── Decreasing_Srrnmeeida.c ├── sum-of-digits.c ├── TEMPLATE_CP.c ├── Devu_and_Array.cpp ├── .cph ├── .Odd_Sum.cpp_7c7dbd6e2f5ff088008de10c8091afaf.prob ├── .MEX_OR.cpp_4444c348cf1733b3389c3d7abe4f2ee3.prob ├── .Mask_Policy.cpp_2d9cc1514cc1ec9d0d0398d2e584b8ee.prob ├── .Chef_and_Pal.cpp_c1ad6d45630fb041170cc68a5215e134.prob ├── .Blackjack.cpp_d43ddee93ba666c036d97026737e6f80.prob ├── .New_Piece.cpp_72d332ca18e485cc06413ad49e86253d.prob ├── .01_Subsequence.cpp_53c563124e62a45101428daf46c90777.prob ├── .Too_many_items.cpp_71982af964ad03f52d45c5ab4232cee5.prob ├── .Avoid_Contact.cpp_3855bd82b8b2f643fcf09bb80f6bf5a3.prob ├── .Car_Choice.cpp_1862ac52ca9f2b5431ae344c3271f357.prob ├── .GCD_of_Prefixes.cpp_287fbaafa673ac54e737f980077d428b.prob ├── .Magical_Doors.cpp_6e7323f555ca9ec86f3cc1fb01734ee0.prob ├── .The_Two_Dishes.cpp_87862167b6a62e3b5a6e54608e107047.prob ├── .Three_Boxes.cpp_60f4b5c32c961e58f821acee8a08984b.prob ├── .Equal_Coins.cpp_e3695f506abc3bc834680c43d2e31e14.prob ├── .String_Reverse.cpp_8fc0e43f09070a9db95545acc7974189.prob ├── .Three_Boxes.java_60092907a9caf8481339ee52a224d957.prob ├── .Good_Program.cpp_6c43a8994641734fec72ff9484684640.prob ├── .Keplers_Law.cpp_73fff380a15d73b9198d0b4e18781fce.prob ├── .Obtain_the_Sum.cpp_aa11077aca566ed99e7dcc7635916eb7.prob ├── .The_product_mystery.cpp_f2421cc2edb073bf46947b8f2aca4458.prob ├── .Which_Mixture.cpp_1f16acce5b3b7665d8cd5396383e7e02.prob ├── .Average_Flex.cpp_9bcd94ef4f365933dde36038476673d7.prob ├── .Badminton_Serves.cpp_e57cca90c48036017f4ffe4ff724c31d.prob ├── .Chef_and_Water_Car.cpp_593163e96fe5ec498e7d204064e0ac31.prob ├── .Find_the_Direction.cpp_0c054a1ff76f952206bed7b9d9c212e4.prob ├── .Make_it_Divisible.cpp_b1e7f15035e6d794e6cf2fce97e3bfa7.prob ├── .Perfect_Permutation.cpp_2696eabda55339b066e79fb522b302d3.prob ├── .Problem_Category.cpp_d2625c9826121d98b88f1fabd359733d.prob ├── .Travel_Pass.cpp_c98e23176563eff2523235f3c0a7fa53.prob ├── .XOR_Equal.cpp_5dac64fe437dfd40e779f28e8f726dbb.prob ├── .Covid_Spread.cpp_bb9cf3989df33bbecc517ef20e4cf08d.prob ├── .EVM_Hacking.cpp_290fddc0ec86714af1ee2dec7676e703.prob ├── .Equal_Difference.cpp_6e7a8dbdc913383e0d082cd51d996fe6.prob ├── .Hungry_Ashish.cpp_d30a760d9a32c5d1f09407e1bae4271b.prob ├── .List_of_Lists.cpp_fb9f64e920fc08ca29ea5be2fd00e79f.prob ├── .Mean_Maximization.cpp_bbe9a7be231c999568da4572e65d5bf3.prob ├── .Permutation_Xority.cpp_369f031e266920584b6f2b139b1918d5.prob ├── .RCB_and_Playoffs.cpp_9deb787a373ca711264f00b6935b356a.prob ├── .Count_the_Holidays.cpp_0637590285e58768b94843e3d37d4a5f.prob ├── .Palindromes_Not_Allowed.cpp_4678ffaac2b0d890892bf1ff0872e781.prob ├── .Exactly_N_plus_1_Values.cpp_2bdb460196ebbbdd99601bf7714847a3.prob ├── .Longest_AND_Subarray.cpp_daba10da950b169196b67ea9f8901e06.prob ├── .Rapid_Re_Orderings.cpp_e92c3864339e2beb3dedea5af9e0cbf7.prob ├── .Shuffling_Parities.cpp_91bcdfc68bf4ade0804e59263a6de4e4.prob ├── .Weird_Palindrome_Making.cpp_c5d7f533c033b13134877c3509a58f60.prob ├── .Xor_Palindrome.cpp_19adab04cf4bf3b13ca19fb3bcb7d649.prob ├── .Avoid_Fixed_Points.cpp_fee87a211e8ee8107461c420138655b9.prob ├── .Maximum_Light_Up.cpp_3a097734d35bc648f7b3448e0e47e9d0.prob ├── .Minimum_Number_of_Pizzas.cpp_5be3ea3081354fbfed9d0977823134bf.prob ├── .Parallel_Processing.cpp_676edf97a8d0f2a689df2a8c5100dfc4.prob ├── .Valleys_and_Hills.cpp_169da9909f467e748562822e6f93ea30.prob ├── .Prime_in_a_binary_string.cpp_f1ad435390bb087e6df190eee683bd47.prob ├── .The_One_On_The_Last_Night.cpp_0e8b865d5912d9822f5a436c945dff17.prob ├── .Chef_and_Magical_Steps.cpp_5c66750d9355fb4085469c9530163c4f.prob ├── .Chef_and_NextGen.cpp_7824bcd023927b77e6f31515bd8a8834.prob ├── .Genes.cpp_a86a764f71ff0735c93cceda2ac08444.prob ├── .Self_Defence_Training.cpp_99d503d18ecb38c2272434121bbd00db.prob ├── .Subarray_permutations.cpp_0f000bbfd588ca256a71efbedb8aaa57.prob ├── .The_Grid_Fill_Problem.cpp_64a4d8b14adbdef07d40add9d66a1778.prob ├── .Airline_Restrictions.cpp_9345bb74ac96bdc428c97b5a8971dcb2.prob ├── .Alternating_Work_Days.cpp_34e9676d063149e52dc6e9a1e3bc4907.prob ├── .Distinct_Binary_Strings.cpp_0180c1d1c949340c764b1b1e96f71fdf.prob ├── .Good_Weather.cpp_6dfc433a1e3bae209ebbc76f23ef5d0d.prob ├── .Hill_Sequence.cpp_21576e4a7d18f1af9efc16b08583e5e2.prob ├── .Say_No_To_Drugs.cpp_f4f9f70d7ddfa0f3fe70538fc7f94bf4.prob ├── .The_One_with_All_the_Candy.cpp_7741d3421b3dd97e4e2f7ae54a4eec49.prob ├── .Three_Points.cpp_69f67e0518f0030a9ab8e27a1b927d64.prob ├── .Chef_and_Stock_Prices_.cpp_94bfd59759ea67cd28b037ce6fc080d7.prob ├── .Diagonal_movement.cpp_ce13d710374ac83a0fd51b643bf9471d.prob ├── .Utkarsh_and_Placement_tests.cpp_2b707ccc4157ad2e0f17aa74f37a1f2d.prob ├── .Fixed_number_of_Fixed_Points.cpp_3bc1bc0094e8fbf571c902af65b7438b.prob ├── .The_One_with_Russ.cpp_013dfafe08cfaadb690283b52de0da6a.prob ├── .Prefix_Permutation.cpp_191d3f568c42794a89ab8daa60e6274f.prob ├── .Watching_Movies_at_2_x.cpp_ac0efdefecb97aed2ebbe5eef260ca45.prob ├── .Chef_and_Pairing_Slippers.cpp_438b65fbc14fd33b3f77cef9fd3380c2.prob ├── .Four_Equidistant_Points_on_a_Grid.cpp_3ff0f322e32035eacf4ed8a0fa599b4d.prob ├── .World_Chess_Championship.cpp_7745bd289c5fb63d147f8003da95f59f.prob └── .Team_Formation.cpp_9597a9f9b849803c734594092397dd5d.prob ├── ATM_codechef.c ├── TEMPLETE_CP.cpp ├── split_string.c ├── codechef_splitstring.c ├── cutting_recipies.py ├── chef_&_quaries.c ├── sin_&_cos.c ├── Coin_flip.c ├── XOR_Compare.c ├── Gold_Trip.c ├── Flip_strings.c ├── XOR_Equal.cpp ├── FoodChain.cpp ├── covid_codechef.c ├── Chef_and_Fruits.c ├── Smart_Phone1.cpp ├── Three_Points.cpp ├── Prime_in_a_binary_string.cpp ├── Chef_&_GCD.cpp ├── Kitchen_timetable.c ├── ProblemDifficulties.cpp ├── Count_subarray.c ├── Play_Piano.cpp ├── Genes.cpp ├── sum-and-puppy.c ├── Badminton_Serves.cpp ├── Chef_and_Pairing_Slippers.cpp ├── Pass_or_Fail.cpp ├── RCB_and_Playoffs.cpp ├── Playing_with_strings.cpp ├── XOR_OR_ED.cpp ├── Chef_and_Lockout_Draws.cpp ├── Ada_dishes.cpp ├── Secret_recipe.cpp ├── Forgotten_String.cpp ├── Maximum_Length_Even_Subarray.cpp ├── Large_Squares.cpp ├── Chef_and_IPC.c ├── Problem_Category.cpp ├── MaxArrXOR.cpp ├── Which_Mixture.cpp ├── Hardest_Problem_Bet.cpp ├── Hungry_Ashish.cpp ├── Blackjack.cpp ├── Too_many_items.cpp ├── Diagonal_movement.cpp ├── Minimum_Number_of_Pizzas.cpp ├── Obtain_the_Sum.cpp ├── Keplers_Law.cpp ├── Ada_dishes.c ├── Chef_and_Pal.cpp ├── The_product_mystery.cpp ├── Three_Boxes.cpp ├── Programming_Languages.cpp ├── Utkarsh_and_Placement_tests.cpp ├── Mask_Policy.cpp ├── Distinct_Binary_Strings.cpp ├── Magical_Doors.cpp ├── Weird_Palindrome_Making_GOODQ.cpp ├── Palindromes_Not_Allowed.cpp ├── Restore_sequenceCC.cpp ├── Find_the_Direction.cpp ├── Maximum_Light_Up.cpp ├── Chef_and_Stock_Prices_.cpp ├── Travel_Pass.cpp ├── Chef_and_NextGen.cpp ├── Four_Equidistant_Points_on_a_Grid.cpp ├── Chef_and_Water_Car.cpp ├── Make_it_Divisible.cpp ├── Airline_Restrictions.cpp ├── New_Piece.cpp ├── Encoding_Message.cpp ├── The_Two_Dishes.cpp ├── Avoid_Contact.cpp ├── Alternating_Work_Days.cpp ├── Special_Products.cpp ├── Avoid_Fixed_Points.cpp ├── Good_Weather.cpp ├── String_Reverse.cpp ├── Odd_Sum.cpp ├── The_One_with_All_the_Candy.cpp ├── Professor_And_Directions.cpp ├── Movie_weekend.c ├── Prefix_Permutation.cpp ├── MEX_OR.cpp ├── Chef_and_Bulb_Invention.AUG_LCcpp.cpp ├── Shuffling_Parities.cpp ├── Bear_milky_Cookies.cpp ├── Careless_Chef.cpp ├── Mean_Maximization.cpp ├── Permutation_Xority.cpp ├── Count_the_Holidays.cpp ├── Exactly_N_plus_1_Values.cpp ├── Average_Flex.cpp ├── Equal_Difference.cpp ├── Subarray_permutations.cpp ├── GCD_of_Prefixes.cpp ├── Gasoline_introduction.cpp ├── The_One_with_Russ.cpp ├── Equal_Coins.cpp ├── RedAlert.cpp ├── Joker_and_Batman.cpp ├── Chef_and_Subset_Additions.cpp ├── Control_the_Pollution.cpp ├── Say_No_To_Drugs.cpp ├── Chef_And_Salary_Pay.cpp ├── Perfect_Permutation.cpp ├── Beautiful_Pairs_IMPORTANT.cpp ├── Team_Formation.cpp ├── The_Grid_Fill_Problem.cpp ├── World_Chess_Championship.cpp ├── Restore_sequence.c ├── Crossing_Blocks_IMPORTANT_LunchTime.cpp ├── Xor_Palindrome.cpp ├── Chef_and_InfinitePlane.cpp ├── Fixed_number_of_Fixed_Points_IMPORTANT.cpp ├── The_One_On_The_Last_Night.cpp └── Longest_AND_Subarray.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.exe 3 | -------------------------------------------------------------------------------- /Programming_Languages.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tempCodeRunnerFile.c: -------------------------------------------------------------------------------- 1 | z = a[i] - a[i - 1]; 2 | -------------------------------------------------------------------------------- /tempCodeRunnerFile.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | for _ in range(t): -------------------------------------------------------------------------------- /tempCodeRunnerFile.cpp: -------------------------------------------------------------------------------- 1 | for (i = 0; i < n; i++) 2 | cin >> s[i]; -------------------------------------------------------------------------------- /Odd_Repeat.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niharika2k00/Codechef_codes/HEAD/Odd_Repeat.bin -------------------------------------------------------------------------------- /Hardest_Problem_Bet.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niharika2k00/Codechef_codes/HEAD/Hardest_Problem_Bet.bin -------------------------------------------------------------------------------- /cutting recepies.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int 8 | 9 | 10 | 11 | } -------------------------------------------------------------------------------- /lucky-four.py: -------------------------------------------------------------------------------- 1 | 2 | t = int(input("Enter value of test-case : ")) 3 | for i in range(t): 4 | counter = 0 5 | n = int(input("Enter a number : ")) 6 | while(n > 0): 7 | digit = n % 10 # mod - remainder 8 | 9 | if (digit == 4): 10 | counter = counter + 1 11 | 12 | n = n // 10 13 | 14 | print(counter) 15 | -------------------------------------------------------------------------------- /lapindrome.py: -------------------------------------------------------------------------------- 1 | # cook your dish here 2 | # LINKS :: https://www.codechef.com/problems/LAPIN 3 | 4 | 5 | """ t = int(input()) 6 | for _ in range(t): """ 7 | 8 | w = input() 9 | r = len(w)//2 10 | print(r) 11 | if len(w) % 2 != 0: 12 | w = w[:r] + w[r+1:] 13 | w1 = w[:r] 14 | w2 = w[r:] 15 | if sorted(w1) == sorted(w2): 16 | print('YES') 17 | else: 18 | print('NO') 19 | -------------------------------------------------------------------------------- /packaging_cupcakes.c: -------------------------------------------------------------------------------- 1 | 2 | //pancake problem in the codechef. 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | int t, n, pack; 9 | printf("enter t value : "); 10 | scanf("%d", &t); 11 | while (t--) 12 | { 13 | printf("enter n value : "); 14 | scanf("%d", &n); 15 | pack = (n / 2) + 1; 16 | printf("%d \n", pack); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Decreasing_Srrnmeeida.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | int t; 8 | scanf("%d", &t); 9 | 10 | while (t--) 11 | { 12 | int l, r; 13 | scanf("%d %d", &l, &r); 14 | if (r < l * 2) 15 | printf("%d\n", r); 16 | else 17 | printf("-1\n"); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /sum-of-digits.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int x, i, k, n, t; 8 | scanf("%d", &t); 9 | 10 | while (t--) 11 | { 12 | scanf("%d", &x); 13 | int sum = 0; 14 | 15 | for (i = x; i > 0; i = i / 10) 16 | { 17 | k = i; 18 | n = k % 10; 19 | sum = sum + n; 20 | } 21 | printf("%d \n", sum); 22 | // t--; 23 | } 24 | } -------------------------------------------------------------------------------- /TEMPLATE_CP.c: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define ll long long 9 | #define loop1(n) for (ll i = 0; i < (n); i++) 10 | #define loop2(n) for (ll i = 1; i <= (n); i++) 11 | // #define test ll t; cin>>t; while(t--) 12 | #define test \ 13 | ll t; \ 14 | scanf("%lld", &t); \ 15 | while (t--) 16 | 17 | int main() 18 | { 19 | // serve your dish 20 | 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /Devu_and_Array.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define pb push_back 13 | #define mp make_pair 14 | #define loop1(n) for (ll i = 0; i < (n); i++) 15 | #define loop2(n) for (ll i = 1; i <= (n); i++) 16 | #define test ll t; cin>>t; while(t--) 17 | 18 | int main() 19 | { 20 | ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 21 | 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /.cph/.Odd_Sum.cpp_7c7dbd6e2f5ff088008de10c8091afaf.prob: -------------------------------------------------------------------------------- 1 | {"name":"Odd Sum","group":"CodeChef - October Cook-Off 2021 Division 3","url":"https://www.codechef.com/COOK134C/problems/ODDSUM","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1635192162018,"input":"1\n3","output":"3"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"OddSum"}},"batch":{"id":"3f19eff2-eed5-4757-8355-504f601cc732","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Odd_Sum.cpp"} -------------------------------------------------------------------------------- /.cph/.MEX_OR.cpp_4444c348cf1733b3389c3d7abe4f2ee3.prob: -------------------------------------------------------------------------------- 1 | {"name":"MEX-OR","group":"CodeChef - October Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/OCT21C/problems/MEXOR","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1633363809703,"input":"4\n0\n1\n2\n5","output":"1\n2\n2\n4"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"MEXOR"}},"batch":{"id":"d6df9c7f-e4f7-4150-8703-42daa9b8ba40","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\MEX_OR.cpp"} -------------------------------------------------------------------------------- /.cph/.Mask_Policy.cpp_2d9cc1514cc1ec9d0d0398d2e584b8ee.prob: -------------------------------------------------------------------------------- 1 | {"name":"Mask Policy","group":"CodeChef - January Cook-Off 2022 Division 3","url":"https://www.codechef.com/COOK137C/problems/MASKPOL","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1642950331483,"input":"3\n2 1\n3 2\n3 1","output":"1\n1\n1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"MaskPolicy"}},"batch":{"id":"0d2c9d48-3ba3-4707-b710-dbd545c77f68","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Mask_Policy.cpp"} -------------------------------------------------------------------------------- /.cph/.Chef_and_Pal.cpp_c1ad6d45630fb041170cc68a5215e134.prob: -------------------------------------------------------------------------------- 1 | {"name":"Chef and Pal","group":"CodeChef - CodeChef Starters 20 Division 3 (Rated)","url":"https://www.codechef.com/START20C/problems/ANTIPAL","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1639579845210,"input":"2\n9\n8","output":"-1\n10010110"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ChefAndPal"}},"batch":{"id":"44bfe3cb-5475-4296-b308-cbe3e242949c","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Chef_and_Pal.cpp"} -------------------------------------------------------------------------------- /.cph/.Blackjack.cpp_d43ddee93ba666c036d97026737e6f80.prob: -------------------------------------------------------------------------------- 1 | {"name":"Blackjack","group":"CodeChef - CodeChef Starters 27 Division 3 (Rated)","url":"https://www.codechef.com/START27C/problems/BLACKJACK","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"input":"3\n1 10\n1 5\n4 9\n","output":"10\n-1\n8\n","id":1645626772006}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"Blackjack"}},"batch":{"id":"7f92eb2a-763c-4404-9e35-34ff0a2263b6","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Blackjack.cpp"} -------------------------------------------------------------------------------- /.cph/.New_Piece.cpp_72d332ca18e485cc06413ad49e86253d.prob: -------------------------------------------------------------------------------- 1 | {"name":"New Piece","group":"CodeChef - CodeChef Starters 17 Division 3 (Rated)","url":"https://www.codechef.com/START17C/problems/NEWPIECE","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1637161195068,"input":"3\n1 1 8 8\n5 7 5 8\n3 3 3 3","output":"2\n1\n0"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"NewPiece"}},"batch":{"id":"fcc8f27f-c629-4e26-a3c2-517d55912372","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\New_Piece.cpp"} -------------------------------------------------------------------------------- /.cph/.01_Subsequence.cpp_53c563124e62a45101428daf46c90777.prob: -------------------------------------------------------------------------------- 1 | {"name":"01 Subsequence","group":"CodeChef - October Cook-Off 2021 Division 3","url":"https://www.codechef.com/COOK134C/problems/ZEROONE","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"input":"1\n4\n2 3 4 3\n","output":"4 3 2 3\n30\n","id":1635337464336}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"Subsequence"}},"batch":{"id":"89f6299b-4390-4a7d-8b41-5161912aac0f","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\01_Subsequence.cpp"} -------------------------------------------------------------------------------- /.cph/.Too_many_items.cpp_71982af964ad03f52d45c5ab4232cee5.prob: -------------------------------------------------------------------------------- 1 | {"name":"Too many items","group":"CodeChef - CodeChef Starters 27 Division 3 (Rated)","url":"https://www.codechef.com/START27C/problems/POLYBAGS","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1645627177358,"input":"3\n20\n24\n99","output":"2\n3\n10"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"TooManyItems"}},"batch":{"id":"0f744d4c-fbcf-493d-8c12-e9c979202b5c","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Too_many_items.cpp"} -------------------------------------------------------------------------------- /.cph/.Avoid_Contact.cpp_3855bd82b8b2f643fcf09bb80f6bf5a3.prob: -------------------------------------------------------------------------------- 1 | {"name":"Avoid Contact","group":"CodeChef - CodeChef Starters 24 Division 3 (Rated)","url":"https://www.codechef.com/START24C/problems/AVOIDCONTACT","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1643812595711,"input":"3\n4 0\n5 3\n3 3","output":"4\n8\n5"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"AvoidContact"}},"batch":{"id":"a7e0754b-2feb-40d7-b515-c8a190800c0b","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Avoid_Contact.cpp"} -------------------------------------------------------------------------------- /.cph/.Car_Choice.cpp_1862ac52ca9f2b5431ae344c3271f357.prob: -------------------------------------------------------------------------------- 1 | {"name":"Car Choice","group":"CodeChef - CodeChef Starters 28 Division 3 (Rated)","url":"https://www.codechef.com/START28C/problems/CARCHOICE","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1646231709608,"input":"3\n10 5 3 20\n7 2 7 2\n1 5 3 2","output":"-1\n0\n1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"CarChoice"}},"batch":{"id":"5b12de83-b8e3-4b35-807c-4d0fab5e0c4d","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Car_Choice.cpp"} -------------------------------------------------------------------------------- /.cph/.GCD_of_Prefixes.cpp_287fbaafa673ac54e737f980077d428b.prob: -------------------------------------------------------------------------------- 1 | {"name":"GCD of Prefixes","group":"CodeChef - CodeChef Starters 17 Division 3 (Rated)","url":"https://www.codechef.com/START17C/problems/GCDPRF","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1637162878083,"input":"2\n2\n4 2\n2\n1 3","output":"4 26\n-1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"GCDOfPrefixes"}},"batch":{"id":"6ab416b2-89a8-46a1-b3f2-7ca0edacf32c","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\GCD_of_Prefixes.cpp"} -------------------------------------------------------------------------------- /.cph/.Magical_Doors.cpp_6e7323f555ca9ec86f3cc1fb01734ee0.prob: -------------------------------------------------------------------------------- 1 | {"name":"Magical Doors","group":"CodeChef - CodeChef Starters 13 Division 3 (Rated)","url":"https://www.codechef.com/START13C/problems/MAGDOORS","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1632910663378,"input":"3\n111\n010\n10011","output":"0\n3\n2"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"MagicalDoors"}},"batch":{"id":"41fef074-0842-43ee-ac0f-6b487f720279","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Magical_Doors.cpp"} -------------------------------------------------------------------------------- /.cph/.The_Two_Dishes.cpp_87862167b6a62e3b5a6e54608e107047.prob: -------------------------------------------------------------------------------- 1 | {"name":"The Two Dishes","group":"CodeChef - CodeChef Starters 11 Division 3 (Rated)","url":"https://www.codechef.com/START11C/problems/MAX_DIFF","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1631717662085,"input":"3\n3 1\n4 4\n2 3","output":"1\n4\n1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"TheTwoDishes"}},"batch":{"id":"651f03ef-7b37-4219-881e-4adc2c19f493","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\The_Two_Dishes.cpp"} -------------------------------------------------------------------------------- /.cph/.Three_Boxes.cpp_60f4b5c32c961e58f821acee8a08984b.prob: -------------------------------------------------------------------------------- 1 | {"name":"Three Boxes","group":"CodeChef - October Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/OCT21C/problems/THREEBOX","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1633293429119,"input":"3\n2 3 5 10\n1 2 3 5\n3 3 4 4","output":"1\n2\n3"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ThreeBoxes"}},"batch":{"id":"51acdcf6-b876-47a5-be23-5d3e7e020cea","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Three_Boxes.cpp"} -------------------------------------------------------------------------------- /.cph/.Equal_Coins.cpp_e3695f506abc3bc834680c43d2e31e14.prob: -------------------------------------------------------------------------------- 1 | {"name":"Equal Coins","group":"CodeChef - November Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/NOV21C/problems/EQUALCOIN","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1636578297108,"input":"4\n2 2\n1 3\n4 0\n1 10","output":"YES\nNO\nYES\nNO"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"EqualCoins"}},"batch":{"id":"a3e807d8-be76-421a-963c-ba0e3a7990ae","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Equal_Coins.cpp"} -------------------------------------------------------------------------------- /.cph/.String_Reverse.cpp_8fc0e43f09070a9db95545acc7974189.prob: -------------------------------------------------------------------------------- 1 | {"name":"String Reverse","group":"CodeChef - CodeChef Starters 27 Division 3 (Rated)","url":"https://www.codechef.com/START27C/problems/STR_REVERSE","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1645631817711,"input":"2\nabdeba\ncodechef","output":"3\n7"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"StringReverse"}},"batch":{"id":"8e8f0df8-0544-45e1-b7c4-23c4e72399d9","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\String_Reverse.cpp"} -------------------------------------------------------------------------------- /.cph/.Three_Boxes.java_60092907a9caf8481339ee52a224d957.prob: -------------------------------------------------------------------------------- 1 | {"name":"Three Boxes","group":"CodeChef - October Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/OCT21C/problems/THREEBOX","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"input":"3\n2 3 5 10\n1 2 3 5\n3 3 4 4\n","output":"1\n2\n3\n","id":1633293379965}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ThreeBoxes"}},"batch":{"id":"399e7b05-9cfb-4815-8257-df1028b7873d","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Three_Boxes.java"} -------------------------------------------------------------------------------- /.cph/.Good_Program.cpp_6c43a8994641734fec72ff9484684640.prob: -------------------------------------------------------------------------------- 1 | {"name":"Good Program","group":"CodeChef - February Lunchtime 2022 Division 3","url":"https://www.codechef.com/LTIME105C/problems/NIBBLE","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1646145083651,"input":"4\n8\n17\n52\n3","output":"Good\nNot Good\nGood\nNot Good"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"GoodProgram"}},"batch":{"id":"293fbcdd-4840-4f59-be24-71efcd8481ed","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Good_Program.cpp"} -------------------------------------------------------------------------------- /.cph/.Keplers_Law.cpp_73fff380a15d73b9198d0b4e18781fce.prob: -------------------------------------------------------------------------------- 1 | {"name":"Keplers Law","group":"CodeChef - January Long 2022 - I, Division 3 (Rated)","url":"https://www.codechef.com/JAN221C/problems/KEPLERSLAW","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"input":"3\n1 1 1 1\n1 2 3 4\n1 8 2 8\n","output":"Yes\nNo\nYes\n","id":1641628867907}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"KeplersLaw"}},"batch":{"id":"d0d09e1d-c389-4656-969c-8c0b8248ab9b","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Keplers_Law.cpp"} -------------------------------------------------------------------------------- /.cph/.Obtain_the_Sum.cpp_aa11077aca566ed99e7dcc7635916eb7.prob: -------------------------------------------------------------------------------- 1 | {"name":"Obtain the Sum","group":"CodeChef - CodeChef Starters 11 Division 3 (Rated)","url":"https://www.codechef.com/START11C/problems/BIGARRAY","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1631719842213,"input":"4\n4 8\n5 10\n2 3\n5 17","output":"2\n5\n-1\n-1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ObtainTheSum"}},"batch":{"id":"3741e552-4720-451f-bd4e-f04d72b43e64","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Obtain_the_Sum.cpp"} -------------------------------------------------------------------------------- /.cph/.The_product_mystery.cpp_f2421cc2edb073bf46947b8f2aca4458.prob: -------------------------------------------------------------------------------- 1 | {"name":"The product mystery","group":"CodeChef - CodeChef Starters 27 Division 3 (Rated)","url":"https://www.codechef.com/START27C/problems/PRODUCT","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1645627510244,"input":"2\n2 4\n8 12","output":"2\n3"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"TheProductMystery"}},"batch":{"id":"725f2e56-29b2-4300-94af-cb6018f79f46","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\The_product_mystery.cpp"} -------------------------------------------------------------------------------- /.cph/.Which_Mixture.cpp_1f16acce5b3b7665d8cd5396383e7e02.prob: -------------------------------------------------------------------------------- 1 | {"name":"Which Mixture","group":"CodeChef - October Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/OCT21C/problems/MIXTURE","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1633283701021,"input":"3\n10 5\n0 3\n3 0","output":"Solution\nLiquid\nSolid"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"WhichMixture"}},"batch":{"id":"e50a8c60-b42b-47d6-bf8e-989db0ae06b4","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Which_Mixture.cpp"} -------------------------------------------------------------------------------- /ATM_codechef.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int amtwithdraw; 8 | float total, netbalance, x; 9 | scanf("%d", &amtwithdraw); 10 | scanf("%f", &total); 11 | 12 | if (amtwithdraw + 0.50 > total) 13 | printf("%.2f\n", total); 14 | 15 | else if ((amtwithdraw + 0.50 <= total) && (amtwithdraw % 5 == 0)) 16 | { 17 | x = total - amtwithdraw; 18 | netbalance = x - 0.50; 19 | printf("%.2f\n", netbalance); 20 | } 21 | else if ((amtwithdraw + 0.50 <= total) && (amtwithdraw % 5 != 0)) 22 | printf("%.2f\n", total); 23 | } -------------------------------------------------------------------------------- /TEMPLETE_CP.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define vll vector 13 | #define pb push_back 14 | #define mp make_pair 15 | #define loop1(n) for (ll i = 0; i < (n); i++) 16 | #define loop2(n) for (ll i = 1; i <= (n); i++) 17 | #define test \ 18 | ll t; \ 19 | cin >> t; \ 20 | while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /.cph/.Average_Flex.cpp_9bcd94ef4f365933dde36038476673d7.prob: -------------------------------------------------------------------------------- 1 | {"name":"Average Flex","group":"CodeChef - October Cook-Off 2021 Division 3","url":"https://www.codechef.com/COOK134C/problems/AVGFLEX","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"input":"3\n3\n100 100 100\n3\n2 1 3\n4\n30 1 30 30\n","output":"3\n2\n3\n","id":1635189046384}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"AverageFlex"}},"batch":{"id":"0d0749fc-47bf-429d-9184-5bb972dcd6bb","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Average_Flex.cpp"} -------------------------------------------------------------------------------- /.cph/.Badminton_Serves.cpp_e57cca90c48036017f4ffe4ff724c31d.prob: -------------------------------------------------------------------------------- 1 | {"name":"Badminton Serves","group":"CodeChef - CodeChef Starters 24 Division 3 (Rated)","url":"https://www.codechef.com/START24C/problems/BADMINTON","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1643812361069,"input":"4\n2\n9\n53\n746","output":"2\n5\n27\n374"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"BadmintonServes"}},"batch":{"id":"91b964bc-0d70-420e-bb85-fba4920dd706","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Badminton_Serves.cpp"} -------------------------------------------------------------------------------- /.cph/.Chef_and_Water_Car.cpp_593163e96fe5ec498e7d204064e0ac31.prob: -------------------------------------------------------------------------------- 1 | {"name":"Chef and Water Car","group":"CodeChef - October Lunchtime 2021 Division 3","url":"https://www.codechef.com/LTIME101C/problems/CHEFCAR","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1636048162063,"input":"3\n3 1\n4 2\n4 3","output":"3 3\n6 4\n6 3"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ChefAndWaterCar"}},"batch":{"id":"a0225b92-38a3-4143-a61d-5400662bd6b0","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Chef_and_Water_Car.cpp"} -------------------------------------------------------------------------------- /.cph/.Find_the_Direction.cpp_0c054a1ff76f952206bed7b9d9c212e4.prob: -------------------------------------------------------------------------------- 1 | {"name":"Find the Direction","group":"CodeChef - CodeChef Starters 11 Division 3 (Rated)","url":"https://www.codechef.com/START11C/problems/FACEDIR","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1631716486689,"input":"3\n1\n3\n6","output":"East\nWest\nSouth"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"FindTheDirection"}},"batch":{"id":"b01be2b9-6621-466b-95ef-6b579bef69ea","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Find_the_Direction.cpp"} -------------------------------------------------------------------------------- /.cph/.Make_it_Divisible.cpp_b1e7f15035e6d794e6cf2fce97e3bfa7.prob: -------------------------------------------------------------------------------- 1 | {"name":"Make it Divisible","group":"CodeChef - CodeChef Starters 12 Division 3 (Rated)","url":"https://www.codechef.com/START12C/problems/MAKEDIV3","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1632321851218,"input":"5\n1\n2\n3\n5\n6","output":"3\n15\n123"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"MakeItDivisible"}},"batch":{"id":"bed13b37-6a5b-4739-860f-ca6580ac22c0","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Make_it_Divisible.cpp"} -------------------------------------------------------------------------------- /.cph/.Perfect_Permutation.cpp_2696eabda55339b066e79fb522b302d3.prob: -------------------------------------------------------------------------------- 1 | {"name":"Perfect Permutation","group":"CodeChef - February Cook-Off 2022 Division 3","url":"https://www.codechef.com/COOK138C/problems/PERFPERM","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1646225953097,"input":"2\n1 1\n6 2","output":"1\n4 5 6 1 2 3"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"PerfectPermutation"}},"batch":{"id":"b720f31a-9017-412a-b0cc-bee825fac982","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Perfect_Permutation.cpp"} -------------------------------------------------------------------------------- /.cph/.Problem_Category.cpp_d2625c9826121d98b88f1fabd359733d.prob: -------------------------------------------------------------------------------- 1 | {"name":"Problem Category","group":"CodeChef - October Lunchtime 2021 Division 3","url":"https://www.codechef.com/LTIME101C/problems/PROBCAT","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"input":"3\n50\n172\n201\n","output":"Easy\nMedium\nHard\n","id":1635343548906}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ProblemCategory"}},"batch":{"id":"ed2055a5-201e-40d6-af82-c4d860a82906","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Problem_Category.cpp"} -------------------------------------------------------------------------------- /.cph/.Travel_Pass.cpp_c98e23176563eff2523235f3c0a7fa53.prob: -------------------------------------------------------------------------------- 1 | {"name":"Travel Pass","group":"CodeChef - September Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/SEPT21C/problems/TRAVELPS","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"input":"3\n2 1 2\n00\n2 1 1\n01\n4 2 1\n1101\n","output":"2\n2\n5\n","id":1631041836732}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"TravelPass"}},"batch":{"id":"869c666d-0207-4895-bf39-e8e870be99af","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Travel_Pass.cpp"} -------------------------------------------------------------------------------- /.cph/.XOR_Equal.cpp_5dac64fe437dfd40e779f28e8f726dbb.prob: -------------------------------------------------------------------------------- 1 | {"name":"XOR Equal","group":"CodeChef - September Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/SEPT21C/problems/PALINT","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1631101469671,"input":"3\n3 2\n1 2 3\n5 100\n1 2 3 4 5\n4 1\n2 2 6 6","output":"2 1\n1 0\n2 0"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"XOREqual"}},"batch":{"id":"2660e07f-d303-4080-907c-a9bfef970bde","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\XOR_Equal.cpp"} -------------------------------------------------------------------------------- /.cph/.Covid_Spread.cpp_bb9cf3989df33bbecc517ef20e4cf08d.prob: -------------------------------------------------------------------------------- 1 | {"name":"Covid Spread","group":"CodeChef - January Long 2022 - I, Division 3 (Rated)","url":"https://www.codechef.com/JAN221C/problems/COVSPRD","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1641629305351,"input":"4\n100 3\n2000 10\n6000 11\n10 11","output":"8\n1024\n3072\n10"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"CovidSpread"}},"batch":{"id":"de32f218-1038-4ad3-b2b3-23882c81b784","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Covid_Spread.cpp"} -------------------------------------------------------------------------------- /.cph/.EVM_Hacking.cpp_290fddc0ec86714af1ee2dec7676e703.prob: -------------------------------------------------------------------------------- 1 | {"name":"EVM Hacking","group":"CodeChef - CodeChef Starters 24 Division 3 (Rated)","url":"https://www.codechef.com/START24C/problems/EVMHACK","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1643813488644,"input":"3\n1 1 1 3 3 3\n49 1 49 50 100 50\n0 0 0 1 1 1","output":"YES\nYES\nNO"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"EVMHacking"}},"batch":{"id":"ee89a5d5-2af2-444c-a39c-f25e27faab69","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\EVM_Hacking.cpp"} -------------------------------------------------------------------------------- /.cph/.Equal_Difference.cpp_6e7a8dbdc913383e0d082cd51d996fe6.prob: -------------------------------------------------------------------------------- 1 | {"name":"Equal Difference","group":"CodeChef - August Cook-Off 2021 Division 3","url":"https://www.codechef.com/COOK132C/problems/EQDIFFER","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1629653598532,"input":"3\n2\n1 2\n5\n2 5 1 2 2\n4\n1 2 1 2","output":"0\n2\n2"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"EqualDifference"}},"batch":{"id":"9daf1069-dd20-446e-b18a-3dcac2662411","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Equal_Difference.cpp"} -------------------------------------------------------------------------------- /.cph/.Hungry_Ashish.cpp_d30a760d9a32c5d1f09407e1bae4271b.prob: -------------------------------------------------------------------------------- 1 | {"name":"Hungry Ashish","group":"CodeChef - January Cook-Off 2022 Division 3","url":"https://www.codechef.com/COOK137C/problems/PIZZA_BURGER","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1642948355416,"input":"3\n50 40 60\n40 55 39\n30 42 37","output":"PIZZA\nBURGER\nNOTHING"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"HungryAshish"}},"batch":{"id":"e1134fcf-7aae-40cc-b0e0-d81f3d52d5a4","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Hungry_Ashish.cpp"} -------------------------------------------------------------------------------- /.cph/.List_of_Lists.cpp_fb9f64e920fc08ca29ea5be2fd00e79f.prob: -------------------------------------------------------------------------------- 1 | {"name":"List of Lists","group":"CodeChef - December Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/DEC21C/problems/LISTLIST","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1639119958867,"input":"4\n1\n1\n2\n1 2\n3\n1 1 2\n4\n4 4 9 4","output":"0\n-1\n2"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ListOfLists"}},"batch":{"id":"45bbac75-f2d4-4f80-9910-14d846808728","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\List_of_Lists.cpp"} -------------------------------------------------------------------------------- /.cph/.Mean_Maximization.cpp_bbe9a7be231c999568da4572e65d5bf3.prob: -------------------------------------------------------------------------------- 1 | {"name":"Mean Maximization","group":"CodeChef - January Cook-Off 2022 Division 3","url":"https://www.codechef.com/COOK137C/problems/MEANMAX","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1642953527410,"input":"2\n2\n4 5\n5\n2 2 2 2 2","output":"9.000000\n4.000000"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"MeanMaximization"}},"batch":{"id":"9ddacc55-678b-4862-8105-4132b36f515d","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Mean_Maximization.cpp"} -------------------------------------------------------------------------------- /.cph/.Permutation_Xority.cpp_369f031e266920584b6f2b139b1918d5.prob: -------------------------------------------------------------------------------- 1 | {"name":"Permutation Xority","group":"CodeChef - CodeChef Starters 28 Division 3 (Rated)","url":"https://www.codechef.com/START28C/problems/PERMXORITY","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1646233581686,"input":"2\n3\n6","output":"3 2 1\n5 2 3 6 4 1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"PermutationXority"}},"batch":{"id":"aa899cda-d1c6-400e-adb3-c2b0b4840933","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Permutation_Xority.cpp"} -------------------------------------------------------------------------------- /.cph/.RCB_and_Playoffs.cpp_9deb787a373ca711264f00b6935b356a.prob: -------------------------------------------------------------------------------- 1 | {"name":"RCB and Playoffs","group":"CodeChef - CodeChef Starters 14 Division 3 (Rated)","url":"https://www.codechef.com/START14C/problems/RCBPLAY","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1632925932028,"input":"3\n4 10 8\n3 6 1\n4 8 2","output":"YES\nNO\nYES"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"RCBAndPlayoffs"}},"batch":{"id":"f579e57f-1c67-4296-ae3d-e2cd34a40f84","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\RCB_and_Playoffs.cpp"} -------------------------------------------------------------------------------- /split_string.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | // your code goes here 8 | 9 | /* int t; 10 | scanf("%d", &t); 11 | while (t--) 12 | { */ 13 | int i, n; 14 | char s[100] , ch; 15 | 16 | scanf("%d", &n); 17 | scanf("%s", s); 18 | 19 | ch = s[n-1]; 20 | for (i = 0; i < n-1; i++) 21 | { 22 | if (ch == s[i]) 23 | { 24 | printf("YES\n"); 25 | break; 26 | } 27 | } 28 | if (i == n - 1) 29 | printf("NO\n"); 30 | 31 | /* } */ 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /.cph/.Count_the_Holidays.cpp_0637590285e58768b94843e3d37d4a5f.prob: -------------------------------------------------------------------------------- 1 | {"name":"Count the Holidays","group":"CodeChef - CodeChef Starters 28 Division 3 (Rated)","url":"https://www.codechef.com/START28C/problems/SUNDAY","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1646232246854,"input":"3\n2\n5 7\n3\n23 1 6\n1\n13","output":"9\n10\n8"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"CountTheHolidays"}},"batch":{"id":"b189be8d-d47f-4ef7-87df-ce5260a6201d","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Count_the_Holidays.cpp"} -------------------------------------------------------------------------------- /.cph/.Palindromes_Not_Allowed.cpp_4678ffaac2b0d890892bf1ff0872e781.prob: -------------------------------------------------------------------------------- 1 | {"name":"Palindromes Not Allowed","group":"CodeChef - January Cook-Off 2022 Division 3","url":"https://www.codechef.com/COOK137C/problems/NOPAL","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1642950753802,"input":"3\n2\n2\n4","output":"gl\nhf\nwaow"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"PalindromesNotAllowed"}},"batch":{"id":"922b6054-8e45-435d-a850-765f20b5480f","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Palindromes_Not_Allowed.cpp"} -------------------------------------------------------------------------------- /.cph/.Exactly_N_plus_1_Values.cpp_2bdb460196ebbbdd99601bf7714847a3.prob: -------------------------------------------------------------------------------- 1 | {"name":"Exactly N plus 1 Values","group":"CodeChef - October Lunchtime 2021 Division 3","url":"https://www.codechef.com/LTIME101C/problems/N1VALUES","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1635346733470,"input":"2\n3\n4","output":"1 2 2 3\n1 2 3 3 7"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ExactlyNPlus1Values"}},"batch":{"id":"0e6a5bbf-6f33-4882-9270-fd6eec7f0121","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Exactly_N_plus_1_Values.cpp"} -------------------------------------------------------------------------------- /.cph/.Longest_AND_Subarray.cpp_daba10da950b169196b67ea9f8901e06.prob: -------------------------------------------------------------------------------- 1 | {"name":"Longest AND Subarray","group":"CodeChef - October Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/OCT21C/problems/ANDSUBAR","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1633334445611,"input":"5\n1\n2\n3\n4\n7","output":"1\n1\n2\n2\n4"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"LongestANDSubarray"}},"batch":{"id":"c636eb42-7c9b-4951-a6bb-037980578c23","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Longest_AND_Subarray.cpp"} -------------------------------------------------------------------------------- /.cph/.Rapid_Re_Orderings.cpp_e92c3864339e2beb3dedea5af9e0cbf7.prob: -------------------------------------------------------------------------------- 1 | {"name":"Rapid Re-Orderings","group":"CodeChef - November Lunchtime 2021 Division 3","url":"https://www.codechef.com/LTIME102C/problems/RPDRDNG","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1638510729972,"input":"2\n3\n6 5 5 7 6 6\n3\n1 2 1 4 2 4","output":"5 6 7\n-1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"RapidReOrderings"}},"batch":{"id":"703fa9b2-5a26-4a2a-b3b7-f9723a3e95b7","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Rapid_Re_Orderings.cpp"} -------------------------------------------------------------------------------- /.cph/.Shuffling_Parities.cpp_91bcdfc68bf4ade0804e59263a6de4e4.prob: -------------------------------------------------------------------------------- 1 | {"name":"Shuffling Parities","group":"CodeChef - September Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/SEPT21C/problems/SHUFFLIN","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1631047704963,"input":"3\n3\n1 2 3\n3\n2 4 5\n2\n2 4","output":"2\n3\n1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ShufflingParities"}},"batch":{"id":"91866d16-f953-4287-94ef-d171f786799c","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Shuffling_Parities.cpp"} -------------------------------------------------------------------------------- /.cph/.Weird_Palindrome_Making.cpp_c5d7f533c033b13134877c3509a58f60.prob: -------------------------------------------------------------------------------- 1 | {"name":"Weird Palindrome Making","group":"CodeChef - November Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/NOV21C/problems/MAKEPAL","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1636784878068,"input":"2\n1\n4\n3\n4 3 1","output":"0\n1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"WeirdPalindromeMaking"}},"batch":{"id":"ad26f28f-c894-4b85-a9a5-1bd32ebb491d","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Weird_Palindrome_Making.cpp"} -------------------------------------------------------------------------------- /.cph/.Xor_Palindrome.cpp_19adab04cf4bf3b13ca19fb3bcb7d649.prob: -------------------------------------------------------------------------------- 1 | {"name":"Xor Palindrome","group":"CodeChef - February Long 2022 - II, Division 3 (Rated)","url":"https://www.codechef.com/FEB222C/problems/XORPAL","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1644750897165,"input":"4\n2\n00\n4\n0011\n3\n001\n4\n0001","output":"YES\nYES\nYES\nNO"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"XorPalindrome"}},"batch":{"id":"3380a34a-4eae-4d33-9463-9f1214a8d564","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Xor_Palindrome.cpp"} -------------------------------------------------------------------------------- /codechef_splitstring.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | // your code goes here 8 | 9 | /* int t; 10 | scanf("%d", &t); 11 | while (t--) 12 | { */ 13 | int i, n; 14 | char s[100000] , ch; 15 | 16 | scanf("%d", &n); 17 | scanf("%s", s); 18 | 19 | ch = s[n-1]; 20 | for (i = 0; i < n-1; i++) 21 | { 22 | if (ch == s[i]) 23 | { 24 | printf("YES\n"); 25 | break; 26 | } 27 | } 28 | if (i == n - 1) 29 | printf("NO\n"); 30 | 31 | /* } */ 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /.cph/.Avoid_Fixed_Points.cpp_fee87a211e8ee8107461c420138655b9.prob: -------------------------------------------------------------------------------- 1 | {"name":"Avoid Fixed Points","group":"CodeChef - February Long 2022 - II, Division 3 (Rated)","url":"https://www.codechef.com/FEB222C/problems/NOFIX","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"input":"3\n3\n2 4 5\n3\n4 1 3\n4\n3 2 4 2\n","output":"0\n1\n2\n","id":1644747476447}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"AvoidFixedPoints"}},"batch":{"id":"80a66dec-2203-488c-9388-9b654d66fc37","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Avoid_Fixed_Points.cpp"} -------------------------------------------------------------------------------- /.cph/.Maximum_Light_Up.cpp_3a097734d35bc648f7b3448e0e47e9d0.prob: -------------------------------------------------------------------------------- 1 | {"name":"Maximum Light Up","group":"CodeChef - CodeChef Starters 13 Division 3 (Rated)","url":"https://www.codechef.com/START13C/problems/DIWALI1","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1632919868054,"input":"3\n100 5 5 10 4 8\n16 2 2 2 1 1\n55 1 2 3 4 5","output":"4\n4\n9"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"MaximumLightUp"}},"batch":{"id":"accbfd24-1762-407f-9775-2399ecddff92","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Maximum_Light_Up.cpp"} -------------------------------------------------------------------------------- /.cph/.Minimum_Number_of_Pizzas.cpp_5be3ea3081354fbfed9d0977823134bf.prob: -------------------------------------------------------------------------------- 1 | {"name":"Minimum Number of Pizzas","group":"CodeChef - November Lunchtime 2021 Division 3","url":"https://www.codechef.com/LTIME102C/problems/MINPIZZAS","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1638024312964,"input":"3\n2 2\n2 3\n4 2","output":"1\n2\n2"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"MinimumNumberOfPizzas"}},"batch":{"id":"c0b2969f-ce14-4666-a67a-3fa152ada5e5","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Minimum_Number_of_Pizzas.cpp"} -------------------------------------------------------------------------------- /.cph/.Parallel_Processing.cpp_676edf97a8d0f2a689df2a8c5100dfc4.prob: -------------------------------------------------------------------------------- 1 | {"name":"Parallel Processing","group":"CodeChef - February Lunchtime 2022 Division 3","url":"https://www.codechef.com/LTIME105C/problems/PLPROCESS","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1646146569925,"input":"3\n3\n4 2 3\n6\n1 1 1 1 1 1\n1\n5","output":"5\n3\n5"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ParallelProcessing"}},"batch":{"id":"bc1830a1-e776-40be-8680-304b9230f0cc","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Parallel_Processing.cpp"} -------------------------------------------------------------------------------- /.cph/.Valleys_and_Hills.cpp_169da9909f467e748562822e6f93ea30.prob: -------------------------------------------------------------------------------- 1 | {"name":"Valleys and Hills","group":"CodeChef - December Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/DEC21C/problems/VANDH","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1639134465121,"input":"3\n3 2\n2 3\n3 3","output":"7\n0101010\n7\n1010101\n8\n01010101"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ValleysAndHills"}},"batch":{"id":"5b253657-0792-46a9-ae9d-c45606ba70b4","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Valleys_and_Hills.cpp"} -------------------------------------------------------------------------------- /.cph/.Prime_in_a_binary_string.cpp_f1ad435390bb087e6df190eee683bd47.prob: -------------------------------------------------------------------------------- 1 | {"name":"Prime in a binary string","group":"CodeChef - January Long 2022 - I, Division 3 (Rated)","url":"https://www.codechef.com/JAN221C/problems/PINBS","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1641643045808,"input":"3\n1\n111\n101101","output":"No\nYes\nYes"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"PrimeInABinaryString"}},"batch":{"id":"7bb17c5f-14fe-4e49-9f6a-37b39a2d282f","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Prime_in_a_binary_string.cpp"} -------------------------------------------------------------------------------- /.cph/.The_One_On_The_Last_Night.cpp_0e8b865d5912d9822f5a436c945dff17.prob: -------------------------------------------------------------------------------- 1 | {"name":"The One On The Last Night","group":"CodeChef - C.O.D.E.R.S Division 3 (Rated)","url":"https://www.codechef.com/FOUR21C/problems/S06E06","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1638517141922,"input":"3\n1 5\n2221 3\n123456 0","output":"6\n36\n720"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"TheOneOnTheLastNight"}},"batch":{"id":"b53325ab-e4a5-4c6b-b275-f4f30797e9fa","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\The_One_On_The_Last_Night.cpp"} -------------------------------------------------------------------------------- /.cph/.Chef_and_Magical_Steps.cpp_5c66750d9355fb4085469c9530163c4f.prob: -------------------------------------------------------------------------------- 1 | {"name":"Chef and Magical Steps","group":"CodeChef - CodeChef Starters 16 Division 3 (Rated)","url":"https://www.codechef.com/START16C/problems/CHEFMGX","interactive":false,"memoryLimit":256,"timeLimit":2000,"tests":[{"input":"4\n2 10\n5 12\n34 43\n57 63\n","output":"6\n5\n6\n4\n","id":1635179503380}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ChefAndMagicalSteps"}},"batch":{"id":"69dac637-9a03-482d-9753-0479a62394dd","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Chef_and_Magical_Steps.cpp"} -------------------------------------------------------------------------------- /.cph/.Chef_and_NextGen.cpp_7824bcd023927b77e6f31515bd8a8834.prob: -------------------------------------------------------------------------------- 1 | {"name":"Chef and NextGen","group":"CodeChef - February Long 2022 - II, Division 3 (Rated)","url":"https://www.codechef.com/FEB222C/problems/HELIUM3","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1644690284088,"input":"4\n1 2 3 4\n4 3 2 1\n2 18 9 4\n1 100 2 49","output":"Yes\nNo\nYes\nNo"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ChefAndNextGen"}},"batch":{"id":"8c37a995-c290-46c7-a39e-ffbeb826d4e5","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Chef_and_NextGen.cpp"} -------------------------------------------------------------------------------- /.cph/.Genes.cpp_a86a764f71ff0735c93cceda2ac08444.prob: -------------------------------------------------------------------------------- 1 | {"name":"Genes","group":"CodeChef - CodeChef Starters 20 Division 3 (Rated)","url":"https://www.codechef.com/START20C/problems/GENE01","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"input":"R B\n","output":"R\n","id":1639579076126},{"input":"B B\n","output":"B\n","id":1639579076073},{"id":1639579076141,"input":"G B","output":"B"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"Genes"}},"batch":{"id":"9fd612c0-a9b8-442c-b7ee-5e1323339c74","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Genes.cpp"} -------------------------------------------------------------------------------- /.cph/.Self_Defence_Training.cpp_99d503d18ecb38c2272434121bbd00db.prob: -------------------------------------------------------------------------------- 1 | {"name":"Self Defence Training","group":"CodeChef - CodeChef Starters 28 Division 3 (Rated)","url":"https://www.codechef.com/START28C/problems/SELFDEF","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1646231434892,"input":"3\n3\n15 23 65\n3\n15 62 16\n2\n35 9","output":"2\n2\n1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"SelfDefenceTraining"}},"batch":{"id":"7dff4b99-1a72-4284-ba94-3cf484aa57dd","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Self_Defence_Training.cpp"} -------------------------------------------------------------------------------- /.cph/.Subarray_permutations.cpp_0f000bbfd588ca256a71efbedb8aaa57.prob: -------------------------------------------------------------------------------- 1 | {"name":"Subarray permutations","group":"CodeChef - January Lunchtime 2022 Division 3","url":"https://www.codechef.com/LTIME104C/problems/SUBPERM","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1643809276196,"input":"4\n1 1\n3 2\n4 1\n5 3","output":"1\n1 3 2\n-1\n5 3 1 4 2"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"SubarrayPermutations"}},"batch":{"id":"45d63875-fdb1-42ea-b29a-c0f7447cf6e5","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Subarray_permutations.cpp"} -------------------------------------------------------------------------------- /.cph/.The_Grid_Fill_Problem.cpp_64a4d8b14adbdef07d40add9d66a1778.prob: -------------------------------------------------------------------------------- 1 | {"name":"The Grid Fill Problem","group":"CodeChef - CodeChef Starters 11 Division 3 (Rated)","url":"https://www.codechef.com/START11C/problems/FILLGRID","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1631723295714,"input":"2\n2\n3","output":"-1 -1\n-1 -1\n1 -1 1\n-1 1 1\n1 1 -1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"TheGridFillProblem"}},"batch":{"id":"80c01ebd-9229-43b1-a020-5d579d76cef1","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\The_Grid_Fill_Problem.cpp"} -------------------------------------------------------------------------------- /.cph/.Airline_Restrictions.cpp_9345bb74ac96bdc428c97b5a8971dcb2.prob: -------------------------------------------------------------------------------- 1 | {"name":"Airline Restrictions","group":"CodeChef - September Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/SEPT21C/problems/AIRLINE","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1631034793003,"input":"3\n1 1 1 15 5\n8 7 6 15 5\n8 5 7 15 6","output":"YES\nNO\nYES"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"AirlineRestrictions"}},"batch":{"id":"4bfe2536-b5cc-49a5-9d71-4ad1482bce95","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Airline_Restrictions.cpp"} -------------------------------------------------------------------------------- /.cph/.Alternating_Work_Days.cpp_34e9676d063149e52dc6e9a1e3bc4907.prob: -------------------------------------------------------------------------------- 1 | {"name":"Alternating Work Days","group":"CodeChef - October Lunchtime 2021 Division 3","url":"https://www.codechef.com/LTIME101C/problems/ALTER","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1635343740787,"input":"4\n1 2 1 2\n1 2 3 2\n4 3 4 6\n3 5 9 25","output":"YES\nNO\nYES\nNO"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"AlternatingWorkDays"}},"batch":{"id":"6a7f2a21-8944-424d-a948-6869a4e89350","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Alternating_Work_Days.cpp"} -------------------------------------------------------------------------------- /.cph/.Distinct_Binary_Strings.cpp_0180c1d1c949340c764b1b1e96f71fdf.prob: -------------------------------------------------------------------------------- 1 | {"name":"Distinct Binary Strings","group":"CodeChef - CodeChef Starters 27 Division 3 (Rated)","url":"https://www.codechef.com/START27C/problems/BINSTRING","interactive":false,"memoryLimit":256,"timeLimit":2000,"tests":[{"id":1645629723401,"input":"3\n3\n100\n4\n1111\n5\n10110","output":"2\n1\n4"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"DistinctBinaryStrings"}},"batch":{"id":"eb475444-24a0-4d85-8e0c-58f4c7fa5f44","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Distinct_Binary_Strings.cpp"} -------------------------------------------------------------------------------- /.cph/.Good_Weather.cpp_6dfc433a1e3bae209ebbc76f23ef5d0d.prob: -------------------------------------------------------------------------------- 1 | {"name":"Good Weather","group":"CodeChef - CodeChef Starters 12 Division 3 (Rated)","url":"https://www.codechef.com/START12C/problems/GOODWEAT","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"input":"4\n1 0 1 0 1 1 1\n0 1 0 0 0 0 1\n1 1 1 1 1 1 1\n0 0 0 1 0 0 0\n","output":"YES\nNO\nYES\nNO\n","id":1632321463294}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"GoodWeather"}},"batch":{"id":"147862f8-8873-4b21-ab62-787557964547","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Good_Weather.cpp"} -------------------------------------------------------------------------------- /.cph/.Hill_Sequence.cpp_21576e4a7d18f1af9efc16b08583e5e2.prob: -------------------------------------------------------------------------------- 1 | {"name":"Hill Sequence","group":"CodeChef - November Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/NOV21C/problems/HILLSEQ","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1637059646046,"input":"4\n3\n2 3 5\n3\n1 1 1\n5\n5 7 2 1 2\n5\n1 2 3 2 2","output":"5 3 2 \n-1\n2 7 5 2 1 \n-1"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"HillSequence"}},"batch":{"id":"111b02a4-6b58-4cb5-83c0-04ace28e194c","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Hill_Sequence.cpp"} -------------------------------------------------------------------------------- /.cph/.Say_No_To_Drugs.cpp_f4f9f70d7ddfa0f3fe70538fc7f94bf4.prob: -------------------------------------------------------------------------------- 1 | {"name":"Say No To Drugs","group":"CodeChef - AlgoManiac - Code For Future Division 3 (Rated)","url":"https://www.codechef.com/CDMN21C/problems/NODRUGS","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1634393037552,"input":"3\n4 2 2\n2 1 3 2\n4 2 2\n2 1 4 2\n3 -10 100\n12 11 9","output":"Yes\nNo\nNo"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"SayNoToDrugs"}},"batch":{"id":"e3e1c18a-ab18-47fe-aacd-cfebe44f3a77","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Say_No_To_Drugs.cpp"} -------------------------------------------------------------------------------- /.cph/.The_One_with_All_the_Candy.cpp_7741d3421b3dd97e4e2f7ae54a4eec49.prob: -------------------------------------------------------------------------------- 1 | {"name":"The One with All the Candy","group":"CodeChef - C.O.D.E.R.S Division 3 (Rated)","url":"https://www.codechef.com/FOUR21C/problems/S07E09","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1638531882680,"input":"3\n3\n2 1 1\n3\n0 5 0\n4\n3 0 2 1","output":"4\n1\n3"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"TheOneWithAllTheCandy"}},"batch":{"id":"4c31d7a3-f42f-41fc-aa68-43e1414ec3c0","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\The_One_with_All_the_Candy.cpp"} -------------------------------------------------------------------------------- /.cph/.Three_Points.cpp_69f67e0518f0030a9ab8e27a1b927d64.prob: -------------------------------------------------------------------------------- 1 | {"name":"Three Points","group":"CodeChef - CodeChef Starters 8 Division 3 (Rated)","url":"https://www.codechef.com/START8C/problems/THREEPTS","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1629313112014,"input":"4\n1 1\n1 3\n3 3\n0 0\n2 2\n3 4\n5 2\n3 2\n1 2\n1 1\n-1 1\n10000 10000","output":"YES\nNO\nYES\nNO"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ThreePoints"}},"batch":{"id":"68136440-5c20-4f08-8013-25e905ce4ddd","size":1},"srcPath":"c:\\MY_DRIVE_LOCAL\\Programming_Coding\\Codechef_codes\\Three_Points.cpp"} -------------------------------------------------------------------------------- /.cph/.Chef_and_Stock_Prices_.cpp_94bfd59759ea67cd28b037ce6fc080d7.prob: -------------------------------------------------------------------------------- 1 | {"name":"Chef and Stock Prices ","group":"CodeChef - November Lunchtime 2021 Division 3","url":"https://www.codechef.com/LTIME102C/problems/CSTOCK","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1638021887101,"input":"3\n100 93 108 7\n100 94 100 -7\n183 152 172 -17","output":"Yes\nNo\nNo"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ChefAndStockPrices"}},"batch":{"id":"d84eec02-f427-45e9-9421-b4d6641503b4","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Chef_and_Stock_Prices_.cpp"} -------------------------------------------------------------------------------- /.cph/.Diagonal_movement.cpp_ce13d710374ac83a0fd51b643bf9471d.prob: -------------------------------------------------------------------------------- 1 | {"name":"Diagonal movement","group":"CodeChef - CodeChef Starters 14 Division 3 (Rated)","url":"https://www.codechef.com/START14C/problems/DIAGMOVE","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"input":"6\n0 2\n1 2\n-1 -3\n-1 0\n-3 1\n2 -1\n","output":"YES\nNO\nYES\nNO\nYES\nNO\n","id":1632927509855}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"DiagonalMovement"}},"batch":{"id":"838c62ec-97ba-4544-815a-b323a094a37f","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Diagonal_movement.cpp"} -------------------------------------------------------------------------------- /.cph/.Utkarsh_and_Placement_tests.cpp_2b707ccc4157ad2e0f17aa74f37a1f2d.prob: -------------------------------------------------------------------------------- 1 | {"name":"Utkarsh and Placement tests","group":"CodeChef - December Challenge 2021 Division 3 (Rated)","url":"https://www.codechef.com/DEC21C/problems/UTKPLC","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1638901329354,"input":"2\nA B C\nA B\nB C A\nA C","output":"A\nC"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"UtkarshAndPlacementTests"}},"batch":{"id":"3d9e0cd1-83b1-43f2-8a77-36567b80a9df","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Utkarsh_and_Placement_tests.cpp"} -------------------------------------------------------------------------------- /.cph/.Fixed_number_of_Fixed_Points.cpp_3bc1bc0094e8fbf571c902af65b7438b.prob: -------------------------------------------------------------------------------- 1 | {"name":"Fixed number of Fixed Points","group":"CodeChef - CodeChef Starters 14 Division 3 (Rated)","url":"https://www.codechef.com/START14C/problems/FIXFIX","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1632930942348,"input":"3\n2 1\n3 1\n4 2","output":"-1\n1 3 2\n3 2 1 4"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"FixedNumberOfFixedPoints"}},"batch":{"id":"9d825a84-6ac7-42ec-bb55-45b4791d4f1d","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Fixed_number_of_Fixed_Points.cpp"} -------------------------------------------------------------------------------- /.cph/.The_One_with_Russ.cpp_013dfafe08cfaadb690283b52de0da6a.prob: -------------------------------------------------------------------------------- 1 | {"name":"The One with Russ","group":"CodeChef - C.O.D.E.R.S Division 3 (Rated)","url":"https://www.codechef.com/FOUR21C/problems/S02E10","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1638515163781,"input":"3\n4 2 2\n1 7 7 5\n1 8 1 2\n5 1 3\n9 8 7 2 5\n5 4 1 8 9\n3 3 0\n2 3 4\n2 3 4","output":"YES\nNO\nYES"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"TheOneWithRuss"}},"batch":{"id":"0a3104ab-6d62-4d1a-9c2e-1280d5e840bc","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\The_One_with_Russ.cpp"} -------------------------------------------------------------------------------- /.cph/.Prefix_Permutation.cpp_191d3f568c42794a89ab8daa60e6274f.prob: -------------------------------------------------------------------------------- 1 | {"name":"Prefix Permutation","group":"CodeChef - February Cook-Off 2022 Division 3","url":"https://www.codechef.com/COOK138C/problems/PREFPERM","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1646137928074,"input":"3\n8 4\n3 6 7 8\n7 1\n7\n5 5\n1 2 3 4 5","output":"2 3 1 6 4 5 7 8\n4 6 1 5 2 7 3\n1 2 3 4 5"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"PrefixPermutation"}},"batch":{"id":"ff4e99fc-a1bd-483a-8f0d-8c3104d61c94","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Prefix_Permutation.cpp"} -------------------------------------------------------------------------------- /.cph/.Watching_Movies_at_2_x.cpp_ac0efdefecb97aed2ebbe5eef260ca45.prob: -------------------------------------------------------------------------------- 1 | {"name":"Watching Movies at 2x","group":"CodeChef - February Lunchtime 2022 Division 3","url":"https://www.codechef.com/LTIME105C/problems/MOVIE2X","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"input":"100 20\n","output":"90\n","id":1646145894910},{"id":1646145894885,"input":"50 24","output":"38"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"WatchingMoviesAt2x"}},"batch":{"id":"29180a09-8732-4936-bcc7-e326f70d88b5","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Watching_Movies_at_2_x.cpp"} -------------------------------------------------------------------------------- /.cph/.Chef_and_Pairing_Slippers.cpp_438b65fbc14fd33b3f77cef9fd3380c2.prob: -------------------------------------------------------------------------------- 1 | {"name":"Chef and Pairing Slippers","group":"CodeChef - October Cook-Off 2021 Division 3","url":"https://www.codechef.com/COOK134C/problems/CHEFSLP","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"input":"4\n0 0 100\n10 1 0\n1000 10 1000\n10 7 1\n","output":"0\n0\n10000\n3\n","id":1635182759911}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ChefAndPairingSlippers"}},"batch":{"id":"047d4a89-b3f2-4c89-b0b1-8dc063d8e82f","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Chef_and_Pairing_Slippers.cpp"} -------------------------------------------------------------------------------- /cutting_recipies.py: -------------------------------------------------------------------------------- 1 | 2 | t = int(input()) 3 | for _ in range(t): 4 | 5 | list = [] 6 | 7 | n = int(input("Enter number of elements : ")) 8 | 9 | for i in range(0, n): 10 | ele = int(input()) 11 | list.append(ele) 12 | 13 | small = min(list) 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | """ def get_gcd(a, b): 22 | while(b): 23 | a, b = b, a%b 24 | return a 25 | t = int(input()) 26 | for _ in range(t): 27 | l = list(map(int, input().split(' '))) 28 | gcd = get_gcd(l[1], l[2]) 29 | for i in range(2, len(l)): 30 | gcd = get_gcd(gcd,l[i]) 31 | for i in range(1, len(l)): 32 | print(l """[i]//gcd,end = ' ') 33 | print() -------------------------------------------------------------------------------- /chef_&_quaries.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int n, k, remain, i, result; 8 | scanf("%d %d", &n, &k); 9 | int a[n]; 10 | 11 | for (i = 0; i < n; i++) 12 | scanf("%d", &a[i]); 13 | 14 | for (i = 0; i < n; i++) 15 | { 16 | if (a[i] >= k) 17 | { 18 | carry = a[i] - k; 19 | a[i + 1] = carry + a[i + 1]; 20 | } 21 | if (a[i] < k) 22 | { 23 | printf("%d\n", i + 1); 24 | } 25 | if () 26 | { 27 | remain = a[i + 1] / k; 28 | result = remain + n + 1; 29 | printf("%d\n", result); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.cph/.Four_Equidistant_Points_on_a_Grid.cpp_3ff0f322e32035eacf4ed8a0fa599b4d.prob: -------------------------------------------------------------------------------- 1 | {"name":"Four Equidistant Points on a Grid","group":"CodeChef - February Lunchtime 2022 Division 3","url":"https://www.codechef.com/LTIME105C/problems/DISTCON","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"input":"2\n","output":"0 1\n1 2\n2 3\n3 4\n","id":1646150646556},{"id":1646150646539,"input":"1","output":""}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"FourEquidistantPointsOnAGrid"}},"batch":{"id":"b67669b6-827f-4b39-90ba-ad68573fab07","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Four_Equidistant_Points_on_a_Grid.cpp"} -------------------------------------------------------------------------------- /sin_&_cos.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | void main() { 7 | float r; 8 | int i; 9 | char ch; 10 | printf("- - - - - - - - - - - - - - - - - -"); 11 | printf("\nAngle \t Sin \t Cos \n"); 12 | printf("- - - - - - - - - - - - - - - - - -"); 13 | for (i = 0; i <= 180; i = i + 30) { 14 | r = i * 3.14159 / 180; 15 | printf("\n%3d \t %5.2f \t %5.2f \n", i, sin(r), cos(r)); 16 | } 17 | printf("- - - - - - - - - - - - - - - - - -"); 18 | 19 | printf("HELLO\t\tWORLD\n"); 20 | printf("%d \n", 3 / 4 > 0); 21 | printf("%d \n", 0 && 1); 22 | int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, i = 6; 23 | int *p = &a[0]; 24 | printf("%d\n", *(p + i)); 25 | 26 | } -------------------------------------------------------------------------------- /.cph/.World_Chess_Championship.cpp_7745bd289c5fb63d147f8003da95f59f.prob: -------------------------------------------------------------------------------- 1 | {"name":"World Chess Championship","group":"CodeChef - February Long 2022 - II, Division 3 (Rated)","url":"https://www.codechef.com/FEB222C/problems/WCC","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1644690372409,"input":"4\n100\nCCCCCCCCCCCCCC\n400\nCDCDCDCDCDCDCD\n30\nDDCCNNDDDCCNND\n1\nNNDNNDDDNNDNDN","output":"6000\n24000\n1650\n40"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"WorldChessChampionship"}},"batch":{"id":"0c8c3324-76dc-4e92-9b9e-faeeb2b1cbd0","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\World_Chess_Championship.cpp"} -------------------------------------------------------------------------------- /.cph/.Team_Formation.cpp_9597a9f9b849803c734594092397dd5d.prob: -------------------------------------------------------------------------------- 1 | {"name":"Team Formation","group":"CodeChef - August Cook-Off 2021 Division 3","url":"https://www.codechef.com/COOK132C/problems/TEAMFOR","interactive":false,"memoryLimit":256,"timeLimit":500,"tests":[{"id":1629649583776,"input":"4\n3\n101\n001\n4\n1010\n0110\n3\n000\n110\n2\n10\n11","output":"1\n2\n0\n1"},{"id":1629652447288,"input":"1\n3\n111\n011","output":"1"},{"id":1629656755085,"input":"1\n4\n1100\n0111","output":"2"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"TeamFormation"}},"batch":{"id":"a4088aa3-a844-41a8-b644-5d1c7491b3a1","size":1},"srcPath":"c:\\LOCAL_DRIVE_Niharika\\Programming_Code\\Codechef_codes\\Team_Formation.cpp"} -------------------------------------------------------------------------------- /Coin_flip.c: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/LRNDSA01/problems/CONFLIP 3 | 4 | #include 5 | #include 6 | #define ll long long 7 | #define loop1(n) for (ll i = 0; i < (n); i++) 8 | #define loop2(n) for (ll i = 1; i <= (n); i++) 9 | #define test \ 10 | ll t; \ 11 | scanf("%lld", &t); \ 12 | while (t--) 13 | 14 | int main() 15 | { 16 | // serve your dish 17 | test 18 | { 19 | int n, q, i, g, j; 20 | scanf("%d\n", &g); 21 | for (j = 0; j < g; j++) 22 | { 23 | scanf("%d %d %d\n", &i, &n, &q); 24 | if (i == q) 25 | printf("%d\n", n / 2); 26 | else 27 | printf("%d\n", n - (n / 2)); 28 | } 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /XOR_Compare.c: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/LTIME90B/problems/XORCOMP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define ll long long 9 | #define loop1(n) for (ll i = 0; i < (n); i++) 10 | #define loop2(n) for (ll i = 1; i <= (n); i++) 11 | // #define test ll t; cin>>t; while(t--) 12 | #define test \ 13 | ll t; \ 14 | scanf("%lld", &t); \ 15 | while (t--) 16 | 17 | int main() 18 | { 19 | // serve your dish 20 | test 21 | { 22 | int x, y, n, c = 0; 23 | scanf("%d%d%d", &x, &y, &n); 24 | for (int i = 0; i <= n; i++) 25 | { 26 | if ((x ^ i) < (y ^ i)) 27 | c++; 28 | } 29 | printf("%d/n", c); 30 | } 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Gold_Trip.c: -------------------------------------------------------------------------------- 1 | 2 | // LINKS :: https://www.codechef.com/ARYS2020/problems/GOLDTRIP 3 | 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | int t; 10 | scanf("%d", &t); 11 | 12 | while (t--) 13 | { 14 | int n, Q; 15 | scanf("%d", &n); 16 | int a[n], q, i, sum = 0, j, a, b; 17 | for (i = 0; i < n; i++) 18 | scanf("%d", &a[i]); 19 | scanf("%d", &Q); 20 | for (i = 0; i < n; i++) 21 | scanf("%d", &a[i]); 22 | 23 | for (i = 0; i < Q; i++) 24 | { 25 | scanf("%d %d", &a, &b); 26 | for (i = (a - 1); i <= (b - 1); i++) 27 | sum = sum + a[i]; 28 | 29 | printf("%d\n", sum); 30 | sum = 0; 31 | } 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Flip_strings.c: -------------------------------------------------------------------------------- 1 | // LINKS :: https://www.codechef.com/problems/FLIP 2 | 3 | #include 4 | #include 5 | 6 | int main(void) 7 | { 8 | int t, c = 0; 9 | scanf("%d", &t); 10 | 11 | while (t--) 12 | { 13 | char a[10000], b[10000]; 14 | int i; 15 | scanf("%d %d", &a, &b); 16 | for (i = 0; i < strlen(a); i++) 17 | { 18 | if (a[i] != b[i]) 19 | { 20 | if (a[i] == 0) 21 | { 22 | a[i] = 1; 23 | c++; 24 | } 25 | 26 | else 27 | { 28 | a[i] = 0; 29 | c++; 30 | } 31 | } 32 | } 33 | printf("%d\n", c); 34 | } 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /XOR_Equal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/SEPT21C/problems/PALINT 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define vi vector 17 | #define vll vector 18 | #define pb push_back 19 | #define mp make_pair 20 | #define loop1(n) for (ll i = 0; i < (n); i++) 21 | #define loop2(n) for (ll i = 1; i <= (n); i++) 22 | #define test \ 23 | ll t; \ 24 | cin >> t; \ 25 | while (t--) 26 | 27 | int main() 28 | { 29 | ios_base::sync_with_stdio(false); 30 | cin.tie(NULL); 31 | cout.tie(NULL); 32 | 33 | test 34 | { 35 | } 36 | 37 | return 0; 38 | } -------------------------------------------------------------------------------- /FoodChain.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/START7C/problems/FODCHAIN 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define vll vector 13 | #define pb push_back 14 | #define mp make_pair 15 | #define loop1(n) for (ll i = 0; i < (n); i++) 16 | #define loop2(n) for (ll i = 1; i <= (n); i++) 17 | #define test \ 18 | ll t; \ 19 | cin >> t; \ 20 | while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | 28 | test 29 | { 30 | int E, k, count = 0; 31 | cin >> E >> k; 32 | while (E > 0) 33 | { 34 | E = floor(E / k); 35 | count++; 36 | } 37 | cout << count + 1 << endl; 38 | } 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /covid_codechef.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int t; 8 | printf("enter t value : "); 9 | scanf("%d", &t); 10 | 11 | while (t--) 12 | { 13 | int n, k, x, y, i, flag = 0; 14 | printf("enter the 4 values : "); 15 | scanf("%d %d %d %d", &n, &k, &x, &y); 16 | 17 | for (i = 0; i <= n + 2; i++) 18 | { 19 | // printf("YES2\n"); 20 | if (((x + k * i) % n) == y) 21 | { 22 | printf("YES\n"); 23 | flag = 1; 24 | break; 25 | } 26 | } 27 | 28 | // printf("hii"); 29 | if (flag == 0) 30 | printf("NO\n"); 31 | 32 | // printf("hii$$"); 33 | flag = 0; 34 | } 35 | } 36 | 37 | /* for (i = x; i < n ; i = i % n) 38 | { 39 | printf("YES2\n"); 40 | i = i + k; 41 | if (((x + k) % n) == y) 42 | { 43 | printf("YES3\n"); 44 | // flag = 1; 45 | break; 46 | } 47 | 48 | else 49 | { 50 | printf("NO"); 51 | 52 | } */ -------------------------------------------------------------------------------- /Chef_and_Fruits.c: -------------------------------------------------------------------------------- 1 | 2 | // LINKS :: https://www.codechef.com/problems/FRUITS 3 | 4 | #include 5 | #include 6 | 7 | #define ll long long 8 | #define rep0(n) for (ll i = 0; i < (n); i++) 9 | #define rep1(n) for (ll i = 1; i <= (n); i++) 10 | // #define test ll t; cin>>t; while(t--) 11 | #define test \ 12 | ll t; \ 13 | scanf("%d", &t); \ 14 | while (t--) 15 | 16 | int main() 17 | { 18 | test 19 | { 20 | int n, m, k, i,diff=0; 21 | scanf("%d %d %d",&n,&m,&k); 22 | if (k >= abs(n - m)) 23 | printf("0\n"); 24 | else if (n > m) 25 | { 26 | diff = n - m; 27 | if (diff > k) 28 | { 29 | m = k + m; 30 | printf("%d\n", abs(n - m)); 31 | } 32 | } 33 | else 34 | { n = n + k; 35 | printf("%d\n", abs(n - m)); 36 | } 37 | } 38 | return 0; 39 | } -------------------------------------------------------------------------------- /Smart_Phone1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define ll long long 5 | #define vi vector 6 | #define pb push_back 7 | #define mp make_pair 8 | #define loop1(n) for (ll i = 0; i < (n); i++) 9 | #define loop2(n) for (ll i = 1; i <= (n); i++) 10 | #define test ll t; cin>>t; while(t--) 11 | 12 | int main() 13 | { 14 | ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 15 | ll customer, i, LENGTH; 16 | ll *maxi; 17 | cin >> customer; 18 | ll a[customer], b[customer]; 19 | for (i = 0; i < customer; i++) 20 | cin >> a[i]; 21 | LENGTH = sizeof(a) / sizeof(a[0]); 22 | // for (i = 0; i < customer; i++) 23 | sort(a, a + customer); 24 | 25 | for (i = 0; i < customer; i++) 26 | { 27 | b[i] = a[i] * LENGTH; 28 | LENGTH = LENGTH - 1; 29 | } 30 | 31 | maxi = max_element(b, b + customer); // returns a pointer type 32 | cout << *maxi << "\n"; 33 | 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /Three_Points.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ________________________________________ 4 | ---------------------------------------- 5 | Author : Niharika Dutta 6 | Code Link : https://www.codechef.com/START8C/problems/THREEPTS 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define vi vector 17 | #define vll vector 18 | #define pb push_back 19 | #define mp make_pair 20 | #define loop1(n) for (ll i = 0; i < (n); i++) 21 | #define loop2(n) for (ll i = 1; i <= (n); i++) 22 | #define test \ 23 | ll t; \ 24 | cin >> t; \ 25 | while (t--) 26 | 27 | int main() 28 | { 29 | ios_base::sync_with_stdio(false); 30 | cin.tie(NULL); 31 | cout.tie(NULL); 32 | 33 | test 34 | { 35 | ll xA, xB, xC, yA, yB, yC, ans = 0; 36 | cin >> xA >> yA >> xB >> yB >> xC >> yC; 37 | } 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /Prime_in_a_binary_string.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/JAN221C/problems/PINBS 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | string str; 37 | cin >> str; 38 | } 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Chef_&_GCD.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/COOK131C/problems/CHFGCD 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define vll vector 13 | #define pb push_back 14 | #define mp make_pair 15 | #define loop1(n) for (ll i = 0; i < (n); i++) 16 | #define loop2(n) for (ll i = 1; i <= (n); i++) 17 | #define test \ 18 | ll t; \ 19 | cin >> t; \ 20 | while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | 28 | test 29 | { 30 | int x, y, gcd, count = 0; 31 | cin >> x >> y; 32 | gcd = __gcd(x, y); 33 | if (gcd > 1) 34 | cout << "0\n"; 35 | else if (__gcd(x + 1, y) > 1 || __gcd(x, y + 1) > 1) 36 | cout << "1\n"; 37 | else 38 | cout << "2\n"; 39 | } 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Kitchen_timetable.c: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/problems/KTTABLE 3 | 4 | #include 5 | 6 | #define ll long long 7 | #define rep0(n) for (ll i = 0; i < (n); i++) 8 | #define rep1(n) for (ll i = 1; i <= (n); i++) 9 | // #define test ll t; cin>>t; while(t--) 10 | #define test ll t; scanf("%lld", &t);while (t--) 11 | 12 | int main() 13 | { 14 | // serve your dish 15 | test 16 | { 17 | int n, i, count = 0,z; 18 | scanf("%d",&n); 19 | int a[n], b[n]; 20 | for ( i = 0; i < n; i++) 21 | scanf("%d",&a[i]); 22 | for ( i = 0; i < n; i++) 23 | scanf("%d",&b[i]); 24 | // if(a[0] >= b[0]) 25 | // count++; 26 | for (i = 0; i < n; i++) 27 | { 28 | if (i == 0) 29 | z = a[i]; 30 | else 31 | z = a[i] - a[i - 1]; 32 | if (z >= b[i]) 33 | count++; 34 | } 35 | printf("%d\n",count); 36 | } 37 | 38 | return 0; 39 | } -------------------------------------------------------------------------------- /ProblemDifficulties.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/AUG21C/problems/PROBDIFF 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define vll vector 13 | #define pb push_back 14 | #define mp make_pair 15 | #define loop1(n) for (ll i = 0; i < (n); i++) 16 | #define loop2(n) for (ll i = 1; i <= (n); i++) 17 | #define test \ 18 | ll t; \ 19 | cin >> t; \ 20 | while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | 28 | test 29 | { 30 | int a, b, c, d; 31 | cin >> a >> b >> c >> d; 32 | if (a == b && b == c && c == d && d == a) // all same 33 | cout << "0\n"; 34 | else if (a == b && b == c || b == c && c == d || c == d && d == a || d == a && a == b) // 3 same 35 | cout << "1\n"; 36 | else 37 | cout << "2\n"; 38 | } 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Count_subarray.c: -------------------------------------------------------------------------------- 1 | 2 | // LINKS :: https://www.codechef.com/LRNDSA07/problems/SUBINC 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define ll long long 9 | #define loop1(n) for (ll i = 0; i < (n); i++) 10 | #define loop2(n) for (ll i = 1; i <= (n); i++) 11 | // #define test ll t; cin>>t; while(t--) 12 | #define test \ 13 | ll t; \ 14 | scanf("%lld", &t); \ 15 | while (t--) 16 | 17 | int main() 18 | { 19 | // serve your dish 20 | test 21 | { //***************************** O(n^2) ****************************** 22 | int sum = 0, d = 0, n; 23 | scanf("%d", &n); 24 | int a[n]; 25 | loop1(n) 26 | scanf("%d", &a[i]); 27 | for (i = 1; i < n; i++) 28 | { 29 | if (a[i] > a[i - 1]) 30 | { 31 | d++; 32 | sum = sum + d; 33 | } 34 | else 35 | d = 0; 36 | } 37 | printf("%d\n", n + sum); 38 | } 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Play_Piano.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | #define ll long long 8 | #define vi vector 9 | #define pb push_back 10 | #define mp make_pair 11 | #define loop1(n) for (ll i = 0; i < (n); i++) 12 | #define loop2(n) for (ll i = 1; i <= (n); i++) 13 | #define test \ 14 | ll t; \ 15 | cin >> t; \ 16 | while (t--) 17 | // #define test ll t; scanf("%d", &t);while (t--) 18 | 19 | int main() 20 | { 21 | ios_base::sync_with_stdio(false); 22 | cin.tie(NULL); 23 | cout.tie(NULL); 24 | test 25 | { 26 | string s; 27 | int i, flag = 1; 28 | cin >> s; 29 | for (i = 0; i < s.length(); i++) 30 | { 31 | if (s[i] == s[i + 1]) 32 | { 33 | flag = 0; 34 | break; 35 | } 36 | else 37 | i++; 38 | } 39 | if (flag) 40 | cout << "yes" << endl; 41 | else 42 | cout << "no" << endl; 43 | } 44 | } 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Genes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START20C/problems/GENE01 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | char a, b; 35 | cin >> a >> b; 36 | 37 | if (a == b) 38 | cout << a << endl; 39 | else if (a == 'R' || b == 'R') 40 | cout << "R\n"; 41 | else 42 | cout << "B\n"; 43 | return 0; 44 | } -------------------------------------------------------------------------------- /sum-and-puppy.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int sum(int num); 6 | int main() 7 | { 8 | int t, total, i, num, times, k; 9 | scanf("%d", &t); 10 | 11 | while (t--) 12 | { 13 | // printf("Enter the TIMES & NUM : "); 14 | scanf("%d %d", ×, &num); 15 | for (i = 0; i < times; i++) 16 | { 17 | k = sum(num); 18 | num = k; 19 | } 20 | printf("%d\n", num); 21 | } 22 | } 23 | 24 | int sum(int n) 25 | { 26 | int z; 27 | z = (n * (n + 1) / 2); 28 | return z; 29 | } 30 | 31 | 32 | // increment 33 | #include 34 | 35 | int main(void) { 36 | // your code goes here 37 | int n; 38 | scanf("%d",&n); 39 | if (n % 4 == 0) 40 | printf("%d",++n); 41 | else 42 | printf("%d",--n); 43 | 44 | return 0; 45 | } 46 | 47 | // hrlpongchef 48 | # cook your dish here 49 | 50 | testcase = int(input()) 51 | 52 | for i in range(testcase): 53 | n = int(input()) 54 | if (n < 10): 55 | print("Thanks for helping Chef!") 56 | else: 57 | print("-1") 58 | 59 | 60 | // -------------------------------------------------------------------------------- /Badminton_Serves.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START24C/problems/BADMINTON 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int p; 31 | cin >> p; 32 | 33 | int ans = p / 2; 34 | cout << ans + 1 << endl; 35 | } 36 | 37 | int main() 38 | { 39 | ios_base::sync_with_stdio(false); 40 | cin.tie(NULL); 41 | cout.tie(NULL); 42 | 43 | test 44 | { 45 | solve(); 46 | } 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Chef_and_Pairing_Slippers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK134C/problems/CHEFSLP 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int n, l, x, ans = 0, r = 0; 37 | cin >> n >> l >> x; 38 | 39 | r = n - l; 40 | ans = x * (min(l, r)); 41 | cout << ans << endl; 42 | } 43 | return 0; 44 | } -------------------------------------------------------------------------------- /Pass_or_Fail.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int n, x, p, marks = 0; 37 | cin >> n >> x >> p; 38 | 39 | marks = ((n - x) * (-1)) + (x * 3); 40 | if (marks >= p) 41 | cout << "PASS\n"; 42 | else 43 | cout << "FAIL\n"; 44 | } 45 | return 0; 46 | } -------------------------------------------------------------------------------- /RCB_and_Playoffs.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START14C/problems/RCBPLAY 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int x, y, z; 37 | cin >> x >> y >> z; 38 | 39 | if (z * 2 + x >= y) 40 | cout << "YES\n"; 41 | else 42 | cout << "NO\n"; 43 | } 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Playing_with_strings.cpp: -------------------------------------------------------------------------------- 1 | 2 | // LINKS :: https://www.codechef.com/problems/PLAYSTR 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define pb push_back 13 | #define mp make_pair 14 | #define loop1(n) for (ll i = 0; i < (n); i++) 15 | #define loop2(n) for (ll i = 1; i <= (n); i++) 16 | #define test \ 17 | ll t; \ 18 | cin >> t; \ 19 | while (t--) 20 | // #define test ll t; scanf("%d", &t);while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | test 28 | { 29 | int n, s1 = 0, i, r1 = 0; 30 | cin >> n; 31 | string s, r; 32 | cin >> s >> r; 33 | for (i = 0; i < n; i++) 34 | { 35 | if (s[i] == '1') 36 | s1++; 37 | if (r[i] == '1') 38 | r1++; 39 | } 40 | if (s1 == r1) 41 | cout << "YES\n"; 42 | else 43 | cout << "NO\n"; 44 | } 45 | 46 | return 0; 47 | } -------------------------------------------------------------------------------- /XOR_OR_ED.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: // https://www.codechef.com/COOK131C/problems/XORORED 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define vll vector 13 | #define pb push_back 14 | #define mp make_pair 15 | #define loop1(n) for (ll i = 0; i < (n); i++) 16 | #define loop2(n) for (ll i = 1; i <= (n); i++) 17 | #define test \ 18 | ll t; \ 19 | cin >> t; \ 20 | while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | 28 | test 29 | { 30 | int n, i, res = 0; 31 | int Max = INT_MIN; 32 | cin >> n; 33 | vi a(n); // vector 34 | for (i = 0; i < n; i++) 35 | cin >> a[i]; 36 | 37 | Max = *max_element(a.begin(), a.end()); 38 | for (i = 0; i < n; i++) 39 | { 40 | a[i] = a[i] ^ Max; // xor operator 41 | res = res | a[i]; 42 | } 43 | 44 | cout << Max << " " << res << endl; 45 | } 46 | 47 | return 0; 48 | } -------------------------------------------------------------------------------- /Chef_and_Lockout_Draws.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME104C/problems/LOCKDRAW 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int a, c, b; 37 | cin >> a >> b >> c; 38 | 39 | if (a + b == c || b + c == a || c + a == b) 40 | cout << "YES\n"; 41 | else 42 | cout << "NO\n"; 43 | } 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Ada_dishes.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | int t; 8 | scanf("%d", &t); 9 | 10 | while (t--) 11 | { 12 | int i, n, a, first = 0, sec = 0, diff, j; 13 | scanf("%d", &n); 14 | int c[n]; 15 | 16 | for (i = 0; i < n; i++) 17 | scanf("%d", &c[i]); 18 | 19 | // reverse sorting 20 | Sort(c, c + n); 21 | Reverse(c, c + n); 22 | /* for (i = 0; i < n; ++i) 23 | { 24 | for (j = i + 1; j < n; ++j) 25 | { 26 | if (c[i] < c[j]) 27 | { 28 | a = c[i]; 29 | c[i] = c[j]; 30 | c[j] = a; 31 | } 32 | } 33 | } */ 34 | 35 | first = first + c[0]; 36 | 37 | for (i = 1; i < n; i++) 38 | { 39 | if (first > sec) 40 | sec = sec + c[i]; 41 | else 42 | first = first + c[i]; 43 | } 44 | 45 | if (first >= sec) 46 | printf("%d\n", first); 47 | 48 | else 49 | printf("%d\n", sec); 50 | } 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /Secret_recipe.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/problems/CHEFRUN 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define pb push_back 13 | #define mp make_pair 14 | #define loop1(n) for (ll i = 0; i < (n); i++) 15 | #define loop2(n) for (ll i = 1; i <= (n); i++) 16 | #define test \ 17 | ll t; \ 18 | cin >> t; \ 19 | while (t--) 20 | // #define test ll t; scanf("%d", &t);while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | test 28 | { 29 | int x1, x2, x3; 30 | float t1, t2, v1, v2, path1, path2; 31 | cin >> x1 >> x2 >> x3 >> v1 >> v2; 32 | path1 = (x3 - x1); 33 | path2 = (x2 - x3); 34 | t1 = path1 / v1; 35 | t2 = path2 / v2; 36 | if (t1 < t2) 37 | cout << "Chef\n"; 38 | else if (t2 < t1) 39 | cout << "Kefa\n"; 40 | else if (t1 == t2) 41 | cout << "Draw\n"; 42 | } 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /Forgotten_String.cpp: -------------------------------------------------------------------------------- 1 | 2 | // LINKS :: https://www.codechef.com/problems/FRGTNLNG 3 | 4 | #include 5 | #include 6 | #include "bits/stdc++.h" 7 | using namespace std; 8 | 9 | #define ll long long 10 | #define rep0(n) for (ll i = 0; i < (n); i++) 11 | #define rep1(n) for (ll i = 1; i <= (n); i++) 12 | #define test ll t; cin>>t; while(t--) 13 | // #define test ll t; scanf("%lld", &t);while (t--) 14 | 15 | int main() 16 | { 17 | test { 18 | int n, k,l; 19 | string s; 20 | map b; 21 | cin >> n >> k; 22 | vector a(n); 23 | 24 | for (int i = 0; i < n; i++) 25 | cin >> a[i]; 26 | 27 | for (int i = 0; i < k; i++) { 28 | cin >> l; 29 | for (int j = 0; j < l; j++) { 30 | cin >> s; 31 | b[s] = true; // for a key of s the value is TRUE 32 | } 33 | } 34 | 35 | for (string x : a) { 36 | if (b[x]) { 37 | cout << "YES "; 38 | } else { 39 | cout << "NO "; 40 | } 41 | } 42 | cout << endl; 43 | } 44 | return 0; 45 | } -------------------------------------------------------------------------------- /Maximum_Length_Even_Subarray.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME99C/problems/MXEVNSUB 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define vi vector 17 | #define vll vector 18 | #define pb push_back 19 | #define mp make_pair 20 | #define loop1(n) for (ll i = 0; i < (n); i++) 21 | #define loop2(n) for (ll i = 1; i <= (n); i++) 22 | #define test \ 23 | ll t; \ 24 | cin >> t; \ 25 | while (t--) 26 | 27 | int main() 28 | { 29 | ios_base::sync_with_stdio(false); 30 | cin.tie(NULL); 31 | cout.tie(NULL); 32 | 33 | test 34 | { 35 | int n, sum = 0; 36 | cin >> n; 37 | vector arr; 38 | sum = n * (n + 1) / 2; 39 | 40 | if (sum % 2 == 0) 41 | cout << n << endl; 42 | else 43 | cout << n - 1 << endl; 44 | } 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Large_Squares.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ________________________________________ 4 | - By Niharika Dutta 5 | Code Link : https://www.codechef.com/START9C/problems/XLSQUARE 6 | ________________________________________ 7 | */ 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | 13 | #define ll long long 14 | #define vi vector 15 | #define vll vector 16 | #define pb push_back 17 | #define mp make_pair 18 | #define loop1(n) for (ll i = 0; i < (n); i++) 19 | #define loop2(n) for (ll i = 1; i <= (n); i++) 20 | #define test \ 21 | ll t; \ 22 | cin >> t; \ 23 | while (t--) 24 | 25 | bool isPerfectSquare(ll x) 26 | { 27 | ll sr = sqrt(x); 28 | return (sr * sr == x); 29 | } 30 | 31 | int main() 32 | { 33 | ios_base::sync_with_stdio(false); 34 | cin.tie(NULL); 35 | cout.tie(NULL); 36 | 37 | // test 38 | { 39 | ll n, a, sq; 40 | bool res; 41 | cin >> n >> a; 42 | 43 | res = isPerfectSquare(n); 44 | // if (res) 45 | // { 46 | sq = sqrt(n); 47 | cout << sq << endl; 48 | cout << sq * a << endl; 49 | // } 50 | } 51 | return 0; 52 | } -------------------------------------------------------------------------------- /Chef_and_IPC.c: -------------------------------------------------------------------------------- 1 | 2 | // LINKS :: https://www.codechef.com/problems/IPCCERT 3 | 4 | #include 5 | #include 6 | 7 | int main(void) 8 | { 9 | int n, m, k, q, sum = 0, c = 0, i, j,a; 10 | scanf("%d %d %d", &n, &m, &k); 11 | for (i = 0; i < n; i++) 12 | { 13 | sum = 0; 14 | for (int j = 0; j < k; j++) 15 | { 16 | scanf("%d",&a); 17 | sum = sum + a; // same line additn possible as its not array 18 | } 19 | scanf("%d",&q); 20 | if (sum >= m && q <= 10) 21 | c++; 22 | } 23 | printf("%d\n", c); 24 | } 25 | 26 | 27 | 28 | 29 | /* 30 | #include 31 | #include 32 | 33 | int main(void) 34 | { 35 | int n, m, k, sum = 0, c = 0, i, j; 36 | scanf("%d %d %d", &n, &m, &k); 37 | int a[n]={0},q[n]; 38 | for (i = 0; i < n; i++) 39 | { 40 | for (j = 0; j < k; j++) 41 | { 42 | scanf("%d",&sum); 43 | a[i]+=sum; 44 | } 45 | scanf("%d", &q[i]); 46 | } 47 | 48 | for (i = 0; i < n; i++) 49 | { 50 | if (a[i] >= m && q[i]<= 10) 51 | c++; 52 | } 53 | 54 | printf("%d\n", c); 55 | return 0; 56 | } */ -------------------------------------------------------------------------------- /Problem_Category.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME101C/problems/PROBCAT 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int x; 37 | cin >> x; 38 | 39 | if (1 <= x && x < 100) 40 | cout << "Easy\n"; 41 | else if (100 <= x && x < 200) 42 | cout << "Medium\n"; 43 | else 44 | cout << "Hard\n"; 45 | } 46 | 47 | return 0; 48 | } -------------------------------------------------------------------------------- /MaxArrXOR.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/START7C/problems/MAXARXOR 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define vll vector 13 | #define pb push_back 14 | #define mp make_pair 15 | #define loop1(n) for (ll i = 0; i < (n); i++) 16 | #define loop2(n) for (ll i = 1; i <= (n); i++) 17 | #define test \ 18 | ll t; \ 19 | cin >> t; \ 20 | while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | 28 | test 29 | { 30 | ll int n, k, terms, ans; 31 | cin >> n >> k; 32 | terms = pow(2, n); 33 | ans = (terms - 1) * 2 * min(terms / 2, k); 34 | cout << ans << endl; 35 | } 36 | return 0; 37 | } 38 | 39 | /* 40 | 41 | For example take n = 3, 42 | terms = 2*3 = 8 43 | (8-1) = 7 44 | 45 | 0 1 2 3 4 5 6 7 46 | if we add(BINARY OF) -----> 47 | 0 with 7 , 48 | 1 with 6 ..... like this 49 | then 50 | value will always come (terms - 1) --------------> XOR PROPERTY 51 | 52 | 53 | */ -------------------------------------------------------------------------------- /Which_Mixture.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/OCT21C/problems/MIXTURE 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int a, b; 37 | cin >> a >> b; 38 | 39 | if (a > 0 && b > 0) 40 | cout << "Solution\n"; 41 | 42 | else if (b == 0) 43 | cout << "Solid\n"; 44 | 45 | else 46 | cout << "Liquid\n"; 47 | } 48 | 49 | return 0; 50 | } -------------------------------------------------------------------------------- /Hardest_Problem_Bet.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START10C/problems/HARDBET 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define vi vector 17 | #define vll vector 18 | #define pb push_back 19 | #define mp make_pair 20 | #define loop1(n) for (ll i = 0; i < (n); i++) 21 | #define loop2(n) for (ll i = 1; i <= (n); i++) 22 | #define test \ 23 | ll t; \ 24 | cin >> t; \ 25 | while (t--) 26 | 27 | int main() 28 | { 29 | ios_base::sync_with_stdio(false); 30 | cin.tie(NULL); 31 | cout.tie(NULL); 32 | 33 | test 34 | { 35 | int Sa, Sb, Sc; 36 | cin >> Sa >> Sb >> Sc; 37 | 38 | if (Sa <= Sb && Sa <= Sc) 39 | cout << "Draw\n"; 40 | 41 | else if (Sb <= Sa && Sb <= Sc) 42 | cout << "Bob\n"; 43 | 44 | else 45 | cout << "Alice\n"; 46 | } 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Hungry_Ashish.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK137C/problems/PIZZA_BURGER 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int x, y, z; 37 | cin >> x >> y >> z; 38 | 39 | if (y <= x) 40 | cout << "PIZZA\n"; 41 | 42 | else if (z <= x) 43 | cout << "BURGER\n"; 44 | 45 | else 46 | cout << "NOTHING\n"; 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /Blackjack.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START27C/problems/BLACKJACK 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int a, b, sum = 0, res = 0; 37 | cin >> a >> b; 38 | 39 | sum = (a + b); 40 | 41 | res = 21 - sum; 42 | 43 | if (res > 0 && res <= 10) 44 | cout << res << endl; 45 | else 46 | cout << "-1" << endl; 47 | } 48 | 49 | return 0; 50 | } -------------------------------------------------------------------------------- /Too_many_items.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START27C/problems/POLYBAGS 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int n, res = 0; 31 | cin >> n; 32 | 33 | res = n / 10; 34 | n = n % 10; // remainder 35 | if (n == 0) 36 | cout << res << endl; 37 | else 38 | cout << res + 1 << endl; 39 | } 40 | 41 | int main() 42 | { 43 | ios_base::sync_with_stdio(false); 44 | cin.tie(NULL); 45 | cout.tie(NULL); 46 | 47 | test 48 | { 49 | solve(); 50 | } 51 | 52 | return 0; 53 | } -------------------------------------------------------------------------------- /Diagonal_movement.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START14C/problems/DIAGMOVE 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | ll x, y; 37 | cin >> x >> y; 38 | 39 | if (abs(x) == abs(y)) 40 | cout << "YES\n"; 41 | 42 | else if ((abs(x) - abs(y)) % 2 == 0) 43 | cout << "YES\n"; 44 | 45 | else 46 | cout << "NO\n"; 47 | } 48 | 49 | return 0; 50 | } -------------------------------------------------------------------------------- /Minimum_Number_of_Pizzas.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME102C/problems/MINPIZZAS 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | lli gcd(lli a, lli b) 29 | { 30 | if (a == 0) 31 | return b; 32 | return gcd(b % a, a); 33 | } 34 | 35 | int main() 36 | { 37 | ios_base::sync_with_stdio(false); 38 | cin.tie(NULL); 39 | cout.tie(NULL); 40 | 41 | test 42 | { 43 | lli n, k, ans = 0, res = 0; 44 | cin >> n >> k; 45 | 46 | ans = n / gcd(n, k); 47 | cout << ans << endl; 48 | } 49 | 50 | return 0; 51 | } -------------------------------------------------------------------------------- /Obtain_the_Sum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START11C/problems/BIGARRAY 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | long long int n, s, sum, ans = 0; 37 | cin >> n >> s; 38 | 39 | sum = (n * (n + 1)) / 2; 40 | ans = sum - s; 41 | 42 | if (ans > 0 && ans <= n) 43 | cout << ans << endl; 44 | else 45 | cout << "-1\n"; 46 | } 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Keplers_Law.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/JAN221C/problems/KEPLERSLAW 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int t1, t2, r1, r2; 37 | cin >> t1 >> t2 >> r1 >> r2; 38 | 39 | float left = pow(t1, 2) / pow(r1, 3); 40 | float right = pow(t2, 2) / pow(r2, 3); 41 | 42 | if (left == right) 43 | cout << "Yes\n"; 44 | else 45 | cout << "No\n"; 46 | } 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Ada_dishes.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | int t; 8 | scanf("%d", &t); 9 | 10 | while (t--) 11 | { 12 | int i, n, a, first = 0, sec = 0, diff, j; 13 | scanf("%d", &n); 14 | int c[n]; 15 | 16 | for (i = 0; i < n; i++) 17 | scanf("%d", &c[i]); 18 | 19 | // reverse sorting 20 | Sort(c, c + n); 21 | Reverse(c, c + n); 22 | /* for (i = 0; i < n; ++i) 23 | { 24 | for (j = i + 1; j < n; ++j) 25 | { 26 | if (c[i] < c[j]) 27 | { 28 | a = c[i]; 29 | c[i] = c[j]; 30 | c[j] = a; 31 | } 32 | } 33 | } */ 34 | 35 | first = first + c[0]; 36 | 37 | for (i = 1; i < n; i++) 38 | { 39 | 40 | if (first > sec) 41 | { 42 | sec = sec + c[i]; 43 | } 44 | else 45 | { 46 | first = first + c[i]; 47 | } 48 | } 49 | 50 | if (first >= sec) 51 | printf("%d\n", first); 52 | 53 | else 54 | printf("%d\n", sec); 55 | } 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /Chef_and_Pal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START20C/problems/ANTIPAL 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int n, i; 37 | cin >> n; 38 | string s; 39 | 40 | if (n % 2 != 0) // ODD 41 | cout << "-1\n"; 42 | else 43 | { 44 | for (i = 0; i < n / 2; i++) 45 | s = s + "10"; 46 | cout << s << endl; 47 | } 48 | } 49 | 50 | return 0; 51 | } -------------------------------------------------------------------------------- /The_product_mystery.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START27C/problems/PRODUCT 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int gcd(int a, int b) 29 | { 30 | if (a == 0) 31 | return b; 32 | return gcd(b % a, a); 33 | } 34 | 35 | void solve() 36 | { 37 | int b, c, a = 0, res = 0, i; 38 | cin >> b >> c; 39 | 40 | res = gcd(b, c); 41 | 42 | cout << c / res << endl; 43 | } 44 | 45 | int main() 46 | { 47 | ios_base::sync_with_stdio(false); 48 | cin.tie(NULL); 49 | cout.tie(NULL); 50 | 51 | test 52 | { 53 | solve(); 54 | } 55 | 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Three_Boxes.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ________________________________________ 4 | ---------------------------------------- 5 | Author : Niharika Dutta 6 | Code Link : https://www.codechef.com/OCT21C/problems/THREEBOX 7 | Time Complexity : 8 | ________________________________________ 9 | ---------------------------------------- 10 | */ 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | 16 | #define ll long long 17 | #define lli long long int 18 | #define vi vector 19 | #define vll vector 20 | #define pb push_back 21 | #define mp make_pair 22 | #define loop1(n) for (ll i = 0; i < (n); i++) 23 | #define loop2(n) for (ll i = 1; i <= (n); i++) 24 | #define test \ 25 | ll t; \ 26 | cin >> t; \ 27 | while (t--) 28 | 29 | int main() 30 | { 31 | ios_base::sync_with_stdio(false); 32 | cin.tie(NULL); 33 | cout.tie(NULL); 34 | 35 | test 36 | { 37 | int a, b, c, d, flag = 0; 38 | cin >> a >> b >> c >> d; 39 | 40 | if (a + b + c <= d) 41 | flag = 1; 42 | else if (a + b <= d || b + c <= d || c + a <= d) 43 | flag = 2; 44 | else 45 | flag = 3; 46 | 47 | cout << flag << endl; 48 | } 49 | 50 | return 0; 51 | } -------------------------------------------------------------------------------- /Programming_Languages.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME99C/problems/PROGLANG 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define vi vector 17 | #define vll vector 18 | #define pb push_back 19 | #define mp make_pair 20 | #define loop1(n) for (ll i = 0; i < (n); i++) 21 | #define loop2(n) for (ll i = 1; i <= (n); i++) 22 | #define test \ 23 | ll t; \ 24 | cin >> t; \ 25 | while (t--) 26 | 27 | int main() 28 | { 29 | ios_base::sync_with_stdio(false); 30 | cin.tie(NULL); 31 | cout.tie(NULL); 32 | 33 | test 34 | { 35 | int a, b, a1, b1, a2, b2, a3, b3, a4, b4; 36 | cin >> a >> b >> a1 >> b1 >> a2 >> b2; 37 | 38 | if ((a == a1 && b == b1) || (a == b1 && b == a1)) 39 | cout << "1\n"; 40 | else if ((a == a2 && b == b2) || (a == b2 && b == a2)) 41 | cout << "2\n"; 42 | else 43 | cout << "0\n"; 44 | } 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Utkarsh_and_Placement_tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ________________________________________ 4 | ---------------------------------------- 5 | Author : Niharika Dutta 6 | Code Link : https://www.codechef.com/DEC21C/problems/UTKPLC 7 | Time Complexity : 8 | ________________________________________ 9 | ---------------------------------------- 10 | */ 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | 16 | #define ll long long 17 | #define lli long long int 18 | #define vi vector 19 | #define vll vector 20 | #define pb push_back 21 | #define mp make_pair 22 | #define loop1(n) for (ll i = 0; i < (n); i++) 23 | #define loop2(n) for (ll i = 1; i <= (n); i++) 24 | #define test \ 25 | ll t; \ 26 | cin >> t; \ 27 | while (t--) 28 | 29 | int main() 30 | { 31 | ios_base::sync_with_stdio(false); 32 | cin.tie(NULL); 33 | cout.tie(NULL); 34 | 35 | test 36 | { 37 | char a, b, c, x, y; 38 | cin >> a >> b >> c; 39 | 40 | // string s[3]; 41 | // cin >> s[0] >> s[1] >> s[2]; 42 | cin >> x >> y; 43 | 44 | if (a == x || a == y) 45 | cout << a << endl; 46 | 47 | else 48 | cout << b << endl; 49 | } 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /Mask_Policy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK137C/problems/MASKPOL 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int total, affected, safe = 0; 37 | cin >> total >> affected; 38 | 39 | safe = total - affected; 40 | if (safe > affected) 41 | cout << affected << endl; 42 | else if (safe < affected) 43 | cout << safe << endl; 44 | else 45 | cout << affected << endl; 46 | } 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Distinct_Binary_Strings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START27C/problems/BINSTRING 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int len, i, res = 0, result = 0; 31 | cin >> len; 32 | string str; 33 | cin >> str; 34 | 35 | for (i = 0; i < len; i++) 36 | { 37 | if (str[i + 1] != str[i]) 38 | result++; 39 | } 40 | 41 | cout << result << endl; 42 | } 43 | 44 | int main() 45 | { 46 | ios_base::sync_with_stdio(false); 47 | cin.tie(NULL); 48 | cout.tie(NULL); 49 | 50 | test 51 | { 52 | solve(); 53 | } 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /Magical_Doors.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START13C/problems/MAGDOORS 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | string s; 37 | int i, count = 0; 38 | 39 | cin >> s; 40 | 41 | if (s[0] == '0') 42 | count = 1; 43 | 44 | for (i = 1; i < s.length(); i++) 45 | { 46 | if (s[i] != s[i - 1]) 47 | count++; 48 | } 49 | 50 | cout << count << endl; 51 | } 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /Weird_Palindrome_Making_GOODQ.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/NOV21C/problems/MAKEPAL 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | lli i, countOdd = 0, n; 37 | cin >> n; 38 | vector a(n); 39 | 40 | for (i = 0; i < n; i++) 41 | { 42 | cin >> a[i]; 43 | if (a[i] % 2 != 0) // Odd number 44 | countOdd++; 45 | } 46 | 47 | cout << countOdd / 2 << endl; 48 | } 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /Palindromes_Not_Allowed.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK137C/problems/NOPAL 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int len, i, a = 97; 37 | string str; 38 | 39 | cin >> len; 40 | 41 | // ascii values a = 97 to z = 122 42 | while (len--) 43 | { 44 | if (a == 122) 45 | a = 97; 46 | cout << (char)a; 47 | a++; 48 | } 49 | 50 | cout << endl; 51 | } 52 | return 0; 53 | } -------------------------------------------------------------------------------- /Restore_sequenceCC.cpp: -------------------------------------------------------------------------------- 1 | 2 | // LINKS :: https://www.codechef.com/NOV20B/problems/RESTORE 3 | // Successfully runned and compiled.. 4 | 5 | #include 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | long long i, j, MAX = 4000000; 11 | long long *a, *c; 12 | a = new long long[MAX]; 13 | 14 | for (i = 2; i < MAX; i++) 15 | a[i] = 1; 16 | 17 | for (i = 2; i < sqrt(MAX); i++) 18 | { 19 | if (a[i] == 1) 20 | for (j = i; i * j < MAX; j++) 21 | a[i * j] = 0; // non - prime. 22 | } 23 | 24 | int t; 25 | cin >> t; 26 | while (t--) 27 | { 28 | long long n, k = 2; 29 | cin >> n; 30 | long long *b; 31 | b = new long long[n]; 32 | 33 | for (i = 0; i < n; i++) 34 | cin >> b[i]; 35 | 36 | unordered_map map; 37 | for (i = 0; i < n; i++) 38 | { 39 | if (map.find(b[i]) == map.end()) 40 | { 41 | while (a[k] == 0) 42 | k++; 43 | map[b[i]] = k; 44 | k++; 45 | } 46 | } 47 | for (i = 0; i < n; i++) 48 | cout << map[b[i]] << " "; 49 | cout << "\n"; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Find_the_Direction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START11C/problems/FACEDIR 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int x, mod; 37 | cin >> x; 38 | mod = x % 4; 39 | 40 | if (mod == 1) 41 | cout << "East\n"; 42 | else if (mod == 2) 43 | cout << "South\n"; 44 | else if (mod == 3) 45 | cout << "West\n"; 46 | else if (mod == 0) 47 | cout << "North\n"; 48 | } 49 | 50 | return 0; 51 | } -------------------------------------------------------------------------------- /Maximum_Light_Up.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START13C/problems/DIWALI1 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | ll budget, a, b, c, x, y, maxNum = 0; 37 | cin >> budget >> a >> b >> c >> x >> y; 38 | 39 | /* 40 | Cost to light Up 1 Anar = (a * x ) + b; 41 | Cost to light Up 1 Charki = (y * a) + c; 42 | */ 43 | 44 | maxNum = min((a * x) + b, (y * a) + c); 45 | cout << budget / maxNum << endl; 46 | } 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Chef_and_Stock_Prices_.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ________________________________________ 4 | ---------------------------------------- 5 | Author : Niharika Dutta 6 | Code Link : https://www.codechef.com/LTIME102C/problems/CSTOCK 7 | Time Complexity : 8 | ________________________________________ 9 | ---------------------------------------- 10 | */ 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | 16 | #define ll long long 17 | #define lli long long int 18 | #define vi vector 19 | #define vll vector 20 | #define pb push_back 21 | #define mp make_pair 22 | #define loop1(n) for (ll i = 0; i < (n); i++) 23 | #define loop2(n) for (ll i = 1; i <= (n); i++) 24 | #define test \ 25 | ll t; \ 26 | cin >> t; \ 27 | while (t--) 28 | 29 | int main() 30 | { 31 | ios_base::sync_with_stdio(false); 32 | cin.tie(NULL); 33 | cout.tie(NULL); 34 | 35 | test 36 | { 37 | double s, a, b, c, val; 38 | cin >> s >> a >> b >> c; 39 | 40 | // if (c > 0) 41 | // val = s + ((c / 100.0) * s); 42 | // else 43 | val = s + ((c / 100.0) * s); 44 | 45 | if (val >= a && val <= b) 46 | cout << val << "YES\n"; 47 | else 48 | cout << val << "NO\n"; 49 | } 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /Travel_Pass.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/SEPT21C/problems/TRAVELPS 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define vi vector 17 | #define vll vector 18 | #define pb push_back 19 | #define mp make_pair 20 | #define loop1(n) for (ll i = 0; i < (n); i++) 21 | #define loop2(n) for (ll i = 1; i <= (n); i++) 22 | #define test \ 23 | ll t; \ 24 | cin >> t; \ 25 | while (t--) 26 | 27 | int main() 28 | { 29 | ios_base::sync_with_stdio(false); 30 | cin.tie(NULL); 31 | cout.tie(NULL); 32 | 33 | test 34 | { 35 | int i, a, b, n, zero = 0, one = 0, sum = 0; 36 | cin >> n >> a >> b; 37 | string s; 38 | cin >> s; 39 | 40 | for (i = 0; i < n; i++) 41 | { 42 | if (s[i] == '0') 43 | zero++; 44 | else 45 | one++; 46 | } 47 | 48 | sum = (zero * a) + (one * b); 49 | cout << sum << endl; 50 | } 51 | 52 | return 0; 53 | } -------------------------------------------------------------------------------- /Chef_and_NextGen.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/FEB222C/problems/HELIUM3 6 | Time Complexity : https://www.codechef.com/FEB222C/problems/HELIUM3 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int x, y, a, b; 31 | cin >> a >> b >> x >> y; 32 | 33 | int totalPower = x * y; 34 | int provide = a * b; // for b years 35 | 36 | if (totalPower >= provide) 37 | cout << "YES" << endl; 38 | else 39 | cout << "NO" << endl; 40 | } 41 | 42 | int main() 43 | { 44 | ios_base::sync_with_stdio(false); 45 | cin.tie(NULL); 46 | cout.tie(NULL); 47 | 48 | test 49 | { 50 | solve(); 51 | } 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /Four_Equidistant_Points_on_a_Grid.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME105C/problems/DISTCON 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int d; 31 | cin >> d; 32 | 33 | if (d == 1 || d % 2) 34 | { 35 | cout << "-1" << endl; 36 | return; 37 | } 38 | 39 | d = d / 2; 40 | 41 | cout << 0 << " " << d << endl; 42 | cout << d << " " << 0 << endl; 43 | cout << 0 << " " << -(d) << endl; 44 | cout << -(d) << " " << 0 << endl; 45 | } 46 | 47 | int main() 48 | { 49 | ios_base::sync_with_stdio(false); 50 | cin.tie(NULL); 51 | cout.tie(NULL); 52 | 53 | solve(); 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /Chef_and_Water_Car.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME101C/problems/CHEFCAR 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | int n, v; 35 | cin >> n >> v; 36 | int min = 0, max = (n * (n - 1)) / 2; // n * (n+1) / 2 , but here n=(n-1) 37 | if (v == 1) 38 | { 39 | cout << max << ' ' << max << endl; 40 | return; 41 | } 42 | 43 | if (v >= n - 1) 44 | min = n - 1; // 1 * (n-1) 45 | else 46 | min += v + ((n - v) * (n - v + 1)) / 2 - 1; 47 | 48 | cout << max << ' ' << min << endl; 49 | 50 | return 0; 51 | } -------------------------------------------------------------------------------- /Make_it_Divisible.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START12C/problems/MAKEDIV3 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int n, i; 37 | // string digit; 38 | cin >> n; 39 | 40 | if (n == 1) 41 | cout << "3\n"; 42 | else if (n == 2) 43 | cout << "33\n"; 44 | else 45 | { 46 | cout << "3"; 47 | for (i = 1; i <= (n - 1); i++) 48 | cout << "0"; 49 | cout << "3\n"; 50 | } 51 | } 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /Airline_Restrictions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/SEPT21C/problems/AIRLINE 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define vi vector 17 | #define vll vector 18 | #define pb push_back 19 | #define mp make_pair 20 | #define loop1(n) for (ll i = 0; i < (n); i++) 21 | #define loop2(n) for (ll i = 1; i <= (n); i++) 22 | #define test \ 23 | ll t; \ 24 | cin >> t; \ 25 | while (t--) 26 | 27 | int main() 28 | { 29 | ios_base::sync_with_stdio(false); 30 | cin.tie(NULL); 31 | cout.tie(NULL); 32 | 33 | test 34 | { 35 | int a, b, c, d, e, flag = 0; 36 | cin >> a >> b >> c >> d >> e; 37 | 38 | if (a <= e && (b + c) <= d) 39 | flag = 1; 40 | else if (b <= e && (c + a) <= d) 41 | flag = 1; 42 | else if (c <= e && (a + b) <= d) 43 | flag = 1; 44 | 45 | if (flag) 46 | cout << "YES" << endl; 47 | else 48 | cout << "NO" << endl; 49 | } 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /New_Piece.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START17C/problems/NEWPIECE 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int a, b, p, q; 37 | cin >> a >> b >> p >> q; 38 | 39 | if (a == p && b == q) 40 | cout << "0\n"; 41 | 42 | else 43 | { 44 | if (((a + b) % 2 == 0 && (p + q) % 2 == 0) || ((a + b) % 2 != 0 && (p + q) % 2 != 0)) // same color 45 | cout << "2\n"; 46 | 47 | else 48 | cout << "1\n"; 49 | } 50 | } 51 | 52 | return 0; 53 | } -------------------------------------------------------------------------------- /Encoding_Message.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/problems/ENCMSG 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define pb push_back 13 | #define mp make_pair 14 | #define loop1(n) for (ll i = 0; i < (n); i++) 15 | #define loop2(n) for (ll i = 1; i <= (n); i++) 16 | #define test \ 17 | ll t; \ 18 | cin >> t; \ 19 | while (t--) 20 | 21 | int main() 22 | { 23 | ios_base::sync_with_stdio(false); 24 | cin.tie(NULL); 25 | cout.tie(NULL); 26 | test 27 | { 28 | int n, i, swap, length; 29 | char temp; 30 | cin >> n; 31 | string s; 32 | cin >> s; 33 | length = s.length(); 34 | if (length % 2 == 0) //even 35 | { 36 | for (i = 0; i < n; i = i + 2) 37 | swap(s[i],s[i+1]); 38 | } 39 | else 40 | { 41 | for (i = 0; i < n - 1; i = i + 2) 42 | { 43 | temp = s[i + 1]; 44 | s[i + 1] = s[i]; 45 | s[i] = temp; 46 | } 47 | } 48 | for (i = 0; i < length; i++) 49 | s[i] = 'z' - (s[i] - 'a'); 50 | 51 | cout << s << "\n"; 52 | } 53 | return 0; 54 | } -------------------------------------------------------------------------------- /The_Two_Dishes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START11C/problems/MAX_DIFF 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int n, s, temp, diff; 37 | cin >> n >> s; 38 | 39 | if (n < s) 40 | { 41 | temp = s - n; 42 | diff = abs(n - temp); 43 | } 44 | // if (s == n) 45 | // { 46 | // diff = n; 47 | // } 48 | else if (n >= s) 49 | { 50 | diff = s; 51 | } 52 | 53 | cout << diff << endl; 54 | } 55 | 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Avoid_Contact.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START24C/problems/AVOIDCONTACT 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int total = 0, affected = 0; 31 | cin >> total >> affected; 32 | 33 | if (affected == 0) 34 | { 35 | cout << total << endl; 36 | return; 37 | } 38 | 39 | if (affected == total) 40 | { 41 | cout << total + (total - 1) << endl; 42 | return; 43 | } 44 | 45 | cout << total + affected << endl; 46 | } 47 | 48 | int main() 49 | { 50 | ios_base::sync_with_stdio(false); 51 | cin.tie(NULL); 52 | cout.tie(NULL); 53 | 54 | test 55 | { 56 | solve(); 57 | } 58 | 59 | return 0; 60 | } -------------------------------------------------------------------------------- /Alternating_Work_Days.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME101C/problems/ALTER 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | ll a, b, p, q, adays, bdays; 37 | cin >> a >> b >> p >> q; 38 | 39 | ll aa = p / a; 40 | ll bb = q / b; 41 | if (p % a == 0 && q % b == 0) 42 | { 43 | if (abs(aa - bb) == 1 || abs(aa - bb) == 0) 44 | cout << "Yes" << endl; 45 | else 46 | cout << "No" << endl; 47 | } 48 | else 49 | cout << "No" << endl; 50 | } 51 | 52 | return 0; 53 | } -------------------------------------------------------------------------------- /Special_Products.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/PPW12020/problems/ANITGUY2 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | #define ll long long 10 | #define vi vector 11 | #define pb push_back 12 | #define mp make_pair 13 | #define loop1(n) for (ll i = 0; i < (n); i++) 14 | #define loop2(n) for (ll i = 1; i <= (n); i++) 15 | #define test \ 16 | ll t; \ 17 | cin >> t; \ 18 | while (t--) 19 | // #define test ll t; scanf("%d", &t);while (t--) 20 | 21 | int main() 22 | { 23 | ios_base::sync_with_stdio(false); 24 | cin.tie(NULL); 25 | cout.tie(NULL); 26 | test 27 | { 28 | int i, j, p, c = 0, n, x; 29 | cin >> x; 30 | cin >> n; 31 | vi ar; 32 | for (i = 0; i < n; i++) 33 | { 34 | int tmp; 35 | cin >> tmp; 36 | ar.pb(tmp); 37 | } 38 | for (i = 0; i < n; i++) 39 | { 40 | if (ar[i] < x) 41 | count++; 42 | p = ar[i]; 43 | for (j = i + 1; j < n; j++) 44 | { 45 | p = p * ar[j]; 46 | if (p < k) 47 | c++; 48 | else 49 | break; 50 | } 51 | } 52 | cout << c << "\n"; 53 | } 54 | return 0; 55 | } -------------------------------------------------------------------------------- /Avoid_Fixed_Points.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/FEB222C/problems/NOFIX 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solver() 29 | { 30 | int len, i, k = 0, index = 0; 31 | cin >> len; 32 | vector vec(len); 33 | 34 | for (i = 0; i < len; i++) 35 | cin >> vec[i]; 36 | 37 | for (i = 0; i < len; i++) 38 | { 39 | index = (i + 1) + k; 40 | if (index == vec[i]) 41 | k++; 42 | // cout << vec[i] << " "; 43 | } 44 | 45 | cout << k << endl; 46 | } 47 | 48 | int main() 49 | { 50 | ios_base::sync_with_stdio(false); 51 | cin.tie(NULL); 52 | cout.tie(NULL); 53 | 54 | test 55 | { 56 | the 57 | solver(); 58 | } 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Good_Weather.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START12C/problems/GOODWEAT 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | vector v(7); 37 | int i, sunny = 0, rainny = 0; 38 | 39 | for (i = 0; i < 7; i++) 40 | cin >> v[i]; 41 | 42 | for (i = 0; i < 7; i++) 43 | { 44 | if (v[i] == 0) 45 | rainny++; 46 | else 47 | sunny++; 48 | } 49 | 50 | if (sunny > rainny) 51 | cout << "YES\n"; 52 | else 53 | cout << "NO\n"; 54 | } 55 | 56 | return 0; 57 | } -------------------------------------------------------------------------------- /String_Reverse.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START27C/problems/STR_REVERSE 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | string str, reverseStr; 31 | cin >> str; 32 | int i = 0, len = str.length(), count = 0, j = 0; 33 | 34 | reverseStr = str; 35 | reverse(reverseStr.begin(), reverseStr.end()); 36 | 37 | while (i < len) 38 | { 39 | if (str[i] == reverseStr[j]) 40 | j++; 41 | else 42 | count++; 43 | i++; 44 | } 45 | 46 | cout << count << endl; 47 | } 48 | 49 | int main() 50 | { 51 | ios_base::sync_with_stdio(false); 52 | cin.tie(NULL); 53 | cout.tie(NULL); 54 | 55 | test 56 | { 57 | solve(); 58 | } 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Odd_Sum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK134C/problems/ODDSUM 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | ll n; 37 | cin >> n; 38 | 39 | if (n == 1 || n == 2) 40 | cout << "1\n"; 41 | else 42 | { 43 | /* 1 + 0 + (even numbers) 44 | 1 + 0 + [2 , 4 ,6 ,8 ,... ] 45 | N = 5 , 1 + 0 + [3 terms] 46 | N , 1 + 0 + n(n+1) 47 | */ 48 | 49 | n = n - 2; 50 | cout << 1 + n * (n + 1) << endl; 51 | } 52 | } 53 | 54 | return 0; 55 | } -------------------------------------------------------------------------------- /The_One_with_All_the_Candy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/FOUR21C/problems/S07E09 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | lli n, i, maxTime = 0, minElement; 37 | cin >> n; 38 | vector vec(n); 39 | for (i = 0; i < n; i++) 40 | cin >> vec[i]; 41 | 42 | minElement = *min_element(vec.begin(), vec.end()); 43 | maxTime = minElement * n; // minimum num of times the bowl rotates 44 | 45 | for (i = 0; i < n; i++) 46 | if (vec[i] > minElement) 47 | maxTime++; 48 | 49 | cout << maxTime << endl; 50 | } 51 | 52 | return 0; 53 | } -------------------------------------------------------------------------------- /Professor_And_Directions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START16C/problems/DIRECTN 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int n, i, flag = 0; 37 | string s; 38 | cin >> n; 39 | cin >> s; 40 | 41 | for (i = 0; i < s.length(); i++) 42 | { 43 | if ((s[i] == 'R' && s[i + 1] == 'R') || (s[i] == 'L' && s[i - 1] == 'L')) 44 | { 45 | flag = 1; 46 | break; 47 | } 48 | } 49 | 50 | if (flag) 51 | cout << "YES\n"; 52 | else 53 | cout << "NO\n"; 54 | } 55 | 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Movie_weekend.c: -------------------------------------------------------------------------------- 1 | 2 | // LINKS :: https://www.codechef.com/problems/MOVIEWKN 3 | 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | #define ll long long 9 | #define pb push_back 10 | #define loop1(n) for (ll i = 0; i < (n); i++) 11 | #define loop2(n) for (ll i = 1; i <= (n); i++) 12 | #define test \ 13 | ll t; \ 14 | cin >> t; \ 15 | while (t--) 16 | 17 | int main() 18 | { 19 | ios_base::sync_with_stdio(false); 20 | cin.tie(NULL); 21 | cout.tie(NULL); 22 | 23 | test 24 | { 25 | int n, index=0, max, i; 26 | cin >> n; 27 | int l[n], r[n]; 28 | // vector l,r; 29 | for (i = 0; i < (n); i++) 30 | cin >> l[i]; 31 | // l.push_back(i); 32 | 33 | for (i = 0; i < (n); i++) 34 | cin >> r[i]; 35 | // r.push_back(i); 36 | 37 | max = l[0] * r[0]; 38 | for (i = 0; i < n; i++) 39 | { 40 | if ((l[i] * r[i]) > max) 41 | { 42 | max = (l[i] * r[i]); 43 | index = i; 44 | } 45 | else if (l[i] * r[i] == max) 46 | { 47 | if (r[i] > r[index]) 48 | { 49 | max = l[i] * r[i]; 50 | index = i; 51 | } 52 | } 53 | } 54 | cout << index + 1 << "\n"; 55 | } 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Prefix_Permutation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK138C/problems/PREFPERM 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int n, k, previous = 0, i, j; 31 | cin >> n >> k; 32 | vector vec(k), result; 33 | for (i = 0; i < k; i++) 34 | cin >> vec[i]; 35 | 36 | for (i = 0; i < k; i++) 37 | { 38 | for (j = vec[i]; j > previous; j--) 39 | result.push_back(j); 40 | previous = vec[i]; 41 | } 42 | 43 | for (auto it : result) 44 | cout << it << " "; 45 | 46 | cout << endl; 47 | } 48 | 49 | int main() 50 | { 51 | ios_base::sync_with_stdio(false); 52 | cin.tie(NULL); 53 | cout.tie(NULL); 54 | 55 | test 56 | { 57 | solve(); 58 | } 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /MEX_OR.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/OCT21C/problems/MEXOR 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | ll x, k = 1; 37 | cin >> x; 38 | 39 | if (x == 2 || x == 1) 40 | cout << "2\n"; 41 | else if (x == 0) 42 | cout << "1\n"; 43 | else 44 | { 45 | while (k * 2 <= x) 46 | k = k * 2; 47 | 48 | if (k == x) 49 | cout << x << endl; 50 | else if (x == 2 * k - 1) 51 | cout << x + 1 << endl; 52 | else 53 | cout << k << endl; 54 | } 55 | } 56 | 57 | return 0; 58 | } -------------------------------------------------------------------------------- /Chef_and_Bulb_Invention.AUG_LCcpp.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/AUG21C/problems/CHFINVNT 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define vll vector 13 | #define pb push_back 14 | #define mp make_pair 15 | #define loop1(n) for (ll i = 0; i < (n); i++) 16 | #define loop2(n) for (ll i = 1; i <= (n); i++) 17 | #define test \ 18 | ll t; \ 19 | cin >> t; \ 20 | while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | 28 | test 29 | { 30 | // 18 9 5 31 | ll int n, p, k, ans = 0, x, mod, i; 32 | cin >> n >> p >> k; 33 | 34 | mod = p % k; // 4 35 | mod = mod - 1; 36 | 37 | // 2 size extra after 15 (last no. divisibe by 5 here) 38 | x = (n - 1) - ((n - 1) / k) * k; // 17 - 15 = 2 39 | 40 | if (mod > x) 41 | ans = ans + (x + 1) * (((n - 1) / k) + 1) + (mod - x) * ((n - 1) / k); 42 | 43 | else 44 | ans = ans + (mod + 1) * ((n - 1) / k + 1); 45 | 46 | for (i = mod + 1; i < n; i = i + k) 47 | { 48 | ans++; 49 | if (i == p) 50 | { 51 | cout << ans << endl; 52 | break; 53 | } 54 | } 55 | } 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Shuffling_Parities.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/SEPT21C/problems/SHUFFLIN 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define vi vector 17 | #define vll vector 18 | #define pb push_back 19 | #define mp make_pair 20 | #define loop1(n) for (ll i = 0; i < (n); i++) 21 | #define loop2(n) for (ll i = 1; i <= (n); i++) 22 | #define test \ 23 | ll t; \ 24 | cin >> t; \ 25 | while (t--) 26 | 27 | int main() 28 | { 29 | ios_base::sync_with_stdio(false); 30 | cin.tie(NULL); 31 | cout.tie(NULL); 32 | 33 | test 34 | { 35 | int i, odd = 0, even = 0, n, oddNums = 0, evenNums = 0, ans = 0; 36 | cin >> n; 37 | int arr[n]; 38 | for (i = 1; i <= n; i++) 39 | cin >> arr[i]; 40 | 41 | even = n / 2; 42 | odd = n - even; 43 | 44 | for (i = 1; i <= n; i++) 45 | { 46 | if (arr[i] % 2 == 0) 47 | evenNums++; 48 | else 49 | oddNums++; 50 | } 51 | 52 | ans = min(oddNums, even) + min(evenNums, odd); 53 | cout << ans << endl; 54 | } 55 | 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Bear_milky_Cookies.cpp: -------------------------------------------------------------------------------- 1 | // LINKS :: https://www.codechef.com/problems/COOMILK 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | #define ll long long 10 | #define vi vector 11 | #define pb push_back 12 | #define mp make_pair 13 | #define loop1(n) for (ll i = 0; i < (n); i++) 14 | #define loop2(n) for (ll i = 1; i <= (n); i++) 15 | #define test \ 16 | ll t; \ 17 | cin >> t; \ 18 | while (t--) 19 | 20 | int main() 21 | { 22 | ios_base::sync_with_stdio(false); 23 | cin.tie(NULL); 24 | cout.tie(NULL); 25 | test 26 | { 27 | int n, flag = 1, i; 28 | cin >> n; 29 | string s[50]; // ARRAY OF STRINGS 30 | for (i = 0; i < n; i++) 31 | cin >> s[i]; 32 | for (i = 0; i < n; i++) 33 | { 34 | if (s[i] == "cookie") 35 | { 36 | if (s[i] == s[i + 1]) // nxt is not "cookie" 37 | { 38 | flag = 0; 39 | break; 40 | } 41 | if ((s[i] != s[i + 1]) && (s[i + 1] != "milk")) //nxt is neither "cookie" nor "milk" 42 | { 43 | flag = 0; 44 | break; 45 | } 46 | } 47 | } 48 | if (flag == 1) 49 | cout << "YES\n"; 50 | else 51 | cout << "NO\n"; 52 | } 53 | 54 | return 0; 55 | } -------------------------------------------------------------------------------- /Careless_Chef.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START26C/problems/LOSTSEQ 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int n, i, len = 0, sum = 0; 31 | cin >> n; 32 | len = n * 2; 33 | vector vec(len); 34 | for (i = 0; i < len; i++) 35 | { 36 | cin >> vec[i]; 37 | sum = sum + vec[i]; 38 | } 39 | 40 | // CountEven == len || CountOdd == len || CountEven == CountOdd 41 | // as (a + k) + (a - k) will becomes 2a so it will always be positive. 42 | if (sum % 2 == 0) 43 | cout << "YES\n"; 44 | else 45 | cout << "NO\n"; 46 | } 47 | 48 | int main() 49 | { 50 | ios_base::sync_with_stdio(false); 51 | cin.tie(NULL); 52 | cout.tie(NULL); 53 | 54 | test 55 | { 56 | solve(); 57 | } 58 | 59 | return 0; 60 | } -------------------------------------------------------------------------------- /Mean_Maximization.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK137C/problems/MEANMAX 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int i, len; 37 | float sum = 0, mean1 = 0, mean2 = 0; 38 | cin >> len; 39 | vector vec(len); 40 | 41 | for (i = 0; i < len; i++) 42 | { 43 | cin >> vec[i]; 44 | sum = sum + vec[i]; 45 | } 46 | 47 | sort(vec.begin(), vec.end()); 48 | 49 | sum = sum - vec[len - 1]; // sum - lastElement 50 | mean1 = sum / (len - 1); 51 | mean2 = vec[len - 1]; 52 | 53 | cout << fixed << setprecision(6) << (mean1 + mean2) << endl; 54 | } 55 | 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Permutation_Xority.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START28C/problems/PERMXORITY 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int n, i; 31 | cin >> n; 32 | 33 | if (n == 2) 34 | { 35 | cout << "-1\n"; 36 | return; 37 | } 38 | 39 | // When N is ODD print all 40 | if (n % 2 != 0) 41 | { 42 | for (i = 1; i <= n; i++) 43 | cout << i << " "; 44 | } 45 | 46 | else 47 | { 48 | for (i = n - 1; i >= 2; i--) 49 | cout << i << " "; 50 | 51 | cout << n << " " << 1; 52 | } 53 | 54 | cout << endl; 55 | } 56 | 57 | int main() 58 | { 59 | ios_base::sync_with_stdio(false); 60 | cin.tie(NULL); 61 | cout.tie(NULL); 62 | 63 | test 64 | { 65 | solve(); 66 | } 67 | 68 | return 0; 69 | } -------------------------------------------------------------------------------- /Count_the_Holidays.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START28C/problems/SUNDAY 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int n, i, getHolidays = 0; 31 | cin >> n; 32 | vector vec(n); 33 | for (i = 0; i < n; i++) 34 | cin >> vec[i]; 35 | 36 | getHolidays = 8; 37 | 38 | for (i = 0; i < n; i++) 39 | { 40 | if (vec[i] == 6 || vec[i] == 7 || vec[i] == 13 || vec[i] == 14 || vec[i] == 20 || vec[i] == 21 || vec[i] == 27 || vec[i] == 28) 41 | continue; 42 | else 43 | getHolidays++; 44 | } 45 | 46 | cout << getHolidays << endl; 47 | } 48 | 49 | int main() 50 | { 51 | ios_base::sync_with_stdio(false); 52 | cin.tie(NULL); 53 | cout.tie(NULL); 54 | 55 | test 56 | { 57 | solve(); 58 | } 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Exactly_N_plus_1_Values.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME101C/problems/N1VALUES 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | ll n, power, i, sum = 0; 37 | cin >> n; 38 | power = pow(2, n); 39 | 40 | if (n == 1) 41 | cout << "1 1\n"; 42 | else 43 | { 44 | for (i = 1; i < n; i++) 45 | { 46 | cout << i << " "; 47 | sum = sum + i; 48 | } 49 | // cout << i - 1 << " " << power - (n * (n + 1) / 2) + 1; 50 | cout << i - 1 << " "; 51 | sum = sum + i - 1; 52 | cout << power - sum << endl; 53 | } 54 | } 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /Average_Flex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK134C/problems/AVGFLEX 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int n, i, j, count = 0, boastStudent = 0; 37 | cin >> n; 38 | int a[n]; 39 | for (i = 0; i < n; i++) 40 | cin >> a[i]; 41 | 42 | for (i = 0; i < n; i++) 43 | { 44 | count = 0; 45 | for (j = 0; j < n; j++) 46 | { 47 | if (a[i] >= a[j]) 48 | count++; // scoring less than and equals to 49 | } 50 | if (count > n - count) 51 | boastStudent++; 52 | } 53 | 54 | cout << boastStudent << endl; 55 | } 56 | 57 | return 0; 58 | } -------------------------------------------------------------------------------- /Equal_Difference.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK132C/problems/EQDIFFER 6 | ________________________________________ 7 | ---------------------------------------- 8 | */ 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | #define ll long long 15 | #define vi vector 16 | #define vll vector 17 | #define pb push_back 18 | #define mp make_pair 19 | #define loop1(n) for (ll i = 0; i < (n); i++) 20 | #define loop2(n) for (ll i = 1; i <= (n); i++) 21 | #define test \ 22 | ll t; \ 23 | cin >> t; \ 24 | while (t--) 25 | 26 | int main() 27 | { 28 | ios_base::sync_with_stdio(false); 29 | cin.tie(NULL); 30 | cout.tie(NULL); 31 | 32 | test 33 | { 34 | int n, i, value = 0; 35 | cin >> n; 36 | vector vec(n); 37 | map mp; 38 | 39 | for (i = 0; i < n; i++) 40 | { 41 | cin >> vec[i]; 42 | mp[vec[i]]++; 43 | value = max(value, mp[vec[i]]); 44 | } 45 | 46 | if (n <= 2) 47 | { 48 | cout << "0" << endl; 49 | continue; // next iteration runs 50 | } 51 | else if (value == 1) 52 | { 53 | cout << n - 2 << endl; 54 | continue; 55 | } 56 | 57 | cout << n - value << endl; 58 | } 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Subarray_permutations.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME104C/problems/SUBPERM 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int len, k, i; 31 | cin >> len >> k; 32 | 33 | vector vec; 34 | for (i = 1; i <= len; i++) 35 | vec.push_back(i); 36 | 37 | if (len > 1 && k == 1) 38 | { 39 | cout << "-1\n"; 40 | return; 41 | } 42 | 43 | // K good subsequence means (n - k) we have to reverse. 44 | for (i = 1; i < k; i++) 45 | cout << i << " "; 46 | 47 | // Reverse 48 | for (i = len; i >= k; i--) 49 | cout << i << " "; 50 | 51 | cout << endl; 52 | } 53 | 54 | int main() 55 | { 56 | ios_base::sync_with_stdio(false); 57 | cin.tie(NULL); 58 | cout.tie(NULL); 59 | 60 | test 61 | { 62 | solve(); 63 | } 64 | 65 | return 0; 66 | } -------------------------------------------------------------------------------- /GCD_of_Prefixes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START17C/problems/GCDPRF 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | lli i, n, flag = 0; 37 | cin >> n; 38 | vector b(n); 39 | 40 | for (i = 0; i < n; i++) 41 | cin >> b[i]; 42 | 43 | for (i = 1; i < n; i++) 44 | { 45 | if ((b[i] > b[i - 1]) && (b[i - 1] % b[i] != 0)) 46 | { 47 | flag = 1; 48 | break; 49 | } 50 | } 51 | 52 | if (flag == 1) 53 | cout << "-1"; 54 | else 55 | for (i = 0; i < n; i++) 56 | cout << b[i] << " "; 57 | 58 | cout << endl; 59 | } 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Gasoline_introduction.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/LTIME90B/problems/BEGGASOL 3 | 4 | #include 5 | using namespace std; 6 | 7 | #define ll long long 8 | #define vi vector 9 | #define pb push_back 10 | #define mp make_pair 11 | #define loop1(n) for (ll i = 0; i < (n); i++) 12 | #define loop2(n) for (ll i = 1; i <= (n); i++) 13 | #define test \ 14 | ll t; \ 15 | cin >> t; \ 16 | while (t--) 17 | 18 | int main() 19 | { 20 | ios_base::sync_with_stdio(false); 21 | cin.tie(NULL); 22 | cout.tie(NULL); 23 | 24 | test 25 | { 26 | 27 | int n, i, petrol = 1, dist = 0, total; 28 | cin >> n; 29 | vi f; 30 | for (i = 0; i < n; i++) 31 | { 32 | int tmp; 33 | cin >> tmp; 34 | f.pb(tmp); 35 | } 36 | petrol = f[0]; 37 | for (i = 1; i < n; i++) 38 | { 39 | if (petrol - 1 >= 0) 40 | { 41 | petrol = petrol - 1 + f[i]; 42 | dist++; 43 | } 44 | if (petrol <= 0) 45 | break; 46 | } 47 | 48 | if (petrol >= 0) 49 | total = dist + petrol; 50 | 51 | cout << total << endl; 52 | } 53 | return 0; 54 | } 55 | 56 | /* cout << "\nVector elements are: "; 57 | for (auto it = f.begin(); it != f.end(); it++) 58 | cout << *it << " "; 59 | 60 | cout << "The vector elements are: "; 61 | for (i = 0; i < f.size(); i++) 62 | cout << f[i] << " "; */ -------------------------------------------------------------------------------- /The_One_with_Russ.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/FOUR21C/problems/S02E10 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int n, x, k, i, count = 0, diff = 0; 37 | cin >> n >> x >> k; 38 | 39 | vector a(n), b(n); 40 | for (i = 0; i < n; i++) 41 | cin >> a[i]; 42 | 43 | for (i = 0; i < n; i++) 44 | cin >> b[i]; 45 | 46 | // Algorithm 47 | for (i = 0; i < n; i++) 48 | { 49 | diff = abs(a[i] - b[i]); 50 | if (diff <= k) 51 | count++; 52 | } 53 | 54 | if (count >= x) 55 | cout << "YES\n"; 56 | else 57 | cout << "NO\n"; 58 | } 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Equal_Coins.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/NOV21C/problems/EQUALCOIN 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int x, y, money = 0; 37 | cin >> x >> y; 38 | 39 | money = x + (2 * y); 40 | // if (money % 2 == 0) 41 | // cout << "YES\n"; 42 | // else 43 | // cout << "NO\n"; 44 | 45 | if (x % 2 == 0) 46 | { 47 | if (x == 0) 48 | { 49 | if (y % 2 == 0) 50 | cout << "YES\n"; 51 | else 52 | cout << "NO\n"; 53 | } 54 | else 55 | cout << "YES\n"; 56 | } 57 | else 58 | cout << "NO\n"; 59 | } 60 | 61 | return 0; 62 | } -------------------------------------------------------------------------------- /RedAlert.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/LTIME98C/problems/REDALERT 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define vll vector 13 | #define pb push_back 14 | #define mp make_pair 15 | #define loop1(n) for (ll i = 0; i < (n); i++) 16 | #define loop2(n) for (ll i = 1; i <= (n); i++) 17 | #define test \ 18 | ll t; \ 19 | cin >> t; \ 20 | while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | 28 | test 29 | { 30 | int n, d, h, i, total = 0, flag = 0; 31 | cin >> n >> d >> h; 32 | vi arr(n); 33 | for (i = 0; i < n; i++) 34 | cin >> arr[i]; 35 | 36 | for (i = 0; i < n; i++) 37 | { 38 | if (arr[i] > 0) 39 | { 40 | total = total + arr[i]; 41 | if (total > h) 42 | { 43 | flag = 1; 44 | break; 45 | } 46 | } 47 | if (arr[i] == 0) 48 | { 49 | if (total >= d) 50 | total = total - d; 51 | else 52 | total = 0; 53 | } 54 | } 55 | 56 | if (flag == 0) 57 | cout << "NO\n"; 58 | else 59 | cout << "YES\n"; 60 | } 61 | return 0; 62 | } 63 | } -------------------------------------------------------------------------------- /Joker_and_Batman.cpp: -------------------------------------------------------------------------------- 1 | 2 | // https://www.codechef.com/START6C/problems/JOKRBTMN 3 | // STARTERS ---> 2021 (JULY) 4 | // IMPORTANT GOOOD PROGRAMMM 5 | 6 | #include 7 | using namespace std; 8 | 9 | #define ll long long 10 | #define vll vector 11 | #define vi vector 12 | #define pb push_back 13 | #define mp make_pair 14 | #define loop1(n) for (ll i = 0; i < (n); i++) 15 | #define loop2(n) for (ll i = 1; i <= (n); i++) 16 | #define test \ 17 | ll t; \ 18 | cin >> t; \ 19 | while (t--) 20 | 21 | int main() 22 | { 23 | ios_base::sync_with_stdio(false); 24 | cin.tie(NULL); 25 | cout.tie(NULL); 26 | 27 | /* 28 | N --> number of colors, 29 | M --> number of lists, 30 | L --> length of the strip, 31 | */ 32 | test 33 | { 34 | int i, j, n, m, l, k, id, ans = 0; 35 | map map; 36 | 37 | cin >> n >> m >> l; 38 | vector strip(l); 39 | 40 | for (i = 0; i < m; i++) // m lists 41 | { 42 | cin >> k; // length of each list 43 | for (j = 0; j < k; j++) 44 | { 45 | cin >> id; 46 | map[id] = i; 47 | } 48 | } 49 | 50 | for (i = 0; i < l; i++) 51 | cin >> strip[i]; 52 | 53 | for (i = 1; i < l; i++) 54 | { 55 | if (map[strip[i]] != map[strip[i - 1]]) 56 | ans++; 57 | } 58 | 59 | cout << ans + 1 << endl; 60 | } 61 | 62 | return 0; 63 | } -------------------------------------------------------------------------------- /Chef_and_Subset_Additions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME104C/problems/SUBSTADD 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int len, x, y, flag = 0, count = 0; 37 | cin >> len >> x >> y; 38 | 39 | int vecA[len], vecB[len]; 40 | 41 | for (int i = 0; i < len; i++) 42 | cin >> vecA[i]; 43 | 44 | for (int j = 0; j < len; j++) 45 | cin >> vecB[j]; 46 | 47 | for (int i = 0; i < len; i++) 48 | { 49 | // Difference not matches 50 | if (vecB[i] - vecA[i] == x || vecB[i] - vecA[i] == y) 51 | count++; 52 | } 53 | 54 | if (count == len) 55 | cout << "yes\n"; 56 | else 57 | cout << "no\n"; 58 | } 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Control_the_Pollution.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START26C/problems/SMOKE 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int human, x, y; 31 | cin >> human >> x >> y; 32 | 33 | // int result = (human + 99) / 100 * x; 34 | // result = min(result, (human + 3) / 4 * y); 35 | // result = min(result, ((human / 100) * x) + ((human % 100) + 3) / 4 * y); 36 | // cout << result << endl; 37 | 38 | double bus = ceil(human / (double)100); 39 | double car = ceil(human / (double)4); 40 | 41 | ll b = n / 100; 42 | ll remaining = n % 100; 43 | ll c = ceil(remaining / (double)4); 44 | 45 | ll res = min({bus * x, car * y, b * x + c * y}); 46 | cout << res << endl; 47 | } 48 | 49 | int main() 50 | { 51 | ios_base::sync_with_stdio(false); 52 | cin.tie(NULL); 53 | cout.tie(NULL); 54 | 55 | test 56 | { 57 | solve(); 58 | } 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Say_No_To_Drugs.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/CDMN21C/problems/NODRUGS 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int n, k, l, i, max = 0, drugGiven = 0, flag = 0; 37 | cin >> n >> k >> l; 38 | int speed[n]; 39 | for (i = 0; i < n; i++) 40 | cin >> speed[i]; 41 | 42 | max = *max_element(speed, speed + n); 43 | 44 | if (speed[n - 1] == max && drugGiven < l - 1) 45 | flag = 1; 46 | 47 | else 48 | { 49 | int fullDrugs = (l - 1) * k; 50 | if (speed[n - 1] + fullDrugs > max) 51 | flag = 1; 52 | } 53 | 54 | if (flag) 55 | cout << "Yes" << endl; 56 | else 57 | cout << "No" << endl; 58 | } 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /Chef_And_Salary_Pay.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START16C/problems/HCAGMAM1 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | int x, y, i, countOne = 0, subarrayLength = 0, max = 0, ans = 0; 37 | string s; 38 | cin >> x >> y; 39 | cin >> s; 40 | int len = s.length(); 41 | 42 | for (i = 0; i < len; i++) 43 | { 44 | if (s[i] == '1') 45 | { 46 | countOne++; 47 | subarrayLength++; 48 | } 49 | 50 | if (subarrayLength > max) 51 | max = subarrayLength; 52 | 53 | if (s[i] == '0') 54 | subarrayLength = 0; 55 | } 56 | 57 | ans = x * countOne + y * max; 58 | cout << ans << endl; 59 | } 60 | 61 | return 0; 62 | } -------------------------------------------------------------------------------- /Perfect_Permutation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK138C/problems/PERFPERM 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int n, k, i; 31 | cin >> n >> k; 32 | 33 | if (k > n) 34 | { 35 | cout << "-1" << endl; 36 | return; 37 | } 38 | 39 | if (n == 1 && k == 1) 40 | { 41 | cout << 1 << endl; 42 | return; 43 | } 44 | 45 | if (k == n) 46 | { 47 | for (i = 1; i <= n; i++) 48 | cout << i << " "; 49 | 50 | cout << endl; 51 | return; 52 | } 53 | 54 | for (i = 1; i <= k; i++) 55 | cout << i << " "; 56 | 57 | for (i = k + 1; i <= n; i++) 58 | cout << 1 << " "; 59 | 60 | cout << endl; 61 | } 62 | 63 | int main() 64 | { 65 | ios_base::sync_with_stdio(false); 66 | cin.tie(NULL); 67 | cout.tie(NULL); 68 | 69 | test 70 | { 71 | solve(); 72 | } 73 | 74 | return 0; 75 | } -------------------------------------------------------------------------------- /Beautiful_Pairs_IMPORTANT.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | //LINKS :: // https://www.codechef.com/LTIME98C/problems/BUTYPAIR 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | #define ll long long 12 | #define vi vector 13 | #define vll vector 14 | #define pb push_back 15 | #define mp make_pair 16 | #define loop1(n) for (ll i = 0; i < (n); i++) 17 | #define loop2(n) for (ll i = 1; i <= (n); i++) 18 | #define test \ 19 | ll t; \ 20 | cin >> t; \ 21 | while (t--) 22 | 23 | int main() 24 | { 25 | ios_base::sync_with_stdio(false); 26 | cin.tie(NULL); 27 | cout.tie(NULL); 28 | 29 | test 30 | { 31 | ll i, n, j, count = 0; 32 | cin >> n; 33 | vll arr(n); 34 | map map; 35 | 36 | for (i = 0; i < n; i++) 37 | { 38 | cin >> arr[i]; 39 | map[arr[i]]++; 40 | } 41 | 42 | for (auto it : map) 43 | count = count + ((n - it.second) * it.second); 44 | 45 | cout << count << endl; 46 | 47 | /* 48 | // O(n^2) NAIVE METHOD / BRUTE FORCE 49 | for (i = 0; i < n; i++) 50 | cin >> arr[i]; 51 | 52 | for (i = 0; i < n - 1; i++) 53 | { 54 | for (j = i + 1; j < n; j++) 55 | { 56 | if (((float)(arr[i] - arr[j]) / (float)arr[i]) < ((float)(arr[i] - arr[j]) / (float)arr[j])) 57 | count++; 58 | } 59 | } 60 | cout << count * 2 << endl; 61 | */ 62 | } 63 | return 0; 64 | } -------------------------------------------------------------------------------- /Team_Formation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/COOK132C/problems/TEAMFOR 6 | ________________________________________ 7 | ---------------------------------------- 8 | */ 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | #define ll long long 15 | #define vi vector 16 | #define vll vector 17 | #define pb push_back 18 | #define mp make_pair 19 | #define loop1(n) for (ll i = 0; i < (n); i++) 20 | #define loop2(n) for (ll i = 1; i <= (n); i++) 21 | #define test \ 22 | ll t; \ 23 | cin >> t; \ 24 | while (t--) 25 | 26 | int main() 27 | { 28 | ios_base::sync_with_stdio(false); 29 | cin.tie(NULL); 30 | cout.tie(NULL); 31 | 32 | test 33 | { 34 | int i, result, n, onlyProg = 0, onlyEng = 0, both = 0; 35 | cin >> n; 36 | string eng, prog; 37 | 38 | cin >> eng; 39 | cin >> prog; 40 | 41 | for (i = 0; i < n; i++) 42 | { 43 | if (prog[i] == '1' /* && eng[i] == '0' */) 44 | onlyProg++; 45 | if (eng[i] == '1' /* && prog[i] == '0' */) 46 | onlyEng++; 47 | // else if (prog[i] == '1' && eng[i] == '1') 48 | // both++; 49 | } 50 | 51 | // while (both * 2 > n) 52 | // both--; 53 | 54 | cout << min(onlyProg, min(onlyEng, n / 2)) << endl; 55 | // result = min(onlyProg, onlyEng); 56 | // cout << (result + both) << endl; 57 | } 58 | 59 | return 0; 60 | } -------------------------------------------------------------------------------- /The_Grid_Fill_Problem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START11C/problems/FILLGRID 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | ll n, i, j; 37 | cin >> n; 38 | 39 | if (n % 2 == 0) 40 | { 41 | for (i = 0; i < n; i++) 42 | { 43 | for (j = 0; j < n; j++) 44 | cout << "-1 "; 45 | cout << "\n"; 46 | } 47 | } 48 | 49 | else // if n = ODD 50 | { 51 | for (i = 0; i < n; i++) 52 | for (j = 0; j < n; j++) 53 | { 54 | if (j == i) 55 | cout << "-1 "; 56 | else 57 | cout << "1 "; 58 | } 59 | cout << "\n"; 60 | } 61 | } 62 | 63 | return 0; 64 | } -------------------------------------------------------------------------------- /World_Chess_Championship.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/FEB222C/problems/WCC 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int x, i, result = 0, chef = 0, carlsen = 0; 31 | cin >> x; 32 | string s; 33 | cin >> s; 34 | 35 | for (i = 0; i < 14; i++) 36 | { 37 | if (s[i] == 'C') 38 | carlsen += 2; 39 | else if (s[i] == 'N') 40 | chef += 2; 41 | else 42 | { 43 | chef += 1; 44 | carlsen += 1; 45 | } 46 | } 47 | 48 | if (chef > carlsen) 49 | result = 40 * x; 50 | 51 | else if (carlsen > chef) 52 | result = 60 * x; 53 | 54 | else if (chef == carlsen) 55 | result = 55 * x; 56 | 57 | cout << result << endl; 58 | } 59 | 60 | int main() 61 | { 62 | ios_base::sync_with_stdio(false); 63 | cin.tie(NULL); 64 | cout.tie(NULL); 65 | 66 | test 67 | { 68 | solve(); 69 | } 70 | 71 | return 0; 72 | } -------------------------------------------------------------------------------- /Restore_sequence.c: -------------------------------------------------------------------------------- 1 | 2 | // LINKS :: https://www.codechef.com/NOV20B/problems/RESTORE 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | int main() 9 | { 10 | long long i, j, k = 0, MAX = 4000000; 11 | long long *a, *c; 12 | a = malloc(sizeof(long long) * MAX); 13 | c = malloc(sizeof(long long) * MAX); 14 | 15 | for (i = 2; i < MAX; i++) 16 | a[i] = 1; 17 | 18 | // ------------------- LOGIC prime- ------------------- 19 | for (i = 2; i < sqrt(MAX); i++) 20 | { 21 | if (a[i] == 1) 22 | for (j = i; i * j < MAX; j++) 23 | a[i * j] = 0; 24 | } 25 | 26 | for (i = 2; i < MAX; i++) 27 | { 28 | if (a[i] == 1) 29 | c[k++] = i; //c is a new array storing prime no. in every index. 30 | } 31 | 32 | int t; 33 | scanf("%d", &t); 34 | while (t--) 35 | { 36 | long long n; 37 | printf("Value of n : "); 38 | scanf("%lld", &n); 39 | long long *b, *a1; 40 | 41 | b = malloc(sizeof(long long) * n); 42 | a1 = malloc(sizeof(long long) * n); 43 | 44 | printf("Value of b array : "); 45 | for (i = 0; i < n; i++) 46 | scanf("%lld", &b[i]); 47 | 48 | for (k = 0; k < n; k++) 49 | a1[k] = c[k]; 50 | 51 | for (i = 0; i < n; i++) 52 | { 53 | if (b[i] == (i + 1)) 54 | break; 55 | else 56 | a1[i] = a1[b[i] - 1]; 57 | } 58 | 59 | printf("\nPrime number till n index -- > \n"); 60 | for (k = 0; k < n; k++) 61 | printf("%lld", a1[k]); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Crossing_Blocks_IMPORTANT_LunchTime.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/LTIME99C/problems/CROSBLK 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define vi vector 17 | #define vll vector 18 | #define pb push_back 19 | #define mp make_pair 20 | #define loop1(n) for (ll i = 0; i < (n); i++) 21 | #define loop2(n) for (ll i = 1; i <= (n); i++) 22 | #define test \ 23 | ll t; \ 24 | cin >> t; \ 25 | while (t--) 26 | 27 | int main() 28 | { 29 | ios_base::sync_with_stdio(false); 30 | cin.tie(NULL); 31 | cout.tie(NULL); 32 | 33 | test 34 | { 35 | int n, i, maxELe = INT_MIN, result = 0; 36 | cin >> n; 37 | vector vec(n); 38 | for (i = 0; i < n; i++) 39 | cin >> vec[i]; 40 | 41 | for (i = n - 1; i > 0; i--) 42 | { 43 | if (vec[i] > maxELe) 44 | { 45 | maxELe = vec[i]; 46 | result++; 47 | } 48 | } 49 | 50 | // At the end the maxELe = 20 51 | // if the first ele of vector is MAX then OK else return -1 52 | if (vec[0] >= maxELe) 53 | cout << result /* - 1 */ << endl; 54 | else 55 | cout << "-1" << endl; 56 | } 57 | 58 | return 0; 59 | } 60 | 61 | // Using STACK :: 62 | /* https://www.codechef.com/viewsolution/50311246 */ -------------------------------------------------------------------------------- /Xor_Palindrome.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/FEB222C/problems/XORPAL 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | void solve() 29 | { 30 | int i, len, zero = 0, one = 0; 31 | cin >> len; 32 | string str; 33 | cin >> str; 34 | 35 | for (i = 0; i < len; i++) 36 | { 37 | if (str[i] == '0') 38 | zero++; 39 | else 40 | one++; 41 | } 42 | 43 | if (len % 2 != 0) // means length ODD 44 | { 45 | cout << "YES\n"; 46 | return; 47 | } 48 | 49 | // length EVEN 50 | // YES ---> all zero , all one , both one & zero even number esist 51 | if (zero == one || zero == len || one == len || (zero % 2 == 0 && one % 2 == 0)) 52 | { 53 | cout << "YES\n"; 54 | return; 55 | } 56 | 57 | else 58 | cout << "NO\n"; 59 | } 60 | 61 | int main() 62 | { 63 | ios_base::sync_with_stdio(false); 64 | cin.tie(NULL); 65 | cout.tie(NULL); 66 | 67 | test 68 | { 69 | solve(); 70 | } 71 | 72 | return 0; 73 | } -------------------------------------------------------------------------------- /Chef_and_InfinitePlane.cpp: -------------------------------------------------------------------------------- 1 | 2 | //LINKS :: https://www.codechef.com/COOK131C/problems/CHFPLN 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | #define ll long long 11 | #define vi vector 12 | #define vll vector 13 | #define pb push_back 14 | #define mp make_pair 15 | #define loop1(n) for (ll i = 0; i < (n); i++) 16 | #define loop2(n) for (ll i = 1; i <= (n); i++) 17 | #define test \ 18 | ll t; \ 19 | cin >> t; \ 20 | while (t--) 21 | 22 | int main() 23 | { 24 | ios_base::sync_with_stdio(false); 25 | cin.tie(NULL); 26 | cout.tie(NULL); 27 | 28 | /* 29 | Suppose for 5 : (n - 1) ways are there means 4 Unique ways 30 | ----------- 31 | (1 , 4) 32 | (2 , 3) 33 | (3 , 2) 34 | (4 . 1) 35 | 36 | Array : 2 2 4 4 2 6 37 | Frequency Array ==> 2 <- 3 max-unique = 1 (n - 1) 38 | 4 <- 2 max-unique = 3 39 | 6 <- 1 max-unique = 5 40 | 41 | */ 42 | 43 | test 44 | { 45 | ll n, i, count = 0; 46 | cin >> n; 47 | vector arr(n); 48 | map mp; 49 | for (i = 0; i < n; i++) 50 | { 51 | cin >> arr[i]; 52 | mp[arr[i]]++; // for the frequency array 53 | } 54 | 55 | for (i = 0; i < mp.size(); i++) 56 | { 57 | if (mp[i] != 0) 58 | { 59 | if (mp[i] >= i - 1) 60 | count = count + (i - 1); 61 | else 62 | count = count + mp[i]; 63 | } 64 | } 65 | 66 | cout << count << endl; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Fixed_number_of_Fixed_Points_IMPORTANT.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/START14C/problems/FIXFIX 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | test 35 | { 36 | ll n, k, i; 37 | cin >> n >> k; 38 | 39 | if ((k == n - 1) || (k > n)) 40 | cout << "-1\n"; 41 | 42 | else if (k == n) 43 | { 44 | for (i = 1; i <= n; i++) 45 | cout << i << " "; 46 | cout << "\n"; 47 | } 48 | 49 | else 50 | { 51 | for (i = 1; i <= k; i++) 52 | cout << i << " "; 53 | for (i = k + 2; i <= n; i++) // Shifted elements 54 | cout << i << " "; 55 | cout << k + 1 << endl; 56 | } 57 | } 58 | 59 | return 0; 60 | } 61 | 62 | /* 63 | INTUITION 64 | -------------------------- 65 | 66 | - Put k elements sequentially 67 | - Rest elements put one place shifted 68 | 69 | */ -------------------------------------------------------------------------------- /The_One_On_The_Last_Night.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/FOUR21C/problems/S06E06 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | /* 35 | METHOD - I First SORT the array then , INCREMENT arr[0] = arr[0] + 1 K times. 36 | 37 | METHOD - II We can take another Vector / Multiset and do the same but it will increase the time complexity. 38 | */ 39 | test 40 | { 41 | string s; 42 | cin >> s; 43 | ll k, i, product = 1; 44 | cin >> k; 45 | 46 | sort(s.begin(), s.end()); 47 | 48 | while (k--) // when digit NOT 9 49 | { 50 | if (s[0] == '9') 51 | continue; 52 | s[0] = s[0] + 1; 53 | sort(s.begin(), s.end()); 54 | } 55 | 56 | for (i = 0; i < s.size(); i++) 57 | product = product * (s[i] - '0'); // ASCII character '0' is 48. 58 | 59 | cout << product << endl; 60 | } 61 | 62 | return 0; 63 | } -------------------------------------------------------------------------------- /Longest_AND_Subarray.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ________________________________________ 3 | ---------------------------------------- 4 | Author : Niharika Dutta 5 | Code Link : https://www.codechef.com/OCT21C/problems/ANDSUBAR 6 | Time Complexity : 7 | ________________________________________ 8 | ---------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | 15 | #define ll long long 16 | #define lli long long int 17 | #define vi vector 18 | #define vll vector 19 | #define pb push_back 20 | #define mp make_pair 21 | #define loop1(n) for (ll i = 0; i < (n); i++) 22 | #define loop2(n) for (ll i = 1; i <= (n); i++) 23 | #define test \ 24 | ll t; \ 25 | cin >> t; \ 26 | while (t--) 27 | 28 | int main() 29 | { 30 | ios_base::sync_with_stdio(false); 31 | cin.tie(NULL); 32 | cout.tie(NULL); 33 | 34 | // . Find the length of the longest subarray in this sequence such that the bitwise AND of all elements in the subarray is positive. 35 | test 36 | { 37 | ll n, i, bitwiseAnd = 0, k = 1, maxlength = 0; 38 | cin >> n; 39 | 40 | // for (i = 1; i <= n; i++) 41 | // { 42 | // // bitwiseAnd = bitwiseAnd & arr[i]; 43 | // if (bitwiseAnd > 0) 44 | // k 2 < n= i + 1; 45 | 46 | if (n == 1) 47 | { 48 | cout << "1\n"; 49 | continue; 50 | } 51 | 52 | while (k * 2 <= n) // 2 ^ n 53 | k = k * 2; 54 | 55 | maxlength = n - k + 1; 56 | 57 | if (n == k) 58 | cout << n / 2 << endl; 59 | else 60 | cout << max(maxlength, k / 2) << endl; 61 | // } 62 | } 63 | 64 | return 0; 65 | } 66 | --------------------------------------------------------------------------------