├── 2016 ├── DEC.md └── DEC │ └── DEC16 │ ├── ANKTRAIN │ ├── ANKTRAIN.c │ └── ANKTRAIN.cpp │ ├── BASE │ ├── BASE.c │ └── BASE.cpp │ ├── KIRLAB │ └── KIRLAB.cpp │ ├── SEAINCR │ └── SEAINCR.cpp │ └── THREECOL │ └── THREECOL.cpp ├── 2017 ├── APR.md ├── APR │ ├── APRIL17 │ │ ├── CHEFDIV │ │ │ └── CHEFDIV.cpp │ │ ├── DGTCNT │ │ │ └── DGTCNT.py │ │ ├── DISHLIFE │ │ │ └── DISHLIFE.cpp │ │ ├── RNDGRID │ │ │ └── RNDGRID.py │ │ ├── ROWSOLD │ │ │ └── ROWSOLD.cpp │ │ ├── SIMDISH │ │ │ ├── SIMDISH.cpp │ │ │ └── SIMDISH.py │ │ └── SMARKET │ │ │ ├── SMARKET.cpp │ │ │ └── SMARKET.java │ ├── COOK81 │ │ ├── ABREPEAT │ │ │ └── ABREPEAT.cpp │ │ └── CANDY123 │ │ │ └── CANDY123.cpp │ └── LTIME47 │ │ ├── BEARSEG │ │ ├── BEARSEG.cpp │ │ └── BEARSEG.py │ │ └── SEGM01 │ │ └── SEGM01.CPP ├── AUG.md ├── AUG │ ├── AUG17 │ │ ├── GCAC │ │ │ └── GCAC.cpp │ │ ├── HILLJUMP │ │ │ └── HILLJUMP.cpp │ │ ├── PALINGAM │ │ │ └── PALINGAM.cpp │ │ └── RAINBOWA │ │ │ ├── RAINBOWA.cpp │ │ │ └── RAINBOWA.java │ ├── COOK85 │ │ ├── ELEVSTRS │ │ │ └── ELEVSTRS.cpp │ │ └── OBTTRNGL │ │ │ └── OBTTRNGL.cpp │ └── LTIME51 │ │ └── MATPAN │ │ └── MATPAN.cpp ├── FEB.md ├── FEB │ ├── COOK79 │ │ └── DWNLD │ │ │ └── DWNLD.cpp │ ├── FEB17 │ │ ├── CHEFAPAR │ │ │ └── CHEFAPAR.c │ │ ├── DISTNUM3 │ │ │ └── DISTNUM3.cpp │ │ ├── GERMANDE │ │ │ └── GERMANDE.c │ │ └── MFREQ │ │ │ └── MFREQ.c │ └── LTIME45 │ │ └── COOMILK │ │ └── COOMILK.cpp ├── JAN.md ├── JAN │ ├── COOK78 │ │ └── LISDIGIT │ │ │ └── LISDIGIT.cpp │ ├── JAN17 │ │ ├── CAPIMOVE │ │ │ ├── CAPIMOVE.c │ │ │ ├── CAPIMOVE.cpp │ │ │ └── CAPIMOVE.java │ │ ├── CATSDOGS │ │ │ ├── CATSDOGS.c │ │ │ └── CATSDOGS.cpp │ │ └── RESERVOI │ │ │ └── RESERVOI.cpp │ └── LTIME44 │ │ └── NOTINCOM │ │ └── NOTINCOM.cpp ├── JULY.md ├── JULY │ ├── JULY17 │ │ ├── CALC │ │ │ ├── CALC.c │ │ │ ├── CALC.cpp │ │ │ └── CALC.py │ │ ├── CHEFSIGN │ │ │ ├── CHEFSIGN.cpp │ │ │ └── CHEFSIGN.py │ │ ├── EXPTREE │ │ │ └── EXPTREE.py │ │ ├── IPCTRAIN │ │ │ └── IPCTRAIN.cpp │ │ └── NITIKA │ │ │ └── NITIKA.py │ └── LTIME50 │ │ ├── LOSTMAX │ │ └── LOSTMAX.py │ │ └── MAXOR.cpp ├── JUN.md ├── JUNE │ ├── COOK83 │ │ ├── ADACRA │ │ │ ├── ADACRA.cpp │ │ │ └── ADACRA.py │ │ └── SNACKUP │ │ │ └── SNACKUP.cpp │ ├── JUNE17 │ │ ├── CLONEME │ │ │ └── CLONEME.cpp │ │ ├── GOODSET │ │ │ ├── GOODSET.c │ │ │ ├── GOODSET.cpp │ │ │ └── GOODSET.py │ │ ├── NEO01 │ │ │ └── NEO01.cpp │ │ ├── PRMQ │ │ │ └── PRMQ.cpp │ │ ├── SUMQ │ │ │ ├── SUMQ.cpp │ │ │ └── SUMQ.py │ │ ├── UNIONSET │ │ │ ├── UNIONSET.cpp │ │ │ └── UNIONSET.py │ │ └── XENRANK │ │ │ ├── XENRANK.c │ │ │ └── XENRANK.cpp │ └── LTIME49 │ │ ├── MAXSEGM │ │ └── MAXSEGM.cpp │ │ └── TWONMS │ │ └── TWONMS.py ├── MAR.md ├── MAR │ ├── COOK80 │ │ ├── CARDS777 │ │ │ └── CARDS777.cpp │ │ └── ROBOTG │ │ │ └── ROBOTG.cpp │ ├── LTIME46 │ │ └── BRLADDER │ │ │ └── BRLADDER.cpp │ └── MARCH17 │ │ ├── BANDMATR │ │ └── BANDMATR.cpp │ │ ├── EXTRAN │ │ └── EXTRAN.cpp │ │ ├── SORTROW │ │ └── SORTROW.cpp │ │ └── XENTASK │ │ ├── XENTASK.c │ │ └── XENTASK.cpp ├── MAY.md ├── MAY │ ├── COOK82 │ │ ├── COOK82A │ │ │ ├── COOK82A.cpp │ │ │ └── COOK82A.py │ │ └── COOK82B │ │ │ └── COOK82B.cpp │ └── MAY17 │ │ ├── CHEFCODE │ │ ├── CHEFCODE.cpp │ │ ├── CHEFCODE.java │ │ └── CHEFCODE.py │ │ ├── CHEFROUT │ │ └── CHEFROUT.cpp │ │ ├── CHEFSUBA │ │ ├── CHEFSUBA.cpp │ │ └── CHEFSUBA.py │ │ ├── GPD │ │ └── GPD.cpp │ │ ├── MXMEDIAN │ │ └── MXMEDIAN.cpp │ │ ├── SANDWICH │ │ └── SANDWICH.cpp │ │ ├── UNICOURS │ │ └── UNICOURS.cpp │ │ └── WSITES01 │ │ ├── WSITES01.cpp │ │ └── WSITES01.py ├── OCT.md ├── SEPT.md └── SEPT │ ├── COOK86 │ ├── LIKECS01 │ │ └── LIKECS01.cpp │ ├── LIKECS02 │ │ └── LIKECS02.cpp │ └── LIKECS03 │ │ └── LIKECS03.cpp │ ├── LTIME52 │ └── C00K0FF │ │ └── C00K0FF.cpp │ └── SEPT17 │ ├── CHEFPDIG │ ├── CHEFPDIG.cpp │ └── CHEFPDIG.py │ ├── CHEFSUM │ ├── CHEFSUM.c │ ├── CHEFSUM.java │ └── CHEFSUM.py │ ├── FILLMTR │ └── FILLMTR.cpp │ ├── MINPERM │ ├── MINPERM.c │ ├── MINPERM.java │ └── MINPERM.py │ └── SEACO │ └── SEACO.cpp ├── .coafile ├── .codeclimate.yml ├── .editorconfig ├── .github ├── ADD_ME_IN_README.md ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── CNAME ├── CODE-OF-CONDUCT.md ├── CONTRIBUTING.md ├── README.md ├── _config.yml └── img ├── AC.png ├── CC.png ├── GH.png ├── RE.png ├── TLE.png └── WA.png /.coafile: -------------------------------------------------------------------------------- 1 | # For local fixing 2 | # coala --apply-patches -n 3 | 4 | # C/C++ Spacing 5 | [C/CPP Spacing] 6 | files = **/*.c, **/*.cpp 7 | bears = SpaceConsistencyBear 8 | use_spaces = False 9 | 10 | # Python lint 11 | [pep8] 12 | files = **/*.py 13 | bears = PEP8Bear 14 | 15 | -------------------------------------------------------------------------------- /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | engines: 3 | duplication: 4 | enabled: true 5 | checks: 6 | Similar code: 7 | enabled: false # matches in different files 8 | config: 9 | languages: 10 | - c 11 | - java 12 | fixme: 13 | enabled: true 14 | radon: 15 | enabled: true 16 | checks: 17 | Complexity: 18 | enabled: false 19 | ratings: 20 | paths: 21 | - "**.js" 22 | - "**.cpp" 23 | - "**.c" 24 | - "**.py" 25 | exclude_paths: [] 26 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | [*.{c,cpp}] 8 | charset = utf-8 9 | indent_style = tab 10 | tab_width = 4 11 | trim_trailing_whitespace = true 12 | 13 | [*.{py,java}] 14 | charset = utf-8 15 | indent_style = space 16 | indent_size = 4 17 | trim_trailing_whitespace = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.github/ADD_ME_IN_README.md: -------------------------------------------------------------------------------- 1 | The general format which can be used to add an entry to the monthwise README is: 2 | 3 | ``` 4 | [![image](../img/GH.png)](MONTH/EVENT_FOLDER/PROBLEM_FOLDER/FILE_NAME) [![image](../img/CC.png)](LINK_TO_YOUR_CODECHEF_SOLUTION) (POINTS_SCORED pts) [![image](../img/SELECT_STATUS).png)](#) 5 | ``` 6 | 7 | where, 8 | MONTH : Month in which the competition was held. 9 | EVENT_FOLDER : The Event code of the problem. 10 | PROBLEM_FOLDER : The Code of problem whose solution are you adding. 11 | FILE_NAME : The Name of the file of your solution. 12 | LINK_TO_YOUR_CODECHEF_SOLUTION : Your solution's link on codechef. 13 | POINTS_SCORED : Points you scored in that question. 14 | SELECT_STATUS : The status of your submission i.e. AC or WA or TLE. 15 | 16 | 17 | An example entry which is made in this repository is: 18 | 19 | ``` 20 | [![image](../img/GH.png)](DEC/DEC16/ANKTRAIN/ANKTRAIN.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12160847) (100 pts) [![image](../img/AC.png)](#) 21 | ``` 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | - [ ] Issue Title is in form `Problem Code (Contest Code) [Language]` 3 | - [ ] I ensure I'm Eligible as per [ECR](https://github.com/iiitv/ChefLib/blob/master/README.md#ecr). 4 | - [ ] I got AC for this problem when the contest was live. (Not necessary, but appreciable). 5 | - [ ] I have checked that my solution is passing on Problem (in case you make some changes). 6 | - [ ] I will send my PR only after I'm assigned to this issue by any maintainer. 7 | - [ ] I ensure that I'm not assigned to more than 2 issues. 8 | - [ ] Assign this issue to me (I want to work on this). 9 | 10 | ##### It's not necessary for all for points to be checked, we will look at what is required once you open an issue. 11 | 12 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Fixes #{ISSUE_NUMBER} 2 | 3 | - [ ] Pull Request Title is of form `Problem Code (Contest Code) [Language]`. 4 | - [ ] This problem already had an entry in this repository. 5 | - [ ] This solution is better than the one already in this repository. 6 | - [ ] This solution is prepared by me and not copied from anywhere else on the web. 7 | - [ ] I have added a __copyright comment__ in my solution. 8 | - [ ] I have updated README.md file (in appropriate order). 9 | - [ ] I have read and followed [Code Samples](https://github.com/iiitv/ChefLib/blob/master/CONTRIBUTING.md#samples). 10 | - [ ] I understand that pull request will be closed if I failed to update it even once in a week. 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.obj 3 | *.elf 4 | 5 | # Precompiled Headers 6 | *.gch 7 | *.pch 8 | 9 | # Libraries 10 | *.lib 11 | 12 | 13 | # Executables 14 | *.exe 15 | *.out 16 | *.orig 17 | *.class 18 | *.pyc 19 | *.html 20 | 21 | 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.6" 4 | env: 5 | GOPATH: $HOME/go 6 | PATH: $GOPATH/bin:$PATH 7 | 8 | install: 9 | - sudo apt-get update 10 | - pip install coala-bears 11 | - cd $TRAVIS_BUILD_DIR 12 | 13 | script: 14 | - coala --ci 15 | -------------------------------------------------------------------------------- /2016/DEC.md: -------------------------------------------------------------------------------- 1 | ## Index Of Dishes from December 2016 2 | 3 | #### All problems are open to contributions, but prefer working and improving solutions marked with [![image](../img/WA.png)](#) and [![image](../img/TLE.png)](#). Simply [Create an Issue](https://github.com/iiitv/ChefLib/issues/new) and Send a PR when assigned. 4 | 5 | ##### Here in this Table [![image](../img/CC.png)](#) links to solution on CodeChef and [![image](../img/GH.png)](#) links to solution on this repository. 6 | 7 | 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [DEC16](https://www.codechef.com/DEC16) | [ANKTRAIN](https://www.codechef.com/DEC16/problems/ANKTRAIN) | ★★ | [![image](../img/GH.png)](DEC/DEC16/ANKTRAIN/ANKTRAIN.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12160847) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](DEC/DEC16/ANKTRAIN/ANKTRAIN.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12161855) (100 pts) [![image](../img/AC.png)](#) | | | 13 | | [DEC16](https://www.codechef.com/DEC16) | [KIRLAB](https://www.codechef.com/DEC16/problems/KIRLAB/) | ★★ | | [![image](../img/GH.png)](DEC/DEC16/KIRLAB/KIRLAB.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12262686) (30 pts) [![image](../img/TLE.png)](#) | | | | 14 | | [DEC16](https://www.codechef.com/DEC16) | [BASE](https://www.codechef.com/DEC16/problems/BASE) | ★★★ | [![image](../img/GH.png)](DEC/DEC16/BASE/BASE.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12245322) (40 pts) [![image](../img/TLE.png)](#) | [![image](../img/GH.png)](DEC/DEC16/BASE/BASE.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12187429) (16 pts) [![image](../img/TLE.png)](#) | | | 15 | | [DEC16](https://www.codechef.com/DEC16) | [KTHMAX](https://www.codechef.com/DEC16/problems/KTHMAX) | ★★★★ | | | | | 16 | | [DEC16](https://www.codechef.com/DEC16) | [ALEXROSE](https://www.codechef.com/DEC16/problems/ALEXROSE) | ★★★★ | | | | | 17 | | [DEC16](https://www.codechef.com/DEC16) | [EDIT](https://www.codechef.com/DEC16/problems/EDIT) | ★★★★ | | | | | 18 | | [DEC16](https://www.codechef.com/DEC16) | [THREECOL](https://www.codechef.com/DEC16/problems/THREECOL) | ★★★★ | | [![image](../img/GH.png)](DEC/DEC16/THREECOL/THREECOL.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12206199) (12 pts) [![image](../img/WA.png)](#) | | | 19 | | [DEC16](https://www.codechef.com/DEC16) | [CHEFAFD](https://www.codechef.com/DEC16/problems/CHEFAFD) | ★★★★ | | | | | 20 | | [DEC16](https://www.codechef.com/DEC16) | [SEAINCR](https://www.codechef.com/DEC16/problems/SEAINCR) | ★★★★ | | [![image](../img/GH.png)](DEC/DEC16/SEAINCR/SEAINCR.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12223885) (30 pts) [![image](../img/TLE.png)](#) | | | 21 | | [DEC16](https://www.codechef.com/DEC16) | [BOUNCE](https://www.codechef.com/DEC16/problems/BOUNCE) | ★★★★★ | | | | | 22 | 23 | 24 | #### Cook-Off 25 | 26 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 27 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 28 | | [COOK77](https://www.codechef.com/COOK77) | [CHEFSETC](https://www.codechef.com/COOK77/problems/CHEFSETC) | ★★ | | | | | 29 | | [COOK77](https://www.codechef.com/COOK77) | [CHEFARRB](https://www.codechef.com/COOK77/problems/CHEFARRB) | ★★★ | | | | | 30 | | [COOK77](https://www.codechef.com/COOK77) | [CHEFINS](https://www.codechef.com/COOK77/problems/CHEFINS) | ★★★★ | | | | | 31 | | [COOK77](https://www.codechef.com/COOK77) | [CHEFNUMK](https://www.codechef.com/COOK77/problems/CHEFNUMK) | ★★★★★ | | | | | 32 | | [COOK77](https://www.codechef.com/COOK77) | [CHEFTRI4](https://www.codechef.com/COOK77/problems/CHEFTRI4) | ★★★★★ | | | | | 33 | 34 | 35 | #### Lunchtime 36 | 37 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 38 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 39 | | [LTIME43](https://www.codechef.com/LTIME43) | [SUPVIL](https://www.codechef.com/LTIME43/problems/SUPVIL) | ★★★ | | | | | 40 | | [LTIME43](https://www.codechef.com/LTIME43) | [FLYMODE](https://www.codechef.com/LTIME43/problems/FLYMODE) | ★★★★ | | | | | 41 | | [LTIME43](https://www.codechef.com/LTIME43) | [MSTQS](https://www.codechef.com/LTIME43/problems/MSTQS) | ★★★★★ | | | | | 42 | | [LTIME43](https://www.codechef.com/LTIME43) | [SBSWAP](https://www.codechef.com/LTIME43/problems/SBSWAP) | ★★★★★ | | | | | 43 | 44 | 45 | ## Eligible Contributors Rating 46 | 47 | ECR section in table above is for checking who are eligible for contributing to this Problem. 48 | This section will contain ★s which will represent CodeChef's ★ Rating. 49 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` 50 | -------------------------------------------------------------------------------- /2016/DEC/DEC16/ANKTRAIN/ANKTRAIN.c: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | // Use memcpy while copying array :D 6 | #include 7 | int main() 8 | { 9 | int t; 10 | scanf("%d",&t); 11 | while(t--) 12 | { 13 | int n; 14 | scanf("%d",&n); 15 | if(n%8==0) 16 | { 17 | printf("%dSL\n",n-1); 18 | } 19 | if(n%8==1) 20 | { 21 | printf("%dLB\n",n+3); 22 | } 23 | if(n%8==2) 24 | { 25 | printf("%dMB\n",n+3); 26 | } 27 | if(n%8==3) 28 | { 29 | printf("%dUB\n",n+3); 30 | } 31 | if(n%8==4) 32 | { 33 | printf("%dLB\n",n-3); 34 | } 35 | if(n%8==5) 36 | { 37 | printf("%dMB\n",n-3); 38 | } 39 | if(n%8==6) 40 | { 41 | printf("%dUB\n",n-3); 42 | } 43 | if(n%8==7) 44 | { 45 | printf("%dSU\n",n+1); 46 | } 47 | 48 | 49 | } 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /2016/DEC/DEC16/ANKTRAIN/ANKTRAIN.cpp: -------------------------------------------------------------------------------- 1 | // Code Written by Monal (cc handle: monalshadi) 2 | # include "bits/stdc++.h" 3 | 4 | using namespace std; 5 | 6 | void checknprint(int n, int orgn) { // This will check for the seat placing and its adjacent seat number 7 | switch(n) { 8 | case 1: 9 | cout << orgn+3 << "LB" << endl; 10 | break; 11 | case 2: 12 | cout << orgn+3 << "MB" << endl; 13 | break; 14 | case 3: 15 | cout << orgn+3 << "UB" << endl; 16 | break; 17 | case 4: 18 | cout << orgn-3 << "LB" << endl; 19 | break; 20 | case 5: 21 | cout << orgn-3 << "MB" << endl; 22 | break; 23 | case 6: 24 | cout << orgn-3 << "UB" << endl; 25 | break; 26 | case 7: 27 | cout << orgn+1 << "SU" << endl; 28 | break; 29 | case 8: 30 | cout << orgn-1 << "SL" << endl; 31 | break; 32 | case 0: 33 | cout<> tc; 42 | while(tc--) { 43 | int n; 44 | cin >> n; 45 | checknprint(n%8, n); 46 | } 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /2016/DEC/DEC16/BASE/BASE.c: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | // Use memcpy while copying array :D 6 | #include 7 | #include 8 | #include 9 | 10 | typedef long int BIG; 11 | 12 | 13 | int main() 14 | { 15 | int t; 16 | scanf("%ld",&t); 17 | while(t--) 18 | { 19 | BIG n,i,count=1,b; 20 | scanf("%ld",&n); 21 | if(n==0) 22 | { 23 | printf("%d\n",0); 24 | } 25 | else if(n==1) 26 | { 27 | printf("INFINITY\n"); 28 | } 29 | else if(n==2) 30 | { 31 | printf("1\n"); 32 | } 33 | 34 | else 35 | { 36 | for(i=3;i<=n;i++) 37 | { BIG t=n; 38 | while(t!=0) 39 | { 40 | t=t/i; 41 | if(t-i<0) 42 | { 43 | if(t==1) 44 | { 45 | count++; 46 | } 47 | break; //stops loop from running additionally 48 | } 49 | 50 | } 51 | 52 | } 53 | printf("%ld\n",count); 54 | } 55 | 56 | } 57 | 58 | return 0; 59 | } 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /2016/DEC/DEC16/BASE/BASE.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | // This solution is perfect but the only thing that this lacks is efficieny. Hence, failed on big test cases 3 | # include "bits/stdc++.h" 4 | 5 | # define ll long long int 6 | # define l long int 7 | 8 | using namespace std; 9 | 10 | bool checkBase(ll n, ll b) { // To check if the leading bit in bth base is 1 11 | int digit = 0 12 | 13 | while(n/b > 0) { 14 | n /= b 15 | } 16 | digit = n % b 17 | if(digit == 1) { 18 | return true 19 | } 20 | else { 21 | return false 22 | } 23 | } 24 | 25 | int main() { 26 | ios::sync_with_stdio(false); 27 | l tc; 28 | cin >> tc; 29 | while(tc--) { 30 | ll n; 31 | cin >> n; 32 | if(n == 1) { // trivial case 33 | cout << "INFINITY\n"; 34 | continue; 35 | } 36 | if(n == 0) { // trivial case 37 | cout << "0\n"; 38 | continue; 39 | } 40 | int counter = floor(n/2); 41 | for(ll i = 2; i <= sqrt(n); i++) { 42 | if(checkBase(n, i)) 43 | counter++; 44 | } 45 | if(n % 2 == 0) { 46 | counter--; 47 | } 48 | cout << counter+1 << endl; // as for any base greater than n we will have the same number as answer 49 | } 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /2016/DEC/DEC16/KIRLAB/KIRLAB.cpp: -------------------------------------------------------------------------------- 1 | //This solution is not the most efficient and hence failed with big test cases 2 | // Code Written by Monal (cc handle: monalshadi) 3 | # include "bits/stdc++.h" 4 | # include 5 | 6 | # define ll long long int 7 | # define l long int 8 | 9 | using namespace std; 10 | 11 | ll gcd(ll a, ll b) { // find gcd 12 | if (b == 0) 13 | return a; 14 | else 15 | gcd(b, a % b); 16 | } 17 | 18 | int main() { 19 | int tc 20 | scanf("%d", & tc) 21 | while (tc--) { 22 | l n, counter = 0 23 | 24 | scanf("%ld", & n) 25 | l arr[n] 26 | l size[n] 27 | for (l i=0; i < n; i++) { 28 | scanf("%ld", & arr[i]) 29 | size[i] = 0 30 | } 31 | 32 | for (l i=n-1; i > 0; i--) { 33 | l j = i-1 34 | while (j >= 0) { 35 | if(arr[i] == 1) 36 | break 37 | if(arr[j] != 1 & &gcd(arr[i], arr[j]) > 1 & &size[i]+1 > size[j]) { // we neglect 1's...check for gcd with element behind and also for their trail sizes 38 | size[j] = size[i]+1 39 | if(size[j] > counter) 40 | counter = size[j] 41 | } 42 | 43 | j--; 44 | } 45 | 46 | } 47 | printf("%ld\n", counter+1) 48 | // as we will always miss the one element 49 | } 50 | return 0 51 | } 52 | -------------------------------------------------------------------------------- /2016/DEC/DEC16/SEAINCR/SEAINCR.cpp: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | // Use memcpy while copying array :D 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | int BinSearch(vector &v, int l, int r, int h) { 13 | while (r-l > 1) { 14 | int m = l + (r-l)/2; 15 | if (v[m] >= h) 16 | r = m; 17 | else 18 | l = m; 19 | } 20 | return r; 21 | } 22 | 23 | int resfn(vector &x) { 24 | if (x.size() == 0) 25 | return 0; 26 | 27 | vector end(x.size(), 0); 28 | int length = 1; 29 | end[0] = x[0]; 30 | for (size_t i = 1; i < x.size(); i++) { 31 | if (x[i] < end[0]) 32 | end[0] = x[i]; 33 | 34 | else if (x[i] > end[length-1]) 35 | end[length++] = x[i]; 36 | 37 | else 38 | end[BinSearch(end, -1, length-1, x[i])] = x[i]; 39 | } 40 | 41 | return length; 42 | } 43 | 44 | 45 | int main() 46 | { 47 | std::ios::sync_with_stdio(false); //for making FASTER I/O. 48 | int t; 49 | cin >> t; 50 | while(t--) 51 | { 52 | int n,m; 53 | cin >> n >> m ; 54 | int i,j; 55 | vector v1(n); 56 | for(i=0;i> v1[i]; 59 | } 60 | 61 | while(m--) 62 | { 63 | int l,r; 64 | cin >> l >> r; 65 | std::vector newvec(r-l+1); 66 | copy(v1.begin()+l-1,v1.begin()+r,newvec.begin()); 67 | cout << resfn(newvec) << endl; 68 | } 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /2016/DEC/DEC16/THREECOL/THREECOL.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | //Program based on pure brute force and only working for n == 2 3 | # include 4 | 5 | using namespace std 6 | int main() { 7 | int n 8 | cin >> n 9 | cout << "5\n1 1 2 1\n2 1 2 2\n1 1 1 2\n1 1 2 1\n1 2 2 2" 10 | return 0 11 | } 12 | -------------------------------------------------------------------------------- /2017/APR.md: -------------------------------------------------------------------------------- 1 | ## Index Of Dishes from April 2017 2 | 3 | #### All problems are open to contributions, but prefer working and improving solutions marked with [![image](../img/WA.png)](#) and [![image](../img/TLE.png)](#). Simply [Create an Issue](https://github.com/iiitv/ChefLib/issues/new) and Send a PR when assigned. 4 | 5 | ##### Here in this Table [![image](../img/CC.png)](#) links to solution on CodeChef and [![image](../img/GH.png)](#) links to solution on this repository. 6 | 7 | 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [APRIL17](https://www.codechef.com/APRIL17) | [SIMDISH](https://www.codechef.com/APRIL17/problems/SIMDISH) | ★ | | [![image](../img/GH.png)](APR/APRIL17/SIMDISH/SIMDISH.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13218689) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](APR/APRIL17/SIMDISH/SIMDISH.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13214822) (100 pts) [![image](../img/AC.png)](#) | 13 | | [APRIL17](https://www.codechef.com/APRIL17) | [DISHLIFE](https://www.codechef.com/APRIL17/problems/DISHLIFE) | ★★ | | [![image](../img/GH.png)](APR/APRIL17/DISHLIFE/DISHLIFE.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13232008) (100 pts) [![image](../img/AC.png)](#) | | | 14 | | [APRIL17](https://www.codechef.com/APRIL17) | [ROWSOLD](https://www.codechef.com/APRIL17/problems/ROWSOLD) | ★★ | | [![image](../img/GH.png)](APR/APRIL17/ROWSOLD/ROWSOLD.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13284593) (100 pts) [![image](../img/AC.png)](#) | | | 15 | | [APRIL17](https://www.codechef.com/APRIL17) | [CLIQUED](https://www.codechef.com/APRIL17/problems/CLIQUED) | ★★★ | | | | | 16 | | [APRIL17](https://www.codechef.com/APRIL17) | [CHEFDIV](https://www.codechef.com/APRIL17/problems/CHEFDIV) | ★★★ | | [![image](../img/GH.png)](APR/APRIL17/CHEFDIV/CHEFDIV.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13340966) (100 pts) [![image](../img/AC.png)](#) | | | 17 | | [APRIL17](https://www.codechef.com/APRIL17) | [SMARKET](https://www.codechef.com/APRIL17/problems/SMARKET) | ★★★★ | | [![image](../img/GH.png)](APR/APRIL17/SMARKET/SMARKET.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13242167) (10 pts) [![image](../img/TLE.png)](#) | [![image](../img/GH.png)](APR/APRIL17/SMARKET/SMARKET.java) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13242308) (10 pts) [![image](../img/TLE.png)](#) | | 18 | | [APRIL17](https://www.codechef.com/APRIL17) | [RNDGRID](https://www.codechef.com/APRIL17/problems/RNDGRID) | ★★★★ | | | | [![image](../img/GH.png)](APR/APRIL17/DGTCNT/DGTCNT.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13341409) (45 pts) [![image](../img/TLE.png)](#) | 19 | | [APRIL17](https://www.codechef.com/APRIL17) | [DGTCNT](https://www.codechef.com/APRIL17/problems/DGTCNT) | ★★★★ | | | | [![image](../img/GH.png)](APR/APRIL17/DGTCNT/DGTCNT.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13279156) (25 pts) [![image](../img/TLE.png)](#) | 20 | | [APRIL17](https://www.codechef.com/APRIL17) | [SEABIL](https://www.codechef.com/APRIL17/problems/SEABIL) | ★★★★★ | | | | | 21 | | [APRIL17](https://www.codechef.com/APRIL17) | [HLD](https://www.codechef.com/APRIL17/problems/HLD) | ★★★★★ | | | | | 22 | 23 | 24 | #### Cook-Off 25 | 26 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 27 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 28 | | [COOK81](https://www.codechef.com/COOK81) | [CANDY123](https://www.codechef.com/COOK81/problems/CANDY123) | ★★ | | [![image](../img/GH.png)](APR/COOK81/CANDY123/CANDY123.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13377269) (100 pts) [![image](../img/AC.png)](#) | | | 29 | | [COOK81](https://www.codechef.com/COOK81) | [ABREPEAT](https://www.codechef.com/COOK81/problems/ABREPEAT) | ★★★ | | [![image](../img/GH.png)](APR/COOK81/ABREPEAT/ABREPEAT.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13380740) (100 pts) [![image](../img/AC.png)](#) | | | 30 | | [COOK81](https://www.codechef.com/COOK81) | [SHOPTRIP](https://www.codechef.com/COOK81/problems/SHOPTRIP) | ★★★★ | | | | | 31 | | [COOK81](https://www.codechef.com/COOK81) | [XORSUMS](https://www.codechef.com/COOK81/problems/XORSUMS) | ★★★★★ | | | | | 32 | | [COOK81](https://www.codechef.com/COOK81) | [BESTTRI](https://www.codechef.com/COOK81/problems/BESTTRI) | ★★★★★ | | | | | 33 | 34 | 35 | #### Lunchtime 36 | 37 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 38 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 39 | | [LTIME47](https://www.codechef.com/LTIME47) | [SEGM01](https://www.codechef.com/LTIME47/problems/SEGM01) | ★★ | | [![image](../img/GH.png)](APR/LTIME47/SEGM01/SEGM01.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13406492) (100 pts) [![image](../img/AC.png)](#) | | | 40 | | [LTIME47](https://www.codechef.com/LTIME47) | [BEARSEG](https://www.codechef.com/LTIME47/problems/BEARSEG) | ★★★★ | | [![image](../img/GH.png)](APR/LTIME47/BEARSEG/BEARSEG.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13408230) (50 pts) [![image](../img/TLE.png)](#) | | [![image](../img/GH.png)](APR/LTIME47/BEARSEG/BEARSEG.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13408694) (50 pts) [![image](../img/TLE.png)](#) | 41 | | [LTIME47](https://www.codechef.com/LTIME47) | [DIGVIRUS](https://www.codechef.com/LTIME47/problems/DIGVIRUS) | ★★★★★ | | | | | 42 | | [LTIME47](https://www.codechef.com/LTIME47) | [CLOSESTQ](https://www.codechef.com/LTIME47/problems/CLOSESTQ) | ★★★★★ | | | | | 43 | 44 | 45 | 46 | ## Eligible Contributors Rating 47 | 48 | ECR section in table above is for checking who are eligible for contributing to this Problem. 49 | This section will contain ★s which will represent CodeChef's ★ Rating. 50 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` 51 | -------------------------------------------------------------------------------- /2017/APR/APRIL17/CHEFDIV/CHEFDIV.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define ll long long int 8 | #define l long int 9 | #define maxi 1000000 10 | #define in(a,b) cin>>a>>b 11 | 12 | using namespace std; 13 | 14 | #define number_arr(a,b) for (ll i = 0; a + i <= b; ++i) { numbers[i] = a + i; } 15 | 16 | vector primes; 17 | bool primes_bool[maxi]; 18 | void sieve() { // Find primes 19 | fill(primes_bool, primes_bool + maxi, true); 20 | 21 | for(l i=2;iocc_arr[maxi]; 36 | void count_prime_for_number() { // Counts prime divisors for each number in range [a,b] 37 | for (ll i=0; i < primes.size(); ++i) { 38 | ll temp = a + (primes[i] - a % primes[i]) % primes[i]; 39 | ll start = temp - a; 40 | while (temp <= b) { 41 | if (a <= temp) { 42 | ll occ = 0; 43 | while (numbers[start] % primes[i] == 0) { 44 | occ++; 45 | numbers[start] /= primes[i]; 46 | } 47 | occ_arr[start].push_back(occ); 48 | } 49 | 50 | temp += primes[i]; 51 | start += primes[i]; 52 | } 53 | } 54 | 55 | } 56 | 57 | int main() { 58 | ios::sync_with_stdio(false); 59 | sieve(); 60 | in(a,b); 61 | number_arr(a,b); // storing numbers in array 62 | count_prime_for_number(); // checking for each prime to divide number in range [a,b] 63 | ll answer = 0; 64 | for (ll i = 0; i <= b - a; ++i) { // Clubbing up divisors for longest branch 65 | vector tmp = occ_arr[i]; 66 | if (numbers[i] != 1) { 67 | tmp.push_back(1); 68 | } 69 | if (tmp.size() != 0) { 70 | 71 | sort(tmp.begin(), tmp.end()); // sort decreasingly 72 | for (ll i = 0; i < tmp.size() / 2; ++i) { 73 | swap(tmp[i], tmp[tmp.size() - i - 1]); 74 | } 75 | 76 | while (tmp[0] > 0) { 77 | ll count_divi = 1; 78 | for (l j = 0; j < tmp.size(); ++j) { 79 | count_divi *= tmp[j] + 1; 80 | } 81 | tmp[0]--; 82 | answer += count_divi; 83 | 84 | sort(tmp.begin(), tmp.end()); // Sort decreasingly 85 | for (ll i = 0; i < tmp.size() / 2; ++i) { 86 | swap(tmp[i], tmp[tmp.size() - i - 1]); 87 | } 88 | 89 | } 90 | } 91 | } 92 | cout<= 10: 13 | passer = True 14 | occ = [0] * 10 15 | for digit in s: 16 | occ[int(digit)] += 1 17 | for digit in range(10): 18 | if occ[digit] == given[digit]: 19 | passer = False 20 | break 21 | if passer: 22 | count += 1 23 | else: 24 | for i in range(l, r+1, 1): 25 | passer = True 26 | occ = [0] * 10 27 | s = str(i) 28 | for digit in s: 29 | occ[int(digit)] += 1 30 | for digit in range(10): 31 | if occ[digit] == given[digit]: 32 | passer = False 33 | break 34 | if passer: 35 | count += 1 36 | print(count) 37 | 38 | 39 | if __name__ == '__main__': 40 | main() 41 | -------------------------------------------------------------------------------- /2017/APR/APRIL17/DISHLIFE/DISHLIFE.cpp: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | #define mod(x) x%1000000007; 11 | #define MIN(n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 12 | #define MAX(n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 13 | #define MID(s, e) (s+(e-s)/2) 14 | #define FOR(i, a, b) int i; for(i=(a);i<(b);i++) 15 | #define FORD(i, a, b) int i; for(i=(a);i>(b);i--) 16 | #define show(a) for(i=0;i>a[i]; 18 | #define scanint(a) scanf("%d",&a) 19 | #define scanLLD(a) scanf("%lld",&a) 20 | #define scanstr(s) scanf("%s",s) 21 | #define scanline(l) scanf(" %[^\n]",l); 22 | 23 | typedef long int BIG; 24 | typedef long long PAPA; 25 | 26 | int main() 27 | { 28 | std::ios_base::sync_with_stdio(false); 29 | int t, i, j; 30 | scanf("%d", &t); 31 | while(t--) { 32 | long int n, k; 33 | scanf("%ld %ld", &n, &k); 34 | bool check[k]; 35 | int count = 0, result = 0; 36 | memset(check, false, k); 37 | for(i = 0; i < n; i++) { 38 | long int p, x; 39 | scanf("%ld", &p); 40 | for(j = 0; j < p; j++) { 41 | scanf("%ld", &x); 42 | check[x-1] = true; 43 | } 44 | 45 | if(p==k) { 46 | count = k; 47 | } 48 | else if(result != 2 && i>=n-2) { 49 | count = 0; 50 | for(j = 0; j < k; j++) { 51 | if(check[j] == true ) { 52 | count++; 53 | //printf("%d ",j); 54 | } 55 | } 56 | } 57 | //printf("count = %d\n", count); 58 | if(count == k && i == n-2 ) result = 2; 59 | else if(count == k && result != 2) result = 3; 60 | } 61 | if(count < k) printf("sad\n"); 62 | else if(result == 2) printf("some\n"); 63 | else if(result == 3) printf("all\n"); 64 | } 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /2017/APR/APRIL17/RNDGRID/RNDGRID.py: -------------------------------------------------------------------------------- 1 | # Code written by Monal 2 | def main(): 3 | tc = int(input()) 4 | for _ in range(tc): 5 | l, n = map(int, input().split()) 6 | moves = input() 7 | matrix = [] 8 | for i in range(n): 9 | matrix.append(input()) 10 | answer = 0 11 | for i in range(n): 12 | for j in range(n): 13 | ci = i 14 | cj = j 15 | count = 0 16 | if matrix[i][j] == '.': 17 | for s in moves: 18 | if s == 'D': 19 | if ci + 1 == n: 20 | break 21 | elif matrix[ci + 1][cj] == '.': 22 | count += 1 23 | ci += 1 24 | else: 25 | break 26 | if s == 'U': 27 | if ci == 0: 28 | break 29 | elif matrix[ci - 1][cj] == '.': 30 | count += 1 31 | ci -= 1 32 | else: 33 | break 34 | if s == 'L': 35 | if cj == 0: 36 | break 37 | elif matrix[ci][cj - 1] == '.': 38 | count += 1 39 | cj -= 1 40 | else: 41 | break 42 | if s == 'R': 43 | if cj + 1 == n: 44 | break 45 | elif matrix[ci][cj + 1] == '.': 46 | count += 1 47 | cj += 1 48 | else: 49 | break 50 | if count == 0: 51 | pass 52 | else: 53 | if answer == 0: 54 | answer = count 55 | else: 56 | answer = answer ^ count 57 | print(answer) 58 | 59 | 60 | if __name__ == '__main__': 61 | main() 62 | -------------------------------------------------------------------------------- /2017/APR/APRIL17/ROWSOLD/ROWSOLD.cpp: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | #define mod(x) x%1000000007; 12 | #define MIN(n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 13 | #define MAX(n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 14 | #define MID(s, e) (s+(e-s)/2) 15 | #define FOR(i, a, b) int i; for(i=(a);i<(b);i++) 16 | #define FORD(i, a, b) int i; for(i=(a);i>(b);i--) 17 | #define show(a) for(i=0;i>a[i]; 19 | #define scanint(a) scanf("%d",&a) 20 | #define scanLLD(a) scanf("%lld",&a) 21 | #define scanstr(s) scanf("%s",s) 22 | #define scanline(l) scanf(" %[^\n]",l); 23 | 24 | typedef long int BIG; 25 | typedef long long PAPA; 26 | 27 | int main() 28 | { 29 | std::ios_base::sync_with_stdio(false); 30 | PAPA t; 31 | cin >> t; 32 | while(t--) { 33 | string str; 34 | cin >> str; 35 | PAPA one = 0, zero = 1, result = 0, i; 36 | PAPA size = str.size(); 37 | for (i = 0; i < size; i++) { 38 | if(str[i] == '1') { 39 | if(i == size - 1) { 40 | zero = 0; // reset the zero counter 41 | } 42 | i++; 43 | one ++; // one counter increment 44 | 45 | while(str[i] == '1') { 46 | if(i == size - 1){ 47 | zero = 0; // reset the zero counter 48 | } 49 | i++; 50 | one ++; // one counter increment 51 | } 52 | 53 | while(str[i] == '0') { 54 | zero++; 55 | i++; 56 | } 57 | --i; 58 | } 59 | result = result + one*zero; 60 | zero = 1; // reset zero count to 1 61 | } 62 | cout< 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | #define mod(x) x%1000000007; 12 | #define MIN( n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 13 | #define MAX( n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 14 | #define MID(s,e) (s+(e-s)/2) 15 | #define FOR(i,a,b) for(int i=(a);i<=(b);i++) 16 | #define FORD(i,a,b) for(int i=(a);i>=(b);i--) 17 | #define show(a) for(i=0;i>a[i]; 19 | #define p printf 20 | #define scanint(a) scanf("%d",&a) 21 | #define scanLLD(a) scanf("%lld",&a) 22 | #define scanstr(s) scanf("%s",s) 23 | #define scanline(l) scanf(" %[^\n]",l); 24 | 25 | typedef long int BIG; 26 | typedef long long PAPA; 27 | 28 | int main() 29 | { 30 | std::ios_base::sync_with_stdio(false); 31 | int t; 32 | scanint(t); 33 | while(t--) { 34 | int res = 0; 35 | char s11[200], s12[200], s13[200], s14[200], s21[200], s22[200], s23[200], s24[200]; 36 | cin >> s11 >> s12 >> s13 >> s14 >> s21 >> s22 >> s23 >> s24; 37 | if(strcmp(s11,s21)==0) res++; 38 | if(strcmp(s11,s22)==0) res++; 39 | if(strcmp(s11,s23)==0) res++; 40 | if(strcmp(s11,s24)==0) res++; 41 | if(strcmp(s12,s21)==0) res++; 42 | if(strcmp(s12,s22)==0) res++; 43 | if(strcmp(s12,s23)==0) res++; 44 | if(strcmp(s12,s24)==0) res++; 45 | if(strcmp(s13,s21)==0) res++; 46 | if(strcmp(s13,s22)==0) res++; 47 | if(strcmp(s13,s23)==0) res++; 48 | if(strcmp(s13,s24)==0) res++; 49 | if(strcmp(s14,s21)==0) res++; 50 | if(strcmp(s14,s23)==0) res++; 51 | if(strcmp(s14,s22)==0) res++; 52 | if(strcmp(s14,s24)==0) res++; 53 | if(res>=2) printf("similar\n"); 54 | else printf("dissimilar\n"); 55 | } 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /2017/APR/APRIL17/SIMDISH/SIMDISH.py: -------------------------------------------------------------------------------- 1 | # Code written by Monal 2 | t = int(input()) 3 | for _ in range(t): 4 | first = input().split() 5 | second = input().split() 6 | count = 0 7 | passer = False 8 | for i in first: 9 | if i in second: 10 | count += 1 11 | if 2 * count == len(first): 12 | print('similar') 13 | passer = True 14 | break 15 | if not passer: 16 | print('dissimilar') 17 | -------------------------------------------------------------------------------- /2017/APR/APRIL17/SMARKET/SMARKET.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include"bits/stdc++.h" 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int tc; 9 | scanf("%d",&tc); 10 | while (tc--) { 11 | int n,q; 12 | scanf("%ld %ld",&n,&q); 13 | vector arr(n); 14 | for (int i=0;iocc(n,0); 20 | for(int i=n-1;i>=0;i--) { 21 | count=1; 22 | while (arr[i]==prev && i>=0) { 23 | occ[i]=count; 24 | count++; 25 | i--; 26 | } 27 | prev=arr[i]; 28 | i++; 29 | } 30 | 31 | while (q--) { 32 | int l,r,k; 33 | long int answer=0; 34 | scanf("%d %d %d",&l,&r,&k); 35 | prev = arr[l-1]; 36 | for (int i=l-1;ir) { 41 | tmp = tmp - occ[r]; 42 | } 43 | if (tmp>=k) { 44 | answer++; 45 | i += (tmp-1); 46 | } 47 | } 48 | printf("%ld\n",answer); 49 | } 50 | } 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /2017/APR/APRIL17/SMARKET/SMARKET.java: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | import java.io.BufferedReader; 3 | import java.io.IOException; 4 | import java.io.InputStreamReader; 5 | import java.util.Scanner; 6 | import java.util.StringTokenizer; 7 | 8 | class Solution { 9 | static class FastReader 10 | { 11 | BufferedReader br; 12 | StringTokenizer st; 13 | 14 | public FastReader() { 15 | br = new BufferedReader(new 16 | InputStreamReader(System.in)); 17 | } 18 | 19 | int nextInt() { 20 | return Integer.parseInt(next()); 21 | } 22 | 23 | long nextLong() { 24 | return Long.parseLong(next()); 25 | } 26 | 27 | String next() { 28 | while (st == null || !st.hasMoreElements()) { 29 | try { 30 | st = new StringTokenizer(br.readLine()); 31 | } catch (IOException e) { 32 | e.printStackTrace(); 33 | } 34 | } 35 | return st.nextToken(); 36 | } 37 | 38 | } 39 | 40 | public static void main(String[] args) throws Exception { 41 | FastReader scan=new FastReader(); 42 | int tc=scan.nextInt(); 43 | while (tc--!=0) { 44 | int n=scan.nextInt(); 45 | int q=scan.nextInt(); 46 | long[] arr = new long[n]; 47 | 48 | for (int i=0;i=0;i--) { 55 | count=1; 56 | prev=arr[i]; 57 | while (arr[i]==prev) { 58 | occ[i]=count; 59 | count++; 60 | i--; 61 | if (i<0) 62 | break; 63 | } 64 | i++; 65 | } 66 | 67 | while (q--!=0) { 68 | int l=scan.nextInt(); 69 | int r=scan.nextInt(); 70 | int k=scan.nextInt(); 71 | long answer=0; 72 | prev = arr[l-1]; 73 | for (int i=l-1;ir) { 76 | tmp = tmp - occ[r]; 77 | } 78 | if (tmp>=k) { 79 | answer++; 80 | i += (tmp-1); 81 | } 82 | } 83 | System.out.println(answer); 84 | } 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /2017/APR/COOK81/ABREPEAT/ABREPEAT.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include "bits/stdc++.h" 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | ios::sync_with_stdio(false); 8 | int tc; 9 | cin>>tc; 10 | while (tc--) { 11 | long long int n,k; 12 | cin>>n>>k; 13 | string s; 14 | cin>>s; 15 | long long int aarr[n]; 16 | long long int barr[n]; 17 | memset(aarr,0,n); 18 | memset(barr,0,n); 19 | long long int answer = 0; 20 | long long int count=0; 21 | for (long long int i=0;i=0;--i) { 29 | if (s[i]=='b') 30 | count++; 31 | else if (s[i]=='a') 32 | aarr[i]=count; 33 | } 34 | for (long int i=0;i>tc; 10 | while (tc--) { 11 | int a,b; 12 | cin>>a>>b; 13 | int tmp1=1,tmp2=2; 14 | int chance = 0; 15 | while (1) { 16 | if (!chance) { 17 | if (a-tmp1<0) { 18 | cout<<"Bob\n"; 19 | break; 20 | } 21 | else { 22 | a -= tmp1; 23 | tmp1 += 2; 24 | } 25 | chance=1; 26 | } 27 | else { 28 | if (b-tmp2<0) { 29 | cout<<"Limak\n"; 30 | break; 31 | } 32 | else { 33 | b-=tmp2; 34 | tmp2 += 2; 35 | } 36 | chance=0; 37 | } 38 | } 39 | } 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /2017/APR/LTIME47/BEARSEG/BEARSEG.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include "bits/stdc++.h" 3 | 4 | using namespace std; 5 | 6 | #define ll long long int 7 | #define l long int 8 | 9 | 10 | void sum_of_subsequence(l n,ll P) { 11 | ll curr_sum; 12 | vector arr(n,0); 13 | for (l i = 0; i < n; ++i) { 14 | cin>>arr[i]; 15 | } 16 | ll max=0,occ=0; 17 | for (l i = 0; i < n; ++i) { 18 | curr_sum = 0; 19 | for (l j = i; j < n; ++j) { 20 | curr_sum = curr_sum + arr[j]; 21 | if (curr_sum % P > max) { 22 | max = curr_sum % P; 23 | occ=1; 24 | } 25 | else if (curr_sum % P == max) { 26 | occ++; 27 | } 28 | } 29 | } 30 | arr.clear(); 31 | cout<>tc; 38 | while (tc--) { 39 | l n; 40 | ll p; 41 | cin>>n>>p; 42 | sum_of_subsequence(n,p); 43 | } 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /2017/APR/LTIME47/BEARSEG/BEARSEG.py: -------------------------------------------------------------------------------- 1 | # Code written by Monal 2 | def sum_of_subsequences(n, p): 3 | arr = list(map(int, input().split())) 4 | maxi = 0 5 | occ = 0 6 | for i in range(n): 7 | curr_sum = 0 8 | for j in range(i, n): 9 | curr_sum = curr_sum + arr[j] 10 | if curr_sum % p > maxi: 11 | maxi = curr_sum % p 12 | occ = 1 13 | elif curr_sum % p == maxi: 14 | occ += 1 15 | print(maxi, occ) 16 | 17 | 18 | def main(): 19 | tc = int(input()) 20 | for _ in range(tc): 21 | n, p = map(int, input().split()) 22 | sum_of_subsequences(n, p) 23 | 24 | 25 | if __name__ == '__main__': 26 | main() 27 | -------------------------------------------------------------------------------- /2017/APR/LTIME47/SEGM01/SEGM01.CPP: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include "bits/stdc++.h" 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | ios::sync_with_stdio(false); 8 | int tc; 9 | cin>>tc; 10 | while (tc--) { 11 | string s; 12 | cin>>s; 13 | vector occ; 14 | int nocc; 15 | for (int i=0;i 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [AUG17](https://www.codechef.com/AUG17) | [RAINBOWA](https://www.codechef.com/AUG17/problems/RAINBOWA) | ★★ | | [![image](../img/GH.png)](AUG/AUG17/RAINBOWA/RAINBOWA.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14909134) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](AUG/AUG17/RAINBOWA/RAINBOWA.java) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14859923) (100 pts) [![image](../img/AC.png)](#) | | 13 | | [AUG17](https://www.codechef.com/AUG17) | [CHEFMOVR](https://www.codechef.com/AUG17/problems/CHEFMOVR) | ★★ | | | | | 14 | | [AUG17](https://www.codechef.com/AUG17) | [GCAC](https://www.codechef.com/AUG17/problems/GCAC) | ★★★ | | [![image](../img/GH.png)](AUG/AUG17/GCAC/GCAC.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14947059) (100 pts) [![image](../img/AC.png)](#) | | | 15 | | [AUG17](https://www.codechef.com/AUG17) | [PALINGAM](https://www.codechef.com/AUG17/problems/PALINGAM) | ★★★ | | [![image](../img/GH.png)](AUG/AUG17/PALINGAM/PALINGAM.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14908284) (100 pts) [![image](../img/AC.png)](#) | | | 16 | | [AUG17](https://www.codechef.com/AUG17) | [CHEFFA](https://www.codechef.com/AUG17/problems/CHEFFA) | ★★★★ | | | | | 17 | | [AUG17](https://www.codechef.com/AUG17) | [STRINGRA](https://www.codechef.com/AUG17/problems/STRINGRA) | ★★★★ | | | | | 18 | | [AUG17](https://www.codechef.com/AUG17) | [MATDW](https://www.codechef.com/AUG17/problems/MATDW) | ★★★★ | | | | | 19 | | [AUG17](https://www.codechef.com/AUG17) | [HILLJUMP](https://www.codechef.com/AUG17/problems/HILLJUMP) | ★★★★★ | | [![image](../img/GH.png)](AUG/AUG17/HILLJUMP/HILLJUMP.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14996982) (100 pts) [![image](../img/AC.png)](#) | | | 20 | | [AUG17](https://www.codechef.com/AUG17) | [WALKBT](https://www.codechef.com/AUG17/problems/WALKBT) | ★★★★★ | | | | | 21 | | [AUG17](https://www.codechef.com/AUG17) | [FLOWERPO](https://www.codechef.com/AUG17/problems/FLOWERPO) | ★★★★★ | | | | | 22 | 23 | 24 | #### Cook-Off 25 | 26 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 27 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 28 | | [COOK85](https://www.codechef.com/COOK85) | [ELEVSTRS](https://www.codechef.com/COOK85/problems/ELEVSTRS) | ★★ | | [![image](../img/GH.png)](AUG/COOK85/ELEVSTRS/ELEVSTRS.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15044633) (100 pts) [![image](../img/AC.png)](#) | | | 29 | | [COOK85](https://www.codechef.com/COOK85) | [OBTTRNGL](https://www.codechef.com/COOK85/problems/OBTTRNGL) | ★★★ | | [![image](../img/GH.png)](AUG/COOK85/OBTTRNGL/OBTTRNGL.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15051769) (100 pts) [![image](../img/AC.png)](#) | | | 30 | | [COOK85](https://www.codechef.com/COOK85) | [MTRXMOD](https://www.codechef.com/COOK85/problems/MTRXMOD) | ★★★★ | | | | | 31 | | [COOK85](https://www.codechef.com/COOK85) | [GAMSTICK](https://www.codechef.com/COOK85/problems/GAMSTICK) | ★★★★★ | | | | | 32 | | [COOK85](https://www.codechef.com/COOK85) | [TRCNTCT](https://www.codechef.com/COOK85/problems/TRCNTCT) | ★★★★★ | | | | | 33 | 34 | 35 | #### Lunchtime 36 | 37 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 38 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 39 | | [LTIME51](https://www.codechef.com/LTIME51) | [MATPAN](https://www.codechef.com/LTIME51/problems/MATPAN) | ★★ | | [![image](../img/GH.png)](AUG/LTIME51/MATPAN/MATPAN.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15119803) (100 pts) [![image](../img/AC.png)](#) | | | 40 | | [LTIME51](https://www.codechef.com/LTIME51) | [MATDYS](https://www.codechef.com/LTIME51/problems/MATDYS) | ★★★ | | | | | 41 | | [LTIME51](https://www.codechef.com/LTIME51) | [MATTEG](https://www.codechef.com/LTIME51/problems/MATTEG) | ★★★★★ | | | | | 42 | | [LTIME51](https://www.codechef.com/LTIME51) | [MATCUT](https://www.codechef.com/LTIME51/problems/MATCUT) | ★★★★★ | | | | | 43 | 44 | 45 | 46 | ## Eligible Contributors Rating 47 | 48 | ECR section in table above is for checking who are eligible for contributing to this Problem. 49 | This section will contain ★s which will represent CodeChef's ★ Rating. 50 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` 51 | -------------------------------------------------------------------------------- /2017/AUG/AUG17/GCAC/GCAC.cpp: -------------------------------------------------------------------------------- 1 | //Made by vanguard7 2 | 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | ios::sync_with_stdio(false); 8 | cin.tie(NULL); 9 | int t; 10 | cin >> t; 11 | while(t--) { 12 | int n, m, i, j; 13 | set s; 14 | cin >> n >> m; 15 | char x[m+1]; 16 | long long int minSalary[n], offeredSalary[m], maxJobOffered[m], cost = 0, jobs = 0, companies = m; 17 | for(i = 0; i < n; ++i) { 18 | cin >> minSalary[i]; 19 | } 20 | for(i = 0; i < m; ++i) { 21 | cin >> offeredSalary[i] >> maxJobOffered[i]; 22 | } 23 | for(i = 0; i < n; ++i) { 24 | int max = -1; 25 | vector v; 26 | cin >> x; 27 | for(j = 0; j < m; ++j) 28 | if(x[j] == '1') 29 | v.push_back(j); 30 | j = v.size(); 31 | if(v.size() != 0) { 32 | int maxsalary = -1; 33 | while(j--) { 34 | if(minSalary[i] <= offeredSalary[v[j]] && maxJobOffered[v[j]] > 0 && offeredSalary[v[j]] > maxsalary) { 35 | max = v[j]; 36 | maxsalary = offeredSalary[v[j]]; 37 | } 38 | } 39 | } 40 | if(max! =- 1) { 41 | cost += offeredSalary[max]; 42 | maxJobOffered[max]--; 43 | jobs++; 44 | s.insert(max); 45 | } 46 | } 47 | cout << jobs << " " << cost << " " << companies-s.size() << endl; 48 | } 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /2017/AUG/AUG17/HILLJUMP/HILLJUMP.cpp: -------------------------------------------------------------------------------- 1 | //Code Copyright: Manish Kumar, E&C 4th Year, IIT Roorkee 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | #define ll long long 8 | #define si(n) scanf("%d",&n) 9 | #define sll(n) scanf("%lld",&n) 10 | #define pin(n) printf("%d\n",n) 11 | #define plln(n) printf("%lld\n",n) 12 | #define pis(n) printf("%d ",n) 13 | #define plls(n) printf("%lld ",n) 14 | #define rep(i, start, end) for(int i = start; i 18 | #define PP pair 19 | #define mod 1000000007 20 | #define MAX 100005 21 | #define block 100 22 | #define newLine printf("\n") 23 | 24 | ll countt[1001][block]; 25 | ll last[1001][block]; 26 | ll Parent[1001][block]; 27 | 28 | ll n,q; 29 | ll arr[MAX]; 30 | ll lazy[1005]; 31 | void blockUpdate(ll blockNum){ 32 | int l = blockNum * 100; 33 | int r = min( (ll)l+99LL , n-1 ); 34 | stack< pair > S; 35 | while(r >= l){ 36 | ll curr = arr[r]+lazy[r/100]; 37 | while(!S.empty() && S.top().first <= curr){ 38 | S.pop(); 39 | } 40 | if(S.empty()){ 41 | countt[r/100][r%100] = 0; 42 | last[r/100][r%100] = r; 43 | } 44 | else{ 45 | pair temp=S.top(); 46 | countt[r/100][r%100] = countt[temp.second/100][temp.second%100]+1; 47 | last[r/100][r%100] = last[temp.second/100][temp.second%100]; 48 | } 49 | S.push({curr,r}); 50 | r--; 51 | } 52 | } 53 | int query(int index, int jump){ 54 | if(jump == 0) return index; 55 | int currBlock=index/100; 56 | int maxxJ=countt[currBlock][index%100]; 57 | if(maxxJ>=jump){ 58 | int currJump=0; 59 | int lastMax=index; 60 | ll lastValue=arr[index]+lazy[index/100]; 61 | for(int i = index+1; i <= last[currBlock][index%100]; i++){ 62 | if(currJump == jump) return lastMax; 63 | ll currVal=arr[i]+lazy[i/100]; 64 | if(currVal > lastValue){ 65 | currJump++; 66 | lastValue=currVal; 67 | lastMax=i; 68 | } 69 | } 70 | return lastMax; 71 | } 72 | else{ 73 | int finalInd=last[currBlock][index%100]; 74 | if(currBlock == ((n-1)/100) || Parent[currBlock][finalInd%100] == finalInd) return finalInd; 75 | if((Parent[currBlock][finalInd%100]-finalInd)>100){ 76 | return finalInd; 77 | } 78 | int x=jump-maxxJ-1; 79 | return query(Parent[currBlock][finalInd%100], x); 80 | } 81 | } 82 | void blockUpdate2(int blockNum){ 83 | if(blockNum<0 || blockNum == ((n-1)/100)) return; 84 | int j=(blockNum+1)*100; 85 | int la=j+100; 86 | int i = j-1; 87 | while(i>=(blockNum*100)){ 88 | if(last[i/100][i%100]!=i){ 89 | int qqq=last[i/100][i%100]; 90 | Parent[i/100][i%100] = Parent[qqq/100][qqq%100]; 91 | i--; 92 | continue; 93 | } 94 | while(j=((right/100)*100); i--) arr[i] += value; 109 | blockUpdate(right/100); 110 | blockUpdate(left/100); 111 | blockUpdate2(right/100); 112 | blockUpdate2((right/100)-1); 113 | blockUpdate2(left/100); 114 | blockUpdate2((left/100)-1); 115 | } 116 | else{ 117 | for(int i = left; i <= right; i++) arr[i] += value; 118 | blockUpdate(right/100); 119 | blockUpdate2(right/100); 120 | blockUpdate2((right/100)-1); 121 | } 122 | } 123 | void build(){ 124 | for(int i = 0; i <= ((n-1)/100); i++) blockUpdate(i); 125 | for(int i = 0; i <= ((n-1)/100); i++) blockUpdate2(i); 126 | } 127 | int main(){ 128 | sll(n); 129 | sll(q); 130 | rep(i,0,n) sll(arr[i]); 131 | build(); 132 | rep(qqqq,0,q){ 133 | int a; si(a); 134 | if(a == 1){ 135 | si(a); 136 | int k; 137 | si(k); 138 | a--; 139 | pin(1+query(a,k)); 140 | } 141 | else{ 142 | si(a); 143 | int b; 144 | ll c; 145 | si(b); 146 | sll(c); 147 | a--;b--; 148 | update(a, b, c); 149 | } 150 | } 151 | return 0; 152 | } 153 | -------------------------------------------------------------------------------- /2017/AUG/AUG17/PALINGAM/PALINGAM.cpp: -------------------------------------------------------------------------------- 1 | //Code Copyright: Sanskar Jain, Software Engineering 2nd Year, DTU 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | int main() { 10 | int t; 11 | cin>>t; 12 | while(t--){ 13 | map c,d; 14 | map::iterator it; 15 | string a,b; 16 | int e[26],f[26],g[501],h[501]; 17 | memset(e,0,sizeof(e)); 18 | memset(f,0,sizeof(f)); 19 | memset(g,0,sizeof(g)); 20 | memset(h,0,sizeof(h)); 21 | cin>>a>>b; 22 | if(a==b){ 23 | cout<<"B\n"; 24 | continue; 25 | } 26 | sort(a.begin(),a.end()); 27 | sort(b.begin(),b.end()); 28 | if(a==b){ 29 | cout<<"B\n"; 30 | continue; 31 | } 32 | for(int i=0;i(a[i],1)); 39 | } 40 | } 41 | for(int i=0;i(b[i],1)); 48 | } 49 | } 50 | for(int i=0;i<26;i++){ 51 | g[e[i]]++; 52 | h[f[i]]++; 53 | } 54 | char winner='B'; 55 | int flag=0; 56 | for (it=c.begin(); it!=c.end(); ++it){ 57 | if(it->second>=2&&d.find(it->first)==d.end()){ 58 | winner='A'; 59 | goto result; 60 | } 61 | } 62 | for (it=c.begin(); it!=c.end(); ++it){ 63 | if(d.find(it->first)==d.end()){ 64 | flag=1; 65 | } 66 | } 67 | if(flag==0){ 68 | winner='B'; 69 | goto result; 70 | } 71 | for(int i=0;i<26;i++){ 72 | if(f[i]==1&&e[i]==0){ 73 | winner='B'; 74 | goto result; 75 | } 76 | } 77 | flag=0; 78 | if(g[1]!=0){ 79 | for (it=d.begin(); it!=d.end(); ++it){ 80 | if(c.find(it->first)==c.end()){ 81 | flag=1; 82 | } 83 | } 84 | if(flag==0){ 85 | winner='A'; 86 | goto result; 87 | } 88 | } 89 | result: 90 | cout< 3 | using namespace std; 4 | 5 | int main() { 6 | int t; 7 | cin>>t; 8 | while(t--) { 9 | int n, i; 10 | cin>>n; 11 | int A[n], max=0, flag=0, B[10]={0}; 12 | for(i = 0; i>A[i]; 14 | if (max7) 22 | flag = 1; 23 | else { 24 | for(i=0;i<7;i++){ 25 | if(!B[i]) { 26 | flag=1; 27 | } 28 | } 29 | for(i=0; i 7) { 22 | flag = 1; 23 | } 24 | else 25 | reached[a-1] = true; 26 | if (!reached[6] && a != bef && a != bef + 1) { 27 | flag = 1; 28 | } 29 | req = req + a; 30 | bef = a; 31 | } 32 | flag1 = 0; 33 | for (int i = 0; i < 7; i++) { 34 | if (!reached[i]) { 35 | flag1 = 1; 36 | break; 37 | } 38 | } 39 | if (flag == 1 || flag1 == 1) { 40 | System.out.println("no"); 41 | } 42 | else { 43 | for (int i = 0; i < req.length() / 2; ++i) { 44 | if ( req.charAt(i) != req.charAt(req.length() - i - 1) ) { 45 | flag = 1; 46 | break; 47 | } 48 | } 49 | if (flag == 1) { 50 | System.out.println("no"); 51 | } 52 | else { 53 | System.out.println("yes"); 54 | } 55 | 56 | } 57 | } 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /2017/AUG/COOK85/ELEVSTRS/ELEVSTRS.cpp: -------------------------------------------------------------------------------- 1 | // Code by Piyush 2 | 3 | #include 4 | using namespace std; 5 | int main() { 6 | 7 | std::ios::sync_with_stdio(false); 8 | int testCases; 9 | cin >> testCases; 10 | double sr2 = sqrt(2); 11 | while(testCases--) { 12 | double n, v1, v2; 13 | cin >> n >> v1 >> v2; 14 | if((sr2 * n / v1) <= (2 * n / v2)) 15 | cout << "Stairs\n"; 16 | else 17 | cout << "Elevator\n"; 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /2017/AUG/COOK85/OBTTRNGL/OBTTRNGL.cpp: -------------------------------------------------------------------------------- 1 | // Code made by Monal5031/monalshadi 2 | #include "bits/stdc++.h" 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | ios::sync_with_stdio(false); 8 | cin.tie(NULL); 9 | cout.tie(NULL); 10 | 11 | long int tc; 12 | cin >> tc; 13 | while (tc--) { 14 | long long k, a, b; 15 | cin >> k >> a >> b; 16 | 17 | long long maxi = max(a, b); 18 | long long mini = min(a, b); 19 | 20 | if (maxi - mini == k/2 && k % 2 == 0) { 21 | cout << "0\n"; 22 | } else if (maxi - mini - 1 < k/2) { 23 | cout << (maxi - mini - 1) << "\n"; 24 | } else { 25 | cout << (k - maxi + mini - 1) << "\n"; 26 | } 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2017/AUG/LTIME51/MATPAN/MATPAN.cpp: -------------------------------------------------------------------------------- 1 | //Made by vanguard7 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | int t; 7 | cin >> t; 8 | while(t--) { 9 | long long int prices[26], sum = 0; 10 | int freq[26]= {0}; 11 | string s; 12 | for (int i = 0; i < 26; ++i) { 13 | cin >> prices[i]; 14 | } 15 | cin >> s; 16 | for(int i = 0; i < s.length(); ++i) { 17 | ++freq[s[i] - 97]; 18 | } 19 | for(int i = 0; i < 26; ++i) { 20 | if (freq[i] == 0) { 21 | sum += prices[i]; 22 | } 23 | } 24 | cout << sum << endl; 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /2017/FEB.md: -------------------------------------------------------------------------------- 1 | ## Index Of Dishes from February 2017 2 | 3 | #### All problems are open to contributions, but prefer working and improving solutions marked with [![image](../img/WA.png)](#) and [![image](../img/TLE.png)](#). Simply [Create an Issue](https://github.com/iiitv/ChefLib/issues/new) and Send a PR when assigned. 4 | 5 | ##### Here in this Table [![image](../img/CC.png)](#) links to solution on CodeChef and [![image](../img/GH.png)](#) links to solution on this repository. 6 | 7 | 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [FEB17](https://www.codechef.com/FEB17) | [CHEFAPAR](https://www.codechef.com/FEB17/problems/CHEFAPAR) | ★ | [![image](../img/GH.png)](FEB/FEB17/CHEFAPAR/CHEFAPAR.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12705568) (100 pts) [![image](../img/AC.png)](#) | | | | 13 | | [FEB17](https://www.codechef.com/FEB17) | [MAKETRI](https://www.codechef.com/FEB17/problems/MAKETRI) | ★★ | | | | | 14 | | [FEB17](https://www.codechef.com/FEB17) | [GERMANDE](https://www.codechef.com/FEB17/problems/GERMANDE) | ★★ | [![image](../img/GH.png)](FEB/FEB17/GERMANDE/GERMANDE.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12892020) (30 pts) [![image](../img/TLE.png)](#) | | | | 15 | | [FEB17](https://www.codechef.com/FEB17) | [MFREQ](https://www.codechef.com/FEB17/problems/MFREQ) | ★★ | [![image](../img/GH.png)](FEB/FEB17/MFREQ/MFREQ.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12840138) (40 pts) [![image](../img/WA.png)](#) | | | | 16 | | [FEB17](https://www.codechef.com/FEB17) | [KBIGNUMB](https://www.codechef.com/FEB17/problems/KBIGNUMB) | ★★★ | | | | | 17 | | [FEB17](https://www.codechef.com/FEB17) | [INTERVAL](https://www.codechef.com/FEB17/problems/INTERVAL) | ★★★ | | | | | 18 | | [FEB17](https://www.codechef.com/FEB17) | [CHEFYODA](https://www.codechef.com/FEB17/problems/CHEFYODA) | ★★★★ | | | | | 19 | | [FEB17](https://www.codechef.com/FEB17) | [CHEFBEST](https://www.codechef.com/FEB17/problems/CHEFBEST) | ★★★★ | | | | | 20 | | [FEB17](https://www.codechef.com/FEB17) | [ALICGARD](https://www.codechef.com/FEB17/problems/ALICGARD) | ★★★★ | | | | | 21 | | [FEB17](https://www.codechef.com/FEB17) | [DISTNUM3](https://www.codechef.com/FEB17/problems/DISTNUM3) | ★★★★★ | | [![image](../img/GH.png)](FEB/FEB17/DISTNUM3/DISTNUM3.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12870071) (100 pts) [![image](../img/AC.png)](#) | | | 22 | | [FEB17](https://www.codechef.com/FEB17) | [SEAINVS](https://www.codechef.com/FEB17/problems/SEAINVS) | ★★★★★ | | | | | 23 | | [FEB17](https://www.codechef.com/FEB17) | [JAKKU](https://www.codechef.com/FEB17/problems/JAKKU) | ★★★★★ | | | | | 24 | 25 | 26 | #### Cook-Off 27 | 28 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 29 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 30 | | [COOK79](https://www.codechef.com/COOK79) | [DWNLD](https://www.codechef.com/COOK79/problems/DWNLD) | ★★★ | | [![image](../img/GH.png)](FEB/COOK79/DWNLD/DWNLD.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12895343) (100 pts) [![image](../img/AC.png)](#) | | | 31 | | [COOK79](https://www.codechef.com/COOK79) | [CHAIRS](https://www.codechef.com/COOK79/problems/CHAIRS) | ★★★★ | | | | | 32 | | [COOK79](https://www.codechef.com/COOK79) | [COOKGAME](https://www.codechef.com/COOK79/problems/COOKGAME) | ★★★★ | | | | | 33 | | [COOK79](https://www.codechef.com/COOK79) | [ADDMULT](https://www.codechef.com/COOK79/problems/ADDMULT) | ★★★★★ | | | | | 34 | | [COOK79](https://www.codechef.com/COOK79) | [MIXFLVOR](https://www.codechef.com/COOK79/problems/MIXFLVOR) | ★★★★★ | | | | | 35 | 36 | 37 | #### Lunchtime 38 | 39 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 40 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 41 | | [LTIME45](https://www.codechef.com/LTIME45) | [COOMILK](https://www.codechef.com/LTIME45/problems/COOMILK) | ★★★ | | [![image](../img/GH.png)](FEB/LTIME45/COOMILK/COOMILK.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15267617) (100 pts) [![image](../img/AC.png)](#) | | | 42 | | [LTIME45](https://www.codechef.com/LTIME45) | [QHOUSE](https://www.codechef.com/LTIME45/problems/QHOUSE) | ★★★★ | | | | | 43 | | [LTIME45](https://www.codechef.com/LTIME45) | [BRIBETR](https://www.codechef.com/LTIME45/problems/BRIBETR) | ★★★★★ | | | | | 44 | | [LTIME45](https://www.codechef.com/LTIME45) | [OVERPNT](https://www.codechef.com/LTIME45/problems/OVERPNT) | ★★★★★ | | | | | 45 | 46 | 47 | 48 | ## Eligible Contributors Rating 49 | 50 | ECR section in table above is for checking who are eligible for contributing to this Problem. 51 | This section will contain ★s which will represent CodeChef's ★ Rating. 52 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` 53 | -------------------------------------------------------------------------------- /2017/FEB/COOK79/DWNLD/DWNLD.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include"bits/stdc++.h" 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int tc; 9 | scanf("%d",&tc); 10 | while(tc--) 11 | { 12 | int n,k; 13 | scanf("%d%d",&n,&k); 14 | int min[n]; 15 | int cost[n]; 16 | 17 | for(int i=0;i=0&&i 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | typedef long long int lli; 12 | typedef long int li; 13 | 14 | // Aashutosh Rathi 15 | // CodeChef February Long CHEFAPAR 16 | 17 | int main() 18 | { 19 | int t; 20 | scanf("%d",&t); 21 | while(t--) 22 | { 23 | li n; 24 | scanf("%ld",&n); 25 | li a[n],i,fine = 0,flag = 0,in,onec=0; 26 | for(i=0;i 3 | #define sz(a) int((a).size()) 4 | #define pb push_back 5 | #define eb emplace_back 6 | #define mp make_pair 7 | #define mt make_tuple 8 | #define F first 9 | #define S second 10 | #define ld(a) while(a--) 11 | #define tci(v, i) for(auto i = v.begin();i! = v.end();i++) 12 | #define tcf(v, i) for(auto i : v) 13 | #define all(v) v.begin(),v.end() 14 | #define rep(i, start, lim) for(int (i) = (start);i < (lim);i++) 15 | #define repd(i, start, lim) for(long long (i) = (start);i >= (lim);i--) 16 | #define present(c, x) (find(all(c), x) != (c).end()) 17 | #define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) 18 | #define osit ostream_iterator 19 | #define endl '\n' 20 | #ifdef WIN32 21 | #define getchar_unlocked getchar_unlocked 22 | #endif 23 | #define gc getchar 24 | #define N 1000006 25 | using namespace std; 26 | typedef vector vi; 27 | typedef vector vvi; 28 | typedef long long int ll; 29 | typedef vector vll; 30 | typedef vector vvll; 31 | typedef long double ld; 32 | typedef pair ii; 33 | typedef vector vii; 34 | typedef vector vvii; 35 | typedef tuple iii; 36 | typedef set si; 37 | typedef complex pnt; 38 | typedef vector vpnt; 39 | typedef priority_queue > spq; 40 | const ll MOD=1000000007LL; 41 | templatevoid read(T &x) { register T c = gc(); x = 0; int t = 0; if (c == '-') t = 1, c = gc(); for (; (c < 48 || c>57); c = gc()); for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; }if (t) x = -x; } 42 | int vis[N], col[N], bg[N], ed[N], id[N], st[17][N], par[N], level[N], ctemp[N], gct, res, ans[N], siz; 43 | int val[N]; 44 | vi g[N]; 45 | int last[N], maxn=0; 46 | unordered_map conv; 47 | struct node{ 48 | int l, r, i, lc, t = 0; 49 | }q[N]; 50 | bool cmp(node& a,node& b){ 51 | return a.l / siz==b.l / siz?(a.r / siz==b.r / siz?(a.t= 0;i--){ 85 | if(st[i][u] != -1 && st[i][u] != st[i][v]){ 86 | u = st[i][u]; 87 | v = st[i][v]; 88 | } 89 | } 90 | return par[u]; 91 | } 92 | inline void check(int& u){ 93 | if(vis[u] && (--val[col[u]]) == 0) --res; 94 | else if(!vis[u] && (val[col[u]]++) == 0) ++res; 95 | vis[u] ^= 1; 96 | } 97 | inline void change(int& u, int& c){ 98 | if(vis[u]){ 99 | check(u); col[u] = c; check(u); 100 | } 101 | else col[u] = c; 102 | } 103 | int main(){ 104 | conv.reserve(1024); conv.max_load_factor(0.25); 105 | int n, m, u, v; read(n); read(m); 106 | rep(i, 0, n) read(col[i]), ctemp[i] = col[i], last[i] = col[i]; 107 | rep(i, 0, n-1){ 108 | read(u); read(v); --u; --v; g[u].eb(v); g[v].eb(u); 109 | } 110 | sort(ctemp, ctemp + n); 111 | int zz=unique(ctemp, ctemp+n) - ctemp, org; 112 | rep(i, 0, n) { 113 | org = col[i]; 114 | col[i] = (lower_bound(ctemp, ctemp+zz, col[i]) - ctemp) + 1; last[i] = col[i]; conv[org] = col[i]; 115 | maxn = max(maxn, col[i]); 116 | } 117 | rep(j, 0, 17) rep(i, 0, n) st[j][i] = -1; 118 | dfs(0, -1, 0); pre(n); 119 | int type, y, qct = 0, uct = 0, lc, mtemp; 120 | siz=max( (int)pow(n, (double)2.0/(double)3.0) + 1500, 1000); 121 | rep(i, 0, m){ 122 | read(type); 123 | if(type == 1){ 124 | read(u); read(v); --u; --v; 125 | if(bg[u] > bg[v]) swap(u, v); 126 | q[qct].i = qct; q[qct].r = bg[v]; lc = lca(u, v); q[qct].lc = lc; 127 | if(lc == u) q[qct].l = bg[u]; 128 | else q[qct].l = ed[u]; 129 | q[qct].t = uct; 130 | ++qct; 131 | } 132 | else{ 133 | read(u); read(y); --u; 134 | mtemp = conv[y]; 135 | if(!mtemp){ 136 | ++maxn; conv[y] = maxn; y = maxn; 137 | } 138 | else y = mtemp; 139 | up[uct].u = u; up[uct].prev = last[u]; up[uct].curr = y; last[u] = y; ++uct; 140 | } 141 | } 142 | sort(q, q + qct, cmp); 143 | int cl = q[0].l, cr = q[0].l - 1, now = 0, L, R, T; 144 | rep(i, 0, qct){ 145 | L = q[i].l,R = q[i].r,T = q[i].t; 146 | while(now T){ 150 | --now; change(up[now].u, up[now].prev); 151 | } 152 | while(cr < R){ 153 | ++cr; 154 | check(id[cr]); 155 | } 156 | while(cl > L){ 157 | --cl; 158 | check(id[cl]); 159 | } 160 | while(cl < L){ 161 | check(id[cl]); 162 | ++cl; 163 | } 164 | while(cr > R){ 165 | check(id[cr]); 166 | --cr; 167 | } 168 | int u = id[L], v = id[R], lc = q[i].lc; 169 | if(lc != u && lc != v) check(lc); 170 | ans[q[i].i] = res; 171 | if(lc != u && lc != v) check(lc); 172 | } 173 | rep(i, 0, qct) printf("%d\n", ans[i]); 174 | } 175 | -------------------------------------------------------------------------------- /2017/FEB/FEB17/GERMANDE/GERMANDE.c: -------------------------------------------------------------------------------- 1 | // Code written by Divyesh 2 | #include 3 | #include 4 | int main() { 5 | int t; 6 | scanf("%d",&t); 7 | while (t--) { 8 | int o1, o2; 9 | long int m, e; 10 | scanf("%d %d", &o1, &o2); 11 | int a[o1*o2 + 10]; 12 | int k, b, c, d=0, g, f=0, h, n=0, x=0; 13 | e = o1 * o2; 14 | k = o2; 15 | m = e; 16 | for (b = 0; b < o1 * o2; b++) { 17 | scanf("%d", &a[b]); 18 | } 19 | while (k--) { 20 | int p = 0; 21 | int j = 0; 22 | n = 0; 23 | x = 0; 24 | h = o1 * o2; 25 | for (g = f; h > 0; g++) { 26 | p++; 27 | j++; 28 | n = n + a[g % m]; 29 | if (j % o2 == 0 && n >= (o2 / 2) + 1) { 30 | x++; 31 | } 32 | if (p % o2 == 0) { 33 | n = 0; 34 | } 35 | h--; 36 | } 37 | f++; 38 | if (x >= ((o1/2) + 1)) { 39 | printf("1\n"); 40 | break; 41 | } 42 | if (k==0) { 43 | printf("0\n"); 44 | break; 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /2017/FEB/FEB17/MFREQ/MFREQ.c: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | #include 6 | #include 7 | #include 8 | // MFREQ CodeChef Feb 2017 Long 9 | typedef long long int lli; 10 | typedef long int li; 11 | 12 | int main() 13 | { 14 | li n,m; 15 | scanf("%ld %ld",&n,&m); 16 | lli a[n],i; 17 | for(i=0;i=k){ 47 | printf("%ld\n",a[mid]); 48 | } 49 | else if(count 4 | #define endl "\n" 5 | using namespace std; 6 | int main() { 7 | 8 | std::ios::sync_with_stdio(false); 9 | int testCases; 10 | cin >> testCases; 11 | while(testCases--) { 12 | int minutes; 13 | cin >> minutes; 14 | string arr[minutes]; 15 | for (int i = 0; i < minutes; i++) 16 | cin >> arr[i]; 17 | bool instructions = true; 18 | for (int i = 0; i < minutes; i++) { 19 | if (arr[i] == "cookie" && arr[i + 1] != "milk") { 20 | instructions = false; 21 | break; 22 | } 23 | } 24 | if (instructions) 25 | cout << "YES" << endl; 26 | else 27 | cout << "NO" << endl; 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /2017/JAN.md: -------------------------------------------------------------------------------- 1 | ## Index Of Dishes from January 2017 2 | 3 | #### All problems are open to contributions, but prefer working and improving solutions marked with [![image](../img/WA.png)](#) and [![image](../img/TLE.png)](#). Simply [Create an Issue](https://github.com/iiitv/ChefLib/issues/new) and Send a PR when assigned. 4 | 5 | ##### Here in this Table [![image](../img/CC.png)](#) links to solution on CodeChef and [![image](../img/GH.png)](#) links to solution on this repository. 6 | 7 | 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [JAN17](https://www.codechef.com/JAN17) | [CATSDOGS](https://www.codechef.com/JAN17/problems/CATSDOGS) | ★★ | [![image](../img/GH.png)](JAN/JAN17/CATSDOGS/CATSDOGS.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12414324) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](JAN/JAN17/CATSDOGS/CATSDOGS.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12414517) (100 pts) [![image](../img/AC.png)](#) | | | 13 | | [JAN17](https://www.codechef.com/JAN17) | [RESERVOI](https://www.codechef.com/JAN17/problems/RESERVOI) | ★★ | | [![image](../img/GH.png)](JAN/JAN17/RESERVOI/RESERVOI.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12473662) (100 pts) [![image](../img/AC.png)](#) | | | 14 | | [JAN17](https://www.codechef.com/JAN17) | [CAPIMOVE](https://www.codechef.com/JAN17/problems/CAPIMOVE/) | ★★★ | [![image](../img/GH.png)](JAN/JAN17/CAPIMOVE/CAPIMOVE.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12455090) (50 pts) ![image](../img/RE.png) | [![image](../img/GH.png)](JAN/JAN17/CAPIMOVE/CAPIMOVE.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12471815) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](JAN/JAN17/CAPIMOVE/CAPIMOVE.java) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12471815) (50 pts) ![image](../img/RE.png) | | 15 | | [JAN17](https://www.codechef.com/JAN17) | [TOURISTS](https://www.codechef.com/JAN17/problems/TOURISTS) | ★★★ | | | | | 16 | | [JAN17](https://www.codechef.com/JAN17) | [DIGITSEP](https://www.codechef.com/JAN17/problems/DIGITSEP) | ★★★★ | | | | | 17 | | [JAN17](https://www.codechef.com/JAN17) | [CHEFCIRC](https://www.codechef.com/JAN17/problems/CHEFCIRC) | ★★★★ | | | | | 18 | | [JAN17](https://www.codechef.com/JAN17) | [FOURSQ](https://www.codechef.com/JAN17/problems/FOURSQ) | ★★★★ | | | | | 19 | | [JAN17](https://www.codechef.com/JAN17) | [SEACIR](https://www.codechef.com/JAN17/problems/SEACIR) | ★★★★★ | | | | | 20 | | [JAN17](https://www.codechef.com/JAN17) | [SEABOX](https://www.codechef.com/JAN17/problems/SEABOX) | ★★★★★ | | | | | 21 | | [JAN17](https://www.codechef.com/JAN17) | [TUPLES](https://www.codechef.com/JAN17/problems/TUPLES) | ★★★★★ | | | | | 22 | 23 | 24 | #### Cook-Off 25 | 26 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 27 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 28 | | [COOK78](https://www.codechef.com/COOK78) | [LISDIGIT](https://www.codechef.com/COOK78/problems/LISDIGIT) | ★★★ | | [![image](../img/GH.png)](JAN/COOK78/LISDIGIT/LISDIGIT.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14538726) (100 pts) [![image](../img/AC.png)](#) | | | 29 | | [COOK78](https://www.codechef.com/COOK78) | [MTRNSFRM](https://www.codechef.com/COOK78/problems/MTRNSFRM) | ★★★★ | | | | | 30 | | [COOK78](https://www.codechef.com/COOK78) | [DIGITLIS](https://www.codechef.com/COOK78/problems/DIGITLIS) | ★★★★★ | | | | | 31 | | [COOK78](https://www.codechef.com/COOK78) | [XRGRD](https://www.codechef.com/COOK78/problems/XRGRD) | ★★★★★ | | | | | 32 | | [COOK78](https://www.codechef.com/COOK78) | [UNGAME](https://www.codechef.com/COOK78/problems/UNGAME) | ★★★★★ | | | | | 33 | 34 | 35 | #### Lunchtime 36 | 37 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 38 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 39 | | [LTIME44](https://www.codechef.com/LTIME44) | [NOTINCOM](https://www.codechef.com/LTIME44/problems/NOTINCOM) | ★★★ | | [![image](../img/GH.png)](JAN/LTIME44/NOTINCOM/NOTINCOM.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15324794) (100 pts) [![image](../img/AC.png)](#) | | | 40 | | [LTIME44](https://www.codechef.com/LTIME44) | [SEALUP](https://www.codechef.com/LTIME44/problems/SEALUP) | ★★★★ | | | | | 41 | | [LTIME44](https://www.codechef.com/LTIME44) | [SEGMENTQ](https://www.codechef.com/LTIME44/problems/SEGMENTQ) | ★★★★★ | | | | | 42 | | [LTIME44](https://www.codechef.com/LTIME44) | [IMPROVE](https://www.codechef.com/LTIME44/problems/IMPROVE) | ★★★★★ | | | | | 43 | 44 | 45 | 46 | ## Eligible Contributors Rating 47 | 48 | ECR section in table above is for checking who are eligible for contributing to this Problem. 49 | This section will contain ★s which will represent CodeChef's ★ Rating. 50 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` 51 | -------------------------------------------------------------------------------- /2017/JAN/COOK78/LISDIGIT/LISDIGIT.cpp: -------------------------------------------------------------------------------- 1 | // Code by Piyush 2 | #include 3 | #define endl "\n" 4 | using namespace std; 5 | 6 | int main() { 7 | 8 | std::ios::sync_with_stdio(false); 9 | int testCases; 10 | cin >> testCases; 11 | while (testCases--) { 12 | int n; 13 | cin >> n; 14 | int a[n]; 15 | for (int i = 0; i < n; i++) 16 | cin >> a[i]; 17 | for (int i = 0; i < n; i++) 18 | cout << a[i]; 19 | cout << endl; 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /2017/JAN/JAN17/CAPIMOVE/CAPIMOVE.c: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | typedef long long int lli; 12 | typedef long int li; 13 | #define mod(x) x%1000000007; 14 | #define MIN( n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 15 | #define MAX( n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 16 | 17 | 18 | int main() 19 | { 20 | int t; 21 | scanf("%d",&t); 22 | while(t--) 23 | { 24 | li n,i,j; 25 | scanf("%ld",&n); 26 | lli a[n]; 27 | for(i=0;i 3 | #include 4 | #define ll long long int 5 | #define li long int 6 | using namespace std; 7 | 8 | map > mapping; 9 | vector > pairs; //1st element will be population and 2nd is planet number 10 | 11 | int main() 12 | { 13 | int tc; 14 | scanf("%d",&tc); 15 | while(tc--) 16 | { 17 | int n; 18 | scanf("%d",&n); 19 | ll tmp; 20 | for(int i=1;i<=n;i++) 21 | { 22 | scanf("%lld",&tmp); 23 | pairs.push_back(make_pair(tmp,i)); //pairing population with planet number 24 | } 25 | int tmp1,tmp2; 26 | for(int i=1;i=1) 39 | { 40 | if(pairs[checkn-1].second==i+1) 41 | { 42 | checkn--; 43 | continue; 44 | } 45 | else if(find(mapping[i+1].begin(),mapping[i+1].end(),pairs[checkn-1].second)==mapping[i+1].end()) // checking if infected planet are not mapped and if its population is greater 46 | { 47 | printf("%d ",pairs[checkn-1].second);//2nd element of pair is number 48 | checker=1; 49 | break; 50 | } 51 | checkn--; 52 | } 53 | if(checker==0) 54 | printf("0 "); 55 | } 56 | printf("\n"); 57 | mapping.clear(); //clearing a memory a little 58 | pairs.clear(); 59 | } 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /2017/JAN/JAN17/CAPIMOVE/CAPIMOVE.java: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | import java.io.*; 3 | import java.util.*; 4 | class CapitalMovement 5 | { 6 | static class FastReader 7 | { 8 | BufferedReader br; 9 | StringTokenizer st; 10 | 11 | public FastReader() 12 | { 13 | br = new BufferedReader(new 14 | InputStreamReader(System.in)); 15 | } 16 | 17 | String next() 18 | { 19 | while (st == null || !st.hasMoreElements()) 20 | { 21 | try 22 | { 23 | st = new StringTokenizer(br.readLine()); 24 | } 25 | catch (IOException e) 26 | { 27 | e.printStackTrace(); 28 | } 29 | } 30 | return st.nextToken(); 31 | } 32 | 33 | int nextInt() 34 | { 35 | return Integer.parseInt(next()); 36 | } 37 | 38 | long nextLong() 39 | { 40 | return Long.parseLong(next()); 41 | } 42 | 43 | double nextDouble() 44 | { 45 | return Double.parseDouble(next()); 46 | } 47 | 48 | String nextLine() 49 | { 50 | String str = ""; 51 | try 52 | { 53 | str = br.readLine(); 54 | } 55 | catch (IOException e) 56 | { 57 | e.printStackTrace(); 58 | } 59 | return str; 60 | } 61 | } 62 | 63 | 64 | 65 | 66 | public static void main(String[] args)throws Exception 67 | { 68 | int tc; 69 | FastReader scan=new FastReader(); 70 | int n,tmp1,tmp2,ans; 71 | long max; 72 | tc=scan.nextInt(); 73 | HashMap map = new HashMap(); 74 | while(tc--!=0) 75 | { 76 | n=scan.nextInt(); 77 | long []popu=new long[n+1]; 78 | boolean[][] matrix=new boolean[n+1][n+1]; 79 | for(int i=1;imax) 104 | { 105 | ans=j; 106 | max=popu[j]; 107 | } 108 | } 109 | System.out.print(ans+" "); 110 | } 111 | System.out.println(""); 112 | map.clear(); 113 | matrix=null; 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /2017/JAN/JAN17/CATSDOGS/CATSDOGS.c: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | typedef long long int lli; 12 | typedef long int li; 13 | #define mod(x) x%1000000007; 14 | #define MIN( n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 15 | #define MAX( n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 16 | 17 | 18 | int main() 19 | { 20 | int t; 21 | scanf("%d",&t); 22 | while(t--) 23 | { 24 | lli c,d,l; 25 | scanf("%lld %lld %lld",&c,&d,&l); 26 | if(l%4!=0) 27 | { 28 | printf("no\n"); 29 | } 30 | else 31 | { 32 | if(l<(d)*4) 33 | printf("no\n"); 34 | else if(l>(c+d)*4) 35 | printf("no\n"); 36 | else if(d==0 && l(c+d)*4) 39 | printf("no\n"); 40 | else if(c>2*d && l<=d*4) 41 | printf("no\n"); 42 | else if(c>2*d && l<(d*4+(c-2*d)*4)) 43 | printf("no\n"); 44 | else 45 | printf("yes\n"); 46 | 47 | } 48 | } 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /2017/JAN/JAN17/CATSDOGS/CATSDOGS.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include"bits/stdc++.h" 3 | 4 | #define li long int 5 | #define ll long long int 6 | using namespace std; 7 | int main() 8 | { 9 | ios::sync_with_stdio(false); 10 | li tc; 11 | cin>>tc; 12 | while(tc--) 13 | { 14 | ll c,d,l; 15 | cin>>c>>d>>l; 16 | if(4*(c+d)==l) 17 | cout<<"yes\n"; 18 | else if(l%4!=0) 19 | cout<<"no\n"; 20 | else if(4*(c+d)=c) 30 | cout<<"yes\n"; 31 | else if(c>2*d) 32 | { 33 | c=c-2*d; 34 | if(l<4*d+c*4) 35 | cout<<"no\n"; 36 | else 37 | cout<<"yes\n"; 38 | } 39 | else 40 | cout<<"no\n"; 41 | } 42 | } 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /2017/JAN/JAN17/RESERVOI/RESERVOI.cpp: -------------------------------------------------------------------------------- 1 | // Code Written by Monal 2 | #include"bits/stdc++.h" 3 | #define ll long long int 4 | #define li long int 5 | using namespace std; 6 | int main() 7 | { 8 | ios::sync_with_stdio(false); 9 | int tc; 10 | cin>>tc; 11 | while(tc--) 12 | { 13 | int h,w; 14 | cin>>h>>w; 15 | char build[h+1][w+1]; 16 | for(int i=1;i<=h;i++) 17 | for(int j=1;j<=w;j++) 18 | cin>>build[i][j]; 19 | int checker=1; 20 | for(int i=1;i<=h;i++) 21 | for(int j=1;j<=w;j++) 22 | { 23 | if(build[i][j]=='W') 24 | { 25 | if(j==1||j==w||i==h) 26 | { 27 | checker=0; 28 | break; 29 | } 30 | else if(build[i][j-1]=='A'||build[i][j+1]=='A') 31 | { 32 | checker=0; 33 | break; 34 | } 35 | else if(build[i+1][j]=='A') 36 | { 37 | checker=0; 38 | break; 39 | } 40 | } 41 | else if(build[i][j]=='A') 42 | { 43 | if(i==1&&j==1&&build[i][j+1]=='W') 44 | { 45 | checker=0; 46 | break; 47 | } 48 | else if(i==1&&j==w&&build[i][j-1]=='W') 49 | { 50 | checker=0; 51 | break; 52 | } 53 | else if((j!=w&&build[i][j+1]=='W')||(j!=1&&build[i][j-1]=='W')) 54 | { 55 | checker=0; 56 | break; 57 | } 58 | else if(i!=1&&build[i-1][j]!='A') 59 | { 60 | checker=0; 61 | break; 62 | } 63 | } 64 | } 65 | if(checker==1) 66 | cout<<"yes\n"; 67 | else 68 | cout<<"no\n"; 69 | } 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /2017/JAN/LTIME44/NOTINCOM/NOTINCOM.cpp: -------------------------------------------------------------------------------- 1 | // Code by Piyush 2 | #include 3 | #define endl "\n" 4 | using namespace std; 5 | 6 | int main() { 7 | 8 | std::ios::sync_with_stdio(false); 9 | int testCases; 10 | cin >> testCases; 11 | while (testCases--) { 12 | int n, m; 13 | cin >> n >> m; 14 | vector collection(1e+6, 0); 15 | for (int i = 0; i < n + m; i++) { 16 | int temp; 17 | cin >> temp; 18 | ++collection[temp - 1]; 19 | } 20 | int common = 0; 21 | for (int i = 0; i < collection.size(); i++) { 22 | if (collection[i] > 1) 23 | common++; 24 | } 25 | cout << common << endl; 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /2017/JULY.md: -------------------------------------------------------------------------------- 1 | ## Index Of Dishes from July 2017 2 | 3 | #### All problems are open to contributions, but prefer working and improving solutions marked with [![image](../img/WA.png)](#) and [![image](../img/TLE.png)](#). Simply [Create an Issue](https://github.com/iiitv/ChefLib/issues/new) and Send a PR when assigned. 4 | 5 | ##### Here in this Table [![image](../img/CC.png)](#) links to solution on CodeChef and [![image](../img/GH.png)](#) links to solution on this repository. 6 | 7 | 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [JULY17](https://www.codechef.com/JULY17) | [NITIKA](https://www.codechef.com/JULY17/problems/NITIKA) | ★★ | | | | [![image](../img/GH.png)](JULY/JULY17/NITIKA/NITIKA.py)  [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14431696) (100 pts) [![image](../img/AC.png)](#) | 13 | | [JULY17](https://www.codechef.com/JULY17) | [CHEFSIGN](https://www.codechef.com/JULY17/problems/CHEFSIGN) | ★★ | | [![image](../img/GH.png)](JULY/JULY17/CHEFSIGN/CHEFSIGN.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14502863) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](JULY/JULY17/CHEFSIGN/CHEFSIGN.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14488195) (100 pts) [![image](../img/AC.png)](#) | 14 | | [JULY17](https://www.codechef.com/JULY17) | [CALC](https://www.codechef.com/JULY17/problems/CALC) | ★★★ | [![image](../img/GH.png)](JULY/JULY17/CALC/CALC.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14483078) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](JULY/JULY17/CALC/CALC.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14439041) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](JULY/JULY17/CALC/CALC.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14490655) (100 pts) [![image](../img/AC.png)](#) | 15 | | [JULY17](https://www.codechef.com/JULY17) | [IPCTRAIN](https://www.codechef.com/JULY17/problems/IPCTRAIN) | ★★★ | | [![image](../img/GH.png)](JULY/JULY17/IPCTRAIN/IPCTRAIN.cpp)  [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14431781) (100 pts) [![image](../img/AC.png)](#) | | | 16 | | [JULY17](https://www.codechef.com/JULY17) | [EXPTREE](https://www.codechef.com/JULY17/problems/EXPTREE) | ★★★★ | | | | [![image](../img/GH.png)](JULY/JULY17/EXPTREE/EXPTREE.py)  [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14541593) (100 pts) [![image](../img/AC.png)](#) | 17 | | [JULY17](https://www.codechef.com/JULY17) | [PSHTTR](https://www.codechef.com/JULY17/problems/PSHTTR) | ★★★★ | | | | | 18 | | [JULY17](https://www.codechef.com/JULY17) | [TWOCOINS](https://www.codechef.com/JULY17/problems/TWOCOINS) | ★★★★ | | | | | 19 | | [JULY17](https://www.codechef.com/JULY17) | [SRVRS](https://www.codechef.com/JULY17/problems/SRVRS) | ★★★★★ | | | | | 20 | | [JULY17](https://www.codechef.com/JULY17) | [MULDIG](https://www.codechef.com/JULY17/problems/MULDIG) | ★★★★★ | | | | | 21 | | [JULY17](https://www.codechef.com/JULY17) | [APRPS](https://www.codechef.com/JULY17/problems/APRPS) | ★★★★★ | | | | | 22 | 23 | 24 | #### Lunchtime 25 | 26 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 27 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 28 | | [LTIME50](https://www.codechef.com/LTIME50) | [LOSTMAX](https://www.codechef.com/LTIME50/problems/LOSTMAX) | ★★★ | | | | [![image](../img/GH.png)](JULY/LTIME50/LOSTMAX/LOSTMAX.py)  [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14717251) (100 pts) [![image](../img/AC.png)](#) | 29 | | [LTIME50](https://www.codechef.com/LTIME50) | [MAXOR](https://www.codechef.com/LTIME50/problems/MAXOR) | ★★★★ | | [![image](../img/GH.png)](JULY/LTIME50/MAXOR/MAXOR.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14721836) (20 pts) [![image](../img/TLE.png)](#) | | | 30 | | [LTIME50](https://www.codechef.com/LTIME50) | [DIVSET](https://www.codechef.com/LTIME50/problems/DIVSET) | ★★★★★ | | | | | 31 | | [LTIME50](https://www.codechef.com/LTIME50) | [TRAVELAL](https://www.codechef.com/LTIME50/problems/TRAVELAL) | ★★★★★ | | | | | 32 | 33 | 34 | 35 | ## Eligible Contributors Rating 36 | 37 | ECR section in table above is for checking who are eligible for contributing to this Problem. 38 | This section will contain ★s which will represent CodeChef's ★ Rating. 39 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` 40 | -------------------------------------------------------------------------------- /2017/JULY/JULY17/CALC/CALC.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { long long unsigned int Life,test,B,Ans,x,y; 6 | scanf("%llu",&test); 7 | while(test--){ 8 | Ans = 0; 9 | scanf("%llu%llu",&Life,&B); 10 | if(Life<=B){ 11 | printf("%llu\n",Ans); 12 | continue; 13 | } 14 | Life = Life-B; 15 | x = Life/(2*B); 16 | y = Life%(2*B); 17 | Ans = x*(x+1)*B; 18 | x++; 19 | Ans = Ans+ x*y; 20 | printf("%llu\n",Ans); 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /2017/JULY/JULY17/CALC/CALC.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Made by: 3 | ``` Monal Shadi `` 4 | Github: Monal5031 5 | Codechef: monalshadi 6 | */ 7 | 8 | #include "bits/stdc++.h" 9 | 10 | using namespace std; 11 | 12 | int main() { 13 | ios::sync_with_stdio(false); 14 | cin.tie(NULL); 15 | cout.tie(NULL); 16 | 17 | int tc; 18 | cin >> tc; 19 | while (tc--) { 20 | long long n, b; 21 | cin >> n >> b; 22 | if (n <= b) { 23 | cout << "0\n"; 24 | continue; 25 | } 26 | else if (b > n / 2) { 27 | cout << n % b << "\n"; 28 | continue; 29 | } 30 | unsigned long long a = n / b; 31 | unsigned long long t = a; 32 | a = ceil(a / 2.0); 33 | cout << (n - a*b) * (a) << "\n"; 34 | } 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /2017/JULY/JULY17/CALC/CALC.py: -------------------------------------------------------------------------------- 1 | # made by vanguard7 2 | 3 | from math import ceil 4 | 5 | 6 | def main(): 7 | t = int(input()) 8 | while t > 0: 9 | n, b = map(int, input().split()) 10 | a = ceil(float(n // b) / float(2)) 11 | temp = n - (a * b) 12 | maxm = temp * a 13 | print(maxm) 14 | t -= 1 15 | 16 | 17 | if __name__ == '__main__': 18 | main() 19 | -------------------------------------------------------------------------------- /2017/JULY/JULY17/CHEFSIGN/CHEFSIGN.cpp: -------------------------------------------------------------------------------- 1 | // Code by Piyush 2 | 3 | #include 4 | #define endl "\n" 5 | using namespace std; 6 | 7 | int main() { 8 | 9 | std::ios::sync_with_stdio(false); 10 | int testCases; 11 | cin >> testCases; 12 | while (testCases--) { 13 | string sign; 14 | cin >> sign; 15 | int l = 0, g = 0, temp1 = 0, temp2 = 0; 16 | for (int i = 0; i < sign.length(); i++) { 17 | if (sign[i] == '<') { 18 | temp1++; 19 | temp2 = 0; 20 | } 21 | else if (sign[i] == '>') { 22 | temp2++; 23 | temp1 = 0; 24 | } 25 | l = max(l, temp1); 26 | g = max(g, temp2); 27 | } 28 | cout << max(l, g) + 1 << endl; 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /2017/JULY/JULY17/CHEFSIGN/CHEFSIGN.py: -------------------------------------------------------------------------------- 1 | # made by DipanshKhandelwal 2 | # this is a python3 file 3 | 4 | 5 | def main(): 6 | N = int(input()) 7 | for _ in range(N): 8 | maxfreq = 0 9 | presentfreq = 0 10 | present = '=' 11 | string = input() 12 | for i in string: 13 | if i == '>' or i == '<': 14 | if i == present: 15 | presentfreq += 1 16 | else: 17 | present = i 18 | presentfreq = 1 19 | if presentfreq > maxfreq: 20 | maxfreq = presentfreq 21 | print(maxfreq+1) 22 | 23 | 24 | if __name__ == '__main__': 25 | main() 26 | -------------------------------------------------------------------------------- /2017/JULY/JULY17/EXPTREE/EXPTREE.py: -------------------------------------------------------------------------------- 1 | #__BY:sirjan13__ 2 | 3 | 4 | def gcd(n, m): 5 | if n == 0: 6 | return m 7 | return gcd(m % n, n) 8 | 9 | 10 | t1, t2 = 0, 0 11 | 12 | 13 | def egcd(a, b): 14 | x, y, u, v = 0, 1, 1, 0 15 | while a != 0: 16 | q, r = b//a, b % a 17 | m, n = x-u*q, y-v*q 18 | b, a, x, y, u, v = a, r, u, v, m, n 19 | gc = b 20 | return gc, x, y 21 | 22 | 23 | def mi(a, m): 24 | g = egcd(a, m) 25 | ans = (g[1] % m + m) % m 26 | return ans 27 | 28 | 29 | mod1 = 10**9+7 30 | mod2 = mod1 + 2 31 | for cppp in range(int(raw_input())): 32 | n = int(raw_input()) 33 | if n == 0: 34 | print "0 0" 35 | else: 36 | n1 = n 37 | n2 = n1-1 38 | tree = 2*n-3 39 | if (n1 & 1): 40 | (n2) = (n2)/2 41 | else: 42 | (n1) = (n1)/2 43 | f = gcd(n1, tree) 44 | n1 = n1//f 45 | tree = tree//f 46 | s = gcd(n2, tree) 47 | n2 = n2//s 48 | tree = tree//s 49 | ans1 = ((n1 % mod1)*(n2 % mod1)) % mod1 50 | ans1 = ans1 % mod1 51 | ans2 = ((n1 % mod2)*(n2 % mod2)) % mod2 52 | ans2 = ans2 % mod2 53 | i = mi(tree, mod1) 54 | j = mi(tree, mod2) 55 | a = ((ans1 % mod1)*(i % mod1)) % mod1 56 | b = ((ans2 % mod2)*(j % mod2)) % mod2 57 | print a, b 58 | -------------------------------------------------------------------------------- /2017/JULY/JULY17/IPCTRAIN/IPCTRAIN.cpp: -------------------------------------------------------------------------------- 1 | //Code by ista2000 / Istasis Mishra 2 | #include 3 | using namespace std; 4 | #define int long long int 5 | 6 | struct tr 7 | { 8 | int d, t, s; 9 | }; 10 | bool cmp(tr tr1, tr tr2) 11 | { 12 | return tr1.d < tr2.d; 13 | } 14 | 15 | const int mod = 1e9 + 7; 16 | #undef int 17 | int main() 18 | { 19 | #define int long long int 20 | 21 | ios_base::sync_with_stdio(0); 22 | cin.tie(0); 23 | cout.tie(0); 24 | 25 | int tc; 26 | cin>>tc; 27 | while(tc--) 28 | { 29 | int n, m; 30 | cin >> n >> m; 31 | vector v(n); 32 | for(int i = 0;i> v[i].d >> v[i].t >> v[i].s; 34 | sort(v.begin(), v.end(), cmp); 35 | priority_queue< pair > pq; 36 | int cnt = 0; 37 | for(int i = 0;i <= m;i++) 38 | { 39 | for(;cnt i) 42 | break; 43 | pq.push(make_pair(v[cnt].s, cnt)); 44 | cnt++; 45 | } 46 | if(pq.empty()) continue; 47 | auto pp = pq.top(); 48 | v[pp.second].t--; 49 | if(v[pp.second].t == 0) 50 | pq.pop(); 51 | } 52 | int anss = 0; 53 | for(int i = 0;i> tc; 19 | while (tc--) { 20 | int n; 21 | cin >> n; 22 | if (n == 1) { 23 | cout<<"0\n"; 24 | continue; 25 | } 26 | vector < int > arr(n); 27 | int ans = 0; 28 | int tmp = 0; 29 | for (int i = 0; i < n; ++i) { 30 | cin >> arr[i]; 31 | tmp = arr[i]; 32 | for (int j = 0; j < i; ++j) { 33 | if (tmp == 0 || arr[j] == 0) { 34 | ans++; 35 | } else if (tmp == 1) { 36 | if (arr[j] & 1) { 37 | ans++; 38 | } 39 | } else if (arr[j] == 1) { 40 | if (tmp & 1) { 41 | ans++; 42 | } 43 | } else if ((tmp | arr[j]) <= max(tmp, arr[j])) { 44 | ans++; 45 | } 46 | } 47 | } 48 | cout << ans << "\n"; 49 | } 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /2017/JUN.md: -------------------------------------------------------------------------------- 1 | ## Index Of Dishes from June 2017 2 | 3 | #### All problems are open to contributions, but prefer working and improving solutions marked with [![image](../img/WA.png)](#) and [![image](../img/TLE.png)](#). Simply [Create an Issue](https://github.com/iiitv/ChefLib/issues/new) and Send a PR when assigned. 4 | 5 | ##### Here in this Table [![image](../img/CC.png)](#) links to solution on CodeChef and [![image](../img/GH.png)](#) links to solution on this repository. 6 | 7 | 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [JUNE17](https://www.codechef.com/JUNE17) | [GOODSET](https://www.codechef.com/JUNE17/problems/GOODSET) | ★★ | [![image](../img/GH.png)](JUNE/JUNE17/GOODSET/GOODSET.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14053097) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](JUNE/JUNE17/GOODSET/GOODSET.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13990045) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](JUNE/JUNE17/GOODSET/GOODSET.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13983894) (100 pts) [![image](../img/AC.png)](#) | 13 | | [JUNE17](https://www.codechef.com/JUNE17) | [XENRANK](https://www.codechef.com/JUNE17/problems/XENRANK) | ★★ | [![image](../img/GH.png)](JUNE/JUNE17/XENRANK/XENRANK.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14067724) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](JUNE/JUNE17/XENRANK/XENRANK.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13995543) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](JUNE/JUNE17/XENRANK/XENRANK.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13986151) (100 pts) [![image](../img/AC.png)](#) | 14 | | [JUNE17](https://www.codechef.com/JUNE17) | [NEO01](https://www.codechef.com/JUNE17/problems/NEO01) | ★★★ | | [![image](../img/GH.png)](JUNE/JUNE17/NEO01/NEO01.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14083418) (100 pts) [![image](../img/AC.png)](#) | | | 15 | | [JUNE17](https://www.codechef.com/JUNE17) | [UNIONSET](https://www.codechef.com/JUNE17/problems/UNIONSET) | ★★★ | | [![image](../img/GH.png)](JUNE/JUNE17/UNIONSET/UNIONSET.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14043562) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](JUNE/JUNE17/UNIONSET/UNIONSET.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14042608) (40 pts) [![image](../img/TLE.png)](#) | 16 | | [JUNE17](https://www.codechef.com/JUNE17) | [SUMQ](https://www.codechef.com/JUNE17/problems/SUMQ) | ★★★ | | [![image](../img/GH.png)](JUNE/JUNE17/SUMQ/SUMQ.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14114749) (30 pts) [![image](../img/TLE.png)](#) | | [![image](../img/GH.png)](JUNE/JUNE17/SUMQ/SUMQ.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14058942) (30 pts) [![image](../img/TLE.png)](#) | 17 | | [JUNE17](https://www.codechef.com/JUNE17) | [PRMQ](https://www.codechef.com/JUNE17/problems/PRMQ) | ★★★★ | | [![image](../img/GH.png)](JUNE/JUNE17/PRMQ/PRMQ.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14084951) (10 pts) [![image](../img/TLE.png)](#) | | | 18 | | [JUNE17](https://www.codechef.com/JUNE17) | [SBTR](https://www.codechef.com/JUNE17/problems/SBTR) | ★★★★ | | | | | 19 | | [JUNE17](https://www.codechef.com/JUNE17) | [CLONEME](https://www.codechef.com/JUNE17/problems/CLONEME) | ★★★★ | | [![image](../img/GH.png)](JUNE/JUNE17/CLONEME/CLONEME.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14044326) (10 pts) [![image](../img/TLE.png)](#) | | | 20 | | [JUNE17](https://www.codechef.com/JUNE17) | [ES](https://www.codechef.com/JUNE17/problems/ES) | ★★★★★ | | | | | 21 | | [JUNE17](https://www.codechef.com/JUNE17) | [OAK](https://www.codechef.com/JUNE17/problems/OAK) | ★★★★★ | | | | | 22 | 23 | 24 | #### Cook-Off 25 | 26 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 27 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 28 | | [COOK83](https://www.codechef.com/COOK83) | [ADACRA](https://www.codechef.com/COOK83/problems/ADACRA) | ★★ | | [![image](../img/GH.png)](JUNE/COOK83/ADACRA/ADACRA.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14279136) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](JUNE/COOK83/ADACRA/ADACRA.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14278836) (100 pts) [![image](../img/AC.png)](#) | 29 | | [COOK83](https://www.codechef.com/COOK83) | [SNACKUP](https://www.codechef.com/COOK83/problems/SNACKUP) | ★★★ | | [![image](../img/GH.png)](JUNE/COOK83/SNACKUP/SNACKUP.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14281072) (100 pts) [![image](../img/AC.png)](#) | | | 30 | | [COOK83](https://www.codechef.com/COOK83) | [CENTREE](https://www.codechef.com/COOK83/problems/CENTREE) | ★★★★ | | | | | 31 | | [COOK83](https://www.codechef.com/COOK83) | [KNICOV](https://www.codechef.com/COOK83/problems/KNICOV) | ★★★★★ | | | | | 32 | | [COOK83](https://www.codechef.com/COOK83) | [ADADET](https://www.codechef.com/COOK83/problems/ADADET) | ★★★★★ | | | | | 33 | 34 | 35 | #### Lunchtime 36 | 37 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 38 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 39 | | [LTIME49](https://www.codechef.com/LTIME49) | [TWONMS](https://www.codechef.com/LTIME49/problems/TWONMS) | ★★ | | | | [![image](../img/GH.png)](JUNE/LTIME49/TWONMS/TWONMS.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14322647) (100 pts) [![image](../img/AC.png)](#) | 40 | | [LTIME49](https://www.codechef.com/LTIME49) | [MAXSEGM](https://www.codechef.com/LTIME49/problems/MAXSEGM) | ★★★ | | [![image](../img/GH.png)](JUNE/LTIME49/MAXSEGM/MAXSEGM.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14326828) (100 pts) [![image](../img/AC.png)](#) | | | 41 | | [LTIME49](https://www.codechef.com/LTIME49) | [COMPCLUB](https://www.codechef.com/LTIME49/problems/COMPCLUB) | ★★★★★ | | | | | 42 | | [LTIME49](https://www.codechef.com/LTIME49) | [SHDWCMP](https://www.codechef.com/LTIME49/problems/SHDWCMP) | ★★★★★ | | | | | 43 | -------------------------------------------------------------------------------- /2017/JUNE/COOK83/ADACRA/ADACRA.cpp: -------------------------------------------------------------------------------- 1 | // Code by Piyush 2 | 3 | #include 4 | #define endl "\n" 5 | using namespace std; 6 | 7 | int main() { 8 | 9 | std::ios::sync_with_stdio(false); 10 | int testCases; 11 | cin >> testCases; 12 | while (testCases--) { 13 | int up = 0, down = 0; 14 | string input; 15 | cin >> input; 16 | if (input[0] == 'U') 17 | up++; 18 | else 19 | down++; 20 | for (int i = 0; i < input.length(); i++) { 21 | if (input[i] == 'U' && input[i + 1] == 'D') 22 | down++; 23 | else if (input[i] == 'D' && input[i + 1] == 'U') 24 | up++; 25 | } 26 | cout << min(up, down) << endl; 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2017/JUNE/COOK83/ADACRA/ADACRA.py: -------------------------------------------------------------------------------- 1 | # code written by Monal 2 | def main(): 3 | tc = int(input()) 4 | for _ in range(tc): 5 | string = input() 6 | init = string[0] 7 | count_up = 0 8 | count_down = 0 9 | tmp = 0 10 | inc = False 11 | n = len(string) 12 | while tmp < n: 13 | while tmp < n and string[tmp] == 'U': 14 | tmp += 1 15 | inc = True 16 | if inc: 17 | count_up += 1 18 | inc = False 19 | while tmp < n and string[tmp] == 'D': 20 | tmp += 1 21 | inc = True 22 | if inc: 23 | count_down += 1 24 | print(min(count_down, count_up)) 25 | 26 | 27 | if __name__ == '__main__': 28 | main() 29 | -------------------------------------------------------------------------------- /2017/JUNE/COOK83/SNACKUP/SNACKUP.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include "bits/stdc++.h" 3 | 4 | using namespace std; 5 | 6 | 7 | void call_even(int n) { 8 | int j = 1; 9 | for (int i = 1; i <= n; i += 2) { 10 | cout<>tc; 44 | while (tc--) { 45 | int n; 46 | cin>>n; 47 | //vector init (n, false); 48 | //vector < vector > arr (n, vector (n, false)); 49 | cout<>tc; 11 | while (tc--) { 12 | long int n,q; 13 | cin>>n>>q; 14 | vector < long int > arr(n); 15 | for (int i = 0; i < n; ++i) 16 | cin>>arr[i]; 17 | while (q--) { 18 | long long int sum1 = 0, sum2 = 0; 19 | long int a, b, c, d; 20 | cin>>a>>b>>c>>d; 21 | bool passer = true; 22 | bool chance = true; 23 | long int copyn = b - a + 1; 24 | vector < long int > arr1(copyn); 25 | vector arr2(copyn); 26 | 27 | long int j = a - 1; 28 | 29 | for (long int i = 0; i < copyn; ++i, ++j) 30 | arr1[i] = arr[j]; 31 | sort(arr1.begin(), arr1.end()); 32 | 33 | j = c - 1; 34 | 35 | for (long int i = 0; i < copyn; ++i, ++j) 36 | arr2[i] = arr[j]; 37 | sort(arr2.begin(), arr2.end()); 38 | 39 | for (long int i = 0; i < copyn; ++i) { 40 | if (arr1[i] != arr2[i]) { 41 | if (chance) 42 | chance = false; 43 | else { 44 | passer = false; 45 | break; 46 | } 47 | } 48 | } 49 | if (passer) 50 | cout<<"YES\n"; 51 | else 52 | cout<<"NO\n"; 53 | } 54 | } 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /2017/JUNE/JUNE17/GOODSET/GOODSET.c: -------------------------------------------------------------------------------- 1 | /*This code is by Mohak Khare*/ 2 | #include < stdio.h > 3 | int main() { 4 | long T; 5 | scanf("%ld", & T); 6 | while (T--) { 7 | int n; 8 | scanf("%d", & n); 9 | int a[n], i; 10 | a[0] = 500; 11 | a[1] = 499; 12 | for (i = 2; i < n; i++) { 13 | a[i] = a[i - 1] - 1; 14 | } 15 | 16 | for (i = 0; i < n; i++) { 17 | printf("%d ", a[i]); 18 | } 19 | printf("\n"); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /2017/JUNE/JUNE17/GOODSET/GOODSET.cpp: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | // Use memcpy while copying array :D 6 | 7 | // Answer Stauts : AC (100 pts) 8 | 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | #define mod(x) x%1000000007; 15 | #define MIN(n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 16 | #define MAX(n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 17 | #define MID(s, e) (s+(e-s)/2) 18 | #define FOR(i, a, b) int i; for(i=(a);i<(b);i++) 19 | #define FORD(i, a, b) int i; for(i=(a);i>(b);i--) 20 | #define show(a) for(i=0;i>a[i]; 22 | #define scanint(a) scanf("%d",&a) 23 | #define scanLLD(a) scanf("%lld",&a) 24 | #define scanstr(s) scanf("%s",s) 25 | #define scanline(l) scanf(" %[^\n]",l); 26 | 27 | typedef long BIG; 28 | typedef unsigned long long PAPA; 29 | 30 | int main() { 31 | std::ios_base::sync_with_stdio(false); 32 | cin.tie(0); 33 | int t; 34 | cin >> t; 35 | while(t--) { 36 | int n, i; 37 | cin >> n; 38 | for(i=n;i<2*n;i++) { 39 | cout << i << " "; 40 | } 41 | cout << endl; 42 | } 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /2017/JUNE/JUNE17/GOODSET/GOODSET.py: -------------------------------------------------------------------------------- 1 | # code written by Monal 2 | import math 3 | 4 | 5 | def main(): 6 | tc = int(input()) 7 | primes = [1, 2, 5, 9, 13] 8 | appended = False 9 | for i in range(14, 501): 10 | appended = False 11 | for j in primes: 12 | for k in primes: 13 | if k != j: 14 | if i == j + k: 15 | appended = True 16 | break 17 | if not appended: 18 | primes.append(i) 19 | if len(primes) == 100: 20 | break 21 | for _ in range(tc): 22 | n = int(input()) 23 | tmp = [str(primes[x]) for x in range(n)] 24 | 25 | print(' '.join(tmp)) 26 | 27 | 28 | if __name__ == '__main__': 29 | main() 30 | -------------------------------------------------------------------------------- /2017/JUNE/JUNE17/NEO01/NEO01.cpp: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | // Use memcpy while copying array :D 6 | #include 7 | #include 8 | // Yaar use long long instead of long 9 | using namespace std; 10 | 11 | #define mod(x) x%1000000007; 12 | #define MIN(n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 13 | #define MAX(n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 14 | #define MID(s, e) (s+(e-s)/2) 15 | #define FOR(i, a, b) int i; for(i=(a);i<(b);i++) 16 | #define FORD(i, a, b) int i; for(i=(a);i>(b);i--) 17 | #define show(a) for(i=0;i>a[i]; 19 | #define scanint(a) scanf("%d",&a) 20 | #define scanLLD(a) scanf("%lld",&a) 21 | #define scanstr(s) scanf("%s",s) 22 | #define scanline(l) scanf(" %[^\n]",l); 23 | 24 | typedef long BIG; 25 | typedef long long PAPA; 26 | 27 | int main() { 28 | std::ios_base::sync_with_stdio(false); 29 | cin.tie(0); 30 | int t; 31 | cin >> t; 32 | while(t--) { 33 | BIG n ,i; 34 | cin >> n; 35 | std::vector v; 36 | PAPA a[n], sum = 0, positive = 0, positivec = 0, negative = 0, maxres = 0, negsum = 0, max1 = 0; 37 | for (i = 0; i < n; ++i) { 38 | cin >> a[i]; 39 | if(a[i]>=0) { 40 | positivec++; 41 | positive += a[i]; 42 | } 43 | else { 44 | v.push_back(-a[i]); 45 | negsum += -a[i]; 46 | } 47 | } 48 | 49 | //cout << "negsum: " << negsum << endl; 50 | 51 | sort(v.begin(), v.end()); 52 | std::vector maxy; 53 | 54 | //for(BIG x:v) 55 | // cout << x << " "; 56 | //cout << "negative : " << negative < get_factorization(long int num) { 30 | vector ret; 31 | while (num != 1) { 32 | ret.push_back(spf[num]); 33 | num = num / spf[num]; 34 | } 35 | return ret; 36 | } 37 | 38 | 39 | int main() { 40 | ios::sync_with_stdio(false); 41 | cin.tie(NULL); 42 | sieve(); 43 | long int n; 44 | cin>>n; 45 | long int arr[n]; 46 | for (int i = 0; i < n; ++i) 47 | cin>>arr[i]; 48 | //cout<<"done"<>q; 55 | while (q--) { 56 | long int l,r,x,y; 57 | cin>>l>>r>>x>>y; 58 | //cout<= l-1; --j) { 63 | //cout<<"yaha"< tmp = get_factorization(arr[j]); 65 | 66 | //for (int i = 0; i < tmp.size(); ++i) 67 | // cout< 3 | using namespace std; 4 | 5 | long long int mod(long long int a, long long int m) { 6 | return (a % m + m) % m; 7 | } 8 | 9 | int main() { 10 | int t; 11 | cin >> t; 12 | while (t--) { 13 | int p, q, r, i, j, k; 14 | cin >> p >> q >> r; 15 | long long int X[p], Y[q], val, sum = 0; 16 | vector < long long int > Z; 17 | vector < long long int > temp; 18 | for (i = 0; i < p; i++) { 19 | cin >> X[i]; 20 | } 21 | for (i = 0; i < q; i++) { 22 | cin >> Y[i]; 23 | } 24 | sort(Y, Y + q); 25 | for (i = 0; i < r; i++) { 26 | cin >> val; 27 | if (val <= Y[q - 1]) 28 | Z.push_back(val); 29 | } 30 | for (i = 0; i < p; i++) { 31 | if (X[i] <= Y[q - 1]) 32 | temp.push_back(X[i]); 33 | } 34 | sort(temp.begin(), temp.end()); 35 | sort(Z.begin(), Z.end()); 36 | for (j = 0; j < q; j++) { 37 | for (i = 0; i < temp.size(); i++) { 38 | for (k = 0; k < Z.size(); k++) { 39 | if (temp[i] <= Y[j] && Y[j] >= Z[k]) 40 | sum = sum + ((temp[i] + Y[j]) * (Y[j] + Z[k])) % 1000000007; 41 | } 42 | } 43 | } 44 | cout << mod(sum, 1000000007) << endl; 45 | } 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /2017/JUNE/JUNE17/SUMQ/SUMQ.py: -------------------------------------------------------------------------------- 1 | # code written by Monal 2 | def main(): 3 | tc = int(input()) 4 | for _ in range(tc): 5 | p, q, q = map(int, input().split()) 6 | a = tuple(map(int, input().split())) 7 | b = tuple(map(int, input().split())) 8 | c = tuple(map(int, input().split())) 9 | 10 | # print(a,b,c) 11 | answer = 0 12 | 13 | for y in b: 14 | for x in a: 15 | if x <= y: 16 | tmp = (x + y) 17 | # print(tmp) 18 | for z in c: 19 | if z <= y: 20 | # print(z) 21 | answer += (tmp * (y + z)) 22 | print(answer % 1000000007) 23 | 24 | 25 | if __name__ == '__main__': 26 | main() 27 | -------------------------------------------------------------------------------- /2017/JUNE/JUNE17/UNIONSET/UNIONSET.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include "bits/stdc++.h" 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | ios::sync_with_stdio(false); 8 | cin.tie(NULL); 9 | //int start = clock(); 10 | int tc; 11 | cin>>tc; 12 | while (tc--) { 13 | int n,k; 14 | cin>>n>>k; 15 | vector < vector < bool > > arr; 16 | vector < int > counter; 17 | int copyn = n; 18 | while (copyn--) { 19 | vector < bool > tmp(k+1, false); 20 | int tn; 21 | cin>>tn; 22 | int tmp1; 23 | counter.push_back(tn); 24 | while (tn--) { 25 | cin>>tmp1; 26 | tmp[tmp1] = true; 27 | } 28 | arr.push_back(tmp); 29 | } 30 | //cout<<"done"<= k) { 39 | for (int copyn = 1; copyn <= k; ++copyn) { 40 | if (!arr[i][copyn] && !arr[j][copyn]) { 41 | //cout< 3 | int main() { 4 | 5 | long t; 6 | scanf("%ld", & t); 7 | while (t--) { 8 | long i, a[2]; 9 | for (i = 0; i < 2; i++) { 10 | scanf("%ld", & a[i]); 11 | } 12 | long long k, r, ans; 13 | k = a[0] + a[1]; 14 | 15 | r = (k * k + k + 2) / 2; 16 | ans = r + a[0]; 17 | 18 | printf("%lld\n", ans); 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /2017/JUNE/JUNE17/XENRANK/XENRANK.cpp: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | // Use memcpy while copying array :D 6 | 7 | // Answer Stauts : AC (100 pts) ** if ull not used it gives WA in ST#2 8 | 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | #define mod(x) x%1000000007; 15 | #define MIN(n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 16 | #define MAX(n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 17 | #define MID(s, e) (s+(e-s)/2) 18 | #define FOR(i, a, b) int i; for(i=(a);i<(b);i++) 19 | #define FORD(i, a, b) int i; for(i=(a);i>(b);i--) 20 | #define show(a) for(i=0;i>a[i]; 22 | #define scanint(a) scanf("%d",&a) 23 | #define scanLLD(a) scanf("%lld",&a) 24 | #define scanstr(s) scanf("%s",s) 25 | #define scanline(l) scanf(" %[^\n]",l); 26 | 27 | typedef long BIG; 28 | typedef unsigned long long PAPA; 29 | 30 | int main() { 31 | std::ios_base::sync_with_stdio(false); 32 | cin.tie(0); 33 | int t; 34 | cin >> t; 35 | while(t--) { 36 | PAPA u, v, i, j; 37 | cin >> u >> v; 38 | PAPA sum = ((u+v)*(u+v+1))/2 + 1; 39 | cout << sum + u << endl; 40 | 41 | } 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /2017/JUNE/LTIME49/MAXSEGM/MAXSEGM.cpp: -------------------------------------------------------------------------------- 1 | // code written by Monal 2 | #include "bits/stdc++.h" 3 | 4 | using namespace std; 5 | 6 | void solve(long int n) { 7 | unordered_set s; 8 | long long int w[n]; 9 | long int c[n]; 10 | for (long int i =0 ; i < n; ++i) { 11 | cin>>c[i]; 12 | } 13 | for (long int i =0 ; i < n; ++i) { 14 | cin>>w[i]; 15 | } 16 | long int j = 0; 17 | unsigned long long int tmp = 0, ans = 0; 18 | for (int i = 0; i < n; ++i) { 19 | while (j < n && s.find(c[j]) == s.end()) { 20 | s.insert(c[j]); 21 | tmp += w[j]; 22 | j++; 23 | } 24 | if (tmp > ans) { 25 | ans = tmp; 26 | } 27 | tmp -= w[i]; 28 | s.erase(c[i]); 29 | } 30 | cout<>tc; 40 | while (tc--) { 41 | long int n; 42 | cin>>n; 43 | solve(n); 44 | } 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /2017/JUNE/LTIME49/TWONMS/TWONMS.py: -------------------------------------------------------------------------------- 1 | # code written by Monal 2 | def main(): 3 | tc = int(input()) 4 | for _ in range(tc): 5 | a, b, t = map(int, input().split()) 6 | if t % 2 == 0: 7 | print(max(a, b) // min(a, b)) 8 | else: 9 | print(max(2*a, b) // min(2*a, b)) 10 | 11 | 12 | if __name__ == '__main__': 13 | main() 14 | -------------------------------------------------------------------------------- /2017/MAR.md: -------------------------------------------------------------------------------- 1 | ## Index Of Dishes from March 2017 2 | 3 | #### All problems are open to contributions, but prefer working and improving solutions marked with [![image](../img/WA.png)](#) and [![image](../img/TLE.png)](#). Simply [Create an Issue](https://github.com/iiitv/ChefLib/issues/new) and Send a PR when assigned. 4 | 5 | ##### Here in this Table [![image](../img/CC.png)](#) links to solution on CodeChef and [![image](../img/GH.png)](#) links to solution on this repository. 6 | 7 | 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [MARCH17](https://www.codechef.com/MARCH17) | [XENTASK](https://www.codechef.com/MARCH17/problems/XENTASK) | ★ | [![image](../img/GH.png)](MAR/MARCH17/XENTASK/XENTASK.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13033268) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](MAR/MARCH17/XENTASK/XENTASK.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12973914) (100 pts) [![image](../img/AC.png)](#) | | | 13 | | [MARCH17](https://www.codechef.com/MARCH17) | [EXTRAN](https://www.codechef.com/MARCH17/problems/EXTRAN) | ★★ | | [![image](../img/GH.png)](MAR/MARCH17/EXTRAN/EXTRAN.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13034093) (100 pts) [![image](../img/AC.png)](#) | | | 14 | | [MARCH17](https://www.codechef.com/MARCH17) | [BANDMATR](https://www.codechef.com/MARCH17/problems/BANDMATR) | ★★ | | [![image](../img/GH.png)](MAR/MARCH17/BANDMATR/BANDMATR.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13030736) (100 pts) [![image](../img/AC.png)](#) | | | 15 | | [MARCH17](https://www.codechef.com/MARCH17) | [SORTROW](https://www.codechef.com/MARCH17/problems/SORTROW) | ★★★ | | [![image](../img/GH.png)](MAR/MARCH17/SORTROW/SORTROW.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/12974751) (100 pts) [![image](../img/AC.png)](#) | | | 16 | | [MARCH17](https://www.codechef.com/MARCH17) | [SCHEDULE](https://www.codechef.com/MARCH17/problems/SCHEDULE) | ★★★ | | | | | 17 | | [MARCH17](https://www.codechef.com/MARCH17) | [PSHTBRTH](https://www.codechef.com/MARCH17/problems/PSHTBRTH) | ★★★★ | | | | | 18 | | [MARCH17](https://www.codechef.com/MARCH17) | [FAVGAME](https://www.codechef.com/MARCH17/problems/FAVGAME) | ★★★★ | | | | | 19 | | [MARCH17](https://www.codechef.com/MARCH17) | [SUMDIS](https://www.codechef.com/MARCH17/problems/SUMDIS) | ★★★★★ | | | | | 20 | | [MARCH17](https://www.codechef.com/MARCH17) | [BEARTRAP](https://www.codechef.com/MARCH17/problems/BEARTRAP) | ★★★★★ | | | | | 21 | | [MARCH17](https://www.codechef.com/MARCH17) | [TUPLES2](https://www.codechef.com/MARCH17/problems/TUPLES2) | ★★★★★ | | | | | 22 | 23 | 24 | #### Cook-Off 25 | 26 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 27 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 28 | | [COOK80](https://www.codechef.com/COOK80) | [ROBOTG](https://www.codechef.com/COOK80/problems/ROBOTG) | ★★ | | [![image](../img/GH.png)](MAR/COOK80/ROBOTG/ROBOTG.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13127553) (100 pts) [![image](../img/AC.png)](#) | | | 29 | | [COOK80](https://www.codechef.com/COOK80) | [RAINBOW](https://www.codechef.com/COOK80/problems/RAINBOW) | ★★★ | | | | | 30 | | [COOK80](https://www.codechef.com/COOK80) | [CARDS777](https://www.codechef.com/COOK80/problems/CARDS777) | ★★★ | | [![image](../img/GH.png)](MAR/COOK80/CARDS777/CARDS777.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13129955) (100 pts) [![image](../img/AC.png)](#) | | | 31 | | [COOK80](https://www.codechef.com/COOK80) | [INCXOR](https://www.codechef.com/COOK80/problems/INCXOR) | ★★★★★ | | | | | 32 | | [COOK80](https://www.codechef.com/COOK80) | [MEETUP](https://www.codechef.com/COOK80/problems/MEETUP) | ★★★★★ | | | | | 33 | 34 | 35 | #### Lunchtime 36 | 37 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 38 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 39 | | [LTIME46](https://www.codechef.com/LTIME46) | [BRLADDER](https://www.codechef.com/LTIME46/problems/BRLADDER) | ★★ | | [![image](../img/GH.png)](MAR/LTIME46/BRLADDER/BRLADDER.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13159851) (100 pts) [![image](../img/AC.png)](#) | | | 40 | | [LTIME46](https://www.codechef.com/LTIME46) | [SPECIES](https://www.codechef.com/LTIME46/problems/SPECIES) | ★★★ | | | | | 41 | | [LTIME46](https://www.codechef.com/LTIME46) | [HAIRCUT](https://www.codechef.com/LTIME46/problems/HAIRCUT) | ★★★★ | | | | | 42 | | [LTIME46](https://www.codechef.com/LTIME46) | [ALMROW](https://www.codechef.com/LTIME46/problems/ALMROW) | ★★★★★ | | | | | 43 | 44 | 45 | 46 | ## Eligible Contributors Rating 47 | 48 | ECR section in table above is for checking who are eligible for contributing to this Problem. 49 | This section will contain ★s which will represent CodeChef's ★ Rating. 50 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` 51 | -------------------------------------------------------------------------------- /2017/MAR/COOK80/CARDS777/CARDS777.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include"bits/stdc++.h" 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | int tc; 10 | scanf("%d",&tc); 11 | while(tc--){ 12 | long int r,b,p; 13 | scanf("%ld%ld%ld",&r,&b,&p); 14 | float r1 = (float) r; 15 | float b1 = (float) b; 16 | float rt = (float) p; 17 | float bt = r1 + b1 - rt; 18 | 19 | float ans = (r1*rt) + (b1*bt); 20 | ans = ans / (r1+b1); 21 | printf("%.10lf\n",ans); 22 | } 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /2017/MAR/COOK80/ROBOTG/ROBOTG.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include"bits/stdc++.h" 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int tc; 9 | scanf("%d",&tc); 10 | while(tc--) { 11 | int n,m; 12 | string s; 13 | scanf("%d%d",&n,&m); 14 | cin>>s; 15 | 16 | for(int i=0;i=m) 28 | break; 29 | } 30 | else if(s[k]=='D'){ 31 | ci++; 32 | if(ci>=n) 33 | break; 34 | } 35 | else{ 36 | ci--; 37 | if(ci<0) 38 | break; 39 | } 40 | } 41 | if(k==s.length()) 42 | { 43 | printf("safe\n"); 44 | goto skip; 45 | } 46 | } 47 | } 48 | printf("unsafe\n"); 49 | skip: 50 | int a; 51 | } 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /2017/MAR/LTIME46/BRLADDER/BRLADDER.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include"bits/stdc++.h" 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int tc; 9 | scanf("%d",&tc); 10 | while(tc--) { 11 | long long int a,b; 12 | scanf("%lld%lld",&a,&b); 13 | if(abs(a-b)==2) 14 | printf("YES\n"); 15 | else if(a%2==1) 16 | { 17 | a--; 18 | a=a/2; 19 | if(b==2*a+2) 20 | printf("YES\n"); 21 | else 22 | printf("NO\n"); 23 | } 24 | else if(b%2==1) 25 | { 26 | b--; 27 | b=b/2; 28 | if(a==2*b+2) 29 | printf("YES\n"); 30 | else 31 | printf("NO\n"); 32 | } 33 | else 34 | printf("NO\n"); 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /2017/MAR/MARCH17/BANDMATR/BANDMATR.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include"bits/stdc++.h" 3 | 4 | using namespace std; 5 | int main() 6 | { 7 | ios::sync_with_stdio(false); 8 | int tc; 9 | cin>>tc; 10 | while(tc--) 11 | { 12 | int n; 13 | cin>>n; 14 | int ones=0; 15 | int tmp; 16 | for(int i=0;i>tmp; 19 | if(tmp) 20 | ones++; 21 | } 22 | if(ones<=n) 23 | cout<<"0\n"; 24 | else 25 | { 26 | tmp=0; 27 | for(int i=0;iback&&ones<=front) 33 | { 34 | cout< 6 | #include 7 | #include 8 | /* 9 | Aashutosh Rathi 10 | Code Chef March Long Problem 2 11 | Bear and Extra Number 12 | */ 13 | using namespace std; 14 | typedef long int BIG; 15 | typedef long long int PAPA; 16 | 17 | int main() 18 | { 19 | int t; 20 | scanf("%d",&t); 21 | while(t--){ 22 | BIG n,i,c=0; 23 | scanf("%ld",&n); 24 | PAPA a[n]; 25 | for(i=0;i=n-2){ 35 | printf("%lld\n",a[n-1]); 36 | break; 37 | } 38 | } 39 | 40 | } 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /2017/MAR/MARCH17/SORTROW/SORTROW.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include"bits/stdc++.h" 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | int n; 8 | scanf("%d",&n); 9 | int arr[n][n]; 10 | for(int i=0;i 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | typedef long long int lli; 12 | typedef long int BIG; 13 | #define mod(x) x%1000000007; 14 | #define MIN( n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 15 | #define MAX( n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 16 | 17 | 18 | int main() 19 | { 20 | int t; 21 | scanf("%d",&t); 22 | while(t--){ 23 | BIG n,i,j; 24 | scanf("%ld",&n); 25 | BIG x[n],y[n]; 26 | for(i=0;i 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int tc; 9 | scanf("%d",&tc); 10 | while(tc--) 11 | { 12 | int n; 13 | scanf("%d",&n); 14 | long int a[n],b[n],tmp; 15 | long long int o1,o2,e1,e2; 16 | o1=o2=e1=e2=0; 17 | for(int i=0;i 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [MAY17](https://www.codechef.com/MAY17) | [CHEFROUT](https://www.codechef.com/MAY17/problems/CHEFROUT) | ★ | | [![image](../img/GH.png)](MAY/MAY17/CHEFROUT/CHEFROUT.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13488483) (100 pts) [![image](../img/AC.png)](#) | | | 13 | | [MAY17](https://www.codechef.com/MAY17) | [UNICOURS](https://www.codechef.com/MAY17/problems/UNICOURS) | ★★ | | [![image](../img/GH.png)](MAY/MAY17/UNICOURS/UNICOURS.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13485038) (100 pts) [![image](../img/AC.png)](#) | | | 14 | | [MAY17](https://www.codechef.com/MAY17) | [MXMEDIAN](https://www.codechef.com/MAY17/problems/MXMEDIAN) | ★★ | | [![image](../img/GH.png)](MAY/MAY17/MXMEDIAN/MXMEDIAN.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13489057) (100 pts) [![image](../img/AC.png)](#) | | | 15 | | [MAY17](https://www.codechef.com/MAY17) | [CHEFSUBA](https://www.codechef.com/MAY17/problems/CHEFSUBA) | ★★★ | | [![image](../img/GH.png)](MAY/MAY17/CHEFSUBA/CHEFSUBA.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13521626) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](MAY/MAY17/CHEFSUBA/CHEFSUBA.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13587367) (30 pts) [![image](../img/TLE.png)](#) | 16 | | [MAY17](https://www.codechef.com/MAY17) | [WSITES01](https://www.codechef.com/MAY17/problems/WSITES01) | ★★★ | | [![image](../img/GH.png)](MAY/MAY17/WSITES01/WSITES01.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13539627) (30 pts) [![image](../img/TLE.png)](#) | | [![image](../img/GH.png)](MAY/MAY17/WSITES01/WSITES01.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13540222) (30 pts) [![image](../img/TLE.png)](#) | 17 | | [MAY17](https://www.codechef.com/MAY17) | [CHEFCODE](https://www.codechef.com/MAY17/problems/CHEFCODE) | ★★★★ | | [![image](../img/GH.png)](MAY/MAY17/CHEFCODE/CHEFCODE.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13511169) (30 pts) [![image](../img/TLE.png)](#) | [![image](../img/GH.png)](MAY/MAY17/CHEFCODE/CHEFCODE.java) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13548344) (30 pts) [![image](../img/WA.png)](#) | [![image](../img/GH.png)](MAY/MAY17/CHEFCODE/CHEFCODE.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13555085) (30 pts) [![image](../img/WA.png)](#) | 18 | | [MAY17](https://www.codechef.com/MAY17) | [GPD](https://www.codechef.com/MAY17/problems/GPD) | ★★★★ | | [![image](../img/GH.png)](MAY/MAY17/GPD/GPD.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13585707) (100 pts) [![image](../img/AC.png)](#) | | | 19 | | [MAY17](https://www.codechef.com/MAY17) | [SANDWICH](https://www.codechef.com/MAY17/problems/SANDWICH) | ★★★★★ | | [![image](../img/GH.png)](MAY/MAY17/SANDWICH/SANDWICH.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15224401) (100 pts) [![image](../img/AC.png)](#) | | | 20 | | [MAY17](https://www.codechef.com/MAY17) | [CHEFBATL](https://www.codechef.com/MAY17/problems/CHEFBATL) | ★★★★★ | | | | | 21 | | [MAY17](https://www.codechef.com/MAY17) | [KILLER](https://www.codechef.com/MAY17/problems/KILLER) | ★★★★★ | | | | | 22 | 23 | 24 | #### Cook-Off 25 | 26 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 27 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 28 | | [COOK82](https://www.codechef.com/COOK82) | [COOK82A](https://www.codechef.com/COOK82/problems/COOK82A) | ★★ | | [![image](../img/GH.png)](MAY/COOK82/COOK82A/COOK82A.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13699856) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](MAY/COOK82/COOK82A/COOK82A.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/13701118) (100 pts) [![image](../img/AC.png)](#) | 29 | | [COOK82](https://www.codechef.com/COOK82) | [COOK82B](https://www.codechef.com/COOK82/problems/COOK82B) | ★★★ | | | | | 30 | | [COOK82](https://www.codechef.com/COOK82) | [COOK82C](https://www.codechef.com/COOK82/problems/COOK82C) | ★★★★ | | | | | 31 | | [COOK82](https://www.codechef.com/COOK82) | [COOK82D](https://www.codechef.com/COOK82/problems/COOK82D) | ★★★★ | | | | | 32 | | [COOK82](https://www.codechef.com/COOK82) | [COOK82E](https://www.codechef.com/COOK82/problems/COOK82E) | ★★★★★ | | | | | 33 | 34 | 35 | 36 | ## Eligible Contributors Rating 37 | 38 | ECR section in table above is for checking who are eligible for contributing to this Problem. 39 | This section will contain ★s which will represent CodeChef's ★ Rating. 40 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` 41 | -------------------------------------------------------------------------------- /2017/MAY/COOK82/COOK82A/COOK82A.cpp: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | // Answer Status : Correct Answer 7 | 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | 13 | typedef long int BIG; 14 | typedef long long PAPA; 15 | 16 | int main() { 17 | std::ios_base::sync_with_stdio(false); 18 | int t; 19 | cin >> t; 20 | while(t--) { 21 | string s; 22 | int b, m, r, e, i; 23 | for(i=0 ; i<4; i++) { 24 | cin >> s; 25 | if(s == "Barcelona") 26 | cin >> b; 27 | else if(s == "Malaga") 28 | cin >> m; 29 | else if(s == "RealMadrid") 30 | cin >> r; 31 | else if(s == "Eibar") 32 | cin >> e; 33 | } 34 | if(m>r && b>e) 35 | cout << "Barcelona" << endl; 36 | else 37 | cout << "RealMadrid" << endl; 38 | 39 | } 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /2017/MAY/COOK82/COOK82A/COOK82A.py: -------------------------------------------------------------------------------- 1 | # Code written by Divyesh 2 | def main(): 3 | t = int(input()) 4 | while t > 0: 5 | l = [] 6 | l1 = [] 7 | for x in range(4): 8 | str, n = input().split() 9 | l.append(str) 10 | l1.append(n) 11 | r = l.index("RealMadrid") 12 | b = l.index("Barcelona") 13 | m = l.index("Malaga") 14 | e = l.index("Eibar") 15 | if l1[r] < l1[m] and l1[e] < l1[b]: 16 | print("Barcelona") 17 | else: 18 | print("RealMadrid") 19 | t = t - 1 20 | 21 | 22 | if __name__ == '__main__': 23 | main() 24 | -------------------------------------------------------------------------------- /2017/MAY/COOK82/COOK82B/COOK82B.cpp: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | // Answer Status : Wrong Answer 7 | 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | 13 | #define mod(x) x%1000000007; 14 | #define MIN(n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 15 | #define MAX(n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 16 | #define MID(s, e) (s+(e-s)/2) 17 | #define FOR(i, a, b) int i; for(i=(a);i<(b);i++) 18 | #define FORD(i, a, b) int i; for(i=(a);i>(b);i--) 19 | #define show(a) for(i=0;i>a[i]; 21 | #define scanint(a) scanf("%d",&a) 22 | #define scanLLD(a) scanf("%lld",&a) 23 | #define scanstr(s) scanf("%s",s) 24 | #define scanline(l) scanf(" %[^\n]",l); 25 | 26 | typedef long int BIG; 27 | typedef unsigned long long PAPA; 28 | 29 | long long fast_power(long long base, long long power) { 30 | long long result = 1; 31 | while(power > 0) { 32 | 33 | if(power % 2 == 1) { // Can also use (power & 1) to make code even faster 34 | result = (result*base); 35 | } 36 | base = (base * base); 37 | power = power / 2; // Can also use power >>= 1; to make code even faster 38 | } 39 | return result; 40 | } 41 | 42 | bool check(PAPA pro, int n) { 43 | PAPA val = round(pow(pro, 1.0/n)); 44 | if(val == pow(pro, 1.0/n)) { 45 | return true; 46 | } 47 | return false; 48 | } 49 | 50 | 51 | int main() { 52 | std::ios_base::sync_with_stdio(false); 53 | int n, i; 54 | cin >> n; 55 | long a[n]; 56 | PAPA pro = 1, res = 1; 57 | for(i = 0; i < n; i++) { 58 | cin >> a[i]; 59 | pro = (pro * a[i]); 60 | } 61 | PAPA val = round(pow(pro, 1.0/n)); 62 | if(check(pro, n)) { 63 | cout << "justdoit"; 64 | } 65 | else { 66 | PAPA pro2 = pro; 67 | 68 | long c[(long)sqrt(pro)+1]; 69 | bool b[(long)sqrt(pro)+1]; 70 | 71 | memset(c, 0, sqrt(pro)+1); 72 | memset(b, false, sqrt(pro)+1); 73 | 74 | i=2; 75 | while(pro2%i == 0) { 76 | b[i] = true; 77 | c[i]++; 78 | pro2 = pro2/i; 79 | } 80 | 81 | for(i=3; i<=sqrt(pro); i=i+2) { 82 | while(pro2%i == 0) { 83 | b[i] = true; 84 | c[i]++; 85 | pro2 = pro2/i; 86 | } 87 | } 88 | 89 | for(i=2; i<=sqrt(pro); i++) { 90 | if(b[i]) { 91 | //cout << i <<" : "<>n>>k 10 | #define inone(tmp) cin>>tmp 11 | #define out(a) cout< products; 19 | 20 | void update(ull k, ull inp) { 21 | int size = products.size(); 22 | forn(size) { 23 | ull popped = pf(); 24 | po(); 25 | ull tmp = inp * popped; 26 | pb(popped); 27 | if(tmp <= k) // If product with previous elements is less 28 | pb(tmp); 29 | } 30 | } 31 | 32 | 33 | void solve(int n, ull k) { 34 | forn(n) { 35 | ull tmp; 36 | inone(tmp); 37 | if (tmp <= k) { 38 | update(k, tmp); 39 | pb(tmp); 40 | } 41 | } 42 | } 43 | 44 | int main() { 45 | ios::sync_with_stdio(false); 46 | cin.tie(NULL); 47 | int n; 48 | ull k; 49 | intwo(n, k); 50 | solve(n, k); 51 | out(products.size()); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /2017/MAY/MAY17/CHEFCODE/CHEFCODE.java: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | import java.io.FileInputStream; 3 | import java.io.IOException; 4 | import java.io.InputStreamReader; 5 | import java.util.Scanner; 6 | import java.util.StringTokenizer; 7 | import java.io.DataInputStream; 8 | import java.util.Vector; 9 | import java.math.BigInteger; 10 | 11 | class ChefAndSubsequences1 { 12 | static class Reader { 13 | final private int BUFFER_SIZE = 1 << 16; 14 | private DataInputStream din; 15 | private byte[] buffer; 16 | private int bufferPointer, bytesRead; 17 | 18 | public Reader() { 19 | din = new DataInputStream(System.in); 20 | buffer = new byte[BUFFER_SIZE]; 21 | bufferPointer = bytesRead = 0; 22 | } 23 | 24 | public Reader(String file_name) throws IOException { 25 | din = new DataInputStream(new FileInputStream(file_name)); 26 | buffer = new byte[BUFFER_SIZE]; 27 | bufferPointer = bytesRead = 0; 28 | } 29 | 30 | public String readLine() throws IOException { 31 | byte[] buf = new byte[64]; // line length 32 | int cnt = 0, c; 33 | while ((c = read()) != -1) 34 | { 35 | if (c == '\n') 36 | break; 37 | buf[cnt++] = (byte) c; 38 | } 39 | return new String(buf, 0, cnt); 40 | } 41 | 42 | public int nextInt() throws IOException { 43 | int ret = 0; 44 | byte c = read(); 45 | while (c <= ' ') 46 | c = read(); 47 | boolean neg = (c == '-'); 48 | if (neg) 49 | c = read(); 50 | do { 51 | ret = ret * 10 + c - '0'; 52 | } while ((c = read()) >= '0' && c <= '9'); 53 | 54 | if (neg) 55 | return -ret; 56 | return ret; 57 | } 58 | 59 | public long nextLong() throws IOException { 60 | long ret = 0; 61 | byte c = read(); 62 | while (c <= ' ') 63 | c = read(); 64 | boolean neg = (c == '-'); 65 | if (neg) 66 | c = read(); 67 | do { 68 | ret = ret * 10 + c - '0'; 69 | } 70 | while ((c = read()) >= '0' && c <= '9'); 71 | if (neg) 72 | return -ret; 73 | return ret; 74 | } 75 | 76 | public double nextDouble() throws IOException { 77 | double ret = 0, div = 1; 78 | byte c = read(); 79 | while (c <= ' ') 80 | c = read(); 81 | boolean neg = (c == '-'); 82 | if (neg) 83 | c = read(); 84 | 85 | do { 86 | ret = ret * 10 + c - '0'; 87 | } 88 | while ((c = read()) >= '0' && c <= '9'); 89 | 90 | if (c == '.') { 91 | while ((c = read()) >= '0' && c <= '9') { 92 | ret += (c - '0') / (div *= 10); 93 | } 94 | } 95 | 96 | if (neg) 97 | return -ret; 98 | return ret; 99 | } 100 | 101 | private void fillBuffer() throws IOException { 102 | bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 103 | if (bytesRead == -1) 104 | buffer[0] = -1; 105 | } 106 | 107 | private byte read() throws IOException { 108 | if (bufferPointer == bytesRead) 109 | fillBuffer(); 110 | return buffer[bufferPointer++]; 111 | } 112 | 113 | public void close() throws IOException { 114 | if (din == null) 115 | return; 116 | din.close(); 117 | } 118 | } 119 | public static void main(String[] args) throws Exception { 120 | Reader scan = new Reader(); 121 | int n; 122 | long k; 123 | n = scan.nextInt(); 124 | k = scan.nextLong(); 125 | BigInteger kb = BigInteger.valueOf(k); 126 | long answer = 0; 127 | Vector products = new Vector (); 128 | BigInteger[] arr = new BigInteger[n]; 129 | long temp; 130 | long prev1 = 0; 131 | for (int i = 0; i < n; ++i) { 132 | temp = scan.nextLong(); 133 | arr[i] = BigInteger.valueOf(temp); 134 | if (arr[i].compareTo(BigInteger.ONE) == 0) { 135 | answer += prev1; 136 | for (int j = 0; j < products.size(); ++j) { 137 | if (products.get(j).compareTo(kb) <= 0) { 138 | answer++; 139 | prev1++; 140 | } 141 | } 142 | answer++; 143 | products.add(arr[i]); 144 | } 145 | else if (arr[i].compareTo(kb) <= 0) { 146 | int size = products.size(); 147 | for (int j = 0; j < size; ++j) { 148 | BigInteger tmp = arr[i].multiply(products.get(j)); 149 | if (tmp.compareTo(kb) <= 0) { 150 | products.add(tmp); 151 | answer++; 152 | } 153 | } 154 | answer++; 155 | products.add(arr[i]); 156 | } 157 | } 158 | System.out.println(answer); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /2017/MAY/MAY17/CHEFCODE/CHEFCODE.py: -------------------------------------------------------------------------------- 1 | # Code written by Monal 2 | def main(): 3 | n, k = map(int, input().split()) 4 | nums = list(map(int, input().split())) 5 | products = [] 6 | answer = 0 7 | one = 0 8 | for i in nums: 9 | if i == 1 and k != 1: 10 | one += 1 11 | elif i - k > 0: 12 | pass 13 | else: 14 | size = len(products) 15 | for j in range(size): 16 | tmp = i * products[j] 17 | if tmp - k > 0: 18 | pass 19 | else: 20 | answer += 1 21 | products.append(tmp) 22 | products.append(i) 23 | answer += 1 24 | answer += (((2**one)-1) * answer) 25 | answer += (one*(one+1))//2 26 | print(answer) 27 | 28 | 29 | if __name__ == '__main__': 30 | main() 31 | -------------------------------------------------------------------------------- /2017/MAY/MAY17/CHEFROUT/CHEFROUT.cpp: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | // Result = Correct Answer 7 | 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | 13 | #define mod(x) x%1000000007; 14 | #define MIN(n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 15 | #define MAX(n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 16 | #define MID(s, e) (s+(e-s)/2) 17 | #define FOR(i, a, b) int i; for(i=(a);i<(b);i++) 18 | #define FORD(i, a, b) int i; for(i=(a);i>(b);i--) 19 | #define show(a) for(i=0;i>a[i]; 21 | #define scanint(a) scanf("%d",&a) 22 | #define scanLLD(a) scanf("%lld",&a) 23 | #define scanstr(s) scanf("%s",s) 24 | #define scanline(l) scanf(" %[^\n]",l); 25 | 26 | typedef long int BIG; 27 | typedef long long PAPA; 28 | 29 | int main() 30 | { 31 | std::ios_base::sync_with_stdio(false); 32 | int t; 33 | cin >> t; 34 | while(t--) { 35 | string s; 36 | cin >> s; 37 | int i, c = 0; 38 | for(i=0; i 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | 9 | using namespace std; 10 | 11 | #define innum(n, k, p) cin>>n>>k>>p 12 | #define inone(s) cin>>s 13 | #define pb(tmp) push_back(tmp) 14 | #define po() pop_back() 15 | #define bk() back() 16 | #define pf(tmp) push_front(tmp) 17 | #define bg() begin() 18 | #define er(tmp) erase(tmp) 19 | #define fr() front() 20 | #define cnt(tmp) count(tmp) 21 | #define out(tmp) cout< :: iterator traversor; 25 | deque < long int > mydequeue; 26 | vector < long int > bits; 27 | map < long int , long int > mymap; 28 | 29 | int main() { 30 | ios::sync_with_stdio(false); 31 | long int n, k, p; 32 | innum(n, k, p); 33 | forn(n) { 34 | long int tmp; 35 | inone(tmp); 36 | bits.pb(tmp); 37 | } 38 | // Why such big input codechef? 39 | long int start = k - 1; // start of left out part 40 | long int end = n - 1; // end of left out part 41 | string query; 42 | inone(query); // string of ? and ! 43 | long int ones_in_frame = 0; 44 | forn(min(k, n)) { 45 | ones_in_frame += bits[i]; 46 | } 47 | if (k >= n) { // Overflow case 48 | forn(p) { 49 | if (query[i] == '?') 50 | out(ones_in_frame); 51 | } 52 | return 0; // Never need rotation as it wont affect anything. 53 | } 54 | forn(n - k + 1) { 55 | mydequeue.pb(ones_in_frame); 56 | mymap[-1*ones_in_frame] = (mymap.cnt(-1*ones_in_frame) > 0)? (mymap[-1*ones_in_frame] + 1) : 1; 57 | if (i + k < n) // frame of last k elements 58 | ones_in_frame += (bits[i+k] - bits[i]); 59 | } 60 | forn(p) { // Normal cases 61 | if (query[i] == '!') { 62 | long int left = bits[start]; 63 | start--; 64 | if(start == -1) // rotation resulting out of bounds 65 | start = n - 1; 66 | long int right = bits[end]; 67 | end--; 68 | if(end == -1) // if out of bound 69 | end = n - 1; 70 | ones_in_frame = mydequeue.bk(); 71 | mydequeue.po(); 72 | mymap[-1*ones_in_frame] = mymap[-1*ones_in_frame] - 1; 73 | if(mymap[-1*ones_in_frame] == 0) 74 | mymap.er(-1*ones_in_frame); 75 | ones_in_frame = mydequeue.fr() + right - left; 76 | mymap[-1*ones_in_frame] = (mymap.cnt(-1*ones_in_frame) > 0)? (mymap[-1*ones_in_frame] + 1) : 1; 77 | mydequeue.pf(ones_in_frame); 78 | } else { 79 | traversor = mymap.bg(); 80 | long int ans = traversor->first; 81 | out(-1*ans); 82 | } 83 | } 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /2017/MAY/MAY17/CHEFSUBA/CHEFSUBA.py: -------------------------------------------------------------------------------- 1 | # Code written by Divyesh 2 | import collections 3 | import itertools 4 | 5 | 6 | def main(): 7 | n, k, p = input().split() 8 | arr = list(map(int, input().split())) 9 | str = input() 10 | y = 0 11 | u = 0 12 | for x in str: 13 | if x == "!": 14 | u = u + 1 15 | y = 0 16 | else: 17 | arr = collections.deque(arr) 18 | arr.rotate(u) 19 | for x in range(abs(int(n)-int(k)+1)): 20 | ans = list(itertools.islice(arr, x, x+int(k))).count(1) 21 | if ans > y: 22 | y = ans 23 | u = 0 24 | print(y) 25 | 26 | 27 | if __name__ == '__main__': 28 | main() 29 | -------------------------------------------------------------------------------- /2017/MAY/MAY17/GPD/GPD.cpp: -------------------------------------------------------------------------------- 1 | //Solution by ista2000 2 | //Original solution link: https://www.codechef.com/viewsolution/13585707 3 | #include 4 | #define int long long int 5 | using namespace std; 6 | 7 | int n, q, r, key; 8 | //Solution uses a persistent trie to solve this problem, all the function names are self-explanatory 9 | struct trie 10 | { 11 | int nxt[2]; 12 | trie() 13 | { 14 | nxt[0] = nxt[1] = -1; 15 | } 16 | }ar[300002 * 32];//This is the trie, ar[i] is a node in the trie 17 | int tot = 0; 18 | void insert(int x, int root) 19 | { 20 | int i = 32; 21 | while(i--) 22 | { 23 | int b = (bool)(x & (1 << i)); 24 | if(ar[root].nxt[b] == -1) 25 | { 26 | ar[++tot] = trie(); 27 | ar[root].nxt[b] = tot; 28 | } 29 | else 30 | { 31 | ar[++tot] = ar[ar[root].nxt[b]]; 32 | ar[root].nxt[b] = tot; 33 | } 34 | root = ar[root].nxt[b]; 35 | } 36 | } 37 | map > > g; 38 | map start; 39 | void dfs(pair u, pair p) 40 | { 41 | ar[++tot] = ar[ start[p.first] ]; 42 | start[u.first] = tot; 43 | insert(u.second, start[u.first]); 44 | for(pair v: g[u.first]) 45 | dfs(v, u); 46 | } 47 | void addnode(int v, int u, int k) 48 | { 49 | ar[++tot] = ar[ start[v] ]; 50 | start[u] = tot; 51 | insert(k, start[u]); 52 | } 53 | 54 | int maxxor(int x, int root) 55 | { 56 | int i = 32, ret = 0; 57 | while(i--) 58 | { 59 | int b = (bool)(x & (1 << i)); 60 | if(ar[root].nxt[b ^ 1]==-1) 61 | root = ar[root].nxt[b]; 62 | else 63 | ret += 1 << i, root = ar[root].nxt[b ^ 1]; 64 | } 65 | return ret; 66 | } 67 | int minxor(int x, int root) 68 | { 69 | int i = 32, ret = 0; 70 | while(i--) 71 | { 72 | int b = (bool)(x & (1 << i)); 73 | if(ar[root].nxt[b]==-1) 74 | ret += 1 << i, root = ar[root].nxt[b ^ 1]; 75 | else 76 | root = ar[root].nxt[b]; 77 | } 78 | return ret; 79 | } 80 | 81 | #undef int 82 | int main() 83 | { 84 | #define int long long int 85 | 86 | ios_base::sync_with_stdio(0); 87 | cin.tie(0); 88 | cout.tie(0); 89 | 90 | cin >> n >> q >> r >> key; 91 | for(int i = 0;i> u >> v >> k; 95 | g[v].push_back({u, k}); 96 | } 97 | ar[0] = trie(); 98 | start[0] = 0; 99 | tot = 0; 100 | dfs( {r, key}, {0, 0}); 101 | int la = 0; 102 | while(q--) 103 | { 104 | int t; 105 | cin >> t; 106 | t ^= la; 107 | if(t == 0) 108 | { 109 | int u, v, k; 110 | cin >> v >> u >> k; 111 | v ^= la; 112 | u ^= la; 113 | k ^= la; 114 | addnode(v, u, k); 115 | } 116 | else 117 | { 118 | int u, k; 119 | cin >> u >> k; 120 | u ^= la; 121 | k ^= la; 122 | int ans1 = maxxor(k, start[u]); 123 | int ans2 = minxor(k, start[u]); 124 | la = ans1 ^ ans2; 125 | cout << ans2 << " " << ans1 << endl; 126 | } 127 | } 128 | 129 | return 0; 130 | } 131 | -------------------------------------------------------------------------------- /2017/MAY/MAY17/MXMEDIAN/MXMEDIAN.cpp: -------------------------------------------------------------------------------- 1 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | // ~~~~~~~© Aashutosh Rathi~~~~~~ 3 | // ~~~~~~~~aashutosh001~~~~~~~~~~ 4 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | // Result = Correct Answer (100 marks) 7 | 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | 13 | #define mod(x) x%1000000007; 14 | #define MIN(n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 15 | #define MAX(n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 16 | #define MID(s, e) (s+(e-s)/2) 17 | #define FOR(i, a, b) int i; for(i=(a);i<(b);i++) 18 | #define FORD(i, a, b) int i; for(i=(a);i>(b);i--) 19 | #define show(a) for(i=0;i>a[i]; 21 | #define scanint(a) scanf("%d",&a) 22 | #define scanLLD(a) scanf("%lld",&a) 23 | #define scanstr(s) scanf("%s",s) 24 | #define scanline(l) scanf(" %[^\n]",l); 25 | 26 | typedef long int BIG; 27 | typedef long long PAPA; 28 | 29 | int main() 30 | { 31 | std::ios_base::sync_with_stdio(false); 32 | int t; 33 | cin >> t; 34 | while(t--) { 35 | int n; 36 | cin >> n; 37 | int dn = 2*n; 38 | int a[dn], i; 39 | for (i = 0; i < dn; ++i) { 40 | cin >> a[i]; 41 | } 42 | sort(a, a+dn); 43 | cout << a[n+n/2] << endl; 44 | for (i = 0; i < n; i++) { 45 | cout << a[i] << " " << a[n+i] <<" "; 46 | } 47 | cout << endl; 48 | } 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /2017/MAY/MAY17/SANDWICH/SANDWICH.cpp: -------------------------------------------------------------------------------- 1 | //Code by: ista2000/Istasis Mishra 2 | #include 3 | #define int long long int 4 | using namespace std; 5 | 6 | vector euler(1000003, -1), primes; 7 | 8 | void genprime() 9 | { 10 | for( int i = 2 ; i <= 1000002 ; i++ ) 11 | { 12 | if(euler[i] == -1) 13 | { 14 | primes.push_back(i); 15 | euler[i] = i-1; 16 | for(int j = 2 * i; j <= 1000002; j += i ) 17 | { 18 | if(euler[j] == -1)euler[j] = j; 19 | euler[j] = (euler[j] / i) * (i - 1); 20 | } 21 | } 22 | } 23 | } 24 | 25 | int powll(int x, int p, int m = 1ll << 62) 26 | { 27 | if(p == 0)return 1; 28 | if(p == 1)return x % m; 29 | int ans = powll(x, p / 2, m); 30 | ans = ((ans % m) * (ans % m)) % m; 31 | if(p & 1)ans = (ans * x % m) % m; 32 | return ans % m; 33 | } 34 | 35 | int inverse(int x, int m) 36 | { 37 | if(x == 1)return 1; 38 | assert(__gcd(x, m) == 1); 39 | return powll(x, euler[m] - 1, m) % m; 40 | } 41 | //finds (n!)_p 42 | int ff(int n, int p, int q) 43 | { 44 | int x = 1, y = powll(p, q); 45 | for(int i = 2; i <= n; i++) 46 | if(i % p) 47 | x = (x * i) % y; 48 | return x % y; 49 | } 50 | 51 | //Generalized Lucas Theorem 52 | int f(int n, int m, int p, int q) 53 | { 54 | int r = n - m, x = powll(p, q); 55 | int e0 = 0, eq = 0; 56 | int mul = (p == 2 && q >= 3) ? 1: -1; 57 | int cr = r, cm = m, carry = 0, cnt = 0; 58 | while(cr || cm || carry) 59 | { 60 | cnt++; 61 | int rr = cr % p, rm = cm % p; 62 | if(rr + rm + carry >= p) 63 | { 64 | e0++; 65 | if(cnt >= q)eq++; 66 | } 67 | carry = (carry + rr + rm) / p; 68 | cr /= p; 69 | cm /= p; 70 | } 71 | mul = powll(p, e0) * powll(mul, eq); 72 | int ret = (mul % x + x) % x; 73 | int temp = 1; 74 | for(int i = 0; ;i++) 75 | { 76 | ret = ((ret * ff((n / temp) % x, p, q) % x) % x * (inverse(ff((m / temp) % x, p, q), x) % x * inverse(ff((r/temp) % x, p, q), x) % x) % x) % x; 77 | 78 | if(temp > n / p && temp > m / p && temp > r / p)break; 79 | temp = temp * p; 80 | } 81 | return (ret % x + x) % x; 82 | } 83 | 84 | #undef int 85 | int main() 86 | { 87 | #define int long long int 88 | 89 | ios_base::sync_with_stdio(0); 90 | cin.tie(0); 91 | cout.tie(0); 92 | 93 | genprime(); 94 | int t; 95 | cin >> t; 96 | while(t--) 97 | { 98 | int n, k, m; 99 | cin >> n >> k >> m; 100 | int temp = m; 101 | int x = n / k + (bool)(n % k); 102 | int nn = x + k * x - n - 1, nm = k * x - n; 103 | // nnCnm % m = ?? 104 | vector num, rem; 105 | for(int i = 0; primes[i] <= m && i < primes.size(); i++) 106 | { 107 | if(m % primes[i]==0) 108 | { 109 | int p = primes[i], q = 0; 110 | while(m % p==0) 111 | q++, m /= p; 112 | num.push_back(powll(p, q)); 113 | rem.push_back(f(nn, nm, p, q)); 114 | } 115 | } 116 | m = temp; 117 | int ans = 0; 118 | //Chinese Remainder Theorem 119 | temp = 1; 120 | for(int i = 0;i 9 | #include 10 | 11 | using namespace std; 12 | 13 | #define mod(x) x%1000000007; 14 | #define MIN(n1, n2 ) ((n1) > (n2) ? (n2) : (n1)) 15 | #define MAX(n1, n2 ) ((n1) > (n2) ? (n1) : (n2)) 16 | #define MID(s, e) (s+(e-s)/2) 17 | #define FOR(i, a, b) int i; for(i=(a);i<(b);i++) 18 | #define FORD(i, a, b) int i; for(i=(a);i>(b);i--) 19 | #define show(a) for(i=0;i>a[i]; 21 | #define scanint(a) scanf("%d",&a) 22 | #define scanLLD(a) scanf("%lld",&a) 23 | #define scanstr(s) scanf("%s",s) 24 | #define scanline(l) scanf(" %[^\n]",l); 25 | 26 | typedef long int BIG; 27 | typedef long long PAPA; 28 | 29 | int main() { 30 | std::ios_base::sync_with_stdio(false); 31 | int t; 32 | cin >> t; 33 | while(t--) { 34 | int n; 35 | cin >> n; 36 | int a[n], i; 37 | for(i=0; i> a[i]; 39 | } 40 | sort(a,a+n); 41 | cout << n - a[n-1] << endl; 42 | } 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /2017/MAY/MAY17/WSITES01/WSITES01.cpp: -------------------------------------------------------------------------------- 1 | // Code written by Monal 2 | #include "bits/stdc++.h" 3 | #include 4 | 5 | using namespace std; 6 | 7 | #define li long int 8 | #define in(a) cin>>a 9 | #define out(a) cout< yes; 14 | vector < string > no; 15 | vector answer; 16 | 17 | template 18 | bool LexCompare(const Container& a, const Container& b) { 19 | return lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()); 20 | } 21 | 22 | // Use that comparison function to sort a range: 23 | template 24 | void sort_by_lexicographical_comapre(ContainerIterator beg, ContainerIterator end) { 25 | sort(beg, end, LexCompare); 26 | } 27 | 28 | 29 | string calculate(string check, vector yes) { 30 | for (int i = 1; i <= check.length(); ++i) { 31 | int j; 32 | string temp = check.substr(0,i); 33 | for (j = 0; j < yes.size(); ++j) { 34 | if (i > yes[j].length()) 35 | continue; 36 | if (temp == yes[j].substr(0,i)) 37 | break; 38 | } 39 | if (j == yes.size()) 40 | return temp; 41 | } 42 | return "NO"; 43 | } 44 | 45 | int main() { 46 | ios::sync_with_stdio(false); 47 | cin.tie(NULL); 48 | int n; 49 | in(n); 50 | char ch; 51 | string s; 52 | forn(n) { 53 | in(ch); 54 | in(s); 55 | if (ch == '+') 56 | yes.pb(s); 57 | else 58 | no.pb(s); 59 | } 60 | forn(no.size()) { 61 | string temp = calculate(no[i],yes); 62 | if (temp != "NO") 63 | answer.pb(temp); 64 | } 65 | if (answer.size() != no.size()) { 66 | cout<<"-1"; 67 | return 0; 68 | } 69 | set myset( answer.begin(), answer.end() ); 70 | answer.assign( myset.begin(), myset.end() ); 71 | out(answer.size()); 72 | forn(answer.size()) { 73 | out(answer[i]); 74 | } 75 | return 0; 76 | } 77 | -------------------------------------------------------------------------------- /2017/MAY/MAY17/WSITES01/WSITES01.py: -------------------------------------------------------------------------------- 1 | # Code written by Monal 2 | def calculate(check, yes): 3 | for i in range(len(check)): 4 | temp = check[0:i+1] 5 | j = 0 6 | for _ in range(len(yes)): 7 | if i > len(yes[j]): 8 | j += 1 9 | continue 10 | if temp == yes[j][0:i+1]: 11 | break 12 | j += 1 13 | if j == len(yes): 14 | return temp 15 | return 'NO' 16 | 17 | 18 | def main(): 19 | n = int(input()) 20 | yes = [] 21 | no = [] 22 | answer = [] 23 | for _ in range(n): 24 | ch, temp = input().split() 25 | if ch == '-': 26 | no.append(temp) 27 | else: 28 | yes.append(temp) 29 | for i in no: 30 | temp = calculate(i, yes) 31 | if temp != 'NO': 32 | answer.append(temp) 33 | if len(answer) != len(no): 34 | print('-1') 35 | else: 36 | ouput = set(answer) 37 | print(len(ouput)) 38 | print('\n'.join(sorted(ouput))) 39 | 40 | 41 | if __name__ == '__main__': 42 | main() 43 | -------------------------------------------------------------------------------- /2017/OCT.md: -------------------------------------------------------------------------------- 1 | ## Index Of Dishes from October 2017 2 | 3 | #### All problems are open to contributions, but prefer working and improving solutions marked with [![image](../img/WA.png)](#) and [![image](../img/TLE.png)](#). Simply [Create an Issue](https://github.com/iiitv/ChefLib/issues/new) and Send a PR when assigned. 4 | 5 | ##### Here in this Table [![image](../img/CC.png)](#) links to solution on CodeChef and [![image](../img/GH.png)](#) links to solution on this repository. 6 | 7 | 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [OCT17](https://www.codechef.com/OCT17) | [PERFCONT](https://www.codechef.com/OCT17/problems/PERFCONT) | ★★ | | | | | 13 | | [OCT17](https://www.codechef.com/OCT17) | [MEX](https://www.codechef.com/OCT17/problems/MEX) | ★★ | | | | | 14 | | [OCT17](https://www.codechef.com/OCT17) | [CHEFCOUN](https://www.codechef.com/OCT17/problems/CHEFCOUN) | ★★★ | | | | | 15 | | [OCT17](https://www.codechef.com/OCT17) | [CHEFGP](https://www.codechef.com/OCT17/problems/CHEFGP) | ★★★★ | | | | | 16 | | [OCT17](https://www.codechef.com/OCT17) | [CHEFCCYL](https://www.codechef.com/OCT17/problems/CHEFCCYL) | ★★★★ | | | | | 17 | | [OCT17](https://www.codechef.com/OCT17) | [MARRAYS](https://www.codechef.com/OCT17/problems/MARRAYS) | ★★★★★ | | | | | 18 | | [OCT17](https://www.codechef.com/OCT17) | [POINTCN](https://www.codechef.com/OCT17/problems/POINTCN) | ★★★★★ | | | | | 19 | | [OCT17](https://www.codechef.com/OCT17) | [SHTARR](https://www.codechef.com/OCT17/problems/SHTARR) | ★★★★★★ | | | | | 20 | | [OCT17](https://www.codechef.com/OCT17) | [LKYEDGE](https://www.codechef.com/OCT17/problems/LKYEDGE) | ★★★★★★★ | | | | | 21 | | [OCT17](https://www.codechef.com/OCT17) | [XORTREEH](https://www.codechef.com/OCT17/problems/XORTREEH) | ★★★★★★★ | | | | | 22 | 23 | 24 | #### Cook-Off 25 | 26 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 27 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 28 | | [COOK87](https://www.codechef.com/COOK87) | [CK87MEDI](https://www.codechef.com/COOK87/problems/CK87MEDI) | ★★★ | | | | | 29 | | [COOK87](https://www.codechef.com/COOK87) | [CK87QUER](https://www.codechef.com/COOK87/problems/CK87QUER) | ★★★★ | | | | | 30 | | [COOK87](https://www.codechef.com/COOK87) | [CK87GSUB](https://www.codechef.com/COOK87/problems/CK87GSUB) | ★★★★★ | | | | | 31 | | [COOK87](https://www.codechef.com/COOK87) | [CK87DANC](https://www.codechef.com/COOK87/problems/CK87DANC) | ★★★★★★ | | | | | 32 | | [COOK87](https://www.codechef.com/COOK87) | [CK87MEAD](https://www.codechef.com/COOK87/problems/CK87MEAD) | ★★★★★★★ | | | | | 33 | 34 | 35 | #### Lunchtime 36 | 37 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 38 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 39 | | [LTIME53](https://www.codechef.com/LTIME53) | [BUGCAL](https://www.codechef.com/LTIME53/problems/BUGCAL) | ★★★ | | | | | 40 | | [LTIME53](https://www.codechef.com/LTIME53) | [MAXNUM3](https://www.codechef.com/LTIME53/problems/MAXNUM3) | ★★★★ | | | | | 41 | | [LTIME53](https://www.codechef.com/LTIME53) | [WEICOM](https://www.codechef.com/LTIME53/problems/WEICOM) | ★★★★★★ | | | | | 42 | | [LTIME53](https://www.codechef.com/LTIME53) | [OPTSSET](https://www.codechef.com/LTIME53/problems/OPTSSET) | ★★★★★★★ | | | | | 43 | 44 | 45 | 46 | ## Eligible Contributors Rating 47 | 48 | ECR section in table above is for checking who are eligible for contributing to this Problem. 49 | This section will contain ★s which will represent CodeChef's ★ Rating. 50 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` -------------------------------------------------------------------------------- /2017/SEPT.md: -------------------------------------------------------------------------------- 1 | ## Index Of Dishes from September 2017 2 | 3 | #### All problems are open to contributions, but prefer working and improving solutions marked with [![image](../img/WA.png)](#) and [![image](../img/TLE.png)](#). Simply [Create an Issue](https://github.com/iiitv/ChefLib/issues/new) and Send a PR when assigned. 4 | 5 | ##### Here in this Table [![image](../img/CC.png)](#) links to solution on CodeChef and [![image](../img/GH.png)](#) links to solution on this repository. 6 | 7 | 8 | #### Long 9 | 10 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 11 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 12 | | [SEPT17](https://www.codechef.com/SEPT17) | [CHEFSUM](https://www.codechef.com/SEPT17/problems/CHEFSUM) | ★★ | [![image](../img/GH.png)](SEPT/SEPT17/CHEFSUM/CHEFSUM.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15287440) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](SEPT/SEPT17/CHEFSUM/CHEFSUM.java) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15197031) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](SEPT/SEPT17/CHEFSUM/CHEFSUM.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15185892) (100 pts) [![image](../img/AC.png)](#) | 13 | | [SEPT17](https://www.codechef.com/SEPT17) | [MINPERM](https://www.codechef.com/SEPT17/problems/MINPERM) | ★★ | [![image](../img/GH.png)](SEPT/SEPT17/MINPERM/MINPERM.c) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15288810) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](SEPT/SEPT17/MINPERM/MINPERM.java) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15210637) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](SEPT/SEPT17/MINPERM/MINPERM.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15236776) (100 pts) [![image](../img/AC.png)](#) | 14 | | [SEPT17](https://www.codechef.com/SEPT17) | [CHEFPDIG](https://www.codechef.com/SEPT17/problems/CHEFPDIG) | ★★★ | | [![image](../img/GH.png)](SEPT/SEPT17/CHEFPDIG/CHEFPDIG.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15187308) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](SEPT/SEPT17/CHEFPDIG/CHEFPDIG.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15339840) (100 pts) [![image](../img/AC.png)](#) | 15 | | [SEPT17](https://www.codechef.com/SEPT17) | [SEACO](https://www.codechef.com/SEPT17/problems/SEACO) | ★★★★ | | [![image](../img/GH.png)](SEPT/SEPT17/SEACO/SEACO.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15338761) (100 pts) [![image](../img/AC.png)](#) | | | 16 | | [SEPT17](https://www.codechef.com/SEPT17) | [FILLMTR](https://www.codechef.com/SEPT17/problems/FILLMTR) | ★★★★ | | [![image](../img/GH.png)](SEPT/SEPT17/FILLMTR/FILLMTR.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15243260) (100 pts) [![image](../img/AC.png)](#) | | | 17 | | [SEPT17](https://www.codechef.com/SEPT17) | [WEASELTX](https://www.codechef.com/SEPT17/problems/WEASELTX) | ★★★★★ | | | | | 18 | | [SEPT17](https://www.codechef.com/SEPT17) | [SEAFUNC](https://www.codechef.com/SEPT17/problems/SEAFUNC) | ★★★★★ | | | | | 19 | | [SEPT17](https://www.codechef.com/SEPT17) | [SUMCUBE](https://www.codechef.com/SEPT17/problems/SUMCUBE) | ★★★★★★ | | | | | 20 | | [SEPT17](https://www.codechef.com/SEPT17) | [WEASELSC](https://www.codechef.com/SEPT17/problems/WEASELSC) | ★★★★★★ | | | | | 21 | | [SEPT17](https://www.codechef.com/SEPT17) | [QGRID](https://www.codechef.com/SEPT17/problems/QGRID) | ★★★★★★★ | | | | | 22 | 23 | 24 | #### Cook-Off 25 | 26 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 27 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 28 | | [COOK86](https://www.codechef.com/COOK86) | [LIKECS01](https://www.codechef.com/COOK86/problems/LIKECS01) | ★★ | | [![image](../img/GH.png)](SEPT/COOK86/LIKECS01/LIKECS01.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15515422) (100 pts) [![image](../img/AC.png)](#) | | | 29 | | [COOK86](https://www.codechef.com/COOK86) | [LIKECS02](https://www.codechef.com/COOK86/problems/LIKECS02) | ★★★ | | [![image](../img/GH.png)](SEPT/COOK86/LIKECS02/LIKECS02.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15449918) (100 pts) [![image](../img/AC.png)](#) | | | 30 | | [COOK86](https://www.codechef.com/COOK86) | [LIKECS03](https://www.codechef.com/COOK86/problems/LIKECS03) | ★★★★ | | [![image](../img/GH.png)](SEPT/COOK86/LIKECS03/LIKECS03.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15452266) (100 pts) [![image](../img/AC.png)](#) | | | 31 | | [COOK86](https://www.codechef.com/COOK86) | [LIKECS04](https://www.codechef.com/COOK86/problems/LIKECS04) | ★★★★★ | | | | | 32 | | [COOK86](https://www.codechef.com/COOK86) | [LIKECS05](https://www.codechef.com/COOK86/problems/LIKECS05) | ★★★★★★ | | | | | 33 | 34 | 35 | #### Lunchtime 36 | 37 | | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | 38 | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| 39 | | [LTIME52](https://www.codechef.com/LTIME52) | [C00K0FF](https://www.codechef.com/LTIME52/problems/C00K0FF) | ★★★ | | [![image](../img/GH.png)](SEPT/LTIME52/C00K0FF/C00K0FF.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15560158) (100 pts) [![image](../img/AC.png)](#) | | | 40 | | [LTIME52](https://www.codechef.com/LTIME52) | [CHEFDICE](https://www.codechef.com/LTIME52/problems/CHEFDICE) | ★★★★ | | | | | 41 | | [LTIME52](https://www.codechef.com/LTIME52) | [CHEFPCHF](https://www.codechef.com/LTIME52/problems/CHEFPCHF) | ★★★★★ | | | | | 42 | | [LTIME52](https://www.codechef.com/LTIME52) | [CHEFTRAF](https://www.codechef.com/LTIME52/problems/CHEFTRAF) | ★★★★★★ | | | | | 43 | 44 | 45 | 46 | ## Eligible Contributors Rating 47 | 48 | ECR section in table above is for checking who are eligible for contributing to this Problem. 49 | This section will contain ★s which will represent CodeChef's ★ Rating. 50 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` 51 | -------------------------------------------------------------------------------- /2017/SEPT/COOK86/LIKECS01/LIKECS01.cpp: -------------------------------------------------------------------------------- 1 | // code written by heet 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int t; 9 | cin >> t; 10 | while (t--) { 11 | string s; 12 | cin >> s; 13 | int a[26] = {0}; 14 | int n = s.size(); 15 | bool isbreak = false; 16 | for (int i = 0; i < n; ++i) { 17 | a[(int)s[i] - 97]++; 18 | if(a[(int)s[i] - 97 ] == 2) { 19 | cout << "yes\n"; 20 | isbreak = true; 21 | break; 22 | } 23 | } 24 | if(!isbreak) 25 | cout << "no\n"; 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /2017/SEPT/COOK86/LIKECS02/LIKECS02.cpp: -------------------------------------------------------------------------------- 1 | // Code by nextbigthing 2 | 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | int t; 8 | cin >> t; 9 | while(t--) 10 | { 11 | long long x; 12 | cin >> x; 13 | if(x > 1) 14 | { 15 | long long y = x / 2; 16 | long long z = y + x; 17 | for(long long t = y;t < z;t++) 18 | cout << t << " "; 19 | cout << endl; 20 | } 21 | else 22 | cout << 1 << endl; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /2017/SEPT/COOK86/LIKECS03/LIKECS03.cpp: -------------------------------------------------------------------------------- 1 | //Only if a number is power of 2 and is not present, it is required to add. 2 | //Make a pattern till 12-13 and you will realize you can make all 3 | //numbers from taking bitwise or of some of numbers other than power of 2s 4 | 5 | //code copyright: Manish Kumar, E&C, IIT Roorkee 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | using namespace std; 13 | #define si(n) scanf("%d",&n) 14 | #define mem(A,i) memset(A, i, sizeof(A)) 15 | #define rep(i, start, end) for(int i=start; i=end; i--) 17 | 18 | bool powerof2(int x){ 19 | return x && (!(x&(x-1))); 20 | } 21 | 22 | int n,k; 23 | int arr[100005]; 24 | #define sz 1<<21 25 | 26 | int main(){ 27 | int t=1; 28 | si(t); 29 | while(t--){ 30 | si(n); 31 | si(k); 32 | rep(i,0,n) si(arr[i]); 33 | bool present[10 + (1 << k)]; 34 | mem(present, false); 35 | rep(i,0,n) present[arr[i]] = true; 36 | int ans = 0; 37 | rep(i,1,1< 3 | using namespace std; 4 | int main() { 5 | int t; 6 | cin >> t; 7 | while (t--) { 8 | int n; 9 | cin >> n; 10 | string s[n]; 11 | int y[5] = {0}; 12 | for (int i=0 ; i < n ; i++) { 13 | cin >> s[i]; 14 | } 15 | for (int i=0 ; i < n ; i++) { 16 | if ( s[i] == "cakewalk" ) 17 | y[0] = 1; 18 | if ( s[i] == "easy" ) 19 | y[2] = 1; 20 | if ( s[i] == "simple" ) 21 | y[1] = 1; 22 | if ( s[i] == "easy-medium" || s[i] == "medium" ) 23 | y[3] = 1; 24 | if ( s[i] == "hard" || s[i] == "medium-hard" ) 25 | y[4]=1; 26 | } 27 | int flag = 1; 28 | for (int i=0 ; i < 5 ; i++) { 29 | if(y[i] == 0) { 30 | flag = 0; 31 | break; 32 | } 33 | } 34 | if ( flag ) { 35 | cout << "Yes\n"; 36 | } 37 | else { 38 | cout << "No\n"; 39 | } 40 | } 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /2017/SEPT/SEPT17/CHEFPDIG/CHEFPDIG.cpp: -------------------------------------------------------------------------------- 1 | // Made by Piyush 2 | #include 3 | #define endl "\n" 4 | using namespace std; 5 | 6 | int main() { 7 | std::ios::sync_with_stdio(false); 8 | int testCases; 9 | cin >> testCases; 10 | while (testCases--) { 11 | string input; 12 | vector alpha(10, 0); 13 | cin >> input; 14 | for (int i = 0; i < input.length(); i++) 15 | ++alpha[input[i] - 48]; 16 | for (int i = 6; i < 10; i++) { 17 | if (alpha[i] > 0) { 18 | for (int j = 0; i < 10; j++) { 19 | char ch = i * 10 + j; 20 | if (ch >= 65 && ch <= 90) { 21 | if (j == i && alpha[j] > 1) cout << ch; 22 | if (j != i && alpha[j] > 0) cout << ch; 23 | } 24 | } 25 | } 26 | } 27 | cout << endl; 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /2017/SEPT/SEPT17/CHEFPDIG/CHEFPDIG.py: -------------------------------------------------------------------------------- 1 | # made by vanguard7 2 | 3 | 4 | def main(): 5 | t = int(input()) 6 | for i in range(t): 7 | l = list(input()) 8 | six = l.count('6') 9 | seven = l.count('7') 10 | eight = l.count('8') 11 | if six != 0: 12 | if '5' in l: 13 | print("A", end="") 14 | if six > 1: 15 | print("B", end="") 16 | if seven != 0: 17 | print("C", end="") 18 | if eight != 0: 19 | print("D", end="") 20 | if '9' in l: 21 | print("E", end="") 22 | if seven != 0: 23 | if '0' in l: 24 | print("F", end="") 25 | if '1' in l: 26 | print("G", end="") 27 | if '2' in l: 28 | print("H", end="") 29 | if '3' in l: 30 | print("I", end="") 31 | if '4' in l: 32 | print("J", end="") 33 | if '5' in l: 34 | print("K", end="") 35 | if six != 0: 36 | print("L", end="") 37 | if seven > 1: 38 | print("M", end="") 39 | if eight != 0: 40 | print("N", end="") 41 | if '9' in l: 42 | print("O", end="") 43 | if eight != 0: 44 | if '0' in l: 45 | print("P", end="") 46 | if '1' in l: 47 | print("Q", end="") 48 | if '2' in l: 49 | print("R", end="") 50 | if '3' in l: 51 | print("S", end="") 52 | if '4' in l: 53 | print("T", end="") 54 | if '5' in l: 55 | print("U", end="") 56 | if six != 0: 57 | print("V", end="") 58 | if seven != 0: 59 | print("W", end="") 60 | if eight > 1: 61 | print("X", end="") 62 | if '9' in l: 63 | print("Y", end="") 64 | if '9' in l: 65 | if '0' in l: 66 | print("Z", end="") 67 | print() 68 | 69 | 70 | if __name__ == '__main__': 71 | main() 72 | -------------------------------------------------------------------------------- /2017/SEPT/SEPT17/CHEFSUM/CHEFSUM.c: -------------------------------------------------------------------------------- 1 | //Made by Divyesh Puri 2 | #include 3 | int main(){ 4 | int t; 5 | scanf("%d", &t); 6 | while (t--){ 7 | int n, i, k = 100000, index; 8 | scanf("%d", &n); 9 | int arr[n]; 10 | for (i = 0; i < n; i++){ 11 | scanf("%d", &arr[i]); 12 | if (arr[i] < k){ 13 | k = arr[i]; 14 | index = i; 15 | } 16 | } 17 | printf("%d\n",index + 1); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /2017/SEPT/SEPT17/CHEFSUM/CHEFSUM.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class CHEFSUM { 4 | public static void main(String[] args) { 5 | Scanner inp = new Scanner(System.in); 6 | int tc = inp.nextInt(); 7 | while (tc-- != 0) { 8 | int n = inp.nextInt(); 9 | long input_array[] = new long[n]; 10 | long sub_array_sum[] = new long[n+1]; 11 | long all_sums[] = new long[n]; 12 | long total_sum = 0; 13 | for(int j = 0; j < n; j++) { 14 | input_array[j] = inp.nextInt(); 15 | total_sum += input_array[j]; 16 | sub_array_sum[j+1] = total_sum; 17 | } 18 | int min_index = 0; 19 | for(int j = 0; j < n; j++) { 20 | all_sums[j] = sub_array_sum[j+1] + (total_sum - sub_array_sum[j]); 21 | if(all_sums[min_index] > all_sums[j]) 22 | min_index = j; 23 | } 24 | System.out.println(min_index + 1); 25 | } 26 | sc.close(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /2017/SEPT/SEPT17/CHEFSUM/CHEFSUM.py: -------------------------------------------------------------------------------- 1 | # Made by Piyush 2 | def main(): 3 | testCases = int(input()) 4 | for _ in range(testCases): 5 | l = int(input()) 6 | arr = list(map(int, input().split())) 7 | print(arr.index(min(arr)) + 1) 8 | 9 | 10 | if __name__ == '__main__': 11 | main() 12 | -------------------------------------------------------------------------------- /2017/SEPT/SEPT17/FILLMTR/FILLMTR.cpp: -------------------------------------------------------------------------------- 1 | #include < bits/stdc++.h > 2 | 3 | //____By:sirjan13____ 4 | 5 | #define ll long long int 6 | #define mod 1000000007 7 | #define show(a) for(i=0;i 11 | #define vs vector 12 | #define vll vector 13 | #define pb push_back 14 | #define pi pair 15 | #define si set< int > 16 | #define sll set< ll > 17 | #define maxheap priority_queue< int > 18 | #define minheap priority_queue< int,vector< int >,greater< int > > 19 | #define mp make_pair 20 | #define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false); 21 | #define long_zero 0ll 22 | #define long_one 1ll 23 | 24 | inline int sbt(int x){return __builtin_popcount(x);} 25 | 26 | using namespace std; 27 | 28 | struct cell { 29 | int nind; 30 | int x; 31 | }; 32 | 33 | bool v[100002]; 34 | int arr[100002]; 35 | bool fff=false; 36 | 37 | vector< cell > a[100002]; 38 | 39 | void f( int p,int current ){ 40 | v[ current ]=true; 41 | for(int i=0;i> t; 61 | 62 | while ( t-- ){ 63 | memset (v, false, sizeof(v)); 64 | int n,m,r,c,va; 65 | cin >> n >>m; 66 | fff=false; 67 | memset(arr,0,sizeof(arr)); 68 | for(int i=0;i> r >> c >> va; 70 | cell nwc; 71 | nwc.nind=c; 72 | nwc.x=va; 73 | a[r].pb(nwc); 74 | cell nw2c; 75 | nw2c.x=va; 76 | nw2c.nind=r; 77 | a[c].pb(nw2c); 78 | } 79 | for(int i=1;i<=n;i++){ 80 | if(!v[i]){ 81 | f(0,i); 82 | if(fff){ 83 | break; 84 | } 85 | } 86 | } 87 | freespace(n); 88 | if(fff) 89 | cout << "no"; 90 | else 91 | cout << "yes"; 92 | cout< 3 | int main() { 4 | int t; 5 | scanf("%d", &t); 6 | while(t--) { 7 | int n; 8 | scanf("%d", &n); 9 | int arr[n + 1]; 10 | int i, j, k, l; 11 | for(i = 1; i <= n; i++){ 12 | arr[i] = i; 13 | } 14 | if (n % 2 == 0) { 15 | for(i = 1; i < n; i += 2){ 16 | int temp = arr[i]; 17 | arr[i] = arr[i + 1]; 18 | arr[i + 1] = temp; 19 | } 20 | } 21 | else { 22 | for(i = 1; i < n; i += 2){ 23 | int temp = arr[i]; 24 | arr[i] = arr[i + 1]; 25 | arr[i + 1] = temp; 26 | } 27 | j = arr[n - 1]; 28 | arr[n - 1] = arr[n]; 29 | arr[n] = j; 30 | } 31 | for(i = 1; i <= n; i++){ 32 | printf("%d ", arr[i]); 33 | } 34 | printf("\n"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /2017/SEPT/SEPT17/MINPERM/MINPERM.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class MINPERM { 4 | public static void main(String[] args) { 5 | Scanner inp = new Scanner(System.in); 6 | int tc = inp.nextInt(); 7 | while (tc-- != 0) { 8 | int n = inp.nextInt(); 9 | int final_array[] = new int[n]; 10 | for(int j=0; j 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | #define ll long long 10 | #define si(n) scanf("%d",&n) 11 | #define sll(n) scanf("%lld",&n) 12 | #define pin(n) printf("%d\n",n) 13 | #define mem(A,i) memset(A, i, sizeof(A)) 14 | #define plln(n) printf("%lld\n",n) 15 | #define pis(n) printf("%d ",n) 16 | #define plls(n) printf("%lld ",n) 17 | #define rep(i, start, end) for(int i=start; i 21 | #define PP pair 22 | #define mod 1000000007 23 | #define MAX 100005 24 | #define s second 25 | #define f first 26 | #define newLine printf("\n") 27 | ll n,m; 28 | pair > arr[MAX]; 29 | ll ADD[MAX]; 30 | ll SUB[MAX]; 31 | ll A[MAX]; 32 | ll C; 33 | 34 | ll add(ll &x, ll y){ 35 | x = (x + y) % mod; 36 | if(x < 0) x += mod; 37 | return x; 38 | } 39 | 40 | int main() 41 | { 42 | int t; 43 | si(t); 44 | while(t--){ 45 | sll(n); sll(m); 46 | mem(ADD, 0); 47 | mem(SUB, 0); 48 | mem(A, 0); 49 | C = 1; 50 | rep(i, 0, m){ 51 | si(arr[i].f); 52 | sll(arr[i].s.f); 53 | sll(arr[i].s.s); 54 | arr[i].s.f -= 1; 55 | arr[i].s.s -= 1; 56 | } 57 | for(int i = m-1; i >= 0; i--){ 58 | add(C, ADD[i]); 59 | add(C, -1LL*SUB[i]); 60 | ADD[i] = C; 61 | if(arr[i].f == 2){ 62 | if(arr[i].s.f > 0) add(SUB[arr[i].s.f-1], C); 63 | add(ADD[arr[i].s.s], C); 64 | } 65 | } 66 | mem(SUB, 0); 67 | rep(i, 0, m) 68 | if(arr[i].f == 1){ 69 | if(arr[i].s.s < (n-1)) add(SUB[arr[i].s.s+1],ADD[i]); 70 | add(A[arr[i].s.f],ADD[i]); 71 | } 72 | C = 0; 73 | rep(i, 0, n){ 74 | add(C, A[i]); 75 | add(C, -1*SUB[i]); 76 | A[i] = C; 77 | } 78 | rep(i,0,n) plls(A[i]); 79 | newLine; 80 | } 81 | return 0; 82 | 83 | } 84 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | cheflib.co -------------------------------------------------------------------------------- /CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at `admin@cheflib.co`. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## How to contribute? 2 | 3 | * Have a look at the table in README.md. It contain the list of codes solved by people in CodeChef's rated contests. 4 | * Find a code for which an entry which is not yet added create an issue for it. 5 | * Make sure you are assigned for the issue before sending the PR. 6 | * Code added should follow the standard guidelines of that language, untidy codes will not be accepted. 7 | * Send a PR. 8 | * Make sure that you only send the source code not the binaries and executables in PR. 9 | * While sending a PR make sure you follow one issue per PR rule. 10 | * Link to your solution on CodeChef is mandatory. 11 | 12 | 13 | 14 | 15 | ## Code Styleguide 16 | 17 | * Code submitted should be modular. 18 | * Add the code in their respective directory only. 19 | * Filename should be same as that of the problem code. 20 | * Currently we are accepting contributions in C, C++, Java and Python but other languages may be considered after a discussion. 21 | * Meaningful comments to explain your code better are welcomed. 22 | * No profanity. 23 | * We have defined [skeleton codes](#samples) for some popular languages below. Please follow them whenever possible. 24 | * Sample skeleton codes are for showing guidelines and indentations only. 25 | 26 | 27 | 28 | 29 | ## Improving a Dish 30 | 31 | * If you feel you can improve upon any added code, feel free to open an issue discussing the improvements. 32 | * The points to be considered for improvement will be the time required by code to pass testcases, easy explanation, etc. 33 | 34 | 35 | 36 | ## Samples 37 | 38 | #### C 39 | 40 | ```c 41 | int main() { 42 | int tc; 43 | scanf("%d", &tc); 44 | while (tc--) { 45 | /* 46 | your code here; 47 | */ 48 | } 49 | } 50 | ``` 51 | 52 | #### C++ 53 | 54 | ```c++ 55 | int main() { 56 | int tc; 57 | cin >> tc; 58 | while (tc--) { 59 | /* 60 | your code here; 61 | */ 62 | } 63 | } 64 | ``` 65 | 66 | #### Python 67 | ```python 68 | def main(): 69 | tc = int(input()) 70 | while tc > 0: 71 | Your Dish here... 72 | tc -= 1 73 | 74 | if __name__ == '__main__': 75 | main() 76 | ``` 77 | 78 | #### Java 79 | ```java 80 | public static void main(String[] args) { 81 | Scanner inp = new Scanner(System.in); 82 | int tc = inp.nextInt(); 83 | while (tc-- != 0) { 84 | Your code goes here... 85 | } 86 | } 87 | } 88 | ``` 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ChefLib 2 | 3 | [![Build Status](https://travis-ci.org/iiitv/ChefLib.svg?branch=master)](https://travis-ci.org/iiitv/ChefLib) 4 | [![Join the chat at https://gitter.im/iiitv/ChefLib](https://badges.gitter.im/iiitv/ChefLib.svg)](https://gitter.im/iiitv/ChefLib?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 5 | [![GitHub issues](https://img.shields.io/github/issues/iiitv/ChefLib.svg)](https://github.com/iiitv/ChefLib/issues) 6 | [![Contributions Welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/iiitv/ChefLib/issues) 7 | [![Contributors](https://img.shields.io/github/contributors/iiitv/ChefLib.svg)](https://github.com/iiitv/ChefLib/graphs/contributors) 8 | [![Code Climate](https://codeclimate.com/github/iiitv/ChefLib/badges/gpa.svg)](https://codeclimate.com/github/iiitv/ChefLib) 9 | 10 | ### Library of Sweet Dishes (codes) by Chefs (Coders). 11 | 12 | This repository is collection of CodeChef Contest Solutions. 13 | This is for educational purpose. This may help you to understand problems in better way, and since not all solutions on this repository are AC ![image](img/AC.png) , you can suggest changes by opening an Issue and Send a PR. 14 | You can Discuss about problems (not ones in LIVE contest) at our [Gitter Channel](https://gitter.im/iiitv/ChefLib) 15 | 16 | ## Index Of Dishes 17 | 18 | #### This is Month Wise Index Of Problem. 19 | 20 | 21 | | Month | Long | Cook-Off | Lunchtime | 22 | |:-----------------:|:-----------------:|:-----------------:|:-----------------:| 23 | | [December 2016](2016/DEC.md) | [![image](img/AC.png)](2016/DEC.md#long) | COOK77 [![image](img/AC.png)](2016/DEC.md#cook) | LTIME43 [![image](img/AC.png)](2016/DEC.md#ltime) | 24 | | [January 2017](2017/JAN.md) | [![image](img/AC.png)](2017/JAN.md#long) | COOK78 [![image](img/AC.png)](2017/JAN.md#cook) | LTIME44 [![image](img/AC.png)](2017/JAN.md#ltime) | 25 | | [February 2017](2017/FEB.md) | [![image](img/AC.png)](2017/FEB.md#long) | COOK79 [![image](img/AC.png)](2017/FEB.md#cook) | LTIME45 [![image](img/AC.png)](2017/FEB.md#ltime) | 26 | | [March 2017](2017/MAR.md) | [![image](img/AC.png)](2017/MAR.md#long) | COOK80 [![image](img/AC.png)](2017/MAR.md#cook) | LTIME46 [![image](img/AC.png)](2017/MAR.md#ltime) | 27 | | [April 2017](2017/APR.md) | [![image](img/AC.png)](2017/APR.md#long) | COOK81 [![image](img/AC.png)](2017/APR.md#cook) | LTIME47 [![image](img/AC.png)](2017/APR.md#ltime) | 28 | | [May 2017](2017/MAY.md) | [![image](img/AC.png)](2017/MAY.md#long) | COOK82 [![image](img/AC.png)](2017/MAY.md#cook) | `Unrated` | 29 | | [June 2017](2017/JUN.md) | [![image](img/AC.png)](2017/JUN.md#long) | COOK83 [![image](img/AC.png)](2017/JUN.md#cook) | LTIME49 [![image](img/AC.png)](2017/JUN.md#ltime) | 30 | | [July 2017](2017/JULY.md) | [![image](img/AC.png)](2017/JULY.md#long) | `Unrated` | LTIME50 [![image](img/AC.png)](2017/JULY.md#ltime) | 31 | | [August 2017](2017/AUG.md) | [![image](img/AC.png)](2017/AUG.md#long) | COOK85 [![image](img/AC.png)](2017/AUG.md#cook) | LTIME51 [![image](img/AC.png)](2017/AUG.md#ltime) | 32 | | [September 2017](2017/SEPT.md) | [![image](img/AC.png)](2017/SEPT.md#long) | COOK85 [![image](img/AC.png)](2017/SEPT.md#cook) | LTIME52 [![image](img/AC.png)](2017/SEPT.md#ltime) | 33 | | [October 2017](2017/OCT.md) | [![image](img/AC.png)](2017/OCT.md#long) | COOK86 [![image](img/AC.png)](2017/OCT.md#cook) | LTIME53 [![image](img/AC.png)](2017/OCT.md#ltime) | 34 | 35 | 36 | ## Eligible Contributors Rating 37 | 38 | ECR section in table above is for checking who are eligible for contributing to this Problem. 39 | This section will contain ★s which will represent CodeChef's ★ Rating. 40 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.` 41 | 42 | ## Merging Policy 43 | * Everyone should follow one commit per PR. 44 | * The first Commit message should be like: 45 | ``` 46 | Added {Problem name} in {Contest name with year} [Lang] 47 | Fixes #{issue number} 48 | ``` 49 | Rest of commit messages should reflect the changes done in respective commit. 50 | 51 | ## Contributing 52 | #### It is advised to first read how to contribute to this repository before [creating an issue](https://github.com/iiitv/ChefLib/issues/new). 53 | See [CONTRIBUTING.md](https://github.com/iiitv/ChefLib/blob/master/CONTRIBUTING.md). 54 | 55 | ## Adding Entry to month README 56 | #### If you are confused over how to add an entry to the month's README you can always read [this](.github/ADD_ME_IN_README.md) 57 | 58 | ## Project Maintainers 59 | 60 | * [Aashutosh Rathi](https://github.com/aashutoshrathi) 61 | * [Monal Shadi](https://github.com/Monal5031) 62 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-leap-day -------------------------------------------------------------------------------- /img/AC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/AC.png -------------------------------------------------------------------------------- /img/CC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/CC.png -------------------------------------------------------------------------------- /img/GH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/GH.png -------------------------------------------------------------------------------- /img/RE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/RE.png -------------------------------------------------------------------------------- /img/TLE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/TLE.png -------------------------------------------------------------------------------- /img/WA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/WA.png --------------------------------------------------------------------------------