aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xBinarySearch/mainbin0 -> 27472 bytes
-rw-r--r--BinarySearch/main.cpp38
-rw-r--r--BinarySearch/main_input0.txt3
-rw-r--r--BinarySearch/main_output0.txt10
-rw-r--r--DpWithPrefixSum/main.cpp9
-rwxr-xr-xPolyCarpAndDividend/mainbin0 -> 47448 bytes
-rw-r--r--PolyCarpAndDividend/main.cpp49
-rwxr-xr-xThreeDoors/mainbin0 -> 22728 bytes
-rw-r--r--ThreeDoors/main.cpp23
-rw-r--r--ThreeDoors/main_input0.txt9
-rw-r--r--ThreeDoors/main_output0.txt4
-rwxr-xr-xWorkingWeek/mainbin0 -> 22600 bytes
-rw-r--r--WorkingWeek/main.cpp15
-rw-r--r--WorkingWeek/main_input0.txt4
-rw-r--r--WorkingWeek/main_output0.txt3
-rwxr-xr-xclosestToTheLeft/mainbin0 -> 27424 bytes
-rw-r--r--closestToTheLeft/main.cpp36
-rw-r--r--closestToTheLeft/main_input0.txt3
-rw-r--r--closestToTheLeft/main_output0.txt5
-rwxr-xr-xcodechef/DifferentConsecutiveCharacter/mainbin0 -> 23448 bytes
-rw-r--r--codechef/DifferentConsecutiveCharacter/main.cpp24
-rw-r--r--codechef/DifferentConsecutiveCharacter/main_input0.txt7
-rw-r--r--codechef/DifferentConsecutiveCharacter/main_output0.txt3
-rwxr-xr-xcodechef/FinalSum/mainbin0 -> 27328 bytes
-rw-r--r--codechef/FinalSum/main.cpp25
-rw-r--r--codechef/FinalSum/main_input0.txt10
-rw-r--r--codechef/FinalSum/main_output0.txt2
-rwxr-xr-xcodechef/MakeMultiple/mainbin0 -> 22648 bytes
-rw-r--r--codechef/MakeMultiple/main.cpp15
-rw-r--r--codechef/MakeMultiple/main_input0.txt4
-rw-r--r--codechef/MakeMultiple/main_output0.txt3
-rw-r--r--codechef/MinimiseLcs/main.cpp13
-rwxr-xr-xcodechef/OddSumPair/mainbin0 -> 22648 bytes
-rw-r--r--codechef/OddSumPair/main.cpp16
-rw-r--r--codechef/OddSumPair/main_input0.txt5
-rw-r--r--codechef/OddSumPair/main_output0.txt4
-rw-r--r--codechef/ReachOnTime/main.cpp15
-rwxr-xr-xcodechef/Rectangle/mainbin0 -> 22648 bytes
-rw-r--r--codechef/Rectangle/main.cpp15
-rw-r--r--codechef/Rectangle/main_input0.txt4
-rw-r--r--codechef/Rectangle/main_output0.txt3
-rwxr-xr-xcodechef/ShortestPathInBinaryTrees/mainbin0 -> 22544 bytes
-rw-r--r--codechef/ShortestPathInBinaryTrees/main.cpp24
-rw-r--r--codechef/ShortestPathInBinaryTrees/main_input0.txt4
-rw-r--r--codechef/ShortestPathInBinaryTrees/main_output0.txt3
-rw-r--r--codechef/chopSticks/main.cpp14
-rwxr-xr-xfastSearch/mainbin0 -> 27320 bytes
-rw-r--r--fastSearch/main.cpp25
-rw-r--r--fastSearch/main_input0.txt7
-rw-r--r--fastSearch/main_output0.txt1
50 files changed, 457 insertions, 0 deletions
diff --git a/BinarySearch/main b/BinarySearch/main
new file mode 100755
index 0000000..fc015d6
--- /dev/null
+++ b/BinarySearch/main
Binary files differ
diff --git a/BinarySearch/main.cpp b/BinarySearch/main.cpp
new file mode 100644
index 0000000..2dbe7fe
--- /dev/null
+++ b/BinarySearch/main.cpp
@@ -0,0 +1,38 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+bool bs(vector<int> &a, int toFind) {
+ int low = 0;
+ int high = a.size() - 1;
+ int mid = (high + low) / 2;
+ while (low <= high) {
+ if (a[mid] == toFind) {
+ return true;
+ } else if (a[mid] > toFind) {
+ high = mid - 1;
+ } else if(a[mid] < toFind){
+ low = mid + 1;
+ }
+ mid = (high + low) / 2;
+ }
+ return false;
+}
+
+int main() {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int n, k;
+ cin >> n >> k;
+
+ vector<int> a(n);
+ vector<int> q(n);
+
+ for (int &x : a)
+ cin >> x;
+ for (int i = 0; i < k; i++) {
+ int y;
+ cin >> y;
+ cout << (bs(a, y) ? "YES" : "NO") << endl;
+ }
+}
diff --git a/BinarySearch/main_input0.txt b/BinarySearch/main_input0.txt
new file mode 100644
index 0000000..0b33549
--- /dev/null
+++ b/BinarySearch/main_input0.txt
@@ -0,0 +1,3 @@
+10 10
+1 61 126 217 2876 6127 39162 98126 712687 1000000000
+100 6127 1 61 200 -10000 1 217 10000 1000000000
diff --git a/BinarySearch/main_output0.txt b/BinarySearch/main_output0.txt
new file mode 100644
index 0000000..9b9d3c3
--- /dev/null
+++ b/BinarySearch/main_output0.txt
@@ -0,0 +1,10 @@
+NO
+YES
+YES
+YES
+NO
+NO
+YES
+YES
+NO
+YES
diff --git a/DpWithPrefixSum/main.cpp b/DpWithPrefixSum/main.cpp
new file mode 100644
index 0000000..ecc5aa5
--- /dev/null
+++ b/DpWithPrefixSum/main.cpp
@@ -0,0 +1,9 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ int n;
+ cin >> n;
+ vector<int> prefix(n);
+}
diff --git a/PolyCarpAndDividend/main b/PolyCarpAndDividend/main
new file mode 100755
index 0000000..dc43a20
--- /dev/null
+++ b/PolyCarpAndDividend/main
Binary files differ
diff --git a/PolyCarpAndDividend/main.cpp b/PolyCarpAndDividend/main.cpp
new file mode 100644
index 0000000..81e6a92
--- /dev/null
+++ b/PolyCarpAndDividend/main.cpp
@@ -0,0 +1,49 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+const int N = 1234567;
+
+int a[12], p[N], e[N];
+bool vis[N];
+
+void print(int x) {
+ if (x == -1) return;
+ print(p[x]);
+ printf("%d", e[x]);
+}
+
+int main() {
+ int n, m;
+ scanf("%d", &n);
+ for (int i = 0; i < n; i++) {
+ scanf("%d", a + i);
+ }
+ sort(a, a + n);
+ scanf("%d", &m);
+ int cnt = 0;
+ queue < pair <int, int> > q;
+ q.push(make_pair(-1, 0));
+ while (!q.empty()) {
+ int u = q.front().first;
+ int x = q.front().second;
+ q.pop();
+ for (int i = 0; i < n; i++) {
+ int v = (x * 10 + a[i]) % m;
+ if (u == -1 && a[i] == 0) continue;
+ if (!vis[v]) {
+ vis[v] = true;
+ q.push(make_pair(cnt, v));
+ e[cnt] = a[i];
+ p[cnt++] = u;
+ }
+ if (v == 0) {
+ print(cnt - 1);
+ return 0;
+ }
+ }
+ }
+ puts("-1");
+ return 0;
+}
+
diff --git a/ThreeDoors/main b/ThreeDoors/main
new file mode 100755
index 0000000..9da5af6
--- /dev/null
+++ b/ThreeDoors/main
Binary files differ
diff --git a/ThreeDoors/main.cpp b/ThreeDoors/main.cpp
new file mode 100644
index 0000000..b585a68
--- /dev/null
+++ b/ThreeDoors/main.cpp
@@ -0,0 +1,23 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int key, a, b, c;
+ cin >> key >> a >> b >> c;
+ int behindDoors[3] = {a, b, c};
+ int ans = 1;
+ while(behindDoors[key - 1]) {
+ cerr << behindDoors[key - 1] << endl;
+ key = behindDoors[key - 1];
+ ans++;
+ }
+ cerr << endl;
+ cout << ((ans == 3) ? "YES" : "NO") << endl;
+ }
+}
diff --git a/ThreeDoors/main_input0.txt b/ThreeDoors/main_input0.txt
new file mode 100644
index 0000000..15905eb
--- /dev/null
+++ b/ThreeDoors/main_input0.txt
@@ -0,0 +1,9 @@
+4
+3
+0 1 2
+1
+0 3 2
+2
+3 1 0
+2
+1 3 0
diff --git a/ThreeDoors/main_output0.txt b/ThreeDoors/main_output0.txt
new file mode 100644
index 0000000..2bc7799
--- /dev/null
+++ b/ThreeDoors/main_output0.txt
@@ -0,0 +1,4 @@
+YES
+NO
+YES
+NO
diff --git a/WorkingWeek/main b/WorkingWeek/main
new file mode 100755
index 0000000..d74b258
--- /dev/null
+++ b/WorkingWeek/main
Binary files differ
diff --git a/WorkingWeek/main.cpp b/WorkingWeek/main.cpp
new file mode 100644
index 0000000..7ebc539
--- /dev/null
+++ b/WorkingWeek/main.cpp
@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int n;
+ cin >> n;
+ cout << (n / 3) - 2 << endl;
+ }
+}
diff --git a/WorkingWeek/main_input0.txt b/WorkingWeek/main_input0.txt
new file mode 100644
index 0000000..fbe5368
--- /dev/null
+++ b/WorkingWeek/main_input0.txt
@@ -0,0 +1,4 @@
+3
+6
+10
+1033
diff --git a/WorkingWeek/main_output0.txt b/WorkingWeek/main_output0.txt
new file mode 100644
index 0000000..a8ac54f
--- /dev/null
+++ b/WorkingWeek/main_output0.txt
@@ -0,0 +1,3 @@
+0
+1
+342
diff --git a/closestToTheLeft/main b/closestToTheLeft/main
new file mode 100755
index 0000000..2847c76
--- /dev/null
+++ b/closestToTheLeft/main
Binary files differ
diff --git a/closestToTheLeft/main.cpp b/closestToTheLeft/main.cpp
new file mode 100644
index 0000000..d058458
--- /dev/null
+++ b/closestToTheLeft/main.cpp
@@ -0,0 +1,36 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+int bs(vector<int> &a, int toFind) {
+ int low = -1;
+ int high = a.size();
+ int mid = (high + low) / 2;
+ while (low + 1 < high) {
+ if (a[mid] <= toFind) {
+ low = mid;
+ } else {
+ high = mid;
+ }
+ mid = (high + low) / 2;
+ }
+ return low;
+}
+
+int main() {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int n, k;
+ cin >> n >> k;
+
+ vector<int> a(n);
+ vector<int> q(n);
+
+ for (int &x : a)
+ cin >> x;
+ for (int i = 0; i < k; i++) {
+ int y;
+ cin >> y;
+ cout << bs(a, y) + 1 << endl;
+ }
+}
diff --git a/closestToTheLeft/main_input0.txt b/closestToTheLeft/main_input0.txt
new file mode 100644
index 0000000..007d6fe
--- /dev/null
+++ b/closestToTheLeft/main_input0.txt
@@ -0,0 +1,3 @@
+5 5
+3 3 5 8 9
+2 4 8 1 10
diff --git a/closestToTheLeft/main_output0.txt b/closestToTheLeft/main_output0.txt
new file mode 100644
index 0000000..57cf499
--- /dev/null
+++ b/closestToTheLeft/main_output0.txt
@@ -0,0 +1,5 @@
+1
+3
+4
+1
+6
diff --git a/codechef/DifferentConsecutiveCharacter/main b/codechef/DifferentConsecutiveCharacter/main
new file mode 100755
index 0000000..1469d82
--- /dev/null
+++ b/codechef/DifferentConsecutiveCharacter/main
Binary files differ
diff --git a/codechef/DifferentConsecutiveCharacter/main.cpp b/codechef/DifferentConsecutiveCharacter/main.cpp
new file mode 100644
index 0000000..18cc70e
--- /dev/null
+++ b/codechef/DifferentConsecutiveCharacter/main.cpp
@@ -0,0 +1,24 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int n;
+ cin >> n;
+ string s;
+ cin >> s;
+ int ans = 0;
+ for(int i = 0; i < n - 1; i++) {
+ if(s[i + 1] == s[i]) {
+ s[i] = s[i + 1] - '0';
+ ans++;
+ }
+ }
+ cout << ans << endl;
+ }
+}
diff --git a/codechef/DifferentConsecutiveCharacter/main_input0.txt b/codechef/DifferentConsecutiveCharacter/main_input0.txt
new file mode 100644
index 0000000..1956197
--- /dev/null
+++ b/codechef/DifferentConsecutiveCharacter/main_input0.txt
@@ -0,0 +1,7 @@
+3
+2
+11
+4
+0101
+5
+00100
diff --git a/codechef/DifferentConsecutiveCharacter/main_output0.txt b/codechef/DifferentConsecutiveCharacter/main_output0.txt
new file mode 100644
index 0000000..56f24a1
--- /dev/null
+++ b/codechef/DifferentConsecutiveCharacter/main_output0.txt
@@ -0,0 +1,3 @@
+1
+0
+2
diff --git a/codechef/FinalSum/main b/codechef/FinalSum/main
new file mode 100755
index 0000000..c385446
--- /dev/null
+++ b/codechef/FinalSum/main
Binary files differ
diff --git a/codechef/FinalSum/main.cpp b/codechef/FinalSum/main.cpp
new file mode 100644
index 0000000..4fc98d8
--- /dev/null
+++ b/codechef/FinalSum/main.cpp
@@ -0,0 +1,25 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int n, q;
+ cin >> n >> q;
+ vector<int> v(n);
+ for(auto &x : v) {
+ cin >> x;
+ }
+ int k = 0;
+ while(q--) {
+ int x, y;
+ cin >> x >> y;
+ k += (y - x + 1) % 2;
+ }
+ cout << accumulate(v.begin(), v.end(), 0) + k << '\n';
+ }
+}
diff --git a/codechef/FinalSum/main_input0.txt b/codechef/FinalSum/main_input0.txt
new file mode 100644
index 0000000..1c11117
--- /dev/null
+++ b/codechef/FinalSum/main_input0.txt
@@ -0,0 +1,10 @@
+2
+5 3
+1 3 4 4 2
+1 5
+3 4
+2 2
+1 2
+4
+1 1
+1 1
diff --git a/codechef/FinalSum/main_output0.txt b/codechef/FinalSum/main_output0.txt
new file mode 100644
index 0000000..ef273a4
--- /dev/null
+++ b/codechef/FinalSum/main_output0.txt
@@ -0,0 +1,2 @@
+16
+6
diff --git a/codechef/MakeMultiple/main b/codechef/MakeMultiple/main
new file mode 100755
index 0000000..06c7ecf
--- /dev/null
+++ b/codechef/MakeMultiple/main
Binary files differ
diff --git a/codechef/MakeMultiple/main.cpp b/codechef/MakeMultiple/main.cpp
new file mode 100644
index 0000000..653970c
--- /dev/null
+++ b/codechef/MakeMultiple/main.cpp
@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int a, b;
+ cin >> a >> b;
+ cout << ((a <= b / 2 || a == b) ? "YES" : "NO") << endl;
+ }
+}
diff --git a/codechef/MakeMultiple/main_input0.txt b/codechef/MakeMultiple/main_input0.txt
new file mode 100644
index 0000000..11784f3
--- /dev/null
+++ b/codechef/MakeMultiple/main_input0.txt
@@ -0,0 +1,4 @@
+3
+3 6
+4 14
+9 10
diff --git a/codechef/MakeMultiple/main_output0.txt b/codechef/MakeMultiple/main_output0.txt
new file mode 100644
index 0000000..5ae1e3d
--- /dev/null
+++ b/codechef/MakeMultiple/main_output0.txt
@@ -0,0 +1,3 @@
+YES
+YES
+NO
diff --git a/codechef/MinimiseLcs/main.cpp b/codechef/MinimiseLcs/main.cpp
new file mode 100644
index 0000000..9549f1d
--- /dev/null
+++ b/codechef/MinimiseLcs/main.cpp
@@ -0,0 +1,13 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+
+ }
+}
diff --git a/codechef/OddSumPair/main b/codechef/OddSumPair/main
new file mode 100755
index 0000000..2579f03
--- /dev/null
+++ b/codechef/OddSumPair/main
Binary files differ
diff --git a/codechef/OddSumPair/main.cpp b/codechef/OddSumPair/main.cpp
new file mode 100644
index 0000000..174d714
--- /dev/null
+++ b/codechef/OddSumPair/main.cpp
@@ -0,0 +1,16 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int a, b, c;
+ cin >> a >> b >> c;
+ int sum = (a & 1) + (b & 1) + (c & 1);
+ cout << (sum == 1 || sum == 2 ? "YES" : "NO") << endl;
+ }
+}
diff --git a/codechef/OddSumPair/main_input0.txt b/codechef/OddSumPair/main_input0.txt
new file mode 100644
index 0000000..b45ce37
--- /dev/null
+++ b/codechef/OddSumPair/main_input0.txt
@@ -0,0 +1,5 @@
+4
+1 2 3
+8 4 6
+3 3 9
+7 8 6
diff --git a/codechef/OddSumPair/main_output0.txt b/codechef/OddSumPair/main_output0.txt
new file mode 100644
index 0000000..c8cd351
--- /dev/null
+++ b/codechef/OddSumPair/main_output0.txt
@@ -0,0 +1,4 @@
+YES
+NO
+NO
+YES
diff --git a/codechef/ReachOnTime/main.cpp b/codechef/ReachOnTime/main.cpp
new file mode 100644
index 0000000..caf16c8
--- /dev/null
+++ b/codechef/ReachOnTime/main.cpp
@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int x;
+ cin >> x;
+ cout << (x >= 30 ? "YES" : "NO") << endl;
+ }
+}
diff --git a/codechef/Rectangle/main b/codechef/Rectangle/main
new file mode 100755
index 0000000..e52d0f8
--- /dev/null
+++ b/codechef/Rectangle/main
Binary files differ
diff --git a/codechef/Rectangle/main.cpp b/codechef/Rectangle/main.cpp
new file mode 100644
index 0000000..a032542
--- /dev/null
+++ b/codechef/Rectangle/main.cpp
@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int a, b, c, d;
+ cin >> a >> b >> c >> d;
+ cout << ((a ^ b ^ c ^ d) == 0 ? "YES" : "NO") << endl;
+ }
+}
diff --git a/codechef/Rectangle/main_input0.txt b/codechef/Rectangle/main_input0.txt
new file mode 100644
index 0000000..3a34a60
--- /dev/null
+++ b/codechef/Rectangle/main_input0.txt
@@ -0,0 +1,4 @@
+3
+1 1 2 2
+3 2 2 3
+1 2 2 2
diff --git a/codechef/Rectangle/main_output0.txt b/codechef/Rectangle/main_output0.txt
new file mode 100644
index 0000000..5ae1e3d
--- /dev/null
+++ b/codechef/Rectangle/main_output0.txt
@@ -0,0 +1,3 @@
+YES
+YES
+NO
diff --git a/codechef/ShortestPathInBinaryTrees/main b/codechef/ShortestPathInBinaryTrees/main
new file mode 100755
index 0000000..1b29c37
--- /dev/null
+++ b/codechef/ShortestPathInBinaryTrees/main
Binary files differ
diff --git a/codechef/ShortestPathInBinaryTrees/main.cpp b/codechef/ShortestPathInBinaryTrees/main.cpp
new file mode 100644
index 0000000..eb5f641
--- /dev/null
+++ b/codechef/ShortestPathInBinaryTrees/main.cpp
@@ -0,0 +1,24 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int i, j;
+ cin >> i >> j;
+ int ans = 0;
+ while(i != j) {
+ if (j > i) {
+ j /= 2;
+ } else {
+ i /= 2;
+ }
+ ans++;
+ }
+ cout << ans << '\n';
+ }
+}
diff --git a/codechef/ShortestPathInBinaryTrees/main_input0.txt b/codechef/ShortestPathInBinaryTrees/main_input0.txt
new file mode 100644
index 0000000..94da79c
--- /dev/null
+++ b/codechef/ShortestPathInBinaryTrees/main_input0.txt
@@ -0,0 +1,4 @@
+3
+1 2
+2 3
+4 3
diff --git a/codechef/ShortestPathInBinaryTrees/main_output0.txt b/codechef/ShortestPathInBinaryTrees/main_output0.txt
new file mode 100644
index 0000000..01e79c3
--- /dev/null
+++ b/codechef/ShortestPathInBinaryTrees/main_output0.txt
@@ -0,0 +1,3 @@
+1
+2
+3
diff --git a/codechef/chopSticks/main.cpp b/codechef/chopSticks/main.cpp
new file mode 100644
index 0000000..5f6862e
--- /dev/null
+++ b/codechef/chopSticks/main.cpp
@@ -0,0 +1,14 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+
+
+ }
+}
diff --git a/fastSearch/main b/fastSearch/main
new file mode 100755
index 0000000..0bffc8b
--- /dev/null
+++ b/fastSearch/main
Binary files differ
diff --git a/fastSearch/main.cpp b/fastSearch/main.cpp
new file mode 100644
index 0000000..64d97f9
--- /dev/null
+++ b/fastSearch/main.cpp
@@ -0,0 +1,25 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int n;
+ cin >> n;
+ vector<int> a(n);
+ for(int &x : a) cin >> x;
+ int m;
+ cin >> m;
+
+ int count = 0;
+ for(int i = 0; i < m; i++) {
+ int p1, p2;
+ cin >> p1 >> p2;
+ if(a[i] >= p1 && a[i] <= p2){
+ count++;
+ }
+ }
+ cout << count << endl;
+
+}
diff --git a/fastSearch/main_input0.txt b/fastSearch/main_input0.txt
new file mode 100644
index 0000000..7957c89
--- /dev/null
+++ b/fastSearch/main_input0.txt
@@ -0,0 +1,7 @@
+5
+10 1 10 3 4
+4
+1 10
+2 9
+3 4
+2 2
diff --git a/fastSearch/main_output0.txt b/fastSearch/main_output0.txt
new file mode 100644
index 0000000..21217ec
--- /dev/null
+++ b/fastSearch/main_output0.txt
@@ -0,0 +1 @@
+5 2 2 0