diff --git a/1296A Array with Odd Sum/1296A.cpp b/1296A Array with Odd Sum/1296A.cpp new file mode 100644 index 0000000..5b8eb82 --- /dev/null +++ b/1296A Array with Odd Sum/1296A.cpp @@ -0,0 +1,106 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define lld long double +#define ull unsigned long long +#define endl '\n' +#define ff first +#define ss second +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ins insert +#define fr(i, a, b) for(int i=a; ib; --i) +#define nf(i, n) for(int i=n-1; i>=0; --i) + +// STLs +#define PII pair +#define VI vector +#define VVI vector> +#define SI set +#define SC set +#define MII map +#define VLL vector +#define VVL vector> +#define SL set + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int n; + cin>>n; + int odd=0, even=0; + fn(i,n) + { + int x; + cin>>x; + if(x&1) + odd++; + else + even++; + } + if(odd==0) + no; + else if(even==0 && n%2==0) + no; + else + yes; +} + +int32_t main() +{ + FAST_IO; + int TC = 1; + cin >> TC; + while (TC--) solve(); +} \ No newline at end of file diff --git a/1833A Musical Puzzle/1833A.cpp b/1833A Musical Puzzle/1833A.cpp new file mode 100644 index 0000000..fc34f4f --- /dev/null +++ b/1833A Musical Puzzle/1833A.cpp @@ -0,0 +1,79 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define endl '\n' +#define ff first +#define ss second +#define pb push_back +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int n; + string s; + cin>>n>>s; + setst; + for(int i=0; i> TC; + while (TC--) + solve(); +} \ No newline at end of file diff --git a/1833B Restore the Weather/1833B.cpp b/1833B Restore the Weather/1833B.cpp new file mode 100644 index 0000000..5cd6a5c --- /dev/null +++ b/1833B Restore the Weather/1833B.cpp @@ -0,0 +1,90 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define endl '\n' +#define ff first +#define ss second +#define pb push_back +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int n,k; + cin>>n>>k; + vector>a; + vectorb(n),c(n); + for(int i=0; i>x; + a.pb({x,i}); + } + for(int i=0; i>b[i]; + sort(all(a)); + sort(all(b)); + for(int i=0; i> TC; + while (TC--) + solve(); +} \ No newline at end of file diff --git a/1843B Long Long/1843B.cpp b/1843B Long Long/1843B.cpp new file mode 100644 index 0000000..e48b54b --- /dev/null +++ b/1843B Long Long/1843B.cpp @@ -0,0 +1,93 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define endl '\n' +#define ff first +#define ss second +#define pb push_back +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int n; + cin>>n; + vectorv; + for(int i=0; i>x; + if(x!=0) + v.pb(x); + } + ll sum=0,ct=0; + bool flag = 1; + for(auto x: v) + { + if(x<0 && flag) + { + ct++; + flag = 0; + } + else if(x>0) + flag = 1; + sum += abs(x); + } + cout<> TC; + while (TC--) + solve(); +} \ No newline at end of file diff --git a/1875A Jellyfish and Undertale/1875A.cpp b/1875A Jellyfish and Undertale/1875A.cpp new file mode 100644 index 0000000..b88a23c --- /dev/null +++ b/1875A Jellyfish and Undertale/1875A.cpp @@ -0,0 +1,98 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define lld long double +#define ull unsigned long long +#define endl '\n' +#define ff first +#define ss second +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ins insert +#define fr(i, a, b) for(int i=a; ib; --i) +#define rf(i, n) for(int i=n; i>0; --i) + +// STLs +#define PII pair +#define VI vector +#define VVI vector> +#define SI set +#define SC set +#define MII map +#define VLL vector +#define VVL vector> +#define SL set + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int a,b,n; + cin>>a>>b>>n; + int ans=b; + for(int i=0; i>x; + ans+=min(x,a-1); + } + cout<> TC; + while (TC--) solve(); +} \ No newline at end of file diff --git a/1879B Chips on the Board/1879B.cpp b/1879B Chips on the Board/1879B.cpp new file mode 100644 index 0000000..95be529 --- /dev/null +++ b/1879B Chips on the Board/1879B.cpp @@ -0,0 +1,99 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define lld long double +#define ull unsigned long long +#define endl '\n' +#define ff first +#define ss second +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ins insert +#define fr(i, a, b) for(int i=a; i +#define VI vector +#define VVI vector> +#define SI set +#define SC set +#define MII map +#define VLL vector +#define VVL vector> +#define SL set + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int n; + cin>>n; + VI a(n), b(n); + fr(i, n) cin>>a[i]; + fr(i, n) cin>>b[i]; + sort(all(a)); + sort(all(b)); + int row=0, col=0; + fr(i,n) + row+=a[i]+b[0]; + fr(i,n) + col+=b[i]+a[0]; + cout<> TC; + while (TC--) solve(); +} \ No newline at end of file diff --git a/1900A Cover in Water/1900A.cpp b/1900A Cover in Water/1900A.cpp new file mode 100644 index 0000000..983d30b --- /dev/null +++ b/1900A Cover in Water/1900A.cpp @@ -0,0 +1,108 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define lld long double +#define ull unsigned long long +#define endl '\n' +#define ff first +#define ss second +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ins insert + +// STLs +#define PII pair +#define VI vector +#define VVI vector> +#define SI set +#define SC set +#define MII map +#define VLL vector +#define VVL vector> +#define SL set + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int n; + string s; + cin>>n>>s; + int cnt=0, ct=0, mx=0; + for(char c : s) + { + if(c == '.') + { + cnt++; + ct++; + } + if(c == '#') + { + mx=max(mx,ct); + ct=0; + } + } + mx=max(ct,mx); + if(cnt==0) + cout<<0<2) + cout<<2<> TC; + while (TC--) solve(); +} \ No newline at end of file diff --git a/1900B Laura and Operations/1900B.cpp b/1900B Laura and Operations/1900B.cpp new file mode 100644 index 0000000..63c2e32 --- /dev/null +++ b/1900B Laura and Operations/1900B.cpp @@ -0,0 +1,115 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define lld long double +#define ull unsigned long long +#define endl '\n' +#define ff first +#define ss second +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ins insert + +// STLs +#define PII pair +#define VI vector +#define VVI vector> +#define SI set +#define SC set +#define MII map +#define VLL vector +#define VVL vector> +#define SL set + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int a,b,c,x,y,z,tmp; + cin>>a>>b>>c; + VI v(3,0); + + x=a, y=b, z=c; + tmp=min(y,z); + y-=tmp; + z-=tmp; + x+=tmp; + if(x>0 && max(y,z)%2==0) + v[0]=1; + + x=a, y=b, z=c; + tmp=min(x,z); + x-=tmp; + z-=tmp; + y+=tmp; + if(y>0 && max(x,z)%2==0) + v[1]=1; + + x=a, y=b, z=c; + tmp=min(x,y); + x-=tmp; + y-=tmp; + z+=tmp; + if(z>0 && max(x,y)%2==0) + v[2]=1; + + for(auto ele:v) + cout<> TC; + while (TC--) solve(); +} \ No newline at end of file diff --git a/1907A Rook/1907A.cpp b/1907A Rook/1907A.cpp new file mode 100644 index 0000000..0e00864 --- /dev/null +++ b/1907A Rook/1907A.cpp @@ -0,0 +1,102 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define lld long double +#define ull unsigned long long +#define endl '\n' +#define ff first +#define ss second +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ins insert + +// STLs +#define PII pair +#define VI vector +#define VVI vector> +#define SI set +#define SC set +#define MII map +#define VLL vector +#define VVL vector> +#define SL set + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + string s; + cin>>s; + string ch ="abcdefgh"; + int it = ch.find(s[0]); + for(int i=0; i> TC; + while (TC--) solve(); +} \ No newline at end of file diff --git a/1907B YetnotherrokenKeoard/1907B.cpp b/1907B YetnotherrokenKeoard/1907B.cpp new file mode 100644 index 0000000..231c5f1 --- /dev/null +++ b/1907B YetnotherrokenKeoard/1907B.cpp @@ -0,0 +1,112 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define lld long double +#define ull unsigned long long +#define endl '\n' +#define ff first +#define ss second +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ins insert + +// STLs +#define PII pair +#define VI vector +#define VVI vector> +#define SI set +#define SC set +#define MII map +#define VLL vector +#define VVL vector> +#define SL set + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + string s,ans=""; + cin>>s; + int small=0, capital=0; + for(int i=sz(s)-1; i>=0; --i) + { + char c=s[i]; + if(islower(c)) + { + if(c=='b') + small++; + else if(small) + small--; + else + ans+=c; + } + else + { + if(c=='B') + capital++; + else if(capital) + capital--; + else + ans+=c; + } + } + reverse(all(ans)); + cout<> TC; + while (TC--) solve(); +} \ No newline at end of file diff --git a/456B Fedya and Maths/456B.cpp b/456B Fedya and Maths/456B.cpp new file mode 100644 index 0000000..cd649e5 --- /dev/null +++ b/456B Fedya and Maths/456B.cpp @@ -0,0 +1,105 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define lld long double +#define ull unsigned long long +#define endl '\n' +#define ff first +#define ss second +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ins insert +#define fr(i, a, b) for(int i=a; ib; --i) +#define nf(i, n) for(int i=n; i>0; --i) + +// STLs +#define PII pair +#define VI vector +#define VVI vector> +#define SI set +#define SC set +#define MII map +#define VLL vector +#define VVL vector> +#define SL set + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + string s; + cin>>s; + if(sz(s)<2) + { + int n=s[0]-'0'; + if(n%4) + cout<<0<> TC; + while (TC--) solve(); +} \ No newline at end of file