diff --git a/Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/input1 b/Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/input1 new file mode 100644 index 0000000..f1359d9 --- /dev/null +++ b/Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/input1 @@ -0,0 +1,18 @@ +2 +2 +5 +-> 4 3 +<- 15 +<- 4 +-> 3 1 +-> 1 3 +1 +8 +-> 1 1 +-> 1 2 +-> 2 1 +-> 2 2 +<- 1 +<- 2 +<- 3 +<- 4 diff --git a/Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/output1 b/Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/output1 new file mode 100644 index 0000000..6570706 --- /dev/null +++ b/Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/output1 @@ -0,0 +1,13 @@ +7 +2 3 +1 2 +9 +13 +1 +4 +3 +2 +1 1 +2 2 +2 1 +1 2 diff --git a/Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/solution.cpp b/Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/solution.cpp new file mode 100644 index 0000000..b02c98c --- /dev/null +++ b/Codeforces/CodeforcesRound1016(Div3)/DSkibidiTable/solution.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +struct { + +} + + +void solve() { + int q; + cin >> q; +} + +int main() { + int t; + cin >> t; + while (t--) + solve(); +} diff --git a/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/cpp.out b/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/cpp.out new file mode 100755 index 0000000..e98c9f6 Binary files /dev/null and b/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/cpp.out differ diff --git a/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/input1 b/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/input1 new file mode 100644 index 0000000..6a75dbf --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/input1 @@ -0,0 +1,6 @@ +5 +2 +4 +5 +7 +100 diff --git a/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/output1 b/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/output1 new file mode 100644 index 0000000..588f4c3 --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/output1 @@ -0,0 +1,5 @@ +Alice +Bob +Alice +Alice +Bob diff --git a/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/solution.cpp b/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/solution.cpp new file mode 100644 index 0000000..9ef655f --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/ABlackboardGame/solution.cpp @@ -0,0 +1,16 @@ +#include + +using namespace std; + +int main() { + int t; + cin >> t; + while (t--) { + int n; + cin >> n; + if (!(n & ((1 << 2) - 1))) + cout << "Bob\n"; + else + cout << "Alice\n"; + } +} diff --git a/Codeforces/CodeforcesRound1034(Div3)/BTournament/cpp.out b/Codeforces/CodeforcesRound1034(Div3)/BTournament/cpp.out new file mode 100755 index 0000000..29d6cfa Binary files /dev/null and b/Codeforces/CodeforcesRound1034(Div3)/BTournament/cpp.out differ diff --git a/Codeforces/CodeforcesRound1034(Div3)/BTournament/input1 b/Codeforces/CodeforcesRound1034(Div3)/BTournament/input1 new file mode 100644 index 0000000..4feb537 --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/BTournament/input1 @@ -0,0 +1,7 @@ +3 +5 2 3 +3 2 4 4 1 +5 4 1 +5 3 4 5 2 +6 1 1 +1 2 3 4 5 6 diff --git a/Codeforces/CodeforcesRound1034(Div3)/BTournament/output1 b/Codeforces/CodeforcesRound1034(Div3)/BTournament/output1 new file mode 100644 index 0000000..5ae1e3d --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/BTournament/output1 @@ -0,0 +1,3 @@ +YES +YES +NO diff --git a/Codeforces/CodeforcesRound1034(Div3)/BTournament/solution.cpp b/Codeforces/CodeforcesRound1034(Div3)/BTournament/solution.cpp new file mode 100644 index 0000000..1f38483 --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/BTournament/solution.cpp @@ -0,0 +1,30 @@ +#include +#include +#include + +using namespace std; + +void solve() { + int n, j, k; + cin >> n >> j >> k; + vector a(n); + for (auto &i : a) + cin >> i; + + if (a[j - 1] == *max_element(a.begin(), a.end())) { + cout << "YES\n"; + return; + } + + if (k >= 2) + cout << "YES\n"; + else + cout << "NO\n"; +} + +int main() { + int t; + cin >> t; + while (t--) + solve(); +} diff --git a/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/cpp.out b/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/cpp.out new file mode 100755 index 0000000..e3e847c Binary files /dev/null and b/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/cpp.out differ diff --git a/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/input1 b/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/input1 new file mode 100644 index 0000000..67e5e05 --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/input1 @@ -0,0 +1,7 @@ +3 +6 +1 3 5 4 7 2 +4 +13 10 12 20 +7 +1 2 3 4 5 6 7 diff --git a/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/output1 b/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/output1 new file mode 100644 index 0000000..6f18e66 --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/output1 @@ -0,0 +1,3 @@ +100011 +1101 +1000001 diff --git a/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/solution.cpp b/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/solution.cpp new file mode 100644 index 0000000..259fdac --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/CPrefixMinandSuffixMax/solution.cpp @@ -0,0 +1,40 @@ +#include +#include + +using namespace std; + +void min_maxer(vector &_a, vector &pre, vector &stu, + vector &map) { + int n = _a.size(); + map[0] = true; + map[n - 1] = true; + + for (int i = 1; i < n; i++) { + if (_a[i] < _a[i - 1]) + map[i] = true; + if (_a[n - i - 1] < _a[n - i - 2]) + map[i] = true; + } +} + +void solve() { + int n; + cin >> n; + vector a(n); + for (auto &i : a) + cin >> i; + + vector min_prefix(n), max_stufix(n); + vector map(n); + min_maxer(a, min_prefix, max_stufix, map); + for (auto i : map) + cout << i; + cout << "\n"; +} + +int main() { + int t; + cin >> t; + while (t--) + solve(); +} diff --git a/Codeforces/CodeforcesRound1034(Div3)/EMEXCount/input1 b/Codeforces/CodeforcesRound1034(Div3)/EMEXCount/input1 new file mode 100644 index 0000000..7698c96 --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/EMEXCount/input1 @@ -0,0 +1,11 @@ +5 +5 +1 0 0 1 2 +6 +3 2 0 4 5 1 +6 +1 2 0 1 3 2 +4 +0 3 4 1 +5 +0 0 0 0 0 diff --git a/Codeforces/CodeforcesRound1034(Div3)/EMEXCount/output1 b/Codeforces/CodeforcesRound1034(Div3)/EMEXCount/output1 new file mode 100644 index 0000000..1e89584 --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/EMEXCount/output1 @@ -0,0 +1,5 @@ +1 2 4 3 2 1 +1 6 5 4 3 2 1 +1 3 5 4 3 2 1 +1 3 3 2 1 +1 1 1 1 1 1 diff --git a/Codeforces/CodeforcesRound1034(Div3)/EMEXCount/solution.cpp b/Codeforces/CodeforcesRound1034(Div3)/EMEXCount/solution.cpp new file mode 100644 index 0000000..51f6f8e --- /dev/null +++ b/Codeforces/CodeforcesRound1034(Div3)/EMEXCount/solution.cpp @@ -0,0 +1,31 @@ +#include "iostream" +#include + +using namespace std; + +void solve() { + int n, x; + cin >> n; + map hash_map; + + for (int i = 0; i < n; i++) { + cin >> x; + if (hash_map.count(x) == 0) + hash_map[x] = 1; + else + hash_map[x]++; + } + + for (int k = 0; k <= n; k++) { + int cur_mex = 0; + for (auto &i : hash_map) { + } + } +} + +int main() { + int t; + cin >> t; + while (t--) + solve(); +} diff --git a/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/cpp.out b/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/cpp.out new file mode 100755 index 0000000..90c6b91 Binary files /dev/null and b/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/cpp.out differ diff --git a/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/input1 b/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/input1 new file mode 100644 index 0000000..261553a --- /dev/null +++ b/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/input1 @@ -0,0 +1,8 @@ +7 +1 4 1 2 +1 5 2 1 +3 2 2 1 +1 3 2 1 +2 1 1 2 +3 1 1 2 +1 100 10000000 10000000 diff --git a/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/output1 b/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/output1 new file mode 100644 index 0000000..c4cb0be --- /dev/null +++ b/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/output1 @@ -0,0 +1,7 @@ +3 +6 +1 +3 +-1 +-1 +990000000 diff --git a/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/solution.cpp b/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/solution.cpp new file mode 100644 index 0000000..43c0907 --- /dev/null +++ b/Codeforces/CodeforcesRound1035(Div2)/AAddorXOR/solution.cpp @@ -0,0 +1,43 @@ +#include + +using namespace std; + +void solve() { + int a, b, x, y; + cin >> a >> b >> x >> y; + + if (a > b) { + if (a - b == 1) { + if (a % 2 != 0) { + cout << y << endl; + return; + } + } + cout << "-1\n"; + + return; + } + + int diff = b - a; + int xdiff = diff * x; + if (diff % 2 == 0) { + cout << min(xdiff, ((diff * x) / 2) + ((diff * y) / 2)) << endl; + return; + } else { + if (a % 2 != 0) { + + cout << min(xdiff, (diff / 2 + 1) * x + (diff / 2) * y) << endl; + return; + } else { + cout << min(xdiff, (diff / 2) * x + (diff / 2 + 1) * y) << endl; + return; + } + } +} + +int main() { + int t; + cin >> t; + while (t--) + solve(); +} diff --git a/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/cpp.out b/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/cpp.out new file mode 100755 index 0000000..71a9dca Binary files /dev/null and b/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/cpp.out differ diff --git a/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/input1 b/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/input1 new file mode 100644 index 0000000..5bd8040 --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/input1 @@ -0,0 +1,6 @@ +5 +6 +96 +78 +122 +696 diff --git a/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/output1 b/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/output1 new file mode 100644 index 0000000..b7e83d3 --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/output1 @@ -0,0 +1,5 @@ +6 +6 +7 +1 +6 diff --git a/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/solution.cpp b/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/solution.cpp new file mode 100644 index 0000000..8524ddc --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/AOnlyOneDigit/solution.cpp @@ -0,0 +1,20 @@ +#include +#include + +using namespace std; + +int main() { + int t; + cin >> t; + while (t--) { + int x; + cin >> x; + string xstr = to_string(x); + + int res = 10; + for (const char &i : xstr) { + res = min(res, (int)(i - '0')); + } + cout << res << endl; + } +} diff --git a/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/cpp.out b/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/cpp.out new file mode 100755 index 0000000..19a880c Binary files /dev/null and b/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/cpp.out differ diff --git a/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/input1 b/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/input1 new file mode 100644 index 0000000..279bd7c --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/input1 @@ -0,0 +1,11 @@ +5 +5 1 +0 1 0 0 0 +7 3 +0 0 0 0 0 0 0 +3 1 +1 1 1 +4 2 +0 1 0 1 +6 2 +0 0 1 0 0 0 diff --git a/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/output1 b/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/output1 new file mode 100644 index 0000000..541f409 --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/output1 @@ -0,0 +1,5 @@ +3 +2 +0 +0 +2 diff --git a/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/solution.cpp b/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/solution.cpp new file mode 100644 index 0000000..c9e6ad2 --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/solution.cpp @@ -0,0 +1,38 @@ +#include +#include + +using namespace std; + +void solve() { + int n, k; + cin >> n >> k; + vector a(n); + for (int &i : a) + cin >> i; + + int res = 0; + int len = 0; + for (int i = 0; i < n; i++) { + if (len == k) { + len = 0; + res++; + continue; + } + if (a[i] == 0) { + len++; + } + if (a[i] == 1) { + len = 0; + } + } + if (len == k) + res++; + cout << res << endl; +} + +int main() { + int t; + cin >> t; + while (t--) + solve(); +} diff --git a/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/cpp.out b/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/cpp.out new file mode 100755 index 0000000..5eb4196 Binary files /dev/null and b/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/cpp.out differ diff --git a/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/input1 b/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/input1 new file mode 100644 index 0000000..5129cd2 --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/input1 @@ -0,0 +1,11 @@ +5 +5 3 +3 2 1 4 5 +3 1 +1 3 4 +4 4 +4 4 4 2 +6 2 +2 3 6 9 1 2 +4 2 +1 2 5 6 diff --git a/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/output1 b/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/output1 new file mode 100644 index 0000000..6591b85 --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/output1 @@ -0,0 +1,5 @@ +YES +NO +YES +YES +NO diff --git a/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/solution.cpp b/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/solution.cpp new file mode 100644 index 0000000..1e2e3c9 --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/solution.cpp @@ -0,0 +1,37 @@ +#include +#include +#include + +using namespace std; + +void solve() { + int n, k; + cin >> n >> k; + vector a(n); + for (auto &i : a) + cin >> i; + int h = a[k - 1]; + sort(a.begin(), a.end()); + + int time = 0; + for (auto H : a) { + if (H <= h) + continue; + time += H - h; + if (time > h) { + cout << "NO\n"; + return; + } + h = H; + } + + cout << "YES\n"; +} + +int main() { + int t; + cin >> t; + while (t--) { + solve(); + } +} diff --git a/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/cpp.out b/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/cpp.out new file mode 100755 index 0000000..49111aa Binary files /dev/null and b/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/cpp.out differ diff --git a/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/input1 b/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/input1 new file mode 100644 index 0000000..f45da25 --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/input1 @@ -0,0 +1,16 @@ +5 +6 +72 24 3 3 3 3 +3 3 3 6 12 144 +3 +1 2 3 +4 5 6 +5 +125 125 125 25 25 +25 25 25 25 75 +4 +123 421 282 251 +125 1981 239 223 +3 +124 521 125 +125 121 121 diff --git a/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/output1 b/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/output1 new file mode 100644 index 0000000..eea5076 --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/output1 @@ -0,0 +1,5 @@ +YES +NO +YES +NO +NO diff --git a/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/solution.cpp b/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/solution.cpp new file mode 100644 index 0000000..b03c235 --- /dev/null +++ b/Codeforces/CodeforcesRound1037(Div3)/EGCD,Unlucky!/solution.cpp @@ -0,0 +1,48 @@ +#include +#include + +using namespace std; + +void solve() { + int n; + cin >> n; + vector pre(n), stu(n); + for (int &i : pre) + cin >> i; + for (int &i : stu) + cin >> i; + + if (pre[n - 1] != stu[0]) { + cout << "NO\n"; + return; + } + + for (int i = 0; i < n - 1; i++) { + if (pre[i] < pre[i + 1]) { + cout << "NO\n"; + return; + } + if (pre[i] % pre[i + 1] != 0) { + cout << "NO\n"; + return; + } + } + for (int i = n - 1; i > 0; i--) { + if (stu[i] < stu[i - 1]) { + cout << "NO\n"; + return; + } + if (stu[i] % stu[i - 1] != 0) { + cout << "NO\n"; + return; + } + } + cout << "YES\n"; +} + +int main() { + int t; + cin >> t; + while (t--) + solve(); +} diff --git a/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/cpp.out b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/cpp.out new file mode 100755 index 0000000..87b3df3 Binary files /dev/null and b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/cpp.out differ diff --git a/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/input1 b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/input1 new file mode 100644 index 0000000..8bd0b33 --- /dev/null +++ b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/input1 @@ -0,0 +1,7 @@ +3 +3 +2 2 3 +5 +4 5 5 2 4 +1 +1 diff --git a/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/output1 b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/output1 new file mode 100644 index 0000000..bfdd612 --- /dev/null +++ b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/output1 @@ -0,0 +1,5 @@ +NO +YES +4 +4 5 2 4 +NO diff --git a/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/solution.cpp b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/solution.cpp new file mode 100644 index 0000000..23bbb12 --- /dev/null +++ b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/ADerangedDeletions/solution.cpp @@ -0,0 +1,27 @@ +#include +#include +using namespace std; + +void solve() { + int n; + cin >> n; + vector a(n); + for (int &i : a) + cin >> i; + + for (int i = 0; i < n - 1; i++) { + if (a[i] > a[i + 1]) { + cout << "YES\n2\n"; + cout << a[i] << " " << a[i + 1] << "\n"; + return; + } + } + cout << "NO\n"; +} + +int main() { + int t; + cin >> t; + while (t--) + solve(); +} diff --git a/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/cpp.out b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/cpp.out new file mode 100755 index 0000000..07a8b1b Binary files /dev/null and b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/cpp.out differ diff --git a/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/input1 b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/input1 new file mode 100644 index 0000000..af4811d --- /dev/null +++ b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/input1 @@ -0,0 +1,7 @@ +3 +2 +1 2 +3 +1 2 3 +4 +3 0 2 3 diff --git a/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/output1 b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/output1 new file mode 100644 index 0000000..179d8a7 --- /dev/null +++ b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/output1 @@ -0,0 +1,3 @@ +2 +2 +3 diff --git a/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/solution.cpp b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/solution.cpp new file mode 100644 index 0000000..800e18b --- /dev/null +++ b/Codeforces/EPICInstituteofTechnologyRoundSummer2025(CodeforcesRound1036,Div1Div2)/BMinimiseSum/solution.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +using namespace std; + +void solve() { + int n; + cin >> n; + vector a(n); + for (auto &i : a) + cin >> i; + + cout << min(a[0] + a[1], 2 * a[0]) << "\n"; +} + +int main() { + int t; + cin >> t; + while (t--) + solve(); +} diff --git a/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/cpp.out b/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/cpp.out new file mode 100755 index 0000000..4c16e8c Binary files /dev/null and b/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/cpp.out differ diff --git a/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/input1 b/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/input1 new file mode 100644 index 0000000..b52e52d --- /dev/null +++ b/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/input1 @@ -0,0 +1,3 @@ +2 +1 +3 diff --git a/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/output1 b/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/output1 new file mode 100644 index 0000000..2b24e31 --- /dev/null +++ b/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/output1 @@ -0,0 +1,2 @@ +2 +6 diff --git a/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/solution.cpp b/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/solution.cpp new file mode 100644 index 0000000..6969311 --- /dev/null +++ b/Codeforces/EducationalCodeforcesRound177(RatedforDiv2)/ACloudberryJam/solution.cpp @@ -0,0 +1,14 @@ +#include + +using namespace std; + +int main() { + int t; + cin >> t; + + while (t--) { + int n; + cin >> n; + cout << 2 * n << '\n'; + } +} diff --git a/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/cpp.out b/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/cpp.out new file mode 100755 index 0000000..9359bbb Binary files /dev/null and b/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/cpp.out differ diff --git a/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/input1 b/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/input1 new file mode 100644 index 0000000..6a021e2 --- /dev/null +++ b/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/input1 @@ -0,0 +1,11 @@ +5 +4 +2 3 5 7 +4 +115 9 2 28 +5 +8 4 1 6 2 +6 +1 5 4 1 4 7 +2 +100000 100000 diff --git a/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/output1 b/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/output1 new file mode 100644 index 0000000..68f6e38 --- /dev/null +++ b/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/output1 @@ -0,0 +1,5 @@ +YES +NO +NO +YES +YES diff --git a/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/solution.cpp b/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/solution.cpp new file mode 100644 index 0000000..23ca73a --- /dev/null +++ b/Codeforces/GoodBye20242025isNEAR/ATenderCarpenter/solution.cpp @@ -0,0 +1,55 @@ +#include + +using namespace std; + +int a[200]; + +bool check(int a, int b, int c) { + if (a + b <= c) + return false; + if (a + c <= b) + return false; + if (b + c <= a) + return false; + return true; +} + +void run() { + int n; + cin >> n; + for (int i = 0; i < n; i++) + cin >> a[i]; + + if (n == 2) { + if (check(a[0], a[0], a[1]) || check(a[0], a[1], a[1])) { + cout << "YES\n"; + } else { + cout << "NO\n"; + } + return; + } + + for (int i = 0; i < n - 2; i++) { + if (check(a[i], a[i + 1], a[i + 2])) { + cout << "YES\n"; + return; + } + } + + for (int i = 0; i < n - 1; i++) { + if (check(a[i], a[i], a[i + 1]) || check(a[i], a[i + 1], a[i + 1])) { + cout << "YES\n"; + return; + } + } + + cout << "NO\n"; +} + +int main() { + int t; + cin >> t; + while (t--) { + run(); + }; +} diff --git a/misc/bdhsg_1015/a.out b/misc/bdhsg_1015/a.out new file mode 100755 index 0000000..25f172d Binary files /dev/null and b/misc/bdhsg_1015/a.out differ diff --git a/misc/bdhsg_1015/max3.cpp b/misc/bdhsg_1015/max3.cpp new file mode 100644 index 0000000..5bed425 --- /dev/null +++ b/misc/bdhsg_1015/max3.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + freopen("max3.inp", "r", stdin); + + int n; + cin >> n; + vector a(n); + for (int &i : a) + cin >> i; + + int res = 0; + for (int i = 0; i < n - 2; i++) + res = max(res, a[i] + a[i + 1] + a[i + 2]); + + cout << res << '\n'; +} diff --git a/misc/bdhsg_1015/max3.inp b/misc/bdhsg_1015/max3.inp new file mode 100644 index 0000000..303352e --- /dev/null +++ b/misc/bdhsg_1015/max3.inp @@ -0,0 +1,2 @@ +6 +1 3 4 2 7 9 diff --git a/misc/bdhsg_1015/search.cpp b/misc/bdhsg_1015/search.cpp new file mode 100644 index 0000000..ecac5c8 --- /dev/null +++ b/misc/bdhsg_1015/search.cpp @@ -0,0 +1,32 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + freopen("search.inp", "r", stdin); + + int n, x; + cin >> n >> x; + vector a(n); + for (int &i : a) + cin >> i; + + if (x - 1 > n || x < 0) { + cout << -1 << '\n'; + return 0; + } else { + x = a[x - 1]; + } + int cnt = 0; + for (int i = 0; i < n; i++) { + // cout << a[i] << '\n'; + if (a[i] == x) { + cout << i + 1 << ' '; + cnt++; + } + } + cout << '\n'; + cout << ((cnt == 0) ? -1 : cnt) << '\n'; +} diff --git a/misc/bdhsg_1015/search.inp b/misc/bdhsg_1015/search.inp new file mode 100644 index 0000000..6ffc301 --- /dev/null +++ b/misc/bdhsg_1015/search.inp @@ -0,0 +1,2 @@ +6 2 +1 3 3 5 7 3 diff --git a/misc/bdhsg_1015/search2.cpp b/misc/bdhsg_1015/search2.cpp new file mode 100644 index 0000000..e69de29 diff --git a/misc/bdhsg_1015/search2.inp b/misc/bdhsg_1015/search2.inp new file mode 100644 index 0000000..e69de29 diff --git a/misc/binary-search/cpp.out b/misc/binary-search/cpp.out new file mode 100755 index 0000000..fddedb8 Binary files /dev/null and b/misc/binary-search/cpp.out differ diff --git a/misc/binary-search/ghepcap.cpp b/misc/binary-search/ghepcap.cpp new file mode 100644 index 0000000..4861b69 --- /dev/null +++ b/misc/binary-search/ghepcap.cpp @@ -0,0 +1,35 @@ +#include + +using namespace std; + +int a[100000]; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + freopen("ghepcap.inp", "r", stdin); + + int n; + cin >> n; + for (int i = 0; i < n; i++) + cin >> a[i]; + sort(a, a + n); + // 89 90 91 99 100 101 + int res = 0; + for (int j = 0; j < n; j++) { + int l = 0, r = j; + // int ans = a[n - 1]; + while (l < r) { + int mid = (l + r) / 2; + if (10 * a[mid] < a[j] * 9) { + l = mid + 1; + } else { + r = mid; + // ans = min(ans, mid); + } + } + // res += j - ans; + res += j - l; + } + cout << res << '\n'; +} diff --git a/misc/binary-search/ghepcap.inp b/misc/binary-search/ghepcap.inp new file mode 100644 index 0000000..264cb18 --- /dev/null +++ b/misc/binary-search/ghepcap.inp @@ -0,0 +1,4 @@ +6 +100 89 90 101 91 99 + + diff --git a/misc/binary-search/p145sumg.cpp b/misc/binary-search/p145sumg.cpp new file mode 100644 index 0000000..fb1d31f --- /dev/null +++ b/misc/binary-search/p145sumg.cpp @@ -0,0 +1,40 @@ +#include +#include +using namespace std; + +int a[100000]; +int n, m; + +int checker(int k) { + int ret = 0; + for (int i = 0; i < n; i++) { + ret += k / a[i]; + } + return ret; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + freopen("p145sumg.inp", "r", stdin); + + cin >> n >> m; + int l = 1, r; + for (int i = 0; i < n; i++) { + cin >> a[i]; + r = max(r, a[i]); + } + r *= m; + + int res = r; + while (l < r) { + int mid = (l + r) / 2; + if (checker(mid) >= m) { + r = mid; + res = min(mid, res); + } else { + l = mid + 1; + } + } + cout << res << "\n"; +} diff --git a/misc/binary-search/p145sumg.inp b/misc/binary-search/p145sumg.inp new file mode 100644 index 0000000..ac743b0 --- /dev/null +++ b/misc/binary-search/p145sumg.inp @@ -0,0 +1,8 @@ +7 10 +3 +8 +3 +6 +9 +2 +4 diff --git a/misc/binary-search/ptit126j.cpp b/misc/binary-search/ptit126j.cpp new file mode 100644 index 0000000..a0ff1de --- /dev/null +++ b/misc/binary-search/ptit126j.cpp @@ -0,0 +1,42 @@ +#include + +using namespace std; +int a[1000000]; +int n, m; + +int check(int k) { + int res = 0; + for (int i = 0; i < n; i++) { + if (a[i] - k > 0) + res += a[i] - k; + } + return res; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + + freopen("ptit126j.inp", "r", stdin); + + cin >> n >> m; + for (int i = 0; i < n; i++) + cin >> a[i]; + sort(a, a + n); + + // 10 15 17 20 + int l = 0, r = a[n - 1]; + int res = a[n - 1]; + while (l < r) { + int mid = (l + r) / 2; + + if (check(mid) >= m) { + // cout << mid << "\n"; + res = mid; + l = mid + 1; + } else { + r = mid; + } + } + cout << res << '\n'; +} diff --git a/misc/binary-search/ptit126j.inp b/misc/binary-search/ptit126j.inp new file mode 100644 index 0000000..d2c6abc --- /dev/null +++ b/misc/binary-search/ptit126j.inp @@ -0,0 +1,2 @@ +5 20 +4 42 40 26 46 diff --git a/misc/binary-search/toy.cpp b/misc/binary-search/toy.cpp new file mode 100644 index 0000000..5880a8d --- /dev/null +++ b/misc/binary-search/toy.cpp @@ -0,0 +1,40 @@ +#include + +using namespace std; + +int n, m; + +int checker(const vector &_a, int k) { + int _n = n; + for (auto i : _a) { + while (i > k) { + i -= k; + _n -= k; + } + if (i > 0) { + _n - k + } + } +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + freopen("toy.inp", "r", stdin); + + cin >> n >> m; + vector a(n); + for (auto &i : a) + cin >> i; + + int l = 0, r = n; + while (l < r) { + int mid = (l + r) / 2; + + if (checker(a, mid)) { + r = mid; + } else { + l = mid + 1; + } + } +} diff --git a/misc/binary-search/toy.inp b/misc/binary-search/toy.inp new file mode 100644 index 0000000..000dd87 --- /dev/null +++ b/misc/binary-search/toy.inp @@ -0,0 +1,3 @@ +5 2 +4 +7 diff --git a/misc/chuyen-de-xau/B3.INP b/misc/chuyen-de-xau/B3.INP new file mode 100644 index 0000000..d3fe466 --- /dev/null +++ b/misc/chuyen-de-xau/B3.INP @@ -0,0 +1,6 @@ +5 +ABCD +EFGHIJK +TINHOCTRE +ABCD +EFGHIJK diff --git a/misc/chuyen-de-xau/B4.INP b/misc/chuyen-de-xau/B4.INP new file mode 100644 index 0000000..2f5114a --- /dev/null +++ b/misc/chuyen-de-xau/B4.INP @@ -0,0 +1,4 @@ +3 +34 +3 +30 diff --git a/misc/chuyen-de-xau/B6.INP b/misc/chuyen-de-xau/B6.INP new file mode 100644 index 0000000..a282f9e --- /dev/null +++ b/misc/chuyen-de-xau/B6.INP @@ -0,0 +1,3 @@ +3 11 +3 4 2 +123 0 45 diff --git a/misc/chuyen-de-xau/a.out b/misc/chuyen-de-xau/a.out new file mode 100755 index 0000000..337f993 Binary files /dev/null and b/misc/chuyen-de-xau/a.out differ diff --git a/misc/chuyen-de-xau/b2.cpp b/misc/chuyen-de-xau/b2.cpp new file mode 100644 index 0000000..9df0be8 --- /dev/null +++ b/misc/chuyen-de-xau/b2.cpp @@ -0,0 +1,45 @@ +#include + +using namespace std; + +int segn[300]; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + + for (int j = 0; j < 300; j++) + segn[j] = 0; + string S; + cin >> S; + const int n = S.length(); + int res1 = 0; + int res2 = 0; + + int l = 0, r = 1; + int i = 0; + while (r < n) { + if (S[l] == S[r]) + r++; + else { + segn[i] = r - l; + l = r; + r++; + i++; + } + } + segn[i] = r - l; + i++; + + for (int k = 0; k < i; k++) { + res1 = max(res1, segn[k]); + if (segn[k + 1] == 1) { + res2 = max(res2, segn[k] + segn[k + 1] + segn[k + 2]); + } + if (k != 0 || k != n - 1) { + res2 = max(res2, segn[k] + 1); + } + } + cout << res1 << '\n'; + cout << res2 << '\n'; +} diff --git a/misc/chuyen-de-xau/b3.cpp b/misc/chuyen-de-xau/b3.cpp new file mode 100644 index 0000000..6e6f13f --- /dev/null +++ b/misc/chuyen-de-xau/b3.cpp @@ -0,0 +1,28 @@ +#include + +using namespace std; +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + freopen("B3.INP", "r", stdin); + + map hash; + + int q; + cin >> q; + for (int i = 0; i < q; i++) { + string a; + cin >> a; + // cout << a; + if (hash.find(a) == hash.end()) { + hash[a] = 1; + } else { + hash[a] = 0; + } + } + + for (const auto i : hash) { + if (i.second == 1) + cout << i.first << '\n'; + } +} diff --git a/misc/chuyen-de-xau/b4.cpp b/misc/chuyen-de-xau/b4.cpp new file mode 100644 index 0000000..175c285 --- /dev/null +++ b/misc/chuyen-de-xau/b4.cpp @@ -0,0 +1,31 @@ +#include + +using namespace std; +string S[100]; + +bool check(const string &a, const string &b) { + const string ab = a + b, ba = b + a; + if (stoi(ab) < stoi(ba)) + return false; + return true; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + freopen("B4.INP", "r", stdin); + + int n; + cin >> n; + for (int i = 0; i < n; i++) { + string a; + cin >> a; + S[i] = a; + } + + sort(S, S + n, check); + for (int i = 0; i < n; i++) { + cout << S[i]; + } + cout << '\n'; +} diff --git a/misc/chuyen-de-xau/b5.cpp b/misc/chuyen-de-xau/b5.cpp new file mode 100644 index 0000000..6b5d715 --- /dev/null +++ b/misc/chuyen-de-xau/b5.cpp @@ -0,0 +1,38 @@ +#include +using namespace std; + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + string s; + cin >> s; + + vector digits; + for (char c : s) { + if (isdigit(c)) + digits.push_back(c); + } + + int m = digits.size(); + string result = ""; + int pos = 0; + + for (int need = 5; need > 0; need--) { + char best = '0'; + int bestPos = pos; + + for (int i = pos; i <= m - need; i++) { + if (digits[i] > best) { + best = digits[i]; + bestPos = i; + } + } + + result.push_back(best); + pos = bestPos + 1; + } + + cout << result; + return 0; +} diff --git a/misc/chuyen-de-xau/b6.cpp b/misc/chuyen-de-xau/b6.cpp new file mode 100644 index 0000000..9133df6 --- /dev/null +++ b/misc/chuyen-de-xau/b6.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + + int p, k; + cin >> p >> k; + vector a(p), s(p); + for (int &i : a) + cin >> i; + for (int &i : s) + cin >> i; + + deque stack; + + for (int i = 0; i < p; i++) { + while (a[i]--) { + } + } +} diff --git a/misc/chuyen-de-xau/b7.cpp b/misc/chuyen-de-xau/b7.cpp new file mode 100644 index 0000000..b813a4c --- /dev/null +++ b/misc/chuyen-de-xau/b7.cpp @@ -0,0 +1,30 @@ +#include + +using namespace std; +int counter[(int)('z' - 'a')]; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + + string a; + cin >> a; + for (const auto i : a) { + counter[i - 'a']++; + } + + int sum = 0; + for (const auto i : counter) { + sum += i; + } + + int max_x = 0; + char max_c; + for (int i = 0; i < 'z' - 'a'; i++) { + if (counter[i] > max_x) { + max_x = counter[i]; + max_c = 'a' + i; + } + } + cout << sum << ' ' << max_c << '\n'; +} diff --git a/misc/chuyen-de-xau/b8.cpp b/misc/chuyen-de-xau/b8.cpp new file mode 100644 index 0000000..58f92d2 --- /dev/null +++ b/misc/chuyen-de-xau/b8.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; +string words[20]; + +bool checker(const string &a, const string &b) { return a.size() < b.size(); } + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + freopen("b8.inp", "r", stdin); + + int n = 0; + while (cin >> words[n] && n < 20) + n++; + + stable_sort(words, words + n, checker); + for (int i = 0; i < n; i++) { + cout << words[i] << " "; + } + cout << '\n'; +} diff --git a/misc/chuyen-de-xau/b8.inp b/misc/chuyen-de-xau/b8.inp new file mode 100644 index 0000000..2d90163 --- /dev/null +++ b/misc/chuyen-de-xau/b8.inp @@ -0,0 +1 @@ +acb abcde abcd abc diff --git a/misc/hsg-hn-2025/.vscode/launch.json b/misc/hsg-hn-2025/.vscode/launch.json new file mode 100644 index 0000000..2281252 --- /dev/null +++ b/misc/hsg-hn-2025/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug C++ (input.inp)", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/${fileBasenameNoExtension}", + "args": ["<", "${fileBasenameNoExtension}.inp"], + "cwd": "${workspaceFolder}", + "preLaunchTask": "Build C++", + "MIMode": "gdb", + "externalConsole": false, + "setupCommands": [ + { + "description": "Enable pretty printing", + "text": "-enable-pretty-printing" + } + ] + } + ] +} diff --git a/misc/hsg-hn-2025/.vscode/tasks.json b/misc/hsg-hn-2025/.vscode/tasks.json new file mode 100644 index 0000000..3701159 --- /dev/null +++ b/misc/hsg-hn-2025/.vscode/tasks.json @@ -0,0 +1,22 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build C++", + "type": "shell", + "command": "g++", + "args": [ + "-std=gnu++17", + "-O2", + "-g", + "${file}", + "-o", + "${fileBasenameNoExtension}" + ], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} diff --git a/misc/hsg-hn-2025/a.out b/misc/hsg-hn-2025/a.out new file mode 100755 index 0000000..a98ff0b Binary files /dev/null and b/misc/hsg-hn-2025/a.out differ diff --git a/misc/hsg-hn-2025/denlong b/misc/hsg-hn-2025/denlong new file mode 100755 index 0000000..f097d93 Binary files /dev/null and b/misc/hsg-hn-2025/denlong differ diff --git a/misc/hsg-hn-2025/denlong.cpp b/misc/hsg-hn-2025/denlong.cpp new file mode 100644 index 0000000..f714581 --- /dev/null +++ b/misc/hsg-hn-2025/denlong.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; + +int main() { + int n, k, x; + cin >> n >> k >> x; + vector> hash(9, vector(n, 0)); + + for (int i = 0; i < n; i++) { + int a; + cin >> a; + if (i == 0) + hash[a][i] = 1; + else + hash[a][i] = hash[a][i - 1] + 1; + } +} diff --git a/misc/hsg-hn-2025/denlong.inp b/misc/hsg-hn-2025/denlong.inp new file mode 100644 index 0000000..3a325e7 --- /dev/null +++ b/misc/hsg-hn-2025/denlong.inp @@ -0,0 +1,2 @@ +6 2 2 +1 9 3 2 3 5 \ No newline at end of file diff --git a/misc/hsg-hn-2025/denlong.out b/misc/hsg-hn-2025/denlong.out new file mode 100644 index 0000000..e69de29 diff --git a/misc/hsg-hn-2025/muasam.cpp b/misc/hsg-hn-2025/muasam.cpp new file mode 100644 index 0000000..eaad246 --- /dev/null +++ b/misc/hsg-hn-2025/muasam.cpp @@ -0,0 +1,35 @@ +#include + +using namespace std; + +const int MAX_N = 1e6; +int a[MAX_N]; + +int main() { + freopen("muasam.inp", "r", stdin); + freopen("muasam.out", "w", stdout); + + ios::sync_with_stdio(false); + cin.tie(nullptr); + + int n, l, r; + cin >> n >> l >> r; + for (int i = 0; i < n; i++) + cin >> a[i]; + int res = 1e9; + + sort(a, a + n); + int L = 0, R = n - 1; + while (L < R) { + int sum = a[L] + a[R]; + if (sum > r) + R--; + else if (sum < l) + L++; + else { + res = min(res, sum); + R--; + } + } + cout << res << '\n'; +} diff --git a/misc/hsg-hp-2025/.vscode/launch.json b/misc/hsg-hp-2025/.vscode/launch.json new file mode 100644 index 0000000..2281252 --- /dev/null +++ b/misc/hsg-hp-2025/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug C++ (input.inp)", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/${fileBasenameNoExtension}", + "args": ["<", "${fileBasenameNoExtension}.inp"], + "cwd": "${workspaceFolder}", + "preLaunchTask": "Build C++", + "MIMode": "gdb", + "externalConsole": false, + "setupCommands": [ + { + "description": "Enable pretty printing", + "text": "-enable-pretty-printing" + } + ] + } + ] +} diff --git a/misc/hsg-hp-2025/.vscode/tasks.json b/misc/hsg-hp-2025/.vscode/tasks.json new file mode 100644 index 0000000..3701159 --- /dev/null +++ b/misc/hsg-hp-2025/.vscode/tasks.json @@ -0,0 +1,22 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build C++", + "type": "shell", + "command": "g++", + "args": [ + "-std=gnu++17", + "-O2", + "-g", + "${file}", + "-o", + "${fileBasenameNoExtension}" + ], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} diff --git a/misc/hsg-hp-2025/a.out b/misc/hsg-hp-2025/a.out new file mode 100755 index 0000000..677ab2b Binary files /dev/null and b/misc/hsg-hp-2025/a.out differ diff --git a/misc/hsg-hp-2025/cbai1.cpp b/misc/hsg-hp-2025/cbai1.cpp new file mode 100644 index 0000000..9c6c9ff --- /dev/null +++ b/misc/hsg-hp-2025/cbai1.cpp @@ -0,0 +1,24 @@ +#include + +using namespace std; + +int main() { + string a; + cin >> a; + + int res = 0; + string output = ""; + + for (int i = a.length() - 1; i >= 0; i--) { + if ('0' <= a[i] && a[i] <= '9') + res += (int)(a[i] - '0'); + else + output += a[i]; + } + + cout << res << '\n'; + if (output == "") + cout << -1 << '\n'; + else + cout << output << '\n'; +} diff --git a/misc/hsg-hp-2025/cbai2.cpp b/misc/hsg-hp-2025/cbai2.cpp new file mode 100644 index 0000000..c2c12e9 --- /dev/null +++ b/misc/hsg-hp-2025/cbai2.cpp @@ -0,0 +1,50 @@ +#include + +using namespace std; + +const int max_n = 1e7; + +char is_prime[max_n + 1]; +void sieve() { + for (int i = 0; i <= max_n; i++) + is_prime[i] = 1; + is_prime[0] = 0; + is_prime[1] = 0; + + // 2 check + for (int i = 4; i <= max_n; i += 2) + is_prime[i] = 0; + + // other + for (int i = 3; i * i <= max_n; i += 2) + if (is_prime[i]) + for (int j = i * i; j <= max_n; j += i) + is_prime[j] = 0; +} + +int solve() { + int n; + cin >> n; + if (!is_prime[n]) + return 0; + + int digit_sum = 0; + while (n) { + digit_sum += n % 10; + n /= 10; + } + if (!is_prime[digit_sum]) + return 0; + return 1; +} + +int main() { + sieve(); + int q; + cin >> q; + int res = 0; + while (q--) { + res += solve(); + } + cout << res << "\n"; +} diff --git a/misc/hsg-hp-2025/cbai2.inp b/misc/hsg-hp-2025/cbai2.inp new file mode 100644 index 0000000..6eb908a --- /dev/null +++ b/misc/hsg-hp-2025/cbai2.inp @@ -0,0 +1,2 @@ +6 +2 3 19 23 29 17 diff --git a/misc/hsg-hp-2025/cbai3.cpp b/misc/hsg-hp-2025/cbai3.cpp new file mode 100644 index 0000000..395d2a3 --- /dev/null +++ b/misc/hsg-hp-2025/cbai3.cpp @@ -0,0 +1,28 @@ +#include + +using namespace std; +int a[1000000]; + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + int m, n, S; + cin >> m >> n >> S; + for (int i = 0; i < m * n; i++) + cin >> a[i]; + + sort(a, a + m * n); + + int l = 0, r = m * n - 1; + int cur_max = -1; + while (l < r) { + if (a[l] + a[r] > S) + r--; + else { + cur_max = max(cur_max, a[l] + a[r]); + l++; + } + } + cout << cur_max << '\n'; +} diff --git a/misc/hsg-hp-2025/cbai3.inp b/misc/hsg-hp-2025/cbai3.inp new file mode 100644 index 0000000..52c55a8 --- /dev/null +++ b/misc/hsg-hp-2025/cbai3.inp @@ -0,0 +1,4 @@ +3 4 10 +6 7 8 9 +5 6 7 8 +9 8 8 7 diff --git a/misc/hsg-hp-2025/cbai4 b/misc/hsg-hp-2025/cbai4 new file mode 100755 index 0000000..a04e01f Binary files /dev/null and b/misc/hsg-hp-2025/cbai4 differ diff --git a/misc/hsg-hp-2025/cbai4.cpp b/misc/hsg-hp-2025/cbai4.cpp new file mode 100644 index 0000000..8b0854a --- /dev/null +++ b/misc/hsg-hp-2025/cbai4.cpp @@ -0,0 +1,56 @@ +#include + +using namespace std; + +void solve() { + vector> char_pos(26); + + int n, q; + string S; + cin >> n >> q >> S; + + vector is_exist(n, 1); + set exist_char; + + // O(n) + for (int i = 0; i < n; i++) { + char_pos[S[i] - 'A'].push_back(i); + } + + // O(1) + for (int i = 0; i < 26; i++) + if (!char_pos[i].empty()) + exist_char.insert(i); + + while (q--) { + if (exist_char.empty()) + break; + + int t; + cin >> t; + int target_char; + if (t == 0) + target_char = *exist_char.begin(); + else + target_char = *exist_char.rbegin(); + + int target_idx = char_pos[target_char].front(); + char_pos[target_char].pop_front(); + is_exist[target_idx] = 0; + + if (char_pos[target_char].empty()) + exist_char.erase(target_char); + } + + for (int i = 0; i < n; i++) + if (is_exist[i]) + cout << S[i]; + cout << '\n'; +} + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + solve(); +} diff --git a/misc/hsg-hp-2025/cbai4.inp b/misc/hsg-hp-2025/cbai4.inp new file mode 100644 index 0000000..127bbf3 --- /dev/null +++ b/misc/hsg-hp-2025/cbai4.inp @@ -0,0 +1,3 @@ +10 4 +ADBAACDABC +0 1 1 0 diff --git a/misc/m5a10/code.py b/misc/m5a10/code.py new file mode 100644 index 0000000..93f8be4 --- /dev/null +++ b/misc/m5a10/code.py @@ -0,0 +1,21 @@ +a, b = input().split() + +map_a = {} +map_b = {} + +for i in range(len(a)): + if a[i] in map_a: + if (b[i] != map_a[a[i]]): + print('false') + break + else: + map_a[a[i]] = b[i] + + if b[i] in map_b: + if (a[i] != map_b[b[i]]): + print('false') + break + else: + map_b[b[i]] = a[i] +else: + print('true') diff --git a/misc/m5a10/input b/misc/m5a10/input new file mode 100644 index 0000000..84d1704 --- /dev/null +++ b/misc/m5a10/input @@ -0,0 +1 @@ +show same diff --git a/misc/mysterious/bai1.cpp b/misc/mysterious/bai1.cpp new file mode 100644 index 0000000..ba93175 --- /dev/null +++ b/misc/mysterious/bai1.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + freopen("bai1.inp", "r", stdin); + + int min_gcd, n; + cin >> n >> min_gcd; + n--; + int prod = n; + while (n--) { + int x; + cin >> x; + min_gcd = lcm(min_gcd, x); + } + cout << min_gcd << '\n'; +} diff --git a/misc/mysterious/bai1.inp b/misc/mysterious/bai1.inp new file mode 100644 index 0000000..acffe4a --- /dev/null +++ b/misc/mysterious/bai1.inp @@ -0,0 +1,2 @@ +3 +4 2 8 diff --git a/misc/mysterious/bai2.cpp b/misc/mysterious/bai2.cpp new file mode 100644 index 0000000..e69de29 diff --git a/misc/mysterious/bai2.inp b/misc/mysterious/bai2.inp new file mode 100644 index 0000000..6854349 --- /dev/null +++ b/misc/mysterious/bai2.inp @@ -0,0 +1 @@ +abc3456789PQ diff --git a/misc/mysterious/cpp.cpp b/misc/mysterious/cpp.cpp new file mode 100644 index 0000000..e69de29 diff --git a/misc/mysterious/cpp.out b/misc/mysterious/cpp.out new file mode 100755 index 0000000..6601c24 Binary files /dev/null and b/misc/mysterious/cpp.out differ diff --git a/misc/mysterious/nhap b/misc/mysterious/nhap new file mode 100644 index 0000000..e69de29 diff --git a/misc/mysterious/tgc.cpp b/misc/mysterious/tgc.cpp new file mode 100644 index 0000000..56edf46 --- /dev/null +++ b/misc/mysterious/tgc.cpp @@ -0,0 +1,37 @@ +#include + +using namespace std; + +int a[500000]; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + freopen("tgc.inp", "r", stdin); + + int n; + cin >> n; + for (int i = 0; i < n; i++) + cin >> a[i]; + sort(a, a + n); + + int res = 0; + for (int i = 0; i < n - 1; i++) { + if (a[i] != a[i + 1]) + continue; + + int l = i, r = n - 1; + int mid; + while (l < r) { + mid = (l + r) / 2; + + if (a[mid] < 2 * a[i]) { + l = mid + 1; + } else { + r = mid; + } + } + res += r - mid + l; + } + cout << res << "\n"; +} diff --git a/misc/mysterious/tgc.inp b/misc/mysterious/tgc.inp new file mode 100644 index 0000000..ee093d9 --- /dev/null +++ b/misc/mysterious/tgc.inp @@ -0,0 +1,2 @@ +8 +5 3 2 9 5 4 9 5 diff --git a/misc/others/.vscode/launch.json b/misc/others/.vscode/launch.json new file mode 100644 index 0000000..2281252 --- /dev/null +++ b/misc/others/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug C++ (input.inp)", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/${fileBasenameNoExtension}", + "args": ["<", "${fileBasenameNoExtension}.inp"], + "cwd": "${workspaceFolder}", + "preLaunchTask": "Build C++", + "MIMode": "gdb", + "externalConsole": false, + "setupCommands": [ + { + "description": "Enable pretty printing", + "text": "-enable-pretty-printing" + } + ] + } + ] +} diff --git a/misc/others/.vscode/tasks.json b/misc/others/.vscode/tasks.json new file mode 100644 index 0000000..9fc4710 --- /dev/null +++ b/misc/others/.vscode/tasks.json @@ -0,0 +1,22 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build C++", + "type": "shell", + "command": "g++", + "args": [ + "-std=gnu++17", + "-O0", + "-g", + "${file}", + "-o", + "${fileBasenameNoExtension}" + ], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} diff --git a/misc/others/a.out b/misc/others/a.out new file mode 100755 index 0000000..2d6e0ad Binary files /dev/null and b/misc/others/a.out differ diff --git a/misc/others/a.out.conflict1 b/misc/others/a.out.conflict1 new file mode 100644 index 0000000..26a1757 Binary files /dev/null and b/misc/others/a.out.conflict1 differ diff --git a/misc/others/b.out b/misc/others/b.out new file mode 100755 index 0000000..592532b Binary files /dev/null and b/misc/others/b.out differ diff --git a/misc/others/beauty b/misc/others/beauty new file mode 100755 index 0000000..38183a7 Binary files /dev/null and b/misc/others/beauty differ diff --git a/misc/others/beauty.cpp b/misc/others/beauty.cpp new file mode 100644 index 0000000..31c7ec0 --- /dev/null +++ b/misc/others/beauty.cpp @@ -0,0 +1,66 @@ +#include + +using namespace std; + +const int maxc = 50000; +char check[maxc + 1]; +vector prime; + +void sieve() { + for (int i = 0; i < maxc; i++) + check[i] = 1; + check[0] = 0; + check[1] = 0; + + for (int i = 2; i * i < maxc; i++) + if (check[i]) + for (int j = i * i; j < maxc; j += i) + check[j] = 0; + for (int i = 2; i < maxc; i++) { + if (check[i]) + prime.push_back(i); + } +} + +int is_db(int n) { + int m = n; + + vector factor; + for (int i = 0; i < prime.size() && prime[i]*prime[i]<=n;i++) { + while (n % prime[i] == 0) { + factor.push_back(prime[i]); + n /= prime[i]; + } + } + factor.push_back(n); + + int facsum = 0; + for (auto i : factor) { + while (i) { + facsum += i % 10; + i /= 10; + } + } + + int sum = 0; + while (m) { + sum += m % 10; + m /= 10; + } + if (sum == facsum) { + return 1; + } + return 0; +} + +int main() { + int n; + cin >> n; + n++; + sieve(); + + while (!is_db(n)) { + n++; + } + cout << n << "\n"; +} diff --git a/misc/others/beauty.inp b/misc/others/beauty.inp new file mode 100644 index 0000000..b5045cc --- /dev/null +++ b/misc/others/beauty.inp @@ -0,0 +1 @@ +21 \ No newline at end of file diff --git a/misc/others/lares b/misc/others/lares new file mode 100755 index 0000000..71d02fe Binary files /dev/null and b/misc/others/lares differ diff --git a/misc/others/lares.cpp b/misc/others/lares.cpp new file mode 100644 index 0000000..c322ca4 --- /dev/null +++ b/misc/others/lares.cpp @@ -0,0 +1,30 @@ +#include + +using namespace std; + +int m, n, k; +int check(int _x) { + int mn = _x * 2; + int nn = _x; + if (mn < 0 || nn < 0 || m - mn + n - nn < k) { + return 0; + } + return 1; +} + +int main() { + cin >> m >> n >> k; + int l = 0, r = min(m / 2, n); + + int res = 0; + while (l < r) { + int mid = (l + r) / 2; + if (check(mid)) { + res = max(res, mid); + l = mid + 1; + } else { + r = mid; + } + } + cout << res << '\n'; +} diff --git a/misc/others/lares.inp b/misc/others/lares.inp new file mode 100644 index 0000000..9035817 --- /dev/null +++ b/misc/others/lares.inp @@ -0,0 +1 @@ +12 7 5 \ No newline at end of file diff --git a/misc/others/other.cpp b/misc/others/other.cpp new file mode 100644 index 0000000..63b6a5b --- /dev/null +++ b/misc/others/other.cpp @@ -0,0 +1,63 @@ +#include +#include +using namespace std; +bool isComposite(int n) { + if (n <= 1) { + return false; + } + if (n <= 3) { + return false; + } + if (n % 2 == 0 || n % 3 == 0) { + return true; + } + int i = 5; + while (i * i <= n) { + if (n % i == 0 || n % (i + 2) == 0) { + return true; + } + i = i + 6; + } + return false; +} +int getSum(int n) { + int s = 0; + while (n > 0) { + s += n % 10; + n /= 10; + } + return s; +} +int getPrimeSum(int n) { + int s = 0; + while (n % 2 == 0) { + s += 2; + n /= 2; + } + for (int i = 3; i <= sqrt(n); i += 2) { + while (n % i == 0) { + s += getSum(i); + n /= i; + } + } + if (n > 2) { + s += getSum(n); + } + return s; +} +int main() { + int n; + cin >> n; + while (true) { + if (getSum(n) == getPrimeSum(n)) { + if (getPrimeSum(n) != 0) { + if (isComposite(n)) { + break; + } + } + } + n += 1; + } + cout << n << endl; + return 0; +} diff --git a/misc/python.py b/misc/python.py new file mode 100644 index 0000000..8411f36 --- /dev/null +++ b/misc/python.py @@ -0,0 +1,11 @@ +x = int(input()) +y = int(input()) +counter = 0 + +while (x or y): + counter += (x % 2)^(y % 2) + x >>= 1 + y >>= 1 + +print(counter) + diff --git a/misc/so_mu_dung/code.py b/misc/so_mu_dung/code.py new file mode 100644 index 0000000..034a00c --- /dev/null +++ b/misc/so_mu_dung/code.py @@ -0,0 +1,18 @@ +import math + +highest_num = [0]*31 + +a = [int(_) for _ in input().split()] + +for i in a: + for k in range(32, 0, -1): + if (i % 2**k == 0): + highest_num[k] += 1 + +res = 0 +for i in highest_num: + if (i <= 1): + continue + res += math.comb(i, 2) +print(res) + diff --git a/misc/tlbdhsg/a.out b/misc/tlbdhsg/a.out new file mode 100755 index 0000000..7e32c49 Binary files /dev/null and b/misc/tlbdhsg/a.out differ diff --git a/misc/tlbdhsg/b19.cpp b/misc/tlbdhsg/b19.cpp new file mode 100644 index 0000000..ad13e43 --- /dev/null +++ b/misc/tlbdhsg/b19.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +int main() { + int n; + cin >> n; + unordered_set hash; + deque res; + + while (n--) { + int x; + cin >> x; + if (hash.find(x) == hash.end()) { + res.push_back(x); + hash.insert(x); + } + } + cout << res.size() << '\n'; + while (!res.empty()) { + cout << res.front() << " "; + res.pop_front(); + } + cout << '\n'; +} diff --git a/misc/tlbdhsg/b20.cpp b/misc/tlbdhsg/b20.cpp new file mode 100644 index 0000000..5682389 --- /dev/null +++ b/misc/tlbdhsg/b20.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + int n, x, k; + cin >> n >> k >> x; + cout << n + 1 << '\n'; + k--; + while (n--) { + int a; + cin >> a; + cout << a << ' '; + k--; + if (!k) + cout << x << ' '; + } + cout << '\n'; +} diff --git a/misc/tlbdhsg/ginny.cpp b/misc/tlbdhsg/ginny.cpp new file mode 100644 index 0000000..cb05260 --- /dev/null +++ b/misc/tlbdhsg/ginny.cpp @@ -0,0 +1,4 @@ +#include +using namespace std; + +int main() {} diff --git a/misc/tlbdhsg/stones.cpp b/misc/tlbdhsg/stones.cpp new file mode 100644 index 0000000..bf67838 --- /dev/null +++ b/misc/tlbdhsg/stones.cpp @@ -0,0 +1,20 @@ +#include +#include +using namespace std; +int main() { + ios::sync_with_stdio(false); + cin.tie(NULL); + int n; + cin >> n; + int a = sqrt(n); + int b = (n + a - 1) / a; + + int res_a = a, res_b = b; + a += 1; + b = (n + a - 1) / a; + if (a + b < res_a + res_b) { + cout << a << " " << b << "\n"; + } else { + cout << res_a << " " << res_b << "\n"; + } +} diff --git a/misc/tlbdhsg/stones_t.cpp b/misc/tlbdhsg/stones_t.cpp new file mode 100644 index 0000000..ebd5a4a --- /dev/null +++ b/misc/tlbdhsg/stones_t.cpp @@ -0,0 +1,31 @@ +#include +#include +#include + +using namespace std; + +int main() { + long long n; + if (!(cin >> n)) + return 0; + + // The minimum sum a+b for a*b >= n occurs when a and b are close to sqrt(n) + long long a = sqrt(n); + long long b = (n + a - 1) / a; // Ceiling division + + // We check if (a+1) provides a better sum + // though mathematically, the first integer b near sqrt(n) is usually it. + long long res_a = a, res_b = b; + + // Check the neighbor just in case of rounding issues with sqrt + long long a2 = a + 1; + long long b2 = (n + a2 - 1) / a2; + + if (a2 + b2 < res_a + res_b) { + res_a = a2; + res_b = b2; + } + + cout << res_a << " " << res_b << endl; + return 0; +} diff --git a/misc/w5a8.a b/misc/w5a8.a new file mode 100755 index 0000000..e9b85ce Binary files /dev/null and b/misc/w5a8.a differ diff --git a/misc/w5a8.cpp b/misc/w5a8.cpp new file mode 100644 index 0000000..401d711 --- /dev/null +++ b/misc/w5a8.cpp @@ -0,0 +1,16 @@ +#include + +using namespace std; + +int main() { + int a, b; cin >> a >> b; + int ans = 0; + + while (a or b) { + cout << "value: " << a % 2 << " " << b % 2 << "\n"; + ans += (int)(((a % 2) ^ (b % 2))); + a >>= 1; + b >>= 1; + } + cout << ans << '\n'; +}