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 |
|---|---|---|---|---|---|---|---|
p03156 | /*
chirag11032000
Chirag Thakur
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using db = double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using OrderedSet =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using MinPriorityQueue = priority_queue<T, vector<T>, greater<T>>;
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << std ::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fastIo() \
ios_base ::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
void testCase();
int main() {
fastIo();
testCase();
cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
return 0;
}
void testCase() {
int n, a, b;
cin >> n >> a >> b;
int x = 0, y = 0, z = 0;
for (int i = 0; i < n; ++i) {
int temp;
cin >> temp;
x += (temp <= a);
y += (temp > a && temp <= b);
z += (temp >= b);
}
cout << min({x, y, z}) << "\n";
} | /*
chirag11032000
Chirag Thakur
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using db = double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using OrderedSet =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using MinPriorityQueue = priority_queue<T, vector<T>, greater<T>>;
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << std ::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fastIo() \
ios_base ::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
void testCase();
int main() {
fastIo();
testCase();
cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
return 0;
}
void testCase() {
int n, a, b;
cin >> n >> a >> b;
int x = 0, y = 0, z = 0;
for (int i = 0; i < n; ++i) {
int temp;
cin >> temp;
x += (temp <= a);
y += (temp > a && temp <= b);
z += (temp > b);
}
cout << min({x, y, z}) << "\n";
} | [
"expression.operator.compare.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 949,795 | 949,796 | u774906517 | cpp |
p03156 | #include "stdio.h"
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
typedef long long int lld;
int main() {
int n;
cin >> n;
int A, B;
cin >> A >> B;
int l, m, r;
l = 0;
m = 0;
r = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x <= A)
l++;
if (x > A && x <= B)
m++;
if (x > B)
r++;
}
cout << min(l, min(r, l)) << endl;
return 0;
} | #include "stdio.h"
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
typedef long long int lld;
int main() {
int n;
cin >> n;
int A, B;
cin >> A >> B;
int l, m, r;
l = 0;
m = 0;
r = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x <= A)
l++;
if (x > A && x <= B)
m++;
if (x > B)
r++;
}
cout << min(l, min(r, m)) << endl;
return 0;
} | [
"identifier.change",
"io.output.change"
] | 949,799 | 949,800 | u575705530 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int x, y, z, p;
int main() {
int n, a, b;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> p;
if (p <= a)
x++;
else if (p > b)
z++;
else
y++;
}
cout << max({x, y, z});
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int x, y, z, p;
int main() {
int n, a, b;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> p;
if (p <= a)
x++;
else if (p > b)
z++;
else
y++;
}
cout << min({x, y, z});
} | [
"misc.opposites",
"identifier.change",
"call.function.change",
"io.output.change"
] | 949,803 | 949,804 | u987476436 | cpp |
p03156 | #ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif
// 継承可能な型
template <class Type> struct IN : Type {
IN() { std::cin >> *this; }
};
// 継承不可能な型
template <class Type> struct IN_ {
Type val;
IN_() { std::cin >> val; }
operator Type &() { return val; }
IN_<Type> &operator=(const Type &_value) {
val = _value;
return *this;
}
};
template <class Char, class Type>
std::basic_ostream<Char> &operator<<(std::basic_ostream<Char> &os,
const IN_<Type> &value) {
return os << value.val;
}
template <class Char, class Type>
std::basic_istream<Char> &operator>>(std::basic_istream<Char> &is,
IN_<Type> &value) {
return is >> value.val;
}
template <class Type> void OUT(const Type &value) {
std::cout << value << std::endl;
}
template <class Type, class... Args>
void OUT(const Type &value, const Args &...args) {
std::cout << value << ' ';
OUT(args...);
}
void YES() { OUT("YES"); }
void NO() { OUT("NO"); }
void YESNO(const bool cond) { OUT(cond ? "YES" : "NO"); }
void Yes() { OUT("Yes"); }
void No() { OUT("No"); }
void YesNo(const bool cond) { OUT(cond ? "Yes" : "No"); }
using ll = long long;
using ld = long double;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using P = std::pair<ll, ll>;
using instr = IN<std::string>;
// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n) {
for (ll i = n - 1; i > 1; --i)
n *= i;
return n;
}
// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r) {
if (r * 2 > n)
r = n - r;
ll dividend = 1, divisor = 1;
for (ll i = 1; i <= r; ++i) {
dividend *= n - i + 1;
divisor *= i;
}
return dividend / divisor;
}
// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num) {
if (num < 2)
return false;
if (num == 2)
return true;
if (num % 2 == 0)
return false;
double sqrtNum = sqrt(num);
for (ll i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0)
return false;
}
return true;
}
// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n) {
ll sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
// 2つの数の最大公約数を求める
ll gcd(ll m, ll n) {
// 引数に0がある場合は0を返す
if (m == 0 || n == 0)
return 0;
// ユークリッドの方法
while (m != n) {
if (m > n)
m = m - n;
else
n = n - m;
}
return m;
}
// 2つの数の最小公倍数を求める
ll lcm(const ll m, const ll n) {
// 引数に0がある場合は0を返す
if (m == 0 || n == 0)
return 0;
// lcm = m * n / gcd(m,n)
return m / gcd(m, n) * n;
}
// 3以上の数の最大公約数を求める
template <class Container> ll gcd(const Container &v) {
ll res = *std::begin(v);
for (const auto &i : v) {
res = gcd(res, i);
}
return res;
}
// 3以上の数の最小公倍数を求める
template <class Container> ll lcm(const Container &v) {
ll res = *std::begin(v);
for (const auto &i : v) {
res = lcm(res, i);
}
return res;
}
// 結果を切り上げる除算
ll divup(const ll a, const ll b) { return (a + b - 1) / b; }
ll inrange(const ll x, const ll y, const ll w, const ll h) {
return 0 <= x && x < w && 0 <= y && y < h;
}
// 指数が整数のpow
// https://kazu-yamamoto.hatenablog.jp/entry/20090223/1235372875
template <typename Type> Type pow_i(const Type x, const ll n) {
if (n == 0)
return 1;
else if (n % 2 == 0)
return pow_i(x * x, n / 2);
else
return x * pow_i(x, n - 1);
}
// 指数が整数のpow (mを法として)
// http://augusuto04.hatenablog.com/entry/2015/05/02/183451
ll pow_im(const ll x, const ll n, const ll m) {
if (n == 0)
return 1;
else if (n % 2 == 0)
return pow_im(x * x % m, n / 2, m);
else
return x * pow_im(x, n - 1, m) % m;
}
const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e18;
const ll dy[] = {0, 0, 1, -1};
const ll dx[] = {1, -1, 0, 0};
#define FOR(i, m, n) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll(i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll(i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto(it) = (v).rbegin(); (it) != (v).rend(); ++(it))
void Main();
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
Main();
#ifdef _DEBUG
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << std::endl << "Press Enter key to continue...";
std::cin.get();
#endif
return 0;
}
using namespace std;
//////////////////////////////
void Main() {
inll n, a, b;
ll s = 0, t = 0, u = 0;
REP(i, n) {
inll p;
if (p <= a)
s++;
if (a < p && p <= b)
t++;
if (b <= p)
u++;
}
return OUT(min({s, t, u}));
}
| #ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif
// 継承可能な型
template <class Type> struct IN : Type {
IN() { std::cin >> *this; }
};
// 継承不可能な型
template <class Type> struct IN_ {
Type val;
IN_() { std::cin >> val; }
operator Type &() { return val; }
IN_<Type> &operator=(const Type &_value) {
val = _value;
return *this;
}
};
template <class Char, class Type>
std::basic_ostream<Char> &operator<<(std::basic_ostream<Char> &os,
const IN_<Type> &value) {
return os << value.val;
}
template <class Char, class Type>
std::basic_istream<Char> &operator>>(std::basic_istream<Char> &is,
IN_<Type> &value) {
return is >> value.val;
}
template <class Type> void OUT(const Type &value) {
std::cout << value << std::endl;
}
template <class Type, class... Args>
void OUT(const Type &value, const Args &...args) {
std::cout << value << ' ';
OUT(args...);
}
void YES() { OUT("YES"); }
void NO() { OUT("NO"); }
void YESNO(const bool cond) { OUT(cond ? "YES" : "NO"); }
void Yes() { OUT("Yes"); }
void No() { OUT("No"); }
void YesNo(const bool cond) { OUT(cond ? "Yes" : "No"); }
using ll = long long;
using ld = long double;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using P = std::pair<ll, ll>;
using instr = IN<std::string>;
// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n) {
for (ll i = n - 1; i > 1; --i)
n *= i;
return n;
}
// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r) {
if (r * 2 > n)
r = n - r;
ll dividend = 1, divisor = 1;
for (ll i = 1; i <= r; ++i) {
dividend *= n - i + 1;
divisor *= i;
}
return dividend / divisor;
}
// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num) {
if (num < 2)
return false;
if (num == 2)
return true;
if (num % 2 == 0)
return false;
double sqrtNum = sqrt(num);
for (ll i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0)
return false;
}
return true;
}
// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n) {
ll sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
// 2つの数の最大公約数を求める
ll gcd(ll m, ll n) {
// 引数に0がある場合は0を返す
if (m == 0 || n == 0)
return 0;
// ユークリッドの方法
while (m != n) {
if (m > n)
m = m - n;
else
n = n - m;
}
return m;
}
// 2つの数の最小公倍数を求める
ll lcm(const ll m, const ll n) {
// 引数に0がある場合は0を返す
if (m == 0 || n == 0)
return 0;
// lcm = m * n / gcd(m,n)
return m / gcd(m, n) * n;
}
// 3以上の数の最大公約数を求める
template <class Container> ll gcd(const Container &v) {
ll res = *std::begin(v);
for (const auto &i : v) {
res = gcd(res, i);
}
return res;
}
// 3以上の数の最小公倍数を求める
template <class Container> ll lcm(const Container &v) {
ll res = *std::begin(v);
for (const auto &i : v) {
res = lcm(res, i);
}
return res;
}
// 結果を切り上げる除算
ll divup(const ll a, const ll b) { return (a + b - 1) / b; }
ll inrange(const ll x, const ll y, const ll w, const ll h) {
return 0 <= x && x < w && 0 <= y && y < h;
}
// 指数が整数のpow
// https://kazu-yamamoto.hatenablog.jp/entry/20090223/1235372875
template <typename Type> Type pow_i(const Type x, const ll n) {
if (n == 0)
return 1;
else if (n % 2 == 0)
return pow_i(x * x, n / 2);
else
return x * pow_i(x, n - 1);
}
// 指数が整数のpow (mを法として)
// http://augusuto04.hatenablog.com/entry/2015/05/02/183451
ll pow_im(const ll x, const ll n, const ll m) {
if (n == 0)
return 1;
else if (n % 2 == 0)
return pow_im(x * x % m, n / 2, m);
else
return x * pow_im(x, n - 1, m) % m;
}
const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e18;
const ll dy[] = {0, 0, 1, -1};
const ll dx[] = {1, -1, 0, 0};
#define FOR(i, m, n) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll(i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll(i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto(it) = (v).rbegin(); (it) != (v).rend(); ++(it))
void Main();
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
Main();
#ifdef _DEBUG
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << std::endl << "Press Enter key to continue...";
std::cin.get();
#endif
return 0;
}
using namespace std;
//////////////////////////////
void Main() {
inll n, a, b;
ll s = 0, t = 0, u = 0;
REP(i, n) {
inll p;
if (p <= a)
s++;
if (a < p && p <= b)
t++;
if (b < p)
u++;
}
return OUT(min({s, t, u}));
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 949,805 | 949,806 | u258602643 | cpp |
p03156 | #include <algorithm>
#include <atomic>
#include <cmath>
#include <future>
#include <iostream>
#include <map>
#include <mutex>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <thread>
#include <vector>
#define int long long
#define endre \
getchar(); \
getchar(); \
return 0
#define INF 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define input() \
for (int i = 0; i < n; i++) \
cin >> a[i];
#define P pair<int, int>
#define prique priority_queue<int, vector<int>, greater<int>>
#define vecunique(vec) \
sort(vec.begin(), vec.end()); \
decltype(vec)::iterator result = std::unique(vec.begin(), vec.end()); \
vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
int gcd(int x, int y) {
if (x < y)
swap(x, y);
if (y == 0)
return x;
return (y, x % y);
}
int lcm(int x, int y) { return x * y / gcd(x, y); }
int kai(int n) {
if (n == 0)
return 1;
return (kai(n - 1) * n) % INF;
}
int mod_pow(int x, int y, int mod) {
int res = 1;
while (y > 0) {
if (y & 1) {
res = res * x % mod;
}
x = x * x % mod;
y >>= 1;
}
return res;
}
int mystoi(string s) {
int cnt = 0;
for (int i = 0; i < s.size(); i++) {
cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
}
return cnt;
}
int n, a, b, p[105], aa, bb, cc;
signed main() {
cin >> n >> a >> b;
rep(i, n) {
cin >> p[i];
if (p[i] <= a)
aa++;
if (p[i] >= a && p[i] < b)
bb++;
if (p[i] >= b)
cc++;
}
cout << min({aa, bb, cc}) << endl;
endre;
} | #include <algorithm>
#include <atomic>
#include <cmath>
#include <future>
#include <iostream>
#include <map>
#include <mutex>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <thread>
#include <vector>
#define int long long
#define endre \
getchar(); \
getchar(); \
return 0
#define INF 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define input() \
for (int i = 0; i < n; i++) \
cin >> a[i];
#define P pair<int, int>
#define prique priority_queue<int, vector<int>, greater<int>>
#define vecunique(vec) \
sort(vec.begin(), vec.end()); \
decltype(vec)::iterator result = std::unique(vec.begin(), vec.end()); \
vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
int gcd(int x, int y) {
if (x < y)
swap(x, y);
if (y == 0)
return x;
return (y, x % y);
}
int lcm(int x, int y) { return x * y / gcd(x, y); }
int kai(int n) {
if (n == 0)
return 1;
return (kai(n - 1) * n) % INF;
}
int mod_pow(int x, int y, int mod) {
int res = 1;
while (y > 0) {
if (y & 1) {
res = res * x % mod;
}
x = x * x % mod;
y >>= 1;
}
return res;
}
int mystoi(string s) {
int cnt = 0;
for (int i = 0; i < s.size(); i++) {
cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
}
return cnt;
}
int n, a, b, p[105], aa, bb, cc;
signed main() {
cin >> n >> a >> b;
rep(i, n) {
cin >> p[i];
if (p[i] <= a)
aa++;
if (p[i] > a && p[i] <= b)
bb++;
if (p[i] > b)
cc++;
}
cout << min({aa, bb, cc}) << endl;
endre;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 949,809 | 949,810 | u147049801 | cpp |
p03156 | #include <bits/stdc++.h>
#define rep(i, n, m) for (int i = n; i < (int)(m); i++)
#define rrep(i, n, m) for (int i = ((int)(n)-1); i >= m; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
int main() {
int n, a, b;
cin >> n >> a >> b;
int x, y, z;
rep(i, 0, n) {
int p;
cin >> p;
if (p <= a)
x++;
else if (p <= b)
y++;
else
z++;
}
cout << min({x, y, z}) << endl;
}
| #include <bits/stdc++.h>
#define rep(i, n, m) for (int i = n; i < (int)(m); i++)
#define rrep(i, n, m) for (int i = ((int)(n)-1); i >= m; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
int main() {
int n, a, b;
cin >> n >> a >> b;
int x = 0, y = 0, z = 0;
rep(i, 0, n) {
int p;
cin >> p;
if (p <= a)
x++;
else if (p <= b)
y++;
else
z++;
}
cout << min({x, y, z}) << endl;
}
| [
"variable_declaration.value.change"
] | 949,815 | 949,816 | u649915042 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i, m, n) for (lli i = m; i < n; i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(), n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli, lli>>
#define mod 1000000007;
bool is_prime(lli x) {
for (lli i = 2; i * i <= x; i++) {
if (x % i == 0)
return false;
}
return true;
}
int main() {
lli A, B, C = 1, D = 0, E = 0, F = 0, G = 0, H = 0, N, M;
cin >> N >> A >> B;
vector<int> P(3, 0);
rep(i, 0, A) {
cin >> C;
if (C < A + 1)
P[0]++;
else if (C > A && C < B + 1)
P[1]++;
else
P[2]++;
}
Sort(P);
Out(P[0]);
} | #include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i, m, n) for (lli i = m; i < n; i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(), n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli, lli>>
#define mod 1000000007;
bool is_prime(lli x) {
for (lli i = 2; i * i <= x; i++) {
if (x % i == 0)
return false;
}
return true;
}
int main() {
lli A, B, C = 1, D = 0, E = 0, F = 0, G = 0, H = 0, N, M;
cin >> N >> A >> B;
vector<int> P(3, 0);
rep(i, 0, N) {
cin >> C;
if (C < A + 1)
P[0]++;
else if (C > A && C < B + 1)
P[1]++;
else
P[2]++;
}
Sort(P);
Out(P[0]);
} | [
"identifier.change",
"call.arguments.change"
] | 949,821 | 949,822 | u618604643 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, n) for (int i = 2; i < (int)(n); i++)
#define repk(i, k, n) for (int i = k; i < (int)(n); i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, A, B;
cin >> N >> A >> B;
vei p(N);
rep(i, N) cin >> p[i];
int cnt1 = 0, cnt2 = 0, cnt3 = 0;
rep(i, N) {
if (p[i] <= A)
cnt1++;
if (A + 1 <= p[i] and p[i] <= B)
cnt2++;
if (p[i] >= B)
cnt3++;
}
cout << min(cnt1, min(cnt2, cnt3)) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, n) for (int i = 2; i < (int)(n); i++)
#define repk(i, k, n) for (int i = k; i < (int)(n); i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, A, B;
cin >> N >> A >> B;
vei p(N);
rep(i, N) cin >> p[i];
int cnt1 = 0, cnt2 = 0, cnt3 = 0;
rep(i, N) {
if (p[i] <= A)
cnt1++;
if (A + 1 <= p[i] and p[i] <= B)
cnt2++;
if (p[i] >= B + 1)
cnt3++;
}
cout << min(cnt1, min(cnt2, cnt3)) << endl;
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 949,823 | 949,824 | u263715385 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, A, B, p = 0, q = 0;
cin >> N >> A >> B;
vector<int> a(N);
for (int i = 0; i < N; i++)
cin >> a.at(i);
sort(a.begin(), a.end());
for (int i = 0; i < N; i++) {
if (a.at(i) <= A)
p++;
else if (a.at(i) >= B)
q++;
}
int ans = min(p, q);
ans = min(ans, N - p - q);
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, A, B, p = 0, q = 0;
cin >> N >> A >> B;
vector<int> a(N);
for (int i = 0; i < N; i++)
cin >> a.at(i);
sort(a.begin(), a.end());
for (int i = 0; i < N; i++) {
if (a.at(i) <= A)
p++;
else if (a.at(i) > B)
q++;
}
int ans = min(p, q);
ans = min(ans, N - p - q);
cout << ans << endl;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 949,825 | 949,826 | u936602931 | cpp |
p03156 | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
using namespace std;
int a[114514];
int main() {
int n;
cin >> n;
int t, k;
cin >> t >> k;
int q = 0, w = 0, e = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
if (a[i] <= t) {
q++;
} else if (a[i] <= k) {
w++;
} else {
e++;
}
}
int ans = min(q, w);
int sum = min(w, e);
cout << sum << endl;
} | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
using namespace std;
int a[114514];
int main() {
int n;
cin >> n;
int t, k;
cin >> t >> k;
int q = 0, w = 0, e = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
if (a[i] <= t) {
q++;
} else if (a[i] <= k) {
w++;
} else {
e++;
}
}
int ans = min(q, w);
int sum = min(ans, e);
cout << sum << endl;
} | [
"identifier.change",
"call.arguments.change"
] | 949,829 | 949,830 | u409872261 | cpp |
p03156 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define ll long long
#define REP(i, x) for (int(i) = 0; (i) < (x); (i)++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;
int main() {
int n, a, b;
cin >> n >> a >> b;
vector<int> p(n);
REP(i, n) { cin >> p[i]; }
int prob[3] = {0};
REP(i, n) {
if (p[i] <= a) {
prob[0]++;
} else if (p[i] <= b) {
prob[1]++;
} else {
prob[2]++;
}
}
int m = 100000000;
REP(i, 2) { m = min(m, prob[i]); }
cout << m << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define ll long long
#define REP(i, x) for (int(i) = 0; (i) < (x); (i)++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;
int main() {
int n, a, b;
cin >> n >> a >> b;
vector<int> p(n);
REP(i, n) { cin >> p[i]; }
int prob[3] = {0};
REP(i, n) {
if (p[i] <= a) {
prob[0]++;
} else if (p[i] <= b) {
prob[1]++;
} else {
prob[2]++;
}
}
int m = 100000000;
REP(i, 3) { m = min(m, prob[i]); }
cout << m << endl;
return 0;
} | [
"literal.number.change",
"call.arguments.change"
] | 949,831 | 949,832 | u342129174 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ll long long
int main() {
int n, p[105], a, b;
cin >> n >> a >> b;
rep(i, n) cin >> p[i];
int c1 = 0, c2 = 0, c3 = 0;
rep(i, n) {
if (p[i] < a + 1)
c1++;
else if (a < p[i] < b + 1)
c2++;
else
c3++;
}
cout << min({c1, c2, c3}) << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ll long long
int main() {
int n, p[105], a, b;
cin >> n >> a >> b;
rep(i, n) cin >> p[i];
int c1 = 0, c2 = 0, c3 = 0;
rep(i, n) {
if (p[i] < a + 1)
c1++;
else if (p[i] < b + 1)
c2++;
else
c3++;
}
cout << min({c1, c2, c3}) << endl;
} | [
"expression.operation.binary.remove"
] | 949,844 | 949,845 | u191466726 | cpp |
p03156 | #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF 1e9
#define INFLL 1e18
#define EPS 1e-9
#define MOD 1000000007
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define REPR(i, n) for (ll i = (n)-1; i >= 0; --i)
#define REPR1(i, n) for (ll i = (n); i > 0; --i)
#define REPC(i, obj) for (auto i : obj)
#define ALL(obj) (obj).begin(), (obj).end()
#define SETP(n) cout << fixed << setprecision(n)
#define VV(T, h, w) move(vector<vector<T>>(h, move(vector<T>(w))))
#define VVI(T, h, w, i) move(vector<vector<T>>(h, move(vector<T>(w, i))))
using namespace std;
using ll = long long;
template <typename T = ll> inline T in() {
T ret;
cin >> ret;
return ret;
}
int main() {
ll n = in(), a = in(), b = in();
ll cnt[3] = {0, 0, 0};
REP(i, n) {
ll p = in();
++*(p <= a ? cnt : p <= b ? cnt + 1 : cnt + 2);
}
cout << *min_element(cnt, cnt + 2) << endl;
} | #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF 1e9
#define INFLL 1e18
#define EPS 1e-9
#define MOD 1000000007
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define REPR(i, n) for (ll i = (n)-1; i >= 0; --i)
#define REPR1(i, n) for (ll i = (n); i > 0; --i)
#define REPC(i, obj) for (auto i : obj)
#define ALL(obj) (obj).begin(), (obj).end()
#define SETP(n) cout << fixed << setprecision(n)
#define VV(T, h, w) move(vector<vector<T>>(h, move(vector<T>(w))))
#define VVI(T, h, w, i) move(vector<vector<T>>(h, move(vector<T>(w, i))))
using namespace std;
using ll = long long;
template <typename T = ll> inline T in() {
T ret;
cin >> ret;
return ret;
}
int main() {
ll n = in(), a = in(), b = in();
ll cnt[3] = {0, 0, 0};
REP(i, n) {
ll p = in();
++*(p <= a ? cnt : p <= b ? cnt + 1 : cnt + 2);
}
cout << *min_element(cnt, cnt + 3) << endl;
} | [
"literal.number.change",
"io.output.change"
] | 949,847 | 949,848 | u388817534 | cpp |
p03156 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = a; i < b; i++)
int main() {
int n, a, b;
cin >> n >> a >> b;
int cnt1 = 0, cnt2 = 0, cnt3 = 0;
rep(i, 0, n) {
int p;
cin >> p;
if (p <= a)
cnt1++;
if (p > b)
cnt3++;
else
cnt2++;
}
cout << min({cnt1, cnt2, cnt3});
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = a; i < b; i++)
int main() {
int n, a, b;
cin >> n >> a >> b;
int cnt1 = 0, cnt2 = 0, cnt3 = 0;
rep(i, 0, n) {
int p;
cin >> p;
if (p <= a)
cnt1++;
else if (p > b)
cnt3++;
else
cnt2++;
}
cout << min({cnt1, cnt2, cnt3});
} | [
"control_flow.branch.else_if.replace.add",
"control_flow.branch.if.replace.remove"
] | 949,853 | 949,854 | u356489231 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, A, B;
cin >> n >> A >> B;
int t1, t2, t3;
for (int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
if (x <= A)
t1++;
if (x > A && x <= B)
t2++;
if (x > B)
t3++;
}
cout << min(t1, min(t2, t3));
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, A, B;
cin >> n >> A >> B;
int t1 = 0, t2 = 0, t3 = 0;
for (int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
if (x <= A)
t1++;
if (x > A && x <= B)
t2++;
if (x > B)
t3++;
}
cout << min(t1, min(t2, t3));
return 0;
} | [
"variable_declaration.value.change"
] | 949,855 | 949,856 | u027681381 | cpp |
p03156 | #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int min(int a, int b) {
int result;
if (a < b)
result = a;
else
result = b;
return result;
}
int main() {
int N, A, B;
cin >> N >> A >> B;
int P[N];
for (int i = 0; i < N; i++) {
cin >> P[i];
}
int n1, n2, n3;
for (int i = 0; i < N; i++) {
if (P[i] <= A)
n1++;
else if (P[i] > B)
n3++;
else
n2++;
}
cout << min(min(n1, n2), n3) << endl;
} | #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int min(int a, int b) {
int result;
if (a < b)
result = a;
else
result = b;
return result;
}
int main() {
int N, A, B;
cin >> N >> A >> B;
int P[N];
for (int i = 0; i < N; i++) {
cin >> P[i];
}
int n1 = 0, n2 = 0, n3 = 0;
for (int i = 0; i < N; i++) {
if (P[i] <= A)
n1++;
else if (P[i] > B)
n3++;
else
n2++;
}
cout << min(min(n1, n2), n3) << endl;
} | [
"variable_declaration.value.change"
] | 949,865 | 949,866 | u593433974 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
// const int MOD=998244353;
const double PI = 3.14159265359;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, a, b;
cin >> n >> a >> b;
int c1 = 0, c2 = 0, c3 = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x < a)
c1++;
else if (x <= b)
c2++;
else
c3++;
}
cout << (min(min(c1, c2), c3));
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
// const int MOD=998244353;
const double PI = 3.14159265359;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, a, b;
cin >> n >> a >> b;
int c1 = 0, c2 = 0, c3 = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x <= a)
c1++;
else if (x <= b)
c2++;
else
c3++;
}
cout << (min(min(c1, c2), c3));
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 949,874 | 949,875 | u190449731 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
// const int MOD=998244353;
const double PI = 3.14159265359;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, a, b;
cin >> n >> a >> b;
int c1 = 0, c2 = 0, c3 = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x < a)
c1++;
else if (x < b)
c2++;
else
c3++;
}
cout << (min(min(c1, c2), c3));
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
// const int MOD=998244353;
const double PI = 3.14159265359;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, a, b;
cin >> n >> a >> b;
int c1 = 0, c2 = 0, c3 = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x <= a)
c1++;
else if (x <= b)
c2++;
else
c3++;
}
cout << (min(min(c1, c2), c3));
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 949,876 | 949,875 | u190449731 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
typedef long long ll;
int main() {
int n, a, b;
int p;
cin >> n >> a >> b;
int c1, c2, c3;
rep(i, n) {
cin >> p;
if (p <= a) {
c1++;
} else if (p >= b + 1) {
c3++;
} else {
c2++;
}
}
int mi = min(c1, c2);
cout << min(mi, c3) << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
typedef long long ll;
int main() {
int n, a, b;
int p;
cin >> n >> a >> b;
int c1 = 0, c2 = 0, c3 = 0;
rep(i, n) {
cin >> p;
if (p <= a) {
c1++;
} else if (p >= b + 1) {
c3++;
} else {
c2++;
}
}
int mi = min(c1, c2);
cout << min(mi, c3) << endl;
return 0;
}
| [
"variable_declaration.value.change"
] | 949,877 | 949,878 | u320267096 | cpp |
p03156 | #include <algorithm>
#include <iostream>
using namespace std;
int p[100];
int x[3];
int main() {
int n, a, b, ca = 0, cb = 0, c = 0;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> p[i];
if (p[i] <= a)
ca++;
else if (p[i] > b)
cb++;
else
c++;
}
if (ca <= cb and ca <= c)
cout << ca / 3 << endl;
else if (c < ca and c < cb)
cout << c / 3 << endl;
else
cout << cb / 3 << endl;
} | #include <algorithm>
#include <iostream>
using namespace std;
int p[100];
int x[3];
int main() {
int n, a, b, ca = 0, cb = 0, c = 0;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> p[i];
if (p[i] <= a)
ca++;
else if (p[i] > b)
cb++;
else
c++;
}
if (ca <= cb and ca <= c)
cout << ca << endl;
else if (c < ca and c < cb)
cout << c << endl;
else
cout << cb << endl;
} | [
"expression.operation.binary.remove"
] | 949,881 | 949,882 | u127856129 | cpp |
p03156 | #include <stdio.h>
int main(void) {
int n, a, b, p, i, x[3] = {}, min = 100;
scanf("%d%d%d", &n, &a, &b);
for (i = 0; i < n; i++) {
scanf("%d", &p);
if (p < a)
x[0]++;
else if (p < b)
x[1]++;
else
x[2]++;
}
for (i = 0; i < 3; i++) {
if (min > x[i])
min = x[i];
}
printf("%d\n", min);
return 0;
} | #include <stdio.h>
int main(void) {
int n, a, b, p, i, x[3] = {}, min = 100;
scanf("%d%d%d", &n, &a, &b);
for (i = 0; i < n; i++) {
scanf("%d", &p);
if (p <= a)
x[0]++;
else if (p <= b)
x[1]++;
else
x[2]++;
}
for (i = 0; i < 3; i++) {
if (min > x[i])
min = x[i];
}
printf("%d\n", min);
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 949,883 | 949,884 | u088895504 | cpp |
p03156 | #include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;
int B, A, N;
vector<int> P;
int main() {
cin >> N >> A >> B;
for (int i = 0; i < N; i++) {
int tmpP;
cin >> tmpP;
P.push_back(tmpP);
}
vector<int> n(3);
for (const auto &tmpP : P) {
if (tmpP <= A) {
n[0]++;
} else if (tmpP <= B) {
n[1]++;
} else {
n[2]++;
}
}
int ans = *min(ALL(n));
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;
int B, A, N;
vector<int> P;
int main() {
cin >> N >> A >> B;
for (int i = 0; i < N; i++) {
int tmpP;
cin >> tmpP;
P.push_back(tmpP);
}
vector<int> n(3);
for (const auto &tmpP : P) {
if (tmpP <= A) {
n[0]++;
} else if (tmpP <= B) {
n[1]++;
} else {
n[2]++;
}
}
int ans = *min_element(ALL(n));
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"call.function.change"
] | 949,892 | 949,893 | u378945900 | cpp |
p03156 | #include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;
int B, A, N;
vector<int> P;
int main() {
cin >> N >> A >> B;
for (int i = 0; i < N; i++) {
int tmpP;
cin >> tmpP;
P.push_back(tmpP);
}
vector<int> n(3);
for (const auto &tmpP : P) {
if (tmpP <= A) {
n[0]++;
} else if (tmpP <= B) {
n[1]++;
} else {
n[2]++;
}
}
int ans = *min(ALL(n));
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;
int B, A, N;
vector<int> P;
int main() {
cin >> N >> A >> B;
for (int i = 0; i < N; i++) {
int tmpP;
cin >> tmpP;
P.push_back(tmpP);
}
vector<int> n(3);
for (const auto &tmpP : P) {
if (tmpP <= A) {
n[0]++;
} else if (tmpP <= B) {
n[1]++;
} else {
n[2]++;
}
}
int ans = *min_element(ALL(n));
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"call.function.change"
] | 949,894 | 949,893 | u378945900 | cpp |
p03156 | #include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;
int B, A, N;
vector<int> P;
int main() {
cin >> N >> A >> B;
for (int i = 0; i < N; i++) {
int tmpP;
cin >> tmpP;
P.push_back(tmpP);
}
vector<int> n(3);
for (const int tmpP : P) {
if (tmpP <= A) {
n[0]++;
} else if (tmpP <= B) {
n[1]++;
} else {
n[2]++;
}
}
int ans = *min(ALL(n));
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;
int B, A, N;
vector<int> P;
int main() {
cin >> N >> A >> B;
for (int i = 0; i < N; i++) {
int tmpP;
cin >> tmpP;
P.push_back(tmpP);
}
vector<int> n(3);
for (const auto &tmpP : P) {
if (tmpP <= A) {
n[0]++;
} else if (tmpP <= B) {
n[1]++;
} else {
n[2]++;
}
}
int ans = *min_element(ALL(n));
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"call.function.change"
] | 949,895 | 949,893 | u378945900 | cpp |
p03156 | #include "iostream"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
using ll = long long;
#define MOD 1000000007
int main(int argc, char const *argv[]) {
int n, a, b, p[110], s = 0, t = 0, u = 0;
std::cin >> n >> a >> b;
for (int i = 0; i < n; i++)
std::cin >> p[i];
for (int i = 0; i < n; i++) {
if (p[i] <= a)
s++;
if (p[i] <= b)
t++;
else
u++;
}
std::cout << min(s, min(t, u)) << '\n';
return 0;
}
| #include "iostream"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
using ll = long long;
#define MOD 1000000007
int main(int argc, char const *argv[]) {
int n, a, b, p[110], s = 0, t = 0, u = 0;
std::cin >> n >> a >> b;
for (int i = 0; i < n; i++)
std::cin >> p[i];
for (int i = 0; i < n; i++) {
if (p[i] <= a)
s++;
else if (p[i] <= b)
t++;
else
u++;
}
std::cout << min(s, min(t, u)) << '\n';
return 0;
}
| [
"control_flow.branch.else_if.replace.add",
"control_flow.branch.if.replace.remove"
] | 949,896 | 949,897 | u863279562 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, a, b, p, c = 0, d = 0, e = 0;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> p;
if (p < a) {
c++;
}
if (a + 1 <= p && p <= b) {
d++;
}
if (b + 1 <= p) {
e++;
}
}
cout << min(min(c, d), e);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, a, b, p, c = 0, d = 0, e = 0;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> p;
if (p <= a) {
c++;
}
if (a + 1 <= p && p <= b) {
d++;
}
if (b + 1 <= p) {
e++;
}
}
cout << min(min(c, d), e);
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 949,900 | 949,901 | u529645235 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, a, b, p, c = 0, d = 0, e = 0;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> p;
if (p < a) {
c++;
}
if (a + 1 <= p <= b) {
d++;
}
if (b + 1 <= p) {
e++;
}
}
cout << min(min(c, d), e);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, a, b, p, c = 0, d = 0, e = 0;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> p;
if (p <= a) {
c++;
}
if (a + 1 <= p && p <= b) {
d++;
}
if (b + 1 <= p) {
e++;
}
}
cout << min(min(c, d), e);
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 949,902 | 949,901 | u529645235 | cpp |
p03150 | #include <bits/stdc++.h>
#define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++)
#define rep(x, to) for (int(x) = 0; (x) < (to); (x)++)
#define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--)
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;
void dbg() { cerr << "\n"; }
template <typename T, typename... T2> void dbg(const T &fst, const T2 &...rst) {
cerr << fst << ": ";
dbg(rst...);
}
template <class T> void amin(T &a, T b) { a = min(a, b); }
template <class T> void amax(T &a, T b) { a = max(a, b); }
int main() {
// cin.tie(0); ios_base::sync_with_stdio(false);
string s;
cin >> s;
string mt = "keyence";
int n = sz(s);
rep(i, n) {
rep(j, n + 1 - i) {
string ts = s.substr(0, i) + s.substr(i + j);
// dbg(i,j,ts);
if (mt == ts) {
cout << "YES\n";
return 0;
}
}
}
cout << "No\n";
return 0;
}
| #include <bits/stdc++.h>
#define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++)
#define rep(x, to) for (int(x) = 0; (x) < (to); (x)++)
#define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--)
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;
void dbg() { cerr << "\n"; }
template <typename T, typename... T2> void dbg(const T &fst, const T2 &...rst) {
cerr << fst << ": ";
dbg(rst...);
}
template <class T> void amin(T &a, T b) { a = min(a, b); }
template <class T> void amax(T &a, T b) { a = max(a, b); }
int main() {
// cin.tie(0); ios_base::sync_with_stdio(false);
string s;
cin >> s;
string mt = "keyence";
int n = sz(s);
rep(i, n) {
rep(j, n + 1 - i) {
string ts = s.substr(0, i) + s.substr(i + j);
// dbg(i,j,ts);
if (mt == ts) {
cout << "YES\n";
return 0;
}
}
}
cout << "NO\n";
return 0;
}
| [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 949,924 | 949,925 | u714564133 | cpp |
p03150 | #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
string S;
cin >> S;
bool flag = false;
rep(i, S.size()) {
rep(j, S.size()) {
string temp(S);
temp.erase(temp.begin() + i, temp.begin() + i + j);
if (temp == "keyence") {
cout << "YES" << endl;
flag = true;
break;
}
}
if (flag == true) {
break;
}
}
if (!flag)
cout << "NO" << endl;
return 0;
}
| #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
string S;
cin >> S;
bool flag = false;
rep(i, S.size()) {
rep(j, S.size() - i) {
string temp(S);
temp.erase(temp.begin() + i, temp.begin() + i + j);
// cout << temp << endl;
if (temp == "keyence") {
cout << "YES" << endl;
flag = true;
break;
}
}
if (flag == true) {
break;
}
}
if (!flag)
cout << "NO" << endl;
return 0;
}
| [
"expression.operation.binary.add"
] | 949,942 | 949,943 | u873904588 | cpp |
p03150 | #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
string S;
cin >> S;
bool flag = false;
rep(i, S.size()) {
rep(j, S.size()) {
string temp(S);
temp.erase(temp.begin() + i, temp.begin() + i + j);
if (temp == "keyence") {
cout << "YES" << endl;
break;
}
}
if (flag == true) {
break;
}
}
if (!flag)
cout << "NO" << endl;
return 0;
}
| #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
string S;
cin >> S;
bool flag = false;
rep(i, S.size()) {
rep(j, S.size() - i) {
string temp(S);
temp.erase(temp.begin() + i, temp.begin() + i + j);
// cout << temp << endl;
if (temp == "keyence") {
cout << "YES" << endl;
flag = true;
break;
}
}
if (flag == true) {
break;
}
}
if (!flag)
cout << "NO" << endl;
return 0;
}
| [
"assignment.add"
] | 949,944 | 949,943 | u873904588 | cpp |
p03150 | /*input
mpyszsbznf
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i, n) for (int i = 0; i < ((int)n); i++)
#define pb push_back
#define MP(a, b) make_pair(a, b)
#define SORT_UNIQUE(c) \
(sort(c.begin(), c.end()), \
c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
template <typename T1, typename T2>
ostream &operator<<(ostream &out, pair<T1, T2> P) {
out << '(' << P.F << ',' << P.S << ')';
return out;
}
//}}}
const ll maxn = 300005;
const ll maxlg = __lg(maxn) + 2;
const ll INF64 = 8000000000000000000LL;
const int INF = 0x3f3f3f3f;
const ll MOD = ll(1e9 + 7);
const double PI = acos(-1);
// const ll p=880301;
// const ll P=31;
ll mypow(ll a, ll b) {
ll res = 1LL;
while (b) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
int main() {
IOS;
string a, b = "keyence";
cin >> a;
int i = 0, j = SZ(a) - 1;
for (i = 0; i < SZ(a) && i < SZ(b); i++) {
if (a[i] != b[j])
break;
}
for (j = 0; j < SZ(a) && j < SZ(b); j++) {
if (a[SZ(a) - 1 - j] != b[SZ(b) - 1 - j])
break;
}
if (i + j >= SZ(b))
cout << "YES\n";
else
cout << "NO\n";
return 0;
}
| /*input
keyence
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i, n) for (int i = 0; i < ((int)n); i++)
#define pb push_back
#define MP(a, b) make_pair(a, b)
#define SORT_UNIQUE(c) \
(sort(c.begin(), c.end()), \
c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
template <typename T1, typename T2>
ostream &operator<<(ostream &out, pair<T1, T2> P) {
out << '(' << P.F << ',' << P.S << ')';
return out;
}
//}}}
const ll maxn = 300005;
const ll maxlg = __lg(maxn) + 2;
const ll INF64 = 8000000000000000000LL;
const int INF = 0x3f3f3f3f;
const ll MOD = ll(1e9 + 7);
const double PI = acos(-1);
// const ll p=880301;
// const ll P=31;
ll mypow(ll a, ll b) {
ll res = 1LL;
while (b) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
int main() {
IOS;
string a, b = "keyence";
cin >> a;
int i = 0, j = SZ(a) - 1;
for (i = 0; i < SZ(a) && i < SZ(b); i++) {
if (a[i] != b[i])
break;
}
for (j = 0; j < SZ(a) && j < SZ(b); j++) {
if (a[SZ(a) - 1 - j] != b[SZ(b) - 1 - j])
break;
}
if (i + j >= SZ(b))
cout << "YES\n";
else
cout << "NO\n";
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 949,945 | 949,946 | u010467501 | cpp |
p03150 | /*input
keyofscience
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i, n) for (int i = 0; i < ((int)n); i++)
#define pb push_back
#define MP(a, b) make_pair(a, b)
#define SORT_UNIQUE(c) \
(sort(c.begin(), c.end()), \
c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
template <typename T1, typename T2>
ostream &operator<<(ostream &out, pair<T1, T2> P) {
out << '(' << P.F << ',' << P.S << ')';
return out;
}
//}}}
const ll maxn = 300005;
const ll maxlg = __lg(maxn) + 2;
const ll INF64 = 8000000000000000000LL;
const int INF = 0x3f3f3f3f;
const ll MOD = ll(1e9 + 7);
const double PI = acos(-1);
// const ll p=880301;
// const ll P=31;
ll mypow(ll a, ll b) {
ll res = 1LL;
while (b) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
int main() {
IOS;
string a, b = "keyence";
cin >> a;
int i = 0, j = SZ(a) - 1;
for (i = 0; i < SZ(a) && i < SZ(b); i++) {
if (a[i] != b[j])
break;
}
for (int j = 0; j < SZ(a) && j < SZ(b); j++) {
if (a[SZ(a) - 1 - j] != b[SZ(b) - 1 - j])
break;
}
if (i + j >= SZ(b))
cout << "YES\n";
else
cout << "NO\n";
return 0;
}
| /*input
keyence
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i, n) for (int i = 0; i < ((int)n); i++)
#define pb push_back
#define MP(a, b) make_pair(a, b)
#define SORT_UNIQUE(c) \
(sort(c.begin(), c.end()), \
c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
template <typename T1, typename T2>
ostream &operator<<(ostream &out, pair<T1, T2> P) {
out << '(' << P.F << ',' << P.S << ')';
return out;
}
//}}}
const ll maxn = 300005;
const ll maxlg = __lg(maxn) + 2;
const ll INF64 = 8000000000000000000LL;
const int INF = 0x3f3f3f3f;
const ll MOD = ll(1e9 + 7);
const double PI = acos(-1);
// const ll p=880301;
// const ll P=31;
ll mypow(ll a, ll b) {
ll res = 1LL;
while (b) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
int main() {
IOS;
string a, b = "keyence";
cin >> a;
int i = 0, j = SZ(a) - 1;
for (i = 0; i < SZ(a) && i < SZ(b); i++) {
if (a[i] != b[i])
break;
}
for (j = 0; j < SZ(a) && j < SZ(b); j++) {
if (a[SZ(a) - 1 - j] != b[SZ(b) - 1 - j])
break;
}
if (i + j >= SZ(b))
cout << "YES\n";
else
cout << "NO\n";
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 949,947 | 949,946 | u010467501 | cpp |
p03150 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s, t = "keyence", ans = "NO";
cin >> s;
int n = s.size();
rep(i, 8) {
bool a = true;
rep(j, 7) {
if (i <= j)
if (t[i] != s[n - 7 + i])
a = false;
if (i > j)
if (t[i] != s[i])
a = false;
}
if (a)
ans = "YES";
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string s, t = "keyence", ans = "NO";
cin >> s;
int n = s.size();
rep(i, 8) {
bool a = true;
rep(j, 7) {
if (i <= j)
if (t[j] != s[n - 7 + j])
a = false;
if (i > j)
if (t[j] != s[j])
a = false;
}
if (a)
ans = "YES";
}
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 949,986 | 949,987 | u604231488 | cpp |
p03150 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
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;
}
typedef long long ll;
using namespace std;
int main() {
string t = "keyence";
string s;
cin >> s;
int l = 0, r = 0;
int sl = s.size(), tl = t.size();
while (true) {
bool d = false;
if (s[l] == t[l]) {
l++;
d = true;
}
if (s[sl - r - 1] == t[tl - r - 1]) {
r++;
d = true;
}
if (!d)
break;
}
cout << (l + r == tl ? "YES" : "NO") << endl;
} | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
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;
}
typedef long long ll;
using namespace std;
int main() {
string t = "keyence";
string s;
cin >> s;
int l = 0, r = 0;
int sl = s.size(), tl = t.size();
while (true) {
bool d = false;
if (s[l] == t[l]) {
l++;
d = true;
}
if (s[sl - r - 1] == t[tl - r - 1]) {
r++;
d = true;
}
if (!d)
break;
}
cout << (l + r >= tl ? "YES" : "NO") << endl;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"io.output.change"
] | 949,990 | 949,991 | u653187094 | cpp |
p03150 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr << #x << "=" << x << endl;
int x[100001], a[100001], n, q, sum[100001], tmp;
vector<int> v;
int cf;
int main(void) {
string str;
cin >> str;
rep(i, str.size()) {
rep(j, str.size()) {
if (i >= j)
continue;
if (str.substr(0, i) + str.substr(j, str.size()) == "keyence") {
cout << "YES" << endl;
return 0;
}
}
}
cout << "NO" << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr << #x << "=" << x << endl;
int x[100001], a[100001], n, q, sum[100001], tmp;
vector<int> v;
int cf;
int main(void) {
string str;
cin >> str;
rep(i, str.size()) {
rep(j, str.size()) {
if (i > j)
continue;
// cout<<str.substr(0,i)+str.substr(j,str.size())<<endl;
if (str.substr(0, i) + str.substr(j, str.size()) == "keyence") {
cout << "YES" << endl;
return 0;
}
}
}
cout << "NO" << endl;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 950,002 | 950,003 | u001566280 | cpp |
p03156 | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a, b;
cin >> a >> b;
int c1, c2, c3;
for (int i = 0; i < n; i++) {
int p;
cin >> p;
if (p > b) {
c3++;
} else if (p > a) {
c2++;
} else {
c1++;
}
}
int ans = c1;
if (c2 < ans) {
ans = c2;
}
if (c3 < ans) {
ans = c3;
}
cout << ans << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a, b;
cin >> a >> b;
int c1 = 0, c2 = 0, c3 = 0;
for (int i = 0; i < n; i++) {
int p;
cin >> p;
if (p > b) {
c3++;
} else if (p > a) {
c2++;
} else {
c1++;
}
}
int ans = c1;
if (c2 < ans) {
ans = c2;
}
if (c3 < ans) {
ans = c3;
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.value.change"
] | 950,004 | 950,005 | u587665681 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
int i, N, A, B, tmp, P[3];
int main(void) {
cin >> N >> A >> B;
for (i = 0; i < N; i++) {
cin >> tmp;
if (tmp <= A)
P[0]++;
else if (tmp <= B)
P[1]++;
else
P[2]++;
}
sort(P, P + 2 * sizeof(int));
cout << P[0] << endl;
// cout <<min(P[0],min(P[1],P[2]))<<endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int i, N, A, B, tmp, P[3];
int main(void) {
cin >> N >> A >> B;
for (i = 0; i < N; i++) {
cin >> tmp;
if (tmp <= A)
P[0]++;
else if (tmp <= B)
P[1]++;
else
P[2]++;
}
sort(P, P + 3);
cout << P[0] << endl;
return 0;
}
| [
"literal.number.change",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 950,120 | 950,121 | u918808222 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
int i, N, A, B, tmp, P[3];
int main(void) {
cin >> N >> A >> B;
for (i = 0; i < N; i++) {
cin >> tmp;
if (tmp <= A)
P[0]++;
else if (tmp <= B)
P[1]++;
else
P[2]++;
}
sort(P, P + 2);
cout << P[0] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int i, N, A, B, tmp, P[3];
int main(void) {
cin >> N >> A >> B;
for (i = 0; i < N; i++) {
cin >> tmp;
if (tmp <= A)
P[0]++;
else if (tmp <= B)
P[1]++;
else
P[2]++;
}
sort(P, P + 3);
cout << P[0] << endl;
return 0;
}
| [
"literal.number.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 950,122 | 950,121 | u918808222 | cpp |
p03156 | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main() {
int n;
cin >> n;
int a, b;
cin >> a >> b;
int p[n];
int v1 = 0, v2 = 0, v3 = 0;
for (int i = 0; i < n; i++) {
cin >> p[i];
if (p[i] <= a) {
v1++;
} else if (a < p[i] <= b) {
v2++;
} else {
v3++;
}
}
int ans = min(v2, v3);
ans = min(ans, v1);
cout << ans << endl;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main() {
int n;
cin >> n;
int a, b;
cin >> a >> b;
int p[n];
int v1 = 0, v2 = 0, v3 = 0;
for (int i = 0; i < n; i++) {
cin >> p[i];
if (p[i] <= a) {
v1++;
} else if (a < p[i] && p[i] <= b) {
v2++;
} else {
v3++;
}
}
int ans = min(v2, v3);
ans = min(ans, v1);
cout << ans << endl;
}
| [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 950,126 | 950,127 | u342051078 | cpp |
p03156 | #include <iostream>
#include <string>
using namespace std;
bool is_one(int pi, int a) {
if (pi <= a)
return true;
return false;
}
bool is_two(int pi, int a, int b) {
if (pi >= a + 1 && pi <= b)
return true;
return false;
}
bool is_three(int pi, int b) {
if (pi >= b + 1)
return true;
return false;
}
int p[30];
int main() {
int n, a, b;
cin >> n;
cin >> a >> b;
for (int i = 0; i < n; ++i)
cin >> p[i];
int count1 = 0;
for (int i = 0; i < n; i++) {
if (is_one(p[i], a))
count1++;
}
int count2 = 0;
for (int i = 0; i < n; i++) {
if (is_two(p[i], a, b))
count2++;
}
int count3 = 0;
for (int i = 0; i < n; i++) {
if (is_three(p[i], a))
count3++;
}
int ret = min(count1, count2);
ret = min(ret, count3);
cout << ret << endl;
} | #include <iostream>
#include <string>
using namespace std;
bool is_one(int pi, int a) {
if (pi <= a)
return true;
return false;
}
bool is_two(int pi, int a, int b) {
if (pi >= a + 1 && pi <= b)
return true;
return false;
}
bool is_three(int pi, int b) {
if (pi >= b + 1)
return true;
return false;
}
int p[30];
int main() {
int n, a, b;
cin >> n;
cin >> a >> b;
for (int i = 0; i < n; ++i)
cin >> p[i];
int count1 = 0;
for (int i = 0; i < n; i++) {
if (is_one(p[i], a))
count1++;
}
int count2 = 0;
for (int i = 0; i < n; i++) {
if (is_two(p[i], a, b))
count2++;
}
int count3 = 0;
for (int i = 0; i < n; i++) {
if (is_three(p[i], b))
count3++;
}
int ret = min(count1, count2);
ret = min(ret, count3);
cout << ret << endl;
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 950,155 | 950,156 | u542506429 | cpp |
p03156 | #include <iostream>
#include <string>
using namespace std;
bool is_one(int pi, int a) {
if (pi <= a)
return true;
return false;
}
bool is_two(int pi, int a, int b) {
if (pi >= a + 1 && pi <= b)
return true;
return false;
}
bool is_three(int pi, int b) {
if (pi >= b + 1)
return true;
return false;
}
int p[30];
int main() {
int n, a, b;
cin >> n;
cin >> a >> b;
for (int i = 0; i < n; ++i)
cin >> p[i];
int count1 = 0;
for (int i = 0; i < n; i++) {
if (is_one(p[i], a))
count1++;
}
int count2 = 0;
for (int i = 0; i < n; i++) {
if (is_two(p[i], a, b))
count2++;
}
int count3 = 0;
for (int i = 0; i < n; i++) {
if (is_one(p[i], a))
count3++;
}
int ret = min(count1, count2);
ret = min(ret, count3);
cout << ret << endl;
} | #include <iostream>
#include <string>
using namespace std;
bool is_one(int pi, int a) {
if (pi <= a)
return true;
return false;
}
bool is_two(int pi, int a, int b) {
if (pi >= a + 1 && pi <= b)
return true;
return false;
}
bool is_three(int pi, int b) {
if (pi >= b + 1)
return true;
return false;
}
int p[30];
int main() {
int n, a, b;
cin >> n;
cin >> a >> b;
for (int i = 0; i < n; ++i)
cin >> p[i];
int count1 = 0;
for (int i = 0; i < n; i++) {
if (is_one(p[i], a))
count1++;
}
int count2 = 0;
for (int i = 0; i < n; i++) {
if (is_two(p[i], a, b))
count2++;
}
int count3 = 0;
for (int i = 0; i < n; i++) {
if (is_three(p[i], b))
count3++;
}
int ret = min(count1, count2);
ret = min(ret, count3);
cout << ret << endl;
} | [
"identifier.change",
"call.function.change",
"control_flow.branch.if.condition.change"
] | 950,157 | 950,156 | u542506429 | cpp |
p03156 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n, a, b, p[100], tempA = -1, tempA1 = -1, tempB = -1, ans;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> p[i];
}
sort(p, p + n);
for (int i = 0; i < n; i++) {
if (a >= p[i]) {
tempA = i;
}
if (a + 1 <= p[i] && b >= p[i]) {
tempA1 = i;
}
if (b + 1 < p[i]) {
tempB = i;
}
}
tempA++;
tempA1++;
tempB++;
if (tempA == 0 || tempA1 == 0 || tempA == tempA1 || tempA == tempB ||
tempA1 == tempB) {
cout << 0 << "\n";
return 0;
}
if (tempA < (tempA1 - tempA)) {
if ((tempB - tempA1) < tempA) {
ans = (tempB - tempA1);
} else {
ans = tempA;
}
} else {
if ((tempB - tempA1) < (tempA1 - tempA)) {
ans = (tempB - tempA1);
} else {
ans = (tempA1 - tempA);
}
}
cout << ans << "\n";
return 0;
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n, a, b, p[100], tempA = -1, tempA1 = -1, tempB = -1, ans;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> p[i];
}
sort(p, p + n);
for (int i = 0; i < n; i++) {
if (a >= p[i]) {
tempA = i;
}
if (a + 1 <= p[i] && b >= p[i]) {
tempA1 = i;
}
if (b + 1 < p[i]) {
tempB = i;
}
}
tempA++;
tempA1++;
tempB++;
if (tempA == 0 || tempA1 == 0 || tempB == 0 || tempA == tempA1 ||
tempA == tempB || tempA1 == tempB) {
cout << 0 << "\n";
return 0;
}
if (tempA < (tempA1 - tempA)) {
if ((tempB - tempA1) < tempA) {
ans = (tempB - tempA1);
} else {
ans = tempA;
}
} else {
if ((tempB - tempA1) < (tempA1 - tempA)) {
ans = (tempB - tempA1);
} else {
ans = (tempA1 - tempA);
}
}
cout << ans << "\n";
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 950,158 | 950,159 | u125051909 | cpp |
p03156 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N, A, B;
cin >> N;
cin >> A;
cin >> B;
int p[N - 1];
for (int i = 0; i <= N - 1; i++) {
cin >> p[i];
}
int count1 = 0, count2 = 0, count3 = 0;
for (auto x : p) {
if (x <= A) {
count1++;
}
if (A + 1 <= x && x <= B) {
count2++;
}
if (x >= B + 1) {
count3++;
}
}
cout << min({count1, count2, count3}) << endl;
}
| #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N, A, B;
cin >> N;
cin >> A;
cin >> B;
int p[N];
for (int i = 0; i <= N - 1; i++) {
cin >> p[i];
}
int count1 = 0, count2 = 0, count3 = 0;
for (auto x : p) {
if (x <= A) {
count1++;
}
if (A + 1 <= x && x <= B) {
count2++;
}
if (x >= B + 1) {
count3++;
}
}
cout << min({count1, count2, count3}) << endl;
} | [
"expression.operation.binary.remove"
] | 950,160 | 950,161 | u938418553 | cpp |
p03156 | #include <iostream>
using namespace std;
int min(int a, int b) {
if (a <= b) {
return a;
} else {
return b;
}
}
int main(void) {
int N;
int A, B;
cin >> N >> A >> B;
int P[N];
for (int i = 0; i < N; i++) {
cin >> P[i];
}
int g1 = 0;
int g2 = 0;
int g3 = 0;
for (int i = 0; i < N; i++) {
if (P[i] <= A) {
g1++;
} else if (A < P[i] && P[i] <= B) {
g2++;
} else {
g3++;
}
}
int MIN = min(g1, max(g2, g3));
cout << MIN << endl;
} | #include <iostream>
using namespace std;
int min(int a, int b) {
if (a <= b) {
return a;
} else {
return b;
}
}
int main(void) {
int N;
int A, B;
cin >> N >> A >> B;
int P[N];
for (int i = 0; i < N; i++) {
cin >> P[i];
}
int g1 = 0;
int g2 = 0;
int g3 = 0;
for (int i = 0; i < N; i++) {
if (P[i] <= A) {
g1++;
} else if (A < P[i] && P[i] <= B) {
g2++;
} else {
g3++;
}
}
int MIN = min(g1, min(g2, g3));
cout << MIN << endl;
} | [
"misc.opposites",
"identifier.change",
"call.function.change",
"call.arguments.change"
] | 950,162 | 950,163 | u790171360 | cpp |
p03156 | #include <cmath>
#include <iostream>
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
int less_or_eq_A = 0;
int more_A_less_eq_B = 0;
int more_B = 0;
for (int i = 0; i < N; i++) {
int p;
cin >> p;
if (p <= A) {
less_or_eq_A++;
}
if (p <= B) {
more_A_less_eq_B++;
} else {
more_B++;
}
}
cout << min(min(less_or_eq_A, more_A_less_eq_B), more_B) << endl;
return 0;
}
| #include <cmath>
#include <iostream>
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
int less_or_eq_A = 0;
int more_A_less_eq_B = 0;
int more_B = 0;
for (int i = 0; i < N; i++) {
int p;
cin >> p;
if (p <= A) {
less_or_eq_A++;
} else if (p <= B) {
more_A_less_eq_B++;
} else {
more_B++;
}
}
cout << min(min(less_or_eq_A, more_A_less_eq_B), more_B) << endl;
return 0;
} | [
"control_flow.branch.else_if.replace.add",
"control_flow.branch.if.replace.remove"
] | 950,164 | 950,165 | u389009751 | cpp |
p03156 | #include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int main() {
int ans = 0;
int n, a, b;
cin >> n >> a >> b;
vector<int> p(n);
for (int i = 0; i < n; ++i) {
cin >> p[i];
}
vector<int> pn(3, 0);
for (int i = 0; i < n; ++i) {
if (p[i] <= a) {
pn[0]++;
}
if (a < p[i] || p[i] <= b) {
pn[1]++;
}
if (b < p[i]) {
pn[2]++;
}
}
sort(pn.begin(), pn.end());
ans = pn[0];
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int main() {
int ans = 0;
int n, a, b;
cin >> n >> a >> b;
vector<int> p(n);
for (int i = 0; i < n; ++i) {
cin >> p[i];
}
vector<int> pn(3, 0);
for (int i = 0; i < n; ++i) {
if (p[i] <= a) {
pn[0]++;
}
if (a < p[i] && p[i] <= b) {
pn[1]++;
}
if (b < p[i]) {
pn[2]++;
}
}
sort(pn.begin(), pn.end());
ans = pn[0];
cout << ans << endl;
return 0;
} | [
"misc.opposites",
"control_flow.branch.if.condition.change"
] | 950,166 | 950,167 | u833117432 | cpp |
p03156 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, a, b, counta = 0, countb = 0, countc = 0;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
int op;
cin >> op;
if (op >= b + 1)
countc++;
if (op >= a + 1 && op <= b)
countb++;
else if (op <= a)
counta++;
}
if (counta <= countb && counta <= countc)
cout << counta << endl;
else if (countb <= counta && countb <= countc)
cout << countb << endl;
else if (countc <= countb && countc <= counta)
cout << counta << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, a, b, counta = 0, countb = 0, countc = 0;
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
int op;
cin >> op;
if (op >= b + 1)
countc++;
if (op >= a + 1 && op <= b)
countb++;
else if (op <= a)
counta++;
}
if (counta <= countb && counta <= countc)
cout << counta << endl;
else if (countb <= counta && countb <= countc)
cout << countb << endl;
else if (countc <= countb && countc <= counta)
cout << countc << endl;
return 0;
} | [
"identifier.change",
"io.output.change"
] | 950,169 | 950,170 | u382073340 | cpp |
p03156 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
vector<int> P(N);
for (auto &x : P) {
cin >> x;
}
int n1 = count_if(P.begin(), P.end(), [&](auto x) { return x <= A; });
int n2 = count_if(P.begin(), P.end(),
[&](auto x) { return x <= A + 1 && x <= B; });
int n3 = count_if(P.begin(), P.end(), [&](auto x) { return B + 1 <= x; });
int ans = min({n1, n2, n3});
cout << ans << endl;
}
| #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
vector<int> P(N);
for (auto &x : P) {
cin >> x;
}
int n1 = count_if(P.begin(), P.end(), [&](auto x) { return x <= A; });
int n2 = count_if(P.begin(), P.end(),
[&](auto x) { return A + 1 <= x && x <= B; });
int n3 = count_if(P.begin(), P.end(), [&](auto x) { return B + 1 <= x; });
int ans = min({n1, n2, n3});
cout << ans << endl;
}
| [
"expression.operation.binary.remove"
] | 950,183 | 950,184 | u036411476 | cpp |
p03156 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
int n_of_1, n_of_2, n_of_3;
int p;
while (cin >> p) {
if (p <= A)
++n_of_1;
else if (p <= B)
++n_of_2;
else
++n_of_3;
}
int res = min(n_of_1, n_of_2);
res = min(res, n_of_3);
cout << res << endl;
return 0;
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
int n_of_1 = 0, n_of_2 = 0, n_of_3 = 0;
int p;
while (cin >> p) {
if (p <= A)
++n_of_1;
else if (p <= B)
++n_of_2;
else
++n_of_3;
}
int res = min(n_of_1, n_of_2);
res = min(res, n_of_3);
cout << res << endl;
return 0;
} | [
"variable_declaration.value.change"
] | 950,185 | 950,186 | u067267922 | cpp |
p03156 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
int n_of_1, n_of_2, n_of_3;
int p;
while (cin >> p) {
if (p <= A)
++n_of_1;
else if (A + 1 <= p && p <= B)
++n_of_2;
else if (B + 1 <= p)
++n_of_3;
}
int res = 100;
res = min(res, n_of_1);
res = min(res, n_of_2);
res = min(res, n_of_3);
cout << res << endl;
return 0;
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
int n_of_1 = 0, n_of_2 = 0, n_of_3 = 0;
int p;
while (cin >> p) {
if (p <= A)
++n_of_1;
else if (A + 1 <= p && p <= B)
++n_of_2;
else if (B + 1 <= p)
++n_of_3;
}
int res = 100;
res = min(res, n_of_1);
res = min(res, n_of_2);
res = min(res, n_of_3);
cout << res << endl;
return 0;
} | [
"variable_declaration.value.change"
] | 950,187 | 950,188 | u067267922 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e4;
ll arry[N];
int main() {
ll n;
cin >> n;
ll a, b;
cin >> a >> b;
ll first[N] = {0}, second[N] = {0}, third[N] = {0};
for (int i = 0; i < n; i++) {
ll x;
cin >> x;
if (x <= a) {
first[++first[0]] = x;
} else if (x > a + 1 && x <= b) {
second[++second[0]] = x;
} else {
third[++third[0]] = x;
}
}
ll cmp = 0;
// cout<<first[0]<<" "<<second[0]<<" "<<third[0]<<endl;
cmp = first[0];
if (second[0] < cmp) {
cmp = second[0];
}
if (third[0] < cmp) {
cmp = third[0];
}
cout << cmp << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e4;
ll arry[N];
int main() {
ll n;
cin >> n;
ll a, b;
cin >> a >> b;
ll first[N] = {0}, second[N] = {0}, third[N] = {0};
for (int i = 0; i < n; i++) {
ll x;
cin >> x;
if (x <= a) {
first[++first[0]] = x;
} else if (x >= a + 1 && x <= b) {
second[++second[0]] = x;
} else {
third[++third[0]] = x;
}
}
ll cmp = 0;
// cout<<first[0]<<" "<<second[0]<<" "<<third[0]<<endl;
cmp = first[0];
if (second[0] < cmp) {
cmp = second[0];
}
if (third[0] < cmp) {
cmp = third[0];
}
cout << cmp << endl;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 950,192 | 950,193 | u624688258 | cpp |
p03156 | #include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int nx[] = {0, 1, 0, -1};
int ny[] = {0, 1, 0, -1};
//*****************************************
int n, a, b, tmp, ans;
int main(void) {
scanf("%d", &n);
scanf("%d", &a);
scanf("%d", &b);
vector<int> scores(3, 0);
for (int i = 0; i < n; i++) {
scanf("%d", &tmp);
if (tmp <= a) {
scores[0]++;
} else if (tmp < b) {
scores[1]++;
} else {
scores[2]++;
}
}
int ans = *std::min_element(scores.begin(), scores.end());
printf("%d", ans);
return 0;
}
| #include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int nx[] = {0, 1, 0, -1};
int ny[] = {0, 1, 0, -1};
//*****************************************
int n, a, b, tmp, ans;
int main(void) {
scanf("%d", &n);
scanf("%d", &a);
scanf("%d", &b);
vector<int> scores(3, 0);
for (int i = 0; i < n; i++) {
scanf("%d", &tmp);
if (tmp <= a) {
scores[0]++;
} else if (tmp <= b) {
scores[1]++;
} else {
scores[2]++;
}
}
int ans = *std::min_element(scores.begin(), scores.end());
printf("%d", ans);
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 950,198 | 950,199 | u113497060 | cpp |
p03156 | #include <algorithm>
#include <array>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<ll> vec;
int main(int argc, char const *argv[]) {
ll N, A, B;
cin >> N;
cin >> A >> B;
vector<ll> p(N);
for (ll i = 0; i < N; i++) {
cin >> p[i];
}
ll size = p.size();
sort(p.begin(), p.end());
ll cnt = 0;
for (cnt = 0; cnt < size; cnt++) {
bool flag = true;
for (ll i = 0; i <= p.size(); i++) {
if (i == p.size()) {
flag = false;
break;
}
if (p[i] <= A) {
p.erase(p.begin() + i);
break;
}
}
if (flag) {
for (ll i = 0; i < p.size(); i++) {
if (i == p.size()) {
flag = false;
break;
}
if (A + 1 <= p[i] && p[i] <= B) {
p.erase(p.begin() + i);
break;
}
}
}
if (flag) {
for (ll i = 0; i < p.size(); i++) {
if (i == p.size()) {
flag = false;
break;
}
if (B + 1 <= p[i]) {
p.erase(p.begin() + i);
break;
}
}
}
if (!flag)
break;
}
cout << cnt << endl;
} | #include <algorithm>
#include <array>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<ll> vec;
int main(int argc, char const *argv[]) {
ll N, A, B;
cin >> N;
cin >> A >> B;
vector<ll> p(N);
for (ll i = 0; i < N; i++) {
cin >> p[i];
}
ll size = p.size();
sort(p.begin(), p.end());
ll cnt = 0;
for (cnt = 0; cnt < size; cnt++) {
bool flag = true;
for (ll i = 0; i <= p.size(); i++) {
if (i == p.size()) {
flag = false;
break;
}
if (p[i] <= A) {
p.erase(p.begin() + i);
break;
}
}
if (flag) {
for (ll i = 0; i <= p.size(); i++) {
if (i == p.size()) {
flag = false;
break;
}
if (A + 1 <= p[i] && p[i] <= B) {
p.erase(p.begin() + i);
break;
}
}
}
if (flag) {
for (ll i = 0; i <= p.size(); i++) {
if (i == p.size()) {
flag = false;
break;
}
if (B + 1 <= p[i]) {
p.erase(p.begin() + i);
break;
}
}
}
if (!flag)
break;
}
cout << cnt << endl;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 950,210 | 950,211 | u324139341 | cpp |
p03156 | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, a, b;
cin >> n >> a >> b;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
int small = 0;
int middle = 0;
int large = 0;
for (int i = 0; i < n; i++) {
if (v[n] <= a) {
small++;
} else if (v[n] > a && v[n] <= b) {
middle++;
} else {
large++;
}
}
int minimum = min({small, middle, large});
cout << minimum;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, a, b;
cin >> n >> a >> b;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
int small = 0;
int middle = 0;
int large = 0;
for (int i = 0; i < n; i++) {
if (v[i] <= a) {
small++;
} else if (v[i] > a && v[i] <= b) {
middle++;
} else {
large++;
}
}
int minimum = min({small, middle, large});
cout << minimum;
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 950,223 | 950,224 | u887066391 | cpp |
p03157 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define all(vec) vec.begin(), vec.end()
#define P pair<int, int>
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int kai(int x, int y) {
int res = 1;
for (int i = x - y + 1; i <= x; i++) {
res *= i;
res %= mod;
}
return res;
}
int mod_pow(int x, int y, int m) {
int res = 1;
while (y > 0) {
if (y & 1) {
res = res * x % m;
}
x = x * x % m;
y >>= 1;
}
return res;
}
int comb(int x, int y) {
if (y > x)
return 0;
return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int h, w;
string s[410];
bool bl[410][410];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
long long ans;
void bfs(int x, int y) {
queue<P> que;
que.push({x, y});
bl[x][y] = true;
int cnt1 = 0, cnt2 = 0;
if (s[x][y] == '#')
cnt1++;
else
cnt2++;
while (!que.empty()) {
P p = que.front();
que.pop();
for (int i = 0; i < 4; i++) {
int tx = p.first + dx[i], ty = p.second + dy[i];
if (tx < 0 || h <= tx || ty < 0 || w <= ty ||
s[p.first][p.second] == s[tx][ty] || bl[tx][ty])
continue;
if (s[tx][ty] == '#')
cnt1++;
else
cnt2++;
bl[tx][ty] = true;
que.push({tx, ty});
}
}
ans += cnt1 * cnt2;
}
signed main() {
cin >> h >> w;
for (int i = 0; i < h; i++)
cin >> s[i];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (!bl[i][j])
bfs(i, j);
}
}
cout << ans << endl;
}
| #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define all(vec) vec.begin(), vec.end()
#define P pair<int, int>
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int kai(int x, int y) {
int res = 1;
for (int i = x - y + 1; i <= x; i++) {
res *= i;
res %= mod;
}
return res;
}
int mod_pow(int x, int y, int m) {
int res = 1;
while (y > 0) {
if (y & 1) {
res = res * x % m;
}
x = x * x % m;
y >>= 1;
}
return res;
}
int comb(int x, int y) {
if (y > x)
return 0;
return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int h, w;
string s[410];
bool bl[410][410];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
long long ans;
void bfs(int x, int y) {
queue<P> que;
que.push({x, y});
bl[x][y] = true;
long long cnt1 = 0, cnt2 = 0;
if (s[x][y] == '#')
cnt1++;
else
cnt2++;
while (!que.empty()) {
P p = que.front();
que.pop();
for (int i = 0; i < 4; i++) {
int tx = p.first + dx[i], ty = p.second + dy[i];
if (tx < 0 || h <= tx || ty < 0 || w <= ty ||
s[p.first][p.second] == s[tx][ty] || bl[tx][ty])
continue;
if (s[tx][ty] == '#')
cnt1++;
else
cnt2++;
bl[tx][ty] = true;
que.push({tx, ty});
}
}
ans += cnt1 * cnt2;
}
signed main() {
cin >> h >> w;
for (int i = 0; i < h; i++)
cin >> s[i];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (!bl[i][j])
bfs(i, j);
}
}
cout << ans << endl;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 950,370 | 950,371 | u277153875 | cpp |
p03157 | #include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <queue>
#include <vector>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll, int> P;
int H, W;
string S[410];
int color[410][410];
int now = 1;
int dis[161000];
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
void dfs(int y, int x) {
// cout<<now<<" "<<y<<" "<<x<<endl;
for (int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if (nx >= 0 && nx < W && ny >= 0 && ny < H && color[ny][nx] == -1 &&
S[y][x] != S[ny][nx]) {
if (S[ny][nx] == '#') {
dis[now]++;
color[ny][nx] = 0;
dfs(ny, nx);
} else {
color[ny][nx] = now;
dfs(ny, nx);
}
}
}
}
int main() {
for (int i = 0; i < 410; i++) {
for (int j = 0; j < 410; j++)
color[i][j] = -1;
}
int ans = 0;
cin >> H >> W;
for (int i = 0; i < H; i++) {
cin >> S[i];
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (S[i][j] == '#' && color[i][j] == -1) {
color[i][j] = 0;
dis[now]++;
dfs(i, j);
now++;
}
}
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
// cout<<color[i][j]<<endl;
ans += dis[color[i][j]];
}
}
cout << ans << endl;
}
| #include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <queue>
#include <vector>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll, int> P;
int H, W;
string S[410];
int color[410][410];
int now = 1;
ll dis[161000];
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
void dfs(int y, int x) {
// cout<<now<<" "<<y<<" "<<x<<endl;
for (int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if (nx >= 0 && nx < W && ny >= 0 && ny < H && color[ny][nx] == -1 &&
S[y][x] != S[ny][nx]) {
if (S[ny][nx] == '#') {
dis[now]++;
color[ny][nx] = 0;
dfs(ny, nx);
} else {
color[ny][nx] = now;
dfs(ny, nx);
}
}
}
}
int main() {
for (int i = 0; i < 410; i++) {
for (int j = 0; j < 410; j++)
color[i][j] = -1;
}
ll ans = 0;
cin >> H >> W;
for (int i = 0; i < H; i++) {
cin >> S[i];
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (S[i][j] == '#' && color[i][j] == -1) {
color[i][j] = 0;
dis[now]++;
dfs(i, j);
now++;
}
}
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
// cout<<color[i][j]<<endl;
ans += dis[color[i][j]];
}
}
cout << ans << endl;
}
| [
"variable_declaration.type.change"
] | 950,583 | 950,584 | u591914971 | cpp |
p03157 | // MLEが動かない
//セグフォは関数内で要素のでかい配列を定義しているから
// todo idef DEBUGで、境界チェック付きのvectorを作りたい
// http://marycore.jp/prog/cpp/class-extension-methods/
//現状ifdef DEBUG が何故か動かないので出来ない
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
struct initon {
initon() {
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(16);
};
} hoee;
namespace std {
template <> class hash<std::pair<signed, signed>> {
public:
size_t operator()(const std::pair<signed, signed> &x) const {
return hash<ll>()(((ll)x.first << 32) + x.second);
}
};
template <> class hash<std::pair<ll, ll>> {
public:
size_t operator()(const std::pair<ll, ll> &x) const {
return hash<ll>()(((ll)x.first << 32) + x.second);
}
};
} // namespace std
struct Tri {
int f, s, t;
Tri() { f = -1, s = -1, t = -1; }
Tri(int f, int s, int t) : f(f), s(s), t(t) {}
bool operator<(const Tri &r) const {
return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t;
// return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 大きい順
}
bool operator>(const Tri &r) const {
return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t;
// return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 小さい順
}
int operator[](int i) {
assert(i < 3);
switch (i) {
case 0:
return f;
break;
case 1:
return s;
break;
default:
return t;
break;
}
}
};
//別名
#define ull unsigned long long
#define vec vector
#define con continue
#define bre break
#define brk break
#define is ==
#define eq ==
#define no !=
#define ne !=
#define dif !=
#define df !=
#define rs resize
#define PQ priority_queue<ll, vector<ll>, greater<ll>>
using vi = vector<int>;
#define vvi(a, b, c) vec<vi> a(b, vi(c))
using vb = vector<bool>;
#define vvb(a, b, c) vec<vb> a(b, vb(c))
using vs = vector<string>;
#define vvs(a, b, c) vec<vs> a(b, vs(c))
using vl = vector<ll>;
#define vvl(a, b, c) vec<vl> a(b, vl(c))
using vd = vector<double>;
#define vvd(a, b, c) vec<vd> a(b, vd(c))
#define v3i(a, b, c, d) vector<vector<vi>> a(b, vector<vi>(c, vi(d)))
#define v3d(a, b, c, d) vector<vector<vd>> a(b, vector<vd>(c, vd(d)))
#define v3m(a, b, c, d) vector<vector<vm>> a(b, vector<vm>(c, vm(d)))
using vc = vector<char>;
#define vvc(a, b, c) vec<vc> a(b, vc(c))
using P = pair<int, int>;
// using T = tuple<int, int, int>;
using vp = vector<P>;
#define vvp(a, b, c) vec<vp> a(b, vp(c))
using vt = vector<Tri>;
#define vvt(a, b, c) vec<vt> a(b, vt(c))
using dou = double;
using itn = int;
using str = string;
using bo = bool;
#define uset unordered_set
#define mset multiset
#define umap unordered_map
#define mmap multimap
#define F first
#define S second
//定数
#define k4 10101
#define k5 101010
#define k6 1010101
#define k7 10101010
const int INF = (int)1e9 + 100;
const ll LINF = (ll)1e18 + 100;
const double EPS = 1e-9;
const int y4[] = {-1, 1, 0, 0};
const int x4[] = {0, 0, -1, 1};
const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1};
//配列
#define sz(a) (sizeof(a) / sizeof(a[0]))
//コンテナ
#define mp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
template <class T> T pop(set<T> &set) {
T res = *set.begin();
set.erase(set.find(res));
return res;
}
template <class T> T pop(mset<T> &set) {
T res = *set.begin();
set.erase(set.find(res));
return res;
}
template <class T> T popBack(set<T> &set) {
T res = *set.rbegin();
set.erase(set.find(res));
return res;
}
template <class T> T popBack(mset<T> &set) {
T res = *set.rbegin();
set.erase(set.find(res));
return res;
}
template <class T> inline void sort(vector<T> &a) { sort(a.begin(), a.end()); };
template <class T> inline void rsort(vector<T> &a) {
sort(a.begin(), a.end(), greater<T>());
};
template <class T> inline void sort(vector<T> &a, int len) {
sort(a.begin(), a.begin() + len);
};
template <class T> inline void rsort(vector<T> &a, int len) {
sort(a.begin(), a.begin() + len, greater<T>());
};
//繰り返し
#define _overloadrep(_1, _2, _3, name, ...) name
#define _rep(i, n) for (int i = 0; i < n; i++)
#define repi(i, m, n) for (int i = m; i < n; i++)
#define rep(...) _overloadrep(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rer(i, n) for (int i = n; i >= 0; i--)
#define reri(i, m, n) for (int i = m; i >= n; i--)
#define rer(...) _overloadrep(__VA_ARGS__, reri, _rer, )(__VA_ARGS__)
#define fora(a, b) for (auto &&a : b)
#define forr(a, b) for_each(map.rbegin(),map.rend(),[](auto&& a)
#define rea(a, b) for (auto &&a : b)
#define repa(a, b) for (auto &&a : b)
template <typename A, size_t N, typename T> void fill(A (&a)[N], const T &v) {
rep(i, N) a[i] = v;
}
template <typename A, size_t N, size_t O, typename T>
void fill(A (&a)[N][O], const T &v) {
rep(i, N) rep(j, O) a[i][j] = v;
}
template <typename A, size_t N, size_t O, size_t P, typename T>
void fill(A (&a)[N][O][P], const T &v) {
rep(i, N) rep(j, O) rep(k, P) a[i][j][k] = v;
}
template <typename A, size_t N, size_t O, size_t P, size_t Q, typename T>
void fill(A (&a)[N][O][P][Q], const T &v) {
rep(i, N) rep(j, O) rep(k, P) rep(l, Q) a[i][j][k][l] = v;
}
template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R,
typename T>
void fill(A (&a)[N][O][P][Q][R], const T &v) {
rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) a[i][j][k][l][m] = v;
}
template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R,
size_t S, typename T>
void fill(A (&a)[N][O][P][Q][R][S], const T &v) {
rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) rep(n, S)
a[i][j][k][l][m][n] = v;
}
template <class T, class U> void fill(vector<T> &a, U v) {
rep(i, a.size()) a[i] = v;
}
template <class T, class U> void fill(vector<vector<T>> &a, U v) {
rep(i, a.size()) rep(j, a[0].size()) a[i][j] = v;
}
template <class T, class U> void fill(vector<vector<vector<T>>> &a, U v) {
rep(i, a.size()) rep(j, a[0].size()) rep(k, a[0][0].size()) a[i][j][k] = v;
}
#define arcpy(a, b) memcpy(a, b, sizeof(b))
//入力
template <typename T = int> T in() {
T x;
cin >> x;
return (x);
}
string sin() { return in<string>(); }
double din() { return in<double>(); }
ll lin() { return in<ll>(); }
#define na(a, n) rep(i, n) cin >> a[i];
#define nad(a, n) rep(i, n) cin >> a[i], a[i]--;
#define na3(a, b, c, n) rep(i, n) cin >> a[i] >> b[i] >> c[i];
#define add2(a, b, n) rep(i, n) a.pb(in()), b.pb(in());
#define add2d(a, b, n) rep(i, n) a.pb(in() - 1), b.pb(in() - 1);
#define add3(a, b, c, n) rep(i, n) a.pb(in()), b.pb(in()), c.pb(in());
#define add3d(a, b, c, n) rep(i, n) a.pb(in() - 1), b.pb(in() - 1), c.pb(in());
#define na2(a, b, n) rep(i, n) cin >> a[i] >> b[i];
#define nt(a, h, w) rep(hi, h) rep(wi, w) cin >> a[hi][wi];
#define ntd(a, h, w) rep(hi, h) rep(wi, w) cin >> a[hi][wi], a[hi][wi]--;
#define ntp(a, h, w) \
fill(a, '#'); \
rep(hi, 1, h + 1) rep(wi, 1, w + 1) cin >> a[hi][wi];
#define addn(a, n) \
a.resize(n); \
na(a, n);
#define addnd(a, n) \
a.resize(n); \
na(a, n); \
rep(i, n) a[i]--;
//出力
template <class T> void out(vector<T> x) {
for (auto &&v : x)
cout << v << " ";
cout << "" << endl;
}
template <class T> void out(T x) {
if (typeid(x) == typeid(double))
cout << fixed << setprecision(10) << x << endl;
else
cout << x << endl;
}
//デバッグ
#define debug(x) \
cerr << x << " " \
<< "(L:" << __LINE__ << ")" << '\n';
// 境界チェック付きvector
namespace std_vector_bounds_checking {
using namespace std;
template <class T, class A = std::allocator<T>>
struct vector : std::vector<T, A> {
using std::vector<T, A>::vector;
typename std::vector<T>::reference
operator[](typename std::vector<T>::size_type n) {
return this->at(n);
}
};
} // namespace std_vector_bounds_checking
//よく使うクラス、構造体
class UnionFind {
public:
vi par, rank, sizes;
int n, trees;
UnionFind(int n) : n(n), trees(n) {
par.resize(n), rank.resize(n), sizes.resize(n);
rep(i, n) par[i] = i, sizes[i] = 1;
}
int root(int x) {
if (par[x] == x)
return x;
else
return par[x] = root(par[x]);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return;
if (rank[x] < rank[y])
swap(x, y);
trees--;
par[y] = x;
sizes[x] += sizes[y];
if (rank[x] == rank[y])
rank[x]++;
}
bool same(int x, int y) { return root(x) == root(y); }
int size(int x) { return sizes[root(x)]; }
//順不同 umapなので
vec<vi> sets() {
vec<vi> res(trees);
umap<int, vi> map;
rep(i, n) map[root(i)].push_back(i);
int i = 0;
for (auto &&p : map) {
int r = p.F;
res[i].push_back(r);
for (auto &&v : p.S) {
if (r == v)
continue;
res[i].push_back(v);
}
i++;
}
return res;
}
};
// MOD関連
ll MOD = (int)1e9 + 7;
int mpow(int v, ll a) {
ll x = v, n = a, res = 1;
while (n) {
if (n & 1)
res = (res * x) % MOD;
x = (x * x) % MOD;
n >>= 1;
}
return res;
}
class mint {
private:
ll v;
public:
static ll mod(ll a) { return (a % MOD + MOD) % MOD; }
mint(ll a = 0) { this->v = mod(a); };
mint(const mint &a) { v = a.v; }
mint operator+(const mint &a) { return mint(v + a.v); }
mint operator+(const ll a) { return mint(v + a % MOD); }
mint operator+(const signed a) { return mint(v + a % MOD); }
friend mint operator+(const ll a, const mint &b) {
return mint(a % MOD + b.v);
}
void operator+=(const mint &a) { v = (v + a.v) % MOD; }
void operator+=(const ll a) { v = mod(v + a % MOD); }
void operator+=(const signed a) { v = mod(v + a % MOD); }
friend void operator+=(ll &a, const mint &b) { a = mod(a % MOD + b.v); }
mint operator-(const mint &a) { return mint(v - a.v); }
mint operator-(const ll a) { return mint(v - a % MOD); }
mint operator-(const signed a) { return mint(v - a % MOD); }
friend mint operator-(const ll a, const mint &b) {
return mint(a % MOD - b.v);
}
void operator-=(const mint &a) { v = mod(v - a.v); }
void operator-=(const ll a) { v = mod(v - a % MOD); }
void operator-=(const signed a) { v = mod(v - a % MOD); }
friend void operator-=(ll &a, const mint &b) { a = mod(a % MOD - b.v); }
mint operator*(const mint &a) { return mint(v * a.v); }
mint operator*(const ll a) { return mint(v * (a % MOD)); }
mint operator*(const signed a) { return mint(v * (a % MOD)); }
friend mint operator*(const ll a, const mint &b) {
return mint(a % MOD * b.v);
}
void operator*=(const mint &a) { v = (v * a.v) % MOD; }
void operator*=(const ll a) { v = mod(v * (a % MOD)); }
void operator*=(const signed a) { v = mod(v * (a % MOD)); }
friend void operator*=(ll &a, const mint &b) { a = mod(a % MOD * b.v); }
mint operator/(const mint &a);
mint operator/(const ll a);
mint operator/(const signed a);
friend mint operator/(const ll a, const mint &b);
void operator/=(const mint &a);
void operator/=(const ll a);
void operator/=(const signed a);
friend void operator/=(ll &a, const mint &b);
mint operator^(const mint &a) { return mpow(v, a.v); };
mint operator^(const ll a) { return mpow(v, a); };
mint operator^(const signed a) { return mpow(v, a); };
friend mint operator^(const ll a, const mint &b) { return mpow(a, b.v); };
void operator^=(const mint &a) { v = mpow(v, a.v); }
void operator^=(const ll a) { v = mpow(v, a); }
void operator^=(const signed a) { v = mpow(v, a); }
//単項演算子
mint operator+() { return *this; }
mint operator++() {
v++;
return *this;
}
mint operator++(signed d) {
mint res = *this;
v++;
return res;
}
mint operator-() { return operator*(-1); }
mint operator--() {
v++;
return *this;
}
void operator--(signed d) {
mint res = *this;
v++;
}
bool operator==(mint &a) { return v == a.v; }
bool operator==(signed a) { return v == a; }
friend bool operator==(signed a, mint &b) { return a == b.v; }
bool operator!=(mint &a) { return v != a.v; }
bool operator!=(signed a) { return v != a; }
friend bool operator!=(signed a, mint &b) { return a != b.v; }
operator int() { return v; }
};
const int setModMax = 510000;
mint fac[setModMax], finv[setModMax], inv[setModMax];
void setMod() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < setModMax; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
mint minv(ll a) {
if (fac[0] == 0)
setMod();
if (a < setModMax)
return inv[a];
a %= MOD;
ll b = MOD, x = 1, y = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
x -= t * y;
swap(x, y);
}
return (x % MOD + MOD) % MOD;
}
mint mint::operator/(const mint &a) { return mint(v * minv(a.v)); }
mint mint::operator/(const ll a) { return mint(v * minv(a)); }
mint mint::operator/(const signed a) { return mint(v * minv(a)); }
mint operator/(const ll a, const mint &b) { return mint(a % MOD * minv(b.v)); }
void mint::operator/=(const mint &a) { v = (v * minv(a.v)) % MOD; }
void mint::operator/=(const ll a) { v = mod(v * minv(a)); }
void mint::operator/=(const signed a) { v = mod(v * minv(a)); }
void operator/=(ll &a, const mint &b) { a = mint::mod(a % MOD * minv(b.v)); }
using vm = vector<mint>;
#define vvm(a, b, c) vec<vm> a(b, vm(c))
bool isPrime[4010101];
vi primes;
void setPrime() {
fill(isPrime, true);
isPrime[0] = isPrime[1] = false;
for (int i = 2; i <= sqrt(sz(isPrime)) + 5; ++i) {
if (!isPrime[i])
continue;
for (int j = 2; i * j < sz(isPrime); ++j) {
isPrime[i * j] = false;
}
}
rep(i, sz(isPrime)) if (isPrime[i]) primes.pb(i);
}
mint com(ll n, ll r) {
if (n < r || n < 0 || r < 0)
return 0;
if (fac[0] == 0)
setMod();
return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
//便利関数
void OLE() {
string a = "a";
rep(i, 30) a += a;
rep(i, 1 << 17) cout << a << endl;
cout << "OLE 出力長制限超過" << endl;
exit(0);
}
void TLE() {
int a = 1;
while (a)
cout << a << endl;
}
void RE() {
int a = 1 / (x4[0] / MOD);
cout << a << endl;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
bool equal(double a, double b) { return fabs(a - b) < EPS; }
ll reverse(ll a) {
ll res = 0;
while (a) {
res *= 10;
res += a % 10;
a /= 10;
}
return res;
}
ll ceil(ll a, ll b) {
if (b == 0) {
OLE();
return -1;
} else
return (a + b - 1) / b;
}
ll sqrt(ll a) {
if (a < 0)
OLE();
ll res = (ll)std::sqrt(a);
while (res * res < a)
res++;
return res;
}
double log(double e, double x) { return log(x) / log(e); }
ll sig(ll t) { return (1 + t) * t / 2; }
ll sig(ll s, ll t) { return (s + t) * (t - s + 1) / 2; }
vi divisors(int v) {
vi res;
for (int i = 1; i <= sqrt(v); ++i) {
if (v % i == 0) {
res.pb(i);
if (i != v / i)
res.pb(v / i);
}
}
return res;
}
vi factorization(int v) {
int tv = v;
vi res;
if (!isPrime[2])
setPrime();
for (auto &&p : primes) {
if (v % p == 0)
res.push_back(p);
while (v % p == 0) {
v /= p;
}
if (v == 1 || p * p > tv)
break;
}
if (v > 1)
res.pb(v);
return res;
}
unordered_map<int, int> factorizationMap(int v) {
int tv = v;
unordered_map<int, int> res;
if (!isPrime[2])
setPrime();
for (auto &&p : primes) {
while (v % p == 0) {
res[p]++;
v /= p;
}
if (v == 1 || p * p > tv)
break;
}
if (v > 1)
res[v]++;
return res;
}
int get(int a, int keta) {
a /= (int)pow(10, keta);
return a % 10;
}
//変換系
template <class T, class U> vector<U> keys(map<T, U> a) {
vector<U> res;
for (auto &&k : a)
res.pb(k.F);
return res;
}
template <class T, class U> vector<U> keys(umap<T, U> a) {
vector<U> res;
for (auto &&k : a)
res.pb(k.F);
return res;
}
template <class T, class U> vector<T> values(map<T, U> a) {
vector<T> res;
for (auto &&k : a)
res.pb(k.S);
return res;
}
template <class T, class U> vector<T> values(umap<T, U> a) {
vector<T> res;
for (auto &&k : a)
res.pb(k.S);
return res;
}
vi list(int a) {
vi res;
while (a) {
res.insert(res.begin(), a % 10);
a /= 10;
}
return res;
}
template <class T, class U> bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T, class U> bool chmin(T &a, const U &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template <class T> T min(T a, signed b) { return a < b ? a : b; }
template <class T> T max(T a, signed b) { return a < b ? b : a; }
template <class T> T min(vector<T> a) { return *min_element(all(a)); }
template <class T> T max(vector<T> a) { return *max_element(all(a)); }
template <class T> T min(T a[]) {
T res = a[0];
rep(i, sz(a)) chmin(res, a[i]);
return res;
}
template <class T> T max(T a[]) {
T res = a[0];
rep(i, sz(a)) chmax(res, a[i]);
return res;
}
template <class T> T sum(vector<T> &v, int len = -1) {
if (len == -1)
len = v.size();
T res = 0;
rep(i, min((int)len, (int)v.size())) res += v[i];
return res;
}
///要素が0の時、返り値は0か1か
template <class T> T mul(vector<T> &v, int len = -1) {
if (len == -1)
len = v.size();
T res = 1;
rep(i, min((int)len, (int)v.size())) res *= v[i];
return res;
}
void clear(PQ &q) {
while (q.size())
q.pop();
}
template <class T> void clear(queue<T> &q) {
while (q.size())
q.pop();
}
template <class T> vector<T> ruiv(vector<T> &a) {
vector<T> res(a.size() + 1);
rep(i, a.size()) res[i + 1] = res[i] + a[i];
return res;
}
template <class T> void plus(vector<T> &a, T v = 1) {
for (auto &&u : a)
u += v;
}
template <class T> void minu(vector<T> &a, T v = 1) {
for (auto &&u : a)
u -= v;
}
template <class T> void minus(vector<T> &a, T v = 1) {
for (auto &&u : a)
u -= v;
}
inline bool inside(int y, int x, int H, int W) {
return y >= 0 && x >= 0 && y < H && x < W;
}
ll u(ll a) { return a < 0 ? 0 : a; }
#define MIN(a) numeric_limits<a>::min()
#define MAX(a) numeric_limits<a>::max()
template <class T> T min(vector<vector<T>> &a) {
T res = MAX(T);
rep(i, a.size()) chmin(res, *min_element(all(a[i])));
return res;
}
template <class T> T max(vector<vector<T>> &a) {
T res = MIN(T);
rep(i, a.size()) chmax(res, *max_element(all(a[i])));
return res;
}
bool bget(ll m, int keta) { return (m >> keta) & 1; }
int bget(ll m, int keta, int sinsuu) {
m /= (ll)pow(sinsuu, keta);
return m % sinsuu;
}
inline ll bit(int n) { return (1LL << (n)); }
inline ll bit(int n, int sinsuu) { return (ll)pow(sinsuu, n); }
int bcou(ll m) {
return __builtin_popcount(m & 0xFFFFFFFF) + __builtin_popcount(m >> 32);
}
//初期化は0を渡す
ll nextComb(ll &mask, int n, int r) {
if (!mask)
return mask = (1LL << r) - 1;
ll x = mask & -mask; //最下位の1
ll y = mask + x; //連続した下の1を繰り上がらせる
ll res = ((mask & ~y) / x >> 1) | y;
if (bget(res, n))
return mask = 0;
else
return mask = res;
}
// n桁以下でビットがr個立っているもののvectorを返す
vl bitCombList(int n, int r) {
vl res;
int m = 0;
while (nextComb(m, n, r)) {
res.pb(m);
}
return res;
}
int ctoi(char c) {
if ('A' <= c && c <= 'Z')
return c - 'A';
return c - 'a' + 26;
}
char itoc(int i) {
if (i < 26)
return 'A' + i;
return 'a' + i - 26;
}
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
void compress(vi &a) {
vi b;
int len = a.size();
for (int i = 0; i < len; ++i) {
b.push_back(a[i]);
}
sort(b);
UNIQUE(b);
for (int i = 0; i < len; ++i) {
a[i] = lower_bound(all(b), a[i]) - b.begin();
}
}
void compress(int a[], int len) {
vi b;
for (int i = 0; i < len; ++i) {
b.push_back(a[i]);
}
sort(b);
UNIQUE(b);
for (int i = 0; i < len; ++i) {
a[i] = lower_bound(all(b), a[i]) - b.begin();
}
}
//要素が見つからなかったときに困る
#define lowerIndex(a, v) (lower_bound(all(a), v) - a.begin())
#define lowerBound(a, v) (*lower_bound(all(a), v))
#define upperIndex(a, v) (upper_bound(all(a), v) - a.begin())
#define upperBound(a, v) (*upper_bound(all(a), v))
#define ans(a) \
cout << a << endl; \
continue;
#define poll(a) \
q.front(); \
q.pop()
#define dpoll(a) \
q.front(); \
q.pop_front()
#define pollLast(a) \
q.back(); \
q.pop_back()
#define pollBack(a) \
q.back(); \
q.pop_back()
template <class T> inline void fin(T s) { cout << s << endl, exit(0); }
template <class T> struct edge {
int from, to;
T cost;
int id;
int type;
edge(int f, int t, T c = 1, int id = -1, int ty = -1)
: from(f), to(t), cost(c), id(id), type(ty) {}
bool operator<(const edge &b) const { return cost < b.cost; }
bool operator>(const edge &b) const { return cost > b.cost; }
};
template <typename T> class graph {
protected:
vector<bool> _used;
public:
vector<vector<edge<T>>> g;
vector<edge<T>> edges;
int n, root = -1;
graph(int n) : n(n) {
g.resize(n);
_used.resize(n);
}
void clear() {
g.clear();
edges.clear();
}
void resize(int n) {
this->n = n;
g.resize(n);
_used.resize(n);
}
int size() { return g.size(); }
bool isleaf(int v) {
assert(root != -1);
return g[v].size() == 1 && g[v][0].from != root;
}
vector<edge<T>> operator[](int i) { return g[i]; }
virtual void add(int from, int to, T cost, int ty) = 0;
virtual bool used(edge<T> &e) = 0;
virtual bool used(int id) = 0;
virtual void del(edge<T> &e) = 0;
virtual void del(int id) = 0;
};
template <class T = int> class undigraph : public graph<T> {
public:
using graph<T>::g;
using graph<T>::n;
using graph<T>::edges;
using graph<T>::_used;
undigraph(int n) : graph<T>(n) {}
void add(int f, int t, T cost = 1, int ty = -1) {
if (!(0 <= f && f < n && 0 <= t && t < n))
OLE();
int id = edges.size();
g[f].emplace_back(f, t, cost, id, ty);
g[t].emplace_back(t, f, cost, id + 1, ty);
edges.emplace_back(f, t, cost, id, ty);
edges.emplace_back(t, f, cost, id + 1, ty);
}
void add(edge<T> &e) {
int f = e.from, t = e.to, ty = e.type;
T cost = e.cost;
add(f, t, cost, ty);
}
bool used(edge<T> &e) { return _used[e.id]; }
bool used(int id) { return _used[id]; }
void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; }
void del(int id) { _used[id] = _used[id ^ 1] = 1; }
};
template <typename T = ll> class digraph : public graph<T> {
public:
using graph<T>::g;
using graph<T>::n;
using graph<T>::edges;
using graph<T>::_used;
digraph(int n) : graph<T>(n) {}
void add(int f, int t, T cost = 1, int ty = -1) {
if (!(0 <= f && f < n && 0 <= t && t < n))
OLE();
int id = edges.size();
g[f].emplace_back(f, t, cost, ty, id);
edges.emplace_back(f, t, cost, ty, id);
}
bool used(edge<T> &e) { return _used[e.id]; }
bool used(int id) { return _used[id]; }
void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; }
void del(int id) { _used[id] = _used[id ^ 1] = 1; }
};
template <class T> bool nibu(const graph<T> &g) {
UnionFind uf(g.n * 2);
for (auto &&e : g.edges)
uf.unite(e.f, e.t + g.n), uf.unite(e.f + g.n, e.t);
return !uf.same(0, g.n);
}
template <class T> vector<T> dijkstra(const graph<T> &g, int s) {
if (!(0 <= s && s < g.n))
OLE();
T initValue = MAX(T);
vector<T> dis(g.n, initValue);
priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
dis[s] = 0;
q.emplace(0, s);
while (q.size()) {
T nowc = q.top().F;
int i = q.top().S;
q.pop();
if (dis[i] != nowc)
continue;
for (auto &&e : g.g[i]) {
int to = e.to;
T cost = nowc + e.cost;
if (dis[to] > cost) {
dis[to] = cost;
q.emplace(dis[to], to);
}
}
}
//たどり着かないなら-1
for (auto &&d : dis)
if (d == initValue)
d = -1;
return dis;
}
//機能拡張
template <typename T> void remove(vector<T> &v, unsigned int i) {
v.erase(v.begin() + i);
}
template <typename T>
void remove(vector<T> &v, unsigned int s, unsigned int e) {
v.erase(v.begin() + s, v.begin() + e);
}
template <typename T>
void removen(vector<T> &v, unsigned int s, unsigned int n) {
v.erase(v.begin() + s, v.begin() + s + n);
}
template <typename T> void erase(vector<T> &v, unsigned int i) {
v.erase(v.begin() + i);
}
template <typename T> void erase(vector<T> &v, unsigned int s, unsigned int e) {
v.erase(v.begin() + s, v.begin() + e);
}
template <typename T>
void erasen(vector<T> &v, unsigned int s, unsigned int n) {
v.erase(v.begin() + s, v.begin() + s + n);
}
template <typename T> void insert(vector<T> &v, unsigned int i, T t) {
v.insert(v.begin() + i, t);
}
template <typename T>
void insert(vector<T> &v, unsigned int i, vector<T> list) {
for (auto &&va : list)
v.insert(v.begin() + i++, va);
}
template <typename T>
void insert(vector<T> &v, unsigned int i, initializer_list<T> list) {
for (auto &&va : list)
v.insert(v.begin() + i++, va);
}
int mod(int a, int m) { return (a % m + m) % m; }
ll ma = numeric_limits<ll>::min();
ll mi = numeric_limits<ll>::max();
//閉路がなければtrue
bool topo(vi &res, digraph<int> g) {
int n = g.g.size();
vi nyu(n);
rep(i, n) for (auto &&e : g[i]) nyu[e.to]++;
queue<int> st;
rep(i, n) if (nyu[i] == 0) st.push(i);
while (st.size()) {
int v = st.front();
st.pop();
res.pb(v);
fora(e, g[v]) if (--nyu[e.to] == 0) st.push(e.to);
}
return res.size() == n;
}
//辞書順最小 トポロジカルソート
bool topos(vi &res, digraph<int> g) {
int n = g.g.size();
vi nyu(n);
rep(i, n) for (auto &&e : g[i]) nyu[e.to]++;
set<int> st;
rep(i, n) if (nyu[i] == 0) st.insert(i);
while (st.size()) {
int i = *st.begin();
st.erase(st.begin());
res.pb(i);
fora(e, g[i]) if (--nyu[e.to] == 0) st.insert(e.to);
}
return res.size() == n;
}
vector<string> split(const string a, const char deli) {
string b = a + deli;
int l = 0, r = 0, n = b.size();
vector<string> res;
rep(i, n) {
if (b[i] == deli) {
r = i;
if (l < r)
res.push_back(b.substr(l, r - l));
l = i + 1;
}
}
return res;
}
vector<string> split(const string a, const string deli) {
string b = a + deli;
int l = 0, r = 0, n = b.size(), dn = deli.size();
vector<string> res;
rep(i, n) {
if (i + dn <= n && b.substr(i, i + dn) == deli) {
r = i;
if (l < r)
res.push_back(b.substr(l, r - l));
i += dn - 1;
l = i + 1;
}
}
return res;
}
int N, K, M, H, W, X, Y, q, Q, r;
vi A, B, C;
string S[404];
vvb(used, 404, 404);
// b * w
int dfs(int h, int w) {
if (used[h][w])
return 0;
queue<P> q;
int cb = 0, cw = 0;
if (S[h][w] == '#')
cb++;
else
cw++;
q.emplace(h, w);
used[h][w] = 1;
while (q.size()) {
h = q.front().F;
w = q.front().S;
q.pop();
rep(i, 4) {
int nh = h + y4[i];
int nw = w + x4[i];
if (!inside(nh, nw, H, W))
continue;
if (S[h][w] == S[nh][nw])
continue;
if (used[nh][nw])
continue;
if (S[nh][nw] == '#')
cb++;
else
cw++;
q.emplace(nh, nw);
used[h][w] = 1;
}
}
return cb * cw;
}
signed main() {
int cou = 0;
cin >> H >> W;
rep(i, H) cin >> S[i];
rep(h, H) {
rep(w, W) { cou += dfs(h, w); }
}
cout << cou << endl;
return 0;
}
| // MLEが動かない
//セグフォは関数内で要素のでかい配列を定義しているから
// todo idef DEBUGで、境界チェック付きのvectorを作りたい
// http://marycore.jp/prog/cpp/class-extension-methods/
//現状ifdef DEBUG が何故か動かないので出来ない
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
struct initon {
initon() {
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(16);
};
} hoee;
namespace std {
template <> class hash<std::pair<signed, signed>> {
public:
size_t operator()(const std::pair<signed, signed> &x) const {
return hash<ll>()(((ll)x.first << 32) + x.second);
}
};
template <> class hash<std::pair<ll, ll>> {
public:
size_t operator()(const std::pair<ll, ll> &x) const {
return hash<ll>()(((ll)x.first << 32) + x.second);
}
};
} // namespace std
struct Tri {
int f, s, t;
Tri() { f = -1, s = -1, t = -1; }
Tri(int f, int s, int t) : f(f), s(s), t(t) {}
bool operator<(const Tri &r) const {
return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t;
// return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 大きい順
}
bool operator>(const Tri &r) const {
return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t;
// return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 小さい順
}
int operator[](int i) {
assert(i < 3);
switch (i) {
case 0:
return f;
break;
case 1:
return s;
break;
default:
return t;
break;
}
}
};
//別名
#define ull unsigned long long
#define vec vector
#define con continue
#define bre break
#define brk break
#define is ==
#define eq ==
#define no !=
#define ne !=
#define dif !=
#define df !=
#define rs resize
#define PQ priority_queue<ll, vector<ll>, greater<ll>>
using vi = vector<int>;
#define vvi(a, b, c) vec<vi> a(b, vi(c))
using vb = vector<bool>;
#define vvb(a, b, c) vec<vb> a(b, vb(c))
using vs = vector<string>;
#define vvs(a, b, c) vec<vs> a(b, vs(c))
using vl = vector<ll>;
#define vvl(a, b, c) vec<vl> a(b, vl(c))
using vd = vector<double>;
#define vvd(a, b, c) vec<vd> a(b, vd(c))
#define v3i(a, b, c, d) vector<vector<vi>> a(b, vector<vi>(c, vi(d)))
#define v3d(a, b, c, d) vector<vector<vd>> a(b, vector<vd>(c, vd(d)))
#define v3m(a, b, c, d) vector<vector<vm>> a(b, vector<vm>(c, vm(d)))
using vc = vector<char>;
#define vvc(a, b, c) vec<vc> a(b, vc(c))
using P = pair<int, int>;
// using T = tuple<int, int, int>;
using vp = vector<P>;
#define vvp(a, b, c) vec<vp> a(b, vp(c))
using vt = vector<Tri>;
#define vvt(a, b, c) vec<vt> a(b, vt(c))
using dou = double;
using itn = int;
using str = string;
using bo = bool;
#define uset unordered_set
#define mset multiset
#define umap unordered_map
#define mmap multimap
#define F first
#define S second
//定数
#define k4 10101
#define k5 101010
#define k6 1010101
#define k7 10101010
const int INF = (int)1e9 + 100;
const ll LINF = (ll)1e18 + 100;
const double EPS = 1e-9;
const int y4[] = {-1, 1, 0, 0};
const int x4[] = {0, 0, -1, 1};
const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1};
//配列
#define sz(a) (sizeof(a) / sizeof(a[0]))
//コンテナ
#define mp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
template <class T> T pop(set<T> &set) {
T res = *set.begin();
set.erase(set.find(res));
return res;
}
template <class T> T pop(mset<T> &set) {
T res = *set.begin();
set.erase(set.find(res));
return res;
}
template <class T> T popBack(set<T> &set) {
T res = *set.rbegin();
set.erase(set.find(res));
return res;
}
template <class T> T popBack(mset<T> &set) {
T res = *set.rbegin();
set.erase(set.find(res));
return res;
}
template <class T> inline void sort(vector<T> &a) { sort(a.begin(), a.end()); };
template <class T> inline void rsort(vector<T> &a) {
sort(a.begin(), a.end(), greater<T>());
};
template <class T> inline void sort(vector<T> &a, int len) {
sort(a.begin(), a.begin() + len);
};
template <class T> inline void rsort(vector<T> &a, int len) {
sort(a.begin(), a.begin() + len, greater<T>());
};
//繰り返し
#define _overloadrep(_1, _2, _3, name, ...) name
#define _rep(i, n) for (int i = 0; i < n; i++)
#define repi(i, m, n) for (int i = m; i < n; i++)
#define rep(...) _overloadrep(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rer(i, n) for (int i = n; i >= 0; i--)
#define reri(i, m, n) for (int i = m; i >= n; i--)
#define rer(...) _overloadrep(__VA_ARGS__, reri, _rer, )(__VA_ARGS__)
#define fora(a, b) for (auto &&a : b)
#define forr(a, b) for_each(map.rbegin(),map.rend(),[](auto&& a)
#define rea(a, b) for (auto &&a : b)
#define repa(a, b) for (auto &&a : b)
template <typename A, size_t N, typename T> void fill(A (&a)[N], const T &v) {
rep(i, N) a[i] = v;
}
template <typename A, size_t N, size_t O, typename T>
void fill(A (&a)[N][O], const T &v) {
rep(i, N) rep(j, O) a[i][j] = v;
}
template <typename A, size_t N, size_t O, size_t P, typename T>
void fill(A (&a)[N][O][P], const T &v) {
rep(i, N) rep(j, O) rep(k, P) a[i][j][k] = v;
}
template <typename A, size_t N, size_t O, size_t P, size_t Q, typename T>
void fill(A (&a)[N][O][P][Q], const T &v) {
rep(i, N) rep(j, O) rep(k, P) rep(l, Q) a[i][j][k][l] = v;
}
template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R,
typename T>
void fill(A (&a)[N][O][P][Q][R], const T &v) {
rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) a[i][j][k][l][m] = v;
}
template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R,
size_t S, typename T>
void fill(A (&a)[N][O][P][Q][R][S], const T &v) {
rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) rep(n, S)
a[i][j][k][l][m][n] = v;
}
template <class T, class U> void fill(vector<T> &a, U v) {
rep(i, a.size()) a[i] = v;
}
template <class T, class U> void fill(vector<vector<T>> &a, U v) {
rep(i, a.size()) rep(j, a[0].size()) a[i][j] = v;
}
template <class T, class U> void fill(vector<vector<vector<T>>> &a, U v) {
rep(i, a.size()) rep(j, a[0].size()) rep(k, a[0][0].size()) a[i][j][k] = v;
}
#define arcpy(a, b) memcpy(a, b, sizeof(b))
//入力
template <typename T = int> T in() {
T x;
cin >> x;
return (x);
}
string sin() { return in<string>(); }
double din() { return in<double>(); }
ll lin() { return in<ll>(); }
#define na(a, n) rep(i, n) cin >> a[i];
#define nad(a, n) rep(i, n) cin >> a[i], a[i]--;
#define na3(a, b, c, n) rep(i, n) cin >> a[i] >> b[i] >> c[i];
#define add2(a, b, n) rep(i, n) a.pb(in()), b.pb(in());
#define add2d(a, b, n) rep(i, n) a.pb(in() - 1), b.pb(in() - 1);
#define add3(a, b, c, n) rep(i, n) a.pb(in()), b.pb(in()), c.pb(in());
#define add3d(a, b, c, n) rep(i, n) a.pb(in() - 1), b.pb(in() - 1), c.pb(in());
#define na2(a, b, n) rep(i, n) cin >> a[i] >> b[i];
#define nt(a, h, w) rep(hi, h) rep(wi, w) cin >> a[hi][wi];
#define ntd(a, h, w) rep(hi, h) rep(wi, w) cin >> a[hi][wi], a[hi][wi]--;
#define ntp(a, h, w) \
fill(a, '#'); \
rep(hi, 1, h + 1) rep(wi, 1, w + 1) cin >> a[hi][wi];
#define addn(a, n) \
a.resize(n); \
na(a, n);
#define addnd(a, n) \
a.resize(n); \
na(a, n); \
rep(i, n) a[i]--;
//出力
template <class T> void out(vector<T> x) {
for (auto &&v : x)
cout << v << " ";
cout << "" << endl;
}
template <class T> void out(T x) {
if (typeid(x) == typeid(double))
cout << fixed << setprecision(10) << x << endl;
else
cout << x << endl;
}
//デバッグ
#define debug(x) \
cerr << x << " " \
<< "(L:" << __LINE__ << ")" << '\n';
// 境界チェック付きvector
namespace std_vector_bounds_checking {
using namespace std;
template <class T, class A = std::allocator<T>>
struct vector : std::vector<T, A> {
using std::vector<T, A>::vector;
typename std::vector<T>::reference
operator[](typename std::vector<T>::size_type n) {
return this->at(n);
}
};
} // namespace std_vector_bounds_checking
//よく使うクラス、構造体
class UnionFind {
public:
vi par, rank, sizes;
int n, trees;
UnionFind(int n) : n(n), trees(n) {
par.resize(n), rank.resize(n), sizes.resize(n);
rep(i, n) par[i] = i, sizes[i] = 1;
}
int root(int x) {
if (par[x] == x)
return x;
else
return par[x] = root(par[x]);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return;
if (rank[x] < rank[y])
swap(x, y);
trees--;
par[y] = x;
sizes[x] += sizes[y];
if (rank[x] == rank[y])
rank[x]++;
}
bool same(int x, int y) { return root(x) == root(y); }
int size(int x) { return sizes[root(x)]; }
//順不同 umapなので
vec<vi> sets() {
vec<vi> res(trees);
umap<int, vi> map;
rep(i, n) map[root(i)].push_back(i);
int i = 0;
for (auto &&p : map) {
int r = p.F;
res[i].push_back(r);
for (auto &&v : p.S) {
if (r == v)
continue;
res[i].push_back(v);
}
i++;
}
return res;
}
};
// MOD関連
ll MOD = (int)1e9 + 7;
int mpow(int v, ll a) {
ll x = v, n = a, res = 1;
while (n) {
if (n & 1)
res = (res * x) % MOD;
x = (x * x) % MOD;
n >>= 1;
}
return res;
}
class mint {
private:
ll v;
public:
static ll mod(ll a) { return (a % MOD + MOD) % MOD; }
mint(ll a = 0) { this->v = mod(a); };
mint(const mint &a) { v = a.v; }
mint operator+(const mint &a) { return mint(v + a.v); }
mint operator+(const ll a) { return mint(v + a % MOD); }
mint operator+(const signed a) { return mint(v + a % MOD); }
friend mint operator+(const ll a, const mint &b) {
return mint(a % MOD + b.v);
}
void operator+=(const mint &a) { v = (v + a.v) % MOD; }
void operator+=(const ll a) { v = mod(v + a % MOD); }
void operator+=(const signed a) { v = mod(v + a % MOD); }
friend void operator+=(ll &a, const mint &b) { a = mod(a % MOD + b.v); }
mint operator-(const mint &a) { return mint(v - a.v); }
mint operator-(const ll a) { return mint(v - a % MOD); }
mint operator-(const signed a) { return mint(v - a % MOD); }
friend mint operator-(const ll a, const mint &b) {
return mint(a % MOD - b.v);
}
void operator-=(const mint &a) { v = mod(v - a.v); }
void operator-=(const ll a) { v = mod(v - a % MOD); }
void operator-=(const signed a) { v = mod(v - a % MOD); }
friend void operator-=(ll &a, const mint &b) { a = mod(a % MOD - b.v); }
mint operator*(const mint &a) { return mint(v * a.v); }
mint operator*(const ll a) { return mint(v * (a % MOD)); }
mint operator*(const signed a) { return mint(v * (a % MOD)); }
friend mint operator*(const ll a, const mint &b) {
return mint(a % MOD * b.v);
}
void operator*=(const mint &a) { v = (v * a.v) % MOD; }
void operator*=(const ll a) { v = mod(v * (a % MOD)); }
void operator*=(const signed a) { v = mod(v * (a % MOD)); }
friend void operator*=(ll &a, const mint &b) { a = mod(a % MOD * b.v); }
mint operator/(const mint &a);
mint operator/(const ll a);
mint operator/(const signed a);
friend mint operator/(const ll a, const mint &b);
void operator/=(const mint &a);
void operator/=(const ll a);
void operator/=(const signed a);
friend void operator/=(ll &a, const mint &b);
mint operator^(const mint &a) { return mpow(v, a.v); };
mint operator^(const ll a) { return mpow(v, a); };
mint operator^(const signed a) { return mpow(v, a); };
friend mint operator^(const ll a, const mint &b) { return mpow(a, b.v); };
void operator^=(const mint &a) { v = mpow(v, a.v); }
void operator^=(const ll a) { v = mpow(v, a); }
void operator^=(const signed a) { v = mpow(v, a); }
//単項演算子
mint operator+() { return *this; }
mint operator++() {
v++;
return *this;
}
mint operator++(signed d) {
mint res = *this;
v++;
return res;
}
mint operator-() { return operator*(-1); }
mint operator--() {
v++;
return *this;
}
void operator--(signed d) {
mint res = *this;
v++;
}
bool operator==(mint &a) { return v == a.v; }
bool operator==(signed a) { return v == a; }
friend bool operator==(signed a, mint &b) { return a == b.v; }
bool operator!=(mint &a) { return v != a.v; }
bool operator!=(signed a) { return v != a; }
friend bool operator!=(signed a, mint &b) { return a != b.v; }
operator int() { return v; }
};
const int setModMax = 510000;
mint fac[setModMax], finv[setModMax], inv[setModMax];
void setMod() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < setModMax; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
mint minv(ll a) {
if (fac[0] == 0)
setMod();
if (a < setModMax)
return inv[a];
a %= MOD;
ll b = MOD, x = 1, y = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
x -= t * y;
swap(x, y);
}
return (x % MOD + MOD) % MOD;
}
mint mint::operator/(const mint &a) { return mint(v * minv(a.v)); }
mint mint::operator/(const ll a) { return mint(v * minv(a)); }
mint mint::operator/(const signed a) { return mint(v * minv(a)); }
mint operator/(const ll a, const mint &b) { return mint(a % MOD * minv(b.v)); }
void mint::operator/=(const mint &a) { v = (v * minv(a.v)) % MOD; }
void mint::operator/=(const ll a) { v = mod(v * minv(a)); }
void mint::operator/=(const signed a) { v = mod(v * minv(a)); }
void operator/=(ll &a, const mint &b) { a = mint::mod(a % MOD * minv(b.v)); }
using vm = vector<mint>;
#define vvm(a, b, c) vec<vm> a(b, vm(c))
bool isPrime[4010101];
vi primes;
void setPrime() {
fill(isPrime, true);
isPrime[0] = isPrime[1] = false;
for (int i = 2; i <= sqrt(sz(isPrime)) + 5; ++i) {
if (!isPrime[i])
continue;
for (int j = 2; i * j < sz(isPrime); ++j) {
isPrime[i * j] = false;
}
}
rep(i, sz(isPrime)) if (isPrime[i]) primes.pb(i);
}
mint com(ll n, ll r) {
if (n < r || n < 0 || r < 0)
return 0;
if (fac[0] == 0)
setMod();
return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
//便利関数
void OLE() {
string a = "a";
rep(i, 30) a += a;
rep(i, 1 << 17) cout << a << endl;
cout << "OLE 出力長制限超過" << endl;
exit(0);
}
void TLE() {
int a = 1;
while (a)
cout << a << endl;
}
void RE() {
int a = 1 / (x4[0] / MOD);
cout << a << endl;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
bool equal(double a, double b) { return fabs(a - b) < EPS; }
ll reverse(ll a) {
ll res = 0;
while (a) {
res *= 10;
res += a % 10;
a /= 10;
}
return res;
}
ll ceil(ll a, ll b) {
if (b == 0) {
OLE();
return -1;
} else
return (a + b - 1) / b;
}
ll sqrt(ll a) {
if (a < 0)
OLE();
ll res = (ll)std::sqrt(a);
while (res * res < a)
res++;
return res;
}
double log(double e, double x) { return log(x) / log(e); }
ll sig(ll t) { return (1 + t) * t / 2; }
ll sig(ll s, ll t) { return (s + t) * (t - s + 1) / 2; }
vi divisors(int v) {
vi res;
for (int i = 1; i <= sqrt(v); ++i) {
if (v % i == 0) {
res.pb(i);
if (i != v / i)
res.pb(v / i);
}
}
return res;
}
vi factorization(int v) {
int tv = v;
vi res;
if (!isPrime[2])
setPrime();
for (auto &&p : primes) {
if (v % p == 0)
res.push_back(p);
while (v % p == 0) {
v /= p;
}
if (v == 1 || p * p > tv)
break;
}
if (v > 1)
res.pb(v);
return res;
}
unordered_map<int, int> factorizationMap(int v) {
int tv = v;
unordered_map<int, int> res;
if (!isPrime[2])
setPrime();
for (auto &&p : primes) {
while (v % p == 0) {
res[p]++;
v /= p;
}
if (v == 1 || p * p > tv)
break;
}
if (v > 1)
res[v]++;
return res;
}
int get(int a, int keta) {
a /= (int)pow(10, keta);
return a % 10;
}
//変換系
template <class T, class U> vector<U> keys(map<T, U> a) {
vector<U> res;
for (auto &&k : a)
res.pb(k.F);
return res;
}
template <class T, class U> vector<U> keys(umap<T, U> a) {
vector<U> res;
for (auto &&k : a)
res.pb(k.F);
return res;
}
template <class T, class U> vector<T> values(map<T, U> a) {
vector<T> res;
for (auto &&k : a)
res.pb(k.S);
return res;
}
template <class T, class U> vector<T> values(umap<T, U> a) {
vector<T> res;
for (auto &&k : a)
res.pb(k.S);
return res;
}
vi list(int a) {
vi res;
while (a) {
res.insert(res.begin(), a % 10);
a /= 10;
}
return res;
}
template <class T, class U> bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T, class U> bool chmin(T &a, const U &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template <class T> T min(T a, signed b) { return a < b ? a : b; }
template <class T> T max(T a, signed b) { return a < b ? b : a; }
template <class T> T min(vector<T> a) { return *min_element(all(a)); }
template <class T> T max(vector<T> a) { return *max_element(all(a)); }
template <class T> T min(T a[]) {
T res = a[0];
rep(i, sz(a)) chmin(res, a[i]);
return res;
}
template <class T> T max(T a[]) {
T res = a[0];
rep(i, sz(a)) chmax(res, a[i]);
return res;
}
template <class T> T sum(vector<T> &v, int len = -1) {
if (len == -1)
len = v.size();
T res = 0;
rep(i, min((int)len, (int)v.size())) res += v[i];
return res;
}
///要素が0の時、返り値は0か1か
template <class T> T mul(vector<T> &v, int len = -1) {
if (len == -1)
len = v.size();
T res = 1;
rep(i, min((int)len, (int)v.size())) res *= v[i];
return res;
}
void clear(PQ &q) {
while (q.size())
q.pop();
}
template <class T> void clear(queue<T> &q) {
while (q.size())
q.pop();
}
template <class T> vector<T> ruiv(vector<T> &a) {
vector<T> res(a.size() + 1);
rep(i, a.size()) res[i + 1] = res[i] + a[i];
return res;
}
template <class T> void plus(vector<T> &a, T v = 1) {
for (auto &&u : a)
u += v;
}
template <class T> void minu(vector<T> &a, T v = 1) {
for (auto &&u : a)
u -= v;
}
template <class T> void minus(vector<T> &a, T v = 1) {
for (auto &&u : a)
u -= v;
}
inline bool inside(int y, int x, int H, int W) {
return y >= 0 && x >= 0 && y < H && x < W;
}
ll u(ll a) { return a < 0 ? 0 : a; }
#define MIN(a) numeric_limits<a>::min()
#define MAX(a) numeric_limits<a>::max()
template <class T> T min(vector<vector<T>> &a) {
T res = MAX(T);
rep(i, a.size()) chmin(res, *min_element(all(a[i])));
return res;
}
template <class T> T max(vector<vector<T>> &a) {
T res = MIN(T);
rep(i, a.size()) chmax(res, *max_element(all(a[i])));
return res;
}
bool bget(ll m, int keta) { return (m >> keta) & 1; }
int bget(ll m, int keta, int sinsuu) {
m /= (ll)pow(sinsuu, keta);
return m % sinsuu;
}
inline ll bit(int n) { return (1LL << (n)); }
inline ll bit(int n, int sinsuu) { return (ll)pow(sinsuu, n); }
int bcou(ll m) {
return __builtin_popcount(m & 0xFFFFFFFF) + __builtin_popcount(m >> 32);
}
//初期化は0を渡す
ll nextComb(ll &mask, int n, int r) {
if (!mask)
return mask = (1LL << r) - 1;
ll x = mask & -mask; //最下位の1
ll y = mask + x; //連続した下の1を繰り上がらせる
ll res = ((mask & ~y) / x >> 1) | y;
if (bget(res, n))
return mask = 0;
else
return mask = res;
}
// n桁以下でビットがr個立っているもののvectorを返す
vl bitCombList(int n, int r) {
vl res;
int m = 0;
while (nextComb(m, n, r)) {
res.pb(m);
}
return res;
}
int ctoi(char c) {
if ('A' <= c && c <= 'Z')
return c - 'A';
return c - 'a' + 26;
}
char itoc(int i) {
if (i < 26)
return 'A' + i;
return 'a' + i - 26;
}
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
void compress(vi &a) {
vi b;
int len = a.size();
for (int i = 0; i < len; ++i) {
b.push_back(a[i]);
}
sort(b);
UNIQUE(b);
for (int i = 0; i < len; ++i) {
a[i] = lower_bound(all(b), a[i]) - b.begin();
}
}
void compress(int a[], int len) {
vi b;
for (int i = 0; i < len; ++i) {
b.push_back(a[i]);
}
sort(b);
UNIQUE(b);
for (int i = 0; i < len; ++i) {
a[i] = lower_bound(all(b), a[i]) - b.begin();
}
}
//要素が見つからなかったときに困る
#define lowerIndex(a, v) (lower_bound(all(a), v) - a.begin())
#define lowerBound(a, v) (*lower_bound(all(a), v))
#define upperIndex(a, v) (upper_bound(all(a), v) - a.begin())
#define upperBound(a, v) (*upper_bound(all(a), v))
#define ans(a) \
cout << a << endl; \
continue;
#define poll(a) \
q.front(); \
q.pop()
#define dpoll(a) \
q.front(); \
q.pop_front()
#define pollLast(a) \
q.back(); \
q.pop_back()
#define pollBack(a) \
q.back(); \
q.pop_back()
template <class T> inline void fin(T s) { cout << s << endl, exit(0); }
template <class T> struct edge {
int from, to;
T cost;
int id;
int type;
edge(int f, int t, T c = 1, int id = -1, int ty = -1)
: from(f), to(t), cost(c), id(id), type(ty) {}
bool operator<(const edge &b) const { return cost < b.cost; }
bool operator>(const edge &b) const { return cost > b.cost; }
};
template <typename T> class graph {
protected:
vector<bool> _used;
public:
vector<vector<edge<T>>> g;
vector<edge<T>> edges;
int n, root = -1;
graph(int n) : n(n) {
g.resize(n);
_used.resize(n);
}
void clear() {
g.clear();
edges.clear();
}
void resize(int n) {
this->n = n;
g.resize(n);
_used.resize(n);
}
int size() { return g.size(); }
bool isleaf(int v) {
assert(root != -1);
return g[v].size() == 1 && g[v][0].from != root;
}
vector<edge<T>> operator[](int i) { return g[i]; }
virtual void add(int from, int to, T cost, int ty) = 0;
virtual bool used(edge<T> &e) = 0;
virtual bool used(int id) = 0;
virtual void del(edge<T> &e) = 0;
virtual void del(int id) = 0;
};
template <class T = int> class undigraph : public graph<T> {
public:
using graph<T>::g;
using graph<T>::n;
using graph<T>::edges;
using graph<T>::_used;
undigraph(int n) : graph<T>(n) {}
void add(int f, int t, T cost = 1, int ty = -1) {
if (!(0 <= f && f < n && 0 <= t && t < n))
OLE();
int id = edges.size();
g[f].emplace_back(f, t, cost, id, ty);
g[t].emplace_back(t, f, cost, id + 1, ty);
edges.emplace_back(f, t, cost, id, ty);
edges.emplace_back(t, f, cost, id + 1, ty);
}
void add(edge<T> &e) {
int f = e.from, t = e.to, ty = e.type;
T cost = e.cost;
add(f, t, cost, ty);
}
bool used(edge<T> &e) { return _used[e.id]; }
bool used(int id) { return _used[id]; }
void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; }
void del(int id) { _used[id] = _used[id ^ 1] = 1; }
};
template <typename T = ll> class digraph : public graph<T> {
public:
using graph<T>::g;
using graph<T>::n;
using graph<T>::edges;
using graph<T>::_used;
digraph(int n) : graph<T>(n) {}
void add(int f, int t, T cost = 1, int ty = -1) {
if (!(0 <= f && f < n && 0 <= t && t < n))
OLE();
int id = edges.size();
g[f].emplace_back(f, t, cost, ty, id);
edges.emplace_back(f, t, cost, ty, id);
}
bool used(edge<T> &e) { return _used[e.id]; }
bool used(int id) { return _used[id]; }
void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; }
void del(int id) { _used[id] = _used[id ^ 1] = 1; }
};
template <class T> bool nibu(const graph<T> &g) {
UnionFind uf(g.n * 2);
for (auto &&e : g.edges)
uf.unite(e.f, e.t + g.n), uf.unite(e.f + g.n, e.t);
return !uf.same(0, g.n);
}
template <class T> vector<T> dijkstra(const graph<T> &g, int s) {
if (!(0 <= s && s < g.n))
OLE();
T initValue = MAX(T);
vector<T> dis(g.n, initValue);
priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
dis[s] = 0;
q.emplace(0, s);
while (q.size()) {
T nowc = q.top().F;
int i = q.top().S;
q.pop();
if (dis[i] != nowc)
continue;
for (auto &&e : g.g[i]) {
int to = e.to;
T cost = nowc + e.cost;
if (dis[to] > cost) {
dis[to] = cost;
q.emplace(dis[to], to);
}
}
}
//たどり着かないなら-1
for (auto &&d : dis)
if (d == initValue)
d = -1;
return dis;
}
//機能拡張
template <typename T> void remove(vector<T> &v, unsigned int i) {
v.erase(v.begin() + i);
}
template <typename T>
void remove(vector<T> &v, unsigned int s, unsigned int e) {
v.erase(v.begin() + s, v.begin() + e);
}
template <typename T>
void removen(vector<T> &v, unsigned int s, unsigned int n) {
v.erase(v.begin() + s, v.begin() + s + n);
}
template <typename T> void erase(vector<T> &v, unsigned int i) {
v.erase(v.begin() + i);
}
template <typename T> void erase(vector<T> &v, unsigned int s, unsigned int e) {
v.erase(v.begin() + s, v.begin() + e);
}
template <typename T>
void erasen(vector<T> &v, unsigned int s, unsigned int n) {
v.erase(v.begin() + s, v.begin() + s + n);
}
template <typename T> void insert(vector<T> &v, unsigned int i, T t) {
v.insert(v.begin() + i, t);
}
template <typename T>
void insert(vector<T> &v, unsigned int i, vector<T> list) {
for (auto &&va : list)
v.insert(v.begin() + i++, va);
}
template <typename T>
void insert(vector<T> &v, unsigned int i, initializer_list<T> list) {
for (auto &&va : list)
v.insert(v.begin() + i++, va);
}
int mod(int a, int m) { return (a % m + m) % m; }
ll ma = numeric_limits<ll>::min();
ll mi = numeric_limits<ll>::max();
//閉路がなければtrue
bool topo(vi &res, digraph<int> g) {
int n = g.g.size();
vi nyu(n);
rep(i, n) for (auto &&e : g[i]) nyu[e.to]++;
queue<int> st;
rep(i, n) if (nyu[i] == 0) st.push(i);
while (st.size()) {
int v = st.front();
st.pop();
res.pb(v);
fora(e, g[v]) if (--nyu[e.to] == 0) st.push(e.to);
}
return res.size() == n;
}
//辞書順最小 トポロジカルソート
bool topos(vi &res, digraph<int> g) {
int n = g.g.size();
vi nyu(n);
rep(i, n) for (auto &&e : g[i]) nyu[e.to]++;
set<int> st;
rep(i, n) if (nyu[i] == 0) st.insert(i);
while (st.size()) {
int i = *st.begin();
st.erase(st.begin());
res.pb(i);
fora(e, g[i]) if (--nyu[e.to] == 0) st.insert(e.to);
}
return res.size() == n;
}
vector<string> split(const string a, const char deli) {
string b = a + deli;
int l = 0, r = 0, n = b.size();
vector<string> res;
rep(i, n) {
if (b[i] == deli) {
r = i;
if (l < r)
res.push_back(b.substr(l, r - l));
l = i + 1;
}
}
return res;
}
vector<string> split(const string a, const string deli) {
string b = a + deli;
int l = 0, r = 0, n = b.size(), dn = deli.size();
vector<string> res;
rep(i, n) {
if (i + dn <= n && b.substr(i, i + dn) == deli) {
r = i;
if (l < r)
res.push_back(b.substr(l, r - l));
i += dn - 1;
l = i + 1;
}
}
return res;
}
int N, K, M, H, W, X, Y, q, Q, r;
vi A, B, C;
string S[404];
vvb(used, 404, 404);
// b * w
int dfs(int h, int w) {
if (used[h][w])
return 0;
queue<P> q;
int cb = 0, cw = 0;
if (S[h][w] == '#')
cb++;
else
cw++;
q.emplace(h, w);
used[h][w] = 1;
while (q.size()) {
h = q.front().F;
w = q.front().S;
q.pop();
rep(i, 4) {
int nh = h + y4[i];
int nw = w + x4[i];
if (!inside(nh, nw, H, W))
continue;
if (S[h][w] == S[nh][nw])
continue;
if (used[nh][nw])
continue;
if (S[nh][nw] == '#')
cb++;
else
cw++;
q.emplace(nh, nw);
used[nh][nw] = 1;
}
}
return cb * cw;
}
signed main() {
int cou = 0;
cin >> H >> W;
rep(i, H) cin >> S[i];
rep(h, H) {
rep(w, W) { cou += dfs(h, w); }
}
cout << cou << endl;
return 0;
}
| [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change"
] | 950,744 | 950,745 | u986437843 | cpp |
p03153 | #include <bits/stdc++.h>
using namespace std;
struct UnionFind {
vector<int> data;
UnionFind(int sz) { data.assign(sz, -1); }
bool unite(int x, int y) {
x = find(x), y = find(y);
if (x == y)
return (false);
if (data[x] > data[y])
swap(x, y);
data[x] += data[y];
data[y] = x;
return (true);
}
int find(int k) {
if (data[k] < 0)
return (k);
return (data[k] = find(data[k]));
}
int size(int k) { return (-data[find(k)]); }
};
template <typename T, typename F> T boruvka(int N, F f) {
vector<int> rev(N), belong(N);
UnionFind uf(N);
T ret = T();
while (uf.size(0) != N) {
int ptr = 0;
for (int i = 0; i < N; i++) {
if (uf.find(i) == i) {
belong[i] = ptr++;
rev[belong[i]] = i;
}
}
for (int i = 0; i < N; i++) {
belong[i] = belong[uf.find(i)];
}
auto v = f(ptr, belong);
bool update = false;
for (int i = 0; i < ptr; i++) {
if (~v[i].second && uf.unite(rev[i], rev[v[i].second])) {
ret += v[i].first;
update = true;
}
}
if (!update)
return -1; // notice!!
}
return ret;
}
using int64 = long long;
const int INF = 1LL << 60;
int main() {
int64 N, D, A[200000];
cin >> N >> D;
for (int i = 0; i < N; i++) {
cin >> A[i];
}
using pii = pair<pair<int64, int>, pair<int64, int>>;
using pi = pair<int64, int>;
auto f1 = [](pii a, const pi &p) {
if (a.first.second == p.second) {
a.first.first = min(a.first.first, p.first);
} else if (a.second.second == p.second) {
a.second.first = min(a.second.first, p.first);
if (a.first > a.second)
swap(a.first, a.second);
} else {
if (p < a.first) {
a.second = a.first;
a.first = p;
} else if (p < a.second) {
a.second = p;
}
}
return a;
};
function<vector<pair<int64, int>>(int, vector<int>)> f =
[&](int sz, vector<int> belong) {
vector<pair<int64, int>> ret(sz, {INF, -1});
{
pii uku(make_pair(INF, -1), make_pair(INF, -1));
for (int i = 0; i < N; i++) {
auto e = uku.first.second == belong[i] ? uku.second : uku.first;
e.first += A[i];
e.first += i * D;
ret[belong[i]] = min(ret[belong[i]], e);
uku = f1(uku, pi(-i * D + A[i], belong[i]));
}
}
{
pii uku(make_pair(INF, -1), make_pair(INF, -1));
for (int i = N - 1; i >= 0; i--) {
auto e = uku.first.second == belong[i] ? uku.second : uku.first;
e.first += A[i];
e.first -= i * D;
ret[belong[i]] = min(ret[belong[i]], e);
uku = f1(uku, pi(i * D + A[i], belong[i]));
}
}
return ret;
};
cout << boruvka<int64, decltype(f)>(N, f) << endl;
} | #include <bits/stdc++.h>
using namespace std;
struct UnionFind {
vector<int> data;
UnionFind(int sz) { data.assign(sz, -1); }
bool unite(int x, int y) {
x = find(x), y = find(y);
if (x == y)
return (false);
if (data[x] > data[y])
swap(x, y);
data[x] += data[y];
data[y] = x;
return (true);
}
int find(int k) {
if (data[k] < 0)
return (k);
return (data[k] = find(data[k]));
}
int size(int k) { return (-data[find(k)]); }
};
template <typename T, typename F> T boruvka(int N, F f) {
vector<int> rev(N), belong(N);
UnionFind uf(N);
T ret = T();
while (uf.size(0) != N) {
int ptr = 0;
for (int i = 0; i < N; i++) {
if (uf.find(i) == i) {
belong[i] = ptr++;
rev[belong[i]] = i;
}
}
for (int i = 0; i < N; i++) {
belong[i] = belong[uf.find(i)];
}
auto v = f(ptr, belong);
bool update = false;
for (int i = 0; i < ptr; i++) {
if (~v[i].second && uf.unite(rev[i], rev[v[i].second])) {
ret += v[i].first;
update = true;
}
}
if (!update)
return -1; // notice!!
}
return ret;
}
using int64 = long long;
const int64 INF = 1LL << 60;
int main() {
int64 N, D, A[200000];
cin >> N >> D;
for (int i = 0; i < N; i++) {
cin >> A[i];
}
using pii = pair<pair<int64, int>, pair<int64, int>>;
using pi = pair<int64, int>;
auto f1 = [](pii a, const pi &p) {
if (a.first.second == p.second) {
a.first.first = min(a.first.first, p.first);
} else if (a.second.second == p.second) {
a.second.first = min(a.second.first, p.first);
if (a.first > a.second)
swap(a.first, a.second);
} else {
if (p < a.first) {
a.second = a.first;
a.first = p;
} else if (p < a.second) {
a.second = p;
}
}
return a;
};
function<vector<pair<int64, int>>(int, vector<int>)> f =
[&](int sz, vector<int> belong) {
vector<pair<int64, int>> ret(sz, {INF, -1});
{
pii uku(make_pair(INF, -1), make_pair(INF, -1));
for (int i = 0; i < N; i++) {
auto e = uku.first.second == belong[i] ? uku.second : uku.first;
e.first += A[i];
e.first += i * D;
ret[belong[i]] = min(ret[belong[i]], e);
uku = f1(uku, pi(-i * D + A[i], belong[i]));
}
}
{
pii uku(make_pair(INF, -1), make_pair(INF, -1));
for (int i = N - 1; i >= 0; i--) {
auto e = uku.first.second == belong[i] ? uku.second : uku.first;
e.first += A[i];
e.first -= i * D;
ret[belong[i]] = min(ret[belong[i]], e);
uku = f1(uku, pi(i * D + A[i], belong[i]));
}
}
return ret;
};
cout << boruvka<int64, decltype(f)>(N, f) << endl;
}
| [
"variable_declaration.type.change"
] | 950,828 | 950,829 | u524343822 | cpp |
p03155 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n + 1); i++)
const long long INF = 1LL << 60;
int main() {
int a, b, c;
cin >> a >> b >> c;
cout << (a - c + 1) * (b - c + 1) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n + 1); i++)
const long long INF = 1LL << 60;
int main() {
int a, b, c;
cin >> a >> b >> c;
cout << (a - b + 1) * (a - c + 1) << endl;
}
| [
"identifier.change",
"io.output.change"
] | 950,889 | 950,890 | u983563612 | cpp |
p03157 | #include <bits/stdc++.h>
using namespace std;
using LL = long long;
int H, W;
string S[400];
int c[400][400] = {};
vector<pair<LL, LL>> s;
void f(int i, int j, int k = -1) {
if (c[i][j] != -1) {
assert(k == -1 || c[i][j] == k);
return;
}
if (k == -1) {
c[i][j] = s.size();
s.push_back({0, 0});
} else {
c[i][j] = k;
}
if (S[i][j] == '#')
s[c[i][j]].first++;
else
s[c[i][j]].second++;
if (i > 0 && S[i][j] != S[i - 1][j])
f(i - 1, j, c[i][j]);
if (i < H - 1 && S[i][j] != S[i + 1][j])
f(i + 1, j, c[i][j]);
if (j > 0 && S[i][j] != S[i][j - 1])
f(i, j - 1, c[i][j]);
if (j < W - 1 && S[i][j] != S[i][j + 1])
f(i, j + 1, c[i][j]);
}
int main() {
cin >> H >> W;
for (int i = 0; i < H; i++)
cin >> S[i];
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
c[i][j] = -1;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
f(i, j);
LL ans = 0;
for (pair<int, int> q : s) {
ans += q.first * q.second;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using LL = long long;
int H, W;
string S[400];
int c[400][400] = {};
vector<pair<LL, LL>> s;
void f(int i, int j, int k = -1) {
if (c[i][j] != -1) {
assert(k == -1 || c[i][j] == k);
return;
}
if (k == -1) {
c[i][j] = s.size();
s.push_back({0, 0});
} else {
c[i][j] = k;
}
if (S[i][j] == '#')
s[c[i][j]].first++;
else
s[c[i][j]].second++;
if (i > 0 && S[i][j] != S[i - 1][j])
f(i - 1, j, c[i][j]);
if (i < H - 1 && S[i][j] != S[i + 1][j])
f(i + 1, j, c[i][j]);
if (j > 0 && S[i][j] != S[i][j - 1])
f(i, j - 1, c[i][j]);
if (j < W - 1 && S[i][j] != S[i][j + 1])
f(i, j + 1, c[i][j]);
}
int main() {
cin >> H >> W;
for (int i = 0; i < H; i++)
cin >> S[i];
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
c[i][j] = -1;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
f(i, j);
LL ans = 0;
for (pair<LL, LL> q : s) {
ans += q.first * q.second;
}
cout << ans << endl;
} | [] | 950,935 | 950,936 | u296096665 | cpp |
p03157 | #include <bits/stdc++.h>
using namespace std;
using LL = long long;
int H, W;
string S[400];
int c[400][400] = {};
vector<pair<int, int>> s;
void f(int i, int j, int k = -1) {
if (c[i][j] != -1) {
assert(k == -1 || c[i][j] == k);
return;
}
if (k == -1) {
c[i][j] = s.size();
s.push_back({0, 0});
} else {
c[i][j] = k;
}
if (S[i][j] == '#')
s[c[i][j]].first++;
else
s[c[i][j]].second++;
if (i > 0 && S[i][j] != S[i - 1][j])
f(i - 1, j, c[i][j]);
if (i < H - 1 && S[i][j] != S[i + 1][j])
f(i + 1, j, c[i][j]);
if (j > 0 && S[i][j] != S[i][j - 1])
f(i, j - 1, c[i][j]);
if (j < W - 1 && S[i][j] != S[i][j + 1])
f(i, j + 1, c[i][j]);
}
int main() {
cin >> H >> W;
for (int i = 0; i < H; i++)
cin >> S[i];
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
c[i][j] = -1;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
f(i, j);
LL ans = 0;
for (pair<int, int> q : s) {
ans += q.first * q.second;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using LL = long long;
int H, W;
string S[400];
int c[400][400] = {};
vector<pair<LL, LL>> s;
void f(int i, int j, int k = -1) {
if (c[i][j] != -1) {
assert(k == -1 || c[i][j] == k);
return;
}
if (k == -1) {
c[i][j] = s.size();
s.push_back({0, 0});
} else {
c[i][j] = k;
}
if (S[i][j] == '#')
s[c[i][j]].first++;
else
s[c[i][j]].second++;
if (i > 0 && S[i][j] != S[i - 1][j])
f(i - 1, j, c[i][j]);
if (i < H - 1 && S[i][j] != S[i + 1][j])
f(i + 1, j, c[i][j]);
if (j > 0 && S[i][j] != S[i][j - 1])
f(i, j - 1, c[i][j]);
if (j < W - 1 && S[i][j] != S[i][j + 1])
f(i, j + 1, c[i][j]);
}
int main() {
cin >> H >> W;
for (int i = 0; i < H; i++)
cin >> S[i];
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
c[i][j] = -1;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
f(i, j);
LL ans = 0;
for (pair<LL, LL> q : s) {
ans += q.first * q.second;
}
cout << ans << endl;
} | [] | 950,937 | 950,936 | u296096665 | cpp |
p03157 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
const int INF = 1e9;
const int maxN = 1e3 + 5;
int n, h, w;
char a[maxN][maxN];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
ll ans = 0;
int vis[maxN][maxN];
int flag = 0;
int bl = 0, wt = 0;
void check(int x, int y) {
vis[x][y] = 1;
if (a[x][y] == '#') {
bl++;
} else {
wt++;
}
for (int i = 0; i < 4; i++) {
int tx = x + dx[i];
int ty = y + dy[i];
if (tx < 1 || tx > w || ty < 1 || ty > h)
continue;
if (vis[tx][ty])
continue;
if (a[x][y] != a[tx][ty]) {
check(tx, ty);
}
}
}
int main() {
scanf("%d%d", &h, &w);
for (int i = 1; i <= h; i++) {
scanf("%s", a[i] + 1);
}
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
bl = 0, wt = 0;
if (!vis[i][j]) {
check(i, j);
}
ans += ((ll)wt * bl);
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
const int INF = 1e9;
const int maxN = 1e3 + 5;
int n, h, w;
char a[maxN][maxN];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
ll ans = 0;
int vis[maxN][maxN];
int flag = 0;
int bl = 0, wt = 0;
void check(int x, int y) {
vis[x][y] = 1;
if (a[x][y] == '#') {
bl++;
} else {
wt++;
}
for (int i = 0; i < 4; i++) {
int tx = x + dx[i];
int ty = y + dy[i];
if (tx < 1 || tx > h || ty < 1 || ty > w)
continue;
if (vis[tx][ty])
continue;
if (a[x][y] != a[tx][ty]) {
check(tx, ty);
}
}
}
int main() {
scanf("%d%d", &h, &w);
for (int i = 1; i <= h; i++) {
scanf("%s", a[i] + 1);
}
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
bl = 0, wt = 0;
if (!vis[i][j]) {
check(i, j);
}
ans += ((ll)wt * bl);
}
}
cout << ans << endl;
return 0;
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 950,944 | 950,945 | u807919574 | cpp |
p03157 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int maxn = 412;
string s[maxn];
int h, w, dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
bool vis[maxn][maxn];
void dfs(int x, int y, int &cnt_w, int &cnt_b) {
if (vis[x][y])
return;
vis[x][y] = true;
if (s[x][y] == '#')
cnt_w++;
else
cnt_b++;
rep(i, 0, 4) {
int xx = x + dx[i], yy = y + dy[i];
if (xx < h && xx >= 0 && yy < w && yy >= 0 && s[x][y] != s[xx][yy])
dfs(xx, yy, cnt_w, cnt_b);
}
}
int main() {
#ifdef LOCAL_DEFINE
freopen("test.in", "r", stdin);
#else
cin.sync_with_stdio(0);
cin.tie(0);
#endif
cin >> h >> w;
rep(i, 0, w) cin >> s[i];
int ans = 0;
rep(i, 0, h) {
rep(j, 0, w) {
if (!vis[i][j]) {
int cnt_w = 0, cnt_b = 0;
dfs(i, j, cnt_w, cnt_b);
ans += cnt_w * cnt_b;
}
}
}
cout << ans << '\n';
#ifdef LOCAL_DEFINE
cerr << "Time elapsed: " << 1.0 * (double)clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int maxn = 412;
string s[maxn];
int h, w, dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
bool vis[maxn][maxn];
void dfs(int x, int y, int &cnt_w, int &cnt_b) {
if (vis[x][y])
return;
vis[x][y] = true;
if (s[x][y] == '#')
cnt_w++;
else
cnt_b++;
rep(i, 0, 4) {
int xx = x + dx[i], yy = y + dy[i];
if (xx < h && xx >= 0 && yy < w && yy >= 0 && s[x][y] != s[xx][yy])
dfs(xx, yy, cnt_w, cnt_b);
}
}
int main() {
#ifdef LOCAL_DEFINE
freopen("test.in", "r", stdin);
#else
cin.sync_with_stdio(0);
cin.tie(0);
#endif
cin >> h >> w;
rep(i, 0, h) cin >> s[i];
ll ans = 0;
rep(i, 0, h) {
rep(j, 0, w) {
if (!vis[i][j]) {
int cnt_w = 0, cnt_b = 0;
dfs(i, j, cnt_w, cnt_b);
ans += 1ll * cnt_w * cnt_b;
}
}
}
cout << ans << '\n';
#ifdef LOCAL_DEFINE
cerr << "Time elapsed: " << 1.0 * (double)clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}
| [
"identifier.change",
"call.arguments.change",
"variable_declaration.type.change",
"assignment.change"
] | 950,995 | 950,994 | u403305794 | cpp |
p03157 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 444;
char g[maxn][maxn];
int h, w;
bool vis[maxn][maxn];
int64_t cntb, cntw;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int64_t ans;
void dfs(int x, int y) {
vis[x][y] = 1;
if (g[x][w] == '#') {
cntb++;
} else {
cntw++;
}
for (int i = 0; i < 4; ++i) {
int nx = dx[i] + x;
int ny = dy[i] + y;
if (nx >= 1 && nx <= h && ny >= 1 && ny <= w && !vis[nx][ny] &&
g[nx][ny] != g[x][y]) {
dfs(nx, ny);
}
}
}
int main() {
cin >> h >> w;
for (int i = 1; i <= h; ++i) {
cin >> g[i] + 1;
}
for (int i = 1; i <= h; ++i) {
for (int j = 1; j <= w; ++j) {
if (g[i][j] == '#' && !vis[i][j]) {
cntb = cntw = 0;
dfs(i, j);
ans += cntb * cntw;
}
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
const int maxn = 444;
char g[maxn][maxn];
int h, w;
bool vis[maxn][maxn];
int64_t cntb, cntw;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int64_t ans;
void dfs(int x, int y) {
vis[x][y] = 1;
if (g[x][y] == '#') {
cntb++;
} else {
cntw++;
}
for (int i = 0; i < 4; ++i) {
int nx = dx[i] + x;
int ny = dy[i] + y;
if (nx >= 1 && nx <= h && ny >= 1 && ny <= w && !vis[nx][ny] &&
g[nx][ny] != g[x][y]) {
dfs(nx, ny);
}
}
}
int main() {
cin >> h >> w;
for (int i = 1; i <= h; ++i) {
cin >> g[i] + 1;
}
for (int i = 1; i <= h; ++i) {
for (int j = 1; j <= w; ++j) {
if (g[i][j] == '#' && !vis[i][j]) {
cntb = cntw = 0;
dfs(i, j);
ans += cntb * cntw;
}
}
}
cout << ans << endl;
} | [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 951,004 | 951,005 | u914762730 | cpp |
p03157 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 444;
char g[maxn][maxn];
int h, w;
bool vis[maxn][maxn];
int cntb, cntw;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int64_t ans;
void dfs(int x, int y) {
vis[x][y] = 1;
if (g[x][w] == '#') {
cntb++;
} else {
cntw++;
}
for (int i = 0; i < 4; ++i) {
int nx = dx[i] + x;
int ny = dy[i] + y;
if (nx >= 1 && nx <= h && ny >= 1 && ny <= w && !vis[nx][ny] &&
g[nx][ny] != g[x][y]) {
dfs(nx, ny);
}
}
}
int main() {
cin >> h >> w;
for (int i = 1; i <= h; ++i) {
cin >> g[i] + 1;
}
for (int i = 1; i <= h; ++i) {
for (int j = 1; j <= w; ++j) {
if (g[i][j] == '#' && !vis[i][j]) {
cntb = cntw = 0;
dfs(i, j);
ans += cntb * cntw;
}
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
const int maxn = 444;
char g[maxn][maxn];
int h, w;
bool vis[maxn][maxn];
int64_t cntb, cntw;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int64_t ans;
void dfs(int x, int y) {
vis[x][y] = 1;
if (g[x][y] == '#') {
cntb++;
} else {
cntw++;
}
for (int i = 0; i < 4; ++i) {
int nx = dx[i] + x;
int ny = dy[i] + y;
if (nx >= 1 && nx <= h && ny >= 1 && ny <= w && !vis[nx][ny] &&
g[nx][ny] != g[x][y]) {
dfs(nx, ny);
}
}
}
int main() {
cin >> h >> w;
for (int i = 1; i <= h; ++i) {
cin >> g[i] + 1;
}
for (int i = 1; i <= h; ++i) {
for (int j = 1; j <= w; ++j) {
if (g[i][j] == '#' && !vis[i][j]) {
cntb = cntw = 0;
dfs(i, j);
ans += cntb * cntw;
}
}
}
cout << ans << endl;
} | [
"variable_declaration.type.primitive.change",
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 951,006 | 951,005 | u914762730 | cpp |
p03157 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fLL
#define ms(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
int min3(int a, int b, int c) { return min(min(a, b), c); }
int max3(int a, int b, int c) { return max(max(a, b), c); }
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
x = x * 10 + ch - '0', ch = getchar();
return x * f;
}
const int maxn = 5e5 + 5;
int dir[4][2] = {0, 1, 0, -1, -1, 0, 1, 0};
ll n, m;
ll ans;
char s[405][405];
ll p[maxn], cnt[maxn], vis[maxn];
ll Hash(ll x, ll y) { return x * 450 + y; }
ll Find(ll x) { return x == p[x] ? x : p[x] = Find(p[x]); }
void join(ll x, ll y) {
x = Find(x), y = Find(y);
if (x != y) {
p[x] = y;
cnt[y] += cnt[x];
vis[y] += vis[x];
}
}
void init() {
for (int i = 0; i < maxn; i++) {
p[i] = i;
cnt[i] = 1;
}
}
int main() {
init();
scanf("%lld%lld", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%s", s[i] + 1);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (s[i][j] == '#')
vis[(i, j)] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
for (int k = 0; k < 4; k++) {
int x = i + dir[k][0];
int y = j + dir[k][1];
if (x > 0 && x <= n && y > 0 && y <= m && s[i][j] != s[x][y]) {
join(Hash(x, y), Hash(i, j));
}
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
ll xx = Find(Hash(i, j));
if (cnt[xx] > 1) {
ans += vis[xx] * (cnt[xx] - vis[xx]);
cnt[xx] = 0;
}
}
}
printf("%lld\n", ans);
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fLL
#define ms(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
int min3(int a, int b, int c) { return min(min(a, b), c); }
int max3(int a, int b, int c) { return max(max(a, b), c); }
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
x = x * 10 + ch - '0', ch = getchar();
return x * f;
}
const int maxn = 5e5 + 5;
int dir[4][2] = {0, 1, 0, -1, -1, 0, 1, 0};
ll n, m;
ll ans;
char s[405][405];
ll p[maxn], cnt[maxn], vis[maxn];
ll Hash(ll x, ll y) { return x * 450 + y; }
ll Find(ll x) { return x == p[x] ? x : p[x] = Find(p[x]); }
void join(ll x, ll y) {
x = Find(x), y = Find(y);
if (x != y) {
p[x] = y;
cnt[y] += cnt[x];
vis[y] += vis[x];
}
}
void init() {
for (int i = 0; i < maxn; i++) {
p[i] = i;
cnt[i] = 1;
}
}
int main() {
init();
scanf("%lld%lld", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%s", s[i] + 1);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (s[i][j] == '#')
vis[Hash(i, j)] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
for (int k = 0; k < 4; k++) {
int x = i + dir[k][0];
int y = j + dir[k][1];
if (x > 0 && x <= n && y > 0 && y <= m && s[i][j] != s[x][y]) {
join(Hash(x, y), Hash(i, j));
}
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
ll xx = Find(Hash(i, j));
if (cnt[xx] > 1) {
ans += vis[xx] * (cnt[xx] - vis[xx]);
cnt[xx] = 0;
}
}
}
printf("%lld\n", ans);
return 0;
}
| [
"call.add"
] | 951,234 | 951,235 | u940396739 | cpp |
p03157 | #include <bits/stdc++.h>
#define rep(i, s, e) for (int i = s; i < e; i++)
#define test(t) \
int t; \
cin >> t; \
while (t--)
#define iterate(it, s) for (auto it = s.begin(); it != s.end(); ++it)
#define MOD 1000000007
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef set<int> si;
typedef long long ll;
int findp(int *parent, int n) {
if (parent[n] == n)
return n;
parent[n] = findp(parent, parent[n]);
return parent[n];
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, len;
cin >> n >> len;
int parent[n * len];
int blacks[n * len];
int whites[n * len];
rep(i, 0, n * len) {
parent[i] = i;
blacks[i] = whites[i] = 0;
}
string s[n];
rep(i, 0, n) { cin >> s[i]; }
rep(i, 0, n) {
rep(j, 0, len) {
if (i != 0) {
if (s[i - 1][j] != s[i][j]) {
int p = findp(parent, i * len + j);
parent[p] = findp(parent, (i - 1) * len + j);
}
}
if (j != 0) {
if (s[i][j] != s[i][j - 1]) {
int p = findp(parent, i * len + j);
parent[p] = findp(parent, (i * len + j - 1));
}
}
if (i != (n - 1)) {
if (s[i][j] != s[i + 1][j]) {
int p = findp(parent, i * len + j);
parent[p] = findp(parent, ((i + 1) * len + j));
}
}
if (j != (len - 1)) {
if (s[i][j] != s[i][j + 1]) {
int p = findp(parent, i * len + j);
parent[p] = findp(parent, (i * len + j + 1));
}
}
}
}
rep(i, 0, n) {
rep(j, 0, len) {
int p = findp(parent, i * len + j);
if (s[i][j] == '#')
blacks[p]++;
else
whites[p]++;
}
}
long ways = 0;
rep(i, 0, n) {
rep(j, 0, len) {
ways += (long)(whites[i * len + j] * blacks[parent[i * len + j]]);
}
}
cout << ways << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, s, e) for (int i = s; i < e; i++)
#define test(t) \
int t; \
cin >> t; \
while (t--)
#define iterate(it, s) for (auto it = s.begin(); it != s.end(); ++it)
#define MOD 1000000007
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef set<int> si;
typedef long long ll;
int findp(int *parent, int n) {
if (parent[n] == n)
return n;
parent[n] = findp(parent, parent[n]);
return parent[n];
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, len;
cin >> n >> len;
int parent[n * len];
long blacks[n * len];
long whites[n * len];
rep(i, 0, n * len) {
parent[i] = i;
blacks[i] = whites[i] = 0;
}
string s[n];
rep(i, 0, n) { cin >> s[i]; }
rep(i, 0, n) {
rep(j, 0, len) {
if (i != 0) {
if (s[i - 1][j] != s[i][j]) {
int p = findp(parent, i * len + j);
parent[p] = findp(parent, (i - 1) * len + j);
}
}
if (j != 0) {
if (s[i][j] != s[i][j - 1]) {
int p = findp(parent, i * len + j);
parent[p] = findp(parent, (i * len + j - 1));
}
}
if (i != (n - 1)) {
if (s[i][j] != s[i + 1][j]) {
int p = findp(parent, i * len + j);
parent[p] = findp(parent, ((i + 1) * len + j));
}
}
if (j != (len - 1)) {
if (s[i][j] != s[i][j + 1]) {
int p = findp(parent, i * len + j);
parent[p] = findp(parent, (i * len + j + 1));
}
}
}
}
rep(i, 0, n) {
rep(j, 0, len) {
int p = findp(parent, i * len + j);
if (s[i][j] == '#')
blacks[p]++;
else
whites[p]++;
}
}
long ways = 0;
rep(i, 0, n) {
rep(j, 0, len) {
ways += (long)(whites[i * len + j] * blacks[parent[i * len + j]]);
}
}
cout << ways << endl;
return 0;
}
| [
"variable_declaration.type.primitive.change"
] | 951,342 | 951,343 | u735095729 | cpp |
p03157 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int h, w;
string s[500];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
bool check[500][500];
void dfs(int y, int x, int &b_num, int &w_num) {
check[y][x] = true;
for (int i = 0; i < 4; ++i) {
int ny = y + dy[i], nx = x + dx[i];
if (0 <= nx && nx < w && 0 <= ny && ny < h && !check[ny][nx] &&
s[ny][nx] != s[y][x]) {
if (s[ny][nx] == '#')
b_num++;
else
w_num++;
dfs(ny, nx, b_num, w_num);
}
}
return;
}
int main() {
cin >> h >> w;
for (int i = 0; i < h; ++i)
cin >> s[i];
ll ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (!check[i][j]) {
int b_num = 0, w_num = 0;
if (s[i][j] == '#')
b_num++;
else
w_num++;
dfs(i, j, b_num, w_num);
ans += b_num * w_num;
}
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int h, w;
string s[500];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
bool check[500][500];
void dfs(int y, int x, ll &b_num, ll &w_num) {
check[y][x] = true;
for (int i = 0; i < 4; ++i) {
int ny = y + dy[i], nx = x + dx[i];
if (0 <= nx && nx < w && 0 <= ny && ny < h && !check[ny][nx] &&
s[ny][nx] != s[y][x]) {
if (s[ny][nx] == '#')
b_num++;
else
w_num++;
dfs(ny, nx, b_num, w_num);
}
}
return;
}
int main() {
cin >> h >> w;
for (int i = 0; i < h; ++i)
cin >> s[i];
ll ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (!check[i][j]) {
ll b_num = 0, w_num = 0;
if (s[i][j] == '#')
b_num++;
else
w_num++;
dfs(i, j, b_num, w_num);
ans += b_num * w_num;
}
}
}
cout << ans << endl;
return 0;
}
| [
"variable_declaration.type.change"
] | 951,354 | 951,355 | u054652697 | cpp |
p03157 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll _() {
ll x = 0, f = 1;
char ch = getchar();
for (; ch < '0' || ch > '9'; ch = getchar())
if (ch == '-')
f = -f;
for (; ch >= '0' && ch <= '9'; ch = getchar())
x = x * 10 + ch - '0';
return x * f;
}
#define _ _()
int n, m;
ll f[405 * 405], w[405 * 405], b[405 * 405];
ll ans;
char s[405][405];
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
inline int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
int main() {
n = _;
m = _;
for (int i = 1; i <= n * m; i++)
f[i] = i;
for (int i = 1; i <= n; i++)
scanf("%s", s[i] + 1);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
for (int k = 0; k < 4; k++) {
int nx = i + dx[k], ny = j + dy[k];
if (nx < 1 || ny < 1 || nx > n || ny > m)
continue;
if (s[nx][ny] != s[i][j]) {
int fx = find((nx - 1) * m + ny), fy = (i - 1) * m + j;
f[fx] = f[fy];
}
}
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (s[i][j] == '#')
b[find((i - 1) * m + j)]++;
else
w[find((i - 1) * m + j)]++;
for (int i = 1; i <= n * m; i++)
ans += b[i] * w[i];
printf("%lld\n", ans);
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll _() {
ll x = 0, f = 1;
char ch = getchar();
for (; ch < '0' || ch > '9'; ch = getchar())
if (ch == '-')
f = -f;
for (; ch >= '0' && ch <= '9'; ch = getchar())
x = x * 10 + ch - '0';
return x * f;
}
#define _ _()
int n, m;
ll f[405 * 405], w[405 * 405], b[405 * 405];
ll ans;
char s[405][405];
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
inline int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
int main() {
n = _;
m = _;
for (int i = 1; i <= n * m; i++)
f[i] = i;
for (int i = 1; i <= n; i++)
scanf("%s", s[i] + 1);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
for (int k = 0; k < 4; k++) {
int nx = i + dx[k], ny = j + dy[k];
if (nx < 1 || ny < 1 || nx > n || ny > m)
continue;
if (s[nx][ny] != s[i][j]) {
int fx = find((nx - 1) * m + ny), fy = find((i - 1) * m + j);
f[fx] = f[fy];
}
}
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (s[i][j] == '#')
b[find((i - 1) * m + j)]++;
else
w[find((i - 1) * m + j)]++;
for (int i = 1; i <= n * m; i++)
ans += b[i] * w[i];
printf("%lld\n", ans);
} | [
"call.add",
"call.arguments.change"
] | 951,479 | 951,480 | u513391017 | cpp |
p03157 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;
const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int dy8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
#define p_queue(i) priority_queue<i>
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>>
#define umap(i, j) unordered_map<i, j>
#define P(p) cout << (p) << endl
#define PS(p) cout << (p) << " "
#define IN cin >>
#define rep(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rrep(i, m, n) for (int i = (m - 1); i >= (int)(n); i--)
#define inrep(n, a) \
for (int i = 0; i < (int)(n); i++) \
cin >> a[i];
#define mod(i) ((i) % (ll)(1e9 + 7))
#define divm(a, b) (mod(a * modpow((ll)b, (ll)(1e9 + 5))))
#define rsort(a, b, c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v, c) sort(v.begin(), v.end(), greater<c>())
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a, n, k) (lower_bound(a, a + n, k) - a)
#define vlb(a, k) (lower_bound(a.begin(), a.end(), k) - a.begin())
#define ub(a, n, k) (upper_bound(a, a + n, k) - a)
#define vub(a, k) (upper_bound(a.begin(), a.end(), k) - a.begin())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define ret return
ll modpow(ll i, ll j) {
ll tmp = 1;
while (j) {
if (j % 2)
tmp = mod(tmp * i);
i = mod(i * i);
j /= 2;
}
return tmp;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
vector<string> split(const string &str, char sep) {
vector<string> v;
stringstream ss(str);
string buffer;
while (getline(ss, buffer, sep)) {
v.push_back(buffer);
}
return v;
}
// ll ncr[100][100];
// ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1;
// if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] =
// nCr(n-1,r) + nCr(n-1,r-1);}
// ll npr[100][100]={};
// ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] =
// 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}
// ll nHr(int n,int r){ret nCr(n+r-1,r);}
///////////////////////////////////////////////////////////////////////////
int h, w;
string s[500];
int d[500][500] = {};
int f(int x, int y, int xx, int yy) {
queue<pair<int, int>> q;
q.push(make_pair(x, y));
d[y][x] = 1;
int bc = 1, wc = 0;
while (!q.empty()) {
pair<int, int> now = q.front();
q.pop();
rep(i, 0, 4) {
int nx = now.ft + dx[i], ny = now.sd + dy[i];
if (0 <= nx && nx < w && 0 <= ny && ny < h) {
if (s[now.sd][now.ft] != s[ny][nx] && d[ny][nx] == 0) {
d[ny][nx] = 1;
q.push(make_pair(nx, ny));
if (s[ny][nx] == '.')
wc++;
else
bc++;
}
}
}
}
// PS(bc);P(wc);
return bc * wc;
}
int main() {
cin >> h >> w;
inrep(h, s);
ll ans = 0;
rep(i, 0, h) {
rep(j, 0, w) {
if (s[i][j] == '#' && d[i][j] == 0) {
ans += f(j, i, j, i);
}
}
}
P(ans);
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;
const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int dy8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
#define p_queue(i) priority_queue<i>
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>>
#define umap(i, j) unordered_map<i, j>
#define P(p) cout << (p) << endl
#define PS(p) cout << (p) << " "
#define IN cin >>
#define rep(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rrep(i, m, n) for (int i = (m - 1); i >= (int)(n); i--)
#define inrep(n, a) \
for (int i = 0; i < (int)(n); i++) \
cin >> a[i];
#define mod(i) ((i) % (ll)(1e9 + 7))
#define divm(a, b) (mod(a * modpow((ll)b, (ll)(1e9 + 5))))
#define rsort(a, b, c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v, c) sort(v.begin(), v.end(), greater<c>())
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a, n, k) (lower_bound(a, a + n, k) - a)
#define vlb(a, k) (lower_bound(a.begin(), a.end(), k) - a.begin())
#define ub(a, n, k) (upper_bound(a, a + n, k) - a)
#define vub(a, k) (upper_bound(a.begin(), a.end(), k) - a.begin())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define ret return
ll modpow(ll i, ll j) {
ll tmp = 1;
while (j) {
if (j % 2)
tmp = mod(tmp * i);
i = mod(i * i);
j /= 2;
}
return tmp;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
vector<string> split(const string &str, char sep) {
vector<string> v;
stringstream ss(str);
string buffer;
while (getline(ss, buffer, sep)) {
v.push_back(buffer);
}
return v;
}
// ll ncr[100][100];
// ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1;
// if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] =
// nCr(n-1,r) + nCr(n-1,r-1);}
// ll npr[100][100]={};
// ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] =
// 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}
// ll nHr(int n,int r){ret nCr(n+r-1,r);}
///////////////////////////////////////////////////////////////////////////
int h, w;
string s[500];
int d[500][500] = {};
ll f(int x, int y, int xx, int yy) {
queue<pair<int, int>> q;
q.push(make_pair(x, y));
d[y][x] = 1;
ll bc = 1, wc = 0;
while (!q.empty()) {
pair<int, int> now = q.front();
q.pop();
rep(i, 0, 4) {
int nx = now.ft + dx[i], ny = now.sd + dy[i];
if (0 <= nx && nx < w && 0 <= ny && ny < h) {
if (s[now.sd][now.ft] != s[ny][nx] && d[ny][nx] == 0) {
d[ny][nx] = 1;
q.push(make_pair(nx, ny));
if (s[ny][nx] == '.')
wc++;
else
bc++;
}
}
}
}
// PS(bc);P(wc);
return bc * wc;
}
int main() {
cin >> h >> w;
inrep(h, s);
ll ans = 0;
rep(i, 0, h) {
rep(j, 0, w) {
if (s[i][j] == '#' && d[i][j] == 0) {
ans += f(j, i, j, i);
}
}
}
P(ans);
return 0;
}
| [
"variable_declaration.type.change"
] | 951,501 | 951,502 | u254521846 | cpp |
p03158 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll a[100001];
ll s[100001], s1[100001];
int f1(ll x, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
if (a[mid] >= x) {
int lans = f1(x, st, mid - 1);
if (lans == -1)
return mid;
return lans;
}
return f1(x, mid + 1, end);
}
int f2(ll x, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
if (a[mid] <= x) {
int rans = f2(x, mid + 1, end);
if (rans == -1)
return mid;
return rans;
}
return f2(x, st, mid - 1);
}
int f3(ll x, ll diff, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
ll d = x - a[mid];
if (d <= diff) {
int lans = f3(x, diff, st, mid - 1);
if (lans == -1)
return mid;
return lans;
}
return f3(x, diff, mid + 1, end);
}
int f(ll x, int st, int end, int in2, int in1) {
// cout<<st<<" "<<end<<"\n";
if (st > end)
return -1;
int mid = (st + end) / 2;
ll d1 = a[mid] - x;
ll d2 = 1e14;
if (mid < n - 1)
d2 = a[mid + 1] - x;
int in31 = f3(x, d1, 0, in2);
int in32 = f3(x, d2, 0, in2);
int c1 = n - 1 - mid;
int a1 = mid - in1 + 1;
if (in31 != -1) {
a1 += in2 - in31 + 1;
}
int a2 = mid - in1 + 1;
if (in32 != -1) {
a2 += in2 - in32 + 1;
}
// cout<<a1<<" "<<a2<<"\n";
if ((c1 >= a1 && c1 <= a2) || (c1 - 1 >= a1 && c1 - 1 <= a2))
return mid;
if (a2 < c1)
return f(x, mid + 1, end, in2, in1);
else
return f(x, st, mid - 1, in2, in1);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int q;
cin >> n >> q;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++) {
s[i] = a[i];
if (i != 0)
s[i] += s[i - 1];
}
for (int i = 0; i < n; i++) {
if (i % 2 == 0)
s1[i] = a[i];
if (i > 0)
s1[i] += s1[i - 1];
}
while (q--) {
ll x;
cin >> x;
int in1 = f1(x, 0, n - 1);
if (in1 == -1) {
if (n % 2 == 0)
cout << s[n - 1] - s1[n - 1] << "\n";
else
cout << s1[n - 1] << "\n";
continue;
}
// cout<<in1<<"\n";
int in2 = f2(x, 0, n - 1);
// cout<<in2<<"\n";
if (in1 == in2)
in2--;
int in3 = f(x, in1, n - 1, in2, in1);
// cout<<in3<<"\n";
if (in3 == -1) {
int c1 = n - in1;
int r = in2 + 1 - c1;
ll g = s[n - 1];
ll h = 0;
if (in1 > 1)
h = s[in1 - 1];
if (r <= 0) {
// cout<<"oewiehfwef";
cout << g - h << "\n";
} else {
int num = n - 2 * c1;
if (num % 2 == 0)
cout << s[num - 1] - s1[num - 1] + g - h << "\n";
else
cout << s1[num - 1] + g - h << "\n";
}
continue;
} else {
ll g = s[n - 1];
ll h = 0;
if (in3 + 1 >= 1)
h = s[in3 + 1 - 1];
ll c1 = n - in3 - 1;
ll r = in3 - c1 + 1;
if (r <= 0) {
// cout<<"ewehf";
cout << g - h << "\n";
} else {
int num = n - 2 * c1;
if (num % 2 == 0)
cout << s[num - 1] - s1[num - 1] + g - h << "\n";
else
cout << s1[num - 1] + g - h << "\n";
}
continue;
}
}
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll a[100001];
ll s[100001], s1[100001];
int f1(ll x, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
if (a[mid] >= x) {
int lans = f1(x, st, mid - 1);
if (lans == -1)
return mid;
return lans;
}
return f1(x, mid + 1, end);
}
int f2(ll x, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
if (a[mid] <= x) {
int rans = f2(x, mid + 1, end);
if (rans == -1)
return mid;
return rans;
}
return f2(x, st, mid - 1);
}
int f3(ll x, ll diff, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
ll d = x - a[mid];
if (d <= diff) {
int lans = f3(x, diff, st, mid - 1);
if (lans == -1)
return mid;
return lans;
}
return f3(x, diff, mid + 1, end);
}
int f(ll x, int st, int end, int in2, int in1) {
// cout<<st<<" "<<end<<"\n";
if (st > end)
return -1;
int mid = (st + end) / 2;
ll d1 = a[mid] - x;
ll d2 = 1e14;
if (mid < n - 1)
d2 = a[mid + 1] - x;
int in31 = f3(x, d1, 0, in2);
int in32 = f3(x, d2, 0, in2);
int c1 = n - 1 - mid;
int a1 = mid - in1 + 1;
if (in31 != -1) {
a1 += in2 - in31 + 1;
}
int a2 = mid - in1 + 1;
if (in32 != -1) {
a2 += in2 - in32 + 1;
}
// cout<<a1<<" "<<a2<<"\n";
if ((c1 >= a1 && c1 <= a2) || (c1 - 1 >= a1 && c1 - 1 <= a2))
return mid;
if (a2 < c1)
return f(x, mid + 1, end, in2, in1);
else
return f(x, st, mid - 1, in2, in1);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int q;
cin >> n >> q;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++) {
s[i] = a[i];
if (i != 0)
s[i] += s[i - 1];
}
for (int i = 0; i < n; i++) {
if (i % 2 == 0)
s1[i] = a[i];
if (i > 0)
s1[i] += s1[i - 1];
}
while (q--) {
ll x;
cin >> x;
int in1 = f1(x, 0, n - 1);
if (in1 == -1) {
if (n % 2 == 0)
cout << s[n - 1] - s1[n - 1] << "\n";
else
cout << s1[n - 1] << "\n";
continue;
}
// cout<<in1<<"\n";
int in2 = f2(x, 0, n - 1);
// cout<<in2<<"\n";
if (in1 == in2)
in2--;
int in3 = f(x, in1, n - 1, in2, in1);
// cout<<in3<<"\n";
if (in3 == -1) {
int c1 = n - in1;
int r = in2 + 1 - c1;
ll g = s[n - 1];
ll h = 0;
if (in1 >= 1)
h = s[in1 - 1];
if (r <= 0) {
// cout<<"oewiehfwef";
cout << g - h << "\n";
} else {
int num = n - 2 * c1;
if (num % 2 == 0)
cout << s[num - 1] - s1[num - 1] + g - h << "\n";
else
cout << s1[num - 1] + g - h << "\n";
}
continue;
} else {
ll g = s[n - 1];
ll h = 0;
if (in3 + 1 >= 1)
h = s[in3 + 1 - 1];
ll c1 = n - in3 - 1;
ll r = in3 - c1 + 1;
if (r <= 0) {
// cout<<"ewehf";
cout << g - h << "\n";
} else {
int num = n - 2 * c1;
if (num % 2 == 0)
cout << s[num - 1] - s1[num - 1] + g - h << "\n";
else
cout << s1[num - 1] + g - h << "\n";
}
continue;
}
}
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 951,525 | 951,526 | u825143564 | cpp |
p03158 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll a[100001];
ll s[100001], s1[100001];
int f1(ll x, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
if (a[mid] >= x) {
int lans = f1(x, st, mid - 1);
if (lans == -1)
return mid;
return lans;
}
return f1(x, mid + 1, end);
}
int f2(ll x, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
if (a[mid] <= x) {
int rans = f2(x, mid + 1, end);
if (rans == -1)
return mid;
return rans;
}
return f2(x, st, mid - 1);
}
int f3(ll x, ll diff, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
ll d = x - a[mid];
if (d <= diff) {
int lans = f3(x, diff, st, mid - 1);
if (lans == -1)
return mid;
return lans;
}
return f3(x, diff, mid + 1, end);
}
int f(ll x, int st, int end, int in2, int in1) {
if (st > end)
return -1;
int mid = (st + end) / 2;
ll d1 = a[mid] - x;
ll d2 = 1e14;
if (mid < n - 1)
d2 = a[mid + 1] - x;
int in31 = f3(x, d1, 0, in2);
int in32 = f3(x, d2, 0, in2);
int c1 = n - 1 - mid;
int a1 = mid - in1 + 1;
if (in31 != -1) {
a1 += in2 - in31 + 1;
}
int a2 = mid - in1 + 1;
if (in32 != -1) {
a2 += in2 - in32 + 1;
}
if ((c1 >= a1 && c1 <= a2) || (c1 - 1 >= a1 && c1 - 1 <= a2))
return mid;
if (a2 < c1)
return f(x, mid + 1, end, in2, in1);
else
return f(x, st, mid - 1, in2, in1);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int q;
cin >> n >> q;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++) {
s[i] = a[i];
if (i != 0)
s[i] += s[i - 1];
}
for (int i = 0; i < n; i++) {
if (i % 2 == 0)
s1[i] = a[i];
if (i > 0)
s1[i] += s1[i - 1];
}
while (q--) {
ll x;
cin >> x;
int in1 = f1(x, 0, n - 1);
if (in1 == -1) {
if (n % 2 == 0)
cout << s[n - 1] - s1[n - 1] << "\n";
else
cout << s1[n - 1] << "\n";
continue;
}
// cout<<in1<<"\n";
int in2 = f2(x, 0, n - 1);
// cout<<in2<<"\n";
if (in1 == in2)
in2--;
int in3 = f(x, in1, n - 1, in2, in1);
// cout<<in3<<"\n";
if (in3 == -1) {
int c1 = n - in1;
int r = in2 + 1 - c1;
ll g = s[n - 1];
ll h = 0;
if (in1 > 1)
h = s[in1 - 1];
if (r <= 0) {
cout << g - h << "\n";
} else {
int num = n - 2 * c1;
if (num % 2 == 0)
cout << s[num - 1] - s1[num - 1] + g - h << "\n";
else
cout << s1[num - 1] + g - h << "\n";
}
continue;
} else {
ll g = s[n - 1];
ll h = 0;
if (in3 + 1 > 1)
h = s[in3 + 1 - 1];
ll c1 = n - in3 - 1;
ll r = in3 - c1 + 1;
if (r <= 0) {
cout << g - h << "\n";
} else {
int num = n - 2 * c1;
if (num % 2 == 0)
cout << s[num - 1] - s1[num - 1] + g - h << "\n";
else
cout << s1[num - 1] + g - h << "\n";
}
continue;
}
}
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll a[100001];
ll s[100001], s1[100001];
int f1(ll x, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
if (a[mid] >= x) {
int lans = f1(x, st, mid - 1);
if (lans == -1)
return mid;
return lans;
}
return f1(x, mid + 1, end);
}
int f2(ll x, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
if (a[mid] <= x) {
int rans = f2(x, mid + 1, end);
if (rans == -1)
return mid;
return rans;
}
return f2(x, st, mid - 1);
}
int f3(ll x, ll diff, int st, int end) {
if (st > end)
return -1;
int mid = (st + end) / 2;
ll d = x - a[mid];
if (d <= diff) {
int lans = f3(x, diff, st, mid - 1);
if (lans == -1)
return mid;
return lans;
}
return f3(x, diff, mid + 1, end);
}
int f(ll x, int st, int end, int in2, int in1) {
// cout<<st<<" "<<end<<"\n";
if (st > end)
return -1;
int mid = (st + end) / 2;
ll d1 = a[mid] - x;
ll d2 = 1e14;
if (mid < n - 1)
d2 = a[mid + 1] - x;
int in31 = f3(x, d1, 0, in2);
int in32 = f3(x, d2, 0, in2);
int c1 = n - 1 - mid;
int a1 = mid - in1 + 1;
if (in31 != -1) {
a1 += in2 - in31 + 1;
}
int a2 = mid - in1 + 1;
if (in32 != -1) {
a2 += in2 - in32 + 1;
}
// cout<<a1<<" "<<a2<<"\n";
if ((c1 >= a1 && c1 <= a2) || (c1 - 1 >= a1 && c1 - 1 <= a2))
return mid;
if (a2 < c1)
return f(x, mid + 1, end, in2, in1);
else
return f(x, st, mid - 1, in2, in1);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int q;
cin >> n >> q;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++) {
s[i] = a[i];
if (i != 0)
s[i] += s[i - 1];
}
for (int i = 0; i < n; i++) {
if (i % 2 == 0)
s1[i] = a[i];
if (i > 0)
s1[i] += s1[i - 1];
}
while (q--) {
ll x;
cin >> x;
int in1 = f1(x, 0, n - 1);
if (in1 == -1) {
if (n % 2 == 0)
cout << s[n - 1] - s1[n - 1] << "\n";
else
cout << s1[n - 1] << "\n";
continue;
}
// cout<<in1<<"\n";
int in2 = f2(x, 0, n - 1);
// cout<<in2<<"\n";
if (in1 == in2)
in2--;
int in3 = f(x, in1, n - 1, in2, in1);
// cout<<in3<<"\n";
if (in3 == -1) {
int c1 = n - in1;
int r = in2 + 1 - c1;
ll g = s[n - 1];
ll h = 0;
if (in1 >= 1)
h = s[in1 - 1];
if (r <= 0) {
// cout<<"oewiehfwef";
cout << g - h << "\n";
} else {
int num = n - 2 * c1;
if (num % 2 == 0)
cout << s[num - 1] - s1[num - 1] + g - h << "\n";
else
cout << s1[num - 1] + g - h << "\n";
}
continue;
} else {
ll g = s[n - 1];
ll h = 0;
if (in3 + 1 >= 1)
h = s[in3 + 1 - 1];
ll c1 = n - in3 - 1;
ll r = in3 - c1 + 1;
if (r <= 0) {
// cout<<"ewehf";
cout << g - h << "\n";
} else {
int num = n - 2 * c1;
if (num % 2 == 0)
cout << s[num - 1] - s1[num - 1] + g - h << "\n";
else
cout << s1[num - 1] + g - h << "\n";
}
continue;
}
}
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 951,527 | 951,526 | u825143564 | cpp |
p03158 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n, q;
cin >> n >> q;
int a[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
long long psr[n + 2], ps2[n + 1];
ps2[0] = 0, ps2[1] = a[1];
for (int i = 2; i <= n; i++) {
ps2[i] = ps2[i - 2] + a[i];
}
psr[n + 1] = 0;
for (int i = n; i > 0; i--) {
psr[i] = psr[i + 1] + a[i];
}
for (int i = 0; i < q; i++) {
int x;
cin >> x;
int l = 1, r = n + 1;
while (r - l > 1) {
int mid = (l + r) / 2;
int l2 = 2 * mid - 1 - n;
int r2 = mid - 1;
if (l2 < 1) {
l = mid;
} else if (a[l2 - 1] > x) {
r = mid;
} else if (a[r2] < x) {
l = mid;
} else if (x - a[l2 - 1] <= a[r2] - x) {
r = mid;
} else {
l = mid;
}
}
cout << psr[l] + (l * 2 - n - 2 > 0 ? ps2[l * 2 - n - 2] : 0) << endl;
}
return 0;
}
| #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n, q;
cin >> n >> q;
int a[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
long long psr[n + 2], ps2[n + 1];
ps2[0] = 0, ps2[1] = a[1];
for (int i = 2; i <= n; i++) {
ps2[i] = ps2[i - 2] + a[i];
}
psr[n + 1] = 0;
for (int i = n; i > 0; i--) {
psr[i] = psr[i + 1] + a[i];
}
for (int i = 0; i < q; i++) {
int x;
cin >> x;
int l = 1, r = n + 1;
while (r - l > 1) {
int mid = (l + r) / 2;
int l2 = 2 * mid - 1 - n;
int r2 = mid - 1;
if (l2 <= 1) {
l = mid;
} else if (a[l2 - 1] > x) {
r = mid;
} else if (a[r2] < x) {
l = mid;
} else if (x - a[l2 - 1] <= a[r2] - x) {
r = mid;
} else {
l = mid;
}
}
cout << psr[l] + (l * 2 - n - 2 > 0 ? ps2[l * 2 - n - 2] : 0) << endl;
}
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 951,550 | 951,551 | u587665681 | cpp |
p03158 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
ll sum[100010];
vector<ll> sum1;
vector<ll> sum2;
int n;
bool ok(int num, int x) {
ll aa = a[n - num * 2 + 1];
// int bb = a[n - num - 1];
// int cc = a[n - num * 2 - 1];
ll dd = a[n - num];
return (ll)x - aa <= dd - (ll)x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
int q;
cin >> q;
sum1.push_back(0LL);
sum2.push_back(0LL);
for (int i = 0; i < n; i++) {
cin >> a[i];
if (i & 1) {
sum2.push_back(a[i]);
} else {
sum1.push_back(a[i]);
}
}
for (int i = 1; i <= n; i++) {
sum[i] = a[i - 1];
sum[i] += sum[i - 1];
}
for (int i = 1; i < sum1.size(); i++) {
sum1[i] += sum1[i - 1];
}
for (int i = 1; i < sum2.size(); i++) {
sum2[i] += sum2[i - 1];
}
int aoki = n / 2, taka = n - aoki;
while (q--) {
int x;
cin >> x;
ll midr = a[aoki];
if (x <= midr && midr - x >= x - a[0]) {
cout << sum[n] - sum[aoki] << endl;
continue;
}
int ret = 0;
for (int i = 20; i >= 0; i--) {
if ((ret + (1 << i)) * 2 >= n)
continue;
ll left = a[n - (ret + (1 << i)) * 2];
ll right = a[n - (ret + (1 << i))];
if (x < left) {
ret += (1 << i);
continue;
}
if (x > right)
continue;
if (ok(ret + (1 << i), x))
ret += (1 << i);
}
ll ans = 0;
ans += sum[n] - sum[n - ret];
// cout << "ret " << ret << endl;
// cout << "a " << ans << endl;
int k = n - ret * 2;
k /= 2;
if (n & 1)
k++;
if (n & 1)
ans += sum1[k];
else
ans += sum2[k];
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
ll sum[100010];
vector<ll> sum1;
vector<ll> sum2;
int n;
bool ok(int num, int x) {
ll aa = a[n - num * 2 + 1];
// int bb = a[n - num - 1];
// int cc = a[n - num * 2 - 1];
ll dd = a[n - num];
return (ll)x - aa <= dd - (ll)x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
int q;
cin >> q;
sum1.push_back(0LL);
sum2.push_back(0LL);
for (int i = 0; i < n; i++) {
cin >> a[i];
if (i & 1) {
sum2.push_back(a[i]);
} else {
sum1.push_back(a[i]);
}
}
for (int i = 1; i <= n; i++) {
sum[i] = a[i - 1];
sum[i] += sum[i - 1];
}
for (int i = 1; i < sum1.size(); i++) {
sum1[i] += sum1[i - 1];
}
for (int i = 1; i < sum2.size(); i++) {
sum2[i] += sum2[i - 1];
}
int aoki = n / 2, taka = n - aoki;
while (q--) {
int x;
cin >> x;
ll midr = a[aoki];
if (x <= midr && midr - x >= x - a[0]) {
cout << sum[n] - sum[aoki] << endl;
continue;
}
int ret = 0;
for (int i = 20; i >= 0; i--) {
if ((ret + (1 << i)) * 2 > n)
continue;
ll left = a[n - (ret + (1 << i)) * 2];
ll right = a[n - (ret + (1 << i))];
if (x < left) {
ret += (1 << i);
continue;
}
if (x > right)
continue;
if (ok(ret + (1 << i), x))
ret += (1 << i);
}
ll ans = 0;
ans += sum[n] - sum[n - ret];
// cout << "ret " << ret << endl;
// cout << "a " << ans << endl;
int k = n - ret * 2;
k /= 2;
if (n & 1)
k++;
if (n & 1)
ans += sum1[k];
else
ans += sum2[k];
cout << ans << endl;
}
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 951,560 | 951,561 | u891178744 | cpp |
p03158 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
ll sum[100010];
vector<ll> sum1;
vector<ll> sum2;
int n;
bool ok(int num, int x) {
ll aa = a[n - num * 2 + 1];
// int bb = a[n - num - 1];
// int cc = a[n - num * 2 - 1];
ll dd = a[n - num];
return (ll)x - aa <= dd - (ll)x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
int q;
cin >> q;
sum1.push_back(0LL);
sum2.push_back(0LL);
for (int i = 0; i < n; i++) {
cin >> a[i];
if (i & 1) {
sum2.push_back(a[i]);
} else {
sum1.push_back(a[i]);
}
}
for (int i = 1; i <= n; i++) {
sum[i] = a[i - 1];
sum[i] += sum[i - 1];
}
for (int i = 1; i < sum1.size(); i++) {
sum1[i] += sum1[i - 1];
}
for (int i = 1; i < sum2.size(); i++) {
sum2[i] += sum2[i - 1];
}
int aoki = n / 2, taka = n - aoki;
while (q--) {
int x;
cin >> x;
int midr = a[aoki];
if (x <= midr && midr - x >= x - a[0]) {
cout << sum[n] - sum[aoki] << endl;
continue;
}
int ret = 0;
for (int i = 20; i >= 0; i--) {
if ((ret + (1 << i)) * 2 >= n)
continue;
int left = a[n - (ret + (1 << i)) * 2];
int right = a[n - (ret + (1 << i))];
if (x < left) {
ret += (1 << i);
continue;
}
if (x > right)
continue;
if (ok(ret + (1 << i), x))
ret += (1 << i);
}
ll ans = 0;
ans += sum[n] - sum[n - ret];
// cout << "ret " << ret << endl;
// cout << "a " << ans << endl;
int k = n - ret * 2;
k /= 2;
if (n & 1)
k++;
if (n & 1)
ans += sum1[k];
else
ans += sum2[k];
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
ll sum[100010];
vector<ll> sum1;
vector<ll> sum2;
int n;
bool ok(int num, int x) {
ll aa = a[n - num * 2 + 1];
// int bb = a[n - num - 1];
// int cc = a[n - num * 2 - 1];
ll dd = a[n - num];
return (ll)x - aa <= dd - (ll)x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
int q;
cin >> q;
sum1.push_back(0LL);
sum2.push_back(0LL);
for (int i = 0; i < n; i++) {
cin >> a[i];
if (i & 1) {
sum2.push_back(a[i]);
} else {
sum1.push_back(a[i]);
}
}
for (int i = 1; i <= n; i++) {
sum[i] = a[i - 1];
sum[i] += sum[i - 1];
}
for (int i = 1; i < sum1.size(); i++) {
sum1[i] += sum1[i - 1];
}
for (int i = 1; i < sum2.size(); i++) {
sum2[i] += sum2[i - 1];
}
int aoki = n / 2, taka = n - aoki;
while (q--) {
int x;
cin >> x;
ll midr = a[aoki];
if (x <= midr && midr - x >= x - a[0]) {
cout << sum[n] - sum[aoki] << endl;
continue;
}
int ret = 0;
for (int i = 20; i >= 0; i--) {
if ((ret + (1 << i)) * 2 > n)
continue;
ll left = a[n - (ret + (1 << i)) * 2];
ll right = a[n - (ret + (1 << i))];
if (x < left) {
ret += (1 << i);
continue;
}
if (x > right)
continue;
if (ok(ret + (1 << i), x))
ret += (1 << i);
}
ll ans = 0;
ans += sum[n] - sum[n - ret];
// cout << "ret " << ret << endl;
// cout << "a " << ans << endl;
int k = n - ret * 2;
k /= 2;
if (n & 1)
k++;
if (n & 1)
ans += sum1[k];
else
ans += sum2[k];
cout << ans << endl;
}
return 0;
}
| [
"variable_declaration.type.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 951,562 | 951,561 | u891178744 | cpp |
p03158 | #include <cstdint>
#include <iostream>
using namespace std; // 575
const int MAX = 100001;
int main() {
int N, Q;
static int A[MAX], X;
cin >> N >> Q;
for (int i = 0; i < N; ++i)
cin >> A[i];
static int64_t sum = 0;
static pair<int, int64_t> ans[MAX];
for (int i = N / 2; i < N; ++i)
sum += A[i];
ans[0] = make_pair(0, sum);
for (int i = 0, l = (N + 1) % 2, r = N / 2; r < N;
++i, l += 2, ++r) { // 区間(l, r]ですね
ans[i + 1] = make_pair(A[l] + (A[r] - A[l] + 1) / 2, sum -= A[r] - A[l]);
}
for (int i = 0, min, mid, max, halfDiff; i < Q; ++i) {
min = 0;
max = (N + 3) / 2;
cin >> X;
while (halfDiff = max - min >> 1)
(ans[mid = min + halfDiff].first <= X ? min : max) = mid;
cout << ans[min].second << endl;
}
return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/
で解説していると思うので、良かったら読んでねー
*/ | #include <cstdint>
#include <iostream>
using namespace std; // 575
const int MAX = 100001;
int main() {
int N, Q;
static int A[MAX], X;
cin >> N >> Q;
for (int i = 0; i < N; ++i)
cin >> A[i];
static int64_t sum = 0;
static pair<int, int64_t> ans[MAX];
for (int i = N / 2; i < N; ++i)
sum += A[i];
ans[0] = make_pair(0, sum);
for (int i = 0, l = (N + 1) % 2, r = N / 2; r < N;
++i, l += 2, ++r) { // 区間(l, r]ですね
ans[i + 1] = make_pair(A[l] + (A[r] - A[l]) / 2, sum -= A[r] - A[l]);
}
for (int i = 0, min, mid, max, halfDiff; i < Q; ++i) {
min = 0;
max = (N + 3) / 2;
cin >> X;
while (halfDiff = max - min >> 1)
(ans[mid = min + halfDiff].first < X ? min : max) = mid;
cout << ans[min].second << endl;
}
return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/
で解説していると思うので、良かったら読んでねー
O(N+QlogX)
*/ | [
"expression.operation.binary.remove",
"expression.operator.compare.change",
"assignment.variable.change",
"control_flow.loop.condition.change"
] | 951,569 | 951,567 | u550314572 | cpp |
p03158 | #include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
const int N = 200005;
int n, q;
long long a[N], x;
long long p[N], s[N];
long long l, r;
int get(long long x, int k) {
if (!k)
return n;
int l = 1;
int r = n - k + 1;
while (l < r) {
int mid = (l + r + 1) >> 1;
if (x >= a[mid]) {
if (x - a[mid - 1] < a[mid + k - 1] - x)
r = mid - 1;
else
l = mid;
} else if (a[mid - 1] < x && abs(x - a[mid - 1]) > abs(a[mid + k - 1] - x))
l = mid;
else
r = mid - 1;
}
return r + k - 1;
}
int main() {
scanf("%d%d", &n, &q);
for (int i = 1; i <= n; i++) {
scanf("%lld", &a[i]);
s[i] = s[i - 1] + a[i];
}
for (int i = 1; i <= n; i++)
if ((n ^ i) & 1)
p[i] = p[i - 1] + a[i];
else
p[i] = p[i - 1];
while (q--) {
scanf("%lld", &x);
l = 0;
r = n / 2;
while (l < r) {
int mid = (l + r + 1) >> 1;
if (get(x, mid) < n - mid + 1)
l = mid;
else
r = mid - 1;
}
int c = get(x, r);
printf("%lld\n", s[n] - (s[c] - s[c - r] + p[c - r]));
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
const int N = 200005;
int n, q;
long long a[N], x;
long long p[N], s[N];
long long l, r;
int get(long long x, int k) {
if (!k)
return n;
int l = 1;
int r = n - k + 1;
while (l < r) {
int mid = (l + r + 1) >> 1;
if (x >= a[mid]) {
if (x - a[mid - 1] <= a[mid + k - 1] - x)
r = mid - 1;
else
l = mid;
} else if (a[mid - 1] < x && abs(x - a[mid - 1]) > abs(a[mid + k - 1] - x))
l = mid;
else
r = mid - 1;
}
return r + k - 1;
}
int main() {
scanf("%d%d", &n, &q);
for (int i = 1; i <= n; i++) {
scanf("%lld", &a[i]);
s[i] = s[i - 1] + a[i];
}
for (int i = 1; i <= n; i++)
if ((n ^ i) & 1)
p[i] = p[i - 1] + a[i];
else
p[i] = p[i - 1];
while (q--) {
scanf("%lld", &x);
l = 0;
r = n / 2;
while (l < r) {
int mid = (l + r + 1) >> 1;
if (get(x, mid) < n - mid + 1)
l = mid;
else
r = mid - 1;
}
int c = get(x, r);
printf("%lld\n", s[n] - (s[c] - s[c - r] + p[c - r]));
}
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 951,608 | 951,609 | u639225163 | cpp |
p03158 | #include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int main() {
int N, Q;
cin >> N >> Q;
vector<int> A(N);
for (int i = 0; i < N; ++i)
cin >> A[i];
vector<pair<int, int>> X;
for (int i = 0; i < Q; ++i) {
int x;
cin >> x;
X.emplace_back(x, i);
}
sort(X.begin(), X.end());
long long s = 0;
for (int i = N / 2; i < N; ++i)
s += A[i];
vector<long long> ans(Q);
int l = 0, r = N / 2;
long long c[] = {0, 0};
for (int i = 0; i < Q; ++i) {
int x = X[i].first, id = X[i].second;
while (r < N and abs(x - A[l]) > abs(x - A[r])) {
c[l % 2] += A[l];
s -= A[r];
++l, ++r;
}
// cerr << x << " " << A[l] << " " << A[r] << endl;
while (N - r < r - l) {
if (abs(A[l] - x) < abs(x - A[r - 1])) {
c[l % 2] += A[l];
++l;
} else {
s += A[r - 1];
--r;
}
}
// cerr << x << " " << A[l] << " " << A[r] << endl;
// cerr << c[0] << " " << c[1] << endl;
ans[id] = s + c[1 - N % 2];
}
for (int i = 0; i < Q; ++i)
cout << ans[i] << endl;
}
| #include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int main() {
int N, Q;
cin >> N >> Q;
vector<int> A(N);
for (int i = 0; i < N; ++i)
cin >> A[i];
vector<pair<int, int>> X;
for (int i = 0; i < Q; ++i) {
int x;
cin >> x;
X.emplace_back(x, i);
}
sort(X.begin(), X.end());
long long s = 0;
for (int i = N / 2; i < N; ++i)
s += A[i];
vector<long long> ans(Q);
int l = 0, r = N / 2;
long long c[] = {0, 0};
for (int i = 0; i < Q; ++i) {
int x = X[i].first, id = X[i].second;
while (r < N and abs(x - A[l]) > abs(x - A[r])) {
c[l % 2] += A[l];
s -= A[r];
++l, ++r;
}
// cerr << x << " " << A[l] << " " << A[r] << endl;
while (N - r < r - l) {
if (abs(A[l] - x) > abs(x - A[r - 1])) {
c[l % 2] += A[l];
++l;
} else {
s += A[r - 1];
--r;
}
}
// cerr << N-r << " " << r-l << endl;
// if(N-r > r-l and l > 0) --l, c[l%2] -= A[l];
// cerr << x << " " << A[l] << " " << A[r] << endl;
// cerr << c[0] << " " << c[1] << endl;
ans[id] = s + c[1 - N % 2];
}
for (int i = 0; i < Q; ++i)
cout << ans[i] << endl;
}
| [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 951,612 | 951,613 | u107077660 | cpp |
p03158 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;
template <class T> inline bool chmax(T &a, const T &b) {
if (b > a) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
void solve() {
int N, Q;
cin >> N >> Q;
vector<int> a(N), x(Q);
for (int i = 0; i < N; ++i)
cin >> a[i];
for (int i = 0; i < Q; ++i)
cin >> x[i];
vector<ll> sum(N + 1), sumtaka(N + 1);
for (int i = 1; i < N + 1; ++i)
sum[i] = sum[i - 1] + a[i - 1];
for (int i = 1; i < N + 1; ++i) {
sumtaka[i] = sumtaka[i - 1];
if (N % 2 == i % 2)
sumtaka[i] += a[i - 1];
}
for (int i = 0; i < Q; ++i) {
int cur = x[i];
int ok = N / 2, ng = -1;
while (abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (abs(cur - a[N - mid - 1]) < abs(cur - a[N - mid * 2 - 1]))
ok = mid;
else
ng = mid;
}
if (N % 2 == 1 && ok == N / 2 && abs(cur - a[0]) <= abs(cur - a[N / 2 + 1]))
cout << sum[N] - sum[N / 2] << '\n';
else
cout << sum[N] - sum[N - ok] + sumtaka[N - 2 * ok] << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
solve();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;
template <class T> inline bool chmax(T &a, const T &b) {
if (b > a) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
void solve() {
int N, Q;
cin >> N >> Q;
vector<int> a(N), x(Q);
for (int i = 0; i < N; ++i)
cin >> a[i];
for (int i = 0; i < Q; ++i)
cin >> x[i];
vector<ll> sum(N + 1), sumtaka(N + 1);
for (int i = 1; i < N + 1; ++i)
sum[i] = sum[i - 1] + a[i - 1];
for (int i = 1; i < N + 1; ++i) {
sumtaka[i] = sumtaka[i - 1];
if (N % 2 == i % 2)
sumtaka[i] += a[i - 1];
}
for (int i = 0; i < Q; ++i) {
int cur = x[i];
int ok = N / 2, ng = -1;
while (abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (abs(cur - a[N - mid - 1]) < abs(cur - a[N - mid * 2 - 1]))
ok = mid;
else
ng = mid;
}
if (N % 2 == 1 && ok == N / 2 && abs(cur - a[0]) <= abs(cur - a[N / 2]))
cout << sum[N] - sum[N / 2] << '\n';
else
cout << sum[N] - sum[N - ok] + sumtaka[N - 2 * ok] << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
solve();
return 0;
}
| [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 951,679 | 951,680 | u324549724 | cpp |
p03158 | #include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define REP(i, s, t) for (int i = s; i <= t; i++)
#define RREP(i, s, t) for (int i = s; i >= t; i--)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
vector<P> v;
signed main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int N, Q;
cin >> N >> Q;
int A[100010];
rep(i, N) cin >> A[i];
int sum = 0;
int S = 0;
rep(i, N) S += A[i];
rep(i, N / 2) sum += A[i];
int L = 0, R = N / 2;
while (R < N) {
int tmp = (A[L] + A[R]) / 2;
// cout << tmp << " " << sum << endl;
v.push_back({tmp, sum});
sum -= A[L], sum += A[R];
L += 2, R += 1;
}
while (Q--) {
int X;
cin >> X;
P p = {X, 0};
auto itr = upper_bound(v.begin(), v.end(), p);
if (itr == v.end())
itr--;
cout << S - itr->second << endl;
// cout << itr->first << " " << S - itr->second << endl;
}
return 0;
}
| #include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define REP(i, s, t) for (int i = s; i <= t; i++)
#define RREP(i, s, t) for (int i = s; i >= t; i--)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
vector<P> v;
signed main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int N, Q;
cin >> N >> Q;
int A[100010];
rep(i, N) cin >> A[i];
int sum = 0;
int S = 0;
rep(i, N) S += A[i];
rep(i, N / 2) sum += A[i];
int L = N % 2 == 0, R = N / 2;
while (R < N) {
int tmp = (A[L] + A[R]) / 2;
// cout << tmp << " " << sum << endl;
v.push_back({tmp, sum});
sum -= A[L], sum += A[R];
L += 2, R += 1;
}
while (Q--) {
int X;
cin >> X;
P p = {X, 0};
auto itr = upper_bound(v.begin(), v.end(), p);
if (itr == v.end())
itr--;
cout << S - itr->second << endl;
// cout << itr->first << " " << S - itr->second << endl;
}
return 0;
}
// X < 5
// 1 2 3 4
// 1 3 5 7 9 11 13 15 17
// . .
// X = 5
// 4 2 1 3
// 1 3 5 7 9 11 13 15 17
// . .
// X = 6
//
// 3 1 2 4
// 1 3 5 7 9 11 13 15 17
// . .
// X = 8
// 4 3 2 1
// 1 3 5 7 9 11 13 15 17
// . .
// X = 9
// 4 2 1 3
// 1 3 5 7 9 11 13 15 17
//
// 4 3 2 1
// 1 3 5 7 9 11 13 15 17
// . .
// 4 3 1 2
// 1 3 5 7 9 11 13 15 17
// 4 3 2 1
// 1 3 5 7 9 11 13 15 17
// 1 2 3
// 2 4 8 16 32 64
// X == 10
// 3 2 1
// 2 4 8 16 32 64
// X == 11
// 3 1 2
// 2 4 8 16 32 64
// . .
// X == 24
// 3 2 1
// 2 4 8 16 32 64
// . .
// X == 25
// 3 2 1
// 2 4 8 16 32 64 | [
"assignment.change"
] | 951,681 | 951,682 | u965730380 | cpp |
p03158 | #include <bits/stdc++.h>
using namespace std;
#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define pb push_back
#define sz(v) ((li)(v).size())
#define bgn(v) ((v).begin())
#define eend(v) ((v).end())
#define allof(v) (v).begin(), (v).end()
#define dodp(v, n) memset(v, (li)n, sizeof(v))
#define bit(n) (1ll << (li)(n))
#define mp(a, b) make_pair(a, b)
#define rin rep(i, n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;
#define INF bit(60)
#define DBGP 1
#define idp if (DBGP)
#define F first
#define S second
#define p2(a, b) idp cout << a << "\t" << b << endl
#define p3(a, b, c) idp cout << a << "\t" << b << "\t" << c << endl
#define p4(a, b, c, d) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << endl
#define p5(a, b, c, d, e) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << endl
#define p6(a, b, c, d, e, f) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" \
<< f << endl
#define p7(a, b, c, d, e, f, g) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" \
<< f << "\t" << g << endl
#define p8(a, b, c, d, e, f, g, h) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" \
<< f << "\t" << g << "\t" << h << endl
#define p9(a, b, c, d, e, f, g, h, i) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" \
<< f << "\t" << g << "\t" << h << "\t" << i << endl
#define p10(a, b, c, d, e, f, g, h, i, j) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" \
<< f << "\t" << g << "\t" << h << "\t" << i << "\t" << j << endl
#define foreach(it, v) \
for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it)
#define p2p(x) idp p2((x).F, (x).S)
#define dump(x, n) \
idp { \
rep(i, n) { cout << x[i] << " "; } \
puts(""); \
}
#define dump2(x, n) \
idp { \
rep(i, n) { cout << "[" << x[i].F << " , " << x[i].S << "] "; } \
puts(""); \
}
#define dumpi(x) \
idp { \
foreach (it, x) { cout << (*it) << " "; } \
puts(""); \
}
#define dumpi2(x) \
idp { \
foreach (it, x) { cout << "[" << (it)->F << " , " << (it)->S << "] "; } \
puts(""); \
}
#define read2d(a, w, h) rep(i, h) rep(j, w) cin >> a[i][j]
#define dump2d(a, w, h) \
rep(i, h) { \
rep(j, w) cout << a[i][j] << " "; \
puts(""); \
}
typedef pair<li, li> PI;
li n, q;
li a[100100];
li x[100100];
li sum_tkhs[100100];
li sum[100100];
inline li chk(li xx, li pos) {
li num_tkhs = n - pos;
li diff = abs(a[pos] - xx);
li min_pos_aoki = pos - num_tkhs;
// 高橋君が過半数取ってる -> おかしいので本当の境目はもっと->寄り
if (min_pos_aoki < 0)
return 1;
if (abs(a[min_pos_aoki + 1] - xx) > diff) {
// min_pos_aoki+1より先にposを取っているはず -> 本当の境目はもっと->より
return 1;
}
// [min_pos_aoki, pos-1] の間よりも先にmin_pos_aoki-1を取ってはダメ ->
// 本当の境目はもっと<-寄り
if (min_pos_aoki > 0 &&
abs(a[min_pos_aoki] - xx) >= abs(a[min_pos_aoki - 1] - xx)) {
return -1;
}
// pos-1よりもmin_pos_aokiのほうを先に見に行ってしまう ->
// 本当の境目はもっと<-寄り
if (min_pos_aoki > 0 &&
abs(a[pos - 1] - xx) >= abs(a[min_pos_aoki - 1] - xx)) {
return -1;
}
return 0;
}
// xxが選ばれた時、上から順に取り合いになるのがどこから始まるか
inline li calc(li xx) {
if (xx >= a[n - 2]) {
return n - 1;
}
// 上から順にみていって、初めて取る人が変わる場所を求める
li l = 0;
li r = n - 1;
while (l + 1 < r) {
li mid = (l + r) / 2;
li val = chk(xx, mid);
// p3(xx, mid, val);
if (val == 0) {
return mid;
} else if (val > 0) {
l = mid;
} else {
r = mid;
}
}
if (chk(xx, l) == 0)
return l;
return r;
}
inline li solve(li xx) {
// 左右くっきり分かれるタイプだけ特殊判定
if (abs(a[0] - xx) <= abs(a[(n + 1) / 2] - xx)) {
return sum[n] - sum[n / 2];
}
// get cutting pos
li pos = calc(xx);
li num_tkhs = n - pos;
// p5("pos", pos, pos - num_tkhs - 1, sum_tkhs[pos - num_tkhs - 1], sum[n] -
// sum[pos]);
return sum_tkhs[pos - num_tkhs - 1] + (sum[n] - sum[pos]);
}
int main() {
cin >> n >> q;
rin { cin >> a[i]; }
sum_tkhs[0] = a[0];
sum_tkhs[1] = a[1];
repp(i, 2, n) { sum_tkhs[i] = sum_tkhs[i - 2] + a[i]; }
sum[0] = 0;
rep(i, n) { sum[i + 1] = sum[i] + a[i]; }
rep(i, q) { cin >> x[i]; }
rep(i, q) { cout << solve(x[i]) << endl; }
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define pb push_back
#define sz(v) ((li)(v).size())
#define bgn(v) ((v).begin())
#define eend(v) ((v).end())
#define allof(v) (v).begin(), (v).end()
#define dodp(v, n) memset(v, (li)n, sizeof(v))
#define bit(n) (1ll << (li)(n))
#define mp(a, b) make_pair(a, b)
#define rin rep(i, n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;
#define INF bit(60)
#define DBGP 1
#define idp if (DBGP)
#define F first
#define S second
#define p2(a, b) idp cout << a << "\t" << b << endl
#define p3(a, b, c) idp cout << a << "\t" << b << "\t" << c << endl
#define p4(a, b, c, d) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << endl
#define p5(a, b, c, d, e) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << endl
#define p6(a, b, c, d, e, f) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" \
<< f << endl
#define p7(a, b, c, d, e, f, g) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" \
<< f << "\t" << g << endl
#define p8(a, b, c, d, e, f, g, h) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" \
<< f << "\t" << g << "\t" << h << endl
#define p9(a, b, c, d, e, f, g, h, i) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" \
<< f << "\t" << g << "\t" << h << "\t" << i << endl
#define p10(a, b, c, d, e, f, g, h, i, j) \
idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" \
<< f << "\t" << g << "\t" << h << "\t" << i << "\t" << j << endl
#define foreach(it, v) \
for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it)
#define p2p(x) idp p2((x).F, (x).S)
#define dump(x, n) \
idp { \
rep(i, n) { cout << x[i] << " "; } \
puts(""); \
}
#define dump2(x, n) \
idp { \
rep(i, n) { cout << "[" << x[i].F << " , " << x[i].S << "] "; } \
puts(""); \
}
#define dumpi(x) \
idp { \
foreach (it, x) { cout << (*it) << " "; } \
puts(""); \
}
#define dumpi2(x) \
idp { \
foreach (it, x) { cout << "[" << (it)->F << " , " << (it)->S << "] "; } \
puts(""); \
}
#define read2d(a, w, h) rep(i, h) rep(j, w) cin >> a[i][j]
#define dump2d(a, w, h) \
rep(i, h) { \
rep(j, w) cout << a[i][j] << " "; \
puts(""); \
}
typedef pair<li, li> PI;
li n, q;
li a[100100];
li x[100100];
li sum_tkhs[100100];
li sum[100100];
inline li chk(li xx, li pos) {
li num_tkhs = n - pos;
li diff = abs(a[pos] - xx);
li min_pos_aoki = pos - num_tkhs;
// 高橋君が過半数取ってる -> おかしいので本当の境目はもっと->寄り
if (min_pos_aoki < 0)
return 1;
if (abs(a[min_pos_aoki + 1] - xx) > diff) {
// min_pos_aoki+1より先にposを取っているはず -> 本当の境目はもっと->より
return 1;
}
// [min_pos_aoki, pos-1] の間よりも先にmin_pos_aoki-1を取ってはダメ ->
// 本当の境目はもっと<-寄り
if (min_pos_aoki > 0 &&
abs(a[min_pos_aoki] - xx) >= abs(a[min_pos_aoki - 1] - xx)) {
return -1;
}
// pos-1よりもmin_pos_aoki-1のほうを先に見に行ってしまう ->
// 本当の境目はもっと<-寄り
if (min_pos_aoki > 0 &&
abs(a[pos - 1] - xx) >= abs(a[min_pos_aoki - 1] - xx)) {
return -1;
}
return 0;
}
// xxが選ばれた時、上から順に取り合いになるのがどこから始まるか
inline li calc(li xx) {
if (xx >= a[n - 2]) {
return n - 1;
}
// 上から順にみていって、初めて取る人が変わる場所を求める
li l = 0;
li r = n - 1;
while (l + 1 < r) {
li mid = (l + r) / 2;
li val = chk(xx, mid);
// p3(xx, mid, val);
if (val == 0) {
return mid;
} else if (val > 0) {
l = mid;
} else {
r = mid;
}
}
if (chk(xx, l) == 0)
return l;
return r;
}
inline li solve(li xx) {
// 左右くっきり分かれるタイプだけ特殊判定
if (abs(a[0] - xx) <= abs(a[(n) / 2] - xx)) {
return sum[n] - sum[n / 2];
}
// get cutting pos
li pos = calc(xx);
li num_tkhs = n - pos;
// p5("pos", pos, pos - num_tkhs - 1, sum_tkhs[pos - num_tkhs - 1], sum[n] -
// sum[pos]);
return sum_tkhs[pos - num_tkhs - 1] + (sum[n] - sum[pos]);
}
int main() {
cin >> n >> q;
rin { cin >> a[i]; }
sum_tkhs[0] = a[0];
sum_tkhs[1] = a[1];
repp(i, 2, n) { sum_tkhs[i] = sum_tkhs[i - 2] + a[i]; }
sum[0] = 0;
rep(i, n) { sum[i + 1] = sum[i] + a[i]; }
rep(i, q) { cin >> x[i]; }
rep(i, q) { cout << solve(x[i]) << endl; }
return 0;
} | [
"expression.operation.binary.remove"
] | 951,687 | 951,688 | u962966398 | cpp |
p03158 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(i, k, n) for (ll i = (ll)(k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define lb(v, k) (lower_bound(all(v), k) - v.begin())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int mod = 1e9 + 7;
const ll inf = 1001001001001001;
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> void out(T a) { cout << a << '\n'; }
template <class T> void outv(T v) {
rep(i, v.size()) {
if (i)
cout << ' ';
cout << v[i];
}
cout << '\n';
}
template <class T> void outvv(T v) { rep(i, v.size()) outv(v[i]); }
int main() {
int n, q;
cin >> n >> q;
vi v(n);
rep(i, n) cin >> v[i];
vector<P> query(q);
vi ans(q);
rep(i, q) cin >> query[i].fi;
rep(i, q) query[i].se = i;
sort(all(query));
reverse(all(query));
int w = 0;
ll sum = 0;
for (int i = n - 1; i >= 0; i -= 2)
sum += v[i];
REP(i, 1, (n + 1) / 2) {
while (w < q) {
if (query[w].fi > (v[n - i] + v[n - i - i - 1]) / 2) {
ans[query[w].se] = sum;
w++;
} else
break;
}
sum -= v[n - 1 - i * 2];
sum += v[n - 1 - i];
}
REP(i, w, q) ans[query[i].se] = sum;
for (ll x : ans)
out(x);
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(i, k, n) for (ll i = (ll)(k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define lb(v, k) (lower_bound(all(v), k) - v.begin())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int mod = 1e9 + 7;
const ll inf = 1001001001001001;
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> void out(T a) { cout << a << '\n'; }
template <class T> void outv(T v) {
rep(i, v.size()) {
if (i)
cout << ' ';
cout << v[i];
}
cout << '\n';
}
template <class T> void outvv(T v) { rep(i, v.size()) outv(v[i]); }
int main() {
int n, q;
cin >> n >> q;
vi v(n);
rep(i, n) cin >> v[i];
vector<P> query(q);
vi ans(q);
rep(i, q) cin >> query[i].fi;
rep(i, q) query[i].se = i;
sort(all(query));
reverse(all(query));
int w = 0;
ll sum = 0;
for (int i = n - 1; i >= 0; i -= 2)
sum += v[i];
REP(i, 1, (n + 1) / 2) {
while (w < q) {
if (query[w].fi > (v[n - i - 1] + v[n - i * 2 - 1]) / 2) {
ans[query[w].se] = sum;
w++;
} else
break;
}
sum -= v[n - 1 - i * 2];
sum += v[n - 1 - i];
}
REP(i, w, q) ans[query[i].se] = sum;
for (ll x : ans)
out(x);
} | [
"control_flow.branch.if.condition.change"
] | 951,707 | 951,708 | u422633119 | cpp |
p03158 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(i, k, n) for (ll i = (ll)(k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define lb(v, k) (lower_bound(all(v), k) - v.begin())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int mod = 1e9 + 7;
const ll inf = 1001001001001001;
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> void out(T a) { cout << a << '\n'; }
template <class T> void outv(T v) {
rep(i, v.size()) {
if (i)
cout << ' ';
cout << v[i];
}
cout << '\n';
}
template <class T> void outvv(T v) { rep(i, v.size()) outv(v[i]); }
int main() {
int n, q;
cin >> n >> q;
vi v(n);
rep(i, n) cin >> v[i];
vector<P> query(q);
vi ans(q);
rep(i, q) cin >> query[i].fi;
rep(i, q) query[i].se = i;
sort(all(query));
reverse(all(query));
int w = 0;
ll sum = 0;
for (int i = n - 1; i >= 0; i -= 2)
sum += v[i];
REP(i, 1, (n + 1) / 2) {
while (w < q) {
if (query[w].fi > (v[n - i * 2] + v[n - 1 - i * 2]) / 2) {
ans[query[w].se] = sum;
w++;
} else
break;
}
sum -= v[n - 1 - i * 2];
sum += v[n - 1 - i];
}
REP(i, w, q) ans[query[i].se] = sum;
for (ll x : ans)
out(x);
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(i, k, n) for (ll i = (ll)(k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define lb(v, k) (lower_bound(all(v), k) - v.begin())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int mod = 1e9 + 7;
const ll inf = 1001001001001001;
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> void out(T a) { cout << a << '\n'; }
template <class T> void outv(T v) {
rep(i, v.size()) {
if (i)
cout << ' ';
cout << v[i];
}
cout << '\n';
}
template <class T> void outvv(T v) { rep(i, v.size()) outv(v[i]); }
int main() {
int n, q;
cin >> n >> q;
vi v(n);
rep(i, n) cin >> v[i];
vector<P> query(q);
vi ans(q);
rep(i, q) cin >> query[i].fi;
rep(i, q) query[i].se = i;
sort(all(query));
reverse(all(query));
int w = 0;
ll sum = 0;
for (int i = n - 1; i >= 0; i -= 2)
sum += v[i];
REP(i, 1, (n + 1) / 2) {
while (w < q) {
if (query[w].fi > (v[n - i - 1] + v[n - i * 2 - 1]) / 2) {
ans[query[w].se] = sum;
w++;
} else
break;
}
sum -= v[n - 1 - i * 2];
sum += v[n - 1 - i];
}
REP(i, w, q) ans[query[i].se] = sum;
for (ll x : ans)
out(x);
} | [
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 951,709 | 951,708 | u422633119 | cpp |
p03158 | // header
#ifdef LOCAL
#include "cxx-prettyprint-master/prettyprint.hpp"
#define print(x) cout << x << endl
#else
#define print(...) 42
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
// types
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
template <typename T> using Matrix = vector<vector<T>>;
template <std::uint_fast64_t Modulus> class modint {
using u64 = std::uint_fast64_t;
public:
u64 a;
constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr modint operator+(const modint rhs) const noexcept {
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept {
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept {
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept {
return modint(*this) /= rhs;
}
constexpr modint &operator+=(const modint rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr modint &operator-=(const modint rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint &operator*=(const modint rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint &operator/=(modint rhs) noexcept {
u64 exp = Modulus - 2;
while (exp) {
if (exp % 2) {
*this *= rhs;
}
rhs *= rhs;
exp /= 2;
}
return *this;
}
};
// abbreviations
#define all(x) (x).begin(), (x).end()
#define reverse(x) (x).rbegin(), (x).rend()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define SZ(x) ((ll)(x).size())
#define sum(x) accumulate(begin(x), end(x), 0LL) //?
#define pb(x) push_back(x)
// functions
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
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> T mod_pow(T x, T n, const T &p) {
T ret = 1;
while (n > 0) {
if (n & 1)
(ret *= x) %= p;
(x *= x) %= p;
n >>= 1;
}
return ret;
}
uint64_t my_rand(void) {
static uint64_t x = 88172645463325252ULL;
x = x ^ (x << 13);
x = x ^ (x >> 7);
return x = x ^ (x << 17);
}
// constant
#define INF 1'010'000'000'000'000'017LL
#define mod 1000000007LL
#define eps 0.0001
// library
// main
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(20);
ll N, Q;
cin >> N >> Q;
vector<ll> A(N), cumsum(N + 1), cumsum_taka(N + 1);
rep(i, N) {
cin >> A[i];
cumsum[i + 1] = cumsum[i] + A[i];
cumsum_taka[i + 1] = cumsum_taka[i];
if (i % 2 != N % 2)
cumsum_taka[i + 1] += A[i];
}
rep(i, Q) {
ll x;
cin >> x;
int j = distance(begin(A), upper_bound(all(A), x));
ll ng = (N + 1) / 2 + 1, ok = 1;
ll l;
while (ng - ok > 1) {
ll mid = (ok + ng) / 2;
if (x * 2 - A[N - mid] <= A[N - mid * 2 + 1])
ok = mid;
else
ng = mid;
}
ll ans = cumsum[N] - cumsum[N - ok] + cumsum_taka[N - ok * 2];
cout << ans << endl;
}
}
| // header
#ifdef LOCAL
#include "cxx-prettyprint-master/prettyprint.hpp"
#define print(x) cout << x << endl
#else
#define print(...) 42
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
// types
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
template <typename T> using Matrix = vector<vector<T>>;
template <std::uint_fast64_t Modulus> class modint {
using u64 = std::uint_fast64_t;
public:
u64 a;
constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr modint operator+(const modint rhs) const noexcept {
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept {
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept {
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept {
return modint(*this) /= rhs;
}
constexpr modint &operator+=(const modint rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr modint &operator-=(const modint rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint &operator*=(const modint rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint &operator/=(modint rhs) noexcept {
u64 exp = Modulus - 2;
while (exp) {
if (exp % 2) {
*this *= rhs;
}
rhs *= rhs;
exp /= 2;
}
return *this;
}
};
// abbreviations
#define all(x) (x).begin(), (x).end()
#define reverse(x) (x).rbegin(), (x).rend()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define SZ(x) ((ll)(x).size())
#define sum(x) accumulate(begin(x), end(x), 0LL) //?
#define pb(x) push_back(x)
// functions
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
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> T mod_pow(T x, T n, const T &p) {
T ret = 1;
while (n > 0) {
if (n & 1)
(ret *= x) %= p;
(x *= x) %= p;
n >>= 1;
}
return ret;
}
uint64_t my_rand(void) {
static uint64_t x = 88172645463325252ULL;
x = x ^ (x << 13);
x = x ^ (x >> 7);
return x = x ^ (x << 17);
}
// constant
#define INF 1'010'000'000'000'000'017LL
#define mod 1000000007LL
#define eps 0.0001
// library
// main
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(20);
ll N, Q;
cin >> N >> Q;
vector<ll> A(N), cumsum(N + 1), cumsum_taka(N + 1);
rep(i, N) {
cin >> A[i];
cumsum[i + 1] = cumsum[i] + A[i];
cumsum_taka[i + 1] = cumsum_taka[i];
if (i % 2 != N % 2)
cumsum_taka[i + 1] += A[i];
}
rep(i, Q) {
ll x;
cin >> x;
int j = distance(begin(A), upper_bound(all(A), x));
ll ng = (N + 1) / 2 + 1, ok = 1;
ll l;
while (ng - ok > 1) {
ll mid = (ok + ng) / 2;
if (x * 2 - A[N - mid] <= A[N - mid * 2 + 1])
ok = mid;
else
ng = mid;
}
ll ans = cumsum[N] - cumsum[N - ok] + cumsum_taka[N - ok * 2 + 1];
cout << ans << endl;
}
}
| [
"assignment.change"
] | 951,712 | 951,713 | u310678820 | cpp |
p03158 | #pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
//------ Believe yourself as a genius!!!!!! ------
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll sumrev[ohara], odd[ohara], even[ohara];
bool check(ll ind, ll x) {
ll takahasi = n - 1 - ind, aoki;
ll le = 0, ri = ind, mid;
ll kage = x - (a[ind] - x);
while (ri - le > 1) {
mid = (le + ri) / 2;
if (a[mid] < kage)
le = mid;
else
ri = mid;
}
rrep(i, max(le - 2, 0LL), min(ri + 3, n)) {
if (a[i] >= kage) {
aoki = ind - i + 1;
tmp = ind - takahasi + 1;
break;
}
}
// if (a[ind] == 11) Cout(aoki);
// Cout(a[ind]);
if (aoki > takahasi)
return false;
else
return true;
}
int main(void) {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
cin >> n >> q;
rep(i, n) cin >> a[i];
rep(i, n) {
sumrev[i] = a[i];
if (i % 2 == 0)
even[i] = a[i];
else
odd[i] = a[i];
}
rrrep(i, n - 2, 0) sumrev[i] += sumrev[i + 1];
rrep(i, 1, n) even[i] += even[i - 1], odd[i] += odd[i - 1];
rep(i, q) {
cin >> x;
ll le = 0, ri = n - 1, mid;
while (ri - le > 1) {
mid = (le + ri) / 2;
if (a[mid] > x)
ri = mid;
else
le = mid;
}
tmp = n - 1;
rrep(j, max(le - 2, 0LL), min(ri + 3, n)) {
if (a[j + 1] > x) {
tmp = j;
break;
}
}
if (tmp == n - 1) {
if (tmp % 2 == 0)
Cout(even[tmp]);
else
Cout(odd[tmp]);
} else {
le = tmp, ri = n - 1, mid;
while (ri - le > 1) {
mid = (le + ri) / 2;
if (check(mid, x))
le = mid;
else
ri = mid;
}
rrrep(j, min(ri + 2, n - 1), max(le - 2, 0LL)) {
if (check(j, x)) {
ans = sumrev[j + 1];
// Cout(j);
tmp--;
if (tmp >= 0) {
if (tmp % 2 == 0)
ans += even[tmp];
else
ans += odd[tmp];
}
break;
}
}
Cout(ans);
}
}
return 0;
} | #pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
//------ Believe yourself as a genius!!!!!! ------
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll sumrev[ohara], odd[ohara], even[ohara];
bool check(ll ind, ll x) {
ll takahasi = n - 1 - ind, aoki;
ll le = 0, ri = ind, mid;
ll kage = x - (a[ind] - x);
while (ri - le > 1) {
mid = (le + ri) / 2;
if (a[mid] < kage)
le = mid;
else
ri = mid;
}
rrep(i, max(le - 2, 0LL), min(ri + 3, n)) {
if (a[i] >= kage) {
aoki = ind - i + 1;
tmp = ind - takahasi + 1;
break;
}
}
// if (a[ind] == 11) Cout(aoki);
// Cout(a[ind]);
if (aoki > takahasi)
return false;
else
return true;
}
int main(void) {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
cin >> n >> q;
rep(i, n) cin >> a[i];
rep(i, n) {
sumrev[i] = a[i];
if (i % 2 == 0)
even[i] = a[i];
else
odd[i] = a[i];
}
rrrep(i, n - 2, 0) sumrev[i] += sumrev[i + 1];
rrep(i, 1, n) even[i] += even[i - 1], odd[i] += odd[i - 1];
rep(i, q) {
cin >> x;
ll le = 0, ri = n - 1, mid;
while (ri - le > 1) {
mid = (le + ri) / 2;
if (a[mid] > x)
ri = mid;
else
le = mid;
}
tmp = n - 1;
rrep(j, max(le - 2, 0LL), min(ri + 3, n)) {
if (a[j] > x) {
tmp = j;
break;
}
}
if (tmp == n - 1) {
if (tmp % 2 == 0)
Cout(even[tmp]);
else
Cout(odd[tmp]);
} else {
le = tmp, ri = n - 1, mid;
while (ri - le > 1) {
mid = (le + ri) / 2;
if (check(mid, x))
le = mid;
else
ri = mid;
}
rrrep(j, min(ri + 2, n - 1), max(le - 2, 0LL)) {
if (check(j, x)) {
ans = sumrev[j + 1];
// Cout(j);
tmp--;
if (tmp >= 0) {
if (tmp % 2 == 0)
ans += even[tmp];
else
ans += odd[tmp];
}
break;
}
}
Cout(ans);
}
}
return 0;
} | [
"expression.operation.binary.remove"
] | 951,731 | 951,732 | u876335718 | cpp |
p03158 | //#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
// typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct P {
int q, i, ans;
P() : P(0, 0, 0) {}
P(int q, int i, int ans) : q(q), i(i), ans(ans) {}
};
int A[100010];
P Q[100010];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M, q;
int s = 0;
cin >> N >> M;
rep(i, 0, N) {
cin >> A[i];
if (N / 2 <= i) {
s += A[i];
}
}
rep(i, 0, M) {
cin >> q;
Q[i] = P(q, i, 0);
}
sort(Q, Q + M, [](const P &a, const P &b) { return a.q < b.q; });
int l, r;
if (N % 2 == 1) {
l = 0;
r = N / 2;
} else {
l = 1;
r = N / 2;
}
int qi = 0;
while (l < r) {
int x = (A[r] + A[l]) / 2;
while (Q[qi].q <= x) {
Q[qi].ans = s;
qi++;
}
s -= A[r] - A[l];
l += 2;
r++;
}
while (qi < M) {
Q[qi].ans = s;
qi++;
}
sort(Q, Q + M, [](const P &a, const P &b) { return a.i < b.i; });
rep(i, 0, M) { cout << Q[i].ans << endl; }
return 0;
} | //#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
// typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct P {
int q, i, ans;
P() : P(0, 0, 0) {}
P(int q, int i, int ans) : q(q), i(i), ans(ans) {}
};
int A[100010];
P Q[100010];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M, q;
int s = 0;
cin >> N >> M;
rep(i, 0, N) {
cin >> A[i];
if (N / 2 <= i) {
s += A[i];
}
}
rep(i, 0, M) {
cin >> q;
Q[i] = P(q, i, 0);
}
sort(Q, Q + M, [](const P &a, const P &b) { return a.q < b.q; });
int l, r;
if (N % 2 == 1) {
l = 0;
r = N / 2;
} else {
l = 1;
r = N / 2;
}
int qi = 0;
while (l < r) {
int x = (A[r] + A[l]) / 2;
while (qi < M && Q[qi].q <= x) {
Q[qi].ans = s;
qi++;
}
s -= A[r] - A[l];
l += 2;
r++;
}
while (qi < M) {
Q[qi].ans = s;
qi++;
}
sort(Q, Q + M, [](const P &a, const P &b) { return a.i < b.i; });
rep(i, 0, M) { cout << Q[i].ans << endl; }
return 0;
} | [
"control_flow.loop.condition.change"
] | 951,750 | 951,751 | u874947858 | cpp |
p03160 | #include <bits/stdc++.h>
#define int long long
using namespace std;
int n, a[100007], dp[1000007];
int32_t main() {
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i], dp[i] = INT_MAX;
dp[0] = 0;
dp[1] = abs(dp[1] - dp[0]);
for (int i = 2; i < n; i++)
dp[i] =
min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
cout << dp[n - 1] << endl;
return 0;
} | #include <bits/stdc++.h>
#define int long long
using namespace std;
int n, a[100007], dp[1000007];
int32_t main() {
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i], dp[i] = 0;
dp[0] = 0;
dp[1] = abs(a[1] - a[0]);
for (int i = 2; i < n; i++)
dp[i] =
min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
cout << dp[n - 1] << endl;
return 0;
} | [
"assignment.value.change",
"identifier.replace.remove",
"literal.replace.add",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 951,767 | 951,768 | u669587828 | cpp |
p03160 | #include <bits/stdc++.h>
using namespace std;
int n;
vector<int> hs;
#define rep(i, k, n) for (int i = k; i < (int)(n); i++)
int main() {
cin >> n;
rep(i, 0, n) {
int h;
cin >> h;
hs.push_back(h);
}
int dp[n];
dp[0] = 0;
dp[1] = abs(hs[0] - hs[1]);
rep(i, 2, n) {
dp[i] = max(dp[i - 1] + abs(hs[i - 1] - hs[i]),
dp[i - 2] + abs(hs[i - 2] - hs[i]));
}
cout << dp[n - 1] << endl;
} | #include <bits/stdc++.h>
using namespace std;
int n;
vector<int> hs;
#define rep(i, k, n) for (int i = k; i < (int)(n); i++)
int main() {
cin >> n;
rep(i, 0, n) {
int h;
cin >> h;
hs.push_back(h);
}
int dp[n];
dp[0] = 0;
dp[1] = abs(hs[0] - hs[1]);
rep(i, 2, n) {
dp[i] = min(dp[i - 1] + abs(hs[i - 1] - hs[i]),
dp[i - 2] + abs(hs[i - 2] - hs[i]));
}
cout << dp[n - 1] << endl;
} | [
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change"
] | 951,769 | 951,770 | u657818166 | cpp |
p03160 | #include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
int dp[n];
dp[0] = 0;
dp[1] = abs(a[1] - a[0]);
for (int i = 2; i < n; i++) {
dp[i] =
min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
}
cout << dp[n];
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
T = 1;
// cin>>T;
while (T--) {
solve();
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
int dp[n];
dp[0] = 0;
dp[1] = abs(a[1] - a[0]);
for (int i = 2; i < n; i++) {
dp[i] =
min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
}
cout << dp[n - 1];
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
T = 1;
// cin>>T;
while (T--) {
solve();
}
return 0;
} | [
"expression.operation.binary.add"
] | 951,773 | 951,774 | u640154263 | cpp |
p03160 | #include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846
// #define ll long long int
#define ff first
#define ss second
// #define int long long int
#define pb push_back
#define N 10000010
#define MOD 1000000007
int bexp(int a, int b) {
int res = 1;
while (b) {
if (b & 1)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.precision(10);
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int dp[n] = {};
dp[1] = abs(a[1] - a[0]);
for (int i = 2; i < n; ++i) {
dp[i] =
min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
}
cout << dp[n];
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846
// #define ll long long int
#define ff first
#define ss second
// #define int long long int
#define pb push_back
#define N 10000010
#define MOD 1000000007
int bexp(int a, int b) {
int res = 1;
while (b) {
if (b & 1)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.precision(10);
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int dp[n] = {};
dp[1] = abs(a[1] - a[0]);
for (int i = 2; i < n; ++i) {
dp[i] =
min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
}
cout << dp[n - 1];
return 0;
}
| [
"expression.operation.binary.add"
] | 951,783 | 951,784 | u060049558 | cpp |
p03160 | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 100005
ll inv[N], fac[N], finv[N];
void make() {
fac[0] = fac[1] = 1;
inv[1] = 1;
finv[1] = finv[0] = 1;
for (int i = 2; i < N; ++i) {
fac[i] = i * fac[i - 1] % MOD;
inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
finv[i] = inv[i] * finv[i - 1] % MOD;
}
}
ll C(ll n, ll k) {
if (n < k || n < 0)
return 0;
return fac[n] * finv[n - k] % MOD * finv[k] % MOD;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
#define N 100005
int n;
int h[N];
int dp[N];
int dpf(int i) {
if (i > n)
return 1e9;
if (i == n - 1)
return 0;
if (dp[i] >= 0)
return dp[i];
return dp[i] = min(abs(h[i + 1] - h[i]) + dpf(i + 1),
abs(h[i + 2] - h[i]) + dpf(i + 2));
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> h[i];
dp[i] = -1;
}
int ans = dpf(0);
cout << ans << '\n';
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 100005
ll inv[N], fac[N], finv[N];
void make() {
fac[0] = fac[1] = 1;
inv[1] = 1;
finv[1] = finv[0] = 1;
for (int i = 2; i < N; ++i) {
fac[i] = i * fac[i - 1] % MOD;
inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
finv[i] = inv[i] * finv[i - 1] % MOD;
}
}
ll C(ll n, ll k) {
if (n < k || n < 0)
return 0;
return fac[n] * finv[n - k] % MOD * finv[k] % MOD;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
#define N 100005
int n;
int h[N];
int dp[N];
int dpf(int i) {
if (i >= n)
return 1e9;
if (i == n - 1)
return 0;
if (dp[i] >= 0)
return dp[i];
return dp[i] = min(abs(h[i + 1] - h[i]) + dpf(i + 1),
abs(h[i + 2] - h[i]) + dpf(i + 2));
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> h[i];
dp[i] = -1;
}
int ans = dpf(0);
cout << ans << '\n';
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 951,785 | 951,786 | u060049558 | cpp |
p03160 | #include <bits/stdc++.h>
typedef long long int lli;
typedef long double lld;
typedef long long ll;
// Datatype
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vvlli vector<vector<long long int>>
#define ppi pair<int, int>
#define rppi pair<int, pair<int, int>>
#define lppi pair<pair<int, int>, int>
#define vppi vector<pair<int, int>>
#define sppi stack<pair<int int>>
#define qppi queue<pair<int, int>>
// function
#define f first
#define s second
#define pb(x) push_back(x)
#define mkp(i, j) make_pair(i, j)
#define lmkp(i, j, k) make_pair(make_pair(i, j), k)
#define rmkp(i, j, k) make_pair(i, make_pair(j, k))
// loop
#define loop(i, n) for (i = 0; i < n; ++i)
#define loops(i, k, n) for (i = k; i <= n; ++i)
#define looprev(i, k, n) for (i = k; i >= n; --i)
// Const
#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
// Print
#define prd(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define prdn(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define prf(n) printf("%f", n)
// Scan
#define scd(n) scanf("%d", &n)
#define scd2(a, b) scanf("%d %d", &a, &b)
#define scd3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scl(n) scanf("%lld", &n)
#define scl2(a, b) scanf("%lld %lld", &a, &b)
#define scl3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define scf(n) scanf("%f", &n)
using namespace std;
class Solution {
public:
int frog1(int N, vector<int> vec) {
if (vec.size() == 1) {
return 0;
} else if (vec.size() == 2) {
return abs(vec[1] - vec[0]);
}
int i, j, A[N];
A[0] = vec[0];
A[1] = abs(vec[1] - vec[0]);
loops(i, 2, N - 1) {
A[i] = min(A[i - 1] + abs(vec[i] - vec[i - 1]),
A[i - 2] + abs(vec[i] - vec[i - 2]));
}
return A[N - 1];
}
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli i, j, k, n;
Solution s;
cin >> n;
vector<int> vec(n, 0);
loop(i, n) { cin >> vec[i]; }
int res = s.frog1(n, vec);
cout << res << endl;
return 0;
}
| #include <bits/stdc++.h>
typedef long long int lli;
typedef long double lld;
typedef long long ll;
// Datatype
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vvlli vector<vector<long long int>>
#define ppi pair<int, int>
#define rppi pair<int, pair<int, int>>
#define lppi pair<pair<int, int>, int>
#define vppi vector<pair<int, int>>
#define sppi stack<pair<int int>>
#define qppi queue<pair<int, int>>
// function
#define f first
#define s second
#define pb(x) push_back(x)
#define mkp(i, j) make_pair(i, j)
#define lmkp(i, j, k) make_pair(make_pair(i, j), k)
#define rmkp(i, j, k) make_pair(i, make_pair(j, k))
// loop
#define loop(i, n) for (i = 0; i < n; ++i)
#define loops(i, k, n) for (i = k; i <= n; ++i)
#define looprev(i, k, n) for (i = k; i >= n; --i)
// Const
#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
// Print
#define prd(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define prdn(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define prf(n) printf("%f", n)
// Scan
#define scd(n) scanf("%d", &n)
#define scd2(a, b) scanf("%d %d", &a, &b)
#define scd3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scl(n) scanf("%lld", &n)
#define scl2(a, b) scanf("%lld %lld", &a, &b)
#define scl3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define scf(n) scanf("%f", &n)
using namespace std;
class Solution {
public:
int frog1(int N, vector<int> vec) {
if (vec.size() == 1) {
return 0;
} else if (vec.size() == 2) {
return abs(vec[1] - vec[0]);
}
int i, j, A[N];
A[0] = 0;
A[1] = abs(vec[1] - vec[0]);
loops(i, 2, N - 1) {
A[i] = min(A[i - 1] + abs(vec[i] - vec[i - 1]),
A[i - 2] + abs(vec[i] - vec[i - 2]));
}
return A[N - 1];
}
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli i, j, k, n;
Solution s;
cin >> n;
vector<int> vec(n, 0);
loop(i, n) { cin >> vec[i]; }
int res = s.frog1(n, vec);
cout << res << endl;
return 0;
} | [] | 951,789 | 951,790 | u729836666 | cpp |
p03160 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<int> h(n);
vector<int> dp(n, 1000010);
dp[0] = 0;
for (int &x : h)
scanf("%d", &x);
for (int i = 0; i < n; i++) {
for (int j : {i + 1, i + 2}) {
if (j < n)
dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
}
}
printf("%d\n", dp[n - 1]);
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<int> h(n);
vector<int> dp(n, 1e9 + 5);
dp[0] = 0;
for (int &x : h)
scanf("%d", &x);
for (int i = 0; i < n; i++) {
for (int j : {i + 1, i + 2}) {
if (j < n)
dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
}
}
printf("%d\n", dp[n - 1]);
}
| [
"literal.number.change",
"call.arguments.change"
] | 951,791 | 951,792 | u797695407 | cpp |
p03160 | #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> height(n);
for (int i = 0; i < n; i++)
cin >> height[i];
vector<int> minCost(n);
for (int i = 1; i < n; i++) {
if (i < 1)
minCost[i] = abs(height[i] - height[i - 1]);
else {
int firstStone = abs(height[i] - height[i - 1]) + minCost[i - 1];
int secondStone = abs(height[i] - height[i - 2]) + minCost[i - 2];
minCost[i] = min(firstStone, secondStone);
}
}
cout << minCost.back();
return 0;
}
| #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> height(n);
for (int i = 0; i < n; i++)
cin >> height[i];
vector<int> minCost(n);
for (int i = 1; i < n; i++) {
if (i == 1)
minCost[i] = abs(height[i] - height[i - 1]);
else {
int firstStone = abs(height[i] - height[i - 1]) + minCost[i - 1];
int secondStone = abs(height[i] - height[i - 2]) + minCost[i - 2];
minCost[i] = min(firstStone, secondStone);
}
}
cout << minCost.back();
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 951,793 | 951,794 | u812439155 | cpp |
p03160 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i, l, r) for (int i = (l); i < (r); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int, int>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll MOD = 1e+9 + 7;
// --------------------------------------------------------
const int MAX_N = 1e+5;
VI dp(MAX_N + 1, 0);
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(10);
int N;
cin >> N;
VI h(N + 1);
FOR(i, 1, N + 1) cin >> h[i];
dp[2] = dp[1] + abs(h[2] - h[1]);
FOR(i, 2, N + 1) {
dp[i] =
min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
}
cout << dp[N] << '\n';
return 0;
}
// https://atcoder.jp/contests/dp/tasks/dp_a
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i, l, r) for (int i = (l); i < (r); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int, int>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll MOD = 1e+9 + 7;
// --------------------------------------------------------
const int MAX_N = 1e+5;
VI dp(MAX_N + 1, 0);
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(10);
int N;
cin >> N;
VI h(N + 1);
FOR(i, 1, N + 1) cin >> h[i];
dp[2] = dp[1] + abs(h[2] - h[1]);
FOR(i, 3, N + 1) {
dp[i] =
min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
}
cout << dp[N] << '\n';
return 0;
}
// https://atcoder.jp/contests/dp/tasks/dp_a
| [
"literal.number.change",
"call.arguments.change"
] | 951,799 | 951,800 | u934442292 | cpp |
p03160 | #include <iostream>
using namespace std;
#include <vector>
int main() {
int n;
cin >> n;
const int INF = 1e9 + 7;
vector<long long int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
vector<long long int> s(n, INF);
s[0] = 0;
for (long long int i = 0; i < n; i++) {
for (long long int j = i + 1; j <= i + 2; j++) {
s[j] = min(s[j], s[i] + abs(h[j] - h[i]));
}
}
cout << s[n - 1];
return 0;
}
| #include <iostream>
using namespace std;
#include <vector>
int main() {
int n;
cin >> n;
const int INF = 1e9 + 7;
vector<long long int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
vector<long long int> s(n, INF);
s[0] = 0;
for (long long int i = 0; i < n; i++) {
for (long long int j = i + 1; j <= i + 2; j++) {
if (j < n)
s[j] = min(s[j], s[i] + abs(h[j] - h[i]));
}
}
cout << s[n - 1];
return 0;
}
| [
"control_flow.branch.if.add"
] | 951,806 | 951,807 | u094735113 | cpp |
p03160 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
void inp() {
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
}
ll min(ll a, ll b) {
if (a < b)
return a;
else
return b;
}
ll max(ll a, ll b) {
if (a > b)
return a;
else
return b;
}
int main() {
// inp();
fio;
ll n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; i++) {
cin >> nums[i];
}
vector<int> dp(n, 100);
dp[0] = 0;
for (int i = 1; i < n; i++) {
if (i - 1 >= 0) {
dp[i] = min(dp[i], dp[i - 1] + abs(nums[i] - nums[i - 1]));
}
if (i - 2 >= 0) {
dp[i] = min(dp[i], dp[i - 2] + abs(nums[i] - nums[i - 2]));
}
}
cout << dp[n - 1] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
void inp() {
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
}
ll min(ll a, ll b) {
if (a < b)
return a;
else
return b;
}
ll max(ll a, ll b) {
if (a > b)
return a;
else
return b;
}
int main() {
// inp();
fio;
ll n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; i++) {
cin >> nums[i];
}
vector<int> dp(n, INT_MAX);
dp[0] = 0;
for (int i = 1; i < n; i++) {
if (i - 1 >= 0) {
dp[i] = min(dp[i], dp[i - 1] + abs(nums[i] - nums[i - 1]));
}
if (i - 2 >= 0) {
dp[i] = min(dp[i], dp[i - 2] + abs(nums[i] - nums[i - 2]));
}
}
cout << dp[n - 1] << endl;
return 0;
} | [
"call.arguments.change"
] | 951,808 | 951,809 | u748203773 | cpp |
p03160 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
int main() {
ll n;
cin >> n;
vector<ll> v(n);
rep(i, n) cin >> v[i];
ll dp[n];
rep(i, n) dp[i] = 1e10;
dp[0] = 0;
rep(i, n - 1) {
rep(j, 2) {
if (i >= j)
dp[i + 1] = min(dp[i + 1], dp[i] + abs(v[i + 1] - v[i - j]));
}
}
cout << dp[n - 1] << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
int main() {
ll n;
cin >> n;
vector<ll> v(n);
rep(i, n) cin >> v[i];
ll dp[n];
rep(i, n) dp[i] = 1e10;
dp[0] = 0;
rep(i, n - 1) {
rep(j, 2) {
if (i >= j)
dp[i + 1] = min(dp[i + 1], dp[i - j] + abs(v[i + 1] - v[i - j]));
}
}
cout << dp[n - 1] << endl;
} | [
"assignment.change"
] | 951,810 | 951,811 | u264265458 | cpp |
p03160 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
int main() {
ll n;
cin >> n;
vector<ll> v(n);
rep(i, n) cin >> v[i];
ll dp[n];
rep(i, n) dp[i] = 1e10;
dp[0] = 0;
rep(i, n - 1) {
rep(j, 1) {
if (i >= j)
dp[i + 1] = min(dp[i + 1], dp[i] + abs(v[i + 1] - v[i - j]));
}
}
cout << dp[n - 1] << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
int main() {
ll n;
cin >> n;
vector<ll> v(n);
rep(i, n) cin >> v[i];
ll dp[n];
rep(i, n) dp[i] = 1e10;
dp[0] = 0;
rep(i, n - 1) {
rep(j, 2) {
if (i >= j)
dp[i + 1] = min(dp[i + 1], dp[i - j] + abs(v[i + 1] - v[i - j]));
}
}
cout << dp[n - 1] << endl;
} | [
"literal.number.change",
"call.arguments.change",
"assignment.change"
] | 951,812 | 951,811 | u264265458 | cpp |
p03160 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
int main() {
ll n;
cin >> n;
ll INF = 10000;
vector<ll> v(n);
rep(i, n) cin >> v[i];
ll dp[100000];
rep(i, n) dp[i] = INF;
dp[0] = 0;
rep(i, n - 1) {
dp[i + 1] = min(dp[i + 1], dp[i] + abs(v[i + 1] - v[i]));
if (i > 0)
dp[i + 1] = min(dp[i + 1], dp[i - 1] + abs(v[i + 1] - v[i - 1]));
}
cout << dp[n - 1] << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
int main() {
ll n;
cin >> n;
ll INF = 10000000000;
vector<ll> v(n);
rep(i, n) cin >> v[i];
ll dp[100000];
rep(i, n) dp[i] = INF;
dp[0] = 0;
rep(i, n - 1) {
dp[i + 1] = min(dp[i + 1], dp[i] + abs(v[i + 1] - v[i]));
if (i > 0)
dp[i + 1] = min(dp[i + 1], dp[i - 1] + abs(v[i + 1] - v[i - 1]));
}
cout << dp[n - 1] << endl;
} | [
"literal.number.change",
"variable_declaration.value.change"
] | 951,813 | 951,814 | u264265458 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.