problem_id stringlengths 6 6 | buggy_code stringlengths 8 526k ⌀ | fixed_code stringlengths 12 526k ⌀ | labels listlengths 0 15 ⌀ | buggy_submission_id int64 1 1.54M ⌀ | fixed_submission_id int64 2 1.54M ⌀ | user_id stringlengths 10 10 ⌀ | language stringclasses 9 values |
|---|---|---|---|---|---|---|---|
p03037 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
int left, right;
for (int i = 0; i < M; i++) {
int l, r;
cin >> l >> r;
if (l > left) {
left = l;
}
if (r < right) {
right = r;
}
}
int ans = right - left + 1;
if (ans <= 0) {
cout << 0 << endl;
} else {
cout << ans << endl;
}
} | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
int left = 0, right = N;
for (int i = 0; i < M; i++) {
int l, r;
cin >> l >> r;
if (l > left) {
left = l;
}
if (r < right) {
right = r;
}
}
int ans = right - left + 1;
if (ans <= 0) {
cout << 0 << endl;
} else {
cout << ans << endl;
}
} | [
"variable_declaration.value.change"
] | 852,039 | 852,040 | u412039195 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define rep(x) for (int i = 0; i < (x); i++)
#define repj(x) for (int j = 0; j < (x); j++)
#define REP(i, x) for (int(i) = 0; (i) < (x); (i)++)
#define rrep(x) for (int i = (x); i >= 0; i--)
#define mod 1000000007
/******************************define**********************************/
/*****************************functions********************************/
/****************************main function*****************************/
int main(void) {
int n, m;
cin >> n >> m;
vector<int> l(m), r(m);
rep(n) cin >> l[i] >> r[i];
sort(all(l)), reverse(all(l));
sort(all(r));
if (l[0] - r[0] < 0)
cout << 0 << endl;
else
cout << l[0] - r[0] + 1 << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define rep(x) for (int i = 0; i < (x); i++)
#define repj(x) for (int j = 0; j < (x); j++)
#define REP(i, x) for (int(i) = 0; (i) < (x); (i)++)
#define rrep(x) for (int i = (x); i >= 0; i--)
#define mod 1000000007
/******************************define**********************************/
/*****************************functions********************************/
/****************************main function*****************************/
int main(void) {
int n, m;
cin >> n >> m;
vector<int> l(m), r(m);
rep(m) cin >> l[i] >> r[i];
sort(all(l));
reverse(all(l));
sort(all(r));
if (r[0] - l[0] < 0)
cout << 0 << endl;
else
cout << r[0] - l[0] + 1 << endl;
return 0;
} | [
"identifier.change",
"call.arguments.change",
"control_flow.branch.if.condition.change",
"io.output.change"
] | 852,043 | 852,042 | u426397594 | cpp |
p03037 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
int n, m;
cin >> n >> m;
int l0 = n, r0 = 1;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
l0 = max(l, l0);
r0 = min(r, r0);
}
cout << max(0, r0 - l0 + 1) << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
int n, m;
cin >> n >> m;
int l0 = 1, r0 = n;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
l0 = max(l, l0);
r0 = min(r, r0);
}
cout << max(0, r0 - l0 + 1) << endl;
return 0;
} | [
"variable_declaration.value.change",
"identifier.replace.remove",
"literal.replace.add",
"identifier.replace.add",
"literal.replace.remove"
] | 852,056 | 852,057 | u930898631 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define MAX 50005
int tree[4 * MAX], arr[MAX], print[MAX];
map<int, int> cnt;
void bld(int n, int b, int e) {
if (b == e) {
// cout << arr[b] << " = " << tree[n] << endl;
cnt[arr[b]] += tree[n];
return;
}
int lft = 2 * n;
int rit = lft + 1;
int mid = (b + e) / 2;
tree[lft] += tree[n];
tree[rit] += tree[n];
bld(lft, b, mid);
bld(rit, mid + 1, e);
}
void up(int n, int b, int e, int l, int r) {
if (r < arr[b] or arr[e] < l)
return;
if (l <= arr[b] and arr[e] <= r) {
// cout << l << " to " << r << " val " << arr[b] << " " << arr[e] << endl;
tree[n]++;
return;
}
int left = n * 2;
int right = left + 1;
int mid = (b + e) / 2;
up(left, b, mid, l, r);
up(right, mid + 1, e, l, r);
}
int main() {
int n, q;
scanf("%d %d", &n, &q);
for (int i = 1; i <= n; i++)
arr[i] = i;
for (int i = 0; i < q; i++) {
int u, v;
scanf("%d %d", &u, &v);
if (q == 1) {
cout << v - u + 1 << endl;
return 0;
}
up(1, 1, n, u, v);
}
bld(1, 1, n);
int cn = 0;
for (int i = 1; i <= n; i++) {
if (cnt[i] == q)
cn++;
}
cout << cn << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define MAX 100005
int tree[4 * MAX], arr[MAX], print[MAX];
map<int, int> cnt;
void bld(int n, int b, int e) {
if (b == e) {
// cout << arr[b] << " = " << tree[n] << endl;
cnt[arr[b]] += tree[n];
return;
}
int lft = 2 * n;
int rit = lft + 1;
int mid = (b + e) / 2;
tree[lft] += tree[n];
tree[rit] += tree[n];
bld(lft, b, mid);
bld(rit, mid + 1, e);
}
void up(int n, int b, int e, int l, int r) {
if (r < arr[b] or arr[e] < l)
return;
if (l <= arr[b] and arr[e] <= r) {
// cout << l << " to " << r << " val " << arr[b] << " " << arr[e] << endl;
tree[n]++;
return;
}
int left = n * 2;
int right = left + 1;
int mid = (b + e) / 2;
up(left, b, mid, l, r);
up(right, mid + 1, e, l, r);
}
int main() {
int n, q;
scanf("%d %d", &n, &q);
for (int i = 1; i <= n; i++)
arr[i] = i;
for (int i = 0; i < q; i++) {
int u, v;
scanf("%d %d", &u, &v);
if (q == 1) {
cout << v - u + 1 << endl;
return 0;
}
up(1, 1, n, u, v);
}
bld(1, 1, n);
int cn = 0;
for (int i = 1; i <= n; i++) {
if (cnt[i] == q)
cn++;
}
cout << cn << endl;
return 0;
}
| [
"preprocessor.define.value.change",
"literal.integer.change"
] | 852,058 | 852,059 | u620961063 | cpp |
p03037 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n, m, l, r;
cin >> n >> m >> l >> r;
int lmax = l, rmin = r;
for (int i = 1; i < m; i++) {
cin >> l >> r;
lmax = max(l, lmax);
rmin = min(r, rmin);
}
cout << rmin - lmax + 1 << endl;
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n, m, l, r;
cin >> n >> m >> l >> r;
int lmax = l, rmin = r;
for (int i = 1; i < m; i++) {
cin >> l >> r;
lmax = max(l, lmax);
rmin = min(r, rmin);
}
cout << max(0, rmin - lmax + 1) << endl;
} | [
"call.add",
"call.arguments.change"
] | 852,079 | 852,080 | u240685518 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, L, R;
cin >> N >> M;
L = 1;
R = N;
while (M--) {
int l, r;
cin >> l >> r;
L = max(L, l);
R = min(R, r);
}
cout << R - L + 1;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, L, R;
cin >> N >> M;
L = 1;
R = N;
while (M--) {
int l, r;
cin >> l >> r;
L = max(L, l);
R = min(R, r);
}
cout << max(R - L + 1, 0);
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,083 | 852,084 | u538921909 | cpp |
p03037 | #include <iostream>
#include <math.h>
#include <string>
using namespace std;
int N, M, i, j, Ans, sub, judg, r, L[100000], R[100000];
int main() {
cin >> N >> M;
for (i = 0; i < M; i++) {
cin >> L[i] >> R[i];
if (L[0] < L[i])
L[0] = L[i];
if (R[0] > R[i])
R[0] > R[i];
}
if (R[0] - L[0] >= 0)
Ans = R[0] - L[0] + 1;
else
Ans = 0;
cout << Ans << endl;
return 0;
} | #include <iostream>
#include <math.h>
#include <string>
using namespace std;
int N, M, i, j, Ans, sub, judg, r, L[100000], R[100000];
int main() {
cin >> N >> M;
for (i = 0; i < M; i++) {
cin >> L[i] >> R[i];
if (L[0] < L[i])
L[0] = L[i];
if (R[0] > R[i])
R[0] = R[i];
}
if (R[0] >= L[0])
Ans = R[0] - L[0] + 1;
else
Ans = 0;
cout << Ans << endl;
return 0;
} | [
"expression.operation.binary.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 852,099 | 852,100 | u839537391 | cpp |
p03037 | #include <iostream>
using namespace std;
typedef long long ll;
const ll MAX_N = 100000;
int N, M;
ll L[MAX_N], R[MAX_N];
void solve() {
ll max_L = L[0];
ll min_R = R[0];
for (int k = 1; k < M; k++) {
if (min_R < L[k] || R[k] < max_L) {
min_R = 1;
max_L = 0;
break;
} else {
max_L = max(max_L, L[k]);
min_R = min(min_R, R[k]);
}
}
cout << min_R - max_L + 1 << endl;
}
int main() {
cin >> N >> M;
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
}
solve();
}
| #include <iostream>
using namespace std;
typedef long long ll;
const ll MAX_N = 100000;
int N, M;
ll L[MAX_N], R[MAX_N];
void solve() {
ll max_L = L[0];
ll min_R = R[0];
for (int k = 1; k < M; k++) {
if (min_R < L[k] || R[k] < max_L) {
min_R = -1;
max_L = 0;
break;
} else {
max_L = max(max_L, L[k]);
min_R = min(min_R, R[k]);
}
}
cout << min_R - max_L + 1 << endl;
}
int main() {
cin >> N >> M;
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
}
solve();
}
| [
"expression.operation.unary.arithmetic.add"
] | 852,103 | 852,102 | u345981182 | cpp |
p03037 | #include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) REP(i, 0, (n))
typedef long long ll;
using namespace std;
int n, m, l, r, ansL, ansR = 1e9;
int main() {
cin >> n >> m;
rep(i, m) {
cin >> l >> r;
ansL = max(ansL, l);
ansR = min(ansR, r);
}
cout << ansR - ansL + 1 << endl;
} | #include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) REP(i, 0, (n))
typedef long long ll;
using namespace std;
int n, m, l, r, ansL, ansR = 1e9;
int main() {
cin >> n >> m;
rep(i, m) {
cin >> l >> r;
ansL = max(ansL, l);
ansR = min(ansR, r);
}
cout << max(ansR - ansL + 1, 0) << endl;
} | [
"call.add",
"call.arguments.add"
] | 852,117 | 852,118 | u658655325 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, ans, low, hi;
cin >> n >> m;
vector<int> L(m), R(m);
for (int i = 0; i < m; i++) {
cin >> L.at(i) >> R.at(i);
}
low = L.at(0);
hi = R.at(0);
for (int i = 1; i < m; i++) {
if (L.at(i) > low) {
low = L.at(i);
}
if (R.at(i) < hi) {
hi = R.at(i);
}
}
ans = hi - low + 1;
if (ans > n) {
cout << n << endl;
} else {
cout << ans << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, ans, low, hi;
cin >> n >> m;
vector<int> L(m), R(m);
for (int i = 0; i < m; i++) {
cin >> L.at(i) >> R.at(i);
}
low = L.at(0);
hi = R.at(0);
for (int i = 1; i < m; i++) {
if (L.at(i) > low) {
low = L.at(i);
}
if (R.at(i) < hi) {
hi = R.at(i);
}
}
ans = hi - low + 1;
if (ans >= 0) {
cout << ans << endl;
} else {
cout << 0 << endl;
}
return 0;
} | [
"identifier.change",
"io.output.change",
"identifier.replace.remove",
"literal.replace.add"
] | 852,133 | 852,134 | u536015544 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int min = 0, max = n;
for (int i = 0; i < m; i++) {
int L, R;
cin >> L >> R;
if (min < L)
min = L;
if (max > R)
max = R;
}
cout << (max - min > 0 ? max - min + 1 : 0) << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int min = 0, max = n;
for (int i = 0; i < m; i++) {
int L, R;
cin >> L >> R;
if (min < L)
min = L;
if (max > R)
max = R;
}
cout << (max - min >= 0 ? max - min + 1 : 0) << endl;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"io.output.change"
] | 852,140 | 852,141 | u405230134 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); (i)++)
#define FORE(i, m, n) FOR(i, m, n + 1)
#define REP(i, n) FOR(i, 0, n)
#define REPE(i, n) FOR(i, 0, n + 1)
#define FORR(i, m) for (int(i) = (m); (i) >= 0; (i)--)
#define REPONE(i, n) FOR(i, 1, n + 1)
#define ALL(a) (a).begin(), (a).end()
#define MP(a, b) make_pair((a), (b))
#define fi first
#define se second
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const int INF = 1e9;
const int MOD = 1e9 + 7;
signed main() {
int N, M;
cin >> N >> M;
int a, b, amax = 0, bmin = INF, res = 0;
REP(i, M) {
cin >> a >> b;
chmax(amax, a);
chmin(bmin, b);
}
res = bmin - amax;
if (res >= 0)
res + 1;
chmin(res, N);
if (res < 0)
res = 0;
cout << res << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); (i)++)
#define FORE(i, m, n) FOR(i, m, n + 1)
#define REP(i, n) FOR(i, 0, n)
#define REPE(i, n) FOR(i, 0, n + 1)
#define FORR(i, m) for (int(i) = (m); (i) >= 0; (i)--)
#define REPONE(i, n) FOR(i, 1, n + 1)
#define ALL(a) (a).begin(), (a).end()
#define MP(a, b) make_pair((a), (b))
#define fi first
#define se second
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const int INF = 1e9;
const int MOD = 1e9 + 7;
signed main() {
int N, M;
cin >> N >> M;
int a, b, amax = 0, bmin = INF, res = 0;
REP(i, M) {
cin >> a >> b;
chmax(amax, a);
chmin(bmin, b);
}
res = bmin - amax;
if (res >= 0)
res++;
chmin(res, N);
if (res < 0)
res = 0;
cout << res << endl;
} | [
"expression.operation.binary.change"
] | 852,155 | 852,156 | u481767096 | cpp |
p03037 | #include <bits/stdc++.h>
#define RANGE(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
signed main() {
int N, M;
cin >> N >> M;
int L_max = 0;
int R_min = INT_MAX;
RANGE(i, M) {
int l, r;
cin >> l >> r;
L_max = max(L_max, l);
R_min = min(R_min, r);
}
cout << R_min - L_max + 1 << endl;
}
| #include <bits/stdc++.h>
#define RANGE(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
signed main() {
int N, M;
cin >> N >> M;
int L_max = 0;
int R_min = INT_MAX;
RANGE(i, M) {
int l, r;
cin >> l >> r;
L_max = max(L_max, l);
R_min = min(R_min, r);
}
cout << max(R_min - L_max + 1, 0) << endl;
}
| [
"call.add",
"call.arguments.add"
] | 852,157 | 852,158 | u310710814 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
int main() {
fastio;
int n, m;
cin >> n >> m;
int lc = 0, rc = 0;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
if (!i) {
lc = l;
rc = r;
} else {
lc = max(l, lc);
r = min(r, rc);
}
}
int z = rc - lc + 1;
if (z < 0)
cout << "0\n";
else
cout << rc - lc + 1 << "\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
int main() {
fastio;
int n, m;
cin >> n >> m;
int lc = 0, rc = 0;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
if (!i) {
lc = l;
rc = r;
} else {
lc = max(l, lc);
rc = min(r, rc);
}
}
int z = rc - lc + 1;
if (z < 0)
cout << "0\n";
else
cout << rc - lc + 1 << "\n";
return 0;
}
| [
"assignment.variable.change",
"identifier.change"
] | 852,163 | 852,164 | u335839000 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N = 0, M = 0;
cin >> N >> M;
int lb = 0, rb = N;
vector<int> L(M, 0), R(M, 0);
for (int i = 0; i < M; ++i) {
cin >> L[i] >> R[i];
if (L[i] > lb) {
lb = L[i];
}
if (R[i] < rb) {
rb = R[i];
}
}
cout << rb - lb + 1 << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N = 0, M = 0;
cin >> N >> M;
int lb = 0, rb = N;
vector<int> L(M, 0), R(M, 0);
for (int i = 0; i < M; ++i) {
cin >> L[i] >> R[i];
if (L[i] > lb) {
lb = L[i];
}
if (R[i] < rb) {
rb = R[i];
}
}
cout << max(rb - lb + 1, 0) << endl;
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,176 | 852,177 | u384217508 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
int N, M, Lx, Rx;
cin >> N >> M;
vector<int> L(M), R(M);
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
}
vector<int>::iterator iterL = max_element(L.begin(), L.end());
size_t indexL = distance(L.begin(), iterL);
Lx = L[indexL];
vector<int>::iterator iterR = min_element(R.begin(), R.end());
size_t indexR = distance(R.begin(), iterR);
Rx = R[indexR];
if (Rx - Lx < 1) {
cout << 0;
} else {
cout << Rx - Lx + 1;
}
return 0;
};
| #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
int N, M, Lx, Rx;
cin >> N >> M;
vector<int> L(M), R(M);
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
}
vector<int>::iterator iterL = max_element(L.begin(), L.end());
size_t indexL = distance(L.begin(), iterL);
Lx = L[indexL];
vector<int>::iterator iterR = min_element(R.begin(), R.end());
size_t indexR = distance(R.begin(), iterR);
Rx = R[indexR];
if (Rx - Lx < -1) {
cout << 0;
} else {
cout << Rx - Lx + 1;
}
return 0;
};
| [
"control_flow.branch.if.condition.change"
] | 852,190 | 852,191 | u226530091 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
int min_n, max_n;
int l, r;
int ans;
min_n = (1 << 25);
max_n = -1;
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> l >> r;
max_n = max(max_n, l);
min_n = min(min_n, r);
}
ans = min_n - max_n;
if (ans < 0)
cout << ans;
else
cout << ans + 1;
cout << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
int min_n, max_n;
int l, r;
int ans;
min_n = (1 << 25);
max_n = -1;
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> l >> r;
max_n = max(max_n, l);
min_n = min(min_n, r);
}
ans = min_n - max_n;
if (ans < 0)
cout << 0;
else
cout << ans + 1;
cout << endl;
}
| [
"identifier.replace.remove",
"literal.replace.add",
"io.output.change"
] | 852,200 | 852,201 | u863841238 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int M, N;
cin >> N >> M;
vector<vector<int>> data(M, vector<int>(2, 0));
for (int i = 0; i < M; i++) {
cin >> data.at(i).at(0) >> data.at(i).at(1);
}
int L = 0;
int R = N;
for (int i = 0; i < M; i++) {
L = max(data.at(i).at(0), L);
R = min(data.at(i).at(1), R);
}
if (R - L + 1 > 0) {
cout << R - L << endl;
} else {
cout << 0 << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int M, N;
cin >> N >> M;
vector<vector<int>> data(M, vector<int>(2, 0));
for (int i = 0; i < M; i++) {
cin >> data.at(i).at(0) >> data.at(i).at(1);
}
int L = 0;
int R = N;
for (int i = 0; i < M; i++) {
L = max(data.at(i).at(0), L);
R = min(data.at(i).at(1), R);
}
if (R - L + 1 > 0) {
cout << R - L + 1 << endl;
} else {
cout << 0 << endl;
}
}
| [
"expression.operation.binary.add"
] | 852,210 | 852,211 | u830811818 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
vector<int> li(m);
vector<int> ri(m);
int l, r;
for (int i = 0; i < m; i++) {
cin >> l >> r;
li[i] = l;
ri[i] = r;
}
sort(li.rbegin(), li.rend());
sort(ri.begin(), ri.end());
// cout << li[0] << endl;
// cout << ri[0] << endl;
cout << ri[0] - li[0] + 1 << endl;
;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
vector<int> li(m);
vector<int> ri(m);
int l, r;
for (int i = 0; i < m; i++) {
cin >> l >> r;
li[i] = l;
ri[i] = r;
}
sort(li.rbegin(), li.rend());
sort(ri.begin(), ri.end());
// cout << li[0] << endl;
// cout << ri[0] << endl;
cout << max(ri[0] - li[0] + 1, 0) << endl;
;
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,217 | 852,218 | u199433843 | cpp |
p03037 | #define FOR(i, begin, end) for (int i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
int main() {
int n, m;
cin >> n >> m;
int min = 0, max = INT_MAX;
REP(i, m) {
int l, r;
cin >> l >> r;
if (l > min) {
min = l;
}
if (r < max) {
max = r;
}
}
if (max > min) {
cout << (max - min) + 1 << endl;
} else {
cout << "0" << endl;
}
} | #define FOR(i, begin, end) for (int i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
int main() {
int n, m;
cin >> n >> m;
int min = 0, max = INT_MAX;
REP(i, m) {
int l, r;
cin >> l >> r;
if (l > min) {
min = l;
}
if (r < max) {
max = r;
}
}
if (max >= min) {
cout << (max - min) + 1 << endl;
} else {
cout << "0" << endl;
}
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 852,228 | 852,229 | u489197691 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, R, L, mR, mL;
cin >> N >> M;
mR = 0;
mL = N;
for (int i = 0; i < M; i++) {
cin >> R >> L;
if (mR < R) {
mR = R;
}
if (mL > L) {
mL = L;
}
}
if (mL - mR > 0) {
cout << mL - mR + 1 << endl;
} else {
cout << 0 << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, R, L, mR, mL;
cin >> N >> M;
mR = 0;
mL = N;
for (int i = 0; i < M; i++) {
cin >> R >> L;
if (mR <= R) {
mR = R;
}
if (mL >= L) {
mL = L;
}
}
if (mL - mR > -1) {
cout << mL - mR + 1 << endl;
} else {
cout << 0 << endl;
}
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"literal.number.change"
] | 852,240 | 852,241 | u041855176 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
// templates -------------------------------------
#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for (LL i = 0; i < n; i++)
#define INV_REP(i, n) for (LL i = n; 0 <= i; i--)
LL combination(LL n, LL m) {
LL nume = 1;
REP(i, m) nume *= (n - i);
LL demo = 1;
for (int i = 1; i <= m; i++)
demo *= i;
return nume / demo;
}
template <class T> class UnionFind {
private:
vector<T> par;
vector<T> rank;
vector<T> size;
public:
UnionFind(T N) : par(N, T()), rank(N, T()), size(N, T()) {
REP(i, N) {
par[i] = i;
rank[i] = 0;
size[i] = 1;
}
}
inline T root(T x) { return par[x] == x ? x : par[x] = root(par[x]); }
inline bool same(T x, T y) { return root(x) == root(y); }
inline T getSize(T x) { return size[root(x)]; }
void unite(T x, T y) {
T r1 = root(x);
T r2 = root(y);
if (r1 == r2)
return;
if (rank[r1] < rank[r2])
swap(r1, r2);
if (rank[r1] == rank[r2])
rank[r1]++;
par[r2] = r1;
size[r1] += size[r2];
}
};
// --------------------------------------
LL n, m;
vector<LL> l, r;
void input() {
cin >> n >> m;
l.resize(m);
r.resize(m);
for (int i = 0; i < m; i++) {
cin >> l[i] >> r[i];
}
}
void solve() {
sort(l.begin(), l.end(), [](LL a, LL b) { return a > b; });
sort(r.begin(), r.end());
cout << r[0] - l[0] + 1;
}
int main() {
input();
solve();
return 0;
} | #include <bits/stdc++.h>
using namespace std;
// templates -------------------------------------
#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for (LL i = 0; i < n; i++)
#define INV_REP(i, n) for (LL i = n; 0 <= i; i--)
LL combination(LL n, LL m) {
LL nume = 1;
REP(i, m) nume *= (n - i);
LL demo = 1;
for (int i = 1; i <= m; i++)
demo *= i;
return nume / demo;
}
template <class T> class UnionFind {
private:
vector<T> par;
vector<T> rank;
vector<T> size;
public:
UnionFind(T N) : par(N, T()), rank(N, T()), size(N, T()) {
REP(i, N) {
par[i] = i;
rank[i] = 0;
size[i] = 1;
}
}
inline T root(T x) { return par[x] == x ? x : par[x] = root(par[x]); }
inline bool same(T x, T y) { return root(x) == root(y); }
inline T getSize(T x) { return size[root(x)]; }
void unite(T x, T y) {
T r1 = root(x);
T r2 = root(y);
if (r1 == r2)
return;
if (rank[r1] < rank[r2])
swap(r1, r2);
if (rank[r1] == rank[r2])
rank[r1]++;
par[r2] = r1;
size[r1] += size[r2];
}
};
// --------------------------------------
LL n, m;
vector<LL> l, r;
void input() {
cin >> n >> m;
l.resize(m);
r.resize(m);
for (int i = 0; i < m; i++) {
cin >> l[i] >> r[i];
}
}
void solve() {
sort(l.begin(), l.end(), [](LL a, LL b) { return a > b; });
sort(r.begin(), r.end());
cout << max(r[0] - l[0] + 1, 0LL);
}
int main() {
input();
solve();
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,244 | 852,245 | u042817784 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int l[100005];
int r[100005];
int main() {
int n, m, k;
cin >> n >> m;
int t = k;
int ll, rr;
cin >> ll >> rr;
for (int i = 1; i < m; i++) {
int x, y;
cin >> x >> y;
ll = max(x, ll);
rr = max(x, rr);
}
if (ll <= rr)
cout << rr - ll + 1 << endl;
else
cout << 0 << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int l[100005];
int r[100005];
int main() {
int n, m, k;
cin >> n >> m;
int t = k;
int ll, rr;
cin >> ll >> rr;
for (int i = 1; i < m; i++) {
int x, y;
cin >> x >> y;
ll = max(x, ll);
rr = min(y, rr);
}
if (ll <= rr)
cout << rr - ll + 1 << endl;
else
cout << 0 << endl;
} | [
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change",
"call.arguments.change"
] | 852,258 | 852,259 | u269278772 | cpp |
p03037 | #include <bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod = 1e9 + 7;
const LL LL_MAX = 9223372036854775807;
using namespace std;
int l, r;
struct node {
int x, y;
} a[Max];
bool cmp(node a, node b) { return a.x < b.x; }
int ans = 0;
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d%d", &a[i].x, &a[i].y);
}
sort(a, a + m, cmp);
if (m == 1)
printf("%d\n", a[0].y - a[0].x + 1);
else {
l = a[0].x, r = a[0].y;
for (int i = 1; i < m; i++) {
l = max(l, a[i].x);
r = min(r, a[i].y);
}
printf("%d\n", r - l + 1);
}
return 0;
}
| #include <bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod = 1e9 + 7;
const LL LL_MAX = 9223372036854775807;
using namespace std;
int l, r;
struct node {
int x, y;
} a[Max];
bool cmp(node a, node b) { return a.x < b.x; }
int ans = 0;
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d%d", &a[i].x, &a[i].y);
}
sort(a, a + m, cmp);
if (m == 1)
printf("%d\n", a[0].y - a[0].x + 1);
else {
l = a[0].x, r = a[0].y;
for (int i = 1; i < m; i++) {
l = max(l, a[i].x);
r = min(r, a[i].y);
}
printf("%d\n", max(0, r - l + 1));
}
return 0;
}
| [
"call.arguments.add",
"call.arguments.change"
] | 852,260 | 852,261 | u790399429 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using Gate = std::pair<int, int>;
int solve(int n, const std::vector<Gate> &gates) {
int first = 1;
int last = n;
for (const auto &g : gates) {
first = std::max(first, g.first);
last = std::min(last, g.second);
if (last <= first)
break;
}
return first <= last ? last - first + 1 : 0;
}
int main() {
int n, m;
std::cin >> n >> m;
std::vector<Gate> gates(m);
for (auto &g : gates) {
std::cin >> g.first >> g.second;
}
std::cout << solve(n, gates) << std::endl;
}
| #include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using Gate = std::pair<int, int>;
int solve(int n, const std::vector<Gate> &gates) {
int first = 1;
int last = n;
for (const auto &g : gates) {
first = std::max(first, g.first);
last = std::min(last, g.second);
if (last < first)
break;
}
return first <= last ? last - first + 1 : 0;
}
int main() {
int n, m;
std::cin >> n >> m;
std::vector<Gate> gates(m);
for (auto &g : gates) {
std::cin >> g.first >> g.second;
}
std::cout << solve(n, gates) << std::endl;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 852,262 | 852,263 | u405612058 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int N, M;
cin >> N >> M;
int L = -1, R = 1000000;
int Li, Ri;
for (int i = 0; i < M; i++) {
cin >> Li >> Ri;
if (Li > L)
L = Li;
if (Ri < R)
R = Ri;
}
cout << R - L + 1 << endl;
}
| #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int N, M;
cin >> N >> M;
int L = -1, R = 1000000;
int Li, Ri;
for (int i = 0; i < M; i++) {
cin >> Li >> Ri;
if (Li > L)
L = Li;
if (Ri < R)
R = Ri;
}
cout << max(R - L + 1, 0) << endl;
}
| [
"call.add",
"call.arguments.add"
] | 852,266 | 852,267 | u904131021 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
auto L = vector<int>(M);
auto R = vector<int>(M);
for (int i = 0; i < M; i++)
cin >> L[i] >> R[i];
int minimum = *max_element(L.begin(), L.end());
int maxium = *min_element(R.begin(), R.end());
cout << maxium - minimum + 1 << endl;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
auto L = vector<int>(M);
auto R = vector<int>(M);
for (int i = 0; i < M; i++)
cin >> L[i] >> R[i];
int minimum = *max_element(L.begin(), L.end());
int maxium = *min_element(R.begin(), R.end());
cout << max(0, maxium - minimum + 1) << endl;
}
| [
"call.add",
"call.arguments.change"
] | 852,270 | 852,271 | u726173718 | cpp |
p03037 | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, a, b) for (int i = 0; i < b; i++)
#define REP(i, a, b) for (int i = 0; i <= b; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int, int>
#define vp vector<pair<int, int>>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a, 0, sizeof(a))
#define inf (1ll << 60)
#define Yes(f) \
cout << (f ? "Yes" : "No") << endl // fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout << (f ? "yes" : "no") << endl
#define YES(f) cout << (f ? "YES" : "NO") << endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
using namespace std;
const int mod = 1e9 + 7;
signed main() {
int n, m;
cin >> n >> m;
int fast = 0, last = 100000;
int l, r;
rep(i, m) {
cin >> l >> r;
fast = max(fast, l);
last = min(last, r);
}
int ans;
if (fast > last)
ans = 1;
else
ans = last - fast + 1;
cout << ans << endl;
}
| #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, a, b) for (int i = 0; i < b; i++)
#define REP(i, a, b) for (int i = 0; i <= b; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int, int>
#define vp vector<pair<int, int>>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a, 0, sizeof(a))
#define inf (1ll << 60)
#define Yes(f) \
cout << (f ? "Yes" : "No") << endl // fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout << (f ? "yes" : "no") << endl
#define YES(f) cout << (f ? "YES" : "NO") << endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
using namespace std;
const int mod = 1e9 + 7;
signed main() {
int n, m;
cin >> n >> m;
int fast = 0, last = 1000000;
int l, r;
rep(i, m) {
cin >> l >> r;
fast = max(fast, l);
last = min(last, r);
}
int ans;
if (fast > last)
ans = 0;
else
ans = last - fast + 1;
cout << ans << endl;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"assignment.value.change"
] | 852,272 | 852,273 | u775507068 | cpp |
p03037 | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, a, b) for (int i = 0; i < b; i++)
#define REP(i, a, b) for (int i = 0; i <= b; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int, int>
#define vp vector<pair<int, int>>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a, 0, sizeof(a))
#define inf (1ll << 60)
#define Yes(f) \
cout << (f ? "Yes" : "No") << endl // fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout << (f ? "yes" : "no") << endl
#define YES(f) cout << (f ? "YES" : "NO") << endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
using namespace std;
const int mod = 1e9 + 7;
signed main() {
int n, m;
cin >> n >> m;
int fast = 0, last = 100000;
int l, r;
rep(i, m) {
cin >> l >> r;
fast = max(fast, l);
last = min(last, r);
}
int ans;
if (fast < last)
ans = 1;
else
ans = last - fast + 1;
cout << ans << endl;
}
| #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, a, b) for (int i = 0; i < b; i++)
#define REP(i, a, b) for (int i = 0; i <= b; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int, int>
#define vp vector<pair<int, int>>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a, 0, sizeof(a))
#define inf (1ll << 60)
#define Yes(f) \
cout << (f ? "Yes" : "No") << endl // fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout << (f ? "yes" : "no") << endl
#define YES(f) cout << (f ? "YES" : "NO") << endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
using namespace std;
const int mod = 1e9 + 7;
signed main() {
int n, m;
cin >> n >> m;
int fast = 0, last = 1000000;
int l, r;
rep(i, m) {
cin >> l >> r;
fast = max(fast, l);
last = min(last, r);
}
int ans;
if (fast > last)
ans = 0;
else
ans = last - fast + 1;
cout << ans << endl;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"assignment.value.change"
] | 852,274 | 852,273 | u775507068 | cpp |
p03037 | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, a, b) for (int i = 0; i < b; i++)
#define REP(i, a, b) for (int i = 0; i <= b; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int, int>
#define vp vector<pair<int, int>>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a, 0, sizeof(a))
#define inf (1ll << 60)
#define Yes(f) \
cout << (f ? "Yes" : "No") << endl // fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout << (f ? "yes" : "no") << endl
#define YES(f) cout << (f ? "YES" : "NO") << endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
using namespace std;
const int mod = 1e9 + 7;
signed main() {
int n, m;
cin >> n >> m;
int fast = 0, last = 100000;
int l, r;
rep(i, m) {
cin >> l >> r;
fast = max(fast, l);
last = min(last, r);
}
int ans;
if (fast >= last)
ans = 1;
else
ans = last - fast + 1;
cout << ans << endl;
}
| #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, a, b) for (int i = 0; i < b; i++)
#define REP(i, a, b) for (int i = 0; i <= b; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int, int>
#define vp vector<pair<int, int>>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a, 0, sizeof(a))
#define inf (1ll << 60)
#define Yes(f) \
cout << (f ? "Yes" : "No") << endl // fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout << (f ? "yes" : "no") << endl
#define YES(f) cout << (f ? "YES" : "NO") << endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
using namespace std;
const int mod = 1e9 + 7;
signed main() {
int n, m;
cin >> n >> m;
int fast = 0, last = 1000000;
int l, r;
rep(i, m) {
cin >> l >> r;
fast = max(fast, l);
last = min(last, r);
}
int ans;
if (fast > last)
ans = 0;
else
ans = last - fast + 1;
cout << ans << endl;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"assignment.value.change"
] | 852,275 | 852,273 | u775507068 | cpp |
p03037 | #include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
int maxl = -1, minr = 1000000;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
maxl = max(maxl, l);
minr = min(minr, r);
}
int ans;
if (n < maxl) {
ans = 0;
} else {
ans = min(n, minr) - maxl + 1;
}
cout << ans << endl;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
int maxl = -1, minr = 10000000;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
maxl = max(maxl, l);
minr = min(minr, r);
}
int ans;
if (n < maxl || maxl > minr) {
ans = 0;
} else {
ans = min(n, minr) - maxl + 1;
}
cout << ans << endl;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.branch.if.condition.change"
] | 852,279 | 852,280 | u630664279 | cpp |
p03037 | #include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, l, r, al, ar;
cin >> n >> m;
al = 1, ar = n;
while (m--) {
cin >> l >> r;
al = max(al, l);
ar = min(ar, r);
}
cout << ar - al + 1 << '\n';
return 0;
} | #include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, l, r, al, ar;
cin >> n >> m;
al = 1, ar = n;
while (m--) {
cin >> l >> r;
al = max(al, l);
ar = min(ar, r);
}
cout << max(0LL, ar - al + 1) << '\n';
return 0;
}
| [
"call.add",
"call.arguments.change"
] | 852,281 | 852,282 | u769237842 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9 + 7
int main() {
// input
lint n, m, i;
cin >> n >> m;
vint l(m);
vint r(m);
for (i = 0; i < m; i++) {
cin >> l[i] >> r[i];
}
// caricurate
lint s, e;
s = *max_element(l.begin(), l.end());
e = *min_element(r.begin(), r.end());
// output
if (e > s) {
e = s;
}
cout << (e - s + 1) << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9 + 7
int main() {
// input
lint n, m, i;
cin >> n >> m;
vint l(m);
vint r(m);
for (i = 0; i < m; i++) {
cin >> l[i] >> r[i];
}
// caricurate
lint s, e;
s = *max_element(l.begin(), l.end());
e = *min_element(r.begin(), r.end());
// output
if (e < s) {
e = s - 1;
}
cout << (e - s + 1) << endl;
} | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"assignment.change"
] | 852,283 | 852,284 | u557138271 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int lmax, rmin;
lmax = 0, rmin = N;
for (int i = 0; i < M; i++) {
int l, r;
cin >> l >> r;
if (l > lmax) {
lmax = l;
}
if (r < rmin) {
rmin = r;
}
}
int ans;
if (rmin - lmax > 0) {
ans = rmin - lmax + 1;
} else {
ans = 0;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int lmax, rmin;
lmax = 0, rmin = N;
for (int i = 0; i < M; i++) {
int l, r;
cin >> l >> r;
if (l > lmax) {
lmax = l;
}
if (r < rmin) {
rmin = r;
}
}
int ans;
if (rmin - lmax + 1 > 0) {
ans = rmin - lmax + 1;
} else {
ans = 0;
}
cout << ans << endl;
} | [
"control_flow.branch.if.condition.change"
] | 852,295 | 852,296 | u593555034 | cpp |
p03037 | #include <iostream>
using namespace std;
int n, m;
int r[100005];
int l[100005];
int main() {
cin >> n >> m;
int maxl = 0, minr = 99999999;
for (int i = 1; i <= m; i++) {
cin >> l[i] >> r[i];
maxl = max(maxl, l[i]);
minr = min(minr, r[i]);
}
cout << minr - maxl + 1;
return 0;
} | #include <iostream>
using namespace std;
int n, m;
int r[100005];
int l[100005];
int main() {
cin >> n >> m;
int maxl = 0, minr = 99999999;
for (int i = 1; i <= m; i++) {
cin >> l[i] >> r[i];
maxl = max(maxl, l[i]);
minr = min(minr, r[i]);
}
cout << max(minr - maxl + 1, 0);
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,297 | 852,298 | u261868146 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int left = 1;
int right = N;
for (int i = 0; i < M; ++i) {
int L, R;
cin >> L >> R;
left = max(left, L);
right = min(right, R);
}
cout << right - left + 1 << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int left = 1;
int right = N;
for (int i = 0; i < M; ++i) {
int L, R;
cin >> L >> R;
left = max(left, L);
right = min(right, R);
}
cout << max(0, right - left + 1) << endl;
return 0;
}
| [
"call.add",
"call.arguments.change"
] | 852,299 | 852,300 | u045679746 | cpp |
p03037 | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int N, M, L, R;
cin >> N >> M;
int min = 0, max = N + 1;
for (int i = 0; i < M; i++) {
cin >> L >> R;
if (min < L)
min = L;
if (max > R)
max = R;
}
int ans = 0;
if (max > min)
ans = max - min + 1;
cout << ans << endl;
return 0;
} | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int N, M, L, R;
cin >> N >> M;
int min = 0, max = N + 1;
for (int i = 0; i < M; i++) {
cin >> L >> R;
if (min < L)
min = L;
if (max > R)
max = R;
}
int ans = 0;
if (max >= min)
ans = max - min + 1;
cout << ans << endl;
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 852,301 | 852,302 | u079918228 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
int l[m], r[m], ma = -2, mi = INT_MAX;
for (int i = 0; i < m; i++) {
cin >> l[i] >> r[i];
mi = min(mi, r[i]);
ma = max(ma, l[i]);
}
cout << mi - ma + 1 << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
int l[m], r[m], ma = -2, mi = INT_MAX;
for (int i = 0; i < m; i++) {
cin >> l[i] >> r[i];
mi = min(mi, r[i]);
ma = max(ma, l[i]);
}
cout << max(mi - ma + 1, 0) << endl;
}
| [
"call.add",
"call.arguments.add"
] | 852,315 | 852,316 | u121799456 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, m;
cin >> n >> m;
ll l = -INF;
ll r = INF;
for (ll i = 0; i < m; i++) {
ll L, R;
cin >> L >> R;
l = max(l, L);
r = min(r, R);
}
cout << r - l + 1 << endl;
} | #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, m;
cin >> n >> m;
ll l = -INF;
ll r = INF;
for (ll i = 0; i < m; i++) {
ll L, R;
cin >> L >> R;
l = max(l, L);
r = min(r, R);
}
cout << max(r - l + 1, 0LL) << endl;
} | [
"call.add",
"call.arguments.add"
] | 852,324 | 852,325 | u551351897 | cpp |
p03037 | #include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
long long MOD = 1000000007;
int main() {
int N, M;
cin >> N >> M;
int min_ = 0;
int max_ = N;
for (int i = 0; i < M; i++) {
int L, R;
cin >> L >> R;
min_ = max(min_, L);
max_ = min(max_, R);
}
cout << max_ - min_ + 1 << endl;
} | #include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
long long MOD = 1000000007;
int main() {
int N, M;
cin >> N >> M;
int min_ = 0;
int max_ = N;
for (int i = 0; i < M; i++) {
int L, R;
cin >> L >> R;
min_ = max(min_, L);
max_ = min(max_, R);
}
cout << max(0, max_ - min_ + 1) << endl;
} | [
"call.add",
"call.arguments.change"
] | 852,328 | 852,329 | u658993896 | cpp |
p03037 | #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) {
return (a < b) ? (a = b, 1) : 0;
}
template <class T> bool chmin(T &a, const T &b) {
return (b < a) ? (a = b, 1) : 0;
}
int main() {
ll n, m;
cin >> n >> m;
vl l(m), r(m);
for (int i = 0; i < m; ++i) {
cin >> l[i] >> r[i];
}
ll mi = 1;
ll ma = n;
for (int i = 0; i < m; ++i) {
chmax(mi, l[i]);
chmin(ma, r[i]);
}
cout << ma - mi + 1 << endl;
return 0;
} | #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) {
return (a < b) ? (a = b, 1) : 0;
}
template <class T> bool chmin(T &a, const T &b) {
return (b < a) ? (a = b, 1) : 0;
}
int main() {
ll n, m;
cin >> n >> m;
vl l(m), r(m);
for (int i = 0; i < m; ++i) {
cin >> l[i] >> r[i];
}
ll mi = 1;
ll ma = n;
for (int i = 0; i < m; ++i) {
chmax(mi, l[i]);
chmin(ma, r[i]);
}
cout << max(0LL, ma - mi + 1) << endl;
return 0;
} | [
"call.add",
"call.arguments.change"
] | 852,332 | 852,333 | u756088996 | cpp |
p03037 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
typedef long long ll;
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> l(m), r(m);
for (int i = 0; i < m; ++i) {
cin >> l[i] >> r[i];
}
auto maxl = *max_element(l.begin(), l.end());
auto minr = *min_element(r.begin(), r.end());
cout << minr - maxl + 1 << endl;
return 0;
}
| #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
typedef long long ll;
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> l(m), r(m);
for (int i = 0; i < m; ++i) {
cin >> l[i] >> r[i];
}
auto maxl = *max_element(l.begin(), l.end());
auto minr = *min_element(r.begin(), r.end());
cout << max(minr - maxl + 1, 0) << endl;
return 0;
}
| [
"call.add",
"call.arguments.add"
] | 852,334 | 852,335 | u299843956 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int g = INT_MAX, l = 1;
int L, R;
for (int i = 0; i < m; i++) {
cin >> L >> R;
l = max(L, l);
g = min(R, g);
}
cout << g - l + 1 << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int g = INT_MAX, l = 1;
int L, R;
for (int i = 0; i < m; i++) {
cin >> L >> R;
l = max(L, l);
g = min(R, g);
}
cout << max(g - l + 1, 0) << endl;
return 0;
}
| [
"call.add",
"call.arguments.add"
] | 852,341 | 852,342 | u331948661 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <locale>
#include <string>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N, M;
cin >> N >> M;
int l = 1;
int r = N;
for (int i = 0; i < M; i++) {
int L, R;
cin >> L >> R;
l = max(l, L);
r = min(r, R);
}
if (l < r) {
cout << (r - l + 1) << endl;
} else {
cout << 0 << endl;
}
}
| #include <algorithm>
#include <iostream>
#include <locale>
#include <string>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N, M;
cin >> N >> M;
int l = 1;
int r = N;
for (int i = 0; i < M; i++) {
int L, R;
cin >> L >> R;
l = max(l, L);
r = min(r, R);
}
if (l <= r) {
cout << (r - l + 1) << endl;
} else {
cout << 0 << endl;
}
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 852,343 | 852,344 | u502685724 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int n, m;
int l[100005];
int r[100005];
int cl, cr;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
cl = 1;
cr = n;
for (int i = 1; i <= m; i++) {
cin >> l[i] >> r[i];
cl = max(cl, l[i]);
cr = min(cr, r[i]);
}
cout << cr - cl + 1 << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int n, m;
int l[100005];
int r[100005];
int cl, cr;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
cl = 1;
cr = n;
for (int i = 1; i <= m; i++) {
cin >> l[i] >> r[i];
cl = max(cl, l[i]);
cr = min(cr, r[i]);
}
cout << max(cr - cl + 1, 0) << endl;
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,349 | 852,350 | u659725815 | cpp |
p03037 | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;
template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
if (a > 0)
return a % b;
if (a % b == 0)
return 0;
ll x = -a / b + 1;
a += x * b;
return a % b;
}
ll powm(ll a, ll b, ll c) {
if (b == 0)
return 1;
else if (b % 2 == 0) {
ll d = powm(a, b / 2, c);
return (d * d) % c;
} else
return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};
int main() {
IOS();
ll n, m;
cin >> n >> m;
ll MIN = 1, MAX = n;
for (int i = 0; i < m; i++) {
ll l, r;
cin >> l >> r;
MIN = max(MIN, l);
MAX = min(MAX, r);
}
dump(MAX - MIN + 1);
return 0;
} | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;
template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
if (a > 0)
return a % b;
if (a % b == 0)
return 0;
ll x = -a / b + 1;
a += x * b;
return a % b;
}
ll powm(ll a, ll b, ll c) {
if (b == 0)
return 1;
else if (b % 2 == 0) {
ll d = powm(a, b / 2, c);
return (d * d) % c;
} else
return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};
int main() {
IOS();
ll n, m;
cin >> n >> m;
ll MIN = 1, MAX = n;
for (int i = 0; i < m; i++) {
ll l, r;
cin >> l >> r;
MIN = max(MIN, l);
MAX = min(MAX, r);
}
dump(max(MAX - MIN + 1, 0ll));
return 0;
} | [
"call.arguments.add"
] | 852,365 | 852,366 | u872959410 | cpp |
p03037 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif
const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> L(M), R(M);
for (int i = 0; i < M; i++)
cin >> L[i] >> R[i];
cout << *min_element(R.begin(), R.end()) - *max_element(L.begin(), L.end()) +
1
<< "\n";
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif
const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> L(M), R(M);
for (int i = 0; i < M; i++)
cin >> L[i] >> R[i];
cout << max(*min_element(R.begin(), R.end()) -
*max_element(L.begin(), L.end()) + 1,
0)
<< "\n";
return 0;
} | [
"call.add",
"call.arguments.change",
"call.arguments.add"
] | 852,373 | 852,374 | u532573979 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[]) {
int n, m;
cin >> n >> m;
int mx = n, mn = 1;
rep(i, m) {
int l, r;
cin >> l >> r;
mx = min(mx, r);
mn = max(mn, l);
}
cout << mx - mn + 1 << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[]) {
int n, m;
cin >> n >> m;
int mx = n, mn = 1;
rep(i, m) {
int l, r;
cin >> l >> r;
mx = min(mx, r);
mn = max(mn, l);
}
cout << max(mx - mn + 1, 0) << endl;
return 0;
}
| [
"call.add",
"call.arguments.add"
] | 852,377 | 852,378 | u174404613 | cpp |
p03037 | // failed to generate code
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int L[M], R[M];
int l = 1, r = N;
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
l = max(l, L[i]);
r = min(r, R[i]);
}
cout << r - l + 1 << endl;
}
| // failed to generate code
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int L[M], R[M];
int l = 1, r = N;
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
l = max(l, L[i]);
r = min(r, R[i]);
}
cout << max(r - l + 1, 0) << endl;
}
| [
"call.add",
"call.arguments.add"
] | 852,379 | 852,380 | u709604332 | cpp |
p03037 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <time.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, a, b) for (int i = a; i > b; i--)
#define vint vector<int>
#define vvint vector<vint>
#define ct(a) cout << a << endl
using namespace std;
typedef long long ll;
const int INF = 1e9 + 7;
const ll mod = 998244353;
string S;
ll N, M, ans;
map<int, int> mp;
int main() {
cin >> N >> M;
int left = 1, right = N;
FOR(i, 0, M) {
int a, b;
cin >> a >> b;
if (a > left)
left = a;
if (b < right)
right = b;
}
cout << right - left + 1 << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <time.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, a, b) for (int i = a; i > b; i--)
#define vint vector<int>
#define vvint vector<vint>
#define ct(a) cout << a << endl
using namespace std;
typedef long long ll;
const int INF = 1e9 + 7;
const ll mod = 998244353;
string S;
ll N, M, ans;
map<int, int> mp;
int main() {
cin >> N >> M;
int left = 1, right = N;
FOR(i, 0, M) {
int a, b;
cin >> a >> b;
if (a > left)
left = a;
if (b < right)
right = b;
}
cout << max(0, right - left + 1) << endl;
return 0;
} | [
"call.add",
"call.arguments.change"
] | 852,381 | 852,382 | u243196226 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int left = 1;
int right = n;
int l, r;
for (int i = 0; i < m; i++) {
cin >> l >> r;
if (left < l)
left = l;
if (right > r)
right = r;
}
cout << right - left + 1 << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int left = 1;
int right = n;
int l, r;
for (int i = 0; i < m; i++) {
cin >> l >> r;
if (left < l)
left = l;
if (right > r)
right = r;
}
cout << max(0, right - left + 1) << endl;
}
| [
"call.add",
"call.arguments.change"
] | 852,383 | 852,384 | u013408661 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
ll n, m, lx = 0, rn = 1e9;
cin >> n >> m;
for (int i = 0; i < m; i++) {
ll l, r;
cin >> l >> r;
lx = max(lx, l);
rn = min(rn, r);
}
cout << rn - lx + 1 << endl;
}
| #include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
ll n, m, lx = 0, rn = 1e9;
cin >> n >> m;
for (int i = 0; i < m; i++) {
ll l, r;
cin >> l >> r;
lx = max(lx, l);
rn = min(rn, r);
}
cout << max(0ll, rn - lx + 1) << endl;
}
| [
"call.add",
"call.arguments.change"
] | 852,387 | 852,388 | u921168761 | cpp |
p03037 | #include <iostream>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int l_max = 0;
int r_min = N;
for (int i = 0; i < M; i++) {
int L, R;
cin >> L >> R;
l_max = max(l_max, L);
r_min = min(r_min, R);
}
cout << r_min - l_max + 1 << endl;
} | #include <iostream>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int l_max = 0;
int r_min = N;
for (int i = 0; i < M; i++) {
int L, R;
cin >> L >> R;
l_max = max(l_max, L);
r_min = min(r_min, R);
}
cout << max(0, r_min - l_max + 1) << endl;
} | [
"call.add",
"call.arguments.change"
] | 852,389 | 852,390 | u693133807 | cpp |
p03037 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
int ctoi(char c) {
switch (c) {
case '0':
return 0;
case '1':
return 1;
case '2':
return 2;
case '3':
return 3;
case '4':
return 4;
case '5':
return 5;
case '6':
return 6;
case '7':
return 7;
case '8':
return 8;
case '9':
return 9;
default:
return 0;
}
}
using namespace std;
typedef long long ll;
//定義場所//
int i, j, k, l, m, n;
int N, M, Q;
////////////
int main() {
cin >> N >> M;
vector<int> L;
vector<int> R;
for (i = 0; i < M; i++) {
int l, r;
cin >> l >> r;
L.push_back(l);
R.push_back(r);
}
sort(L.begin(), L.end());
reverse(L.begin(), L.end());
sort(R.begin(), R.end());
cout << R[0] - L[0] + 1;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
int ctoi(char c) {
switch (c) {
case '0':
return 0;
case '1':
return 1;
case '2':
return 2;
case '3':
return 3;
case '4':
return 4;
case '5':
return 5;
case '6':
return 6;
case '7':
return 7;
case '8':
return 8;
case '9':
return 9;
default:
return 0;
}
}
using namespace std;
typedef long long ll;
//定義場所//
int i, j, k, l, m, n;
int N, M, Q;
////////////
int main() {
cin >> N >> M;
vector<int> L;
vector<int> R;
for (i = 0; i < M; i++) {
int l, r;
cin >> l >> r;
L.push_back(l);
R.push_back(r);
}
sort(L.begin(), L.end());
reverse(L.begin(), L.end());
sort(R.begin(), R.end());
cout << max(0, R[0] - L[0] + 1);
} | [
"call.add",
"call.arguments.change"
] | 852,391 | 852,392 | u916974091 | cpp |
p03037 | #include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <chrono>
#include <random>
#include <thread>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
for (auto it = v.begin(); it != v.end(); ++it) {
if (it != v.begin())
os << ",";
os << *it;
}
return os << "}";
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &v) {
os << "{";
os << v.first << ", " << v.second;
return os << "}";
}
// ---------------------------------------------------------------------------
using point = complex<double>;
using ll = int64_t;
int my_main(int argc, char **argv) {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<int> diff(n + 3, 0);
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
diff[l]++;
diff[r + 1]++;
}
int ok = 0;
int res = 0;
for (int i = 0; i < diff.size(); i++) {
ok += diff[i];
if (ok == m)
res++;
}
cout << res << endl;
return 0;
}
// ----------------------------------------------------------------------------
// Test driver
#ifdef DEBUG
#define MAY_RUN_TESTCASE
#endif
#ifdef MAY_RUN_TESTCASE
#include <fstream>
#if __has_include(<unistd.h>)
// Mac, Linux
#include <unistd.h>
#elif __has_include(<io.h>)
// Windows
#include <io.h>
#else
// Other?
#error "unistd.h or io.h not found"
#endif
bool test_file_exists(const std::string &str) {
std::ifstream fs(str);
return fs.is_open();
}
#endif
int main(int argc, char **argv) {
#ifndef MAY_RUN_TESTCASE
return my_main(argc, argv);
#else
if (argc == 1) {
return my_main(argc, argv);
} else if (argc == 2) {
char *stdin_file = argv[1];
freopen(stdin_file, "r", stdin);
return my_main(argc, argv);
} else if (argc == 5) {
std::string stdin_file = argv[1];
std::string expected_file = argv[2];
std::string stdout_file = argv[3];
std::string stderr_file = argv[4];
if (!test_file_exists(stdin_file)) {
std::cerr << stdin_file << " not found" << std::endl;
return 3;
}
if (!test_file_exists(expected_file)) {
std::cerr << expected_file << " not found" << std::endl;
return 3;
}
int original_stdin = dup(fileno(stdin));
int original_stdout = dup(fileno(stdout));
int original_stderr = dup(fileno(stderr));
freopen(stdin_file.c_str(), "r", stdin);
freopen(stdout_file.c_str(), "w", stdout);
freopen(stderr_file.c_str(), "w", stderr);
int ret = my_main(argc, argv);
fflush(stdout);
fflush(stderr);
dup2(original_stderr, fileno(stderr));
dup2(original_stdout, fileno(stdout));
dup2(original_stdin, fileno(stdin));
if (ret != 0) {
std::cerr << "main returns " << ret << std::endl;
return ret;
}
std::ifstream inp(stdin_file);
std::ifstream out(stdout_file);
std::ifstream err(stderr_file);
std::ifstream exp(expected_file);
// Clear is needed if the file is empty.
std::cout << "----- input -----" << std::endl;
std::cout << inp.rdbuf() << std::endl;
std::cout.clear();
std::cout << "-----------------" << std::endl << std::endl;
std::cout << "----- output ----" << std::endl;
std::cout << out.rdbuf() << std::endl;
std::cout.clear();
std::cout << "-----------------" << std::endl << std::endl;
std::cout << "---- expected ---" << std::endl;
std::cout << exp.rdbuf() << std::endl;
std::cout.clear();
std::cout << "-----------------" << std::endl << std::endl;
std::cout << "----- stderr ----" << std::endl;
std::cout << err.rdbuf() << std::endl;
std::cout.clear();
std::cout << "-----------------" << std::endl;
inp.seekg(0);
out.seekg(0);
exp.seekg(0);
err.seekg(0);
std::string output_str, expected_str;
{
std::stringstream output_ss;
output_ss << out.rdbuf();
output_str = output_ss.str();
std::stringstream expected_ss;
expected_ss << exp.rdbuf();
expected_str = expected_ss.str();
}
// Remove trailing spaces
output_str.erase(output_str.find_last_not_of(" \n\r\t") + 1);
expected_str.erase(expected_str.find_last_not_of(" \n\r\t") + 1);
if (output_str == expected_str)
return 0;
else
return 1;
}
return 1;
#endif
}
| #include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <chrono>
#include <random>
#include <thread>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
for (auto it = v.begin(); it != v.end(); ++it) {
if (it != v.begin())
os << ",";
os << *it;
}
return os << "}";
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &v) {
os << "{";
os << v.first << ", " << v.second;
return os << "}";
}
// ---------------------------------------------------------------------------
using point = complex<double>;
using ll = int64_t;
int my_main(int argc, char **argv) {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<int> diff(n + 3, 0);
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
diff[l]++;
diff[r + 1]--;
}
int ok = 0;
int res = 0;
for (int i = 0; i < diff.size(); i++) {
ok += diff[i];
if (ok == m)
res++;
}
cout << res << endl;
return 0;
}
// ----------------------------------------------------------------------------
// Test driver
#ifdef DEBUG
#define MAY_RUN_TESTCASE
#endif
#ifdef MAY_RUN_TESTCASE
#include <fstream>
#if __has_include(<unistd.h>)
// Mac, Linux
#include <unistd.h>
#elif __has_include(<io.h>)
// Windows
#include <io.h>
#else
// Other?
#error "unistd.h or io.h not found"
#endif
bool test_file_exists(const std::string &str) {
std::ifstream fs(str);
return fs.is_open();
}
#endif
int main(int argc, char **argv) {
#ifndef MAY_RUN_TESTCASE
return my_main(argc, argv);
#else
if (argc == 1) {
return my_main(argc, argv);
} else if (argc == 2) {
char *stdin_file = argv[1];
freopen(stdin_file, "r", stdin);
return my_main(argc, argv);
} else if (argc == 5) {
std::string stdin_file = argv[1];
std::string expected_file = argv[2];
std::string stdout_file = argv[3];
std::string stderr_file = argv[4];
if (!test_file_exists(stdin_file)) {
std::cerr << stdin_file << " not found" << std::endl;
return 3;
}
if (!test_file_exists(expected_file)) {
std::cerr << expected_file << " not found" << std::endl;
return 3;
}
int original_stdin = dup(fileno(stdin));
int original_stdout = dup(fileno(stdout));
int original_stderr = dup(fileno(stderr));
freopen(stdin_file.c_str(), "r", stdin);
freopen(stdout_file.c_str(), "w", stdout);
freopen(stderr_file.c_str(), "w", stderr);
int ret = my_main(argc, argv);
fflush(stdout);
fflush(stderr);
dup2(original_stderr, fileno(stderr));
dup2(original_stdout, fileno(stdout));
dup2(original_stdin, fileno(stdin));
if (ret != 0) {
std::cerr << "main returns " << ret << std::endl;
return ret;
}
std::ifstream inp(stdin_file);
std::ifstream out(stdout_file);
std::ifstream err(stderr_file);
std::ifstream exp(expected_file);
// Clear is needed if the file is empty.
std::cout << "----- input -----" << std::endl;
std::cout << inp.rdbuf() << std::endl;
std::cout.clear();
std::cout << "-----------------" << std::endl << std::endl;
std::cout << "----- output ----" << std::endl;
std::cout << out.rdbuf() << std::endl;
std::cout.clear();
std::cout << "-----------------" << std::endl << std::endl;
std::cout << "---- expected ---" << std::endl;
std::cout << exp.rdbuf() << std::endl;
std::cout.clear();
std::cout << "-----------------" << std::endl << std::endl;
std::cout << "----- stderr ----" << std::endl;
std::cout << err.rdbuf() << std::endl;
std::cout.clear();
std::cout << "-----------------" << std::endl;
inp.seekg(0);
out.seekg(0);
exp.seekg(0);
err.seekg(0);
std::string output_str, expected_str;
{
std::stringstream output_ss;
output_ss << out.rdbuf();
output_str = output_ss.str();
std::stringstream expected_ss;
expected_ss << exp.rdbuf();
expected_str = expected_ss.str();
}
// Remove trailing spaces
output_str.erase(output_str.find_last_not_of(" \n\r\t") + 1);
expected_str.erase(expected_str.find_last_not_of(" \n\r\t") + 1);
if (output_str == expected_str)
return 0;
else
return 1;
}
return 1;
#endif
}
| [] | 852,400 | 852,401 | u419874471 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (T &x : vec)
is >> x;
return is;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout << fixed;
int n, m;
cin >> n >> m;
vi l(m), r(m);
REP(i, m) cin >> l[i] >> r[i];
int lm = 0, rm = n;
REP(i, m) {
lm = max(lm, l[i]);
rm = min(rm, r[i]);
}
cout << rm - lm + 1 << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (T &x : vec)
is >> x;
return is;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout << fixed;
int n, m;
cin >> n >> m;
vi l(m), r(m);
REP(i, m) cin >> l[i] >> r[i];
int lm = 0, rm = n;
REP(i, m) {
lm = max(lm, l[i]);
rm = min(rm, r[i]);
}
cout << max(rm - lm + 1, 0) << endl;
return 0;
}
| [
"call.add",
"call.arguments.add"
] | 852,402 | 852,403 | u463697306 | cpp |
p03037 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main() {
int n, m;
cin >> n >> m;
int L = 0, R = n + 1;
rep(i, m) {
int l, r;
scanf("%d%d", &l, &r);
L = max(L, l);
R = min(R, r);
}
cout << R - L + 1 << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main() {
int n, m;
cin >> n >> m;
int L = 0, R = n + 1;
rep(i, m) {
int l, r;
scanf("%d%d", &l, &r);
L = max(L, l);
R = min(R, r);
}
cout << max(0, R - L + 1) << endl;
} | [
"call.add",
"call.arguments.change"
] | 852,406 | 852,407 | u781091740 | cpp |
p03037 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
ll N, M, mi = 0, ma = 100000000;
cin >> N >> M;
vector<ll> L(M), R(M);
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
mi = max(L[i], mi);
ma = min(R[i], ma);
}
cout << ma - mi + 1 << endl;
}
| #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
ll N, M, mi = 0, ma = 100000000;
cin >> N >> M;
vector<ll> L(M), R(M);
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
mi = max(L[i], mi);
ma = min(R[i], ma);
}
cout << max(0ll, ma - mi + 1) << endl;
}
| [
"call.add",
"call.arguments.change"
] | 852,408 | 852,409 | u394033362 | cpp |
p03037 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define all(x) (x).begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ddx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
bool debug = false;
/*---------------------------------------------------*/
int main() {
int N, M;
int left = 0, right = 1000000;
cin >> N >> M;
vector<int> L(M), R(M);
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
left = max(left, L[i]);
right = min(right, R[i]);
}
// //cerr << left << " " << right << endl;
cout << right - left + 1 << endl;
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define all(x) (x).begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ddx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
bool debug = false;
/*---------------------------------------------------*/
int main() {
int N, M;
int left = 0, right = 1000000;
cin >> N >> M;
vector<int> L(M), R(M);
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
left = max(left, L[i]);
right = min(right, R[i]);
}
// //cerr << left << " " << right << endl;
cout << max(right - left + 1, 0) << endl;
return 0;
}
| [
"call.add",
"call.arguments.add"
] | 852,410 | 852,411 | u587248350 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int R, m, L = 1;
cin >> R >> m;
for (int i = 0; i < m; i++) {
int l, r;
scanf("%d%d", &l, &r);
L = max(L, l);
R = min(R, r);
}
cout << R - L + 1 << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int R, m, L = 1;
cin >> R >> m;
for (int i = 0; i < m; i++) {
int l, r;
scanf("%d%d", &l, &r);
L = max(L, l);
R = min(R, r);
}
cout << max(0, R - L + 1) << endl;
return 0;
}
| [
"call.add",
"call.arguments.change"
] | 852,412 | 852,413 | u337381518 | cpp |
p03037 | // srinivas
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
// using namespace boost::multiprecision;
// using namespace __gnu_pbds;
#define all(c) (c).begin(), (c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(), (c).rend()
#define fr(x, in, n, r) for (x = in; x < n; x += r)
#define ifr(x, n) for (x = 0; x < n; x++)
#define dfr(x, n) for (x = n - 1; x >= 0; x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll, ll> mll;
typedef map<string, ll> msll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mod 1000000007
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// freopen("input.txt","r",stdin);
ll n, a, b, m, l, r, i;
cin >> n >> m;
ifr(i, m) {
cin >> a >> b;
if (i == 0)
l = a, r = b;
else {
l = max(l, a);
r = min(r, b);
}
}
cout << r - l + 1 << endl;
return 0;
} | // srinivas
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
// using namespace boost::multiprecision;
// using namespace __gnu_pbds;
#define all(c) (c).begin(), (c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(), (c).rend()
#define fr(x, in, n, r) for (x = in; x < n; x += r)
#define ifr(x, n) for (x = 0; x < n; x++)
#define dfr(x, n) for (x = n - 1; x >= 0; x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll, ll> mll;
typedef map<string, ll> msll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mod 1000000007
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// freopen("input.txt","r",stdin);
ll n, a, b, m, l, r, i;
cin >> n >> m;
ifr(i, m) {
cin >> a >> b;
if (i == 0)
l = a, r = b;
else {
l = max(l, a);
r = min(r, b);
}
}
cout << max(0ll, r - l + 1) << endl;
return 0;
} | [
"call.add",
"call.arguments.change"
] | 852,416 | 852,417 | u906227026 | cpp |
p03037 | #include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
// #define DEBUG 1
#define DFILE "t1.1"
int main() {
int n, m;
#ifdef DEBUG
#define cin fin
fstream fin(DFILE);
#endif
int min_n, max_n;
cin >> n >> m;
min_n = 1;
max_n = n;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
min_n = max(min_n, l);
max_n = min(max_n, r);
}
if (min_n < max_n)
cout << max_n - min_n + 1 << endl;
else
cout << 0 << endl;
return 0;
} | #include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
// #define DEBUG 1
#define DFILE "t1.1"
int main() {
int n, m;
#ifdef DEBUG
#define cin fin
fstream fin(DFILE);
#endif
int min_n, max_n;
cin >> n >> m;
min_n = 1;
max_n = n;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
min_n = max(min_n, l);
max_n = min(max_n, r);
}
if (min_n <= max_n)
cout << max_n - min_n + 1 << endl;
else
cout << 0 << endl;
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 852,428 | 852,429 | u147305315 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <vector>
using namespace std;
int gcd(int a, int b) {
int c = a % b;
while (c != 0) {
a = b;
b = c;
c = a % b;
}
return b;
}
struct UnionFind {
vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
for (int i = 0; i < N; i++)
par[i] = i;
}
int root(int x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根}
if (par[x] == x)
return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) { // xとyの木を併合
int rx = root(x); // xの根をrx
int ry = root(y); // yの根をry
if (rx == ry)
return; // xとyの根が同じ(=同じ木にある)時はそのまま
par[rx] =
ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける
}
bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
int rx = root(x);
int ry = root(y);
return rx == ry;
}
};
typedef long long ll;
const ll M = 1000000007;
vector<ll> fac(300001); // n!(mod M)
vector<ll> ifac(300001); // k!^{M-2} (mod M)
ll mpow(ll x, ll n) {
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x % M;
x = x * x % M;
n = n >> 1;
}
return ans;
}
ll comb(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0)
return 0;
ll tmp = ifac[a - b] * ifac[b] % M;
return tmp * fac[a] % M;
}
int main() {
int n, m, i, l, r, ml, mr;
cin >> n >> m;
ml = 1;
mr = n;
for (i = 0; i < m; i++) {
cin >> l >> r;
ml = min(ml, l);
mr = max(mr, r);
}
if (ml <= mr)
cout << mr - ml + 1 << endl;
else
cout << "0" << endl;
}
| #include <algorithm>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <vector>
using namespace std;
int gcd(int a, int b) {
int c = a % b;
while (c != 0) {
a = b;
b = c;
c = a % b;
}
return b;
}
struct UnionFind {
vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
for (int i = 0; i < N; i++)
par[i] = i;
}
int root(int x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根}
if (par[x] == x)
return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) { // xとyの木を併合
int rx = root(x); // xの根をrx
int ry = root(y); // yの根をry
if (rx == ry)
return; // xとyの根が同じ(=同じ木にある)時はそのまま
par[rx] =
ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける
}
bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
int rx = root(x);
int ry = root(y);
return rx == ry;
}
};
typedef long long ll;
const ll M = 1000000007;
vector<ll> fac(300001); // n!(mod M)
vector<ll> ifac(300001); // k!^{M-2} (mod M)
ll mpow(ll x, ll n) {
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x % M;
x = x * x % M;
n = n >> 1;
}
return ans;
}
ll comb(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0)
return 0;
ll tmp = ifac[a - b] * ifac[b] % M;
return tmp * fac[a] % M;
}
int main() {
int n, m, i, l, r, ml, mr;
cin >> n >> m;
ml = 1;
mr = n;
for (i = 0; i < m; i++) {
cin >> l >> r;
ml = max(ml, l);
mr = min(mr, r);
}
if (ml <= mr)
cout << mr - ml + 1 << endl;
else
cout << "0" << endl;
}
| [
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change"
] | 852,436 | 852,437 | u933068010 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T, class C> void chmax(T &a, C b) { a > b ?: a = b; }
template <class T, class C> void chmin(T &a, C b) { a < b ?: a = b; }
int main() {
int N, M;
cin >> N >> M;
int card_min = -10, card_max = 1000000;
rep(i, M) {
int L, R;
cin >> L >> R;
card_min = max(card_min, L);
card_max = min(card_max, R);
}
cout << card_max - card_min + 1 << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T, class C> void chmax(T &a, C b) { a > b ?: a = b; }
template <class T, class C> void chmin(T &a, C b) { a < b ?: a = b; }
int main() {
int N, M;
cin >> N >> M;
int card_min = -10, card_max = 1000000;
rep(i, M) {
int L, R;
cin >> L >> R;
card_min = max(card_min, L);
card_max = min(card_max, R);
}
cout << max(card_max - card_min + 1, 0) << endl;
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,447 | 852,448 | u959236700 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> void cmax(T &a, U b) {
if (a < b)
a = b;
}
template <class T, class U> void cmin(T &a, U b) {
if (a > b)
a = b;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
int ll = 0;
int rr = n - 1;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
l--;
r--;
cmax(ll, l);
cmin(rr, r);
}
// cerr << ll << rr << endl;
cout << rr - ll + 1 << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> void cmax(T &a, U b) {
if (a < b)
a = b;
}
template <class T, class U> void cmin(T &a, U b) {
if (a > b)
a = b;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
int ll = 0;
int rr = n - 1;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
l--;
r--;
cmax(ll, l);
cmin(rr, r);
}
// cerr << ll << rr << endl;
cout << max(0, rr - ll + 1) << endl;
}
| [
"call.add",
"call.arguments.change"
] | 852,454 | 852,455 | u366644013 | cpp |
p03037 | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, m;
int lb, ub;
cin >> n >> m;
lb = 1;
ub = n;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
lb = max(l, lb);
ub = min(r, ub);
}
cout << ub - lb + 1 << endl;
return 0;
} | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, m;
int lb, ub;
cin >> n >> m;
lb = 1;
ub = n;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
lb = max(l, lb);
ub = min(r, ub);
}
cout << max(0, ub - lb + 1) << endl;
return 0;
} | [
"call.add",
"call.arguments.change"
] | 852,460 | 852,461 | u426837411 | cpp |
p03037 | #include <iostream>
int main() {
unsigned long long N, M;
std::cin >> N >> M;
unsigned long long l = 0;
unsigned long long r = N;
for (unsigned long long m = 0; m < M; m++) {
unsigned long long L, R;
std::cin >> L >> R;
l = std::max(l, L);
r = std::min(r, R);
}
if (l >= r)
std::cout << r - l + 1 << std::endl;
else
std::cout << 0 << std::endl;
return 0;
}
| #include <iostream>
int main() {
unsigned long long N, M;
std::cin >> N >> M;
unsigned long long l = 0;
unsigned long long r = N;
for (unsigned long long m = 0; m < M; m++) {
unsigned long long L, R;
std::cin >> L >> R;
l = std::max(l, L);
r = std::min(r, R);
}
if (l <= r)
std::cout << r - l + 1 << std::endl;
else
std::cout << 0 << std::endl;
return 0;
}
| [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 852,464 | 852,465 | u896932701 | cpp |
p03037 | #include <iostream>
#include <queue>
#include <utility>
#include <vector>
int main(int argc, char const *argv[]) {
int n, m;
std::cin >> n >> m;
int left_max = 1;
int right_min = n;
for (int i = 0; i < m; ++i) {
int l, r;
std::cin >> l >> r;
;
left_max = std::max(left_max, l);
right_min = std::min(right_min, r);
// std::cout << left_max << " : " << right_min << std::endl;
}
if (left_max > right_min) {
std::cout << 0 << std::endl;
}
if (left_max == right_min) {
std::cout << 1 << std::endl;
} else {
std::cout << (right_min - left_max) + 1 << std::endl;
}
} | #include <iostream>
#include <queue>
#include <utility>
#include <vector>
int main(int argc, char const *argv[]) {
int n, m;
std::cin >> n >> m;
int left_max = 1;
int right_min = n;
for (int i = 0; i < m; ++i) {
int l, r;
std::cin >> l >> r;
;
left_max = std::max(left_max, l);
right_min = std::min(right_min, r);
// std::cout << left_max << " : " << right_min << std::endl;
}
if (left_max > right_min) {
std::cout << 0 << std::endl;
} else if (left_max == right_min) {
std::cout << 1 << std::endl;
} else {
std::cout << (right_min - left_max) + 1 << std::endl;
}
} | [
"control_flow.branch.else_if.replace.add",
"control_flow.branch.if.replace.remove"
] | 852,466 | 852,467 | u197999770 | cpp |
p03037 | #include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
int n, m;
int lft, rit;
int l = 0, r = 1e9;
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
scanf("%d%d", &lft, &rit);
l = max(l, lft);
r = min(r, rit);
}
cout << r - l + 1 << endl;
return 0;
} | #include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
int n, m;
int lft, rit;
int l = 0, r = 1e9;
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
scanf("%d%d", &lft, &rit);
l = max(l, lft);
r = min(r, rit);
}
cout << max(r - l + 1, 0) << endl;
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,468 | 852,469 | u504098542 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int L, R;
int L_res = 1, R_res = N;
for (int i = 0; i < M; i++) {
cin >> L >> R;
L_res = max(L, L_res);
R_res = min(R, R_res);
}
cout << R_res - L_res + 1 << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int L, R;
int L_res = 1, R_res = N;
for (int i = 0; i < M; i++) {
cin >> L >> R;
L_res = max(L, L_res);
R_res = min(R, R_res);
}
cout << max(R_res - L_res + 1, 0) << endl;
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,470 | 852,471 | u238353279 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
int l[m], r[m];
rep(i, m) cin >> l[i] >> r[i];
int left = 1, right = n;
rep(i, m) {
if (l[i] > left) {
left = l[i];
}
if (r[i] < right) {
right = r[i];
}
}
cout << right - left + 1 << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
int l[m], r[m];
rep(i, m) cin >> l[i] >> r[i];
int left = 1, right = n;
rep(i, m) {
if (l[i] > left) {
left = l[i];
}
if (r[i] < right) {
right = r[i];
}
}
cout << max(right - left + 1, 0) << endl;
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,474 | 852,475 | u241908712 | cpp |
p03037 | #include <iostream>
#include <utility>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int minN = 1;
int maxN = N;
for (int m = 1; m <= M; ++m) {
int L, R;
cin >> L >> R;
minN = max(minN, L);
maxN = min(maxN, R);
}
cout << maxN - minN + 1 << endl;
return 0;
} | #include <iostream>
#include <utility>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int minN = 1;
int maxN = N;
for (int m = 1; m <= M; ++m) {
int L, R;
cin >> L >> R;
minN = max(minN, L);
maxN = min(maxN, R);
}
cout << max(maxN - minN + 1, 0) << endl;
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,480 | 852,481 | u843070415 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> l(m), r(m);
for (int i = 0; i < m; i++) {
cin >> l[i] >> r[i];
}
int x = *max_element(begin(l), end(l));
int y = *min_element(begin(r), end(r));
cout << y - x + 1 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> l(m), r(m);
for (int i = 0; i < m; i++) {
cin >> l[i] >> r[i];
}
int x = *max_element(begin(l), end(l));
int y = *min_element(begin(r), end(r));
cout << max(y - x + 1, 0) << endl;
} | [
"call.add",
"call.arguments.add"
] | 852,484 | 852,485 | u731175398 | cpp |
p03037 | #include <iomanip>
#include <iostream>
//#include<cstdio>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int Mmax = 1e5;
int N, M;
int L[Mmax], R[Mmax];
int main() {
cin >> N >> M;
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
}
int lmax = L[0], rmin = R[0];
for (int i = 0; i < M; i++) {
lmax = max(lmax, L[i]);
rmin = min(rmin, R[i]);
}
cout << rmin - lmax + 1 << endl;
return 0;
} | #include <iomanip>
#include <iostream>
//#include<cstdio>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int Mmax = 1e5;
int N, M;
int L[Mmax], R[Mmax];
int main() {
cin >> N >> M;
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
}
int lmax = L[0], rmin = R[0];
for (int i = 0; i < M; i++) {
lmax = max(lmax, L[i]);
rmin = min(rmin, R[i]);
}
cout << max(0, rmin - lmax + 1) << endl;
return 0;
}
| [
"call.add",
"call.arguments.change"
] | 852,490 | 852,491 | u534998883 | cpp |
p03037 | // C - Prison
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
int n, m, l, r;
cin >> n >> m;
int ll = 1, rr = n;
for (int i = 0; i < m; i++) {
cin >> l >> r;
ll = max(ll, l);
rr = min(rr, r);
}
cout << (rr - ll + 1) << endl;
return 0;
}
| // C - Prison
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
int n, m, l, r;
cin >> n >> m;
int ll = 1, rr = n;
for (int i = 0; i < m; i++) {
cin >> l >> r;
ll = max(ll, l);
rr = min(rr, r);
}
cout << max(0, rr - ll + 1) << endl;
return 0;
}
| [
"call.add",
"call.arguments.add"
] | 852,502 | 852,503 | u839953699 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
int main() {
int N, M;
cin >> N >> M;
vector<int> L(N), R(N);
for (int i = 0; i < M; i++)
cin >> L.at(i) >> R.at(i);
int l = 1, r = 100000;
for (int i = 0; i < M; i++) {
l = max(l, L.at(i));
r = min(r, R.at(i));
}
if (l > r)
cout << 0 << endl;
else
cout << r - l + 1 << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
int main() {
int N, M;
cin >> N >> M;
vector<int> L(M), R(M);
for (int i = 0; i < M; i++)
cin >> L.at(i) >> R.at(i);
int l = 1, r = N;
for (int i = 0; i < M; i++) {
l = max(l, L.at(i));
r = min(r, R.at(i));
}
if (l > r)
cout << 0 << endl;
else
cout << r - l + 1 << endl;
return 0;
}
| [
"variable_declaration.value.change",
"identifier.replace.add",
"literal.replace.remove"
] | 852,508 | 852,509 | u618649215 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define rep(i, n) for (long i = 0; i < n; i++)
using namespace std;
int main(void) {
cout.precision(12);
long N, M;
cin >> N >> M;
long minL = 0;
long maxR = N + 1;
rep(i, M) {
long L, R;
cin >> L >> R;
minL = max(minL, L);
maxR = min(maxR, R);
}
cout << (maxR - minL + 1) << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define rep(i, n) for (long i = 0; i < n; i++)
using namespace std;
int main(void) {
cout.precision(12);
long N, M;
cin >> N >> M;
long minL = 0;
long maxR = N + 1;
rep(i, M) {
long L, R;
cin >> L >> R;
minL = max(minL, L);
maxR = min(maxR, R);
}
cout << max(0l, (maxR - minL + 1)) << endl;
return 0;
}
| [
"call.add",
"call.arguments.change"
] | 852,510 | 852,511 | u995792346 | cpp |
p03037 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
int main() {
int N, M;
cin >> N >> M;
vector<int> L(M), R(M);
REP(i, M) cin >> L[i] >> R[i];
int l = 1, r = N;
for (int i = 0; i < M; ++i) {
l = max(l, L[i]);
r = min(r, R[i]);
}
cout << r - l + 1 << endl;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
int main() {
int N, M;
cin >> N >> M;
vector<int> L(M), R(M);
REP(i, M) cin >> L[i] >> R[i];
int l = 1, r = N;
for (int i = 0; i < M; ++i) {
l = max(l, L[i]);
r = min(r, R[i]);
}
cout << max(0, r - l + 1) << endl;
} | [
"call.add",
"call.arguments.change"
] | 852,512 | 852,513 | u318727472 | cpp |
p03037 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;
// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * x % MOD;
x = x * x % MOD;
n >>= 1;
}
return res;
}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2) % MOD; }
ll comb(int n, int r) {
return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
while (a % b != 0) {
ll tmp = a;
a = b;
b = tmp % b;
}
return b;
}
const int N_MAX = 1e5;
int N, M;
int L[N_MAX + 1], R[N_MAX + 1];
int main() {
scanf("%d %d", &N, &M);
rep(i, M) scanf("%d %d", &L[i], &R[i]);
int max_l = L[0];
int min_r = R[0];
rep(i, M) {
max_l = max(max_l, L[i]);
min_r = min(min_r, R[i]);
}
printf("%d\n", min_r - max_l + 1);
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;
// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * x % MOD;
x = x * x % MOD;
n >>= 1;
}
return res;
}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2) % MOD; }
ll comb(int n, int r) {
return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
while (a % b != 0) {
ll tmp = a;
a = b;
b = tmp % b;
}
return b;
}
const int N_MAX = 1e5;
int N, M;
int L[N_MAX + 1], R[N_MAX + 1];
int main() {
scanf("%d %d", &N, &M);
rep(i, M) scanf("%d %d", &L[i], &R[i]);
int max_l = L[0];
int min_r = R[0];
rep(i, M) {
max_l = max(max_l, L[i]);
min_r = min(min_r, R[i]);
}
printf("%d\n", max(min_r - max_l + 1, 0));
}
| [
"call.add",
"call.arguments.add"
] | 852,522 | 852,523 | u823451365 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int lm = 0, rm = 1000000;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
lm = max(lm, l);
rm = min(rm, r);
}
cout << rm - lm + 1 << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int lm = 0, rm = 1000000;
for (int i = 0; i < m; i++) {
int l, r;
cin >> l >> r;
lm = max(lm, l);
rm = min(rm, r);
}
cout << max(rm - lm + 1, 0) << endl;
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,526 | 852,527 | u662614053 | cpp |
p03037 | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// value
int N, M;
int L[100010], R[100010];
void solve() {
cin >> N >> M;
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
L[i]--;
R[i]--;
}
int ansL = 0, ansR = N - 1;
for (int i = 0; i < M; i++) {
ansL = max(ansL, L[i]);
ansR = min(ansR, R[i]);
}
cout << ansR - ansL + 1 << endl;
return;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
return 0;
} | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// value
int N, M;
int L[100010], R[100010];
void solve() {
cin >> N >> M;
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
L[i]--;
R[i]--;
}
int ansL = 0, ansR = N - 1;
for (int i = 0; i < M; i++) {
ansL = max(ansL, L[i]);
ansR = min(ansR, R[i]);
}
cout << max(ansR - ansL + 1, 0) << endl;
return;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
return 0;
}
| [
"call.add",
"call.arguments.add"
] | 852,528 | 852,529 | u381714561 | cpp |
p03037 | #include <bits/stdc++.h>
/**/
#include <random>
using namespace std;
int main() {
long long int N, M;
cin >> N >> M;
long long int ansmin = -1, ansmax = 100000000LL;
for (size_t i = 0; i < M; i++) {
long long int L, R;
cin >> L >> R;
ansmin = max(L, ansmin);
ansmax = min(R, ansmax);
}
cout << ansmax - ansmin + 1 << endl;
}
| #include <bits/stdc++.h>
/**/
#include <random>
using namespace std;
int main() {
long long int N, M;
cin >> N >> M;
long long int ansmin = -1, ansmax = 100000000LL;
for (size_t i = 0; i < M; i++) {
long long int L, R;
cin >> L >> R;
ansmin = max(L, ansmin);
ansmax = min(R, ansmax);
}
cout << max(0LL, ansmax - ansmin + 1) << endl;
}
| [
"call.add",
"call.arguments.change"
] | 852,530 | 852,531 | u779353743 | cpp |
p03037 | #include "bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
int N, M;
int main() {
cin >> N >> M;
int l, r;
cin >> l >> r;
for (int i = 1; i < M; i++) {
int a, b;
cin >> a >> b;
l = max(l, a);
r = min(r, b);
}
cout << r - l + 1 << endl;
} | #include "bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
int N, M;
int main() {
cin >> N >> M;
int l, r;
cin >> l >> r;
for (int i = 1; i < M; i++) {
int a, b;
cin >> a >> b;
l = max(l, a);
r = min(r, b);
}
cout << max(0, r - l + 1) << endl;
}
| [
"call.add",
"call.arguments.change"
] | 852,532 | 852,533 | u422592877 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define pb push_back
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
struct edge {
int to, cost;
};
typedef pair<int, int> P;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
bool prime(int a) {
if (a == 1)
return false;
for (int i = 2; i * i <= a; i++) {
if (a % i == 0)
return false;
}
return true;
}
bool kosa(double ax, double ay, double bx, double by, double cx, double cy,
double dx, double dy) { //線分の交差判定
double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
return tc * td < 0 && ta * tb < 0;
}
int kaijo(int n) {
int ans = 1;
for (int i = 2; i <= n; i++) {
ans *= i;
ans %= MOD;
}
return ans;
}
int modpow(int a, int b) {
if (b == 0)
return 1;
if (b % 2)
return modpow(a, b - 1) * a % MOD;
return modpow(a, b / 2) * modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
return kaijo(a) * modpow(kaijo(a - b), MOD - 2) % MOD *
modpow(kaijo(b), MOD - 2) % MOD;
}
int n, m, l, r;
signed main() {
cin >> n >> m;
l = -1, r = 1145141919;
rep(i, m) {
int a, b;
cin >> a >> b;
l = max(l, a);
r = min(r, b);
}
cout << r - l + 1 << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define pb push_back
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
struct edge {
int to, cost;
};
typedef pair<int, int> P;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
bool prime(int a) {
if (a == 1)
return false;
for (int i = 2; i * i <= a; i++) {
if (a % i == 0)
return false;
}
return true;
}
bool kosa(double ax, double ay, double bx, double by, double cx, double cy,
double dx, double dy) { //線分の交差判定
double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
return tc * td < 0 && ta * tb < 0;
}
int kaijo(int n) {
int ans = 1;
for (int i = 2; i <= n; i++) {
ans *= i;
ans %= MOD;
}
return ans;
}
int modpow(int a, int b) {
if (b == 0)
return 1;
if (b % 2)
return modpow(a, b - 1) * a % MOD;
return modpow(a, b / 2) * modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
return kaijo(a) * modpow(kaijo(a - b), MOD - 2) % MOD *
modpow(kaijo(b), MOD - 2) % MOD;
}
int n, m, l, r;
signed main() {
cin >> n >> m;
l = -1, r = 1145141919;
rep(i, m) {
int a, b;
cin >> a >> b;
l = max(l, a);
r = min(r, b);
}
cout << max(0ll, r - l + 1) << endl;
return 0;
}
| [
"call.add",
"call.arguments.change"
] | 852,534 | 852,535 | u006686215 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin >>
#define Z class
#define ll long long
#define ln cout << '\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++)
template <Z A> void pr(A a) {
cout << a;
ln;
}
template <Z A, Z B> void pr(A a, B b) {
cout << a << ' ';
pr(b);
}
template <Z A, Z B, Z C> void pr(A a, B b, C c) {
cout << a << ' ';
pr(b, c);
}
template <Z A, Z B, Z C, Z D> void pr(A a, B b, C c, D d) {
cout << a << ' ';
pr(b, c, d);
}
template <Z A> void PR(A a, ll n) {
rep(i, n) {
if (i)
cout << ' ';
cout << a[i];
}
ln;
}
ll check(ll n, ll m, ll x, ll y) { return x >= 0 && x < n && y >= 0 && y < m; }
const ll MAX = 1e9 + 7, MAXL = 1LL << 61, dx[4] = {-1, 0, 1, 0},
dy[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;
void Main() {
ll n, m;
cin >> n >> m;
ll Ma = n, Mi = 1;
rep(i, m) {
ll l, r;
cin >> l >> r;
Mi = max(Mi, l);
Ma = min(Ma, r);
}
pr(Ma - Mi + 1);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
Main();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin >>
#define Z class
#define ll long long
#define ln cout << '\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++)
template <Z A> void pr(A a) {
cout << a;
ln;
}
template <Z A, Z B> void pr(A a, B b) {
cout << a << ' ';
pr(b);
}
template <Z A, Z B, Z C> void pr(A a, B b, C c) {
cout << a << ' ';
pr(b, c);
}
template <Z A, Z B, Z C, Z D> void pr(A a, B b, C c, D d) {
cout << a << ' ';
pr(b, c, d);
}
template <Z A> void PR(A a, ll n) {
rep(i, n) {
if (i)
cout << ' ';
cout << a[i];
}
ln;
}
ll check(ll n, ll m, ll x, ll y) { return x >= 0 && x < n && y >= 0 && y < m; }
const ll MAX = 1e9 + 7, MAXL = 1LL << 61, dx[4] = {-1, 0, 1, 0},
dy[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;
void Main() {
ll n, m;
cin >> n >> m;
ll Ma = n, Mi = 1;
rep(i, m) {
ll l, r;
cin >> l >> r;
Mi = max(Mi, l);
Ma = min(Ma, r);
}
pr(max(0LL, Ma - Mi + 1));
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
Main();
return 0;
}
| [
"call.add",
"call.arguments.change"
] | 852,542 | 852,543 | u287015418 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x, y) scanf("%d%d", &x, &y)
#define Scd3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%llu", &x)
#define Scll2(x, y) scanf("%llu%llu", &x, &y)
#define Scll3(x, y, z) scanf("%llu%llu%llu", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Rep(x, y) for (int x = 0; x < y; x++)
#define Repe(x, y, z) for (int x = z; x < y; x++)
// }}} 2
// output {{{ 2
#define YesNo(a) (a) ? printf("Yes\n") : printf("No\n");
// }}} 2
// }}} 1
int main() {
int N, M;
Scd2(N, M);
int l, r, L = 1, R = N;
Rep(i, M) {
Scd2(l, r);
L = max(l, L);
R = min(r, R);
}
printf("%d\n", min(R - L + 1, 0));
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x, y) scanf("%d%d", &x, &y)
#define Scd3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%llu", &x)
#define Scll2(x, y) scanf("%llu%llu", &x, &y)
#define Scll3(x, y, z) scanf("%llu%llu%llu", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Rep(x, y) for (int x = 0; x < y; x++)
#define Repe(x, y, z) for (int x = z; x < y; x++)
// }}} 2
// output {{{ 2
#define YesNo(a) (a) ? printf("Yes\n") : printf("No\n");
// }}} 2
// }}} 1
int main() {
int N, M;
Scd2(N, M);
int l, r, L = 1, R = N;
Rep(i, M) {
Scd2(l, r);
L = max(l, L);
R = min(r, R);
}
printf("%d\n", max(R - L + 1, 0));
return 0;
}
| [
"misc.opposites",
"identifier.change",
"call.function.change",
"call.arguments.change",
"io.output.change"
] | 852,546 | 852,547 | u550398291 | cpp |
p03038 | #include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(n, x) \
for (ll i = 0; i < n; i++) \
cin >> x[i];
#define forr(a, b) \
for (ll i = a; i < b; i++) \
;
ll gcd(ll x, ll y) {
if (x % y == 0)
return y;
else
return gcd(y, x % y);
}
// 1or素数だと1を返す
ll prime(ll x) {
for (ll i = 2; i * i <= x; i++) {
if (x % i == 0)
return 0;
}
return 1;
}
int main() {
ll n, m;
cin >> n >> m;
map<ll, ll, greater<ll>> a;
ll x;
for (ll i = 0; i < n; i++) {
cin >> x;
a[x]++;
}
ll b, c;
for (ll i = 0; i < m; i++) {
cin >> b >> c;
a[c] += b;
}
ll ans = 0;
ll num = 0;
auto iter = a.begin();
while (n < num + (iter->second)) {
ans += (iter->first) * (iter->second);
num += (iter->second);
iter = next(iter, 1);
}
ans += (iter->first) * (n - num);
cout << ans << "\n";
return 0;
} | #include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(n, x) \
for (ll i = 0; i < n; i++) \
cin >> x[i];
#define forr(a, b) \
for (ll i = a; i < b; i++) \
;
ll gcd(ll x, ll y) {
if (x % y == 0)
return y;
else
return gcd(y, x % y);
}
// 1or素数だと1を返す
ll prime(ll x) {
for (ll i = 2; i * i <= x; i++) {
if (x % i == 0)
return 0;
}
return 1;
}
int main() {
ll n, m;
cin >> n >> m;
map<ll, ll, greater<ll>> a;
ll x;
for (ll i = 0; i < n; i++) {
cin >> x;
a[x]++;
}
ll b, c;
for (ll i = 0; i < m; i++) {
cin >> b >> c;
a[c] += b;
}
ll ans = 0;
ll num = 0;
auto iter = a.begin();
while (num + (iter->second) <= n) {
ans += (iter->first) * (iter->second);
num += (iter->second);
iter = next(iter, 1);
}
ans += (iter->first) * (n - num);
cout << ans << "\n";
return 0;
} | [
"expression.operation.binary.remove",
"control_flow.loop.condition.change"
] | 852,548 | 852,549 | u936877713 | cpp |
p03038 | #include <algorithm>
#include <cstdio>
const int maxn = 1e5 + 5;
int n, m, a[maxn];
struct Op {
int b, c;
bool operator<(Op b) const { return c > b.c; }
} p[maxn];
long long ans;
int main() {
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; ++i)
scanf("%d", &a[i]), ans += a[i];
for (int i = 1; i <= m; ++i)
scanf("%d %d", &p[i].b, &p[i].c);
std ::sort(a + 1, a + n + 1);
std ::sort(p + 1, p + m + 1);
for (int i = 1, j = 0; i <= m; ++i) {
while (p[i].b && a[j + 1] < p[i].c)
++j, --p[i].b, ans += p[i].c - a[j];
if (p[i].b)
break;
}
printf("%lld", ans);
return 0;
} | #include <algorithm>
#include <cstdio>
const int maxn = 1e5 + 5;
int n, m, a[maxn];
struct Op {
int b, c;
bool operator<(Op b) const { return c > b.c; }
} p[maxn];
long long ans;
int main() {
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; ++i)
scanf("%d", &a[i]), ans += a[i];
for (int i = 1; i <= m; ++i)
scanf("%d %d", &p[i].b, &p[i].c);
std ::sort(a + 1, a + n + 1);
std ::sort(p + 1, p + m + 1);
for (int i = 1, j = 0; i <= m; ++i) {
while (p[i].b && a[j + 1] < p[i].c && j < n)
++j, --p[i].b, ans += p[i].c - a[j];
if (p[i].b)
break;
}
printf("%lld", ans);
return 0;
} | [
"control_flow.loop.condition.change",
"control_flow.loop.for.condition.change"
] | 852,550 | 852,551 | u571935386 | cpp |
p03038 | #include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for (ll i = (k); i < (n); i++)
#define FORe(i, k, n) for (ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for (ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for (ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
const int INF = 1001001001;
using P = pair<ll, ll>;
int main(void) {
ll n, m;
cin >> n >> m;
vector<ll> a(n);
REP(i, n) cin >> a[i];
vector<P> d;
REP(i, m) {
ll b, c;
cin >> b >> c;
d.emplace_back(c, b);
}
sort(ALL(a));
sort(ALLr(d));
ll ans = 0;
ll i = 0;
REP(j, m) {
ll c = d[j].first;
ll b = d[j].second;
ll k = 0;
while (a[i] < c && k < b) {
ans += c;
i++;
k++;
}
}
while (i < n) {
ans += a[i++];
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for (ll i = (k); i < (n); i++)
#define FORe(i, k, n) for (ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for (ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for (ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
const int INF = 1001001001;
using P = pair<ll, ll>;
int main(void) {
ll n, m;
cin >> n >> m;
vector<ll> a(n);
REP(i, n) cin >> a[i];
vector<P> d;
REP(i, m) {
ll b, c;
cin >> b >> c;
d.emplace_back(c, b);
}
sort(ALL(a));
sort(ALLr(d));
ll ans = 0;
ll i = 0;
REP(j, m) {
ll c = d[j].first;
ll b = d[j].second;
ll k = 0;
while (i < n && a[i] < c && k < b) {
ans += c;
i++;
k++;
}
}
while (i < n) {
ans += a[i++];
}
cout << ans << endl;
return 0;
} | [
"control_flow.loop.condition.change"
] | 852,554 | 852,555 | u961136005 | cpp |
p03038 | #include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
int n, m;
std::cin >> n >> m;
std::vector<int> a(n);
std::vector<std::pair<int, int>> bc(m);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
for (int i = 0; i < m; i++) {
int b, c;
std::cin >> b >> c;
bc[i] = std::make_pair(c, b);
}
std::sort(bc.rbegin(), bc.rend());
std::sort(a.begin(), a.end());
int ai = 0;
int bi = 0;
int cnt = 0;
long long ans = 0;
while (ai < n) {
if (cnt == bc[bi].second) {
cnt = 0;
bi++;
}
if (a[ai] < bc[bi].first) {
ans += bc[bi].first - a[ai];
cnt++;
} else {
break;
}
ai++;
}
for (int i = 0; i < n; i++) {
ans += a[i];
}
std::cout << ans << std::endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
int n, m;
std::cin >> n >> m;
std::vector<long long> a(n);
std::vector<std::pair<long long, long long>> bc(m);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
for (int i = 0; i < m; i++) {
int b, c;
std::cin >> b >> c;
bc[i] = std::make_pair(c, b);
}
std::sort(bc.rbegin(), bc.rend());
std::sort(a.begin(), a.end());
int ai = 0;
int bi = 0;
int cnt = 0;
long long ans = 0;
while (ai < n) {
if (cnt == bc[bi].second) {
cnt = 0;
bi++;
}
if (a[ai] < bc[bi].first) {
ans += bc[bi].first - a[ai];
cnt++;
} else {
break;
}
ai++;
}
for (int i = 0; i < n; i++) {
ans += a[i];
}
std::cout << ans << std::endl;
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 852,558 | 852,559 | u275256557 | cpp |
p03038 | #define _GLIBCXX_DEBUG
#include <algorithm> //next_permutation
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
const ll MOD = 1000000007;
const ll MAX = 2000001;
ll mod(ll a) { return a % MOD; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
int main() {
ll n, m;
cin >> n >> m;
vl cardnum(n);
ll sum = 0;
rep(i, n) {
cin >> cardnum[i];
sum += cardnum[i];
}
sort(all(cardnum));
vector<pair<ll, ll>> change(m);
rep(i, m) {
ll a, b;
cin >> a >> b;
change[i] = make_pair(b, a);
}
sort(all(change));
reverse(all(change));
/*for(auto p : change){
cout << p.first << p.second;
}
for(ll x : cardnum){
cout << x;
}*/
ll nowcard = 0;
for (auto p : change) {
for (ll i = 0; i < p.second; i++) {
if (cardnum[nowcard] < p.first) {
sum += p.first - cardnum[nowcard];
nowcard++;
} else {
cout << sum << endl;
return 0;
}
}
}
cout << sum << endl;
} | #define _GLIBCXX_DEBUG
#include <algorithm> //next_permutation
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
const ll MOD = 1000000007;
const ll MAX = 2000001;
ll mod(ll a) { return a % MOD; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
int main() {
ll n, m;
cin >> n >> m;
vl cardnum(n);
ll sum = 0;
rep(i, n) {
cin >> cardnum[i];
sum += cardnum[i];
}
sort(all(cardnum));
vector<pair<ll, ll>> change(m);
rep(i, m) {
ll a, b;
cin >> a >> b;
change[i] = make_pair(b, a);
}
sort(all(change));
reverse(all(change));
/*for(auto p : change){
cout << p.first << p.second;
}
for(ll x : cardnum){
cout << x;
}*/
ll nowcard = 0;
for (auto p : change) {
for (ll i = 0; i < p.second; i++) {
if (nowcard != n and cardnum[nowcard] < p.first) {
sum += p.first - cardnum[nowcard];
nowcard++;
} else {
cout << sum << endl;
return 0;
}
}
}
cout << sum << endl;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 852,566 | 852,567 | u434398296 | cpp |
p03037 | #include "bits/stdc++.h"
#define REP(i, num) for (int i = 0; i < (num); ++i)
#define ALL(c) c.begin(), c.end()
#define PRINTALL(c) \
for (auto &x : c) { \
cout << x << ' '; \
} \
cout << endl;
using namespace std;
using ll = long long;
template <typename T = int> T in() {
T x;
cin >> x;
return (x);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N = in(), M = in();
int l = in(), r = in();
REP(i, M - 1) {
int tl = in(), tr = in();
l = max(l, tl);
r = min(r, tr);
}
cout << (r - l + 1) << endl;
return 0;
} | #include "bits/stdc++.h"
#define REP(i, num) for (int i = 0; i < (num); ++i)
#define ALL(c) c.begin(), c.end()
#define PRINTALL(c) \
for (auto &x : c) { \
cout << x << ' '; \
} \
cout << endl;
using namespace std;
using ll = long long;
template <typename T = int> T in() {
T x;
cin >> x;
return (x);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N = in(), M = in();
int l = in(), r = in();
REP(i, M - 1) {
int tl = in(), tr = in();
l = max(l, tl);
r = min(r, tr);
}
cout << max(r - l + 1, 0) << endl;
return 0;
}
| [
"call.add",
"call.arguments.add"
] | 852,572 | 852,573 | u135248164 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll power(ll x, ll n, ll mod) {
ll res = 1;
x %= mod;
while (n) {
if (n & 1)
res = (res * x) % mod;
x = (x * x) % mod;
n >>= 1;
}
return res;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, m;
cin >> n >> m;
ll arr[n + 5];
memset(arr, 0, sizeof(arr));
ll l = -inf, r = inf;
for (ll i = 1; i <= m; i++) {
ll a, b;
cin >> a >> b;
l = max(l, a);
r = min(r, b);
}
cout << r - l + 1 << en;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll power(ll x, ll n, ll mod) {
ll res = 1;
x %= mod;
while (n) {
if (n & 1)
res = (res * x) % mod;
x = (x * x) % mod;
n >>= 1;
}
return res;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, m;
cin >> n >> m;
ll arr[n + 5];
memset(arr, 0, sizeof(arr));
ll l = -inf, r = inf;
for (ll i = 1; i <= m; i++) {
ll a, b;
cin >> a >> b;
l = max(l, a);
r = min(r, b);
}
cout << max(0ll, r - l + 1) << en;
return 0;
} | [
"call.add",
"call.arguments.change"
] | 852,574 | 852,575 | u401416019 | cpp |
p03037 | #include <iostream>
using namespace std;
int main() {
int left, right, l, r, n, m;
cin >> n >> m;
left = 1;
right = n;
for (int i = 0; i < m; i++) {
cin >> l >> r;
left = max(left, l);
right = min(right, r);
}
cout << right - left + 1 << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int left, right, l, r, n, m;
cin >> n >> m;
left = 1;
right = n;
for (int i = 0; i < m; i++) {
cin >> l >> r;
left = max(left, l);
right = min(right, r);
}
cout << max(0, right - left + 1) << endl;
return 0;
} | [
"call.add",
"call.arguments.change"
] | 852,582 | 852,583 | u749475370 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
int N, M;
cin >> N >> M;
int L[M], R[M];
rep(i, M) { cin >> L[i] >> R[i]; }
int L_max = 1, R_min = N;
rep(i, M) {
L_max = max(L_max, L[i]);
R_min = min(R_min, R[i]);
}
printf("%d\n", R_min - L_max + 1);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
int N, M;
cin >> N >> M;
int L[M], R[M];
rep(i, M) { cin >> L[i] >> R[i]; }
int L_max = 1, R_min = N;
rep(i, M) {
L_max = max(L_max, L[i]);
R_min = min(R_min, R[i]);
}
// printf("%d\n", R_min - L_max+1);
printf("%d\n", max(R_min - L_max + 1, 0));
return 0;
} | [
"call.add",
"call.arguments.add"
] | 852,584 | 852,585 | u263654061 | cpp |
p03037 | #include <algorithm>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int L = 1, R = N;
for (int i = 0; i < M; i++) {
int l, r;
cin >> l >> r;
L = max(L, l);
R = min(R, r);
}
cout << R - L + 1 << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int L = 1, R = N;
for (int i = 0; i < M; i++) {
int l, r;
cin >> l >> r;
L = max(L, l);
R = min(R, r);
}
cout << max(0, R - L + 1) << endl;
return 0;
} | [
"call.add",
"call.arguments.change"
] | 852,598 | 852,599 | u587172770 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
#define int long long
// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
VI l(10010);
VI r(10010);
int n, m;
signed main() {
cin >> n >> m;
l.resize(m);
r.resize(m);
REP(i, m) { cin >> l[i] >> r[i]; }
sort(ALL(l));
sort(ALL(r));
cout << min(n, r.front() - l.back() + 1) << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
VI l(10010);
VI r(10010);
int n, m;
signed main() {
cin >> n >> m;
l.resize(m);
r.resize(m);
REP(i, m) { cin >> l[i] >> r[i]; }
sort(ALL(l));
sort(ALL(r));
cout << max(min(n, r.front() - l.back() + 1), 0LL) << endl;
} | [
"call.add",
"call.arguments.add"
] | 852,602 | 852,603 | u187153832 | cpp |
p03037 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
int main(int argc, const char *argv[]) {
int N, M;
cin >> N >> M;
vector<int> L(M), R(M);
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
}
int l = 1, r = N;
for (int i = 0; i < M; i++) {
l = max(l, L[i]);
r = min(r, R[i]);
}
cout << r - l + 1 << endl;
return 0;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
int main(int argc, const char *argv[]) {
int N, M;
cin >> N >> M;
vector<int> L(M), R(M);
for (int i = 0; i < M; i++) {
cin >> L[i] >> R[i];
}
int l = 1, r = N;
for (int i = 0; i < M; i++) {
l = max(l, L[i]);
r = min(r, R[i]);
}
cout << max(0, r - l + 1) << endl;
return 0;
} | [
"call.add",
"call.arguments.change"
] | 852,604 | 852,605 | u320491590 | cpp |
p03037 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> l(m), r(m);
for (int i = 0; i < m; i++)
cin >> l[i] >> r[i];
int L = 0, M = n - 1;
for (int i = 0; i < m; i++) {
if (L < l[i] - 1)
L = l[i] - 1;
if (M > r[i] - 1)
M = r[i] - 1;
}
cout << M - L + 1 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> l(m), r(m);
for (int i = 0; i < m; i++)
cin >> l[i] >> r[i];
int L = 0, M = n - 1;
for (int i = 0; i < m; i++) {
if (L < l[i] - 1)
L = l[i] - 1;
if (M > r[i] - 1)
M = r[i] - 1;
}
cout << max(M - L + 1, 0) << endl;
} | [
"call.add",
"call.arguments.add"
] | 852,606 | 852,607 | u057079894 | cpp |
p03037 | #include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i, n) for (auto i = 0; i < (n); i++)
#define rep1(i, n) for (auto i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
struct init {
init() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(20);
};
} aaaaaaa;
int main() {
ll n, m;
cin >> n >> m;
vector<ll> l(m);
vector<ll> r(m);
rep(i, m) cin >> l[i] >> r[i];
rep(i, m) l[i]--, r[i]--;
vector<bool> memo(n, true);
ll ld = 0;
ll rd = n - 1;
rep(i, m) {
ld = max(ld, l[i]);
rd = min(rd, r[i]);
}
cout << rd - ld + 1 << endl;
return 0;
}
| #include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i, n) for (auto i = 0; i < (n); i++)
#define rep1(i, n) for (auto i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
struct init {
init() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(20);
};
} aaaaaaa;
int main() {
ll n, m;
cin >> n >> m;
vector<ll> l(m);
vector<ll> r(m);
rep(i, m) cin >> l[i] >> r[i];
rep(i, m) l[i]--, r[i]--;
vector<bool> memo(n, true);
ll ld = 0;
ll rd = n - 1;
rep(i, m) {
ld = max(ld, l[i]);
rd = min(rd, r[i]);
}
cout << max(0ll, rd - ld + 1) << endl;
return 0;
}
| [
"call.add",
"call.arguments.change"
] | 852,618 | 852,619 | u779159595 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.