diff --git a/Codeforces Solutions/1030A - In Search of an Easy Problem.cpp b/Codeforces Solutions/1030A - In Search of an Easy Problem.cpp new file mode 100644 index 0000000..b142e29 --- /dev/null +++ b/Codeforces Solutions/1030A - In Search of an Easy Problem.cpp @@ -0,0 +1,44 @@ +//Author: Akash Gautam (@geekblower) +//Date: 11-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + start_loop { + if(arr[i]) { + display("HARD"); + return; + } + } + + display("EASY") +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/1077A - Frog Jumping.cpp b/Codeforces Solutions/1077A - Frog Jumping.cpp new file mode 100644 index 0000000..6b8257b --- /dev/null +++ b/Codeforces Solutions/1077A - Frog Jumping.cpp @@ -0,0 +1,46 @@ +//Author: Akash Gautam (@geekblower) +//Date: 13-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i:a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(a) + create(b) + create(k) + + int ans = 0; + + ans += (k/2)*a; + ans -= (k/2)*b; + + ans += (k&1) ? a : 0; + + display(ans) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/110A - Nearly Lucky Number.cpp b/Codeforces Solutions/110A - Nearly Lucky Number.cpp new file mode 100644 index 0000000..aaae523 --- /dev/null +++ b/Codeforces Solutions/110A - Nearly Lucky Number.cpp @@ -0,0 +1,46 @@ +//Author: Akash Gautam (@geekblower) +//Date: 01-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + int count = 0; + + while(n) { + if(n%10==4 || n%10==7) + count++; + n /= 10; + } + + if(count==4 || count==7) + display("YES") + else + display("NO") +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/112A - Petya and Strings.cpp b/Codeforces Solutions/112A - Petya and Strings.cpp new file mode 100644 index 0000000..94af7ae --- /dev/null +++ b/Codeforces Solutions/112A - Petya and Strings.cpp @@ -0,0 +1,45 @@ +//Author: Akash Gautam (@geekblower) +//Date: 25-06-2022 +#include +#include +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLVE solve(); return 0; +#define VI vector +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(a.begin(),a.end()) +#define loop(i,a,b,c) for(int i=a;i>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>str1>>str2; + int n = str1.length(); + start_loop { + char ch1 = toupper(str1[i]); + char ch2 = toupper(str2[i]); + if(ch1 > ch2) + return 1; + if(ch1 < ch2) + return -1; + } + return 0; +} + +int32_t main() { + GEEKBLOWER + int n = solve(); + cout< +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + int n = 4; + int arr[4]; + start_loop + cin>>arr[i]; + + sort(arr, arr+n); + + for(int i=0; i<3; i++) + cout< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + int total=0, ans=0; + + start_loop { + create(a) + create(b) + int temp = total; + + total -= a; + total += b; + + ans = max(total, ans); + } + + display(ans) +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/1186A - Vus the Cossack and a Contest.cpp b/Codeforces Solutions/1186A - Vus the Cossack and a Contest.cpp new file mode 100644 index 0000000..07ce05a --- /dev/null +++ b/Codeforces Solutions/1186A - Vus the Cossack and a Contest.cpp @@ -0,0 +1,41 @@ +//Author: Akash Gautam (@geekblower) +//Date: 18-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + create(m) + create(k) + + if(m>=n && k>=n) + display("YES") + else + display("NO") +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/1234A - Equalize Prices Again.cpp b/Codeforces Solutions/1234A - Equalize Prices Again.cpp new file mode 100644 index 0000000..9594c73 --- /dev/null +++ b/Codeforces Solutions/1234A - Equalize Prices Again.cpp @@ -0,0 +1,46 @@ +//Author: Akash Gautam (@geekblower) +//Date: 15-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + int sum = 0; + start_loop { + sum += arr[i]; + } + + if(sum%n) + display(sum/n+1) + else + display(sum/n) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1283A - Minutes Before the New Year.cpp b/Codeforces Solutions/1283A - Minutes Before the New Year.cpp new file mode 100644 index 0000000..6124b86 --- /dev/null +++ b/Codeforces Solutions/1283A - Minutes Before the New Year.cpp @@ -0,0 +1,37 @@ +//Author: Akash Gautam (@geekblower) +//Date: 30-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(h) + create(m) + display((24-h)*60 - m) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1285A - Mezo Playing Zoma.cpp b/Codeforces Solutions/1285A - Mezo Playing Zoma.cpp new file mode 100644 index 0000000..148a2ad --- /dev/null +++ b/Codeforces Solutions/1285A - Mezo Playing Zoma.cpp @@ -0,0 +1,46 @@ +//Author: Akash Gautam (@geekblower) +//Date: 12-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + string str; + cin>>str; + + int l=0, r=0; + start_loop { + if(str[i] == 'L') + l++; + else + r++; + } + + display(l+r+1) +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/1294A - Collecting Coins.cpp b/Codeforces Solutions/1294A - Collecting Coins.cpp new file mode 100644 index 0000000..f61f546 --- /dev/null +++ b/Codeforces Solutions/1294A - Collecting Coins.cpp @@ -0,0 +1,47 @@ +//Author: Akash Gautam (@geekblower) +//Date: 08-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(a) + create(b) + create(c) + create(n) + + int maximum = (a>b && a>c) ? a : (b>c ? b : c); + int total = (maximum-a) + (maximum-b) + (maximum-c); + n -= total; + + if((n%3==0 && n>=3) || n==0) + display("YES") + else + display("NO") +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1296A - Array with Odd Sum.cpp b/Codeforces Solutions/1296A - Array with Odd Sum.cpp new file mode 100644 index 0000000..5d57a27 --- /dev/null +++ b/Codeforces Solutions/1296A - Array with Odd Sum.cpp @@ -0,0 +1,55 @@ +//Author: Akash Gautam (@geekblower) +//Date: 05-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + bool even=false, odd=false; + int sum = 0; + + start_loop { + sum += arr[i]; + + if(arr[i]&1 && !odd) + odd = true; + if(arr[i]%2==0 && !even) + even = true; + } + + if(sum&1) + display("YES") + else if(even && odd) + display("YES") + else + display("NO") +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1311A - Add Odd or Subtract Even.cpp b/Codeforces Solutions/1311A - Add Odd or Subtract Even.cpp new file mode 100644 index 0000000..6cc635c --- /dev/null +++ b/Codeforces Solutions/1311A - Add Odd or Subtract Even.cpp @@ -0,0 +1,46 @@ +//Author: Akash Gautam (@geekblower) +//Date: 30-06-2022 +#include +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<b) ? 2 : 1; + else + count = (a>b) ? 1 : 2; + + display(count) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1328A - Divisibility Problem.cpp b/Codeforces Solutions/1328A - Divisibility Problem.cpp new file mode 100644 index 0000000..14d8330 --- /dev/null +++ b/Codeforces Solutions/1328A - Divisibility Problem.cpp @@ -0,0 +1,40 @@ +//Author: Akash Gautam (@geekblower) +//Date: 06-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(a) + create(b) + + int step = (a%b==0) ? 0 : b-(a%b); + + display(step) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} \ No newline at end of file diff --git a/Codeforces Solutions/1335A - Candies and Two Sisters.cpp b/Codeforces Solutions/1335A - Candies and Two Sisters.cpp new file mode 100644 index 0000000..2b44714 --- /dev/null +++ b/Codeforces Solutions/1335A - Candies and Two Sisters.cpp @@ -0,0 +1,42 @@ +//Author: Akash Gautam (@geekblower) +//Date: 09-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + + if(n<3) + display("0") + else if(n&1) + display(n/2) + else + display(n/2-1) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/136A - Presents.cpp b/Codeforces Solutions/136A - Presents.cpp new file mode 100644 index 0000000..86de387 --- /dev/null +++ b/Codeforces Solutions/136A - Presents.cpp @@ -0,0 +1,46 @@ +//Author: Akash Gautam (@geekblower) +//Date: 18-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + int *ans = new int[n]; + + start_loop { + int x = arr[i]; + ans[x-1] = i+1; + } + + start_loop + cout< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(x) + create(y) + create(n) + + int ans = n-(n%x)+y; + + if(ans>n) + display(ans-x) + else + display(ans) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1385A - Three Pairwise Maximums.cpp b/Codeforces Solutions/1385A - Three Pairwise Maximums.cpp new file mode 100644 index 0000000..06a8a20 --- /dev/null +++ b/Codeforces Solutions/1385A - Three Pairwise Maximums.cpp @@ -0,0 +1,44 @@ +//Author: Akash Gautam (@geekblower) +//Date: 04-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + int n=3; + def(arr,n) + sort(arr, arr+n); + + if(arr[2]!=arr[1]) { + display("NO") + } else { + display("YES") + display(arr[0]<<" "< +#include +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)); +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>str1>>str2>>str3; + mystr = str1 + str2; + + SORT(mystr) + SORT(str3) + + if(str3==mystr) + display("YES") + else + display("NO") +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/1426A - Floor Number.cpp b/Codeforces Solutions/1426A - Floor Number.cpp new file mode 100644 index 0000000..135427b --- /dev/null +++ b/Codeforces Solutions/1426A - Floor Number.cpp @@ -0,0 +1,46 @@ +//Author: Akash Gautam (@geekblower) +//Date: 31-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + create(x) + + n -= 2; + int flr = 1; + if(n<1) { + display(flr) + return; + } + + flr += (n%x==0) ? (n/x) : (n/x)+1; + display(flr) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/144A - Arrival of the General.cpp b/Codeforces Solutions/144A - Arrival of the General.cpp new file mode 100644 index 0000000..93dd410 --- /dev/null +++ b/Codeforces Solutions/144A - Arrival of the General.cpp @@ -0,0 +1,54 @@ +//Author: Akash Gautam (@geekblower) +//Date: 20-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + int maximum=arr[0], minimum=arr[0]; + start_loop { + maximum = max(maximum, arr[i]); + minimum = min(minimum, arr[i]); + } + + int maxIndex=-1, minIndex=-1; + start_loop { + if(maxIndex==-1 && arr[i]==maximum) + maxIndex = i; + if(arr[i]==minimum) + minIndex = i; + } + + if(minIndex>maxIndex) + display(maxIndex + n - minIndex - 1) + else + display(maxIndex + n - minIndex - 2) +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/1454A - Special Permutation.cpp b/Codeforces Solutions/1454A - Special Permutation.cpp new file mode 100644 index 0000000..7fea7e5 --- /dev/null +++ b/Codeforces Solutions/1454A - Special Permutation.cpp @@ -0,0 +1,40 @@ +//Author: Akash Gautam (@geekblower) +//Date: 30-06-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + sort(arr, arr+n); + + int test=0; + while(arr[test] == arr[0] && test +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)); +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + create(m) + create(x) + + int ans = (x%n) ? ((x%n)-1) : (n-1); + + ans *= m; + ans += x/n; + + ans += (x%n==0) ? 0 : 1; + + display(ans) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1519A - Red and Blue Beans.cpp b/Codeforces Solutions/1519A - Red and Blue Beans.cpp new file mode 100644 index 0000000..dbe8dfb --- /dev/null +++ b/Codeforces Solutions/1519A - Red and Blue Beans.cpp @@ -0,0 +1,45 @@ +//Author: Akash Gautam (@geekblower) +//Date: 11-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(red) + create(blue) + create(diff) + + if(red>blue) + swap(red, blue); + + if(blue > (red*(diff+1))) + display("NO") + else + display("YES") +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1520B - Ordinary Numbers.cpp b/Codeforces Solutions/1520B - Ordinary Numbers.cpp new file mode 100644 index 0000000..b888411 --- /dev/null +++ b/Codeforces Solutions/1520B - Ordinary Numbers.cpp @@ -0,0 +1,43 @@ +//Author: Akash Gautam (@geekblower) +//Date: 02-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + int ans = 0; + + for(int power=1; power<=n; power=power*10+1) { + for(int digit=1; digit<=9; digit++) + ans += (power*digit <= n) ? 1 : 0; + } + + display(ans) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1542A - Odd Set.cpp b/Codeforces Solutions/1542A - Odd Set.cpp new file mode 100644 index 0000000..1a41046 --- /dev/null +++ b/Codeforces Solutions/1542A - Odd Set.cpp @@ -0,0 +1,51 @@ +//Author: Akash Gautam (@geekblower) +//Date: 06-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + n *= 2; + def(arr,n) + + int even=0, odd=0; + + start_loop { + if(arr[i]&1) + odd++; + else + even++; + } + + if(odd==even) + display("YES") + else + display("NO") +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1553A - Digits Sum.cpp b/Codeforces Solutions/1553A - Digits Sum.cpp new file mode 100644 index 0000000..57fac1b --- /dev/null +++ b/Codeforces Solutions/1553A - Digits Sum.cpp @@ -0,0 +1,40 @@ +//Author: Akash Gautam (@geekblower) +//Date: 21-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + + int ans = n/10; + ans += (n%10==9) ? 1 : 0; + + display(ans) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/155A - I_love_%username%.cpp b/Codeforces Solutions/155A - I_love_%username%.cpp new file mode 100644 index 0000000..1d717e3 --- /dev/null +++ b/Codeforces Solutions/155A - I_love_%username%.cpp @@ -0,0 +1,51 @@ +//Author: Akash Gautam (@geekblower) +//Date: 27-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + int minimum=arr[0], maximum=arr[0], count=0; + + loop(i, 1, n, 1) { + if(arr[i]>maximum) { + count++; + maximum = arr[i]; + } + + if(arr[i] +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(a) + create(b) + create(c) + + int diff = abs(a-b); + int maximum = diff*2; + + if((abs(a-b)==1) || (a>maximum) || (b>maximum) || (c>maximum)) { + display("-1") + return; + } + + if(c+diff <= maximum) + display(c+diff) + else if(c-diff > 0) + display(c-diff) + else + display(-1) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/158A - Next Round.cpp b/Codeforces Solutions/158A - Next Round.cpp new file mode 100644 index 0000000..409a405 --- /dev/null +++ b/Codeforces Solutions/158A - Next Round.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; + +int main() { + int n, k; + cin>>n>>k; + int *arr = new int[n]; + for(int i=0; i>arr[i]; + int limit=arr[k-1], ans=0; + + for(int i=0; i=limit && arr[i]!=0) + ans++; + else + break; + } + + cout< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(a) + create(b) + create(c) + + if(a==b && b==c) { + display("1 1 1") + return; + } + + int maximum = (a>b && a>c) ? a : (b>c ? b : c); + + int temp1 = (a==maximum) ? ((a==b || a==c) ? 1 : 0) : maximum-a+1; + int temp2 = (b==maximum) ? ((b==a || b==c) ? 1 : 0) : maximum-b+1; + int temp3 = (c==maximum) ? ((c==b || c==a) ? 1 : 0) : maximum-c+1; + + display(temp1<<" "< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + sort(arr, arr+n); + display(arr[n-1]-arr[0]) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1626A - Equidistant Letters.cpp b/Codeforces Solutions/1626A - Equidistant Letters.cpp new file mode 100644 index 0000000..f0900f9 --- /dev/null +++ b/Codeforces Solutions/1626A - Equidistant Letters.cpp @@ -0,0 +1,40 @@ +//Author: Akash Gautam (@geekblower) +//Date: 24-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + string str; + cin>>str; + + sort(str.begin(), str.end()); + + display(str) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1650A - Deletions of Two Adjacent Letters.cpp b/Codeforces Solutions/1650A - Deletions of Two Adjacent Letters.cpp new file mode 100644 index 0000000..aeed211 --- /dev/null +++ b/Codeforces Solutions/1650A - Deletions of Two Adjacent Letters.cpp @@ -0,0 +1,47 @@ +//Author: Akash Gautam (@geekblower) +//Date: 02-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + string str; + char ch; + cin>>str>>ch; + + bool flag = false; + int n = str.length(); + + start_loop { + if (str[i]==ch && i%2==0) + flag = true; + } + + display((flag ? "YES" : "NO")) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1660B - Vlad and Candies.cpp b/Codeforces Solutions/1660B - Vlad and Candies.cpp new file mode 100644 index 0000000..a234fa7 --- /dev/null +++ b/Codeforces Solutions/1660B - Vlad and Candies.cpp @@ -0,0 +1,51 @@ +//Author: Akash Gautam (@geekblower) +//Date: 14-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + if(n==1) { + if(arr[0]==1) + display("YES") + else + display("NO") + return; + } + + sort(arr, arr+n); + + if(arr[n-1] >= arr[n-2]+2) + display("NO") + else + display("YES") +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1676A - Lucky.cpp b/Codeforces Solutions/1676A - Lucky.cpp new file mode 100644 index 0000000..71757d3 --- /dev/null +++ b/Codeforces Solutions/1676A - Lucky.cpp @@ -0,0 +1,44 @@ +//Author: Akash Gautam (@geekblower) +//Date: 17-08-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + string str; + cin>>str; + + int left = (str[0] + str[1] + str[2]) - 144; + int right = (str[3] + str[4] + str[5]) - 144; + + if(left==right) + display("YES") + else + display("NO") +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} diff --git a/Codeforces Solutions/1692A - Marathon.cpp b/Codeforces Solutions/1692A - Marathon.cpp new file mode 100644 index 0000000..a96fafd --- /dev/null +++ b/Codeforces Solutions/1692A - Marathon.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +int main() { + int t; + cin>>t; + + while(t--) { + int a, b, c, d; + cin>>a>>b>>c>>d; + int count = 0; + + if(b>a) + count++; + if(c>a) + count++; + if(d>a) + count++; + + cout< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + string str; + cin>>str; + + if(str[0]=='y' || str[0]=='Y') { + if(str[1]=='e' || str[1]=='E') { + if(str[2]=='s' || str[2]=='S') + display("YES") + else + display("NO") + } else + display("NO") + } else + display("NO") +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} \ No newline at end of file diff --git a/Codeforces Solutions/1703B - ICPC Balloons.cpp b/Codeforces Solutions/1703B - ICPC Balloons.cpp new file mode 100644 index 0000000..cccbbee --- /dev/null +++ b/Codeforces Solutions/1703B - ICPC Balloons.cpp @@ -0,0 +1,56 @@ +//Author: Akash Gautam (@geekblower) +//Date: 12-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + string str; + cin>>str; + + SORT(str); + + int score = 0; + char ch = str[0]; + + loop(i, 0, n, 0) { + score += 2; + i++; + + while(str[i]==ch && i +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + vector position; + + start_loop { + create(k) + string str; + cin>>str; + position.PB (str); + } + + VI answer; + + start_loop { + int x = position[i].length(); + string str = position[i]; + int digit = arr[i]; + + loop(j, 0, x, 1) { + if(str[j]=='D') + digit = (digit==9) ? 0 : digit+1; + else + digit = (digit==0) ? 9 : digit-1; + } + + answer.PB (digit); + } + + print(answer) +} + +int32_t main() { + GEEKBLOWER + TEST_CASES + SOLUTION +} \ No newline at end of file diff --git a/Codeforces Solutions/200B - Drinks.cpp b/Codeforces Solutions/200B - Drinks.cpp new file mode 100644 index 0000000..2714930 --- /dev/null +++ b/Codeforces Solutions/200B - Drinks.cpp @@ -0,0 +1,44 @@ +//Author: Akash Gautam (@geekblower) +//Date: 12-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + float total = 0; + + start_loop + total += arr[i]; + + total /= n; + + display(total) +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/228A - Is your horseshoe on the other hoof.cpp b/Codeforces Solutions/228A - Is your horseshoe on the other hoof.cpp new file mode 100644 index 0000000..8c2c7c2 --- /dev/null +++ b/Codeforces Solutions/228A - Is your horseshoe on the other hoof.cpp @@ -0,0 +1,46 @@ +//Author: Akash Gautam (@geekblower) +//Date: 22-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + int n = 4; + def(arr,n) + sort(arr, arr+n); + int ans = 0; + + start_loop { + while(arr[i]==arr[i+1] && i +using namespace std; + +int main() { + int n; + cin>>n; + int arr[1000][1000]; + int total = 0; + + for(int i=0; i>arr[i][j]; + if(arr[i][j]==1) + c++; + } + if(c>1) + total ++; + } + + cout< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + + if(n&1) { + display("-1") + return; + } + + int *ans = new int[n]; + + for(int i=0, j=1; i +#include +#include +using namespace std; + +int main(){ + string user_name; + cin>>user_name; + sort(user_name.begin(), user_name.end()); + + for(int i=0; user_name[i]!='\0';) { + if(user_name[i] == user_name[i+1]) + user_name.erase (user_name.begin() + i); + else + i++; + } + + int size = user_name.size(); + if(size&1) + cout<<"IGNORE HIM!"; + else + cout<<"CHAT WITH HER!"; + + return 0; +} \ No newline at end of file diff --git a/Codeforces Solutions/263A - Beautiful Matrix.cpp b/Codeforces Solutions/263A - Beautiful Matrix.cpp new file mode 100644 index 0000000..ca301f6 --- /dev/null +++ b/Codeforces Solutions/263A - Beautiful Matrix.cpp @@ -0,0 +1,28 @@ +#include +#include +using namespace std; + +int main() { + int matrix[5][5]; + // Variables to store the location of '1' + int one_i=0, one_j=0; + + // Inputting the matrix + for(int i=0; i<5; i++) { + for(int j=0; j<5; j++) { + cin>>matrix[i][j]; + if(matrix[i][j]) { + one_i = i+1; + one_j = j+1; + } + } + } + + int count = 0; + count += abs(one_i-3); + count += abs(one_j-3); + + cout< +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>str; + + int count=0; + loop(i, 0, n-1, 1) { + if(str[i] == str[i+1]) + count++; + } + + display(count) +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/281A - Word Capitalization.cpp b/Codeforces Solutions/281A - Word Capitalization.cpp new file mode 100644 index 0000000..e64e141 --- /dev/null +++ b/Codeforces Solutions/281A - Word Capitalization.cpp @@ -0,0 +1,11 @@ +#include +#include +using namespace std; + +int main() { + string str; + cin>>str; + if(str[0]>='a' && str[0]<='z') + str[0] -= 32; + cout< +#include +using namespace std; + +int main(){ + int n; + cin>>n; + int x = 0; + + while(n--) { + string str; + cin>>str; + if(str[1]=='+') + x += 1; + else + x -= 1; + } + + cout< +#include +#include +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)); +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>str; + VI nums; + loop(i, 0, str.length(), 2) { + int n = str[i] - 48; + nums.PB (n); + } + SORT(nums) + + int i=0; + loop(j, 0, str.length(), 2) { + char ch = nums[i] + 48; + str[j] = ch; + i++; + } + + display(str) +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/344A - Magnets.cpp b/Codeforces Solutions/344A - Magnets.cpp new file mode 100644 index 0000000..a713d08 --- /dev/null +++ b/Codeforces Solutions/344A - Magnets.cpp @@ -0,0 +1,43 @@ +//Author: Akash Gautam (@geekblower) +//Date: 24-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + int count = 1; + loop(i, 0, n-1, 1) { + if(arr[i]!=arr[i+1]) + count++; + } + + display(count) +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/381A - Sereja and Dima.cpp b/Codeforces Solutions/381A - Sereja and Dima.cpp new file mode 100644 index 0000000..a6bed2d --- /dev/null +++ b/Codeforces Solutions/381A - Sereja and Dima.cpp @@ -0,0 +1,64 @@ +//Author: Akash Gautam (@geekblower) +//Date: 03-07-2022 +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +//#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>arr[i]; + + int start = 0; + int end = n-1; + + int player1 = 0; + int player2 = 0; + + while(start<=end) { + // For player 1 + if(arr[start] <= arr[end]) { + player1 += arr[end]; + end--; + } else { + player1 += arr[start]; + start++; + } + + // For player 2 + if(arr[start] <= arr[end] && start<=end) { + player2 += arr[end]; + end--; + } else if(arr[start] > arr[end] && start<=end) { + player2 += arr[start]; + start++; + } + } + + display(player1<<" "< +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + def(arr,n) + + int police=0, ans=0; + + start_loop { + if(arr[i]>0) + police += arr[i]; + else { + if(police) + police--; + else + ans++; + } + } + + display(ans) +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/443A - Anton and Letters.cpp b/Codeforces Solutions/443A - Anton and Letters.cpp new file mode 100644 index 0000000..8cba163 --- /dev/null +++ b/Codeforces Solutions/443A - Anton and Letters.cpp @@ -0,0 +1,55 @@ +//Author: Akash Gautam (@geekblower) +//Date: 29-06-2022 +#include +#include +#include +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)); +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>ch; + if(ch>='a' && ch<='z') + mystr.PB (ch); + } + + SORT(mystr) + int n = mystr.length(); + + int i=0, count=0; + while(i='a' && mystr[i]<='z') + count++; + while(mystr[i] == mystr[i+1] && i +using namespace std; + +#define endl '\n' +#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); +#define int long long int +#define TEST_CASES create(t);while(t--) +#define SOLUTION solve(); return 0; +#define display(n) cout< +#define PB push_back +#define ALL(a) a.begin(),a.end() +#define SORT(a) sort(ALL(a)) +#define loop(i,a,b,c) for(int i=a;i=b;i-=c) +#define start_loop loop(i,0,n,1) +#define start_revloop revloop(i,n,0,1) +#define create(n) int n;cin>>n; +#define def(a,n) int a[n];start_loop cin>>a[i]; +#define print(a) for(auto i : a){cout<>x;a.PB(x);} +inline int GCD(int a,int b){return !b?a:GCD(b,a%b);} +const int MOD = 1000000007; + +void solve() { + create(n) + int ans = 0; + + while(n--) { + create(p) + create(q) + + if(q-p >= 2) + ans++; + } + + display(ans) +} + +int32_t main() { + GEEKBLOWER + SOLUTION +} diff --git a/Codeforces Solutions/4A - Watermelon.cpp b/Codeforces Solutions/4A - Watermelon.cpp new file mode 100644 index 0000000..3c17033 --- /dev/null +++ b/Codeforces Solutions/4A - Watermelon.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; + +int main() { + int w; + cin>>w; + + if(w%2 || w==2) + cout<<"NO"; + else + cout<<"YES"; + + return 0; +} \ No newline at end of file