├── .gitattributes ├── Aug21 Cook Off └── Which Division.cpp ├── Aug21 Long ├── Array Filling.cpp ├── Chef and Bulb Invention.cpp ├── Olympics Ranking.cpp ├── Problem Difficulties.cpp └── Special Triplets.cpp ├── Aug21 Lunch Time ├── K-th Maximum.cpp ├── Maximum Length Even Subarray.cpp └── Programming Languages.cpp ├── July21 Cook Off └── Shoe Fit.cpp ├── July21 Lunch Time ├── Chef and Spells.cpp └── Red Alert.cpp ├── July22 Long ├── Bidding.cpp ├── Chef and Candies.cpp └── Pass the Exam.cpp ├── Jun22 Long └── Fitness.cpp ├── June21 Long ├── Bella Ciao.cpp ├── Bitwise Tuples.cpp └── Summer Heat.cpp ├── Mar22 Long └── Wordle.cpp ├── May 22 Long Two └── Practice makes us perfect.cpp ├── May21 Long ├── Golf.cpp ├── Solubility.cpp ├── Tic Tac Toe.cpp └── XOR Equality.cpp ├── May21 Lunch Time ├── Birthday Gifts.cpp ├── Hoop Jump.cpp └── Tom and Jerry 1.cpp ├── May22 Lunch Time └── Bucket and Water Flow.cpp ├── Practice └── Beginner │ ├── ATM.cpp │ ├── Add Two Numbers.cpp │ ├── Chef And Operators.cpp │ ├── Chef and Remissness.cpp │ ├── Ciel and Receipt.cpp │ ├── Decrement OR Increment.cpp │ ├── Enormous Input Test.cpp │ ├── Find Remainder.cpp │ ├── Finding Square Roots.cpp │ ├── First and Last Digit.cpp │ ├── GCD and LCM.cpp │ ├── Gross Salary.cpp │ ├── Helping Chef.cpp │ ├── Id and Ship.cpp │ ├── Lucky Four.cpp │ ├── Mahasena.cpp │ ├── Number Mirror.cpp │ ├── Packaging Cupcakes.cpp │ ├── Primality Test.cpp │ ├── Puppy and Sum.cpp │ ├── Reverse The Number.cpp │ ├── Second Largest.cpp │ ├── Small Factorial.cpp │ ├── Smallest Numbers of Notes.cpp │ ├── Sum OR Difference.cpp │ ├── Sum of Digits.cpp │ ├── The Block Game.cpp │ ├── Total Expenses.cpp │ ├── Turbo Sort.cpp │ └── Valid Triangles.cpp ├── README.md ├── Starters 10 ├── Hardest Problem Bet.cpp └── Odd Repeat.cpp ├── Starters 11 └── Find the Direction.cpp ├── Starters 29 ├── Fill the bucket.cpp └── Tyre problem.cpp ├── Starters 33 ├── Minimum Cars required.cpp ├── Monthly Budget.cpp └── The Cheaper Cab.cpp ├── Starters 36 └── Presents for Cheffina.cpp ├── Starters 38 ├── Chef gives Party.cpp └── Get Subscription.cpp ├── Starters 4 ├── Correct Sentence.cpp ├── Lazy Chef.cpp └── Plagiarism.cpp ├── Starters 42 └── Age Limit.cpp ├── Starters 43 ├── Burgers.cpp └── Waiting Time.cpp ├── Starters 44 ├── Air Hockey.cpp └── Biryani.cpp ├── Starters 47 ├── Chef On Date.cpp ├── Chess Time.cpp ├── Construct N.cpp └── Minimum Coins.cpp ├── Starters 51 └── Final Population.cpp ├── Starters 52 └── AI Analysing Code.cpp ├── Starters 53 ├── Car Trip.cpp └── Greater Average.cpp ├── Starters 54 ├── Number of Credits.cpp └── Ticket Fine.cpp ├── Starters 55 └── Fever.cpp ├── Starters 56 └── Chefland Games.cpp ├── Starters 57 ├── Alice and Marks.cpp └── Integers that sum to the same value.cpp ├── Starters 58 ├── Ranklist Pages.cpp ├── Reach the Target.cpp └── Remove Bad elements.cpp ├── Starters 59 ├── Audible Range.cpp ├── Chef and Happy String.cpp └── Speciality.cpp ├── Starters 6 ├── Cricket Ranking.cpp ├── Joker and Batman.cpp └── Three Dices.cpp ├── Starters 60 ├── Card Removal.cpp ├── Expert Setter.cpp ├── Palindrome Flipping.cpp ├── Paper Cutting.cpp └── Tax in Chefland.cpp ├── Starters 61 ├── Different Consecutive Characters.cpp ├── Minimise LCS.cpp ├── Odd Sum Pair.cpp ├── Reach on Time.cpp └── Subarray Removal.cpp ├── Starters 62 ├── Man minus Min.cpp ├── Test Score.cpp └── X Jumps.cpp ├── Starters 63 ├── Packing Books.cpp └── Tasty Decisions.cpp ├── Starters 64 ├── Distinct Colors.cpp └── Water Consumption.cpp ├── Starters 65 ├── Hackerman.cpp └── Parity.cpp ├── Starters 66 ├── Monopoly in Chefland.cpp └── Squats.cpp ├── Starters 67 └── Tour of King.cpp ├── Starters 68 ├── Bull or Bear.cpp └── Make AP.cpp ├── Starters 69 ├── Rain in Chefland.cpp └── Scalene Triangle.cpp ├── Starters 70 ├── Cost of Groceries.cpp ├── Kitchen Timings.cpp └── Spice Level.cpp ├── Starters 71 ├── Instagram.cpp ├── Perfect Trio.cpp └── Snapchat.cpp ├── Starters 72 ├── Indivisible.cpp └── Sum it.cpp ├── Starters 74 └── Mana Points.cpp ├── Starters 75 ├── Profit Increment.cpp ├── Saving Taxes.cpp ├── Three Powers of Two.cpp └── Two Ranges.cpp ├── Starters 76 ├── 400M Race.cpp └── Read Pages.cpp ├── Starters 77 ├── Codechef Airlines.cpp └── Tom and Jerry Chase.cpp ├── Starters 78 ├── Candy Store.cpp └── Good Turn.cpp ├── Starters 79 ├── Ageing.cpp ├── Better Deal.cpp └── Distinct Opposite Sums.cpp ├── Starters 8 ├── Javelin Qualification.cpp └── Penalty.cpp ├── Starters 80 ├── Just One More Episode.cpp ├── Running Comparison.cpp └── Single-use Attack.cpp ├── Starters 81 ├── Maximum Capacity.cpp └── Sunny Day.cpp ├── Starters 82 ├── Candy Division.cpp └── Reach Home.cpp ├── Starters 83 ├── Budget of Technex.cpp ├── Chef Eren.cpp ├── Construct String.cpp └── Couple Game.cpp ├── Starters 84 ├── Chef and Donation.cpp ├── Elections in Chefland.cpp └── Melt Gold.cpp ├── Starters 85 ├── Can Chef.cpp └── IPL Ticket Rush.cpp ├── Starters 86 ├── CodeChef Learn Problem Solving.cpp └── Cricket Match.cpp └── Starters 9 ├── Black cells in a chessboard.cpp ├── Bus full of passengers.cpp ├── Friend Groups In A Line.cpp └── Large Square.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Aug21 Cook Off/Which Division.cpp: -------------------------------------------------------------------------------- 1 | https://www.codechef.com/COOK132C/problems/WHICHDIV 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int r; 6 | cin>>r; 7 | if(r>=2000) 8 | cout<<"1"<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Aug21 Long/Array Filling.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/AUG21C/problems/ARRFILL 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | 6 | bool comp(pairx,pairy) 7 | { 8 | if(x.first!=y.first) 9 | return x.first>y.first; 10 | else 11 | return x.second>y.second; 12 | } 13 | int main() 14 | { 15 | ios::sync_with_stdio(0); 16 | cin.tie(0); 17 | int t; 18 | cin>>t; 19 | while(t--){ 20 | ll n,m,x,y; 21 | vector> v; 22 | cin>>n>>m; 23 | for(ll i=0;i>x>>y; 26 | v.push_back(make_pair(x,y)); 27 | 28 | } 29 | sort(v.begin(),v.end(),comp); 30 | ll k=1,p=n; 31 | ll res=0; 32 | for(int i=0;i0;i++) 33 | { 34 | ll f=v[i].first; 35 | ll s=v[i].second; 36 | k=(k*s)/(__gcd(k,s)); 37 | res+=f*(n-p/k); 38 | n=p/k; 39 | 40 | } 41 | cout< 4 | using namespace std; 5 | void solve(){ 6 | long long int n,p,k,j=0,c=0; 7 | cin>>n>>p>>k; 8 | for(int i=0;i>t; 24 | while(t--) 25 | solve(); 26 | return 0; 27 | }*/ 28 | 29 | #include 30 | using namespace std; 31 | void solve(){ 32 | long long int n,p,k,rem=0,res=0,sum=0; 33 | cin>>n>>p>>k; 34 | rem=p%k; 35 | rem=rem-1; 36 | sum=((n-1)/k)*k; 37 | sum=n-1-sum; 38 | if(rem<=sum) 39 | { 40 | res=res+((n-1)/k+1)*(rem+1); 41 | } 42 | else 43 | { 44 | res=res+(sum+1)*((n-1)/k+1)+(rem-sum)*((n-1)/k); 45 | } 46 | for(int i=rem+1;i>t; 61 | while(t--) 62 | solve(); 63 | return 0; 64 | } -------------------------------------------------------------------------------- /Aug21 Long/Olympics Ranking.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/AUG21C/problems/OLYRANK/ 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int g1,s1,b1,g2,s2,b2; 6 | cin>>g1>>s1>>b1>>g2>>s2>>b2; 7 | if((g1+s1+b1)>(g2+s2+b2)) 8 | cout<<"1"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Aug21 Long/Problem Difficulties.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/AUG21C/problems/PROBDIFF 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int arr[4],c=0,t; 7 | for(int i=0;i<4;i++) 8 | cin>>arr[i]; 9 | sort(arr,arr+4); 10 | for(int j=1;j<4;j++) 11 | { 12 | if(arr[j]!=arr[j-1]) 13 | { 14 | c++; 15 | t=j; 16 | } 17 | } 18 | 19 | if(t==2&&c==1) 20 | cout<<2<=2) 22 | cout<<2<>t; 35 | while(t--) 36 | solve(); 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Aug21 Long/Special Triplets.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/AUG21C/problems/SPCTRIPS 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int num,co=0; 6 | cin>>num; 7 | for(int c=1;c<=num;c++) 8 | { 9 | for(int b=c;b<=num;b=b+c) 10 | { 11 | for(int a=c;a<=num;a=a+b) 12 | { 13 | if(a%b==c) 14 | co++; 15 | } 16 | } 17 | } 18 | cout<>t; 26 | while(t--) 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Aug21 Lunch Time/K-th Maximum.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/LTIME99B/problems/KMAX2 2 | #include 3 | using namespace std; 4 | #define ll long long int 5 | void solve() 6 | { 7 | ll n,k; 8 | cin>>n>>k; 9 | ll a[n],m1=0; 10 | for (ll i = 0; i < n; ++i) 11 | { 12 | cin>>a[i]; 13 | m1=max(m1,a[i]); 14 | } 15 | ll s=0; 16 | for (ll i = k-1; i < n; ++i) 17 | { 18 | if(a[i]==m1) 19 | s=s+(n-i); 20 | } 21 | cout<>t; 29 | while(t--) 30 | solve(); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Aug21 Lunch Time/Maximum Length Even Subarray.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/LTIME99C/problems/MXEVNSUB 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n,s=0; 7 | cin>>n; 8 | int num=n; 9 | while(n) 10 | { 11 | s+=n; 12 | n-=1; 13 | } 14 | if(s%2==0) 15 | cout<>t; 25 | while(t--) 26 | solve(); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /Aug21 Lunch Time/Programming Languages.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/LTIME99C/problems/PROGLANG 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int a,b,a1,b1,a2,b2; 7 | cin>>a>>b>>a1>>b1>>a2>>b2; 8 | if((a==a1 || a==b1)&&(b==a1 || b==b1)) 9 | cout<<"1"<>t; 21 | while(t--) 22 | solve(); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /July21 Cook Off/Shoe Fit.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/COOK131C/problems/SHOEFIT 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a,b,c; 6 | cin>>a>>b>>c; 7 | if(a==0&&b==0&&c==0) 8 | cout<<0<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /July21 Lunch Time/Chef and Spells.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/LTIME98C/problems/CHFSPL 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a[3]; 6 | for (int i = 0; i < 3; ++i) 7 | {cin>>a[i]; 8 | }sort(a,a+3); 9 | cout<<(a[2]+a[1])<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /July21 Lunch Time/Red Alert.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/LTIME98C/problems/REDALERT 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,d,h,s=0,flag=0; 6 | cin>>n>>d>>h; 7 | int a[n]; 8 | for(int i=0;i>a[i]; 11 | } 12 | for(int i=0;i0) 15 | s=s+a[i]; 16 | else 17 | { 18 | if(sh) 24 | {flag=1;break;} 25 | } 26 | if(flag==1) 27 | cout<<"YES"<>t; 37 | while(t--) 38 | solve(); 39 | return 0; 40 | } -------------------------------------------------------------------------------- /July22 Long/Bidding.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/JULY221D/problems/AUCTION 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a,b,c; 6 | cin>>a>>b>>c; 7 | if(max(a,max(b,c))==a) 8 | cout<<"Alice"<>t; 21 | while(t--) 22 | solve(); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /July22 Long/Chef and Candies.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/JULY221D/problems/CHEFCAND 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,x; 6 | cin>>n>>x; 7 | if(n<=x) cout<<0<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /July22 Long/Pass the Exam.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/JULY221D/problems/PASSTHEEXAM 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a,b,c; 6 | cin>>a>>b>>c; 7 | if(((a+b+c)>=100) && a>=10 && b>=10 && c>=10) 8 | cout<<"PASS"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Jun22 Long/Fitness.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/submit/FIT 2 | //Fitness 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | cout<<5*2*x<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /June21 Long/Bella Ciao.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/JUNE21C/problems/CHFHEIST 2 | #include 3 | using namespace std; 4 | 5 | void solve(){ 6 | long long D,d,P,Q,sum=0; 7 | cin>>D>>d>>P>>Q; 8 | long r=D/d,s=D%d; 9 | sum=D*P+d*Q*((r*(r-1))/2)+r*s*Q; 10 | cout<>t; 17 | while(t--) 18 | { 19 | solve(); 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /June21 Long/Bitwise Tuples.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/JUNE21C/problems/BITTUP 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | long long M =1000000007; 6 | ll p( ll a, ll b ) 7 | { 8 | ll ans=1; 9 | while(b){ 10 | if(b%2==1){ans=ans*a%M;} 11 | a=a*a%M; 12 | b=b/2; 13 | } 14 | return ans; 15 | } 16 | void solve(){ 17 | ll n,m,res; 18 | cin>>n>>m; 19 | res=p(2,n)-1; 20 | res=p(res,m); 21 | cout<>t; 28 | while(t--) 29 | { 30 | solve(); 31 | } 32 | return 0; 33 | } 34 | 35 | 36 | /*ANOTHER SOLUTION 37 | #include 38 | #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 39 | #define MOD 1000000007 40 | #define all(z) z.begin(),z.end() 41 | using ll = long long int; 42 | 43 | using namespace std; 44 | 45 | ll getPower(ll a, ll b) { 46 | static ll mod = 1000000007; 47 | if (b == 0) return 1; 48 | if (b == 1) return a; 49 | 50 | if (b % 2 == 0) { 51 | ll ans = getPower(a, b / 2); 52 | return (ans * ans) % mod; 53 | } 54 | else { 55 | ll ans = getPower(a, ((b - 1) / 2)); 56 | return ((a * ans) % mod * ans) % mod; 57 | } 58 | } 59 | 60 | int main() { 61 | fast; 62 | int test; 63 | cin >> test; 64 | while (test--) { 65 | 66 | ll a, b, temp; 67 | cin >> a >> b; 68 | 69 | temp = getPower(2 , a) - 1; 70 | 71 | cout << getPower(temp, b) << endl; 72 | 73 | } 74 | 75 | return 0; 76 | } -------------------------------------------------------------------------------- /June21 Long/Summer Heat.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/JUNE21C/problems/COCONUT 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int xa,xb,Xa,Xb; 6 | cin>>xa>>xb>>Xa>>Xb; 7 | cout<<(Xa/xa)+(Xb/xb)<<"\n"; 8 | } 9 | int main(){ 10 | ios::sync_with_stdio(0); 11 | cin.tie(0); 12 | int t; 13 | cin>>t; 14 | while(t--){ 15 | solve(); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Mar22 Long/Wordle.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/WORDLE 2 | 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | string s1,s2,s3; 7 | cin>>s1>>s2; 8 | for(int i=0;i>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /May 22 Long Two/Practice makes us perfect.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/PRACTICEPERF 2 | //Practice makes us perfect 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,b,c,d,c0=0; 7 | cin>>a>>b>>c>>d; 8 | if(a>=10)c0++; 9 | if(b>=10)c0++; 10 | if(c>=10)c0++; 11 | if(d>=10)c0++; 12 | cout<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /May21 Long/Golf.cpp: -------------------------------------------------------------------------------- 1 | https://www.codechef.com/MAY21C/problems/LKDNGOLF/ 2 | #include 3 | using namespace std; 4 | 5 | void solve(){ 6 | int x,n,k; 7 | cin>>n>>x>>k; 8 | if(x%k==0) 9 | cout<<"YES"<<"\n"; 10 | else if((x%k)==((n+1)%k)) 11 | cout<<"YES"<<"\n"; 12 | else 13 | cout<<"NO"<<"\n"; 14 | } 15 | int main(){ 16 | ios::sync_with_stdio(0); 17 | cin.tie(0); 18 | int t; 19 | cin>>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /May21 Long/Solubility.cpp: -------------------------------------------------------------------------------- 1 | https://www.codechef.com/MAY21C/problems/SOLBLTY/ 2 | #include 3 | using namespace std; 4 | 5 | void solve(){ 6 | int a,b,c,res; 7 | cin>>a>>b>>c; 8 | res=(b+(100-a)*c)*10; 9 | cout<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /May21 Long/Tic Tac Toe.cpp: -------------------------------------------------------------------------------- 1 | https://www.codechef.com/MAY21C/problems/TCTCTOE/ 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | string s,s1,s2; 6 | int co=0,cx=0,cd=0,o=0,x=0; 7 | cin>>s>>s1>>s2; 8 | for(int j=0;j<3;j++) 9 | { 10 | cx=cx+(s[j]=='X')+(s1[j]=='X')+(s2[j]=='X'); 11 | co=co+(s[j]=='O')+(s1[j]=='O')+(s2[j]=='O'); 12 | }cd=9-(co+cx); 13 | if(s[0]=='O'&&s1[0]=='O'&&s2[0]=='O') 14 | o++; 15 | if(s[1]=='O'&&s1[1]=='O'&&s2[1]=='O') 16 | o++; 17 | if(s[2]=='O'&&s1[2]=='O'&&s2[2]=='O') 18 | o++; 19 | if(s[0]=='X'&&s1[0]=='X'&&s2[0]=='X') 20 | x++; 21 | if(s[1]=='X'&&s1[1]=='X'&&s2[1]=='X') 22 | x++; 23 | if(s[2]=='X'&&s1[2]=='X'&&s2[2]=='X') 24 | x++; 25 | if(s[0]=='X'&&s1[1]=='X'&&s2[2]=='X') 26 | x++; 27 | if(s[0]=='O'&&s1[1]=='O'&&s2[2]=='O') 28 | o++; 29 | if(s[2]=='X'&&s1[1]=='X'&&s2[0]=='X') 30 | x++; 31 | if(s[2]=='O'&&s1[1]=='O'&&s2[0]=='O') 32 | o++; 33 | if(s[0]=='X'&&s[1]=='X'&&s[2]=='X') 34 | x++; 35 | if(s1[0]=='X'&&s1[1]=='X'&&s1[2]=='X') 36 | x++; 37 | if(s2[0]=='X'&&s2[1]=='X'&&s2[2]=='X') 38 | x++; 39 | if(s[0]=='O'&&s[1]=='O'&&s[2]=='O') 40 | o++; 41 | if(s1[0]=='O'&&s1[1]=='O'&&s1[2]=='O') 42 | o++; 43 | if(s2[0]=='O'&&s2[1]=='O'&&s2[2]=='O') 44 | o++; 45 | if((o>0&&x>0)||(cx-co)>1||(cx-co)<0) 46 | { 47 | cout<<"3"<0) 56 | { 57 | cout<<"2"<0&&o==0&&cx>co) 61 | { 62 | cout<<"1"<0&&cx==co) 66 | { 67 | cout<<"1"<>t; 83 | while(t--) 84 | solve(); 85 | return 0;} -------------------------------------------------------------------------------- /May21 Long/XOR Equality.cpp: -------------------------------------------------------------------------------- 1 | https://www.codechef.com/MAY21C/problems/XOREQUAL/ 2 | #include 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | const unsigned int M = 1000000007; 8 | long long n,flag=1; 9 | unsigned long long y=2; 10 | cin>>n; 11 | int z=n-1; 12 | y=y%M; 13 | if(y==0) 14 | { 15 | cout<<0<>t; 34 | while(t--) 35 | solve(); 36 | return 0; 37 | } -------------------------------------------------------------------------------- /May21 Lunch Time/Birthday Gifts.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/LTIME96C/problems/TWINGFT 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | long long n,k,i=0,c=0,t=0; 6 | cin>>n>>k; 7 | long long a[n]; 8 | for(i=0;i>a[i]; 11 | } 12 | sort(a,a+n); 13 | for( i=0;i>t; 26 | while(t--){ 27 | solve(); 28 | cout< 3 | using namespace std; 4 | void solve(){ 5 | long long n,res; 6 | cin>>n; 7 | res=(n+1)/2; 8 | cout<>t; 15 | while(t--){ 16 | solve(); 17 | cout< 3 | using namespace std; 4 | void solve(){ 5 | long long n,k,a,b,x,res; 6 | cin>>n>>k>>a>>b>>x; 7 | res=abs(k-b)+abs(n-a); 8 | if(res>x){cout<<"NO"<<"\n";return;} 9 | if(res==x){ 10 | cout<<"YES"<<"\n"; 11 | return; 12 | } 13 | if((x-res)%2==0){cout<<"YES"<<"\n";return;} 14 | cout<<"NO"<<"\n"; 15 | } 16 | 17 | int main(){ 18 | ios_base::sync_with_stdio(0); 19 | cin.tie(0); cout.tie(0); 20 | long long t; 21 | cin>>t; 22 | while(t--) 23 | { 24 | solve(); 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /May22 Lunch Time/Bucket and Water Flow.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/WATERFLOW 2 | //Bucket and Water Flow 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int w,x,y,z; 7 | cin>>w>>x>>y>>z; 8 | if((w+(y*z))>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Practice/Beginner/ATM.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/HS08TEST 2 | #include 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int x; 8 | double y; 9 | cin>>x>>y; 10 | if((x%5==0) && (y-x-0.5)>=0) 11 | cout<>t; 21 | while(t--) 22 | solve(); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /Practice/Beginner/Add Two Numbers.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW001 2 | #include 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | int a,b; 8 | cin>>a>>b; 9 | cout<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Practice/Beginner/Chef And Operators.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CHOPRT 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int a,b; 7 | cin>>a>>b; 8 | if(a>b) 9 | cout<<">"<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Practice/Beginner/Ciel and Receipt.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CIELRCPT 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int p,val=2048,res=0; 7 | cin>>p; 8 | while(p>0) 9 | { 10 | res=res+p/val; 11 | p=p%val; 12 | val=val/2; 13 | } 14 | cout<>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Practice/Beginner/Decrement OR Increment.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/DECINC 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n; 7 | cin>>n; 8 | if(n%4==0) 9 | cout<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /Practice/Beginner/Enormous Input Test.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/INTEST 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | long long int n,k,c=0; 7 | cin>>n>>k; 8 | for (long long int i = 0; i < n; ++i) 9 | { 10 | long long int x; 11 | cin>>x; 12 | if(x%k==0) 13 | c++; 14 | } 15 | cout<>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Practice/Beginner/Find Remainder.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW002 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int a,b; 7 | cin>>a>>b; 8 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Practice/Beginner/Finding Square Roots.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FSQRT 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n; 7 | cin>>n; 8 | cout<<(int)sqrt(n)<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Practice/Beginner/First and Last Digit.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW004 2 | #include 3 | using namespace std; 4 | 5 | void solve() 6 | { 7 | long long n,rl,r; 8 | cin>>n; 9 | rl=n%10; 10 | while(n) 11 | { 12 | r=n%10; 13 | n=n/10; 14 | } 15 | cout<>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Practice/Beginner/GCD and LCM.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW016 2 | #include 3 | using namespace std; 4 | #define ll long long 5 | ll gcd(ll a,ll b) 6 | { 7 | if(a==0) 8 | return b; 9 | return gcd(b%a,a); 10 | } 11 | void solve() 12 | { 13 | ll a,b; 14 | cin>>a>>b; 15 | cout<>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Practice/Beginner/Gross Salary.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW011 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | double s,hra,da; 7 | cin>>s; 8 | if(s<1500) 9 | { 10 | hra=0.1*s; 11 | da=0.9*s; 12 | } 13 | else 14 | { 15 | hra=500; 16 | da=0.98*s; 17 | } 18 | cout<>t; 26 | while(t--) 27 | solve(); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Practice/Beginner/Helping Chef.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW008 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n; 7 | cin>>n; 8 | if(n<10) 9 | cout<<"Thanks for helping Chef!"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /Practice/Beginner/Id and Ship.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/submit/FLOW010 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | char s; 7 | cin>>s; 8 | if(s=='B' || s=='b') 9 | cout<<"BattleShip"<>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Practice/Beginner/Lucky Four.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/LUCKFOUR 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int c=0; 7 | string s; 8 | cin>>s; 9 | for (int i = 0; i < s.length(); ++i) 10 | { 11 | if(s[i]=='4') 12 | c++; 13 | } 14 | cout<>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Practice/Beginner/Mahasena.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/AMR15A 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n,e=0,o=0; 7 | cin>>n; 8 | int a[n]; 9 | for (int i = 0; i < n; ++i) 10 | { 11 | cin>>a[i]; 12 | if(a[i]%2==0) 13 | e++; 14 | else 15 | o++; 16 | } 17 | if(e>o) 18 | cout<<"READY FOR BATTLE"; 19 | else 20 | cout<<"NOT READY"; 21 | } 22 | int main() 23 | { 24 | ios::sync_with_stdio(0); 25 | cin.tie(0); 26 | int t=1; 27 | //cin>>t; 28 | while(t--) 29 | solve(); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /Practice/Beginner/Number Mirror.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/START01 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n; 7 | cin>>n; 8 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Practice/Beginner/Packaging Cupcakes.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/MUFFINS3 2 | #include 3 | using namespace std; 4 | #define ll long long int 5 | void solve() 6 | { 7 | ll n; 8 | cin>>n; 9 | if(n==2) 10 | cout<<2<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /Practice/Beginner/Primality Test.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/PRB01 2 | #include 3 | using namespace std; 4 | bool prime(int n) 5 | { 6 | if(n<=1) 7 | return false; 8 | for(int i=2;i>n; 17 | if(prime(n)) 18 | cout<<"yes"<>t; 28 | while(t--) 29 | solve(); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /Practice/Beginner/Puppy and Sum.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/PPSUM 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int d,n,s=0; 7 | cin>>d>>n; 8 | for(int i=0;i>t; 24 | while(t--) 25 | solve(); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /Practice/Beginner/Reverse The Number.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW007 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | long long n,r=0,rev=0; 7 | cin>>n; 8 | while(n) 9 | { 10 | r=n%10; 11 | rev=rev*10+r; 12 | n=n/10; 13 | } 14 | cout<>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Practice/Beginner/Second Largest.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW017 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | long long a,b,c,ma=0,mi=0; 7 | cin>>a>>b>>c; 8 | ma=max(max(b,c),a); 9 | mi=min(min(b,c),a); 10 | cout<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /Practice/Beginner/Small Factorial.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW018 2 | #include 3 | using namespace std; 4 | #define ll long long int 5 | ll fact(int n) 6 | { 7 | if(n==0) 8 | return 1; 9 | if(n==1) 10 | return 1; 11 | return n*fact(n-1); 12 | } 13 | void solve() 14 | { 15 | int n; 16 | cin>>n; 17 | cout<>t; 25 | while(t--) 26 | solve(); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /Practice/Beginner/Smallest Numbers of Notes.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/submit/FLOW005 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | long long n,rem=0,c=0; 7 | cin>>n; 8 | /* c=n/100; 9 | rem=n%100; 10 | c=c+rem/50; 11 | rem=rem%50; 12 | c=c+rem/10; 13 | rem=rem%10; 14 | c=c+rem/5; 15 | rem=rem%5; 16 | c=c+rem/2; 17 | rem=rem%2; 18 | c=c+rem/1; 19 | rem=rem%1; 20 | cout<>t; 35 | while(t--) 36 | solve(); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /Practice/Beginner/Sum OR Difference.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/DIFFSUM 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n1,n2; 7 | cin>>n1; 8 | cin>>n2; 9 | if(n1>n2) 10 | cout<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /Practice/Beginner/Sum of Digits.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW006 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | long long n,r=0,s=0; 7 | cin>>n; 8 | while(n) 9 | { 10 | r=n%10; 11 | s=s+r; 12 | n=n/10; 13 | } 14 | cout<>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Practice/Beginner/The Block Game.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/PALL01 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n,num=0,r=0,rev=0; 7 | cin>>n; 8 | num=n; 9 | while(n) 10 | { 11 | r=n%10; 12 | rev=rev*10+r; 13 | n=n/10; 14 | } 15 | if(num==rev) 16 | cout<<"wins"<>t; 26 | while(t--) 27 | solve(); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Practice/Beginner/Total Expenses.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW009 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int q,p; 7 | cin>>q>>p; 8 | if(q>1000) 9 | cout<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /Practice/Beginner/Turbo Sort.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/TSORT 2 | #include 3 | using namespace std; 4 | #define ll long long int 5 | void solve() 6 | { 7 | ll n; 8 | cin>>n; 9 | ll a[n]; 10 | for (ll i = 0; i < n; ++i) 11 | { 12 | cin>>a[i]; 13 | } 14 | sort(a,a+n); 15 | for (ll i = 0; i < n; ++i) 16 | { 17 | cout<>t; 26 | while(t--) 27 | solve(); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Practice/Beginner/Valid Triangles.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLOW013 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int a,b,c; 7 | cin>>a>>b>>c; 8 | if((a+b+c)==180) 9 | cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # All of the problems are under copyright of https://www.codechef.com/learn/dashboard 2 | Refer solutions wrt the contest name and number provided. 3 | 4 | CodeChef Profile Link:-https://www.codechef.com/users/lucifer_hanu 5 | -------------------------------------------------------------------------------- /Starters 10/Hardest Problem Bet.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START10C/problems/HARDBET 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int sa,sb,sc; 6 | cin>>sa>>sb>>sc; 7 | if(min(min(sa,sb),sc)==sa) 8 | cout<<"Draw"<>t; 21 | while(t--) 22 | solve(); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Starters 10/Odd Repeat.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/REPEAT 2 | //Odd Repeat 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int N,K,S; 8 | cin>>N>>K>>S; 9 | int i=1,sum=0; 10 | sum+=N*N+(K-1); 11 | int ans=1; 12 | i = 3; 13 | while(i<=N*2-1 && sum!=S){ 14 | if(i%2!=0){ 15 | sum=sum-(ans*K)+ans+(i*K)-i; 16 | ans = i; 17 | 18 | } 19 | i++; 20 | } 21 | cout<>t; 29 | while(t--) 30 | solve(); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /Starters 11/Find the Direction.cpp: -------------------------------------------------------------------------------- 1 | https://www.codechef.com/submit-v2/FACEDIR 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | if(n%4==0) 8 | cout<<"North"<>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Starters 29/Fill the bucket.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FBC 2 | //Fill the Bucket 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int k,x; 8 | cin>>k>>x; 9 | cout<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 29/Tyre problem.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/TYRE 2 | //Tyre Problem 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int m,n; 7 | cin>>n>>m; 8 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Starters 33/Minimum Cars required.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/MINCARS 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | cout<<(n+3)/4<>t; 15 | while(t--) 16 | solve(); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Starters 33/Monthly Budget.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/BUDGET_ 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int x,y; 6 | cin>>x>>y; 7 | if(x>=y*30) 8 | cout<<"YES"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 33/The Cheaper Cab.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START33B/problems/CABS/ 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int x,y; 6 | cin>>x>>y; 7 | if(xy) 10 | cout<<"SECOND"<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Starters 36/Presents for Cheffina.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/PRESENTS 2 | //Presents for Cheffina 3 | #include 4 | #define ll long long int 5 | using namespace std; 6 | void solve(){ 7 | ll n; 8 | cin>>n; 9 | if(n<5) 10 | cout<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Starters 38/Chef gives Party.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/PARTY2 2 | //Chef gives Party 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n,x,k; 7 | cin>>n>>x>>k; 8 | if((k-(x*n))>=0) 9 | cout<<"YES"<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Starters 38/Get Subscription.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/SUBSCRIBE 2 | //Get Subscription 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int x; 8 | cin>>x; 9 | if(x>30)cout<<"YES"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 4/Correct Sentence.cpp: -------------------------------------------------------------------------------- 1 | https://www.codechef.com/START4C/problems/CORTSENT/ 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int k,flag=0,f=0; 6 | cin>>k; 7 | for (int i = 0; i >s; 10 | int lan1=0,lan2=0,lan3=0; 11 | flag=0; 12 | for (int j = 0; j='a'&&s[j]<='m'){ 15 | lan1=1; 16 | } 17 | else if(s[j]>='N'&&s[j]<='Z'){ 18 | lan2=1; 19 | } 20 | else lan3=1; 21 | } 22 | if(lan1==1&&lan2==0&&lan3==0)flag=1; 23 | if(lan2==1&&lan1==0&&lan3==0)flag=1; 24 | if(flag==0){f=1;} 25 | } 26 | if(flag==1&&f==0)cout<<"YES"<>t; 34 | while(t--) 35 | solve(); 36 | return 0; 37 | } -------------------------------------------------------------------------------- /Starters 4/Lazy Chef.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START4C/problems/LAZYCHF/ 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int x,m,d; 6 | cin>>x>>m>>d; 7 | cout<>t; 15 | while(t--) 16 | solve(); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Starters 4/Plagiarism.cpp: -------------------------------------------------------------------------------- 1 | https://www.codechef.com/START4C/problems/QUIZPLAG/ 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,m,k,c=1,z=0; 6 | cin>>n>>m>>k; 7 | int a[k],b[k]; 8 | for (int i = 0; i < k; ++i) 9 | { 10 | cin>>a[i]; 11 | } 12 | sort(a,a+k); 13 | for (int i = 0; i < k; ++i) 14 | { 15 | if(a[i]>n)break; 16 | if(a[i]==a[i+1]&&b[z-1]!=a[i]){ 17 | b[z++]=a[i]; 18 | } 19 | } 20 | cout<>t; 31 | while(t--){ 32 | solve();cout<<"\n";} 33 | return 0;} -------------------------------------------------------------------------------- /Starters 42/Age Limit.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/AGELIMIT 2 | //Age Limit 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y,a; 7 | cin>>x>>y>>a; 8 | if(a>=x && a>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 43/Burgers.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/submit/BURGERS 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a,b; 6 | cin>>a>>b; 7 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Starters 43/Waiting Time.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/WAITTIME 2 | //Waiting Time 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int k,x; 8 | cin>>k>>x; 9 | cout<<7*k-x<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 44/Air Hockey.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/AIRHOCKEY 2 | //Air Hockey 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,b; 7 | cin>>a>> b; 8 | 9 | if (a>=7||b>=7) { 10 | cout<<"0"<>t; 26 | while(t--) 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Starters 44/Biryani.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/BIRYANI 2 | //Biryani 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Starters 47/Chef On Date.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/submit/CHEFONDATE 2 | //Chef On Date 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | if(x>=y) 9 | cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 47/Chess Time.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/submit/CHESSTIME 2 | //Chess Time 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | cout<<(n*60)/20<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Starters 47/Construct N.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CONN 2 | //Construct N 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | if(n==1 || n==3 || n==5) 9 | cout<<"NO"<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Starters 47/Minimum Coins.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/submit/MINCOINSREQ 2 | //Minimum Coins 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x<10) 9 | cout<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Starters 51/Final Population.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/POPULATION 2 | //Final Population 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int x,y,z; 8 | cin>>x>>y>>z; 9 | cout<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 52/AI Analysing Code.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/AIANALYSE 2 | //AI Analysing Code 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int c; 8 | cin>>c; 9 | if(c<=1000) cout<<"Yes"; 10 | else 11 | cout<<"no"; 12 | } 13 | int main() 14 | { 15 | ios::sync_with_stdio(0); 16 | cin.tie(0); 17 | int t=1; 18 | //cin>>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 53/Car Trip.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CARTRIP 2 | //Car Trip 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x<=300)cout<<3000<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 53/Greater Average.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/AVGPROBLEM 2 | //Greater Average 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | double a,b,c; 8 | cin>>a>>b>>c; 9 | if(((a+b)/2)>c)cout<<"yes"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 54/Number of Credits.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CREDS 2 | //Number of Credits 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int x,y,z; 8 | cin>>x>>y>>z; 9 | cout<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 54/Ticket Fine.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/TCKTFINE 2 | //Ticket Fine 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int x,p,q; 8 | cin>>x>>p>>q; 9 | cout<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 55/Fever.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FEVER 2 | //Fever 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int x; 8 | cin>>x; 9 | if(x>98)cout<<"YES"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 56/Chefland Games.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CHEFGAMES 2 | //Chefland Games 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int r1,r2,r3,r4; 7 | cin>>r1>>r2>>r3>>r4; 8 | if(r1 || r2 || r3 || r4)cout<<"OUT"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 57/Alice and Marks.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/MARKSTW 2 | //Alice and Marks 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | if(x>=2*y)cout<<"Yes"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 57/Integers that sum to the same value.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/SUMNEQ 2 | //Integers that sum to the same value 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int n; 8 | cin>>n; 9 | cout<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 58/Ranklist Pages.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/RANKLISTPAGE 2 | //Ranklist Pages 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x%25!=0) 9 | cout<<(x/25)+1<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 58/Reach the Target.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/REACHTARGET 2 | //Reach the Target 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Starters 58/Remove Bad elements.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/REMOVEBAD 2 | //Remove Bad elements 3 | #include 4 | using namespace std; 5 | int min_operations(vector A) { 6 | unordered_map freq; 7 | for (int a : A) { 8 | freq[a]++; 9 | } 10 | int most_freq = max_element(freq.begin(), freq.end(), [](auto &p1, auto &p2){ 11 | return p1.second < p2.second; 12 | })->second; 13 | return A.size() - most_freq; 14 | } 15 | void solve(){ 16 | int N; 17 | cin >> N; 18 | vector A(N); 19 | for (int i = 0; i < N; i++) { 20 | cin >> A[i]; 21 | } 22 | cout << min_operations(A) << endl; 23 | } 24 | int main() 25 | { 26 | ios::sync_with_stdio(0); 27 | cin.tie(0); 28 | int t; 29 | cin>>t; 30 | while(t--) 31 | solve(); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Starters 59/Audible Range.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/AUDIBLE 2 | //Audible Range 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x>=67 && x<=45000)cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 59/Chef and Happy String.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/HAPPYSTR 2 | //Chef and Happy String 3 | #include 4 | using namespace std; 5 | bool isvowel(char t) 6 | { 7 | if(t=='a'||t=='e'||t=='i'||t=='o'||t=='u')return true; 8 | else 9 | return false; 10 | } 11 | void solve(){ 12 | string s; 13 | int c=0; 14 | cin>>s; 15 | for(int i=2;i0) 20 | cout<<"Happy"<>t; 30 | while(t--) 31 | solve(); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Starters 59/Speciality.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/SPECIALITY 2 | //Speciality 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y,z; 7 | cin>>x>>y>>z; 8 | if(x>y && x>z)cout<<"Setter"<x && y>z)cout<<"Tester"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 6/Cricket Ranking.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START6C/problems/CRICRANK/ 2 | #include 3 | using namespace std; 4 | # define ll long long 5 | void solve() 6 | { 7 | int r1,w1,c1,r2,w2,c2,a=0,b=0; 8 | cin>>r1>>w1>>c1; 9 | cin>>r2>>w2>>c2; 10 | if(r1>r2)a++; 11 | else 12 | b++; 13 | if(w1>w2)a++; 14 | else 15 | b++; 16 | if(c1>c2)a++; 17 | else 18 | b++; 19 | if(a>b) 20 | cout<<"A"<>t; 30 | while(t--) 31 | solve(); 32 | return 0; 33 | } 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Starters 6/Joker and Batman.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START6C/problems/JOKRBTMN 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n,m,l; 7 | cin>>n>>m>>l; 8 | int a[n+1]; 9 | for (int i = 1; i <=m; i++) 10 | { 11 | int k; cin>>k; 12 | for(int j=1;j<=k;j++) 13 | { int x; cin>>x; 14 | a[x]=i; 15 | } 16 | } 17 | int temp=0,res=0; 18 | for (int i = 1; i <=l; i++) 19 | { 20 | int y; cin>>y; 21 | if(a[y]!=temp) 22 | res++; 23 | temp=a[y]; 24 | } 25 | cout<>t; 33 | while(t--) 34 | solve(); 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /Starters 6/Three Dices.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START6C/problems/THREDICE 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int x,y; 7 | cin>>x>>y; 8 | if((x+y)>=6) 9 | cout<<0<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Starters 60/Card Removal.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/REMOVECARDS 2 | //Card Removal 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin >> n; 8 | vector cards(n); 9 | for (int i = 0; i < n; i++) { 10 | cin >> cards[i]; 11 | } 12 | sort(cards.begin(), cards.end()); 13 | int ans = n; 14 | for (int i = 0; i < n; i++) { 15 | int cnt = 1; 16 | while (i+1 < n && cards[i] == cards[i+1]) { 17 | cnt++; 18 | i++; 19 | } 20 | ans = min(ans, n-cnt); 21 | } 22 | cout << ans << endl; 23 | 24 | } 25 | int main() 26 | { 27 | ios::sync_with_stdio(0); 28 | cin.tie(0); 29 | int t; 30 | cin>>t; 31 | while(t--) 32 | solve(); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Starters 60/Expert Setter.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/EXPERT 2 | //Expert Setter 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | if(((100*y)/x)>=50)cout<<"Yes"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 60/Palindrome Flipping.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/FLIPPAL 2 | //Palindrome Flipping 3 | #include 4 | using namespace std; 5 | 6 | bool can_convert_to_palindrome(string s) { 7 | int n=s.size(); 8 | vector freq(2, 0); 9 | for (int i=0;i>n>>s; 24 | if (can_convert_to_palindrome(s)) { 25 | cout<<"YES"<>t; 36 | while(t--) 37 | solve(); 38 | return 0; 39 | } -------------------------------------------------------------------------------- /Starters 60/Paper Cutting.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CUTPAPER 2 | //Paper Cutting 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n, k; 7 | cin>>n>> k; 8 | int squares_per_row=floor(n / k); 9 | int max_squares=squares_per_row*squares_per_row; 10 | cout<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 60/Tax in Chefland.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/TAXES 2 | //Tax in Chefland 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x>100)cout<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 61/Different Consecutive Characters.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/DIFFCONSEC 2 | //Different Consecutive Characters 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | string s; 7 | int n,c=0; 8 | cin>>n; 9 | cin>>s; 10 | for(int i=1;i>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Starters 61/Minimise LCS.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/MINLCS 2 | //Minimise LCS 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n,c=0; 7 | string a,b; 8 | cin>>n>>a>>b; 9 | map j,k; 10 | for(char i:a) 11 | { 12 | j[i]++; 13 | } 14 | for(char i:b) { 15 | k[i]++; 16 | } 17 | for(char i='a';i<='z';++i) 18 | { 19 | int p=max(c,min(j[i],k[i])); 20 | c=p; 21 | } 22 | cout<>t; 30 | while(t--) 31 | solve(); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Starters 61/Odd Sum Pair.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/ODDSUMPAIR 2 | //Odd Sum Pair 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,b,c; 7 | cin>>a>>b>>c; 8 | if((a+b)%2==1 || (a+c)%2==1 || (b+c)%2==1)cout<<"yes"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 61/Reach on Time.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/TIMELY 2 | //Reach on Time 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x>=30)cout<<"Yes"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 61/Subarray Removal.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/SUBARRAYREM 2 | //Subarray Removal 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int N,c1=0,c0=0; 7 | cin>>N; 8 | int A[N]; 9 | for (int i=0;i>A[i]; 11 | c1+=A[i]==1; 12 | c0+=A[i]==0; 13 | } 14 | cout<<(min(c1,c0)+max(0,c1-c0)/3)<>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Starters 62/Man minus Min.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/MAXDIFFMIN 2 | //Max minus Min 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,b,c; 7 | cin>>a>>b>>c; 8 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Starters 62/Test Score.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CHEFSCORE 2 | //Test Score 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n,x,y; 7 | cin>>n>>x>>y; 8 | if(n*x>=y && y%x==0)cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 62/X Jumps.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/XJUMP 2 | //X Jumps 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | cout<<(x/y)+(x%y)<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 63/Packing Books.cpp: -------------------------------------------------------------------------------- 1 | //Packing Books 2 | //https://www.codechef.com/problems/BOOKPACK 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int x,y,z; 8 | cin>>x>>y>>z; 9 | if(y%z==0){ 10 | cout<<(y/z)*x<>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Starters 63/Tasty Decisions.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/TASTEDEC 2 | //Tasty Decisions 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | if(x*2>y*5)cout<<"Chocolate"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 64/Distinct Colors.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/DISTINCTCOL/ 2 | //Distinct Colors 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int n; 8 | cin>>n; 9 | int a[n]; 10 | for(int i=0;i>a[i]; 12 | for(int i=1;i>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Starters 64/Water Consumption.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/WATERCONS 2 | //Water Consumption 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x>=2000)cout<<"Yes"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 65/Hackerman.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/PRIMEDICE 2 | //Hackerman 3 | #include 4 | using namespace std; 5 | bool is_prime(int n) { 6 | if (n <= 1) { 7 | return false; 8 | } 9 | for (int i = 2; i <= sqrt(n); i++) { 10 | if (n % i == 0) { 11 | return false; 12 | } 13 | } 14 | return true; 15 | } 16 | void solve(){ 17 | int a,b; 18 | cin>>a>>b; 19 | if(is_prime(a+b))cout<<"Alice"<>t; 29 | while(t--) 30 | solve(); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /Starters 65/Parity.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/PAR2 2 | //Parity 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | if(n%2==0)cout<<"yes"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 66/Monopoly in Chefland.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/MONOPOLY 2 | //Monopoly in Chefland 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int r1,r2,r3; 8 | cin>>r1>>r2>>r3; 9 | if(r1>(r2+r3)||r2>(r3+r1)||r3>(r1+r2))cout<<"YES"<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Starters 66/Squats.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/SQUATS 2 | //Squats 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | cout<<15*x<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 67/Tour of King.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/KNGTOR 2 | //Tour of King 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n,m; 7 | cin>>n>>m; 8 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Starters 68/Bull or Bear.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/BULLBEAR 2 | //Bull or Bear 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | if(x==y)cout<<"NEUTRAL"<y)cout<<"LOSS"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 68/Make AP.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/MAKEAP/ 2 | //Make AP 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,c; 7 | cin>>a>>c; 8 | if(abs(a-c)%2==0) 9 | cout<<(a+c)/2<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /Starters 69/Rain in Chefland.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/RAINFALL1 2 | //Rain in Chefland 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x<3)cout<<"LIGHT"<=3 && x<7)cout<<"MODERATE"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 69/Scalene Triangle.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/SCALENE 2 | //Scalene Triangle 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,b,c; 7 | cin>>a>>b>>c; 8 | if(a!=b && b!=c && a!=c) 9 | cout<<"yes"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 70/Cost of Groceries.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/KITCHENCOST 2 | //Cost of Groceries 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n,x; 7 | cin>>n>>x; 8 | int a[n],b[n]; 9 | for(int i=0;i>a[i]; 10 | for(int i=0;i>b[i]; 11 | int c=0; 12 | for(int i=0;i=x)c+=b[i]; 15 | } 16 | cout<>t; 24 | while(t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Starters 70/Kitchen Timings.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/KITCHENTIME 2 | //Kitchen Timings 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | cout<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 70/Spice Level.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/KITCHENSPICE 2 | //Spice Level 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x<4)cout<<"MILD"<=4 && x<7)cout<<"MEDIUM"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 71/Instagram.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/INSTAGRAM 2 | //Instagram 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | if(x>10*y)cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 71/Perfect Trio.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/PERFECTTRIO 2 | //Perfect Trio 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,b,c; 7 | cin>>a>>b>>c; 8 | if((a+b==c) || (b+c==a) || (a+c==b))cout<<"yes"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 71/Snapchat.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/SNAPCHAT/ 2 | //Snapchat 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | int a[n],b[n],c=0,ans=0; 9 | for(int i=0;i>a[i]; 12 | } 13 | for(int i=0;i>b[i]; 16 | } 17 | for(int i=0;i0 && b[i]>0) 20 | { 21 | c++; 22 | if(c>ans) 23 | ans=c; 24 | } 25 | else if(a[i]==0 || b[i]==0)c=0; 26 | } 27 | cout<>t; 35 | while(t--) 36 | solve(); 37 | return 0; 38 | } -------------------------------------------------------------------------------- /Starters 72/Indivisible.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/INDIVISIBLE 2 | //Indivisible 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int a,b,c; 8 | cin>>a>>b>>c; 9 | for(int i=2;i<100;i++){ 10 | if(a%i!=0 && b%i!=0 && c%i!=0) 11 | { 12 | cout<>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Starters 72/Sum it.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/SUMM 2 | //Sum it 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,b,c; 7 | cin>>a>>b>>c; 8 | if(a+b==c)cout<<"YES"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 74/Mana Points.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/MANAPTS 2 | //Mana Points 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Starters 75/Profit Increment.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/PROINC 2 | //Profit Increment 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | cout<<(1.1*x)-(x-y)<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Starters 75/Saving Taxes.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/TAXSAVING 2 | //Saving Taxes 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | cout<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 75/Three Powers of Two.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/THREEPOW2 2 | //Three Powers of Two 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin >> n; 8 | string s; 9 | cin >> s; 10 | int o = count(s.begin(), s.end(), '1'); 11 | if (o == 1) 12 | { 13 | for(int i=0;i= 2) 18 | { 19 | cout << "YES" << endl; 20 | } 21 | else 22 | cout << "NO" << endl; 23 | 24 | break; 25 | } 26 | } 27 | } 28 | else if (o == 2 or o == 3) 29 | { 30 | cout << "YES" << endl; 31 | } 32 | else 33 | { 34 | cout << "NO" << endl; 35 | } 36 | } 37 | int main() 38 | { 39 | ios::sync_with_stdio(0); 40 | cin.tie(0); 41 | int t; 42 | cin>>t; 43 | while(t--) 44 | solve(); 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Starters 75/Two Ranges.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/TWORANGES 2 | //Two Ranges 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a, b, c, d; 7 | cin >> a >> b >> c >> d; 8 | 9 | set range1, range2; 10 | for (int i = a; i <= b; i++) { 11 | range1.insert(i); 12 | } 13 | for (int i = c; i <= d; i++) { 14 | range2.insert(i); 15 | } 16 | 17 | vector unionVec(range1.size() + range2.size()); 18 | auto it = set_union(range1.begin(), range1.end(), range2.begin(), range2.end(), unionVec.begin()); 19 | 20 | int unionSize = it - unionVec.begin(); 21 | 22 | cout << unionSize << endl; 23 | } 24 | int main() 25 | { 26 | ios::sync_with_stdio(0); 27 | cin.tie(0); 28 | int t; 29 | cin>>t; 30 | while(t--) 31 | solve(); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Starters 76/400M Race.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/RACE400M 2 | //400M Race 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,b,c; 7 | cin>>a>>b>>c; 8 | 9 | if(a>t; 22 | while(t--) 23 | solve(); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Starters 76/Read Pages.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/READPAGES 2 | //Read Pages 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n,x,y; 7 | cin>>n>>x>>y; 8 | if(n<=x*y)cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 77/Codechef Airlines.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/AIRLINES 2 | //Codechef Airlines 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y,z; 7 | cin>>x>>y>>z; 8 | if(y>x*10)cout<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 77/Tom and Jerry Chase.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/JERRYCHASE 2 | //Tom and Jerry Chase 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | if(y>x)cout<<"YES"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 78/Candy Store.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CANDYSTORE 2 | //Candy Store 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | if(x>y)cout<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 78/Good Turn.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/GDTURN 2 | //Good Turn 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x,y; 7 | cin>>x>>y; 8 | if((x+y)>6)cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 79/Ageing.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/AGEING 2 | //Ageing 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Starters 79/Better Deal.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/BETDEAL 2 | //Better Deal 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int a,b; 7 | cin>>a>>b; 8 | if ((100-a)<((100-b)*2)) 9 | cout<<"FIRST"<((100-b)*2)) 11 | cout<<"SECOND"<>t; 21 | while(t--) 22 | solve(); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Starters 79/Distinct Opposite Sums.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/DISTOPPSUMS 2 | //Distinct Opposite Sums 3 | #include 4 | using namespace std; 5 | 6 | vector generatePermutation(int n) { 7 | vector perm(n); 8 | for (int i = 0; i < n/2; i++) { 9 | perm[i] = i*2 + 2; 10 | perm[n-i-1] = i*2 + 1; 11 | } 12 | return perm; 13 | } 14 | 15 | void printPermutation(vector perm) { 16 | for (int i = 0; i < perm.size(); i++) { 17 | cout << perm[i] << " "; 18 | } 19 | cout << endl; 20 | } 21 | int main() 22 | { 23 | ios::sync_with_stdio(0); 24 | cin.tie(0); 25 | int t; 26 | cin>>t; 27 | while(t--){ 28 | int n; 29 | cin >> n; 30 | vector perm = generatePermutation(n); 31 | printPermutation(perm); 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Starters 8/Javelin Qualification.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START8C/problems/JAVELIN 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,m,x; 6 | cin>>n>>m>>x; 7 | vector> v; 8 | int d; 9 | for(int i=0;i>d; 12 | v.push_back(make_pair(d,i+1)); 13 | } 14 | sort(v.rbegin(),v.rend()); 15 | vectorres; 16 | for(int i=0;i=m||res.size()>t; 36 | while(t--) 37 | solve(); 38 | return 0; 39 | } -------------------------------------------------------------------------------- /Starters 8/Penalty.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START8C/problems/PENALTY 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int a[10],se=0,so=0; 6 | for (int i = 0; i < 10; ++i) 7 | { 8 | cin>>a[i]; 9 | } 10 | for(int i=0;i<10;i=i+2) 11 | { 12 | se=se+a[i]; 13 | } 14 | for(int i=1;i<10;i=i+2) 15 | { 16 | so=so+a[i]; 17 | } 18 | if(se>so) 19 | cout<<1<se) 21 | cout<<2<>t; 31 | while(t--) 32 | solve(); 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /Starters 80/Just One More Episode.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/ONEMORE 2 | //Just One More Episode 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x>24)cout<<"Yes"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 80/Running Comparison.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/RUNCOMPARE 2 | //Running Comparison 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n,c=0; 7 | cin>>n; 8 | int a[n],b[n]; 9 | for(int i=0;i>a[i]; 11 | for(int i=0;i>b[i]; 13 | for(int i=0;i2*b[i]) && !(b[i]>2*a[i])))c++; 15 | }cout<>t; 23 | while(t--) 24 | solve(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /Starters 80/Single-use Attack.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/SINGLEUSE 2 | //Single-use Attack 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int h,x,y,count; 7 | cin>>h>>x>>y; 8 | if(h>=y){ 9 | if(((h-y)%x)!=0) 10 | count=((h-y)/x)+2; 11 | else 12 | count=((h-y)/x)+1; 13 | cout<>t; 24 | while(t--) 25 | solve(); 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Starters 81/Maximum Capacity.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/MAXCAP 2 | //Maximum Capacity 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int x,y; 8 | cin>>x>>y; 9 | if(x*y>500 || x>8)cout<<"NO"<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Starters 81/Sunny Day.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/SUNNYDAY 2 | //Sunny Day 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int x; 7 | cin>>x; 8 | if(x>24)cout<<"YES"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 82/Candy Division.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CANDIVIDE 2 | //Candy Division 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | if(n%3==0)cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 82/Reach Home.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/REACH_HOME 2 | //Reach Home 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | double x,y; 8 | cin>>x>>y; 9 | if(y/5.0<=x)cout<<"YES"<>t; 20 | while(t--) 21 | solve(); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Starters 83/Budget of Technex.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START83D/problems/BUDTECH 2 | //Budget of Technex 3 | #include 4 | using namespace std; 5 | void solve() 6 | { 7 | int r; 8 | cin>>r; 9 | cout<<((r*1000)/2)/5<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 83/Chef Eren.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START83D/problems/CHEFEREN 2 | //Chef Eren 3 | #include 4 | using namespace std; 5 | void solve() 6 | { 7 | int n,a,b; 8 | cin>>n>>a>>b; 9 | int c=0; 10 | if(n%2==0) 11 | { 12 | c=((n/2)*a)+((n/2)*b); 13 | } 14 | else 15 | { 16 | c=(((n/2)+1)*b)+((n/2)*a); 17 | } 18 | cout<>t; 26 | while(t--) 27 | solve(); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Starters 83/Construct String.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CONSTR/ 2 | //Construct String 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | long long int n,c=1; 7 | cin>>n; 8 | string s; 9 | cin>>s; 10 | for(int i=0;i>t; 27 | while(t--) 28 | solve(); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Starters 83/Couple Game.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START83D/problems/COUGAME 2 | //Couple Game 3 | #include 4 | using namespace std; 5 | void solve() 6 | { 7 | int g,b; 8 | cin>>g>>b; 9 | cout<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 84/Chef and Donation.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/DNATION 2 | //Chef and Donation 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int x,y; 8 | cin>>x>>y; 9 | cout<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Starters 84/Elections in Chefland.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/ELECTN 2 | //Elections in Chefland 3 | 4 | class Solution { 5 | public: 6 | string simplifyPath(string path) { 7 | string curr,simpath; 8 | stack st; 9 | path.push_back('/'); 10 | for(char c:path) { 11 | if(c=='/') { 12 | if(curr.empty()) continue; 13 | else if(curr=="..") { 14 | if(!st.empty()) st.pop(); 15 | } 16 | else if(curr!=".") st.push(curr); 17 | curr=""; 18 | } 19 | else 20 | curr.push_back(c); 21 | } 22 | 23 | while(!st.empty()) { 24 | simpath="/"+st.top()+simpath; 25 | st.pop(); 26 | } 27 | return simpath.empty()?"/":simpath; 28 | } 29 | }; -------------------------------------------------------------------------------- /Starters 84/Melt Gold.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/MELTGOLD 2 | //Melt Gold 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int x,y,i; 8 | cin>>x>>y; 9 | for(i=1;i<=100000;i++) 10 | { 11 | y=y+i; 12 | if(y>=x){ 13 | cout<>t; 25 | while(t--) 26 | solve(); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Starters 85/Can Chef.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CANCHEF/ 2 | //Can Chef 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | double x,y; 8 | cin>>x>>y; 9 | if((2*y/15.0)<=x)cout<<"YES"<>t; 18 | while(t--) 19 | solve(); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Starters 85/IPL Ticket Rush.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/IPLTRSH 2 | //IPL Ticket Rush 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int n,m; 8 | cin>>n>>m; 9 | cout<<(n-m>0?n-m:0)<>t; 17 | while(t--) 18 | solve(); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Starters 86/CodeChef Learn Problem Solving.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CCLEARN 2 | //CodeChef Learn Problem Solving 3 | #include 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | cout<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Starters 86/Cricket Match.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/problems/CRICMATCH 2 | //Cricket Match 3 | 4 | #include 5 | using namespace std; 6 | void solve(){ 7 | int n,m; 8 | cin>>n>>m; 9 | if(n<=6*6*m)cout<<"YES"<>t; 19 | while(t--) 20 | solve(); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Starters 9/Black cells in a chessboard.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START9C/problems/BLACKCEL 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n; 6 | cin>>n; 7 | cout<<(n*n)/2; 8 | } 9 | int main() 10 | { 11 | ios::sync_with_stdio(0); 12 | cin.tie(0); 13 | int t=1; 14 | //cin>>t; 15 | while(t--) 16 | solve(); 17 | return 0; 18 | } 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Starters 9/Bus full of passengers.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START9C/problems/BUS 2 | #include 3 | using namespace std; 4 | void solve(){ 5 | int n,m,q,s=0,c=0; 6 | cin>>n>>m>>q; 7 | int arr[]; 8 | for(int i=0;i>ch>>a; 12 | if(ch=='+') 13 | s=s+1; 14 | else 15 | s=s-1; 16 | if(s>m) 17 | c--; 18 | if(ch=='+') 19 | arr[a]=arr[a]+a; 20 | else 21 | { 22 | arr[a]=arr[a]-a; 23 | if(arr[a]<0) 24 | c--; 25 | } 26 | } 27 | if(c<0) 28 | cout<<"Inconsistent"<>t; 38 | while(t--) 39 | solve(); 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Starters 9/Friend Groups In A Line.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START9C/problems/FRIENDGR 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n,k,l=0,a=0; 7 | cin>>n>>k; 8 | string s; 9 | cin>>s; 10 | for (int i = 0; i < n; i++) 11 | { 12 | if(s[i]=='0') 13 | continue; 14 | if(i-l<=k+1) 15 | l=min(i+1,l+k); 16 | else{ 17 | a++; 18 | l=i+1; 19 | } 20 | } 21 | cout<>t; 29 | while(t--) 30 | solve(); 31 | return 0; 32 | } 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Starters 9/Large Square.cpp: -------------------------------------------------------------------------------- 1 | //https://www.codechef.com/START9C/problems/XLSQUARE 2 | #include 3 | using namespace std; 4 | void solve() 5 | { 6 | int n,a; 7 | cin>>n>>a; 8 | cout<<((int)(sqrt(n)))*a<>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } 20 | 21 | 22 | --------------------------------------------------------------------------------