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 |
|---|---|---|---|---|---|---|---|
p03055 | // BWOTSHEWCHB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define in insert
#define X first
#define Y second
const int MAXN = 1e6 + 69, MOD = 1e9 + 7;
int n, leaf, dp[MAXN], height[MAXN];
vector<int> g[MAXN];
void dfs(int v, int par = -1) {
for (auto u : g[v])
if (u != par) {
height[u] = height[v] + 1;
if (height[u] > height[leaf])
leaf = u;
dfs(u, v);
}
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
int v, u;
for (int i = 1; i < n; i++)
cin >> v >> u, g[v].pb(u), g[u].pb(v);
dp[0] = 0, dp[1] = 1;
for (int i = 2; i <= n; i++)
dp[i] = (dp[i - 1] & dp[i - 2]) ^ 1;
dfs(1), memset(height, 0, sizeof height), dfs(leaf);
if (dp[height[leaf] + 1])
cout << "Second\n";
else
cout << "First\n";
}
| // BWOTSHEWCHB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define in insert
#define X first
#define Y second
const int MAXN = 1e6 + 69, MOD = 1e9 + 7;
int n, leaf, dp[MAXN], height[MAXN];
vector<int> g[MAXN];
void dfs(int v, int par = -1) {
for (auto u : g[v])
if (u != par) {
height[u] = height[v] + 1;
if (height[u] > height[leaf])
leaf = u;
dfs(u, v);
}
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
int v, u;
for (int i = 1; i < n; i++)
cin >> v >> u, g[v].pb(u), g[u].pb(v);
dp[0] = 0, dp[1] = 1;
for (int i = 2; i <= n; i++)
dp[i] = (dp[i - 1] | dp[i - 2]) ^ 1;
dfs(1), memset(height, 0, sizeof height), dfs(leaf);
if (dp[height[leaf]])
cout << "Second\n";
else
cout << "First\n";
}
| [
"assignment.value.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 870,181 | 870,182 | u711755001 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 200001;
int len, fid, dis;
vector<int> edge[maxn];
void dfs(int now, int last, int d = 0) {
if (d > dis) {
dis = d;
fid = now;
}
for (auto &i : edge[now]) {
if (last != i) {
dfs(i, now, d + 1);
}
}
}
bool win[maxn];
int main() {
cin >> len;
win[1] = true;
win[2] = false;
for (int i = 3; i < maxn; ++i)
(win[i] = !win[i - 1] || !win[i - 2]);
for (int i = 2; i <= len; ++i) {
int a, b;
cin >> a >> b;
edge[a].push_back(b);
edge[b].push_back(a);
}
fid = 1;
dfs(fid, fid);
dis = 0;
dfs(fid, fid);
if (win[dis]) {
cout << "First\n";
} else {
cout << "Second\n";
}
}
| #include <bits/stdc++.h>
using namespace std;
const int maxn = 200001;
int len, fid, dis;
vector<int> edge[maxn];
void dfs(int now, int last, int d = 1) {
if (d > dis) {
dis = d;
fid = now;
}
for (auto &i : edge[now]) {
if (last != i) {
dfs(i, now, d + 1);
}
}
}
bool win[maxn];
int main() {
cin >> len;
win[1] = true;
win[2] = false;
for (int i = 3; i < maxn; ++i)
(win[i] = !win[i - 1] || !win[i - 2]);
for (int i = 1; i < len; ++i) {
int a, b;
cin >> a >> b;
edge[a].push_back(b);
edge[b].push_back(a);
}
fid = 1;
dfs(fid, fid);
dis = 0;
dfs(fid, fid);
if (win[dis]) {
cout << "First\n";
} else {
cout << "Second\n";
}
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 870,183 | 870,184 | u233690053 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 200001;
int len, fid, dis;
vector<int> edge[maxn];
void dfs(int now, int last, int d = 0) {
if (d > dis) {
dis = d;
fid = now;
}
for (auto &i : edge[now]) {
if (last != i) {
dfs(i, now, d + 1);
}
}
}
bool win[maxn];
int main() {
cin >> len;
win[1] = true;
win[2] = false;
for (int i = 3; i < maxn; ++i)
cout << (win[i] = !win[i - 1] || !win[i - 2]);
for (int i = 2; i <= len; ++i) {
int a, b;
cin >> a >> b;
edge[a].push_back(b);
edge[b].push_back(a);
}
fid = 1;
dfs(fid, fid);
dis = 0;
dfs(fid, fid);
if (win[dis]) {
cout << "First\n";
} else {
cout << "Second\n";
}
} | #include <bits/stdc++.h>
using namespace std;
const int maxn = 200001;
int len, fid, dis;
vector<int> edge[maxn];
void dfs(int now, int last, int d = 1) {
if (d > dis) {
dis = d;
fid = now;
}
for (auto &i : edge[now]) {
if (last != i) {
dfs(i, now, d + 1);
}
}
}
bool win[maxn];
int main() {
cin >> len;
win[1] = true;
win[2] = false;
for (int i = 3; i < maxn; ++i)
(win[i] = !win[i - 1] || !win[i - 2]);
for (int i = 1; i < len; ++i) {
int a, b;
cin >> a >> b;
edge[a].push_back(b);
edge[b].push_back(a);
}
fid = 1;
dfs(fid, fid);
dis = 0;
dfs(fid, fid);
if (win[dis]) {
cout << "First\n";
} else {
cout << "Second\n";
}
}
| [
"literal.number.change",
"expression.operation.binary.remove",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 870,185 | 870,184 | u233690053 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;
// 1-indexed, 200000頂点以下で統一
#define MAX_SIZE 200000
vector<int> v[MAX_SIZE + 1];
// 木vで点startから最も遠い頂点の(距離, 座標)を返す関数
pair<int, int> dfs(int start) {
pair<int, int> ans(0, start);
vector<int> dist(MAX_SIZE + 1, -1); // -1は未探訪
stack<int> s;
dist[start] = 0;
s.push(start);
// 木なのでsが空になるまで回せば全ての辺と頂点を巡る
while (!s.empty()) {
int t = s.top();
s.pop();
for (auto x : v[t]) {
if (dist[x] == -1) {
dist[x] = dist[t] + 1;
s.push(x);
pair<int, int> xPair(dist[x], x);
if (ans < xPair)
ans = xPair;
}
}
}
return ans;
}
int main() {
int N;
cin >> N;
for (int i = 0; i < N - 1; ++i) {
int a, b;
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
}
int diameter =
dfs(dfs(1).second).first; // 任意の頂点から2回dfsをすれば直径が求められる
if (diameter % 3 == 1) {
cout << "Second";
} else {
cout << "First";
}
cout << diameter;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;
// 1-indexed, 200000頂点以下で統一
#define MAX_SIZE 200000
vector<int> v[MAX_SIZE + 1];
// 木vで点startから最も遠い頂点の(距離, 座標)を返す関数
pair<int, int> dfs(int start) {
pair<int, int> ans(0, start);
vector<int> dist(MAX_SIZE + 1, -1); // -1は未探訪
stack<int> s;
dist[start] = 0;
s.push(start);
// 木なのでsが空になるまで回せば全ての辺と頂点を巡る
while (!s.empty()) {
int t = s.top();
s.pop();
for (auto x : v[t]) {
if (dist[x] == -1) {
dist[x] = dist[t] + 1;
s.push(x);
pair<int, int> xPair(dist[x], x);
if (ans < xPair)
ans = xPair;
}
}
}
return ans;
}
int main() {
int N;
cin >> N;
for (int i = 0; i < N - 1; ++i) {
int a, b;
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
}
int diameter =
dfs(dfs(1).second).first; // 任意の頂点から2回dfsをすれば直径が求められる
if (diameter % 3 == 1) {
cout << "Second";
} else {
cout << "First";
}
return 0;
} | [] | 870,201 | 870,202 | u590088474 | cpp |
p03055 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long, long long>
#define all(a) a.begin(), a.end()
#define INF 10000000000000000
#define endl '\n'
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
using namespace std;
int n;
vector<int> g[100100];
int dist[100100];
signed main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
rep(i, n - 1) {
int a, b;
cin >> a >> b;
a--;
b--;
g[a].push_back(b);
g[b].push_back(a);
}
rep(i, n) dist[i] = INF;
dist[0] = 0;
queue<int> que;
que.push(0);
int vfar = 0, dfar = 0;
while (que.size()) {
int v = que.front();
que.pop();
if (chmax(dfar, dist[v]))
vfar = v;
rep(i, g[v].size()) {
if (dist[g[v].at(i)] > dist[v] + 1) {
dist[g[v].at(i)] = dist[v] + 1;
que.push(g[v].at(i));
}
}
}
rep(i, n) dist[i] = INF;
dist[vfar] = 0;
queue<int> que2;
que.push(vfar);
dfar = 0;
while (que2.size()) {
int v = que.front();
que.pop();
chmax(dfar, dist[v]);
rep(i, g[v].size()) {
if (dist[g[v].at(i)] > dist[v] + 1) {
dist[g[v].at(i)] = dist[v] + 1;
que.push(g[v].at(i));
}
}
}
cout << (dfar % 3 != 1 ? "First" : "Second") << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long, long long>
#define all(a) a.begin(), a.end()
#define INF 10000000000000000
#define endl '\n'
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
using namespace std;
int n;
vector<int> g[200100];
int dist[200100];
signed main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
rep(i, n - 1) {
int a, b;
cin >> a >> b;
a--;
b--;
g[a].push_back(b);
g[b].push_back(a);
}
rep(i, n) dist[i] = INF;
dist[0] = 0;
queue<int> que;
que.push(0);
int vfar = 0, dfar = 0;
while (que.size()) {
int v = que.front();
que.pop();
if (chmax(dfar, dist[v]))
vfar = v;
rep(i, g[v].size()) {
if (dist[g[v].at(i)] > dist[v] + 1) {
dist[g[v].at(i)] = dist[v] + 1;
que.push(g[v].at(i));
}
}
}
rep(i, n) dist[i] = INF;
dist[vfar] = 0;
queue<int> que2;
que2.push(vfar);
dfar = 0;
while (que2.size()) {
int v = que2.front();
que2.pop();
chmax(dfar, dist[v]);
rep(i, g[v].size()) {
if (dist[g[v].at(i)] > dist[v] + 1) {
dist[g[v].at(i)] = dist[v] + 1;
que2.push(g[v].at(i));
}
}
}
cout << (dfar % 3 != 1 ? "First" : "Second") << endl;
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change",
"identifier.change"
] | 870,212 | 870,211 | u807998890 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define foreach(it, v) \
for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
int N;
vi m[200010];
pii visit(int b, int v) {
pii r(0, v);
for (const auto &e : m[v]) {
if (e != b) {
auto t = visit(v, e);
t.fi++;
if (r.fi < t.fi)
r = t;
}
}
return r;
}
int diameter() {
pii r = visit(-1, 1);
pii t = visit(-1, r.se);
return t.fi; // r.se <=> t.se is farthest pair
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
int a, b;
rep(i, N - 1) {
cin >> a >> b;
m[a].pb(b);
m[b].pb(a);
}
int s = diameter();
if (s % 3 == 2)
cout << "First\n";
else
cout << "Second\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define foreach(it, v) \
for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
int N;
vi m[200010];
pii visit(int b, int v) {
pii r(0, v);
for (const auto &e : m[v]) {
if (e != b) {
auto t = visit(v, e);
t.fi++;
if (r.fi < t.fi)
r = t;
}
}
return r;
}
int diameter() {
pii r = visit(-1, 1);
pii t = visit(-1, r.se);
return t.fi; // r.se <=> t.se is farthest pair
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
int a, b;
rep(i, N - 1) {
cin >> a >> b;
m[a].pb(b);
m[b].pb(a);
}
int s = diameter();
if (s % 3 != 1)
cout << "First\n";
else
cout << "Second\n";
return 0;
}
| [] | 870,227 | 870,228 | u807190097 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define foreach(it, v) \
for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
int N;
vi m[200010];
int d[200010];
int s;
int dq(int dep) {
int ma = -1;
int ma2 = -1;
int cnt = 0;
d[dep] = 1;
for (const auto &x : m[dep]) {
if (d[x] == 0) {
int n = dq(x);
if (n > ma) {
ma2 = ma;
ma = n;
} else {
ma2 = max(ma2, n);
}
cnt++;
}
}
int ret;
if (cnt >= 2)
ret = ma + ma2 + 2;
else if (cnt == 1)
ret = ma + 1;
else
ret = 0;
s = max(s, ret);
return ma + 1;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
int a, b;
rep(i, N - 1) {
cin >> a >> b;
m[a].pb(b);
m[b].pb(a);
}
dq(1);
if (s % 3 == 2)
cout << "First\n";
else
cout << "Second\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define foreach(it, v) \
for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
int N;
vi m[200010];
int d[200010];
int s;
int dq(int dep) {
int ma = -1;
int ma2 = -1;
int cnt = 0;
d[dep] = 1;
for (const auto &x : m[dep]) {
if (d[x] == 0) {
int n = dq(x);
if (n > ma) {
ma2 = ma;
ma = n;
} else {
ma2 = max(ma2, n);
}
cnt++;
}
}
int ret;
if (cnt >= 2)
ret = ma + ma2 + 2;
else if (cnt == 1)
ret = ma + 1;
else
ret = 0;
s = max(s, ret);
return ma + 1;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
int a, b;
rep(i, N - 1) {
cin >> a >> b;
m[a].pb(b);
m[b].pb(a);
}
dq(1);
if (s % 3 != 1)
cout << "First\n";
else
cout << "Second\n";
return 0;
}
| [] | 870,229 | 870,230 | u807190097 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
pair<uint64_t, uint64_t>
farthest(uint64_t N, map<uint64_t, set<uint64_t>> &edges, uint64_t src) {
vector<bool> visited(N, false);
stack<pair<uint64_t, uint64_t>> s;
s.emplace(src, 0);
uint64_t max_len = 0, max_len_node = -1;
while (!s.empty()) {
pair<uint64_t, uint64_t> p = s.top();
s.pop();
if (visited[p.first]) {
continue;
}
visited[p.first] = true;
if (max_len < p.second) {
max_len_node = p.first;
max_len = p.second;
}
for (uint64_t next : edges[p.first]) {
if (!visited[next]) {
s.emplace(next, p.second + 1);
}
}
}
return make_pair(max_len_node, max_len);
}
int main() {
uint64_t N;
cin >> N;
map<uint64_t, set<uint64_t>> edges;
for (uint64_t n = 0; n < N; ++n) {
edges.emplace(n, set<uint64_t>());
}
for (uint64_t n = 0; n < N - 1; ++n) {
uint64_t a, b;
cin >> a >> b;
edges[a - 1].insert(b - 1);
edges[b - 1].insert(a - 1);
}
pair<uint64_t, uint64_t> pu = farthest(N, edges, 0);
pair<uint64_t, uint64_t> pv = farthest(N, edges, pu.first);
uint64_t diameter = pv.second;
cout << ((diameter % 3) != 1 ? "First" : "Second") << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
pair<uint64_t, uint64_t>
farthest(uint64_t N, map<uint64_t, set<uint64_t>> &edges, uint64_t src) {
vector<bool> visited(N, false);
stack<pair<uint64_t, uint64_t>> s;
s.emplace(src, 0);
uint64_t max_len = 0, max_len_node = 0;
while (!s.empty()) {
pair<uint64_t, uint64_t> p = s.top();
s.pop();
if (visited[p.first]) {
continue;
}
visited[p.first] = true;
if (max_len < p.second) {
max_len_node = p.first;
max_len = p.second;
}
for (uint64_t next : edges[p.first]) {
if (!visited[next]) {
s.emplace(next, p.second + 1);
}
}
}
return make_pair(max_len_node, max_len);
}
int main() {
uint64_t N;
cin >> N;
map<uint64_t, set<uint64_t>> edges;
for (uint64_t n = 0; n < N; ++n) {
edges.emplace(n, set<uint64_t>());
}
for (uint64_t n = 0; n < N - 1; ++n) {
uint64_t a, b;
cin >> a >> b;
edges[a - 1].insert(b - 1);
edges[b - 1].insert(a - 1);
}
pair<uint64_t, uint64_t> pu = farthest(N, edges, 0);
pair<uint64_t, uint64_t> pv = farthest(N, edges, pu.first);
uint64_t diameter = pv.second;
cout << ((diameter % 3) != 1 ? "First" : "Second") << endl;
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change"
] | 870,239 | 870,240 | u198355306 | cpp |
p03055 | #include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define Relocate \
freopen("./in.txt", "r", stdin), freopen("./out.txt", "w", stdout)
#define up(mi, a, b) for (mi = a; mi <= b; ++mi)
#define down(mi, b, a) for (mi = b; mi >= a; --mi)
#define mfill(a, v) memset(a, v, sizeof(a))
#define INF 0x3f3f3f3f
#define MAX 200005
#define v_n 5005
#define LL long long
#define ULL unsigned long long
#define e_n 50005
#define eps 0.000000001
#define Blen 32
const LL MOD = 998244353;
using namespace std;
const int N = 2e5 + 50;
const int M = 1e6 + 50;
int n, u, v;
struct Edge {
int v, next;
} edge[M];
int cnt;
int head[N], fir[N], sec[N];
bool vis[N];
void init() {
cnt = 0;
memset(head, -1, sizeof(head));
}
void addEdge(int u, int v) {
edge[cnt] = Edge{v, head[u]};
head[u] = cnt++;
edge[cnt] = Edge{u, head[v]};
head[v] = cnt++;
}
int ans;
//树形dp
void dfs(int u) {
vis[u] = 1;
//最长路和次长路
fir[u] = 0;
sec[u] = 0;
for (int i = head[u]; i != -1; i = edge[i].next) {
int v = edge[i].v;
if (!vis[v]) {
//递归下去更新子节点信息
dfs(v);
//子节点的最长路+1更长,可以更新当前节点信息
//当前节点的最长路变成次长路
if (fir[v] + 1 >= fir[u]) {
sec[u] = fir[u];
fir[u] = fir[v] + 1;
}
//子节点信息只能更新次长路
else if (fir[v] + 1 > sec[u]) {
sec[u] = fir[v] + 1;
}
}
}
//更新整个树的信息
ans = max(ans, fir[u] + sec[u]);
return;
}
bool dp[MAX];
int main(void) {
// Relocate;
scanf("%d", &n);
init();
for (int i = 0; i < n - 1; i++) {
scanf("%d%d", &u, &v);
addEdge(u, v);
}
dfs(1);
int i;
dp[1] = 0;
dp[2] = 1;
// cout << ans << endl;
up(i, 3, ans) { dp[i] = (!dp[i - 1] && !dp[i - 2]); }
if (dp[ans]) {
cout << "First\n";
} else {
cout << "Second\n";
}
return 0;
} | #include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define Relocate \
freopen("./in.txt", "r", stdin), freopen("./out.txt", "w", stdout)
#define up(mi, a, b) for (mi = a; mi <= b; ++mi)
#define down(mi, b, a) for (mi = b; mi >= a; --mi)
#define mfill(a, v) memset(a, v, sizeof(a))
#define INF 0x3f3f3f3f
#define MAX 200005
#define v_n 5005
#define LL long long
#define ULL unsigned long long
#define e_n 50005
#define eps 0.000000001
#define Blen 32
const LL MOD = 998244353;
using namespace std;
const int N = 2e5 + 50;
const int M = 1e6 + 50;
int n, u, v;
struct Edge {
int v, next;
} edge[M];
int cnt;
int head[N], fir[N], sec[N];
bool vis[N];
void init() {
cnt = 0;
memset(head, -1, sizeof(head));
}
void addEdge(int u, int v) {
edge[cnt] = Edge{v, head[u]};
head[u] = cnt++;
edge[cnt] = Edge{u, head[v]};
head[v] = cnt++;
}
int ans;
//树形dp
void dfs(int u) {
vis[u] = 1;
//最长路和次长路
fir[u] = 0;
sec[u] = 0;
for (int i = head[u]; i != -1; i = edge[i].next) {
int v = edge[i].v;
if (!vis[v]) {
//递归下去更新子节点信息
dfs(v);
//子节点的最长路+1更长,可以更新当前节点信息
//当前节点的最长路变成次长路
if (fir[v] + 1 >= fir[u]) {
sec[u] = fir[u];
fir[u] = fir[v] + 1;
}
//子节点信息只能更新次长路
else if (fir[v] + 1 > sec[u]) {
sec[u] = fir[v] + 1;
}
}
}
//更新整个树的信息
ans = max(ans, fir[u] + sec[u]);
return;
}
bool dp[MAX];
int main(void) {
// Relocate;
scanf("%d", &n);
init();
for (int i = 0; i < n - 1; i++) {
scanf("%d%d", &u, &v);
addEdge(u, v);
}
dfs(1);
int i;
dp[1] = 0;
dp[2] = 1;
ans++;
up(i, 3, ans) { dp[i] = (!dp[i - 1] && !dp[i - 2]); }
if (!dp[ans]) {
cout << "First\n";
} else {
cout << "Second\n";
}
return 0;
} | [
"expression.unary.arithmetic.add",
"expression.operation.unary.add",
"control_flow.branch.if.condition.change"
] | 870,241 | 870,242 | u305806150 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T, class C> void chmax(T &a, C b) { a > b ?: a = b; }
template <class T, class C> void chmin(T &a, C b) { a < b ?: a = b; }
using Weight = int;
using Capacity = int;
struct Edge {
int src, dst;
Weight weight;
Edge() : src(0), dst(0), weight(0) {}
Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;
void add_edge(Graph &g, int a, int b, Weight w = 1) {
g[a].emplace_back(a, b, w);
g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) {
g[a].emplace_back(a, b, w);
}
Edge double_sweep(const Graph &g, int s = 0) {
static const Weight INF = std::numeric_limits<Weight>::max() / 8;
static const auto bfs = [](const Graph &g, int s, std::queue<int> &q,
std::vector<int> &dist) {
while (q.size())
q.pop();
q.push(s);
int n = g.size();
dist.assign(n, INF);
dist[s] = 0;
while (q.size()) {
int u = q.front();
q.pop();
for (auto &e : g[u]) {
int v = e.dst;
if (dist[v] == INF) {
dist[v] = dist[u] + e.weight;
q.push(v);
}
}
}
return dist;
};
std::vector<Weight> dist;
std::queue<int> q;
bfs(g, s, q, dist);
int n = g.size(), u = -1, v = -1;
for (int i = 0; i < n; i++)
if (dist[i] != INF && (u == -1 || dist[i] > dist[u]))
u = i;
bfs(g, u, q, dist);
for (int i = 0; i < n; i++)
if (dist[i] != INF && (v == -1 || dist[i] > dist[v]))
v = i;
Weight d = dist[v];
if (u > v)
std::swap(u, v);
return Edge(u, v, d);
}
int main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int n;
std::cin >> n;
Graph g(n);
for (int i = 0; i < n - 1; ++i) {
int a, b;
std::cin >> a >> b;
add_edge(g, a - 1, b - 1, 1);
}
int x = double_sweep(g).weight % 3 == 2;
if (x) {
cout << "First" << endl;
} else {
cout << "Second" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T, class C> void chmax(T &a, C b) { a > b ?: a = b; }
template <class T, class C> void chmin(T &a, C b) { a < b ?: a = b; }
using Weight = int;
using Capacity = int;
struct Edge {
int src, dst;
Weight weight;
Edge() : src(0), dst(0), weight(0) {}
Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;
void add_edge(Graph &g, int a, int b, Weight w = 1) {
g[a].emplace_back(a, b, w);
g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) {
g[a].emplace_back(a, b, w);
}
Edge double_sweep(const Graph &g, int s = 0) {
static const Weight INF = std::numeric_limits<Weight>::max() / 8;
static const auto bfs = [](const Graph &g, int s, std::queue<int> &q,
std::vector<int> &dist) {
while (q.size())
q.pop();
q.push(s);
int n = g.size();
dist.assign(n, INF);
dist[s] = 0;
while (q.size()) {
int u = q.front();
q.pop();
for (auto &e : g[u]) {
int v = e.dst;
if (dist[v] == INF) {
dist[v] = dist[u] + e.weight;
q.push(v);
}
}
}
return dist;
};
std::vector<Weight> dist;
std::queue<int> q;
bfs(g, s, q, dist);
int n = g.size(), u = -1, v = -1;
for (int i = 0; i < n; i++)
if (dist[i] != INF && (u == -1 || dist[i] > dist[u]))
u = i;
bfs(g, u, q, dist);
for (int i = 0; i < n; i++)
if (dist[i] != INF && (v == -1 || dist[i] > dist[v]))
v = i;
Weight d = dist[v];
if (u > v)
std::swap(u, v);
return Edge(u, v, d);
}
int main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int n;
std::cin >> n;
Graph g(n);
for (int i = 0; i < n - 1; ++i) {
int a, b;
std::cin >> a >> b;
add_edge(g, a - 1, b - 1, 1);
}
int x = double_sweep(g).weight % 3 != 1;
if (x) {
cout << "First" << endl;
} else {
cout << "Second" << endl;
}
} | [] | 870,247 | 870,248 | u959236700 | cpp |
p03055 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define fr(i, k, N) for (ll i = k; i < N; i++)
#define rep(i, N) for (ll i = 0; i < N; i++)
#define alll(v) v.begin(), v.end()
using namespace std;
template <class X> void pr(X test) { cout << test << endl; }
template <class X> void prr(X test) {
for (auto it : test) {
cout << it << endl;
}
cout << endl;
}
int main() {
ll h, w, n;
cin >> n;
unordered_map<ll, unordered_set<ll>> m;
vector<ll> v(n + 1, 0), kv(n + 1, 0);
rep(i, n - 1) {
ll a, b;
cin >> a >> b;
m[a].insert(b);
m[b].insert(a);
}
stack<ll> s, z;
s.push(1);
v[1] = 1;
ll yy = 0;
ll indx = 0;
while (s.size() > 0) {
auto y = s.top();
s.pop();
auto tmp = v[y];
for (auto it : m[y])
if (v[it] == 0) {
v[it] = tmp + 1;
s.push(it);
if (v[it] > yy)
yy = v[it], indx = it;
}
// pr(s.size());
}
z.push(indx);
v = kv;
s = z;
v[indx] = 1;
yy = 0;
indx = 0;
while (s.size() > 0) {
auto y = s.top();
s.pop();
auto tmp = v[y];
for (auto it : m[y])
if (v[it] == 0) {
v[it] = tmp + 1;
s.push(it);
if (v[it] > yy)
yy = v[it], indx = it;
}
}
auto length = yy;
pr(length);
if (length % 3 == 2)
pr("Second");
else
pr("First");
return 0;
}
class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
// [usage]
// auto uf = new UF(n);
// uf->merge(a, b);
// ...
public:
int *id; // inner id
int cnt; // number of all vartices
int *sz; // sz[i] means size of i's set
UF(int N) {
cnt = N;
id = new int[N];
sz = new int[N];
for (int i = 0; i < N; i++) {
id[i] = i;
sz[i] = 1;
}
}
~UF() {
delete[] id;
delete[] sz;
}
int find(int p) {
int root = p;
while (root != id[root])
root = id[root];
while (p != root) {
int newp = id[p];
id[p] = root;
p = newp;
}
return root;
}
void merge(int x, int y) {
int i = find(x);
int j = find(y);
if (i == j)
return;
if (sz[i] < sz[j]) {
id[i] = j;
sz[j] += sz[i];
} else {
id[j] = i;
sz[i] += sz[j];
}
cnt--;
}
bool connected(int x, int y) { return find(x) == find(y); }
int count() { return cnt; }
}; | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define fr(i, k, N) for (ll i = k; i < N; i++)
#define rep(i, N) for (ll i = 0; i < N; i++)
#define alll(v) v.begin(), v.end()
using namespace std;
template <class X> void pr(X test) { cout << test << endl; }
template <class X> void prr(X test) {
for (auto it : test) {
cout << it << endl;
}
cout << endl;
}
int main() {
ll h, w, n;
cin >> n;
unordered_map<ll, unordered_set<ll>> m;
vector<ll> v(n + 1, 0), kv(n + 1, 0);
rep(i, n - 1) {
ll a, b;
cin >> a >> b;
m[a].insert(b);
m[b].insert(a);
}
stack<ll> s, z;
s.push(1);
v[1] = 1;
ll yy = 0;
ll indx = 0;
while (s.size() > 0) {
auto y = s.top();
s.pop();
auto tmp = v[y];
for (auto it : m[y])
if (v[it] == 0) {
v[it] = tmp + 1;
s.push(it);
if (v[it] > yy)
yy = v[it], indx = it;
}
// pr(s.size());
}
z.push(indx);
v = kv;
s = z;
v[indx] = 1;
yy = 0;
indx = 0;
while (s.size() > 0) {
auto y = s.top();
s.pop();
auto tmp = v[y];
for (auto it : m[y])
if (v[it] == 0) {
v[it] = tmp + 1;
s.push(it);
if (v[it] > yy)
yy = v[it], indx = it;
}
}
auto length = yy;
// pr(length);
if (length % 3 == 2)
pr("Second");
else
pr("First");
return 0;
}
class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
// [usage]
// auto uf = new UF(n);
// uf->merge(a, b);
// ...
public:
int *id; // inner id
int cnt; // number of all vartices
int *sz; // sz[i] means size of i's set
UF(int N) {
cnt = N;
id = new int[N];
sz = new int[N];
for (int i = 0; i < N; i++) {
id[i] = i;
sz[i] = 1;
}
}
~UF() {
delete[] id;
delete[] sz;
}
int find(int p) {
int root = p;
while (root != id[root])
root = id[root];
while (p != root) {
int newp = id[p];
id[p] = root;
p = newp;
}
return root;
}
void merge(int x, int y) {
int i = find(x);
int j = find(y);
if (i == j)
return;
if (sz[i] < sz[j]) {
id[i] = j;
sz[j] += sz[i];
} else {
id[j] = i;
sz[i] += sz[j];
}
cnt--;
}
bool connected(int x, int y) { return find(x) == find(y); }
int count() { return cnt; }
}; | [
"call.remove"
] | 870,249 | 870,250 | u754514364 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll, ll>
#define FOR(I, A, B) for (ll I = int(A); I < int(B); ++I)
#define FORR(I, A, B) for (ll I = int((B)-1); I >= int(A); --I)
#define TO(x, t, f) ((x) ? (t) : (f))
#define SORT(x) (sort(x.begin(), x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x, v) \
(lower_bound(x.begin(), x.end(), v) - x.begin()) // xi>=v x is sorted
#define POSU(x, v) \
(upper_bound(x.begin(), x.end(), v) - x.begin()) // xi>v x is sorted
#define NUM(x, v) (POSU(x, v) - POSL(x, v)) // x is sorted
#define REV(x) (reverse(x.begin(), x.end())) // reverse
ll gcd(ll a, ll b) {
if (a < b)
swap(a, b);
if (a % b == 0)
return b;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll c = gcd(a, b);
return ((a / c) * (b / c) * c);
} // saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(), x.end())
const ll INF = 1e18 + 7;
const ll MOD = 1e9 + 7;
struct Diameter_of_Tree {
int V; // 0-indexd
vector<vector<pair<int, int>>> g;
Diameter_of_Tree(int V_) {
V = V_;
g.resize(V);
}
void add_edge(int v1, int v2, int cost) {
g[v1].push_back({v2, cost});
g[v2].push_back({v1, cost});
}
pair<int, int> tddfs(int v, int par = -1) {
pair<int, int> ret = {0, v};
for (auto &x : g[v]) {
int w, cost;
tie(w, cost) = x;
if (w == par)
continue;
auto r = tddfs(w, v);
ret = max(ret, {cost + r.first, r.second});
}
return ret;
}
int treeDiameter() {
auto v = tddfs(0);
auto w = tddfs(v.second);
return w.first;
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll N;
cin >> N;
Diameter_of_Tree DT(N);
FOR(i, 0, N - 1) {
ll a, b;
cin >> a >> b;
a--;
b--;
DT.add_edge(a, b, 1);
}
ll td = DT.treeDiameter();
if (td % 3 == 2) {
cout << "First" << endl;
} else {
cout << "Second" << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll, ll>
#define FOR(I, A, B) for (ll I = int(A); I < int(B); ++I)
#define FORR(I, A, B) for (ll I = int((B)-1); I >= int(A); --I)
#define TO(x, t, f) ((x) ? (t) : (f))
#define SORT(x) (sort(x.begin(), x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x, v) \
(lower_bound(x.begin(), x.end(), v) - x.begin()) // xi>=v x is sorted
#define POSU(x, v) \
(upper_bound(x.begin(), x.end(), v) - x.begin()) // xi>v x is sorted
#define NUM(x, v) (POSU(x, v) - POSL(x, v)) // x is sorted
#define REV(x) (reverse(x.begin(), x.end())) // reverse
ll gcd(ll a, ll b) {
if (a < b)
swap(a, b);
if (a % b == 0)
return b;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll c = gcd(a, b);
return ((a / c) * (b / c) * c);
} // saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(), x.end())
const ll INF = 1e18 + 7;
const ll MOD = 1e9 + 7;
struct Diameter_of_Tree {
int V; // 0-indexd
vector<vector<pair<int, int>>> g;
Diameter_of_Tree(int V_) {
V = V_;
g.resize(V);
}
void add_edge(int v1, int v2, int cost) {
g[v1].push_back({v2, cost});
g[v2].push_back({v1, cost});
}
pair<int, int> tddfs(int v, int par = -1) {
pair<int, int> ret = {0, v};
for (auto &x : g[v]) {
int w, cost;
tie(w, cost) = x;
if (w == par)
continue;
auto r = tddfs(w, v);
ret = max(ret, {cost + r.first, r.second});
}
return ret;
}
int treeDiameter() {
auto v = tddfs(0);
auto w = tddfs(v.second);
return w.first;
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll N;
cin >> N;
Diameter_of_Tree DT(N);
FOR(i, 0, N - 1) {
ll a, b;
cin >> a >> b;
a--;
b--;
DT.add_edge(a, b, 1);
}
ll td = DT.treeDiameter();
if (td % 3 == 1) {
cout << "Second" << endl;
} else {
cout << "First" << endl;
}
}
| [
"literal.number.change",
"control_flow.branch.if.condition.change",
"literal.string.change",
"io.output.change"
] | 870,253 | 870,254 | u780122303 | cpp |
p03055 | #include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define per(i, a, b) for (ll i = b - 1LL; i >= (a); --i)
#define clr(a, b) memset((a), (b), sizeof(a))
#define ctos(c) string(1, c)
#define print(x) cout << #x << " = " << x << endl;
#define MOD 1000000007
ll p1, p2;
ll mx1, mx2;
vector<vector<ll>> vv;
void dfs(ll a, ll p, ll h) {
if (h > mx1) {
mx1 = h + 1;
p1 = a;
}
if (vv[a].sz == 1 && p != -1) {
return;
}
rep(i, 0, vv[a].sz) {
if (vv[a][i] == p)
continue;
dfs(vv[a][i], a, h + 1);
}
return;
}
int main() {
ll n;
cin >> n;
if (n == 1) {
cout << "First" << endl;
return 0;
}
if (n == 2) {
cout << "Second" << endl;
return 0;
}
vector<vector<ll>> vv_(n, vector<ll>());
vv = vv_;
rep(i, 0, n - 1) {
ll a, b;
cin >> a >> b;
a--;
b--;
vv[a].pb(b);
vv[b].pb(a);
}
mx1 = 0;
dfs(0, -1, 0);
mx1 = 0;
dfs(p1, -1, 0);
if ((mx1 - 2) % 3 == 0) {
cout << "Second" << endl;
} else {
cout << "First" << endl;
}
return 0;
}
| #include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define per(i, a, b) for (ll i = b - 1LL; i >= (a); --i)
#define clr(a, b) memset((a), (b), sizeof(a))
#define ctos(c) string(1, c)
#define print(x) cout << #x << " = " << x << endl;
#define MOD 1000000007
ll p1, p2;
ll mx1, mx2;
vector<vector<ll>> vv;
void dfs(ll a, ll p, ll h) {
if (h + 1 > mx1) {
mx1 = h + 1;
p1 = a;
}
if (vv[a].sz == 1 && p != -1) {
return;
}
rep(i, 0, vv[a].sz) {
if (vv[a][i] == p)
continue;
dfs(vv[a][i], a, h + 1);
}
return;
}
int main() {
ll n;
cin >> n;
if (n == 1) {
cout << "First" << endl;
return 0;
}
if (n == 2) {
cout << "Second" << endl;
return 0;
}
vector<vector<ll>> vv_(n, vector<ll>());
vv = vv_;
rep(i, 0, n - 1) {
ll a, b;
cin >> a >> b;
a--;
b--;
vv[a].pb(b);
vv[b].pb(a);
}
mx1 = 0;
dfs(0, -1, 0);
mx1 = 0;
dfs(p1, -1, 0);
if ((mx1 - 2) % 3 == 0) {
cout << "Second" << endl;
} else {
cout << "First" << endl;
}
return 0;
}
| [
"control_flow.branch.if.condition.change"
] | 870,255 | 870,256 | u764076797 | cpp |
p03055 | #include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
bool used[200000];
vector<int> G[200000];
vector<pii> ds;
void dfs(int v, int d) {
used[v] = true;
bool term = true;
for (auto u : G[v]) {
if (!used[u]) {
term = false;
dfs(u, d + 1);
}
}
if (term)
ds.push_back({d, v});
}
int main() {
int N, a, b;
cin >> N;
REP(i, N - 1) {
cin >> a >> b;
G[a - 1].push_back(b - 1);
G[b - 1].push_back(a - 1);
}
dfs(0, 0);
sort(ALL(ds));
int s = ds[ds.size() - 1].second;
ds = vector<pii>();
REP(i, N) used[i] = false;
dfs(s, 0);
sort(ALL(ds));
s = ds[ds.size() - 1].first;
if ((s - 1) % 3 == 1)
cout << "First" << endl;
else
cout << "Second" << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
bool used[200000];
vector<int> G[200000];
vector<pii> ds;
void dfs(int v, int d) {
used[v] = true;
bool term = true;
for (auto u : G[v]) {
if (!used[u]) {
term = false;
dfs(u, d + 1);
}
}
if (term)
ds.push_back({d, v});
}
int main() {
int N, a, b;
cin >> N;
REP(i, N - 1) {
cin >> a >> b;
G[a - 1].push_back(b - 1);
G[b - 1].push_back(a - 1);
}
dfs(0, 0);
sort(ALL(ds));
int s = ds[ds.size() - 1].second;
ds = vector<pii>();
REP(i, N) used[i] = false;
dfs(s, 0);
sort(ALL(ds));
s = ds[ds.size() - 1].first;
if (s % 3 == 1)
cout << "Second" << endl;
else
cout << "First" << endl;
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.branch.else.remove",
"control_flow.branch.else_if.replace.remove",
"control_flow.branch.if.replace.add"
] | 870,257 | 870,258 | u472675932 | cpp |
p03055 | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#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;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag,
tree_order_statistics_node_update>
pbds;
int h[222222];
vi adj[222222];
void dfs(int u, int p = -1) {
for (int v : adj[u]) {
if (v == p)
continue;
h[v] = h[u] + 1;
dfs(v, u);
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for (int i = 0; i < n - 1; i++) {
int u, v;
cin >> u >> v;
u--;
v--;
adj[u].pb(v);
adj[v].pb(u);
}
dfs(0);
int r = -1;
int mx = -1;
for (int i = 0; i < n; i++) {
if (h[i] > mx) {
mx = h[i];
r = i;
}
}
h[r] = 0;
dfs(r);
r = -1;
mx = -1;
for (int i = 0; i < n; i++) {
if (h[i] > mx) {
mx = h[i];
r = i;
}
}
if (mx <= 2) {
cout << (mx % 2 == 0 ? "First" : "Second") << '\n';
} else {
cout << (mx % 2 ? "First" : "Second") << '\n';
}
}
| #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#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;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag,
tree_order_statistics_node_update>
pbds;
int h[222222];
vi adj[222222];
void dfs(int u, int p = -1) {
for (int v : adj[u]) {
if (v == p)
continue;
h[v] = h[u] + 1;
dfs(v, u);
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for (int i = 0; i < n - 1; i++) {
int u, v;
cin >> u >> v;
u--;
v--;
adj[u].pb(v);
adj[v].pb(u);
}
dfs(0);
int r = -1;
int mx = -1;
for (int i = 0; i < n; i++) {
if (h[i] > mx) {
mx = h[i];
r = i;
}
}
h[r] = 0;
dfs(r);
r = -1;
mx = -1;
for (int i = 0; i < n; i++) {
if (h[i] > mx) {
mx = h[i];
r = i;
}
}
if (mx <= 2) {
cout << (mx % 2 == 0 ? "First" : "Second") << '\n';
} else {
cout << (mx % 3 != 1 ? "First" : "Second") << '\n';
}
}
| [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 870,265 | 870,266 | u955723966 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
template <typename T> struct Dijkstra {
struct Edge {
int to;
T cost;
};
vector<int> prev;
vector<vector<Edge>> g;
Dijkstra(int n) : prev(n, -1), g(n) {}
void addEdge(int u, int v, T w) {
g[u].push_back({v, w});
g[v].push_back({u, w});
}
vector<T> build(int s) {
vector<T> dist(g.size(), -1);
using Node = pair<T, int>;
priority_queue<Node, vector<Node>, greater<Node>> pq;
pq.push({dist[s] = 0, s});
while (!pq.empty()) {
auto d = pq.top().first;
auto u = pq.top().second;
pq.pop();
if (dist[u] < d)
continue;
for (auto &&v : g[u]) {
if (dist[v.to] < 0 || dist[v.to] > dist[u] + v.cost) {
dist[v.to] = dist[u] + v.cost;
prev[v.to] = u;
pq.push({dist[v.to], v.to});
}
}
}
return dist;
}
vector<int> getPath(int t) {
vector<int> path;
for (; t != -1; t = prev[t])
path.push_back(t);
reverse(begin(path), end(path));
return path;
}
};
int main() {
int n;
cin >> n;
Dijkstra<int> g(n);
for (int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
a--, b--;
g.addEdge(a, b, 1);
}
auto d = g.build(0);
int vmx = 0;
for (int i = 0; i < n; i++) {
if (d[vmx] < d[i])
vmx = i;
}
d = g.build(vmx);
int l = 0;
for (int i = 0; i < n; i++) {
l = max(l, d[i]);
}
cout << ((l % 3 == 2) ? "First" : "Second") << endl;
}
| #include <bits/stdc++.h>
using namespace std;
template <typename T> struct Dijkstra {
struct Edge {
int to;
T cost;
};
vector<int> prev;
vector<vector<Edge>> g;
Dijkstra(int n) : prev(n, -1), g(n) {}
void addEdge(int u, int v, T w) {
g[u].push_back({v, w});
g[v].push_back({u, w});
}
vector<T> build(int s) {
vector<T> dist(g.size(), -1);
using Node = pair<T, int>;
priority_queue<Node, vector<Node>, greater<Node>> pq;
pq.push({dist[s] = 0, s});
while (!pq.empty()) {
auto d = pq.top().first;
auto u = pq.top().second;
pq.pop();
if (dist[u] < d)
continue;
for (auto &&v : g[u]) {
if (dist[v.to] < 0 || dist[v.to] > dist[u] + v.cost) {
dist[v.to] = dist[u] + v.cost;
prev[v.to] = u;
pq.push({dist[v.to], v.to});
}
}
}
return dist;
}
vector<int> getPath(int t) {
vector<int> path;
for (; t != -1; t = prev[t])
path.push_back(t);
reverse(begin(path), end(path));
return path;
}
};
int main() {
int n;
cin >> n;
Dijkstra<int> g(n);
for (int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
a--, b--;
g.addEdge(a, b, 1);
}
auto d = g.build(0);
int vmx = 0;
for (int i = 0; i < n; i++) {
if (d[vmx] < d[i])
vmx = i;
}
d = g.build(vmx);
int l = 0;
for (int i = 0; i < n; i++) {
l = max(l, d[i]);
}
cout << (((l + 1) % 3 != 2) ? "First" : "Second") << endl;
}
| [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"io.output.change"
] | 870,267 | 870,268 | u858748695 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 1;
vector<int> to[maxn];
int len, rt, n;
void dfs(int u, int f, int d) {
if (d > len)
len = d, rt = u;
for (auto v : to[u])
if (v != f)
dfs(v, u, d + 1);
}
int main() {
scanf("%d", &n);
for (int i = 2; i <= n; ++i) {
int u, v;
scanf("%d%d", &u, &v);
to[u].push_back(v);
to[v].push_back(u);
}
dfs(1, 0, 0);
dfs(rt, 0, 0);
puts(len % 3 == 2 ? "First" : "Second");
} | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 1;
vector<int> to[maxn];
int len, rt, n;
void dfs(int u, int f, int d) {
if (d > len)
len = d, rt = u;
for (auto v : to[u])
if (v != f)
dfs(v, u, d + 1);
}
int main() {
scanf("%d", &n);
for (int i = 2; i <= n; ++i) {
int u, v;
scanf("%d%d", &u, &v);
to[u].push_back(v);
to[v].push_back(u);
}
dfs(1, 0, 0);
dfs(rt, 0, 0);
puts(len % 3 != 1 ? "First" : "Second");
} | [] | 870,271 | 870,272 | u860951382 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif
#define int ll
#define rep(i, n) for (int i = 0, i##_cond = (n); i < i##_cond; ++i)
#define FOR(i, a, b) for (int i = (a), i##_cond = (b); i < i##_cond; ++i)
#define ROF(i, a, b) for (int i = (a)-1, i##_cond = (b); i >= i##_cond; --i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend() // sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
constexpr ll inf = 1ll << 61;
constexpr ll mod = 1e9 + 7;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> void add(T &a, const T &b) {
a += b;
a %= mod;
}
int n;
vvi g;
pii bfs(int s) { // sを根としてbfs
vi d(n, -1);
queue<int> q;
d[s] = 0;
int maxd = 0;
int pos = s;
q.push(s);
while (!q.empty()) {
int next = q.front();
q.pop();
rep(i, g[next].size()) {
int c = g[next][i];
dump(c);
if (d[c] == -1) {
d[c] = d[next] + 1;
if (chmax(maxd, d[c]))
pos = c;
q.push(c);
}
}
}
dump(pos, maxd);
return pii(pos, maxd);
}
signed main() {
cin >> n;
g.resize(n);
rep(i, n - 1) {
int a, b;
cin >> a >> b;
a--;
b--;
g[a].pb(b);
g[b].pb(a);
}
pii a = bfs(0);
dump(a);
pii b = bfs(a.first);
dump(b);
if (b.second % 3 == 2)
cout << "First" << endl;
else
cout << "Second" << endl;
} | #include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif
#define int ll
#define rep(i, n) for (int i = 0, i##_cond = (n); i < i##_cond; ++i)
#define FOR(i, a, b) for (int i = (a), i##_cond = (b); i < i##_cond; ++i)
#define ROF(i, a, b) for (int i = (a)-1, i##_cond = (b); i >= i##_cond; --i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend() // sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
constexpr ll inf = 1ll << 61;
constexpr ll mod = 1e9 + 7;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> void add(T &a, const T &b) {
a += b;
a %= mod;
}
int n;
vvi g;
pii bfs(int s) { // sを根としてbfs
vi d(n, -1);
queue<int> q;
d[s] = 0;
int maxd = 0;
int pos = s;
q.push(s);
while (!q.empty()) {
int next = q.front();
q.pop();
rep(i, g[next].size()) {
int c = g[next][i];
dump(c);
if (d[c] == -1) {
d[c] = d[next] + 1;
if (chmax(maxd, d[c]))
pos = c;
q.push(c);
}
}
}
dump(pos, maxd);
return pii(pos, maxd);
}
signed main() {
cin >> n;
g.resize(n);
rep(i, n - 1) {
int a, b;
cin >> a >> b;
a--;
b--;
g[a].pb(b);
g[b].pb(a);
}
pii a = bfs(0);
dump(a);
pii b = bfs(a.first);
dump(b);
if (b.second % 3 == 1)
cout << "Second" << endl;
else
cout << "First" << endl;
} | [
"literal.number.change",
"control_flow.branch.if.condition.change",
"control_flow.branch.else.remove",
"control_flow.branch.else_if.replace.remove",
"control_flow.branch.if.replace.add"
] | 870,291 | 870,292 | u900834830 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for (int i = (s); i < (int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for (int i = (int)(s - 1); i >= (int)(e); i--)
#define pb push_back
#define all(r) r.begin(), r.end()
#define rall(r) r.rbegin(), r.rend()
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const int MAX_N = 2e5 + 10;
vector<int> es[MAX_N];
int dist[MAX_N];
void dfs(int cur, int par) {
int d = dist[cur];
for (auto &to : es[cur]) {
if (to == par)
continue;
dist[to] = d + 1;
dfs(to, cur);
}
}
int dist2[MAX_N];
void dfs2(int cur, int par) {
int d = dist2[cur];
for (auto &to : es[cur]) {
if (to == par)
continue;
dist2[to] = d + 1;
dfs2(to, cur);
}
}
int dp[MAX_N];
int main() {
int n;
cin >> n;
rep(i, n - 1) {
int a, b;
cin >> a >> b;
a--;
b--;
es[a].pb(b);
es[b].pb(a);
}
dist[0] = 1;
dfs(0, -1);
int x = 0;
REP(i, 1, n) if (dist[x] < dist[i]) x = i;
dist2[x] = 1;
dfs2(x, -1);
int y = x;
rep(i, n) if (dist2[y] < dist2[i]) y = i;
int d = dist2[y];
dp[0] = 1;
dp[2] = 0;
REP(i, 3, d + 1) {
if (dp[i - 1] == 0 || dp[i - 2] == 0)
dp[i] = 1;
else
dp[i] = 0;
}
cout << (dp[d] ? "First" : "Second") << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for (int i = (s); i < (int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for (int i = (int)(s - 1); i >= (int)(e); i--)
#define pb push_back
#define all(r) r.begin(), r.end()
#define rall(r) r.rbegin(), r.rend()
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const int MAX_N = 2e5 + 10;
vector<int> es[MAX_N];
int dist[MAX_N];
void dfs(int cur, int par) {
int d = dist[cur];
for (auto &to : es[cur]) {
if (to == par)
continue;
dist[to] = d + 1;
dfs(to, cur);
}
}
int dist2[MAX_N];
void dfs2(int cur, int par) {
int d = dist2[cur];
for (auto &to : es[cur]) {
if (to == par)
continue;
dist2[to] = d + 1;
dfs2(to, cur);
}
}
int dp[MAX_N];
int main() {
int n;
cin >> n;
rep(i, n - 1) {
int a, b;
cin >> a >> b;
a--;
b--;
es[a].pb(b);
es[b].pb(a);
}
dist[0] = 1;
dfs(0, -1);
int x = 0;
REP(i, 1, n) if (dist[x] < dist[i]) x = i;
dist2[x] = 1;
dfs2(x, -1);
int y = x;
rep(i, n) if (dist2[y] < dist2[i]) y = i;
int d = dist2[y];
dp[1] = 1;
dp[2] = 0;
REP(i, 3, d + 1) {
if (dp[i - 1] == 0 || dp[i - 2] == 0)
dp[i] = 1;
else
dp[i] = 0;
}
cout << (dp[d] ? "First" : "Second") << endl;
return 0;
} | [
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change"
] | 870,293 | 870,294 | u912359563 | cpp |
p03055 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<vector<int>> graph;
vector<int> depth;
int start;
void dfs(int v) {
for (auto next : graph[v]) {
if (depth[next] == 0 && next != start) {
depth[next] = depth[v] + 1;
dfs(next);
}
}
}
int main() {
int n;
cin >> n;
graph = vector<vector<int>>(n);
for (int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
a--;
b--;
graph[a].push_back(b);
graph[b].push_back(a);
}
depth = vector<int>(n);
start = 0;
dfs(start);
int best = 0;
int how = 0;
for (int i = 0; i < n; i++) {
if (how < depth[i]) {
how = depth[i];
best = i;
}
}
depth = vector<int>(n);
start = best;
dfs(start);
how = 0;
for (int i = 0; i < n; i++)
how = max(how, depth[i]);
cout << (how == 0 || how % 3 == 1 ? "Second" : "First") << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<vector<int>> graph;
vector<int> depth;
int start;
void dfs(int v) {
for (auto next : graph[v]) {
if (depth[next] == 0 && next != start) {
depth[next] = depth[v] + 1;
dfs(next);
}
}
}
int main() {
int n;
cin >> n;
graph = vector<vector<int>>(n);
for (int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
a--;
b--;
graph[a].push_back(b);
graph[b].push_back(a);
}
depth = vector<int>(n);
start = 0;
dfs(start);
int best = 0;
int how = 0;
for (int i = 0; i < n; i++) {
if (how < depth[i]) {
how = depth[i];
best = i;
}
}
depth = vector<int>(n);
start = best;
dfs(start);
how = 0;
for (int i = 0; i < n; i++)
how = max(how, depth[i]);
cout << (how % 3 == 1 ? "Second" : "First") << endl;
return 0;
} | [
"expression.operation.binary.remove"
] | 870,295 | 870,296 | u412908746 | cpp |
p03055 | #define _USE_MATH_DEFINES
#include <bits/stdc++.h> //////////////////////////////////////////
#define deb(...) /////////////////////////////////////////////////
#define DBP(...) /////////////////////////////////////////////////
#ifdef LOC ///////////////////////////////////////////////////////
#include "debuglib.h" /////////////////////////////////////////////
#endif ///////////////////////////////////////////////////////////
#define x first //////////////////////////////////////////////////
#define y second /////////////////////////////////////////////////
#define pb push_back /////////////////////////////////////////////
#define sz(x) int((x).size()) /////////////////////////////////////
#define each(a, x) for (auto &a : (x)) /////////////////////////////////
#define all(x) (x).begin(), (x).end() //////////////////////////////
#define rep(i, b, e) for (int i = (b); i < (e); i++) ///////////////////////
using namespace std;
using ll = long long;
using Pii = pair<int, int>; //
using Vi = vector<int>;
void run();
int main() {
cin.sync_with_stdio ///
(0);
cin.tie(0);
cout << fixed << setprecision(18);
run();
return 0;
} ////
//-------------------------------------------------------------//
struct Vert {
Vi E;
int dist{-1};
};
vector<Vert> G;
void dfs(int i, int p, int d) {
G[i].dist = d;
each(e, G[i].E) if (e != p) dfs(e, i, d + 1);
}
void run() {
int n;
cin >> n;
G.resize(n);
rep(i, 1, n) {
int a, b;
cin >> a >> b;
G[a - 1].E.pb(b - 1);
G[b - 1].E.pb(a - 1);
}
dfs(0, -1, 0);
Pii best = {-1, -1};
rep(i, 0, n) best = max(best, make_pair(G[i].dist, i));
dfs(best.y, -1, 0);
int d = 0;
each(v, G) d = max(d, v.dist);
vector<bool> dp = {1, 0};
while (sz(dp) <= d)
dp.pb(!dp[sz(dp) - 1] || !dp[sz(dp) - 2]);
cout << (dp.back() ? "First\n" : "Second\n");
}
| #define _USE_MATH_DEFINES
#include <bits/stdc++.h> //////////////////////////////////////////
#define deb(...) /////////////////////////////////////////////////
#define DBP(...) /////////////////////////////////////////////////
#ifdef LOC ///////////////////////////////////////////////////////
#include "debuglib.h" /////////////////////////////////////////////
#endif ///////////////////////////////////////////////////////////
#define x first //////////////////////////////////////////////////
#define y second /////////////////////////////////////////////////
#define pb push_back /////////////////////////////////////////////
#define sz(x) int((x).size()) /////////////////////////////////////
#define each(a, x) for (auto &a : (x)) /////////////////////////////////
#define all(x) (x).begin(), (x).end() //////////////////////////////
#define rep(i, b, e) for (int i = (b); i < (e); i++) ///////////////////////
using namespace std;
using ll = long long;
using Pii = pair<int, int>; //
using Vi = vector<int>;
void run();
int main() {
cin.sync_with_stdio ///
(0);
cin.tie(0);
cout << fixed << setprecision(18);
run();
return 0;
} ////
//-------------------------------------------------------------//
struct Vert {
Vi E;
int dist{-1};
};
vector<Vert> G;
void dfs(int i, int p, int d) {
G[i].dist = d;
each(e, G[i].E) if (e != p) dfs(e, i, d + 1);
}
void run() {
int n;
cin >> n;
G.resize(n);
rep(i, 1, n) {
int a, b;
cin >> a >> b;
G[a - 1].E.pb(b - 1);
G[b - 1].E.pb(a - 1);
}
dfs(0, -1, 0);
Pii best = {-1, -1};
rep(i, 0, n) best = max(best, make_pair(G[i].dist, i));
dfs(best.y, -1, 0);
int d = 0;
each(v, G) d = max(d, v.dist);
vector<bool> dp = {1, 0};
while (sz(dp) <= d)
dp.pb(!dp[sz(dp) - 1] || !dp[sz(dp) - 2]);
cout << (dp[d] ? "First\n" : "Second\n");
}
| [
"call.arguments.change"
] | 870,299 | 870,300 | u018915813 | cpp |
p03055 | /*
`-:://:::-
`//:-------:/:`
.+:--.......--:+`
`+:--..`````..--//`
.o:--..`` ``..--:o`
.o:--...```..---+/`
`/y+o/---....---:+o.
`...````-os+/:---:/+o/--.`
`-/+++++/:. `...` :h+d+oooo+/+-` ...
`/++//:::://++-`....` -.`//````````:` `..`
`o+/::------://o/` `-` -. -` `..`
`---.-o/:./o/::-..``..-ЗАПУСКАЕМ .. .. -` `... ``..``
`....o+:-++/:--.```..-://s. `-` .- -` `-o:
.-//::::/:-`
`:s+/:--....-::/+s-` .- `- -` -///:--------:/:`
./s+//:::::://oo-``..НЕЙРОННУЮ: СЕТЬ:::::::-`РАБОТЯГИ
`+:--........--:/`
.:ooo+++++osso-` `.:-...`/` ./::-------:/:` -`
:+--..``````.--:+:...-+:-`
`.-/+++++/+-.-` -. ``:so:/:--.......--:+`
`-```````o+/+--..`````..--:o/-..:s+:.
```````:``.. `-` -`
`+:--..`````..--/+-.../.`````..-o:--.......---/o. `
`: `:- -. .o:--..`` ``..--:o` `-`
`:o+:--------:+o-`
`-`-... .. .o/--...```..--:+/` `-`
`oy/so/////++o/.`
-/` `-` `- ``+s/o/:---...---:++. `-`
.-../d://///:-.`
`.---..``-..- .-/..`````-oo+/:::::/+o+- `-``-` `-.
````
`:++++/+++++- ..``.-/:` /y-:/++o++/:.`..` ./. `-
-++/::::::://+/..:-``:` .. `-.` ```.``` `..` `..`-` `-
`` -o//:--....-::/++` -.-` `-`.-` `..`..` `-.-
-----ss+:++/:--.```..-://s. /. `:: `-:. ./`
`````/:..+o/::-..``.--:/+s. ..-` `-``-` ..` `-` `-`-`
`-s+/::-----::/+oo---``-` .. .:- ``` .-` .-.- `-`
`:oo+//::://+os/..:`..-/:` :y.-:::::::.`.-` ./-` `-`
`./+oooooooo+/.`- .-:...`.. .//:-------://` `- `..` `:.
``.-::::-.``-/` `-` `- `oo:+:--.......--:/` `-
`.:--h.``..```
-.-`.- .- `+:--..`````..--//` `-
/s-//::::::::.
-` `/- .. .o:--..`` ``..--:o.```.-
`//:--------://`
-` .-`.-`
-.`-o/--...```..--:+/.``-:....``:-.+:--....`...--:+`
..`-. `-. ``:os:o/:---...---:++. `-
``///+:-..``````.--:+-````-.`
`.:///////.-` .:-..` -``-+o+/:::::/+o/. `-
`:+:-..`````..--:o/:--/ys+-
`-++///////+o/. ``....`-. :` `.:++++++/:.` .- -o/---......---/o.
`.`
`++//:-----::/+o:..` .-` : ``````` .- `+so+:--------:++-`
`````:-``:o/::-..`..--:/+o` -. `- .- `../../+o+////+o+:.`
-----syo/o+/:--.```..-://s. .-` `- .- `...
``-:////:-``
.` `/s//:--....-::/+s. -. `-` .- `..`
.+o+/:::--:://+s/-..` .::+y ``` .- `..`
./oo++////+oso-` `.... :y-+:::::::/` ...
`.:+oooooo/-` `....-. .//:-------:/:-.`
``...`` /+:+:--.......--:+`
`+:--..`````..--//`
.o:--..`` ``..--:o`
.+/--...```..--:+/`
`-o/:---...---:++.
`-+o+/:---:/+o/.
`.:+oooo+/-.`
``````
*/
#ifdef aimbot
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <limits>
#include <list>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define random escape__from__random__aetuhoetnuhshe
#define mt make_tuple
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define umap unordered_map
#define uset unordered_set
#define elif else if
#define len(v) ((int)v.size())
#define f(i, n) for (int i = 0; i < (n); i++)
#define rof(i, n) for (int i = ((n)-1); i >= 0; i--)
#define apply(v, act) \
for (auto &x : v) { \
act; \
}
#define log(args...) \
{ \
string s = #args; \
deque<string> deq; \
string buf = ""; \
int bal = 0; \
for (char c : s) { \
if (c == '(' || c == '[' || c == '{') { \
bal++; \
} else if (c == ')' || c == ']' || c == '}') { \
bal--; \
} else { \
if (bal == 0) { \
if (c == ',') { \
deq.pb(buf); \
buf = ""; \
} else { \
if (c != ' ') { \
buf += c; \
} \
} \
} \
} \
} \
if (!buf.empty()) { \
deq.pb(buf); \
} \
smart_io::precall_print(); \
smart_io::_print(deq, args); \
}
inline int min(const int &x, const int &y) {
return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x;
}
inline int max(const int &x, const int &y) {
return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y;
}
inline long long min(const long long &x, const long long &y) {
return (((y - x) >> (64 - 1)) & (x ^ y)) ^ x;
}
inline long long max(const long long &x, const long long &y) {
return (((y - x) >> (64 - 1)) & (x ^ y)) ^ y;
}
#define print \
smart_io::precall_print(); \
cout,
#define scan cin,
#ifdef fast_allocator
const int MAXMEM = 200 * 1000 * 1024;
char _memory[MAXMEM];
size_t _ptr = 0;
void *operator new(size_t _x) {
_ptr += _x;
assert(_ptr < MAXMEM);
return _memory + _ptr - _x;
}
void operator delete(void *) noexcept {}
#endif
using namespace std;
char string_in_buffer[(int)260];
void fast_scan(int &x) { scanf("%d", &x); }
void fast_scan(long long &x) { scanf("%lld", &x); }
void fast_scan(unsigned long long &x) { scanf("%llu", &x); }
void fast_scan(double &x) { scanf("%lf", &x); }
void fast_scan(long double &x) { scanf("%Lf", &x); }
void fast_scan(char &x) {
scanf("%c", &x);
if (x == '\n') {
fast_scan(x);
}
}
void fast_scan(string &x) {
scanf("%s", string_in_buffer);
x = string(string_in_buffer);
}
template <class TFirst, class TSecond>
void fast_scan(pair<TFirst, TSecond> &p) {
fast_scan(p.first);
fast_scan(p.second);
}
template <class T> void fast_scan(vector<T> &v) {
for (auto &x : v)
fast_scan(x);
}
void fast_print(const int &x) { printf("%d", x); }
void fast_print(const unsigned int &x) { printf("%u", x); }
void fast_print(const long long &x) { printf("%lld", x); }
void fast_print(const unsigned long long &x) { printf("%llu", x); }
void fast_print(const double &x) { printf("%.15lf", x); }
void fast_print(const long double &x) { printf("%.15Lf", x); }
void fast_print(const char &x) { printf("%c", x); };
void fast_print(const string &x) { printf("%s", x.c_str()); }
void fast_print(const char v[]) { fast_print((string)v); }
template <class TFirst, class TSecond>
void fast_print(const pair<TFirst, TSecond> &p) {
fast_print(p.first);
fast_print(' ');
fast_print(p.second);
}
template <class T> void fast_print(const vector<T> &v) {
if (v.empty())
return;
fast_print(v[0]);
for (int i = 1; i < v.size(); i++) {
fast_print(' ');
fast_print(v[i]);
}
}
template <class T> void fast_print(const vector<vector<T>> &v) {
if (v.empty())
return;
fast_print(v[0]);
for (int i = 1; i < v.size(); i++) {
fast_print('\n');
fast_print(v[i]);
}
}
template <class T> void fast_print(const T &v) {
for (const auto &x : v) {
fast_print(x);
fast_print(' ');
}
}
using namespace std;
namespace smart_io {
string print_start = "";
string sep = " ";
bool first_print = false;
void precall_print() {
fast_print(print_start);
print_start = "\n";
first_print = true;
}
void _print(deque<string>) {}
template <class T, class... Args>
void _print(deque<string> names, T elem, Args... args) {
if (!first_print) {
fast_print("\n");
} else {
first_print = false;
}
fast_print(names.front());
fast_print(" = ");
fast_print(elem);
names.pop_front();
_print(names, args...);
}
} // namespace smart_io
template <class T> ostream &operator,(ostream &os, const T &object) {
if (!smart_io::first_print) {
fast_print(smart_io::sep);
} else {
smart_io::first_print = false;
}
fast_print(object);
return os;
}
template <class T> istream &operator,(istream &is, T &object) {
fast_scan(object);
return is;
}
namespace random {
using namespace std::chrono;
mt19937 rng(duration_cast<milliseconds>(system_clock::now().time_since_epoch())
.count());
uniform_real_distribution<> prob_dist(0.0, 1.0);
}; // namespace random
namespace typedefs {
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef long double ld;
} // namespace typedefs
namespace numbers_operation {
template <class T> T floor_mod(T a, T b) {
if (a >= 0 && b >= 0)
return a % b;
if (a <= 0 && b <= 0)
return a % b;
return abs(b) - (abs(a) % abs(b));
}
} // namespace numbers_operation
using namespace numbers_operation;
using namespace typedefs;
using namespace random;
int n;
vector<vector<int>> g;
pii max_dist(int v, int _p) {
pii _best = mp(0, v);
for (int sub : g[v]) {
if (sub == _p)
continue;
pii t = max_dist(sub, v);
t.x++;
_best = max(_best, t);
}
return _best;
}
signed main(signed argc, char *argv[]) {
scan n;
g.resize(n);
f(i, n - 1) {
int a, b;
scan a, b;
a--;
b--;
g[a].pb(b);
g[b].pb(a);
}
int v = max_dist(0, -1).y;
int d = max_dist(v, -1).x;
print((d + 1) % 3) ? "Second" : "First";
}
| /*
`-:://:::-
`//:-------:/:`
.+:--.......--:+`
`+:--..`````..--//`
.o:--..`` ``..--:o`
.o:--...```..---+/`
`/y+o/---....---:+o.
`...````-os+/:---:/+o/--.`
`-/+++++/:. `...` :h+d+oooo+/+-` ...
`/++//:::://++-`....` -.`//````````:` `..`
`o+/::------://o/` `-` -. -` `..`
`---.-o/:./o/::-..``..-ЗАПУСКАЕМ .. .. -` `... ``..``
`....o+:-++/:--.```..-://s. `-` .- -` `-o:
.-//::::/:-`
`:s+/:--....-::/+s-` .- `- -` -///:--------:/:`
./s+//:::::://oo-``..НЕЙРОННУЮ: СЕТЬ:::::::-`РАБОТЯГИ
`+:--........--:/`
.:ooo+++++osso-` `.:-...`/` ./::-------:/:` -`
:+--..``````.--:+:...-+:-`
`.-/+++++/+-.-` -. ``:so:/:--.......--:+`
`-```````o+/+--..`````..--:o/-..:s+:.
```````:``.. `-` -`
`+:--..`````..--/+-.../.`````..-o:--.......---/o. `
`: `:- -. .o:--..`` ``..--:o` `-`
`:o+:--------:+o-`
`-`-... .. .o/--...```..--:+/` `-`
`oy/so/////++o/.`
-/` `-` `- ``+s/o/:---...---:++. `-`
.-../d://///:-.`
`.---..``-..- .-/..`````-oo+/:::::/+o+- `-``-` `-.
````
`:++++/+++++- ..``.-/:` /y-:/++o++/:.`..` ./. `-
-++/::::::://+/..:-``:` .. `-.` ```.``` `..` `..`-` `-
`` -o//:--....-::/++` -.-` `-`.-` `..`..` `-.-
-----ss+:++/:--.```..-://s. /. `:: `-:. ./`
`````/:..+o/::-..``.--:/+s. ..-` `-``-` ..` `-` `-`-`
`-s+/::-----::/+oo---``-` .. .:- ``` .-` .-.- `-`
`:oo+//::://+os/..:`..-/:` :y.-:::::::.`.-` ./-` `-`
`./+oooooooo+/.`- .-:...`.. .//:-------://` `- `..` `:.
``.-::::-.``-/` `-` `- `oo:+:--.......--:/` `-
`.:--h.``..```
-.-`.- .- `+:--..`````..--//` `-
/s-//::::::::.
-` `/- .. .o:--..`` ``..--:o.```.-
`//:--------://`
-` .-`.-`
-.`-o/--...```..--:+/.``-:....``:-.+:--....`...--:+`
..`-. `-. ``:os:o/:---...---:++. `-
``///+:-..``````.--:+-````-.`
`.:///////.-` .:-..` -``-+o+/:::::/+o/. `-
`:+:-..`````..--:o/:--/ys+-
`-++///////+o/. ``....`-. :` `.:++++++/:.` .- -o/---......---/o.
`.`
`++//:-----::/+o:..` .-` : ``````` .- `+so+:--------:++-`
`````:-``:o/::-..`..--:/+o` -. `- .- `../../+o+////+o+:.`
-----syo/o+/:--.```..-://s. .-` `- .- `...
``-:////:-``
.` `/s//:--....-::/+s. -. `-` .- `..`
.+o+/:::--:://+s/-..` .::+y ``` .- `..`
./oo++////+oso-` `.... :y-+:::::::/` ...
`.:+oooooo/-` `....-. .//:-------:/:-.`
``...`` /+:+:--.......--:+`
`+:--..`````..--//`
.o:--..`` ``..--:o`
.+/--...```..--:+/`
`-o/:---...---:++.
`-+o+/:---:/+o/.
`.:+oooo+/-.`
``````
*/
#ifdef aimbot
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <limits>
#include <list>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define random escape__from__random__aetuhoetnuhshe
#define mt make_tuple
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define umap unordered_map
#define uset unordered_set
#define elif else if
#define len(v) ((int)v.size())
#define f(i, n) for (int i = 0; i < (n); i++)
#define rof(i, n) for (int i = ((n)-1); i >= 0; i--)
#define apply(v, act) \
for (auto &x : v) { \
act; \
}
#define log(args...) \
{ \
string s = #args; \
deque<string> deq; \
string buf = ""; \
int bal = 0; \
for (char c : s) { \
if (c == '(' || c == '[' || c == '{') { \
bal++; \
} else if (c == ')' || c == ']' || c == '}') { \
bal--; \
} else { \
if (bal == 0) { \
if (c == ',') { \
deq.pb(buf); \
buf = ""; \
} else { \
if (c != ' ') { \
buf += c; \
} \
} \
} \
} \
} \
if (!buf.empty()) { \
deq.pb(buf); \
} \
smart_io::precall_print(); \
smart_io::_print(deq, args); \
}
inline int min(const int &x, const int &y) {
return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x;
}
inline int max(const int &x, const int &y) {
return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y;
}
inline long long min(const long long &x, const long long &y) {
return (((y - x) >> (64 - 1)) & (x ^ y)) ^ x;
}
inline long long max(const long long &x, const long long &y) {
return (((y - x) >> (64 - 1)) & (x ^ y)) ^ y;
}
#define print \
smart_io::precall_print(); \
cout,
#define scan cin,
#ifdef fast_allocator
const int MAXMEM = 200 * 1000 * 1024;
char _memory[MAXMEM];
size_t _ptr = 0;
void *operator new(size_t _x) {
_ptr += _x;
assert(_ptr < MAXMEM);
return _memory + _ptr - _x;
}
void operator delete(void *) noexcept {}
#endif
using namespace std;
char string_in_buffer[(int)260];
void fast_scan(int &x) { scanf("%d", &x); }
void fast_scan(long long &x) { scanf("%lld", &x); }
void fast_scan(unsigned long long &x) { scanf("%llu", &x); }
void fast_scan(double &x) { scanf("%lf", &x); }
void fast_scan(long double &x) { scanf("%Lf", &x); }
void fast_scan(char &x) {
scanf("%c", &x);
if (x == '\n') {
fast_scan(x);
}
}
void fast_scan(string &x) {
scanf("%s", string_in_buffer);
x = string(string_in_buffer);
}
template <class TFirst, class TSecond>
void fast_scan(pair<TFirst, TSecond> &p) {
fast_scan(p.first);
fast_scan(p.second);
}
template <class T> void fast_scan(vector<T> &v) {
for (auto &x : v)
fast_scan(x);
}
void fast_print(const int &x) { printf("%d", x); }
void fast_print(const unsigned int &x) { printf("%u", x); }
void fast_print(const long long &x) { printf("%lld", x); }
void fast_print(const unsigned long long &x) { printf("%llu", x); }
void fast_print(const double &x) { printf("%.15lf", x); }
void fast_print(const long double &x) { printf("%.15Lf", x); }
void fast_print(const char &x) { printf("%c", x); };
void fast_print(const string &x) { printf("%s", x.c_str()); }
void fast_print(const char v[]) { fast_print((string)v); }
template <class TFirst, class TSecond>
void fast_print(const pair<TFirst, TSecond> &p) {
fast_print(p.first);
fast_print(' ');
fast_print(p.second);
}
template <class T> void fast_print(const vector<T> &v) {
if (v.empty())
return;
fast_print(v[0]);
for (int i = 1; i < v.size(); i++) {
fast_print(' ');
fast_print(v[i]);
}
}
template <class T> void fast_print(const vector<vector<T>> &v) {
if (v.empty())
return;
fast_print(v[0]);
for (int i = 1; i < v.size(); i++) {
fast_print('\n');
fast_print(v[i]);
}
}
template <class T> void fast_print(const T &v) {
for (const auto &x : v) {
fast_print(x);
fast_print(' ');
}
}
using namespace std;
namespace smart_io {
string print_start = "";
string sep = " ";
bool first_print = false;
void precall_print() {
fast_print(print_start);
print_start = "\n";
first_print = true;
}
void _print(deque<string>) {}
template <class T, class... Args>
void _print(deque<string> names, T elem, Args... args) {
if (!first_print) {
fast_print("\n");
} else {
first_print = false;
}
fast_print(names.front());
fast_print(" = ");
fast_print(elem);
names.pop_front();
_print(names, args...);
}
} // namespace smart_io
template <class T> ostream &operator,(ostream &os, const T &object) {
if (!smart_io::first_print) {
fast_print(smart_io::sep);
} else {
smart_io::first_print = false;
}
fast_print(object);
return os;
}
template <class T> istream &operator,(istream &is, T &object) {
fast_scan(object);
return is;
}
namespace random {
using namespace std::chrono;
mt19937 rng(duration_cast<milliseconds>(system_clock::now().time_since_epoch())
.count());
uniform_real_distribution<> prob_dist(0.0, 1.0);
}; // namespace random
namespace typedefs {
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef long double ld;
} // namespace typedefs
namespace numbers_operation {
template <class T> T floor_mod(T a, T b) {
if (a >= 0 && b >= 0)
return a % b;
if (a <= 0 && b <= 0)
return a % b;
return abs(b) - (abs(a) % abs(b));
}
} // namespace numbers_operation
using namespace numbers_operation;
using namespace typedefs;
using namespace random;
int n;
vector<vector<int>> g;
pii max_dist(int v, int _p) {
pii _best = mp(0, v);
for (int sub : g[v]) {
if (sub == _p)
continue;
pii t = max_dist(sub, v);
t.x++;
_best = max(_best, t);
}
return _best;
}
signed main(signed argc, char *argv[]) {
scan n;
g.resize(n);
f(i, n - 1) {
int a, b;
scan a, b;
a--;
b--;
g[a].pb(b);
g[b].pb(a);
}
int v = max_dist(0, -1).y;
int d = max_dist(v, -1).x;
print((d + 2) % 3) ? "First" : "Second";
}
| [
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change",
"literal.string.change"
] | 870,305 | 870,306 | u656721037 | cpp |
p03055 | /*
ЗАПУСКАЕМ
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
template <typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
#define files(FILENAME) \
read(FILENAME); \
write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
const string FILENAME = "input";
const int MAXN = 200228;
int n;
vector<int> g[MAXN];
bool used[MAXN];
int dist[MAXN];
void dfs(int u) {
used[u] = true;
for (auto h : g[u]) {
if (!used[h]) {
dist[h] = dist[u] + 1;
dfs(h);
}
}
}
int ans = 0;
void dfs1(int u) {
used[u] = true;
chkmax(ans, dist[u]);
for (auto h : g[u]) {
if (!used[h]) {
dist[h] = dist[u] + 1;
dfs1(h);
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
read(FILENAME);
cin >> n;
for (int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
a--, b--;
g[a].pb(b);
g[b].pb(a);
}
memset(used, 0, sizeof(used));
dist[0] = 1;
dfs(0);
int pos = 0;
for (int i = 0; i < n; i++) {
if (dist[i] > dist[pos]) {
pos = i;
}
}
dist[pos] = 1;
memset(used, 0, sizeof(used));
dfs1(pos);
if ((ans) % 3 != 2) {
cout << "First\n";
} else {
cout << "Second\n";
}
return 0;
} | /*
ЗАПУСКАЕМ
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
template <typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
#define files(FILENAME) \
read(FILENAME); \
write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
const string FILENAME = "input";
const int MAXN = 200228;
int n;
vector<int> g[MAXN];
bool used[MAXN];
int dist[MAXN];
void dfs(int u) {
used[u] = true;
for (auto h : g[u]) {
if (!used[h]) {
dist[h] = dist[u] + 1;
dfs(h);
}
}
}
int ans = 0;
void dfs1(int u) {
used[u] = true;
chkmax(ans, dist[u]);
for (auto h : g[u]) {
if (!used[h]) {
dist[h] = dist[u] + 1;
dfs1(h);
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// read(FILENAME);
cin >> n;
for (int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
a--, b--;
g[a].pb(b);
g[b].pb(a);
}
memset(used, 0, sizeof(used));
dist[0] = 1;
dfs(0);
int pos = 0;
for (int i = 0; i < n; i++) {
if (dist[i] > dist[pos]) {
pos = i;
}
}
dist[pos] = 1;
memset(used, 0, sizeof(used));
dfs1(pos);
if ((ans) % 3 != 2) {
cout << "First\n";
} else {
cout << "Second\n";
}
return 0;
} | [
"call.remove"
] | 870,311 | 870,312 | u139147798 | cpp |
p03055 | #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin >>
#define Z class
#define ll long long
#define ln cout << '\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++)
template <Z A> void pr(A a) {
cout << a;
ln;
}
template <Z A, Z B> void pr(A a, B b) {
cout << a << ' ';
pr(b);
}
template <Z A, Z B, Z C> void pr(A a, B b, C c) {
cout << a << ' ';
pr(b, c);
}
template <Z A, Z B, Z C, Z D> void pr(A a, B b, C c, D d) {
cout << a << ' ';
pr(b, c, d);
}
template <Z A> void PR(A a, ll n) {
rep(i, n) {
if (i)
cout << ' ';
cout << a[i];
}
ln;
}
ll check(ll n, ll m, ll x, ll y) { return x >= 0 && x < n && y >= 0 && y < m; }
const ll MAX = 1e9 + 7, MAXL = 1LL << 61, dx[4] = {-1, 0, 1, 0},
dy[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;
vector<int> v[211111];
int d[211111];
P dfs(int x, int t) {
d[x] = t;
P p = P(d[x], x);
rep(i, v[x].size()) if (d[v[x][i]] == MAX) p = max(p, dfs(v[x][i], t + 1));
return p;
}
P calc() {
fill(d, d + 211111, MAX);
P p = dfs(0, 0);
fill(d, d + 211111, MAX);
P q = dfs(p.S, 0);
return P(p.S, q.S);
}
int dp[2][222222];
int dfs2(int nx, int t) {
if (dp[t][nx] != -1)
return dp[t][nx];
int r = t ? 0 : 1;
REP(i, 1, 3) {
if (nx == 2 && i == 2)
continue;
int x = nx - i;
if (x >= 0) {
int z = dfs2(x, t ^ 1);
if (z == t)
r = z;
}
}
dp[t][nx] = r;
return r;
}
void Main() {
ll n;
R n;
rep(i, n - 1) {
int x, y;
cin >> x >> y;
x--, y--;
v[x].pb(y);
v[y].pb(x);
}
P p = calc();
memset(dp, -1, sizeof(dp));
if (dfs2(p.F + 1, 1))
pr("First");
else
pr("Second");
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
Main();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin >>
#define Z class
#define ll long long
#define ln cout << '\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++)
template <Z A> void pr(A a) {
cout << a;
ln;
}
template <Z A, Z B> void pr(A a, B b) {
cout << a << ' ';
pr(b);
}
template <Z A, Z B, Z C> void pr(A a, B b, C c) {
cout << a << ' ';
pr(b, c);
}
template <Z A, Z B, Z C, Z D> void pr(A a, B b, C c, D d) {
cout << a << ' ';
pr(b, c, d);
}
template <Z A> void PR(A a, ll n) {
rep(i, n) {
if (i)
cout << ' ';
cout << a[i];
}
ln;
}
ll check(ll n, ll m, ll x, ll y) { return x >= 0 && x < n && y >= 0 && y < m; }
const ll MAX = 1e9 + 7, MAXL = 1LL << 61, dx[4] = {-1, 0, 1, 0},
dy[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;
vector<int> v[211111];
int d[211111];
P dfs(int x, int t) {
d[x] = t;
P p = P(d[x], x);
rep(i, v[x].size()) if (d[v[x][i]] == MAX) p = max(p, dfs(v[x][i], t + 1));
return p;
}
P calc() {
fill(d, d + 211111, MAX);
P p = dfs(0, 0);
fill(d, d + 211111, MAX);
P q = dfs(p.S, 0);
return P(p.S, q.S);
}
int dp[2][222222];
int dfs2(int nx, int t) {
if (dp[t][nx] != -1)
return dp[t][nx];
int r = t ? 0 : 1;
REP(i, 1, 3) {
if (nx == 2 && i == 2)
continue;
int x = nx - i;
if (x >= 0) {
int z = dfs2(x, t ^ 1);
if (z == t)
r = z;
}
}
dp[t][nx] = r;
return r;
}
void Main() {
ll n;
R n;
rep(i, n - 1) {
int x, y;
cin >> x >> y;
x--, y--;
v[x].pb(y);
v[y].pb(x);
}
P p = calc();
memset(dp, -1, sizeof(dp));
if (dfs2(d[p.S] + 1, 1))
pr("First");
else
pr("Second");
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
Main();
return 0;
}
| [
"control_flow.branch.if.condition.change",
"variable_access.subscript.index.change"
] | 870,317 | 870,318 | u287015418 | cpp |
p03054 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define INF (1e9)
int H, W, N, Sr, Sc;
string S, T;
int main() {
cin >> H >> W >> N;
cin >> Sr >> Sc;
cin >> S;
cin >> T;
Sc--;
Sr--;
// 横 l < Sc < r で落ちない
int l = -1;
int r = W;
if (S[N - 1] == 'L')
l++;
if (S[N - 1] == 'R')
r--;
for (int i = N - 2; i >= 0; i--) {
if (r - l <= 1)
break;
if (T[i] == 'R')
l = min(l - 1, -1);
if (T[i] == 'L')
r = max(r + 1, W);
if (S[i] == 'L')
l++;
if (S[i] == 'R')
r--;
}
if (Sc <= l || r <= Sc) {
cout << "NO" << endl;
return 0;
}
// 縦 u < Sr < d で落ちない
int u = -1;
int d = H;
if (S[N - 1] == 'U')
u++;
if (S[N - 1] == 'D')
d--;
for (int i = N - 2; i >= 0; i--) {
if (r - u <= 1)
break;
if (T[i] == 'D')
u = min(u - 1, -1);
if (T[i] == 'U')
d = max(d + 1, H);
if (S[i] == 'U')
u++;
if (S[i] == 'D')
d--;
}
if (Sr <= u || d <= Sr) {
cout << "NO" << endl;
return 0;
}
cout << "YES" << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define INF (1e9)
int H, W, N, Sr, Sc;
string S, T;
int main() {
cin >> H >> W >> N;
cin >> Sr >> Sc;
cin >> S;
cin >> T;
Sc--;
Sr--;
// 横 l < Sc < r で落ちない
int l = -1;
int r = W;
if (S[N - 1] == 'L')
l++;
if (S[N - 1] == 'R')
r--;
for (int i = N - 2; i >= 0; i--) {
if (r - l <= 1)
break;
if (T[i] == 'R')
l = max(l - 1, -1);
if (T[i] == 'L')
r = min(r + 1, W);
if (S[i] == 'L')
l++;
if (S[i] == 'R')
r--;
}
if (Sc <= l || r <= Sc) {
cout << "NO" << endl;
return 0;
}
// 縦 u < Sr < d で落ちない
int u = -1;
int d = H;
if (S[N - 1] == 'U')
u++;
if (S[N - 1] == 'D')
d--;
for (int i = N - 2; i >= 0; i--) {
if (d - u <= 1)
break;
if (T[i] == 'D')
u = max(u - 1, -1);
if (T[i] == 'U')
d = min(d + 1, H);
if (S[i] == 'U')
u++;
if (S[i] == 'D')
d--;
}
if (Sr <= u || d <= Sr) {
cout << "NO" << endl;
return 0;
}
cout << "YES" << endl;
return 0;
}
| [
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change",
"control_flow.branch.if.condition.change"
] | 870,325 | 870,326 | u551373727 | cpp |
p03054 | #include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i < n; i++)
#define REPR(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define pb(a) push_back(a)
int H, W, N, sr, sc;
string S, T;
int main() {
cin >> H >> W >> N >> sr >> sc;
sr--;
sc--;
cin >> S;
cin >> T;
int startW = 0;
int endW = W;
REPR(i, N) {
//青木のターン
if (T[i] == 'L') {
endW = min(endW + 1, W);
}
if (T[i] == 'R') {
startW = max(startW - 1, 0);
}
//ちょくだいのターン
if (S[i] == 'L') {
startW++;
}
if (S[i] == 'R') {
endW--;
}
if (startW >= endW) { //ここで外に絶対出せることが証明された
cout << "No" << endl;
return 0;
}
}
if ((sc < startW) | (sc >= endW)) { //ここで外に絶対出せることが証明された
cout << "No" << endl;
return 0;
}
int startH = 0;
int endH = H;
REPR(i, N) {
//青木のターン
if (T[i] == 'U') {
endH = min(endH + 1, H);
}
if (T[i] == 'D') {
startH = max(startH - 1, 0);
}
//ちょくだいのターン
if (S[i] == 'U') {
startH++;
}
if (S[i] == 'D') {
endH--;
}
if (startH >= endH) { //ここで外に絶対出せることが証明された
cout << "No" << endl;
return 0;
}
}
if ((sr < startH) | (sr >= endH)) { //ここで外に絶対出せることが証明された
cout << "No" << endl;
return 0;
}
cout << "Yes" << endl;
return 0;
} | #include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i < n; i++)
#define REPR(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define pb(a) push_back(a)
int H, W, N, sr, sc;
string S, T;
int main() {
cin >> H >> W >> N >> sr >> sc;
sr--;
sc--;
cin >> S;
cin >> T;
int startW = 0;
int endW = W;
REPR(i, N) {
//青木のターン
if (T[i] == 'L') {
endW = min(endW + 1, W);
}
if (T[i] == 'R') {
startW = max(startW - 1, 0);
}
//ちょくだいのターン
if (S[i] == 'L') {
startW++;
}
if (S[i] == 'R') {
endW--;
}
if (startW >= endW) { //ここで外に絶対出せることが証明された
cout << "NO" << endl;
return 0;
}
}
if ((sc < startW) | (sc >= endW)) { //ここで外に絶対出せることが証明された
cout << "NO" << endl;
return 0;
}
int startH = 0;
int endH = H;
REPR(i, N) {
//青木のターン
if (T[i] == 'U') {
endH = min(endH + 1, H);
}
if (T[i] == 'D') {
startH = max(startH - 1, 0);
}
//ちょくだいのターン
if (S[i] == 'U') {
startH++;
}
if (S[i] == 'D') {
endH--;
}
if (startH >= endH) { //ここで外に絶対出せることが証明された
cout << "NO" << endl;
return 0;
}
}
if ((sr < startH) | (sr >= endH)) { //ここで外に絶対出せることが証明された
cout << "NO" << endl;
return 0;
}
cout << "YES" << endl;
return 0;
} | [
"literal.string.change",
"literal.string.case.change",
"io.output.change"
] | 870,343 | 870,344 | u837951457 | cpp |
p03054 | #include <algorithm>
#include <iomanip> // std::setw(int), std::setfill(char)
#include <ios> // std::left, std::right
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int H, W, N;
cin >> H >> W >> N;
int sr, sc;
cin >> sr >> sc;
char S[N], T[N];
cin >> S >> T;
// X回めにここにいればOKという場所を上限、下限、左右はしで定義
int U, D, R, L;
U = 1;
D = H;
R = W;
L = 1;
bool judge = true;
for (int i = N - 1; i >= 0; --i) {
//後攻
if (i < N - 1) {
if (T[i] == 'U') {
D = min(H, D + 1);
} else if (T[i] == 'D') {
U = max(1, U - 1);
} else if (T[i] == 'R') {
L = max(1, L - 1);
} else if (T[i] == 'L') {
R = min(W, R + 1);
}
}
//先行
if (S[i] == 'U') {
U++;
} else if (S[i] == 'D') {
D--;
} else if (S[i] == 'L') {
L++;
} else if (S[i] == 'R') {
R--;
}
if (L > R || U > D) {
judge = false;
}
}
if (sr < L || sr > R || sc < U || sc > D) {
judge = false;
}
if (judge) {
cout << "YES"
<< "\n";
} else {
cout << "NO"
<< "\n";
}
return 0;
} | #include <algorithm>
#include <iomanip> // std::setw(int), std::setfill(char)
#include <ios> // std::left, std::right
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int H, W, N;
cin >> H >> W >> N;
int sr, sc;
cin >> sr >> sc;
char S[N], T[N];
cin >> S >> T;
// X回めにここにいればOKという場所を上限、下限、左右はしで定義
int U, D, R, L;
U = 1;
D = H;
R = W;
L = 1;
bool judge = true;
for (int i = N - 1; i >= 0; --i) {
//後攻
if (i < N - 1) {
if (T[i] == 'U') {
D = min(H, D + 1);
} else if (T[i] == 'D') {
U = max(1, U - 1);
} else if (T[i] == 'R') {
L = max(1, L - 1);
} else if (T[i] == 'L') {
R = min(W, R + 1);
}
}
//先行
if (S[i] == 'U') {
U++;
} else if (S[i] == 'D') {
D--;
} else if (S[i] == 'L') {
L++;
} else if (S[i] == 'R') {
R--;
}
if (L > R || U > D) {
judge = false;
}
}
if (sc < L || sc > R || sr < U || sr > D) {
judge = false;
}
if (judge) {
cout << "YES"
<< "\n";
} else {
cout << "NO"
<< "\n";
}
return 0;
}
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 870,345 | 870,346 | u848504701 | cpp |
p03054 |
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)
using namespace std;
typedef pair<int, int> P;
int H, W, N, sx, sy;
string S, T;
bool solve(int len, int pos, int type) {
int left = 1;
int right = len;
char l = type == 0 ? 'L' : 'U';
char r = type == 0 ? 'R' : 'D';
REV(i, N - 1, 0) {
if (T[i] == l) {
right = min(right + 1, len);
} else if (T[i] == r) {
left = max(left - 1, 1LL);
}
if (S[i] == l) {
left++;
} else if (S[i] == r) {
right--;
}
if (left > right)
return false;
}
return left <= pos && pos << right;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> H >> W >> N >> sx >> sy;
cin >> S >> T;
cout << (solve(W, sy, 0) && solve(H, sx, 1) ? "YES" : "NO") << endl;
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)
using namespace std;
typedef pair<int, int> P;
int H, W, N, sx, sy;
string S, T;
bool solve(int len, int pos, int type) {
int left = 1;
int right = len;
char l = type == 0 ? 'L' : 'U';
char r = type == 0 ? 'R' : 'D';
REV(i, N - 1, 0) {
if (T[i] == l) {
right = min(right + 1, len);
} else if (T[i] == r) {
left = max(left - 1, 1LL);
}
if (S[i] == l) {
left++;
} else if (S[i] == r) {
right--;
}
if (left > right)
return false;
}
return left <= pos && pos <= right;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> H >> W >> N >> sx >> sy;
cin >> S >> T;
cout << (solve(W, sy, 0) && solve(H, sx, 1) ? "YES" : "NO") << endl;
return 0;
}
| [
"function.return_value.change",
"expression.operation.binary.change"
] | 870,353 | 870,354 | u516353059 | cpp |
p03054 | #include <bits/stdc++.h>
using namespace std;
int main() {
int H, W, N;
cin >> H >> W >> N;
int r, c;
cin >> r >> c;
string S, T;
cin >> S >> T;
bool ans = true;
int left_out_lim = 0, right_out_lim = W + 1;
int upper_out_lim = 0, lower_out_lim = H + 1;
if (S[N - 1] == 'L')
left_out_lim++;
if (S[N - 1] == 'R')
right_out_lim--;
for (int i = N - 2; i >= 0; --i) {
if (T[i] == 'R')
left_out_lim = max(left_out_lim - 1, 0);
if (T[i] == 'L')
right_out_lim = min(right_out_lim + 1, W + 1);
if (S[i] == 'L')
left_out_lim++;
if (S[i] == 'R')
right_out_lim--;
if (left_out_lim >= right_out_lim)
ans = false;
}
if (S[N - 1] == 'U')
upper_out_lim++;
if (S[N - 1] == 'D')
lower_out_lim--;
for (int i = N - 2; i >= 0; --i) {
if (T[i] == 'D')
upper_out_lim = max(upper_out_lim - 1, 0);
if (T[i] == 'U')
lower_out_lim = min(lower_out_lim + 1, H + 1);
if (S[i] == 'U')
upper_out_lim++;
if (S[i] == 'D')
lower_out_lim--;
if (upper_out_lim >= lower_out_lim)
ans = false;
}
if (left_out_lim >= c || right_out_lim <= c)
ans = false;
if (upper_out_lim >= r || lower_out_lim <= r)
ans = false;
if (ans)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int H, W, N;
cin >> H >> W >> N;
int r, c;
cin >> r >> c;
string S, T;
cin >> S >> T;
bool ans = true;
int left_out_lim = 0, right_out_lim = W + 1;
int upper_out_lim = 0, lower_out_lim = H + 1;
if (S[N - 1] == 'L')
left_out_lim++;
if (S[N - 1] == 'R')
right_out_lim--;
for (int i = N - 2; i >= 0; --i) {
if (T[i] == 'R')
left_out_lim = max(left_out_lim - 1, 0);
if (T[i] == 'L')
right_out_lim = min(right_out_lim + 1, W + 1);
if (S[i] == 'L')
left_out_lim++;
if (S[i] == 'R')
right_out_lim--;
if (left_out_lim >= right_out_lim - 1)
ans = false;
}
if (S[N - 1] == 'U')
upper_out_lim++;
if (S[N - 1] == 'D')
lower_out_lim--;
for (int i = N - 2; i >= 0; --i) {
if (T[i] == 'D')
upper_out_lim = max(upper_out_lim - 1, 0);
if (T[i] == 'U')
lower_out_lim = min(lower_out_lim + 1, H + 1);
if (S[i] == 'U')
upper_out_lim++;
if (S[i] == 'D')
lower_out_lim--;
if (upper_out_lim >= lower_out_lim - 1)
ans = false;
}
if (left_out_lim >= c || right_out_lim <= c)
ans = false;
if (upper_out_lim >= r || lower_out_lim <= r)
ans = false;
if (ans)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 870,360 | 870,361 | u826487371 | cpp |
p03054 | #include <algorithm>
#include <cassert>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
int h, w, n;
cin >> h >> w >> n;
int sr, sc;
cin >> sr >> sc;
string s, t;
cin >> s >> t;
sr--;
sc--;
int ml = 0;
int mr = w - 1;
int mu = 0;
int md = h - 1;
for (int i = n - 1; i >= 0; --i) {
if (t[i] == 'L') {
mr = min(mr + 1, w - 1);
}
if (t[i] == 'R') {
ml = max(ml - 1, 0);
}
if (t[i] == 'U') {
md = min(md + 1, h - 1);
}
if (t[i] == 'D') {
mu = max(mu - 1, 0);
}
if (s[i] == 'L') {
ml++;
}
if (s[i] == 'R') {
mr--;
}
if (s[i] == 'U') {
mu++;
}
if (s[i] == 'D') {
md--;
}
if (mr < ml || md < mu) {
cout << "NO" << endl;
return 0;
}
}
if (mr >= sc || ml <= sc || md >= sr || mu <= sr) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
| #include <algorithm>
#include <cassert>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
int h, w, n;
cin >> h >> w >> n;
int sr, sc;
cin >> sr >> sc;
string s, t;
cin >> s >> t;
sr--;
sc--;
int ml = 0;
int mr = w - 1;
int mu = 0;
int md = h - 1;
for (int i = n - 1; i >= 0; --i) {
if (t[i] == 'L') {
mr = min(mr + 1, w - 1);
}
if (t[i] == 'R') {
ml = max(ml - 1, 0);
}
if (t[i] == 'U') {
md = min(md + 1, h - 1);
}
if (t[i] == 'D') {
mu = max(mu - 1, 0);
}
if (s[i] == 'L') {
ml++;
}
if (s[i] == 'R') {
mr--;
}
if (s[i] == 'U') {
mu++;
}
if (s[i] == 'D') {
md--;
}
if (mr < ml || md < mu) {
cout << "NO" << endl;
return 0;
}
}
if (mr >= sc && ml <= sc && md >= sr && mu <= sr) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
} | [
"misc.opposites",
"control_flow.branch.if.condition.change"
] | 870,383 | 870,384 | u110336920 | cpp |
p03054 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
int main() {
int a, b, n;
cin >> a >> b >> n;
int x, y;
cin >> x >> y;
string s, t;
cin >> s >> t;
int i;
int ue = 1, sita = a;
for (i = n - 1; 0 <= i; i--) {
if (t[i] == 'U')
sita = min(a, sita + 1);
if (t[i] == 'D')
ue = max(1, ue - 1);
if (s[i] == 'U')
ue++;
if (s[i] == 'D')
sita--;
if (x < ue or sita < 0) {
cout << "NO" << endl;
return 0;
}
// cout<<ue<<" "<<sita<<endl;
}
int right = b, left = 1;
for (i = n - 1; 0 <= i; i--) {
if (t[i] == 'L')
right = min(b, right + 1);
if (t[i] == 'R')
left = max(1, left - 1);
if (s[i] == 'L')
left++;
if (s[i] == 'R')
right--;
if (b < left or right < 0) {
cout << "NO" << endl;
return 0;
}
}
// cout<<ue<<" "<<sita<<endl;
// cout<<left<<" "<<right<<endl;
if (x < ue or sita < x or y < left or right < y)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
int main() {
int a, b, n;
cin >> a >> b >> n;
int x, y;
cin >> x >> y;
string s, t;
cin >> s >> t;
int i;
int ue = 1, sita = a;
for (i = n - 1; 0 <= i; i--) {
if (t[i] == 'U')
sita = min(a, sita + 1);
if (t[i] == 'D')
ue = max(1, ue - 1);
if (s[i] == 'U')
ue++;
if (s[i] == 'D')
sita--;
if (a < ue or sita == 0) {
cout << "NO" << endl;
return 0;
}
// cout<<ue<<" "<<sita<<endl;
}
int right = b, left = 1;
for (i = n - 1; 0 <= i; i--) {
if (t[i] == 'L')
right = min(b, right + 1);
if (t[i] == 'R')
left = max(1, left - 1);
if (s[i] == 'L')
left++;
if (s[i] == 'R')
right--;
if (b < left or right == 0) {
cout << "NO" << endl;
return 0;
}
}
// cout<<ue<<" "<<sita<<endl;
// cout<<left<<" "<<right<<endl;
if (x < ue or sita < x or y < left or right < y)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
| [
"identifier.change",
"control_flow.branch.if.condition.change",
"expression.operator.compare.change"
] | 870,395 | 870,394 | u284045566 | cpp |
p03054 | #include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
const int N = 2e5 + 10;
char A[N], B[N];
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
char G[5] = "DRUL";
int main() {
int h, w, n;
scanf("%d%d%d", &h, &w, &n);
int x, y;
scanf("%d%d", &x, &y);
x--, y--;
int x0 = x, y0 = y;
scanf(" %s %s", A, B);
for (int i = 3; i < 4; i++) {
int j = 0;
x = x0, y = y0;
for (j = 0; j < n; j++) {
if (A[j] == G[i]) {
x += dir[i][0], y += dir[i][1];
if (x < 0 || y < 0 || x >= h || y >= w)
break;
}
if (B[j] == G[(i + 2) % 4]) {
x += dir[(i + 2) % 4][0], y += dir[(i + 2) % 4][1];
if (x < 0 || y < 0 || x >= h || y >= w)
x -= dir[(i + 2) % 4][0], y -= dir[(i + 2) % 4][1];
}
} // cout<<j<<"A\n";
if (j != n)
return cout << "NO\n", 0;
}
cout << "YES\n";
}
| #include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
const int N = 2e5 + 10;
char A[N], B[N];
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
char G[5] = "DRUL";
int main() {
int h, w, n;
scanf("%d%d%d", &h, &w, &n);
int x, y;
scanf("%d%d", &x, &y);
x--, y--;
int x0 = x, y0 = y;
scanf(" %s %s", A, B);
for (int i = 0; i < 4; i++) {
int j = 0;
x = x0, y = y0;
for (j = 0; j < n; j++) {
if (A[j] == G[i]) {
x += dir[i][0], y += dir[i][1];
if (x < 0 || y < 0 || x >= h || y >= w)
break;
}
if (B[j] == G[(i + 2) % 4]) {
x += dir[(i + 2) % 4][0], y += dir[(i + 2) % 4][1];
if (x < 0 || y < 0 || x >= h || y >= w)
x -= dir[(i + 2) % 4][0], y -= dir[(i + 2) % 4][1];
}
} // cout<<j<<"A\n";
if (j != n)
return cout << "NO\n", 0;
}
cout << "YES\n";
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change"
] | 870,396 | 870,397 | u906816242 | cpp |
p03054 | #include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
const int N = 2e5 + 10;
char A[N], B[N];
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
char G[5] = "DRUL";
int main() {
int h, w, n;
scanf("%d%d%d", &h, &w, &n);
int x, y;
scanf("%d%d", &x, &y);
x--, y--;
int x0 = x, y0 = y;
scanf(" %s %s", A, B);
for (int i = 0; i < 4; i++) {
int j = 0;
x = x0, y = x0;
for (j = 0; j < n; j++) {
if (A[j] == G[i]) {
x += dir[i][0], y += dir[i][1];
if (x < 0 || y < 0 || x >= h || y >= w)
break;
} // cout<<x<<' '<<y<<'\n';
if (B[j] == G[(i + 2) % 4]) {
x += dir[(i + 2) % 4][0], y += dir[(i + 2) % 4][1];
if (x < 0 || y < 0 || x >= h || y >= w)
x -= dir[(i + 2) % 4][0], y -= dir[(i + 2) % 4][1];
}
// cout<<x<<' '<<y<<'\n';
} // cout<<j<<"A\n";
if (j != n)
return cout << "NO\n", 0;
}
cout << "YES\n";
}
| #include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
const int N = 2e5 + 10;
char A[N], B[N];
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
char G[5] = "DRUL";
int main() {
int h, w, n;
scanf("%d%d%d", &h, &w, &n);
int x, y;
scanf("%d%d", &x, &y);
x--, y--;
int x0 = x, y0 = y;
scanf(" %s %s", A, B);
for (int i = 0; i < 4; i++) {
int j = 0;
x = x0, y = y0;
for (j = 0; j < n; j++) {
if (A[j] == G[i]) {
x += dir[i][0], y += dir[i][1];
if (x < 0 || y < 0 || x >= h || y >= w)
break;
}
if (B[j] == G[(i + 2) % 4]) {
x += dir[(i + 2) % 4][0], y += dir[(i + 2) % 4][1];
if (x < 0 || y < 0 || x >= h || y >= w)
x -= dir[(i + 2) % 4][0], y -= dir[(i + 2) % 4][1];
}
} // cout<<j<<"A\n";
if (j != n)
return cout << "NO\n", 0;
}
cout << "YES\n";
}
| [
"assignment.value.change",
"identifier.change"
] | 870,398 | 870,397 | u906816242 | cpp |
p03054 | #include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
const int N = 1e5 + 10;
char A[N], B[N];
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
char G[5] = "DRUL";
int main() {
int h, w, n;
scanf("%d%d%d", &h, &w, &n);
int x, y;
scanf("%d%d", &x, &y);
x--, y--;
int x0 = x, y0 = y;
scanf(" %s %s", A, B);
for (int i = 0; i < 4; i++) {
int j = 0;
x = x0, y = x0;
for (j = 0; j < n; j++) {
if (A[j] == G[i]) {
x += dir[i][0], y += dir[i][1];
if (x < 0 || y < 0 || x >= h || y >= w)
break;
} // cout<<x<<' '<<y<<'\n';
if (B[j] == G[(i + 2) % 4]) {
x += dir[(i + 2) % 4][0], y += dir[(i + 2) % 4][1];
if (x < 0 || y < 0 || x >= h || y >= w)
x -= dir[(i + 2) % 4][0], y -= dir[(i + 2) % 4][1];
}
// cout<<x<<' '<<y<<'\n';
} // cout<<j<<"A\n";
if (j != n)
return cout << "NO\n", 0;
}
cout << "YES\n";
}
| #include <bits/stdc++.h>
using namespace std;
#define pi pair<int, int>
const int N = 2e5 + 10;
char A[N], B[N];
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
char G[5] = "DRUL";
int main() {
int h, w, n;
scanf("%d%d%d", &h, &w, &n);
int x, y;
scanf("%d%d", &x, &y);
x--, y--;
int x0 = x, y0 = y;
scanf(" %s %s", A, B);
for (int i = 0; i < 4; i++) {
int j = 0;
x = x0, y = y0;
for (j = 0; j < n; j++) {
if (A[j] == G[i]) {
x += dir[i][0], y += dir[i][1];
if (x < 0 || y < 0 || x >= h || y >= w)
break;
}
if (B[j] == G[(i + 2) % 4]) {
x += dir[(i + 2) % 4][0], y += dir[(i + 2) % 4][1];
if (x < 0 || y < 0 || x >= h || y >= w)
x -= dir[(i + 2) % 4][0], y -= dir[(i + 2) % 4][1];
}
} // cout<<j<<"A\n";
if (j != n)
return cout << "NO\n", 0;
}
cout << "YES\n";
}
| [
"literal.number.change",
"expression.operation.binary.change",
"assignment.value.change",
"identifier.change"
] | 870,399 | 870,397 | u906816242 | cpp |
p03054 | #include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i, s, n) for (int(i) = (s); (i) < (n); ++(i))
#define rep(i, n) reps(i, 0, n)
#define reptr(i, n) for (int(i) = (n); (i) >= 0; --(i))
#define All(x) (x).begin(), (x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define pi pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll MOD = 1e9 + 7;
using namespace std;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
signed main() {
ll H, W, N;
ll sr, sc;
string S, T;
cin >> H >> W >> N;
cin >> sr >> sc;
cin >> S >> T;
bool flag = true;
//右に落としたい
ll x = sc;
for (ll i = 0; i < N; i++) {
if (S[i] == 'R')
x++;
if (x == W + 1) {
flag = false;
}
if (T[i] == 'L' && x >= 2)
x--;
}
//左に落としたい
x = sc;
for (ll i = 0; i < N; i++) {
if (S[i] == 'L')
x--;
if (x == 0) {
flag = false;
}
if (T[i] == 'R' && x <= W - 1)
x++;
}
ll y = sr;
//上に落としたい
for (ll i = 0; i < N; i++) {
if (S[i] == 'U')
y++;
if (y == H + 1) {
flag = false;
}
if (T[i] == 'D' && y >= 2)
y--;
}
//下に落としたい
y = sr;
for (ll i = 0; i < N; i++) {
if (S[i] == 'D')
y--;
if (y == 0) {
flag = false;
}
if (T[i] == 'U' && y <= H - 1)
y++;
}
cout << (flag ? "YES" : "NO") << endl;
}
| #include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i, s, n) for (int(i) = (s); (i) < (n); ++(i))
#define rep(i, n) reps(i, 0, n)
#define reptr(i, n) for (int(i) = (n); (i) >= 0; --(i))
#define All(x) (x).begin(), (x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define pi pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll MOD = 1e9 + 7;
using namespace std;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
signed main() {
ll H, W, N;
ll sr, sc;
string S, T;
cin >> H >> W >> N;
cin >> sr >> sc;
cin >> S >> T;
bool flag = true;
//右に落としたい
ll x = sc;
for (ll i = 0; i < N; i++) {
if (S[i] == 'R')
x++;
if (x == W + 1) {
flag = false;
}
if (T[i] == 'L' && x >= 2)
x--;
}
//左に落としたい
x = sc;
for (ll i = 0; i < N; i++) {
if (S[i] == 'L')
x--;
if (x == 0) {
flag = false;
}
if (T[i] == 'R' && x <= W - 1)
x++;
}
ll y = sr;
//上に落としたい
for (ll i = 0; i < N; i++) {
if (S[i] == 'D')
y++;
if (y == H + 1) {
flag = false;
}
if (T[i] == 'U' && y >= 2)
y--;
}
//下に落としたい
y = sr;
for (ll i = 0; i < N; i++) {
if (S[i] == 'U')
y--;
if (y == 0) {
flag = false;
}
if (T[i] == 'D' && y <= H - 1)
y++;
}
cout << (flag ? "YES" : "NO") << endl;
} | [
"literal.string.change",
"control_flow.branch.if.condition.change"
] | 870,418 | 870,419 | u003019316 | cpp |
p03054 | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define lowbit(x) (x) & (-x)
#define sqr(x) (x) * (x)
#define fir first
#define sec second
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define per(i, a, b) for (register int i = a; i >= b; i--)
#define maxd 1000000007
#define eps 1e-6
typedef long long ll;
const int N = 100000;
const double pi = acos(-1.0);
int n, m, k, nx, ny, x, y;
char s[200200], t[200200];
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;
}
int main() {
n = read();
m = read();
k = read();
x = read(), y = read();
scanf("%s%s", s + 1, t + 1);
int nd = n, nu = 1, nl = 1, nr = m;
per(i, k, 1) {
if (t[i] == 'U')
nd = min(nd + 1, n);
else if (t[i] == 'D')
nu = max(nu - 1, 1);
else if (t[i] == 'L')
nr = min(nr + 1, m);
else if (t[i] == 'R')
nl = max(nl - 1, 1);
if (s[i] == 'U')
nu++;
else if (s[i] == 'D')
nd--;
else if (s[i] == 'L')
nl++;
else if (s[i] == 'R')
nr--;
if ((nu > nd) || (nl > nr)) {
puts("NO");
return 0;
}
}
if ((x > nd) || (x < nu) || (y > nl) || (y < nr))
puts("NO");
else
puts("YES");
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define lowbit(x) (x) & (-x)
#define sqr(x) (x) * (x)
#define fir first
#define sec second
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define per(i, a, b) for (register int i = a; i >= b; i--)
#define maxd 1000000007
#define eps 1e-6
typedef long long ll;
const int N = 100000;
const double pi = acos(-1.0);
int n, m, k, nx, ny, x, y;
char s[200200], t[200200];
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;
}
int main() {
n = read();
m = read();
k = read();
x = read(), y = read();
scanf("%s%s", s + 1, t + 1);
int nd = n, nu = 1, nl = 1, nr = m;
per(i, k, 1) {
if (t[i] == 'U')
nd = min(nd + 1, n);
else if (t[i] == 'D')
nu = max(nu - 1, 1);
else if (t[i] == 'L')
nr = min(nr + 1, m);
else if (t[i] == 'R')
nl = max(nl - 1, 1);
if (s[i] == 'U')
nu++;
else if (s[i] == 'D')
nd--;
else if (s[i] == 'L')
nl++;
else if (s[i] == 'R')
nr--;
if ((nu > nd) || (nl > nr)) {
puts("NO");
return 0;
}
}
if ((x > nd) || (x < nu) || (y < nl) || (y > nr))
puts("NO");
else
puts("YES");
return 0;
}
| [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 870,422 | 870,423 | u473013083 | cpp |
p03054 | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define lowbit(x) (x) & (-x)
#define sqr(x) (x) * (x)
#define fir first
#define sec second
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define per(i, a, b) for (register int i = a; i >= b; i--)
#define maxd 1000000007
#define eps 1e-6
typedef long long ll;
const int N = 100000;
const double pi = acos(-1.0);
int n, m, k, nx, ny, x, y;
char s[200200], t[200200];
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;
}
int main() {
n = read();
m = read();
k = read();
x = read(), y = read();
scanf("%s%s", s + 1, t + 1);
int nd = n, nu = 1, nl = 1, nr = m;
per(i, k, 0) {
if (t[i] == 'U')
nd = min(nd + 1, n);
else if (t[i] == 'D')
nu = max(nu - 1, 1);
else if (t[i] == 'L')
nr = min(nr + 1, m);
else if (t[i] == 'R')
nl = max(nl - 1, 1);
if (s[i] == 'U')
nu++;
else if (s[i] == 'D')
nd--;
else if (s[i] == 'L')
nl++;
else if (s[i] == 'R')
nr--;
if ((nu > nd) || (nl > nr)) {
puts("NO");
return 0;
}
}
if ((x > nd) || (x < nu) || (y > nl) || (y < nr))
puts("NO");
else
puts("YES");
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define lowbit(x) (x) & (-x)
#define sqr(x) (x) * (x)
#define fir first
#define sec second
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define per(i, a, b) for (register int i = a; i >= b; i--)
#define maxd 1000000007
#define eps 1e-6
typedef long long ll;
const int N = 100000;
const double pi = acos(-1.0);
int n, m, k, nx, ny, x, y;
char s[200200], t[200200];
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;
}
int main() {
n = read();
m = read();
k = read();
x = read(), y = read();
scanf("%s%s", s + 1, t + 1);
int nd = n, nu = 1, nl = 1, nr = m;
per(i, k, 1) {
if (t[i] == 'U')
nd = min(nd + 1, n);
else if (t[i] == 'D')
nu = max(nu - 1, 1);
else if (t[i] == 'L')
nr = min(nr + 1, m);
else if (t[i] == 'R')
nl = max(nl - 1, 1);
if (s[i] == 'U')
nu++;
else if (s[i] == 'D')
nd--;
else if (s[i] == 'L')
nl++;
else if (s[i] == 'R')
nr--;
if ((nu > nd) || (nl > nr)) {
puts("NO");
return 0;
}
}
if ((x > nd) || (x < nu) || (y < nl) || (y > nr))
puts("NO");
else
puts("YES");
return 0;
}
| [
"literal.number.change",
"call.arguments.change",
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 870,424 | 870,423 | u473013083 | cpp |
p03054 | /// In The Name Of God
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define sz(x) (int)x.size()
#define sqr(x) ((x)*1ll * (x))
#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define Kazakhstan ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define nl '\n'
#define ioi exit(0);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
using namespace std;
int h, w, n;
char s[N], t[N];
int f(int x, int y) { return min(min(y, h - y), min(x, w - x)); }
pair<int, int> nxt(char c) {
if (c == 'L')
return {-1, 0};
if (c == 'R')
return {1, 0};
if (c == 'U')
return {0, 1};
return {0, -1};
}
bool check(int x, int y) { return 1 <= x && x <= w && 1 <= y && y <= h; }
int id(char c) {
if (c == 'L')
return 0;
if (c == 'R')
return 1;
if (c == 'U')
return 2;
return 3;
}
int main() {
#ifdef IOI2018
freopen("in.txt", "r", stdin);
#endif
Kazakhstan cin >> h >> w >> n;
int x, y;
cin >> x >> y;
cin >> s + 1 >> t + 1;
int sx = x, sy = y;
rep(i, 1, n) {
if (s[i] == 'R')
y++;
if (!check(x, y))
cout << "NO", ioi if (t[i] == 'L' && y > 1) y--;
}
x = sx, y = sy;
rep(i, 1, n) {
if (s[i] == 'L')
y--;
if (!check(x, y))
cout << "NO", ioi if (t[i] == 'R' && y < w) y++;
}
x = sx, y = sy;
rep(i, 1, n) {
if (s[i] == 'U')
x--;
if (!check(x, y))
cout << "NO", ioi if (t[i] == 'D' && x < h) x++;
}
x = sx, y = sy;
rep(i, 1, n) {
if (s[i] == 'D')
x++;
if (!check(x, y))
cout << "NO", ioi if (t[i] == 'U' && x > 1) x--;
}
cout << "YES";
ioi
} | /// In The Name Of God
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define sz(x) (int)x.size()
#define sqr(x) ((x)*1ll * (x))
#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define Kazakhstan ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define nl '\n'
#define ioi exit(0);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
using namespace std;
int h, w, n;
char s[N], t[N];
int f(int x, int y) { return min(min(y, h - y), min(x, w - x)); }
pair<int, int> nxt(char c) {
if (c == 'L')
return {-1, 0};
if (c == 'R')
return {1, 0};
if (c == 'U')
return {0, 1};
return {0, -1};
}
bool check(int x, int y) { return 1 <= x && x <= h && 1 <= y && y <= w; }
int id(char c) {
if (c == 'L')
return 0;
if (c == 'R')
return 1;
if (c == 'U')
return 2;
return 3;
}
int main() {
#ifdef IOI2018
freopen("in.txt", "r", stdin);
#endif
Kazakhstan cin >> h >> w >> n;
int x, y;
cin >> x >> y;
cin >> s + 1 >> t + 1;
int sx = x, sy = y;
rep(i, 1, n) {
if (s[i] == 'R')
y++;
if (!check(x, y))
cout << "NO", ioi if (t[i] == 'L' && y > 1) y--;
}
x = sx, y = sy;
rep(i, 1, n) {
if (s[i] == 'L')
y--;
if (!check(x, y))
cout << "NO", ioi if (t[i] == 'R' && y < w) y++;
}
x = sx, y = sy;
rep(i, 1, n) {
if (s[i] == 'U')
x--;
if (!check(x, y))
cout << "NO", ioi if (t[i] == 'D' && x < h) x++;
}
x = sx, y = sy;
rep(i, 1, n) {
if (s[i] == 'D')
x++;
if (!check(x, y))
cout << "NO", ioi if (t[i] == 'U' && x > 1) x--;
}
cout << "YES";
ioi
} | [
"identifier.change",
"function.return_value.change",
"expression.operation.binary.change"
] | 870,427 | 870,428 | u603064316 | cpp |
p03054 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <utility>
#include <vector>
#ifdef XLor
#define dbg(args...) \
do { \
cout << #args << " -> "; \
err(args); \
} while (0)
#else
#define dbg(...)
#endif
void err() { std::cout << std::endl; }
template <typename T, typename... Args> void err(T a, Args... args) {
std::cout << a << ' ';
err(args...);
}
#define ms(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 200000 + 5;
int n, m, q;
PII st;
char s[maxn], t[maxn];
int dp[maxn][4];
int main() {
scanf("%d%d%d%d%d%s%s", &n, &m, &q, &st.first, &st.second, s, t);
int x = st.first, y = st.second, flag = 0;
for (int i = 1; i <= q; i++) {
if (s[i] == 'L')
y--;
if (y == 0)
flag = 1;
if (t[i] == 'R' && y != m)
y++;
}
y = st.second;
for (int i = 1; i <= q; i++) {
if (s[i] == 'R')
y++;
if (y == m + 1)
flag = 1;
if (t[i] == 'L' && y != 1)
y--;
}
for (int i = 1; i <= q; i++) {
if (s[i] == 'U')
x--;
if (x == 0)
flag = 1;
if (t[i] == 'D' && x != n)
x++;
}
x = st.first;
for (int i = 1; i <= q; i++) {
if (s[i] == 'D')
x++;
if (x == n + 1)
flag = 1;
if (t[i] == 'U' && x != 1)
x--;
}
if (flag)
puts("NO");
else
puts("YES");
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <utility>
#include <vector>
#ifdef XLor
#define dbg(args...) \
do { \
cout << #args << " -> "; \
err(args); \
} while (0)
#else
#define dbg(...)
#endif
void err() { std::cout << std::endl; }
template <typename T, typename... Args> void err(T a, Args... args) {
std::cout << a << ' ';
err(args...);
}
#define ms(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 200000 + 5;
int n, m, q;
PII st;
char s[maxn], t[maxn];
int dp[maxn][4];
int main() {
scanf("%d%d%d%d%d%s%s", &n, &m, &q, &st.first, &st.second, s + 1, t + 1);
int x = st.first, y = st.second, flag = 0;
for (int i = 1; i <= q; i++) {
if (s[i] == 'L')
y--;
if (y == 0)
flag = 1;
if (t[i] == 'R' && y != m)
y++;
}
y = st.second;
for (int i = 1; i <= q; i++) {
if (s[i] == 'R')
y++;
if (y == m + 1)
flag = 1;
if (t[i] == 'L' && y != 1)
y--;
}
for (int i = 1; i <= q; i++) {
if (s[i] == 'U')
x--;
if (x == 0)
flag = 1;
if (t[i] == 'D' && x != n)
x++;
}
x = st.first;
for (int i = 1; i <= q; i++) {
if (s[i] == 'D')
x++;
if (x == n + 1)
flag = 1;
if (t[i] == 'U' && x != 1)
x--;
}
if (flag)
puts("NO");
else
puts("YES");
return 0;
}
| [
"expression.operation.binary.add"
] | 870,454 | 870,455 | u419811360 | cpp |
p03054 | #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define MAX_N 200000
string S, T;
bool solve(int H, int W, int N, int r, int c) {
// それぞれ、スタート地点 (sr, sc) から上下左右の境界へのマージン
const int U = r - 1;
const int D = H - c;
const int L = c - 1;
const int R = W - r;
// 高橋くんの移動可能範囲
int sl, sr, su, sd;
sl = sr = su = sd = 0;
// 青木くんの移動可能範囲
int tl, tr, tu, td;
tl = tr = tu = td = 0;
for (int n = 0; n < N; n++) {
if (S[n] == 'L')
sl++;
if (S[n] == 'R')
sr++;
if (S[n] == 'U')
su++;
if (S[n] == 'D')
sd++;
// 高橋くんの移動後に盤の外へ移動できるのなら、こまは残らない。
if (L < sl - tr)
return false;
if (R < sr - tl)
return false;
if (U < su - td)
return false;
if (D < sd - tu)
return false;
// 青木くんは自分盤内に収まるように移動可能範囲を計算しないといけない。
if (T[n] == 'L' && tl - sr < L)
tl++;
if (T[n] == 'R' && tr - sl < R)
tr++;
if (T[n] == 'U' && tu - sd < U)
tu++;
if (T[n] == 'D' && td - su < D)
td++;
}
// 全ての文字を処理後にまだ盤の外へ出ていない。つまり、こまは残る。
return true;
}
int main(int argc, char **argv) {
int H, W, N;
cin >> H >> W >> N;
int sr, sc;
cin >> sr >> sc;
cin >> S;
cin >> T;
bool ans = solve(H, W, N, sr, sc);
if (ans)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define MAX_N 200000
string S, T;
bool solve(int H, int W, int N, int r, int c) {
// それぞれ、スタート地点 (sr, sc) から上下左右の境界へのマージン
const int U = r - 1;
const int D = H - r;
const int L = c - 1;
const int R = W - c;
// 高橋くんの移動可能範囲
int sl, sr, su, sd;
sl = sr = su = sd = 0;
// 青木くんの移動可能範囲
int tl, tr, tu, td;
tl = tr = tu = td = 0;
for (int n = 0; n < N; n++) {
if (S[n] == 'L')
sl++;
if (S[n] == 'R')
sr++;
if (S[n] == 'U')
su++;
if (S[n] == 'D')
sd++;
// 高橋くんの移動後に盤の外へ移動できるのなら、こまは残らない。
if (L < sl - tr)
return false;
if (R < sr - tl)
return false;
if (U < su - td)
return false;
if (D < sd - tu)
return false;
// 青木くんは自分盤内に収まるように移動可能範囲を計算しないといけない。
if (T[n] == 'L' && tl - sr < L)
tl++;
if (T[n] == 'R' && tr - sl < R)
tr++;
if (T[n] == 'U' && tu - sd < U)
tu++;
if (T[n] == 'D' && td - su < D)
td++;
}
// 全ての文字を処理後にまだ盤の外へ出ていない。つまり、こまは残る。
return true;
}
int main(int argc, char **argv) {
int H, W, N;
cin >> H >> W >> N;
int sr, sc;
cin >> sr >> sc;
cin >> S;
cin >> T;
bool ans = solve(H, W, N, sr, sc);
if (ans)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
| [
"identifier.change",
"expression.operation.binary.change"
] | 870,471 | 870,472 | u319818856 | cpp |
p03054 | #include <bits/stdc++.h>
#define _ \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template <class T> void smin(T &a, T val) {
if (a > val)
a = val;
}
template <class T> void smax(T &a, T val) {
if (a < val)
a = val;
}
const int N = 5 * (int)1e5 + 10;
int h, w, n;
int sr, sc;
string s, t;
int32_t main() {
_
cin >>
h >> w >> n;
cin >> sr >> sc;
cin >> s >> t;
int x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'L') {
y--;
}
if (y < 1) {
cout << "NO";
return 0;
}
if (y <= w - 1 and t[i] == 'R') {
++y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'R') {
y++;
}
if (y > w) {
cout << "NO";
return 0;
}
if (y >= 2 and t[i] == 'L') {
--y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'U') {
x--;
}
if (x < 1) {
cout << "NO";
return 0;
}
if (x <= h - 1 and t[i] == 'D' and t[i] <= h) {
++x;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'D') {
y++;
}
if (y > h) {
cout << "NO";
return 0;
}
if (x >= 2 and t[i] == 'U') {
--x;
}
}
cout << "YES";
return 0;
}
// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me
// give it a try. Mistakes made in past -Ques. ask for max-min => think
// binary_search, DP, greedy -not reading question properly / skipping to read &
// understand all samples properly & wasting time in wrong direction. -Using
// wrong indexing in nested loops something like a[i], when it is supposed to be
// a[j](WA) -value of const int N is not correct (WA/RTE). -Did you memset dp to
// -1 ? -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it
// couldn't be solved, but it isn't the case. -Avoid using #define int long long
// as much as possible when it's dp problem and requires high memory say, O(N^2,
// N=5000) (MLE) -Check Bitwise Operator Precedence -Use pragmas to optimize (by
// constant factor) when necessary.. -Think before coding & starting to debug.
// Have patience to look inside code and actually see how it works | #include <bits/stdc++.h>
#define _ \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template <class T> void smin(T &a, T val) {
if (a > val)
a = val;
}
template <class T> void smax(T &a, T val) {
if (a < val)
a = val;
}
const int N = 5 * (int)1e5 + 10;
int h, w, n;
int sr, sc;
string s, t;
int32_t main() {
_
cin >>
h >> w >> n;
cin >> sr >> sc;
cin >> s >> t;
int x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'L') {
y--;
}
if (y < 1) {
cout << "NO";
return 0;
}
if (t[i] <= w - 1 and t[i] == 'R') {
++y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'R') {
y++;
}
if (y > w) {
cout << "NO";
return 0;
}
if (y >= 2 and t[i] == 'L') {
--y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'U') {
x--;
}
if (x < 1) {
cout << "NO";
return 0;
}
if (x <= h - 1 and t[i] == 'D' and t[i] <= h) {
++x;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'D') {
x++;
}
if (x > h) {
cout << "NO";
return 0;
}
if (x >= 2 and t[i] == 'U') {
--x;
}
}
cout << "YES";
return 0;
}
// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me
// give it a try. Mistakes made in past -Ques. ask for max-min => think
// binary_search, DP, greedy -not reading question properly / skipping to read &
// understand all samples properly & wasting time in wrong direction. -Using
// wrong indexing in nested loops something like a[i], when it is supposed to be
// a[j](WA) -value of const int N is not correct (WA/RTE). -Did you memset dp to
// -1 ? -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it
// couldn't be solved, but it isn't the case. -Avoid using #define int long long
// as much as possible when it's dp problem and requires high memory say, O(N^2,
// N=5000) (MLE) -Check Bitwise Operator Precedence -Use pragmas to optimize (by
// constant factor) when necessary.. -Think before coding & starting to debug.
// Have patience to look inside code and actually see how it works
| [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"identifier.change"
] | 870,473 | 870,474 | u063043074 | cpp |
p03054 | #include <bits/stdc++.h>
#define _ \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template <class T> void smin(T &a, T val) {
if (a > val)
a = val;
}
template <class T> void smax(T &a, T val) {
if (a < val)
a = val;
}
const int N = 5 * (int)1e5 + 10;
int h, w, n;
int sr, sc;
string s, t;
int32_t main() {
_
cin >>
h >> w >> n;
cin >> sr >> sc;
cin >> s >> t;
int x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'L') {
y--;
}
if (y < 1) {
cout << "NO";
return 0;
}
if (t[i] <= w - 1 and t[i] == 'R') {
++y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'R') {
y++;
}
if (y > w) {
cout << "NO";
return 0;
}
if (y >= 2 and t[i] == 'L') {
--y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'U') {
x--;
}
if (x < 1) {
cout << "NO";
return 0;
}
if (x <= h - 1 and t[i] == 'D' and t[i] <= h) {
++x;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'D') {
y++;
}
if (y > h) {
cout << "NO";
return 0;
}
if (x >= 2 and t[i] == 'U') {
--x;
}
}
cout << "YES";
return 0;
}
// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me
// give it a try. Mistakes made in past -Ques. ask for max-min => think
// binary_search, DP, greedy -not reading question properly / skipping to read &
// understand all samples properly & wasting time in wrong direction. -Using
// wrong indexing in nested loops something like a[i], when it is supposed to be
// a[j](WA) -value of const int N is not correct (WA/RTE). -Did you memset dp to
// -1 ? -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it
// couldn't be solved, but it isn't the case. -Avoid using #define int long long
// as much as possible when it's dp problem and requires high memory say, O(N^2,
// N=5000) (MLE) -Check Bitwise Operator Precedence -Use pragmas to optimize (by
// constant factor) when necessary.. -Think before coding & starting to debug.
// Have patience to look inside code and actually see how it works | #include <bits/stdc++.h>
#define _ \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template <class T> void smin(T &a, T val) {
if (a > val)
a = val;
}
template <class T> void smax(T &a, T val) {
if (a < val)
a = val;
}
const int N = 5 * (int)1e5 + 10;
int h, w, n;
int sr, sc;
string s, t;
int32_t main() {
_
cin >>
h >> w >> n;
cin >> sr >> sc;
cin >> s >> t;
int x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'L') {
y--;
}
if (y < 1) {
cout << "NO";
return 0;
}
if (t[i] <= w - 1 and t[i] == 'R') {
++y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'R') {
y++;
}
if (y > w) {
cout << "NO";
return 0;
}
if (y >= 2 and t[i] == 'L') {
--y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'U') {
x--;
}
if (x < 1) {
cout << "NO";
return 0;
}
if (x <= h - 1 and t[i] == 'D' and t[i] <= h) {
++x;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'D') {
x++;
}
if (x > h) {
cout << "NO";
return 0;
}
if (x >= 2 and t[i] == 'U') {
--x;
}
}
cout << "YES";
return 0;
}
// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me
// give it a try. Mistakes made in past -Ques. ask for max-min => think
// binary_search, DP, greedy -not reading question properly / skipping to read &
// understand all samples properly & wasting time in wrong direction. -Using
// wrong indexing in nested loops something like a[i], when it is supposed to be
// a[j](WA) -value of const int N is not correct (WA/RTE). -Did you memset dp to
// -1 ? -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it
// couldn't be solved, but it isn't the case. -Avoid using #define int long long
// as much as possible when it's dp problem and requires high memory say, O(N^2,
// N=5000) (MLE) -Check Bitwise Operator Precedence -Use pragmas to optimize (by
// constant factor) when necessary.. -Think before coding & starting to debug.
// Have patience to look inside code and actually see how it works
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 870,475 | 870,474 | u063043074 | cpp |
p03054 | #include <bits/stdc++.h>
#define _ \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template <class T> void smin(T &a, T val) {
if (a > val)
a = val;
}
template <class T> void smax(T &a, T val) {
if (a < val)
a = val;
}
const int N = 5 * (int)1e5 + 10;
int h, w, n;
int sr, sc;
string s, t;
int32_t main() {
_
cin >>
h >> w >> n;
cin >> sr >> sc;
cin >> s >> t;
int x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'L') {
y--;
}
if (y < 1) {
cout << "NO";
return 0;
}
if (t[i] <= w - 1 and t[i] == 'R') {
++y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'R') {
y++;
}
if (y > w) {
cout << "NO";
return 0;
}
if (y >= 2 and t[i] == 'L') {
--y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'U') {
x--;
}
if (x < 1) {
cout << "NO";
return 0;
}
if (x <= h - 1 and t[i] == 'D') {
++x;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'D') {
y++;
}
if (y > h) {
cout << "NO";
return 0;
}
if (x >= 2 and t[i] == 'U') {
--x;
}
}
cout << "YES";
return 0;
}
// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me
// give it a try. Mistakes made in past -Ques. ask for max-min => think
// binary_search, DP, greedy -not reading question properly / skipping to read &
// understand all samples properly & wasting time in wrong direction. -Using
// wrong indexing in nested loops something like a[i], when it is supposed to be
// a[j](WA) -value of const int N is not correct (WA/RTE). -Did you memset dp to
// -1 ? -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it
// couldn't be solved, but it isn't the case. -Avoid using #define int long long
// as much as possible when it's dp problem and requires high memory say, O(N^2,
// N=5000) (MLE) -Check Bitwise Operator Precedence -Use pragmas to optimize (by
// constant factor) when necessary.. -Think before coding & starting to debug.
// Have patience to look inside code and actually see how it works
| #include <bits/stdc++.h>
#define _ \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template <class T> void smin(T &a, T val) {
if (a > val)
a = val;
}
template <class T> void smax(T &a, T val) {
if (a < val)
a = val;
}
const int N = 5 * (int)1e5 + 10;
int h, w, n;
int sr, sc;
string s, t;
int32_t main() {
_
cin >>
h >> w >> n;
cin >> sr >> sc;
cin >> s >> t;
int x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'L') {
y--;
}
if (y < 1) {
cout << "NO";
return 0;
}
if (y <= w - 1 and t[i] == 'R') {
++y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'R') {
y++;
}
if (y > w) {
cout << "NO";
return 0;
}
if (y >= 2 and t[i] == 'L') {
--y;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'U') {
x--;
}
if (x < 1) {
cout << "NO";
return 0;
}
if (x <= h - 1 and t[i] == 'D') {
++x;
}
}
x = sr, y = sc;
for (int i = 0; i < n; ++i) {
if (s[i] == 'D') {
x++;
}
if (x > h) {
cout << "NO";
return 0;
}
if (x >= 2 and t[i] == 'U') {
--x;
}
}
cout << "YES";
return 0;
}
// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me
// give it a try. Mistakes made in past -Ques. ask for max-min => think
// binary_search, DP, greedy -not reading question properly / skipping to read &
// understand all samples properly & wasting time in wrong direction. -Using
// wrong indexing in nested loops something like a[i], when it is supposed to be
// a[j](WA) -value of const int N is not correct (WA/RTE). -Did you memset dp to
// -1 ? -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it
// couldn't be solved, but it isn't the case. -Avoid using #define int long long
// as much as possible when it's dp problem and requires high memory say, O(N^2,
// N=5000) (MLE) -Check Bitwise Operator Precedence -Use pragmas to optimize (by
// constant factor) when necessary.. -Think before coding & starting to debug.
// Have patience to look inside code and actually see how it works
| [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"identifier.change"
] | 870,476 | 870,477 | u063043074 | cpp |
p03054 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int a, b, n, sa, sb;
string s, t;
cin >> a >> b >> n >> sa >> sb >> s >> t;
bool ans = true;
int x1 = 0, x2 = a;
for (int i = n - 1; i >= 0; i--) {
if (t[i] == 'U') {
x2 = min(x2 + 1, a);
}
if (t[i] == 'D') {
x1 = max(x1 - 1, 0);
}
if (s[i] == 'U') {
x1 = min(x1 + 1, a);
if (x1 == a)
ans = false;
}
if (s[i] == 'D') {
x2 = max(x2 - 1, 0);
if (x2 = 0)
ans = false;
}
}
if (sa <= x1 || sa > x2)
ans = false;
int y1 = 0, y2 = b;
for (int i = n - 1; i >= 0; i--) {
if (t[i] == 'L') {
y2 = min(y2 + 1, b);
}
if (t[i] == 'R') {
y1 = max(y1 - 1, 0);
}
if (s[i] == 'L') {
y1 = min(y1 + 1, b);
if (y1 == b)
ans = false;
}
if (s[i] == 'R') {
y2 = max(y2 - 1, 0);
if (y2 == 0)
ans = false;
}
}
if (sb <= y1 || sb > y2)
ans = false;
cout << (ans ? "YES" : "NO") << endl;
// cout << x1 << " " << x2 << " " << y1 << " " << y2 << endl;
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int a, b, n, sa, sb;
string s, t;
cin >> a >> b >> n >> sa >> sb >> s >> t;
bool ans = true;
int x1 = 0, x2 = a;
for (int i = n - 1; i >= 0; i--) {
if (t[i] == 'U') {
x2 = min(x2 + 1, a);
}
if (t[i] == 'D') {
x1 = max(x1 - 1, 0);
}
if (s[i] == 'U') {
x1 = min(x1 + 1, a);
if (x1 == a)
ans = false;
}
if (s[i] == 'D') {
x2 = max(x2 - 1, 0);
if (x2 == 0)
ans = false;
}
}
if (sa <= x1 || sa > x2)
ans = false;
int y1 = 0, y2 = b;
for (int i = n - 1; i >= 0; i--) {
if (t[i] == 'L') {
y2 = min(y2 + 1, b);
}
if (t[i] == 'R') {
y1 = max(y1 - 1, 0);
}
if (s[i] == 'L') {
y1 = min(y1 + 1, b);
if (y1 == b)
ans = false;
}
if (s[i] == 'R') {
y2 = max(y2 - 1, 0);
if (y2 == 0)
ans = false;
}
}
if (sb <= y1 || sb > y2)
ans = false;
cout << (ans ? "YES" : "NO") << endl;
// cout << x1 << " " << x2 << " " << y1 << " " << y2 << endl;
} | [
"expression.operation.compare.replace.add",
"assignment.replace.remove",
"misc.typo"
] | 870,478 | 870,479 | u179970156 | cpp |
p03054 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using _loop_int = int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); i++)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); i++)
#define FORR(i, a, b) \
for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); i--)
#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))
#define ALL(v) (v).begin(), (v).end()
#define DEBUG(x) cerr << #x << ": " << (x) << endl
#define DEBUG_VEC(v) \
cerr << #v << ": "; \
REP(__i, (v).size()) cerr << ((v)[__i]) << ", "; \
cerr << endl
const ll MOD = 1000000007ll;
int h, w, n;
int sr, sc;
char s[252521], t[252521];
vector<pii> ords;
int x;
int low, high;
bool solve() {
int rl = low, rh = high;
FORR(i, 0, ords.size()) {
pii P = ords[i];
if (P.first == 0) {
// takahashi
if (P.second == +1) {
rh--;
} else {
rl++;
}
if (rl >= rh)
return false;
} else {
// aoki
if (P.second == +1) {
rl = max(low, rl - 1);
} else {
rh = min(high, rh + 1);
}
}
}
return rl <= x && x <= rh;
}
int main() {
scanf("%d%d%d", &h, &w, &n);
scanf("%d%d", &sr, &sc);
--sr;
--sc;
scanf("%s%s", s, t);
{
x = sc;
low = 0;
high = w;
ords.clear();
REP(i, n) {
if (s[i] == 'L')
ords.push_back(pii(0, -1));
if (s[i] == 'R')
ords.push_back(pii(0, +1));
if (t[i] == 'L')
ords.push_back(pii(1, -1));
if (t[i] == 'R')
ords.push_back(pii(1, +1));
}
if (!solve()) {
puts("NO");
return 0;
}
}
{
x = sr;
low = 0;
high = h;
ords.clear();
REP(i, n) {
if (s[i] == 'U')
ords.push_back(pii(0, -1));
if (s[i] == 'D')
ords.push_back(pii(0, +1));
if (t[i] == 'U')
ords.push_back(pii(1, -1));
if (t[i] == 'D')
ords.push_back(pii(1, +1));
}
if (!solve()) {
puts("NO");
return 0;
}
}
puts("YES");
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using _loop_int = int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); i++)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); i++)
#define FORR(i, a, b) \
for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); i--)
#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))
#define ALL(v) (v).begin(), (v).end()
#define DEBUG(x) cerr << #x << ": " << (x) << endl
#define DEBUG_VEC(v) \
cerr << #v << ": "; \
REP(__i, (v).size()) cerr << ((v)[__i]) << ", "; \
cerr << endl
const ll MOD = 1000000007ll;
int h, w, n;
int sr, sc;
char s[252521], t[252521];
vector<pii> ords;
int x;
int low, high;
bool solve() {
int rl = low, rh = high;
FORR(i, 0, ords.size()) {
pii P = ords[i];
if (P.first == 0) {
// takahashi
if (P.second == +1) {
rh--;
} else {
rl++;
}
if (rl >= rh)
return false;
} else {
// aoki
if (P.second == +1) {
rl = max(low, rl - 1);
} else {
rh = min(high, rh + 1);
}
}
}
return rl <= x && x < rh;
}
int main() {
scanf("%d%d%d", &h, &w, &n);
scanf("%d%d", &sr, &sc);
--sr;
--sc;
scanf("%s%s", s, t);
{
x = sc;
low = 0;
high = w;
ords.clear();
REP(i, n) {
if (s[i] == 'L')
ords.push_back(pii(0, -1));
if (s[i] == 'R')
ords.push_back(pii(0, +1));
if (t[i] == 'L')
ords.push_back(pii(1, -1));
if (t[i] == 'R')
ords.push_back(pii(1, +1));
}
if (!solve()) {
puts("NO");
return 0;
}
}
{
x = sr;
low = 0;
high = h;
ords.clear();
REP(i, n) {
if (s[i] == 'U')
ords.push_back(pii(0, -1));
if (s[i] == 'D')
ords.push_back(pii(0, +1));
if (t[i] == 'U')
ords.push_back(pii(1, -1));
if (t[i] == 'D')
ords.push_back(pii(1, +1));
}
if (!solve()) {
puts("NO");
return 0;
}
}
puts("YES");
return 0;
}
| [
"expression.operator.compare.change",
"function.return_value.change",
"expression.operation.binary.change"
] | 870,482 | 870,483 | u462560753 | cpp |
p03054 | #include <bits/stdc++.h>
using namespace std;
#define FastRead \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i, a, n) for (int i = (a); i <= (n); ++i)
#define RFOR(i, a, n) for (int i = (n); i >= (a); --i)
#define FI(i, n) for (int i = 0; i < (n); ++i)
#define ZERO(a) memset((a), 0, sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(), g.end()
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including
// tree_order_statistics_node_updat using namespace __gnu_pbds; typedef tree<ll,
// null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
// ordered_set;
// I am questioning life and universe and
// everything else after looking at this
const ll MAXN = 2e5 + 10;
string s1, s2;
ll a, b;
ll H, W, N;
void solve() {
cin >> H >> W >> N;
ll x, y;
cin >> x >> y;
cin >> s1 >> s2;
a = N;
s1 = '(' + s1, s2 = '(' + s2;
bool ans = true;
ll n_x = x;
FOR(i, 1, a) {
if (s1[i] == 'L')
n_x = n_x - 1;
if (n_x < 1) {
ans = false;
break;
}
if (s2[i] == 'R')
n_x = min(n_x + 1, W);
}
if (!ans) {
cout << "NO\n";
return;
}
n_x = x;
FOR(i, 1, a) {
if (s1[i] == 'R')
n_x = n_x + 1;
if (n_x > W) {
ans = false;
break;
}
if (s2[i] == 'L')
n_x = max(1LL, n_x - 1);
}
if (!ans) {
cout << "NO\n";
return;
}
ll n_y = y;
FOR(i, 1, a) {
if (s1[i] == 'U')
n_y = n_y - 1;
if (n_y < 1) {
ans = false;
break;
}
if (s2[i] == 'D')
n_y = min(H, n_y + 1);
}
if (!ans) {
cout << "NO\n";
return;
}
n_y = y;
FOR(i, 1, a) {
if (s1[i] == 'D')
n_y = n_y + 1;
if (n_y > H) {
ans = false;
break;
}
if (s2[i] == 'U')
n_y = max(n_y - 1, 1LL);
}
if (!ans) {
cout << "NO\n";
return;
}
cout << "YES\n";
}
signed main() {
FastRead;
ll t, w;
t = 1;
// cin>>t;
FOR(i, 1, t) { solve(); }
}
| #include <bits/stdc++.h>
using namespace std;
#define FastRead \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i, a, n) for (int i = (a); i <= (n); ++i)
#define RFOR(i, a, n) for (int i = (n); i >= (a); --i)
#define FI(i, n) for (int i = 0; i < (n); ++i)
#define ZERO(a) memset((a), 0, sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(), g.end()
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including
// tree_order_statistics_node_updat using namespace __gnu_pbds; typedef tree<ll,
// null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
// ordered_set;
// I am questioning life and universe and
// everything else after looking at this
const ll MAXN = 2e5 + 10;
string s1, s2;
ll a, b;
ll H, W, N;
void solve() {
cin >> H >> W >> N;
ll x, y;
cin >> y >> x;
cin >> s1 >> s2;
a = N;
s1 = '(' + s1, s2 = '(' + s2;
bool ans = true;
ll n_x = x;
FOR(i, 1, a) {
if (s1[i] == 'L')
n_x = n_x - 1;
if (n_x < 1) {
ans = false;
break;
}
if (s2[i] == 'R')
n_x = min(n_x + 1, W);
}
if (!ans) {
cout << "NO\n";
return;
}
n_x = x;
FOR(i, 1, a) {
if (s1[i] == 'R')
n_x = n_x + 1;
if (n_x > W) {
ans = false;
break;
}
if (s2[i] == 'L')
n_x = max(1LL, n_x - 1);
}
if (!ans) {
cout << "NO\n";
return;
}
ll n_y = y;
FOR(i, 1, a) {
if (s1[i] == 'U')
n_y = n_y - 1;
if (n_y < 1) {
ans = false;
break;
}
if (s2[i] == 'D')
n_y = min(H, n_y + 1);
}
if (!ans) {
cout << "NO\n";
return;
}
n_y = y;
FOR(i, 1, a) {
if (s1[i] == 'D')
n_y = n_y + 1;
if (n_y > H) {
ans = false;
break;
}
if (s2[i] == 'U')
n_y = max(n_y - 1, 1LL);
}
if (!ans) {
cout << "NO\n";
return;
}
cout << "YES\n";
}
signed main() {
FastRead;
ll t, w;
t = 1;
// cin>>t;
FOR(i, 1, t) { solve(); }
}
| [
"expression.operation.binary.remove"
] | 870,486 | 870,487 | u612858131 | cpp |
p03054 | // ihdignite
#include <bits/stdc++.h>
using namespace std;
bool solve(int n, int a, string sa, string sb, char ca, char cb, int s) {
int l = 0, r = s + 1;
for (int i = n - 1; i >= 0; i--) {
if (sb[i] == ca) {
r = min(r + 1, s + 1);
}
if (sb[i] == cb) {
l = max(l - 1, 0);
}
if (sa[i] == ca) {
l = l + 1;
}
if (sa[i] == cb) {
r = r - 1;
}
if (l >= r) {
return 0;
}
}
return a > l && a < r;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int h, w, n, sr, sc;
string sa, sb;
cin >> h >> w >> n >> sr >> sc >> sa >> sb;
cout << (solve(n, sr, sa, sb, 'U', 'D', h) &&
solve(n, sc, sa, sb, 'L', 'R', w)
? "YES"
: "NO")
<< '\n';
return 0;
} | // ihdignite
#include <bits/stdc++.h>
using namespace std;
bool solve(int n, int a, string sa, string sb, char ca, char cb, int s) {
int l = 0, r = s + 1;
for (int i = n - 1; i >= 0; i--) {
if (sb[i] == ca) {
r = min(r + 1, s + 1);
}
if (sb[i] == cb) {
l = max(l - 1, 0);
}
if (sa[i] == ca) {
l = l + 1;
}
if (sa[i] == cb) {
r = r - 1;
}
if (l + 1 >= r) {
return 0;
}
}
return a > l && a < r;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int h, w, n, sr, sc;
string sa, sb;
cin >> h >> w >> n >> sr >> sc >> sa >> sb;
cout << (solve(n, sr, sa, sb, 'U', 'D', h) &&
solve(n, sc, sa, sb, 'L', 'R', w)
? "YES"
: "NO")
<< '\n';
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 870,490 | 870,491 | u996953683 | cpp |
p03054 | // ihdignite
#include <bits/stdc++.h>
using namespace std;
bool solve(int n, int a, string sa, string sb, char ca, char cb, int s) {
int l = 0, r = l + 1;
for (int i = n - 1; i >= 0; i--) {
if (sb[i] == ca) {
r = min(r + 1, s + 1);
}
if (sb[i] == cb) {
l = max(l - 1, 0);
}
if (sa[i] == ca) {
l = l + 1;
}
if (sa[i] == cb) {
r = r - 1;
}
if (l >= r) {
return 0;
}
}
return a > l && a < r;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int h, w, n, sr, sc;
string sa, sb;
cin >> h >> w >> n >> sr >> sc >> sa >> sb;
cout << (solve(n, sr, sa, sb, 'U', 'D', h) &&
solve(n, sc, sa, sb, 'L', 'R', w)
? "YES"
: "NO")
<< '\n';
return 0;
} | // ihdignite
#include <bits/stdc++.h>
using namespace std;
bool solve(int n, int a, string sa, string sb, char ca, char cb, int s) {
int l = 0, r = s + 1;
for (int i = n - 1; i >= 0; i--) {
if (sb[i] == ca) {
r = min(r + 1, s + 1);
}
if (sb[i] == cb) {
l = max(l - 1, 0);
}
if (sa[i] == ca) {
l = l + 1;
}
if (sa[i] == cb) {
r = r - 1;
}
if (l + 1 >= r) {
return 0;
}
}
return a > l && a < r;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int h, w, n, sr, sc;
string sa, sb;
cin >> h >> w >> n >> sr >> sc >> sa >> sb;
cout << (solve(n, sr, sa, sb, 'U', 'D', h) &&
solve(n, sc, sa, sb, 'L', 'R', w)
? "YES"
: "NO")
<< '\n';
return 0;
} | [
"identifier.change",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 870,492 | 870,491 | u996953683 | cpp |
p03054 | // ihdignite
#include <bits/stdc++.h>
using namespace std;
bool solve(int n, int a, string sa, string sb, char ca, char cb, int s) {
int l = 0, r = l + 1;
for (int i = n - 1; i >= 0; i--) {
if (sb[i] == ca) {
r = min(r + 1, l + 1);
}
if (sb[i] == cb) {
l = max(l - 1, 0);
}
if (sa[i] == ca) {
l = l + 1;
}
if (sa[i] == cb) {
r = r - 1;
}
if (l >= r) {
return 0;
}
}
return a > l && a < r;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int h, w, n, sr, sc;
string sa, sb;
cin >> h >> w >> n >> sr >> sc >> sa >> sb;
cout << (solve(n, sr, sa, sb, 'U', 'D', h) &&
solve(n, sc, sa, sb, 'L', 'R', w)
? "YES"
: "NO")
<< '\n';
return 0;
} | // ihdignite
#include <bits/stdc++.h>
using namespace std;
bool solve(int n, int a, string sa, string sb, char ca, char cb, int s) {
int l = 0, r = s + 1;
for (int i = n - 1; i >= 0; i--) {
if (sb[i] == ca) {
r = min(r + 1, s + 1);
}
if (sb[i] == cb) {
l = max(l - 1, 0);
}
if (sa[i] == ca) {
l = l + 1;
}
if (sa[i] == cb) {
r = r - 1;
}
if (l + 1 >= r) {
return 0;
}
}
return a > l && a < r;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int h, w, n, sr, sc;
string sa, sb;
cin >> h >> w >> n >> sr >> sc >> sa >> sb;
cout << (solve(n, sr, sa, sb, 'U', 'D', h) &&
solve(n, sc, sa, sb, 'L', 'R', w)
? "YES"
: "NO")
<< '\n';
return 0;
} | [
"identifier.change",
"expression.operation.binary.change",
"assignment.value.change",
"call.arguments.change",
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 870,493 | 870,491 | u996953683 | cpp |
p03054 | #include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template <class T> void read(T &res) {
res = 0;
T f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
res = res * 10 + c - '0';
c = getchar();
}
res *= f;
}
template <class T> void out(T x) {
if (x < 0) {
x = -x;
putchar('-');
}
if (x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
int H, W, N;
int sr, sc;
char s[MAXN], t[MAXN];
int suf[MAXN];
bool Process(char a, char b, int dis, int lim) {
suf[N + 1] = 0;
int sum = 0;
for (int i = N; i >= 1; --i) {
suf[i] = suf[i + 1];
if (s[i] == b) {
suf[i] = min(suf[i], sum - 1);
--sum;
}
if (t[i] == a) {
if (sum < 0)
++sum;
}
}
int pos = dis;
for (int i = 1; i <= N; ++i) {
if (s[i] == a)
++pos;
if (pos > lim)
return false;
if (t[i] == b) {
if (pos - 1 + suf[i + 1] >= 1)
--pos;
}
}
return true;
}
void Solve() {
read(H);
read(W);
read(N);
read(sr);
read(sc);
scanf("%s", s + 1);
scanf("%s", t + 1);
if (!Process('D', 'U', sr, H) || !Process('U', 'D', H + 1 - sr, H) ||
!Process('R', 'L', sc, W) || !Process('L', 'R', W + 1 - sc, W)) {
puts("No");
} else
puts("Yes");
}
int main() {
#ifdef ivorysi
freopen("f1.in", "r", stdin);
#endif
Solve();
}
| #include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template <class T> void read(T &res) {
res = 0;
T f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
res = res * 10 + c - '0';
c = getchar();
}
res *= f;
}
template <class T> void out(T x) {
if (x < 0) {
x = -x;
putchar('-');
}
if (x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
int H, W, N;
int sr, sc;
char s[MAXN], t[MAXN];
int suf[MAXN];
bool Process(char a, char b, int dis, int lim) {
suf[N + 1] = 0;
int sum = 0;
for (int i = N; i >= 1; --i) {
suf[i] = suf[i + 1];
if (s[i] == b) {
suf[i] = min(suf[i], sum - 1);
--sum;
}
if (t[i] == a) {
if (sum < 0)
++sum;
}
}
int pos = dis;
for (int i = 1; i <= N; ++i) {
if (s[i] == a)
++pos;
if (pos > lim)
return false;
if (t[i] == b) {
if (pos - 1 + suf[i + 1] >= 1)
--pos;
}
}
return true;
}
void Solve() {
read(H);
read(W);
read(N);
read(sr);
read(sc);
scanf("%s", s + 1);
scanf("%s", t + 1);
if (!Process('D', 'U', sr, H) || !Process('U', 'D', H + 1 - sr, H) ||
!Process('R', 'L', sc, W) || !Process('L', 'R', W + 1 - sc, W)) {
puts("NO");
} else
puts("YES");
}
int main() {
#ifdef ivorysi
freopen("f1.in", "r", stdin);
#endif
Solve();
}
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 870,504 | 870,505 | u845980916 | cpp |
p03054 | #include <stdio.h>
#include <vector>
using namespace std;
int H[2], N, S[2];
char A[200200], B[200200];
bool solve(int h, int s, vector<int> &a, vector<int> &b) {
int l = 1, r = h;
for (int i = N - 1; i >= 0; i--) {
if (b[i] == 1)
l--;
if (b[i] == -1)
r++;
if (l < 0)
l = 1;
if (r > h)
r = h;
if (a[i] == -1)
l++;
if (a[i] == 1)
r--;
if (l > r)
return true;
}
return !(l <= s && s <= r);
}
int main() {
scanf("%d %d %d %d %d %s %s", &H[0], &H[1], &N, &S[0], &S[1], A, B);
for (int k = 0; k < 2; k++) {
vector<int> a, b;
if (k == 0) {
for (int i = 0; i < N; i++) {
if (A[i] == 'U')
a.push_back(-1);
else if (A[i] == 'D')
a.push_back(1);
else
a.push_back(0);
if (B[i] == 'U')
b.push_back(-1);
else if (B[i] == 'D')
b.push_back(1);
else
b.push_back(0);
}
} else {
for (int i = 0; i < N; i++) {
if (A[i] == 'L')
a.push_back(-1);
else if (A[i] == 'R')
a.push_back(1);
else
a.push_back(0);
if (B[i] == 'L')
b.push_back(-1);
else if (B[i] == 'R')
b.push_back(1);
else
b.push_back(0);
}
}
if (solve(H[k], S[k], a, b)) {
puts("NO");
return 0;
}
}
puts("YES");
return 0;
}
| #include <stdio.h>
#include <vector>
using namespace std;
int H[2], N, S[2];
char A[200200], B[200200];
bool solve(int h, int s, vector<int> &a, vector<int> &b) {
int l = 1, r = h;
for (int i = N - 1; i >= 0; i--) {
if (b[i] == 1)
l--;
if (b[i] == -1)
r++;
if (l < 1)
l = 1;
if (r > h)
r = h;
if (a[i] == -1)
l++;
if (a[i] == 1)
r--;
if (l > r)
return true;
}
return !(l <= s && s <= r);
}
int main() {
scanf("%d %d %d %d %d %s %s", &H[0], &H[1], &N, &S[0], &S[1], A, B);
for (int k = 0; k < 2; k++) {
vector<int> a, b;
if (k == 0) {
for (int i = 0; i < N; i++) {
if (A[i] == 'U')
a.push_back(-1);
else if (A[i] == 'D')
a.push_back(1);
else
a.push_back(0);
if (B[i] == 'U')
b.push_back(-1);
else if (B[i] == 'D')
b.push_back(1);
else
b.push_back(0);
}
} else {
for (int i = 0; i < N; i++) {
if (A[i] == 'L')
a.push_back(-1);
else if (A[i] == 'R')
a.push_back(1);
else
a.push_back(0);
if (B[i] == 'L')
b.push_back(-1);
else if (B[i] == 'R')
b.push_back(1);
else
b.push_back(0);
}
}
if (solve(H[k], S[k], a, b)) {
puts("NO");
return 0;
}
}
puts("YES");
return 0;
}
| [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 870,506 | 870,507 | u233632872 | cpp |
p03058 | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for (int i = (j); i <= (k); i++)
#define FFOR(i, j, k) for (int i = (j); i < (k); i++)
#define DFOR(i, j, k) for (int i = (j); i >= (k); i--)
#define bug(x) cerr << #x << " = " << (x) << '\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s) >> (i)) & 1LL)
#define mask(i) ((1LL << (i)))
#define builtin_popcount __builtin_popcountll
using ll = long long;
using ld = long double;
template <typename T> inline void read(T &x) {
char c;
bool nega = 0;
while ((!isdigit(c = getchar())) && (c != '-'))
;
if (c == '-') {
nega = 1;
c = getchar();
}
x = c - 48;
while (isdigit(c = getchar()))
x = x * 10 + c - 48;
if (nega)
x = -x;
}
template <typename T> inline void writep(T x) {
if (x > 9)
writep(x / 10);
putchar(x % 10 + 48);
}
template <typename T> inline void write(T x) {
if (x < 0) {
putchar('-');
x = -x;
}
writep(x);
}
template <typename T> inline void writeln(T x) {
write(x);
putchar('\n');
}
#define taskname "agc033F"
int n, m;
bitset<2000> f[2000];
vector<int> g[2000];
queue<pair<int, int>> q;
bitset<2000> sub[2000];
bitset<2000> head[2000];
bitset<2000> full;
int lca[2000][2000];
vector<int> ch[2000];
bool reach[2000];
int branch[2000][2000];
void dfs(int u) {
reach[u] = 1;
ch[u].pb(u);
lca[u][u] = u;
for (int v : g[u])
if (!reach[v]) {
head[v] = head[u];
head[v][u] = 1;
dfs(v);
for (int x : ch[u])
for (int y : ch[v])
lca[x][y] = lca[y][x] = u;
for (int y : ch[v]) {
branch[u][y] = v;
ch[u].pb(y);
}
}
for (int x : ch[u])
sub[x] = 1;
}
int main() {
#ifdef Aria
if (fopen(taskname ".in", "r"))
freopen(taskname ".in", "r", stdin);
#endif // Aria
read(n);
read(m);
FFOR(i, 0, n) full[i] = 1;
FFOR(i, 1, n) {
int a, b;
read(a);
read(b);
a--;
b--;
g[a].pb(b);
g[b].pb(a);
}
FOR(i, 1, m) {
int a, b;
read(a);
read(b);
a--;
b--;
f[a][b] = 1;
f[b][a] = 1;
q.push(mp(a, b));
}
FFOR(i, 0, n) f[i][i] = 1;
dfs(0);
while (!q.empty()) {
auto a = q.front().first;
auto b = q.front().second;
q.pop();
// cerr<<a<<' '<<b<<'\n';
bitset<2000> now;
if (lca[a][b] == b)
swap(a, b);
if (lca[a][b] == a)
now = (full ^ sub[branch[a][b]]) | sub[b] | head[b];
else {
now = sub[a] | sub[b] | (head[a] ^ head[b]);
now[lca[a][b]] = 1;
}
bitset<2000> nx = (now & f[a]) & (full ^ f[b]);
for (int c = nx._Find_first(); c < 2000; c = nx._Find_next(c)) {
f[b][c] = 1;
f[c][b] = 1;
q.push(mp(b, c));
}
nx = (now & f[b]) & (full ^ f[a]);
for (int c = nx._Find_first(); c < 2000; c = nx._Find_next(c)) {
f[a][c] = 1;
f[c][a] = 1;
q.push(mp(a, c));
}
}
int ans = 0;
FFOR(i, 0, n) ans += f[i].count() - 1;
writeln(ans / 2);
} | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for (int i = (j); i <= (k); i++)
#define FFOR(i, j, k) for (int i = (j); i < (k); i++)
#define DFOR(i, j, k) for (int i = (j); i >= (k); i--)
#define bug(x) cerr << #x << " = " << (x) << '\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s) >> (i)) & 1LL)
#define mask(i) ((1LL << (i)))
#define builtin_popcount __builtin_popcountll
using ll = long long;
using ld = long double;
template <typename T> inline void read(T &x) {
char c;
bool nega = 0;
while ((!isdigit(c = getchar())) && (c != '-'))
;
if (c == '-') {
nega = 1;
c = getchar();
}
x = c - 48;
while (isdigit(c = getchar()))
x = x * 10 + c - 48;
if (nega)
x = -x;
}
template <typename T> inline void writep(T x) {
if (x > 9)
writep(x / 10);
putchar(x % 10 + 48);
}
template <typename T> inline void write(T x) {
if (x < 0) {
putchar('-');
x = -x;
}
writep(x);
}
template <typename T> inline void writeln(T x) {
write(x);
putchar('\n');
}
#define taskname "agc033F"
int n, m;
bitset<2000> f[2000];
vector<int> g[2000];
queue<pair<int, int>> q;
bitset<2000> sub[2000];
bitset<2000> head[2000];
bitset<2000> full;
int lca[2000][2000];
vector<int> ch[2000];
bool reach[2000];
int branch[2000][2000];
void dfs(int u) {
reach[u] = 1;
ch[u].pb(u);
lca[u][u] = u;
for (int v : g[u])
if (!reach[v]) {
head[v] = head[u];
head[v][u] = 1;
dfs(v);
for (int x : ch[u])
for (int y : ch[v])
lca[x][y] = lca[y][x] = u;
for (int y : ch[v]) {
branch[u][y] = v;
ch[u].pb(y);
}
}
for (int x : ch[u])
sub[u][x] = 1;
}
int main() {
#ifdef Aria
if (fopen(taskname ".in", "r"))
freopen(taskname ".in", "r", stdin);
#endif // Aria
read(n);
read(m);
FFOR(i, 0, n) full[i] = 1;
FFOR(i, 1, n) {
int a, b;
read(a);
read(b);
a--;
b--;
g[a].pb(b);
g[b].pb(a);
}
FOR(i, 1, m) {
int a, b;
read(a);
read(b);
a--;
b--;
f[a][b] = 1;
f[b][a] = 1;
q.push(mp(a, b));
}
FFOR(i, 0, n) f[i][i] = 1;
dfs(0);
while (!q.empty()) {
auto a = q.front().first;
auto b = q.front().second;
q.pop();
// cerr<<a<<' '<<b<<'\n';
bitset<2000> now;
if (lca[a][b] == b)
swap(a, b);
if (lca[a][b] == a)
now = (full ^ sub[branch[a][b]]) | sub[b] | head[b];
else {
now = sub[a] | sub[b] | (head[a] ^ head[b]);
now[lca[a][b]] = 1;
}
// for(int i=0; i<n; i++) cerr<<now[i]<<" \n"[i+1==n];
bitset<2000> nx = (now & f[a]) & (full ^ f[b]);
for (int c = nx._Find_first(); c < 2000; c = nx._Find_next(c)) {
f[b][c] = 1;
f[c][b] = 1;
q.push(mp(b, c));
}
nx = (now & f[b]) & (full ^ f[a]);
for (int c = nx._Find_first(); c < 2000; c = nx._Find_next(c)) {
f[a][c] = 1;
f[c][a] = 1;
q.push(mp(a, c));
}
}
int ans = 0;
FFOR(i, 0, n) ans += f[i].count() - 1;
writeln(ans / 2);
} | [] | 870,545 | 870,546 | u216283258 | cpp |
p03059 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;
ll pow_mod(ll p, ll n, ll m) {
if (n == 0)
return 1;
else if (n == 1)
return p % m;
else if (n % 2 == 1)
return p * pow_mod(p, n - 1, m) % m;
else {
ll tmp = pow_mod(p, n / 2, m);
return (tmp * tmp) % m;
}
}
ll gcd(ll x, ll y) {
if (y == 0) {
return x;
}
return gcd(y, x % y);
}
ll com_mod(ll n, ll k, ll m) {
if (k == 0)
return 1;
else {
ll x = 1;
ll y = 1;
for (ll i = 0; i < k; i++) {
x = (x * (n - i)) % m;
y = (y * (i + 1)) % m;
}
ll res = (x * pow_mod(y, m - 2, m)) % m;
return res;
}
}
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << (t + 0.5) / a * b << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;
ll pow_mod(ll p, ll n, ll m) {
if (n == 0)
return 1;
else if (n == 1)
return p % m;
else if (n % 2 == 1)
return p * pow_mod(p, n - 1, m) % m;
else {
ll tmp = pow_mod(p, n / 2, m);
return (tmp * tmp) % m;
}
}
ll gcd(ll x, ll y) {
if (y == 0) {
return x;
}
return gcd(y, x % y);
}
ll com_mod(ll n, ll k, ll m) {
if (k == 0)
return 1;
else {
ll x = 1;
ll y = 1;
for (ll i = 0; i < k; i++) {
x = (x * (n - i)) % m;
y = (y * (i + 1)) % m;
}
ll res = (x * pow_mod(y, m - 2, m)) % m;
return res;
}
}
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << t / a * b << endl;
return 0;
} | [] | 870,549 | 870,550 | u618263300 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#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 repa(i, a, n) for (int i = (a); i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int mod = 1e9 + 7;
int gcd(int a, int b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int N, M, K, H, W, L, R, X;
// string S, T;
signed main() {
int a, b, t;
cin >> a >> b >> t;
cout << (t % a) * b << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#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 repa(i, a, n) for (int i = (a); i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int mod = 1e9 + 7;
int gcd(int a, int b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int N, M, K, H, W, L, R, X;
// string S, T;
signed main() {
int a, b, t;
cin >> a >> b >> t;
cout << (t / a) * b << endl;
return 0;
}
| [
"expression.operator.arithmetic.change",
"io.output.change"
] | 870,560 | 870,561 | u124142430 | cpp |
p03059 | #include <bits/stdc++.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
int a, b, c, d;
cin >> a >> b >> c;
d = a / c;
cout << d * b;
}
| #include <bits/stdc++.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
int a, b, c, d;
cin >> a >> b >> c;
d = c / a;
cout << d * b;
} | [
"expression.operation.binary.remove",
"assignment.change"
] | 870,605 | 870,606 | u683078179 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << (A / T) * B << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << (T / A) * B << endl;
} | [
"expression.operation.binary.remove"
] | 870,607 | 870,608 | u453366189 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
float a, b, c;
cin >> a >> b >> c;
cout << c / a * b;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
cout << (c / a) * b;
}
| [
"variable_declaration.type.primitive.change"
] | 870,621 | 870,622 | u829521436 | cpp |
p03059 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << t % a * b << endl;
return 0;
}
/* 吾輩はやれば出来る子である。
∩∩
(´・ω・)
_| ⊃/(___
/ └-(____/
 ̄ ̄ ̄ ̄ ̄ ̄ ̄
やる気はまだない
⊂⌒/ヽ-、__
/⊂_/____ /
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ */ | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << t / a * b << endl;
return 0;
}
/* 吾輩はやれば出来る子である。
∩∩
(´・ω・)
_| ⊃/(___
/ └-(____/
 ̄ ̄ ̄ ̄ ̄ ̄ ̄
やる気はまだない
⊂⌒/ヽ-、__
/⊂_/____ /
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ */
| [
"expression.operator.arithmetic.change",
"io.output.change"
] | 870,623 | 870,624 | u852449189 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repa(i, a, n) for (int i = (a); i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rrepa(i, a, n) for (int i = n - 1; i >= (a); i--)
#define all(a) (a).begin(), (a).end()
#define MOD 1000000007
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define vc vector
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
int main() {
int a, b, t;
cin >> a >> b;
int ans = t / a;
ans *= b;
cout << ans << "\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repa(i, a, n) for (int i = (a); i < (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rrepa(i, a, n) for (int i = n - 1; i >= (a); i--)
#define all(a) (a).begin(), (a).end()
#define MOD 1000000007
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define vc vector
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
int main() {
int a, b, t;
cin >> a >> b >> t;
int ans = t / a;
ans *= b;
cout << ans << "\n";
return 0;
}
| [
"expression.operation.binary.add"
] | 870,636 | 870,637 | u926025622 | cpp |
p03059 | #include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
int main() {
int A, B;
double T;
cin >> A >> B >> T;
double time = 0;
int biscuit = 0;
while (time <= T + 0.5) {
time += A;
biscuit += B;
}
cout << biscuit << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
int main() {
int A, B;
double T;
cin >> A >> B >> T;
double time = 0;
int biscuit = 0;
while (time <= T + 0.5) {
time += A;
biscuit += B;
}
cout << biscuit - B << endl;
return 0;
} | [
"expression.operation.binary.add"
] | 870,644 | 870,645 | u887938060 | cpp |
p03051 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
#define int long long int
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
template <typename T> using vector2 = vector<vector<T>>;
template <typename T> vector2<T> initVec2(size_t n0, size_t n1, T e = T()) {
return vector2<T>(n0, vector<T>(n1, e));
}
template <typename T> using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()) {
return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}
int powM(int x, int n) {
if (n == 0) {
return 1;
}
if (n % 2 == 0) {
return powM(x * x % MOD, n / 2);
}
return powM(x, n - 1) * x % MOD;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
auto dp = initVec2<int>(1 << 20, 2);
vector<int> cnt(1 << 20);
int sum = 0;
int x = 0;
set<int> s;
rep(i, 1 << 20) { dp[i][0] = 1; }
rep(i, n) {
x ^= a[i];
s.insert(x);
if (x == 0) {
sum++;
} else {
dp[x][0] += dp[x][1] * (sum - cnt[x]) % MOD;
dp[x][0] %= MOD;
dp[x][1] += dp[x][0];
dp[x][1] %= MOD;
cnt[x] = sum;
}
}
if (x == 0) {
int ans = 0;
for (int x : s) {
ans += dp[x][1];
ans %= MOD;
}
ans += powM(2, sum - 1);
ans %= MOD;
cout << ans << endl;
} else {
cout << dp[x][1] << endl;
}
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
#define int long long int
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
template <typename T> using vector2 = vector<vector<T>>;
template <typename T> vector2<T> initVec2(size_t n0, size_t n1, T e = T()) {
return vector2<T>(n0, vector<T>(n1, e));
}
template <typename T> using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()) {
return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}
int powM(int x, int n) {
if (n == 0) {
return 1;
}
if (n % 2 == 0) {
return powM(x * x % MOD, n / 2);
}
return powM(x, n - 1) * x % MOD;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
auto dp = initVec2<int>(1 << 20, 2);
vector<int> cnt(1 << 20);
int sum = 0;
int x = 0;
set<int> s;
rep(i, 1 << 20) { dp[i][0] = 1; }
rep(i, n) {
x ^= a[i];
s.insert(x);
if (x == 0) {
sum++;
} else {
dp[x][0] += dp[x][1] * (sum - cnt[x]) % MOD;
dp[x][0] %= MOD;
dp[x][1] += dp[x][0];
dp[x][1] %= MOD;
cnt[x] = sum;
}
}
if (x == 0) {
int ans = 0;
for (int x : s) {
ans += dp[x][1];
ans %= MOD;
}
ans += powM(2, sum - 1);
ans %= MOD;
cout << ans << endl;
} else {
cout << dp[x][0] << endl;
}
return 0;
}
| [
"literal.number.change",
"variable_access.subscript.index.change",
"io.output.change"
] | 870,681 | 870,682 | u558092537 | cpp |
p03051 | #include <iostream>
#define rep(i, n) for (i = 0; i < n; i++)
#define int long long
using namespace std;
const int M = 1 << 20;
int mod = 1000000007;
int n;
int a[500000];
int ra[500001];
int cnt0[500002];
int dp[2][M];
int lastPos[M];
signed main() {
int i, j;
cin >> n;
rep(i, n) cin >> a[i];
rep(i, n) ra[i + 1] = ra[i] ^ a[i];
rep(i, n + 1) cnt0[i + 1] = cnt0[i] + (ra[i] == 0);
rep(i, M) dp[1][i] = 1;
rep(i, n) {
if (ra[i] != 0) {
(dp[1][ra[i]] += (cnt0[i] - cnt0[lastPos[ra[i]]]) * dp[0][ra[i]]) %= mod;
(dp[0][ra[i]] += dp[1][ra[i]]) %= mod;
lastPos[ra[i]] = i;
}
}
if (ra[n] != 0) {
cout << dp[1][ra[n]] << endl;
return 0;
}
int ans = 1;
rep(i, cnt0[n + 1] - 2)(ans *= 2) %= mod;
rep(i, M) if (i > 0)(ans += dp[0][i]) %= mod;
cout << ans << endl;
return 0;
} | #include <iostream>
#define rep(i, n) for (i = 0; i < n; i++)
#define int long long
using namespace std;
const int M = 1 << 20;
int mod = 1000000007;
int n;
int a[500000];
int ra[500001];
int cnt0[500002];
int dp[2][M];
int lastPos[M];
signed main() {
int i, j;
cin >> n;
rep(i, n) cin >> a[i];
rep(i, n) ra[i + 1] = ra[i] ^ a[i];
rep(i, n + 1) cnt0[i + 1] = cnt0[i] + (ra[i] == 0);
rep(i, M) dp[1][i] = 1;
rep(i, n + 1) {
if (ra[i] != 0) {
(dp[1][ra[i]] += (cnt0[i] - cnt0[lastPos[ra[i]]]) * dp[0][ra[i]]) %= mod;
(dp[0][ra[i]] += dp[1][ra[i]]) %= mod;
lastPos[ra[i]] = i;
}
}
if (ra[n] != 0) {
cout << dp[1][ra[n]] << endl;
return 0;
}
int ans = 1;
rep(i, cnt0[n + 1] - 2)(ans *= 2) %= mod;
rep(i, M) if (i > 0)(ans += dp[0][i]) %= mod;
cout << ans << endl;
return 0;
} | [
"expression.operation.binary.add"
] | 870,691 | 870,692 | u610441939 | cpp |
p03051 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 22;
const int mod = 1e9 + 7;
long long exp_mod(long long a, long long b) {
long long ret = 1;
while (b) {
if (b & 1)
ret = ret * a % mod;
a = a * a % mod;
b >>= 1;
}
return ret;
}
long long dp[MAXN][2], cnt[MAXN];
long long sum, cnt0;
int main(void) {
int n;
scanf("%d", &n);
for (int i = 0; i < MAXN; i++) {
dp[i][0] = 1;
}
for (int i = 1, val; i <= n; i++) {
scanf("%d", &val);
sum ^= val;
if (sum) {
dp[sum][0] = (dp[sum][0] + dp[sum][1] * (cnt0 - cnt[sum])) % mod;
dp[sum][1] = (dp[sum][1] + dp[sum][0]) % mod;
cnt[sum] = cnt0;
} else
cnt0++;
}
if (sum) {
printf("%lld\n", dp[sum][1]);
} else {
long long ret = exp_mod(2, cnt0 - 1);
for (int i = 1; i < MAXN; i++) {
ret = (ret + dp[i][1]) % mod;
}
printf("%lld\n", ret);
}
} | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 22;
const int mod = 1e9 + 7;
long long exp_mod(long long a, long long b) {
long long ret = 1;
while (b) {
if (b & 1)
ret = ret * a % mod;
a = a * a % mod;
b >>= 1;
}
return ret;
}
long long dp[MAXN][2], cnt[MAXN];
long long sum, cnt0;
int main(void) {
int n;
scanf("%d", &n);
for (int i = 0; i < MAXN; i++) {
dp[i][0] = 1;
}
for (int i = 1, val; i <= n; i++) {
scanf("%d", &val);
sum ^= val;
if (sum) {
dp[sum][0] = (dp[sum][0] + dp[sum][1] * (cnt0 - cnt[sum])) % mod;
dp[sum][1] = (dp[sum][1] + dp[sum][0]) % mod;
cnt[sum] = cnt0;
} else
cnt0++;
}
if (sum) {
printf("%lld\n", dp[sum][0]);
} else {
long long ret = exp_mod(2, cnt0 - 1);
for (int i = 1; i < MAXN; i++) {
ret = (ret + dp[i][1]) % mod;
}
printf("%lld\n", ret);
}
} | [
"literal.number.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"io.output.change"
] | 870,703 | 870,704 | u199179002 | cpp |
p03051 | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#define PB push_back
#define ll long long
using namespace std;
template <class T> inline void rd(T &x) {
x = 0;
char c = getchar();
int f = 1;
while (!isdigit(c)) {
if (c == '-')
f = -1;
c = getchar();
}
while (isdigit(c))
x = x * 10 - '0' + c, c = getchar();
x *= f;
}
const int mod = 1e9 + 7, N = 5e5 + 10;
void Add(int &x, int y) {
x += y;
if (x >= mod)
x -= mod;
}
int f[2][N], a[N], n;
vector<int> b[1 << 20];
int buc[N];
int dp[N], s1[N], s2[N];
int solve(vector<int> &p) {
int m = p.size() - 1, ans = 0;
for (int i = 0; i <= m; ++i)
dp[i] = s1[i] = s2[i] = 0;
for (int i = 1; i <= m; ++i) {
dp[i] = ((buc[p[i]] * (ll)s1[i - 1] - s2[i - 1] + 1) % mod + mod) % mod;
s1[i] = (s1[i - 1] + dp[i]) % mod;
s2[i] = (s2[i - 1] + dp[i] * (ll)buc[p[i]] % mod) % mod;
Add(ans, dp[i]);
}
return ans;
}
int main() {
rd(n);
for (int i = 1; i <= n; ++i)
rd(a[i]), a[i] ^= a[i - 1];
int ans = 0;
if (a[n]) {
f[0][0] = 1;
for (int i = 1; i <= n; ++i) {
f[0][i] = f[0][i - 1];
f[1][i] = f[1][i - 1];
if (a[i] == a[n])
Add(f[0][i], f[1][i - 1]);
if (a[i] == 0)
Add(f[1][i], f[0][i - 1]);
}
ans = f[0][n - 1];
} else {
for (int i = 1; i <= n; ++i)
buc[i] = buc[i - 1] + (a[i] == 0);
for (int i = 0; i < (1 << 20); ++i)
b[i].PB(0);
for (int i = 1; i <= n; ++i)
if (a[i])
b[a[i]].PB(i);
for (int i = 0; i < (1 << 20); ++i)
if (b[i].size() > 1)
Add(ans, solve(b[i]));
int t = 1;
for (int i = 1; i < buc[n]; ++i)
t = t * 2ll % mod;
Add(ans, t);
}
printf("%d", ans);
return 0;
}
| #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#define PB push_back
#define ll long long
using namespace std;
template <class T> inline void rd(T &x) {
x = 0;
char c = getchar();
int f = 1;
while (!isdigit(c)) {
if (c == '-')
f = -1;
c = getchar();
}
while (isdigit(c))
x = x * 10 - '0' + c, c = getchar();
x *= f;
}
const int mod = 1e9 + 7, N = 5e5 + 10;
void Add(int &x, int y) {
x += y;
if (x >= mod)
x -= mod;
}
int f[2][N], a[N], n;
vector<int> b[1 << 20];
int buc[N];
int dp[N], s1[N], s2[N];
int solve(vector<int> &p) {
int m = p.size() - 1, ans = 0;
for (int i = 0; i <= m; ++i)
dp[i] = s1[i] = s2[i] = 0;
for (int i = 1; i <= m; ++i) {
dp[i] = ((buc[p[i]] * (ll)s1[i - 1] - s2[i - 1] + 1) % mod + mod) % mod;
s1[i] = (s1[i - 1] + dp[i]) % mod;
s2[i] = (s2[i - 1] + dp[i] * (ll)buc[p[i]] % mod) % mod;
Add(ans, dp[i]);
}
return ans;
}
int main() {
rd(n);
for (int i = 1; i <= n; ++i)
rd(a[i]), a[i] ^= a[i - 1];
int ans = 0;
if (a[n]) {
f[0][0] = 1;
for (int i = 1; i <= n; ++i) {
f[0][i] = f[0][i - 1];
f[1][i] = f[1][i - 1];
if (a[i] == a[n])
Add(f[1][i], f[0][i - 1]);
if (a[i] == 0)
Add(f[0][i], f[1][i - 1]);
}
ans = f[0][n - 1];
} else {
for (int i = 1; i <= n; ++i)
buc[i] = buc[i - 1] + (a[i] == 0);
for (int i = 0; i < (1 << 20); ++i)
b[i].PB(0);
for (int i = 1; i <= n; ++i)
if (a[i])
b[a[i]].PB(i);
for (int i = 0; i < (1 << 20); ++i)
if (b[i].size() > 1)
Add(ans, solve(b[i]));
int t = 1;
for (int i = 1; i < buc[n]; ++i)
t = t * 2ll % mod;
Add(ans, t);
}
printf("%d", ans);
return 0;
}
| [
"call.remove",
"control_flow.branch.if.add",
"call.add"
] | 870,708 | 870,709 | u973935896 | cpp |
p03051 | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a), i##formax = (b); i < i##formax; i++)
#define FORR(i, a, b) for (int i = (a), i##formax = (b); i >= i##formax; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
#define show(x) cout << #x << " = " << x << endl;
#define all(a) (a.begin()), (a.end())
#define each(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define perm(c) \
sort(all(c)); \
for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define bitComb(a, n, k) \
for (int a##x, a##y, a = (1 << k) - 1; a < (1 << n); \
a##x = a & -a, a##y = a + a##x, a = (((a & ~a##y) / a##x) >> 1) | a##y)
#define uniq(v) \
sort(all(v)); \
v.erase(unique(all(v)), v.end())
#define bit(n) (1LL << (n))
#define randInt(l, r) (uniform_int_distribution<ll>(l, r)(rnd))
#define randDouble(l, r) (uniform_real_distribution<double>(l, r)(rnd))
#define dout(d) printf("%.12f\n", d)
typedef long long ll;
typedef __int128_t lll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T, class Y>
ostream &operator<<(ostream &o, const pair<T, Y> &p) {
return o << "(" << p.fi << ", " << p.se << ")";
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &v) {
fill((T *)array, (T *)(array + N), v);
}
lll gcd(lll a, lll b, lll &x, lll &y) {
if (!b) {
x = 1;
y = 0;
return a;
}
lll d = gcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
ll gcd(ll a, ll b) {
lll x = 0, y = 0;
return gcd(a, b, x, y);
}
ll modInv(ll a, ll m) {
lll x, y;
gcd(a, m, x, y);
return (x % m + m) % m;
}
ll modPow(lll a, lll n, ll m) {
if (!a)
return a;
lll p = 1;
for (; n > 0; n >>= 1, a = a * a % m)
if (n & 1)
p = p * a % m;
return (ll)p;
}
bool isPrime(ll n) {
if (n < 2 || n % 2 == 0)
return n == 2;
lll t = n - 1, d = t / (t & -t);
for (lll a : {2, 325, 9375, 28178, 450775, 9780504, 1795265022})
if (a % n) {
for (t = d, a = modPow(a, t, n); t != n - 1 && a != 1 && a != n - 1;
a = a * a % n, t = t * 2 % n)
;
if (a != n - 1 && t % 2 == 0)
return 0;
}
return 1;
}
const int IINF = 1e9 + 6;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());
const int N = 1 << 20;
int n, A[500000];
V<int> v[N];
main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
int X = 0;
FOR(i, 0, n) {
cin >> A[i];
X ^= A[i];
}
if (X) {
ll ans = 0;
int x = 0;
FOR(i, 0, n - 1) {
x ^= A[i];
if (x == X || x == 0)
v[0].pb(x);
}
ll p = 0, sx = 0, s0 = 1;
for (int a : v[0]) {
if (a == x) {
sx = (sx + s0) % MOD;
} else {
s0 = (s0 + sx) % MOD;
}
}
cout << s0 << endl;
return 0;
}
X = 0;
FOR(i, 0, n - 1) {
X ^= A[i];
v[X].pb(i);
}
ll ans = 0;
FOR(i, 1, N) {
if (v[i].empty())
continue;
int p = -1;
ll sx = 0, s0 = 1;
for (int a : v[i]) {
int d = lower_bound(all(v[0]), a) - lower_bound(all(v[0]), p);
p = a;
s0 = (s0 + sx * d) % MOD;
sx = (sx + s0) % MOD;
}
ans += sx;
}
ans = (ans % MOD + modPow(2, sz(v[0]), MOD)) % MOD;
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a), i##formax = (b); i < i##formax; i++)
#define FORR(i, a, b) for (int i = (a), i##formax = (b); i >= i##formax; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
#define show(x) cout << #x << " = " << x << endl;
#define all(a) (a.begin()), (a.end())
#define each(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define perm(c) \
sort(all(c)); \
for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define bitComb(a, n, k) \
for (int a##x, a##y, a = (1 << k) - 1; a < (1 << n); \
a##x = a & -a, a##y = a + a##x, a = (((a & ~a##y) / a##x) >> 1) | a##y)
#define uniq(v) \
sort(all(v)); \
v.erase(unique(all(v)), v.end())
#define bit(n) (1LL << (n))
#define randInt(l, r) (uniform_int_distribution<ll>(l, r)(rnd))
#define randDouble(l, r) (uniform_real_distribution<double>(l, r)(rnd))
#define dout(d) printf("%.12f\n", d)
typedef long long ll;
typedef __int128_t lll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T, class Y>
ostream &operator<<(ostream &o, const pair<T, Y> &p) {
return o << "(" << p.fi << ", " << p.se << ")";
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &v) {
fill((T *)array, (T *)(array + N), v);
}
lll gcd(lll a, lll b, lll &x, lll &y) {
if (!b) {
x = 1;
y = 0;
return a;
}
lll d = gcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
ll gcd(ll a, ll b) {
lll x = 0, y = 0;
return gcd(a, b, x, y);
}
ll modInv(ll a, ll m) {
lll x, y;
gcd(a, m, x, y);
return (x % m + m) % m;
}
ll modPow(lll a, lll n, ll m) {
if (!a)
return a;
lll p = 1;
for (; n > 0; n >>= 1, a = a * a % m)
if (n & 1)
p = p * a % m;
return (ll)p;
}
bool isPrime(ll n) {
if (n < 2 || n % 2 == 0)
return n == 2;
lll t = n - 1, d = t / (t & -t);
for (lll a : {2, 325, 9375, 28178, 450775, 9780504, 1795265022})
if (a % n) {
for (t = d, a = modPow(a, t, n); t != n - 1 && a != 1 && a != n - 1;
a = a * a % n, t = t * 2 % n)
;
if (a != n - 1 && t % 2 == 0)
return 0;
}
return 1;
}
const int IINF = 1e9 + 6;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());
const int N = 1 << 20;
int n, A[500000];
V<int> v[N];
main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
int X = 0;
FOR(i, 0, n) {
cin >> A[i];
X ^= A[i];
}
if (X) {
ll ans = 0;
int x = 0;
FOR(i, 0, n - 1) {
x ^= A[i];
if (x == X || x == 0)
v[0].pb(x);
}
ll p = 0, sx = 0, s0 = 1;
for (int a : v[0]) {
if (a == X) {
sx = (sx + s0) % MOD;
} else {
s0 = (s0 + sx) % MOD;
}
}
cout << s0 << endl;
return 0;
}
X = 0;
FOR(i, 0, n - 1) {
X ^= A[i];
v[X].pb(i);
}
ll ans = 0;
FOR(i, 1, N) {
if (v[i].empty())
continue;
int p = -1;
ll sx = 0, s0 = 1;
for (int a : v[i]) {
int d = lower_bound(all(v[0]), a) - lower_bound(all(v[0]), p);
p = a;
s0 = (s0 + sx * d) % MOD;
sx = (sx + s0) % MOD;
}
ans += sx;
}
ans = (ans % MOD + modPow(2, sz(v[0]), MOD)) % MOD;
cout << ans << endl;
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 870,719 | 870,720 | u976045235 | cpp |
p03051 | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a), i##formax = (b); i < i##formax; i++)
#define FORR(i, a, b) for (int i = (a), i##formax = (b); i >= i##formax; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
#define show(x) cout << #x << " = " << x << endl;
#define all(a) (a.begin()), (a.end())
#define each(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define perm(c) \
sort(all(c)); \
for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define bitComb(a, n, k) \
for (int a##x, a##y, a = (1 << k) - 1; a < (1 << n); \
a##x = a & -a, a##y = a + a##x, a = (((a & ~a##y) / a##x) >> 1) | a##y)
#define uniq(v) \
sort(all(v)); \
v.erase(unique(all(v)), v.end())
#define bit(n) (1LL << (n))
#define randInt(l, r) (uniform_int_distribution<ll>(l, r)(rnd))
#define randDouble(l, r) (uniform_real_distribution<double>(l, r)(rnd))
#define dout(d) printf("%.12f\n", d)
typedef long long ll;
typedef __int128_t lll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T, class Y>
ostream &operator<<(ostream &o, const pair<T, Y> &p) {
return o << "(" << p.fi << ", " << p.se << ")";
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &v) {
fill((T *)array, (T *)(array + N), v);
}
lll gcd(lll a, lll b, lll &x, lll &y) {
if (!b) {
x = 1;
y = 0;
return a;
}
lll d = gcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
ll gcd(ll a, ll b) {
lll x = 0, y = 0;
return gcd(a, b, x, y);
}
ll modInv(ll a, ll m) {
lll x, y;
gcd(a, m, x, y);
return (x % m + m) % m;
}
ll modPow(lll a, lll n, ll m) {
if (!a)
return a;
lll p = 1;
for (; n > 0; n >>= 1, a = a * a % m)
if (n & 1)
p = p * a % m;
return (ll)p;
}
bool isPrime(ll n) {
if (n < 2 || n % 2 == 0)
return n == 2;
lll t = n - 1, d = t / (t & -t);
for (lll a : {2, 325, 9375, 28178, 450775, 9780504, 1795265022})
if (a % n) {
for (t = d, a = modPow(a, t, n); t != n - 1 && a != 1 && a != n - 1;
a = a * a % n, t = t * 2 % n)
;
if (a != n - 1 && t % 2 == 0)
return 0;
}
return 1;
}
const int IINF = 1e9 + 6;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());
const int N = 1 << 20;
int n, A[500000];
V<int> v[N];
main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
int X = 0;
FOR(i, 0, n) {
cin >> A[i];
X ^= A[i];
}
if (X) {
ll ans = 0;
int x = 0;
FOR(i, 0, n - 1) {
x ^= A[i];
if (x == X || x == 0)
v[x].pb(x);
}
ll p = 0, sx = 0, s0 = 1;
for (int a : v[X]) {
if (a == x) {
sx = (sx + s0) % MOD;
} else {
s0 = (s0 + sx) % MOD;
}
}
cout << s0 << endl;
return 0;
}
X = 0;
FOR(i, 0, n - 1) {
X ^= A[i];
v[X].pb(i);
}
ll ans = 0;
FOR(i, 1, N) {
if (v[i].empty())
continue;
int p = -1;
ll sx = 0, s0 = 1;
for (int a : v[i]) {
int d = lower_bound(all(v[0]), a) - lower_bound(all(v[0]), p);
p = a;
s0 = (s0 + sx * d) % MOD;
sx = (sx + s0) % MOD;
}
ans += sx;
}
ans = (ans % MOD + modPow(2, sz(v[0]), MOD)) % MOD;
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a), i##formax = (b); i < i##formax; i++)
#define FORR(i, a, b) for (int i = (a), i##formax = (b); i >= i##formax; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
#define show(x) cout << #x << " = " << x << endl;
#define all(a) (a.begin()), (a.end())
#define each(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define perm(c) \
sort(all(c)); \
for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define bitComb(a, n, k) \
for (int a##x, a##y, a = (1 << k) - 1; a < (1 << n); \
a##x = a & -a, a##y = a + a##x, a = (((a & ~a##y) / a##x) >> 1) | a##y)
#define uniq(v) \
sort(all(v)); \
v.erase(unique(all(v)), v.end())
#define bit(n) (1LL << (n))
#define randInt(l, r) (uniform_int_distribution<ll>(l, r)(rnd))
#define randDouble(l, r) (uniform_real_distribution<double>(l, r)(rnd))
#define dout(d) printf("%.12f\n", d)
typedef long long ll;
typedef __int128_t lll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T, class Y>
ostream &operator<<(ostream &o, const pair<T, Y> &p) {
return o << "(" << p.fi << ", " << p.se << ")";
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &v) {
fill((T *)array, (T *)(array + N), v);
}
lll gcd(lll a, lll b, lll &x, lll &y) {
if (!b) {
x = 1;
y = 0;
return a;
}
lll d = gcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
ll gcd(ll a, ll b) {
lll x = 0, y = 0;
return gcd(a, b, x, y);
}
ll modInv(ll a, ll m) {
lll x, y;
gcd(a, m, x, y);
return (x % m + m) % m;
}
ll modPow(lll a, lll n, ll m) {
if (!a)
return a;
lll p = 1;
for (; n > 0; n >>= 1, a = a * a % m)
if (n & 1)
p = p * a % m;
return (ll)p;
}
bool isPrime(ll n) {
if (n < 2 || n % 2 == 0)
return n == 2;
lll t = n - 1, d = t / (t & -t);
for (lll a : {2, 325, 9375, 28178, 450775, 9780504, 1795265022})
if (a % n) {
for (t = d, a = modPow(a, t, n); t != n - 1 && a != 1 && a != n - 1;
a = a * a % n, t = t * 2 % n)
;
if (a != n - 1 && t % 2 == 0)
return 0;
}
return 1;
}
const int IINF = 1e9 + 6;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());
const int N = 1 << 20;
int n, A[500000];
V<int> v[N];
main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
int X = 0;
FOR(i, 0, n) {
cin >> A[i];
X ^= A[i];
}
if (X) {
ll ans = 0;
int x = 0;
FOR(i, 0, n - 1) {
x ^= A[i];
if (x == X || x == 0)
v[0].pb(x);
}
ll p = 0, sx = 0, s0 = 1;
for (int a : v[0]) {
if (a == X) {
sx = (sx + s0) % MOD;
} else {
s0 = (s0 + sx) % MOD;
}
}
cout << s0 << endl;
return 0;
}
X = 0;
FOR(i, 0, n - 1) {
X ^= A[i];
v[X].pb(i);
}
ll ans = 0;
FOR(i, 1, N) {
if (v[i].empty())
continue;
int p = -1;
ll sx = 0, s0 = 1;
for (int a : v[i]) {
int d = lower_bound(all(v[0]), a) - lower_bound(all(v[0]), p);
p = a;
s0 = (s0 + sx * d) % MOD;
sx = (sx + s0) % MOD;
}
ans += sx;
}
ans = (ans % MOD + modPow(2, sz(v[0]), MOD)) % MOD;
cout << ans << endl;
} | [
"identifier.replace.remove",
"literal.replace.add",
"variable_access.subscript.index.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 870,721 | 870,720 | u976045235 | cpp |
p03051 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, l, r) for (int i = (l); i < (r); i++)
#define per(i, n) for (int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for (int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP << " " <<
#define CYES cout << "Yes" << endl;
#define CNO cout << "No" << endl;
typedef long long LL;
typedef long double LD;
struct sta {
LL a;
LL s;
LL pr;
};
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> rx(n);
rx[0] = a[0];
repp(i, 1, n) rx[i] = rx[i - 1] ^ a[i];
int t = 0;
vector<int> r(n, 0);
if (rx[n - 1] == 0) {
r[n - 1] = 1;
t++;
}
per(i, n - 1) {
if (rx[i] == 0) {
t++;
r[i] = r[i + 1] + 1;
} else {
r[i] = r[i + 1];
}
}
map<int, sta> mp;
LL ans = 0;
if (rx[n - 1] == 0) {
ans = 1;
rep(i, t - 1) ans = (ans * 2) % MOD;
per(i, n) {
if (rx[i] == 0)
continue;
auto itr = mp.find(rx[i]);
if (itr == mp.end()) {
ans = (ans + 1) % MOD;
mp[rx[i]] = {1, 1, r[i]};
} else {
LL na =
(itr->second.a + itr->second.s * (r[i] - itr->second.pr) % MOD) %
MOD;
ans = (ans + na) % MOD;
itr->second = {na, (itr->second.s + na) % MOD, r[i]};
}
}
} else {
ans = 1;
per(i, n) {
if (rx[i] != rx[n - 1])
continue;
auto itr = mp.find(rx[i]);
if (itr == mp.end()) {
mp[rx[i]] = {0, 0, r[i]};
} else {
LL na =
(itr->second.a + itr->second.s * (r[i] - itr->second.pr) % MOD) %
MOD;
ans = (ans + na) % MOD;
itr->second = {na, (itr->second.s + na) % MOD, r[i]};
}
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, l, r) for (int i = (l); i < (r); i++)
#define per(i, n) for (int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for (int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP << " " <<
#define CYES cout << "Yes" << endl;
#define CNO cout << "No" << endl;
typedef long long LL;
typedef long double LD;
struct sta {
LL a;
LL s;
LL pr;
};
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> rx(n);
rx[0] = a[0];
repp(i, 1, n) rx[i] = rx[i - 1] ^ a[i];
int t = 0;
vector<int> r(n, 0);
if (rx[n - 1] == 0) {
r[n - 1] = 1;
t++;
}
per(i, n - 1) {
if (rx[i] == 0) {
t++;
r[i] = r[i + 1] + 1;
} else {
r[i] = r[i + 1];
}
}
map<int, sta> mp;
LL ans = 0;
if (rx[n - 1] == 0) {
ans = 1;
rep(i, t - 1) ans = (ans * 2) % MOD;
per(i, n) {
if (rx[i] == 0)
continue;
auto itr = mp.find(rx[i]);
if (itr == mp.end()) {
ans = (ans + 1) % MOD;
mp[rx[i]] = {1, 1, r[i]};
} else {
LL na =
(itr->second.a + itr->second.s * (r[i] - itr->second.pr) % MOD) %
MOD;
ans = (ans + na) % MOD;
itr->second = {na, (itr->second.s + na) % MOD, r[i]};
}
}
} else {
ans = 1;
per(i, n) {
if (rx[i] != rx[n - 1])
continue;
auto itr = mp.find(rx[i]);
if (itr == mp.end()) {
mp[rx[i]] = {0, 1, r[i]};
} else {
LL na =
(itr->second.a + itr->second.s * (r[i] - itr->second.pr) % MOD) %
MOD;
ans = (ans + na) % MOD;
itr->second = {na, (itr->second.s + na) % MOD, r[i]};
}
}
}
cout << ans << endl;
return 0;
}
| [
"literal.number.change",
"assignment.value.change"
] | 870,739 | 870,740 | u405923605 | cpp |
p03051 | /*
*/
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <complex>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#include <assert.h>
#include <memory.h>
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery
#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300
#define ldouble long double
using namespace std;
#define bs 1000000007
const int N = 1110031;
int n, ar[N], S[N];
long long cnt[N], le[N], opn[N], cls[N];
long long zero_solver() {
long long res = 0;
int C = 0;
for (int i = 1; i <= n; i++) {
if (S[i] == 0)
C++;
}
if (S[n])
return 0;
res = 1;
--C;
for (int i = 1; i <= C; i++) {
res = res * 2 % bs;
}
return res;
}
int main() {
// freopen("apache.in","r",stdin);
// freopen("apache.out","w",stdout);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
// cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> ar[i];
S[i] = (S[i - 1] ^ ar[i]);
cnt[i] = cnt[i - 1] + (S[i] == 0);
}
for (int i = 1; i <= n; i++) {
int here = S[i];
int prv = le[here];
if (prv != 0) {
cls[here] += opn[here] * (cnt[i] - cnt[prv]);
cls[here] %= bs;
opn[here] += cls[here];
}
le[here] = i;
// new one
opn[here] += 1;
opn[here] %= bs;
cls[here] %= bs;
}
/*for (int i=1;i<=100;i++){
if (opn[i]!=0||cls[i]!=0){
cout<<i<<" "<<opn[i]<<" "<<cls[i]<<endl;
}
}*/
long long ans = zero_solver();
// cout<<ans<<endl;
if (S[n] == 0)
for (int i = 1; i < N; i++) {
ans = ans + opn[i];
ans %= bs;
}
if (S[n] != 0)
ans = cls[S[n]];
ans %= bs;
cout << ans << endl;
// cin.get(); cin.get();
return 0;
}
| /*
*/
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <complex>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#include <assert.h>
#include <memory.h>
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery
#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300
#define ldouble long double
using namespace std;
#define bs 1000000007
const int N = 1110031;
int n, ar[N], S[N];
long long cnt[N], le[N], opn[N], cls[N];
long long zero_solver() {
long long res = 0;
int C = 0;
for (int i = 1; i <= n; i++) {
if (S[i] == 0)
C++;
}
if (S[n])
return 0;
res = 1;
--C;
for (int i = 1; i <= C; i++) {
res = res * 2 % bs;
}
return res;
}
int main() {
// freopen("apache.in","r",stdin);
// freopen("apache.out","w",stdout);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
// cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> ar[i];
S[i] = (S[i - 1] ^ ar[i]);
cnt[i] = cnt[i - 1] + (S[i] == 0);
}
for (int i = 1; i <= n; i++) {
int here = S[i];
int prv = le[here];
if (prv != 0) {
cls[here] += opn[here] * (cnt[i] - cnt[prv]);
cls[here] %= bs;
opn[here] += cls[here];
}
le[here] = i;
// new one
opn[here] += 1;
opn[here] %= bs;
cls[here] %= bs;
}
/*for (int i=1;i<=100;i++){
if (opn[i]!=0||cls[i]!=0){
cout<<i<<" "<<opn[i]<<" "<<cls[i]<<endl;
}
}*/
long long ans = zero_solver();
// cout<<ans<<endl;
if (S[n] == 0)
for (int i = 1; i < N; i++) {
ans = ans + opn[i];
ans %= bs;
}
if (S[n] != 0)
ans = (cls[S[n]] + 1) % bs;
ans %= bs;
cout << ans << endl;
// cin.get(); cin.get();
return 0;
}
| [
"assignment.change"
] | 870,743 | 870,744 | u806695213 | cpp |
p03051 | //第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします!
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう!
// #本田未央を一番星に #本田未央を令和のシンデレラガールに
// #第8回シンデレラガール総選挙
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int, int> pint;
typedef pair<lint, lint> pl;
#define All(s) s.begin(), s.end()
#define rAll(s) s.rbegin(), s.rend()
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
//問題文および制約はちゃんと確認しよう!
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう?
ostream &operator<<(ostream &os, const vector<int> &a) {
os << "[";
rep(i, a.size()) {
os << a[i];
if (i < a.size() - 1)
os << ",";
}
os << "]";
return os;
}
int a[512810], b[512810];
lint sum[512810];
map<int, vector<int>> me;
lint mo = 1000000007;
pl cal(int x) {
vector<int> v = me[x];
lint s1 = 0, s2 = 1;
int n = v.size();
REP(i, 1, n) {
lint d = sum[v[i]] - sum[v[i - 1]];
lint now = (s1 + s2 * d + 1) % mo;
lint ns1 = (s1 + s2 * d) % mo, ns2 = (s2 + now) % mo;
s1 = ns1;
s2 = ns2;
}
// cout<<v<<endl;cout<<s1<<' '<<s2<<endl;
return mp(s1, s2);
}
int main() {
int n;
cin >> n;
b[0] = 0;
rep(i, n) {
cin >> a[i];
b[i + 1] = (a[i] ^ b[i]);
me[b[i + 1]].pb(i + 1);
}
sum[0] = 0;
rep(i, n) {
sum[i + 1] = sum[i];
if (b[i + 1] == 0)
sum[i + 1]++;
}
// cout<<b[n]<<endl;
if (b[n] > 0) {
cout << (cal(b[n]).fi) % mo << endl;
return 0;
}
// cout<<me[0]<<endl;
lint out = 0;
REP(i, 1, (1 << 20) + 10) {
if (me[i].size() < 1)
continue;
out += cal(i).se;
out %= mo;
}
lint t = 1;
rep(i, me[0].size() - 1) {
t *= 2;
t %= mo;
}
out += t;
out %= mo;
cout << out << endl;
}
| //第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします!
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう!
// #本田未央を一番星に #本田未央を令和のシンデレラガールに
// #第8回シンデレラガール総選挙
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int, int> pint;
typedef pair<lint, lint> pl;
#define All(s) s.begin(), s.end()
#define rAll(s) s.rbegin(), s.rend()
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
//問題文および制約はちゃんと確認しよう!
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう?
ostream &operator<<(ostream &os, const vector<int> &a) {
os << "[";
rep(i, a.size()) {
os << a[i];
if (i < a.size() - 1)
os << ",";
}
os << "]";
return os;
}
int a[512810], b[512810];
lint sum[512810];
map<int, vector<int>> me;
lint mo = 1000000007;
pl cal(int x) {
vector<int> v = me[x];
lint s1 = 0, s2 = 1;
int n = v.size();
REP(i, 1, n) {
lint d = sum[v[i]] - sum[v[i - 1]];
lint now = (s1 + s2 * d + 1) % mo;
lint ns1 = (s1 + s2 * d) % mo, ns2 = (s2 + now) % mo;
s1 = ns1;
s2 = ns2;
}
// cout<<v<<endl;cout<<s1<<' '<<s2<<endl;
return mp(s1, s2);
}
int main() {
int n;
cin >> n;
b[0] = 0;
rep(i, n) {
cin >> a[i];
b[i + 1] = (a[i] ^ b[i]);
me[b[i + 1]].pb(i + 1);
}
sum[0] = 0;
rep(i, n) {
sum[i + 1] = sum[i];
if (b[i + 1] == 0)
sum[i + 1]++;
}
// cout<<b[n]<<endl;
if (b[n] > 0) {
cout << (cal(b[n]).fi + 1) % mo << endl;
return 0;
}
// cout<<me[0]<<endl;
lint out = 0;
REP(i, 1, (1 << 20) + 10) {
if (me[i].size() < 1)
continue;
out += cal(i).se;
out %= mo;
}
lint t = 1;
rep(i, me[0].size() - 1) {
t *= 2;
t %= mo;
}
out += t;
out %= mo;
cout << out << endl;
}
| [
"expression.operation.binary.add"
] | 870,745 | 870,746 | u162364634 | cpp |
p03051 | #include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;
const int MAXN = 500005, MAXM = (1 << 20), mod = 1000000007;
int a[MAXN], n, x, dp[MAXM][2], lazy[MAXM], sett, y, ans;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
x ^= a[i];
}
for (int i = 1; i < n; ++i) {
y ^= a[i];
if (y == 0) {
++sett;
dp[y][0] *= 2;
++dp[y][0];
dp[y][0] %= mod;
lazy[i] = sett;
} else {
if (lazy[y] < sett) {
dp[y][0] += (1LL * dp[y][1] * (sett - lazy[y])) % mod;
dp[y][0] %= mod;
lazy[y] = sett;
}
dp[y][1] += dp[y][0] + 1;
dp[y][1] %= mod;
}
}
for (int i = 0; i < MAXM; ++i) {
dp[i][0] += (1LL * dp[i][1] * (sett - lazy[i])) % mod;
dp[i][0] %= mod;
}
if (x == 0) {
for (int i = 0; i < MAXM; ++i) {
ans += dp[i][1];
ans %= mod;
}
ans += dp[0][0] + 1;
ans %= mod;
} else {
ans = dp[x][0] + 1;
ans %= mod;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;
const int MAXN = 500005, MAXM = (1 << 20), mod = 1000000007;
int a[MAXN], n, x, dp[MAXM][2], lazy[MAXM], sett, y, ans;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
x ^= a[i];
}
for (int i = 1; i < n; ++i) {
y ^= a[i];
if (y == 0) {
++sett;
dp[y][0] *= 2;
++dp[y][0];
dp[y][0] %= mod;
lazy[y] = sett;
} else {
if (lazy[y] < sett) {
dp[y][0] += (1LL * dp[y][1] * (sett - lazy[y])) % mod;
dp[y][0] %= mod;
lazy[y] = sett;
}
dp[y][1] += dp[y][0] + 1;
dp[y][1] %= mod;
}
}
for (int i = 0; i < MAXM; ++i) {
dp[i][0] += (1LL * dp[i][1] * (sett - lazy[i])) % mod;
dp[i][0] %= mod;
}
if (x == 0) {
for (int i = 0; i < MAXM; ++i) {
ans += dp[i][1];
ans %= mod;
}
ans += dp[0][0] + 1;
ans %= mod;
} else {
ans = dp[x][0] + 1;
ans %= mod;
}
cout << ans << endl;
}
| [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change"
] | 870,748 | 870,749 | u279692478 | cpp |
p03051 | #include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_set>
#include <vector>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod = 1000000007;
const llint big = 2.19e15 + 1;
const long double pai = 3.141592653589793238462643383279502884197;
const long double eps = 1e-15;
template <class T, class U> bool mineq(T &a, U b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T, class U> bool maxeq(T &a, U b) {
if (a < b) {
a = b;
return true;
}
return false;
}
llint gcd(llint a, llint b) {
if (a % b == 0) {
return b;
} else
return gcd(b, a % b);
}
llint lcm(llint a, llint b) {
if (a == 0) {
return b;
}
return a / gcd(a, b) * b;
}
template <class T> void SO(T &ve) { sort(ve.begin(), ve.end()); }
template <class T> void REV(T &ve) { reverse(ve.begin(), ve.end()); }
template <class T> llint LBI(vector<T> &ar, T in) {
return lower_bound(ar.begin(), ar.end(), in) - ar.begin();
}
template <class T> llint UBI(vector<T> &ar, T in) {
return upper_bound(ar.begin(), ar.end(), in) - ar.begin();
}
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int n, i;
cin >> n;
vector<int> a(n);
vector<int> wa(n + 1);
for (i = 0; i < n; i++) {
cin >> a[i];
wa[i + 1] = wa[i] ^ a[i];
}
vector<int> zewa(n + 1);
zewa[0] = 1;
for (i = 1; i <= n; i++) {
zewa[i] = zewa[i - 1];
if (wa[i] == 0) {
zewa[i]++;
}
}
llint dp = 1, ep = 0;
if (wa[n] != 0) {
int ter = wa[i];
for (i = 1; i < n; i++) {
if (wa[i] == ter) {
ep += dp;
ep %= mod;
}
if (wa[i] == 0) {
dp += ep;
dp %= mod;
}
}
cout << dp << endl;
return 0;
}
llint ans = 0;
int mae = 0, mb = 0;
vector<pair<int, int>> bas;
bas.reserve(n + 2 - zewa[n]);
for (i = 1; i < n; i++) {
if (wa[i] == 0) {
continue;
}
bas.pub(mp(wa[i], i));
}
bas.pub(mp(mod, 0));
SO(bas);
for (auto it : bas) {
int p = it.sec;
if (mae != it.fir) {
mae = it.fir;
ans += ep;
ans %= mod;
dp = 1;
ep = 1;
} else {
dp += ep * (zewa[p] - zewa[mb]);
dp %= mod;
ep += dp;
ep %= mod;
}
mb = p;
}
dp = 1;
for (i = 0; i < zewa[n] - 2; i++) {
dp *= 2;
dp %= mod;
}
ans += dp;
ans %= mod;
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_set>
#include <vector>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod = 1000000007;
const llint big = 2.19e15 + 1;
const long double pai = 3.141592653589793238462643383279502884197;
const long double eps = 1e-15;
template <class T, class U> bool mineq(T &a, U b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T, class U> bool maxeq(T &a, U b) {
if (a < b) {
a = b;
return true;
}
return false;
}
llint gcd(llint a, llint b) {
if (a % b == 0) {
return b;
} else
return gcd(b, a % b);
}
llint lcm(llint a, llint b) {
if (a == 0) {
return b;
}
return a / gcd(a, b) * b;
}
template <class T> void SO(T &ve) { sort(ve.begin(), ve.end()); }
template <class T> void REV(T &ve) { reverse(ve.begin(), ve.end()); }
template <class T> llint LBI(vector<T> &ar, T in) {
return lower_bound(ar.begin(), ar.end(), in) - ar.begin();
}
template <class T> llint UBI(vector<T> &ar, T in) {
return upper_bound(ar.begin(), ar.end(), in) - ar.begin();
}
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int n, i;
cin >> n;
vector<int> a(n);
vector<int> wa(n + 1);
for (i = 0; i < n; i++) {
cin >> a[i];
wa[i + 1] = wa[i] ^ a[i];
}
vector<int> zewa(n + 1);
zewa[0] = 1;
for (i = 1; i <= n; i++) {
zewa[i] = zewa[i - 1];
if (wa[i] == 0) {
zewa[i]++;
}
}
llint dp = 1, ep = 0;
if (wa[n] != 0) {
int ter = wa[n];
for (i = 1; i < n; i++) {
if (wa[i] == ter) {
ep += dp;
ep %= mod;
}
if (wa[i] == 0) {
dp += ep;
dp %= mod;
}
}
cout << dp << endl;
return 0;
}
llint ans = 0;
int mae = 0, mb = 0;
vector<pair<int, int>> bas;
bas.reserve(n + 2 - zewa[n]);
for (i = 1; i < n; i++) {
if (wa[i] == 0) {
continue;
}
bas.pub(mp(wa[i], i));
}
bas.pub(mp(mod, 0));
SO(bas);
for (auto it : bas) {
int p = it.sec;
if (mae != it.fir) {
mae = it.fir;
ans += ep;
ans %= mod;
dp = 1;
ep = 1;
} else {
dp += ep * (zewa[p] - zewa[mb]);
dp %= mod;
ep += dp;
ep %= mod;
}
mb = p;
}
dp = 1;
for (i = 0; i < zewa[n] - 2; i++) {
dp *= 2;
dp %= mod;
}
ans += dp;
ans %= mod;
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change"
] | 870,756 | 870,757 | u483814783 | cpp |
p03051 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007LL
vector<int> v[1048576];
int num[500010], pre[500010], sum[500010], n;
inline int rd() {
int x = 0;
char ch = getchar();
for (; ch < '0' || ch > '9'; ch = getchar())
;
for (; ch >= '0' && ch <= '9'; ch = getchar())
x = x * 10 + ch - '0';
return x;
}
inline ll pls(const ll &x, const ll &y) {
return (x + y < mod) ? x + y : x + y - mod;
}
inline ll mns(const ll &x, const ll &y) {
return (x - y < 0) ? x - y + mod : x - y;
}
inline ll ksm(ll x, ll y) {
ll res = 1;
for (; y; y >>= 1, x = x * x % mod)
if (y & 1)
res = res * x % mod;
return res;
}
inline ll gao(int x) {
if (!v[x].size())
return 0;
ll ans = 0, res = 0, sumf = 0;
for (int i = 0; i < v[x].size(); i++) {
int now = v[x][i];
ll hh = 1;
if (i > 0)
res = pls(res, sumf * (sum[v[x][i]] - sum[v[x][i - 1]]) % mod);
hh = pls(hh, res);
sumf = pls(sumf, hh);
ans = hh;
}
return ans;
}
inline ll gao1(int x) {
if (!v[x].size())
return 0;
ll ans = 0, res = 0, sumf = 0;
for (int i = 0; i < v[x].size(); i++) {
int now = v[x][i];
ll hh = 1;
if (i > 0)
res = pls(res, sumf * (sum[v[x][i]] - sum[v[x][i - 1]]) % mod);
hh = pls(hh, res);
sumf = pls(sumf, hh);
}
return sumf;
}
int main() {
n = rd();
for (int i = 1; i <= n; i++)
num[i] = rd();
for (int i = 1; i <= n; i++)
pre[i] = pre[i - 1] ^ num[i];
for (int i = 1; i <= n; i++)
sum[i] = sum[i - 1] + (pre[i] == 0);
for (int i = 1; i <= n; i++)
v[pre[i]].push_back(i);
if (pre[n] != 0) {
printf("%lld\n", gao(n));
return 0;
}
ll ans = 0;
for (int i = 1; i < 1048576; i++)
ans = pls(ans, gao1(i));
int hh = 0;
for (int i = 1; i <= n; i++)
if (!pre[i])
hh++;
hh--;
ans = pls(ans, ksm(2, hh));
printf("%lld\n", ans);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007LL
vector<int> v[1048576];
int num[500010], pre[500010], sum[500010], n;
inline int rd() {
int x = 0;
char ch = getchar();
for (; ch < '0' || ch > '9'; ch = getchar())
;
for (; ch >= '0' && ch <= '9'; ch = getchar())
x = x * 10 + ch - '0';
return x;
}
inline ll pls(const ll &x, const ll &y) {
return (x + y < mod) ? x + y : x + y - mod;
}
inline ll mns(const ll &x, const ll &y) {
return (x - y < 0) ? x - y + mod : x - y;
}
inline ll ksm(ll x, ll y) {
ll res = 1;
for (; y; y >>= 1, x = x * x % mod)
if (y & 1)
res = res * x % mod;
return res;
}
inline ll gao(int x) {
if (!v[x].size())
return 0;
ll ans = 0, res = 0, sumf = 0;
for (int i = 0; i < v[x].size(); i++) {
int now = v[x][i];
ll hh = 1;
if (i > 0)
res = pls(res, sumf * (sum[v[x][i]] - sum[v[x][i - 1]]) % mod);
hh = pls(hh, res);
sumf = pls(sumf, hh);
ans = hh;
}
return ans;
}
inline ll gao1(int x) {
if (!v[x].size())
return 0;
ll ans = 0, res = 0, sumf = 0;
for (int i = 0; i < v[x].size(); i++) {
int now = v[x][i];
ll hh = 1;
if (i > 0)
res = pls(res, sumf * (sum[v[x][i]] - sum[v[x][i - 1]]) % mod);
hh = pls(hh, res);
sumf = pls(sumf, hh);
}
return sumf;
}
int main() {
n = rd();
for (int i = 1; i <= n; i++)
num[i] = rd();
for (int i = 1; i <= n; i++)
pre[i] = pre[i - 1] ^ num[i];
for (int i = 1; i <= n; i++)
sum[i] = sum[i - 1] + (pre[i] == 0);
for (int i = 1; i <= n; i++)
v[pre[i]].push_back(i);
if (pre[n] != 0) {
printf("%lld\n", gao(pre[n]));
return 0;
}
ll ans = 0;
for (int i = 1; i < 1048576; i++)
ans = pls(ans, gao1(i));
int hh = 0;
for (int i = 1; i <= n; i++)
if (!pre[i])
hh++;
hh--;
ans = pls(ans, ksm(2, hh));
printf("%lld\n", ans);
return 0;
} | [
"call.arguments.change"
] | 870,758 | 870,759 | u293498352 | cpp |
p03052 | const long long MOD = 1e9 + 7;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void dfs(int v, int par, vector<int> &h, vector<int> &edge_in, vector<int> &a,
vector<int> &b) {
if (v == par)
h[v] = 0;
else
h[v] = h[par] + 1;
for (int i = 0; i < h.size() - 1; i++) {
if (a[i] == v || b[i] == v) {
int u = a[i] + b[i] - v;
if (u != par) {
edge_in[u] = i;
dfs(u, v, h, edge_in, a, b);
}
}
}
}
int mark(int v, int u, vector<int> &h, vector<int> &edge_in, vector<int> &a,
vector<int> &b) {
int mask = 0;
while (h[v] > h[u]) {
mask += 1 << edge_in[v];
int f = a[edge_in[v]] + b[edge_in[v]] - v;
v = f;
}
while (h[v] < h[u]) {
mask += 1 << edge_in[u];
int f = a[edge_in[u]] + b[edge_in[u]] - u;
u = f;
}
while (v != u) {
mask += 1 << edge_in[v];
int f = a[edge_in[v]] + b[edge_in[v]] - v;
v = f;
mask += 1 << edge_in[u];
f = a[edge_in[u]] + b[edge_in[u]] - u;
u = f;
}
return mask;
}
const int N = 206;
const int M = (1 << 19) + 2;
ll dp[M];
ll EV[M];
ll ans[M];
int on_right[M];
ll Supersigmacnk[N][N];
ll Supersigmacnkdec[N][N];
ll Supersigmacnkinc[N][N];
ll cnk[N][N];
ll fact[N];
ll rev[N];
ll supersigmacnkdec(ll i, ll k, ll n) {
ll ans = Supersigmacnk[k][n] * (i + MOD - 1) % MOD;
ans = (ans + Supersigmacnkdec[k][n]) % MOD;
return ans;
}
ll supersigmacnkinc(ll i, ll k, ll n) {
ll ans = Supersigmacnk[k][n] * i % MOD;
ans = (ans + Supersigmacnkinc[k][n]) % MOD;
return ans;
}
signed main() {
srand(time(NULL));
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
fact[0] = 1;
rev[1] = 1;
for (int i = 1; i < N; i++)
fact[i] = (fact[i - 1] * i) % MOD;
for (int i = 2; i < N; i++)
rev[i] = MOD - (MOD / i) * rev[MOD % i] % MOD;
for (int i = 0; i < N; i++) {
cnk[i][0] = cnk[i][i] = 1;
for (int j = 1; j < i; j++) {
cnk[i][j] = (cnk[i - 1][j - 1] + cnk[i - 1][j]) % MOD;
}
}
for (int k = 0; k < N; k++) {
for (int n = k; n < N; n++) {
Supersigmacnk[k][n] =
((n != k ? Supersigmacnk[k][n - 1] : 0) + cnk[n][k]) % MOD;
Supersigmacnkdec[k][n] =
((n != k ? Supersigmacnkdec[k][n - 1] : 0) + Supersigmacnk[k][n]) %
MOD;
Supersigmacnkinc[k][n] =
((n != k ? Supersigmacnkinc[k][n - 1] : 0) + (n - k) * cnk[n][k]) %
MOD;
}
}
int n, m;
cin >> n >> m;
vector<int> a(m), b(m);
for (int i = 0; i < m; i++) {
cin >> a[i] >> b[i];
a[i]--, b[i]--;
}
vector<int> h(n), edge_in(n);
dfs(0, 0, h, edge_in, a, b);
vector<int> suba(m);
for (int i = n - 1; i < m; i++) {
int z = mark(a[i], b[i], h, edge_in, a, b);
suba[i] = z;
}
int M = 1 << (n - 1);
{
for (int i = n - 1; i < m; i++) {
int w = M - 1 - suba[i];
on_right[w]++;
}
for (int b = 0; b < n - 1; b++) {
for (int i = M - 1; i >= 0; i--) {
if (i & (1 << b))
continue;
on_right[i] += on_right[i + (1 << b)];
}
}
for (int mask = 1; mask < M; mask++) {
on_right[mask] = m - n + 1 - on_right[mask];
on_right[mask] += __builtin_popcount(mask) - 1;
}
return 0;
on_right[0] = -1;
dp[0] = 1;
for (int mask = 1; mask < M; mask++) {
ll summ_right = 0, cnt_left = 0;
for (int p = 0; p < n - 1; p++) {
if (mask & (1 << p)) {
int pmask = mask - (1 << p);
if (pmask == 0) {
dp[mask] = fact[on_right[mask]];
EV[mask] = fact[on_right[mask]];
ans[mask] = fact[on_right[mask]] * (m - on_right[mask]) % MOD;
continue;
}
int cnt = on_right[mask] - on_right[pmask] - 1;
ll ways = cnk[on_right[mask]][on_right[pmask] + 1] *
fact[on_right[mask] - on_right[pmask] - 1] % MOD;
ll dpways = dp[pmask] * ways % MOD;
dp[mask] = (dp[mask] + dpways) % MOD;
ll W = fact[cnt] * dp[pmask] % MOD;
ll SS1 = Supersigmacnkdec[on_right[pmask]][on_right[mask] - 1];
cnt_left = (cnt_left + SS1 * W) % MOD;
ll SS2 = supersigmacnkinc(on_right[pmask] + 1, on_right[pmask],
on_right[mask] - 1);
summ_right =
(summ_right + SS2 * fact[cnt] % MOD * (EV[pmask] + dp[pmask])) %
MOD;
ll SS3 = Supersigmacnk[on_right[pmask]][on_right[mask] - 1];
ll SS4 = supersigmacnkinc(0, on_right[pmask], on_right[mask] - 1);
ans[mask] = (ans[mask] + ans[pmask] * fact[cnt] % MOD * SS3 +
(m - on_right[mask]) * W % MOD * SS3 -
EV[pmask] * fact[cnt] % MOD * SS4) %
MOD;
if (ans[mask] < 0)
ans[mask] += MOD;
}
}
if (__builtin_popcount(mask) > 1) {
// cout << mask << " " << summ_right << " " << cnt_left << " " <<
// cnt_right << "\n";
EV[mask] = (cnt_left + summ_right) * rev[on_right[mask] + 1] % MOD;
}
// cout << mask << " " << dp[mask] << " " << EV[mask] << " " << ans[mask]
// << "\n";
}
// cout << dp[M - 1] << "\n";
cout << ans[M - 1] << "\n";
}
}
/* Note:
Check constants at the beginning of the code (MOD, INF, INFLL)
Check corner cases.
N = 1
No def int long long for now.
Add something here.
*/
| const long long MOD = 1e9 + 7;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void dfs(int v, int par, vector<int> &h, vector<int> &edge_in, vector<int> &a,
vector<int> &b) {
if (v == par)
h[v] = 0;
else
h[v] = h[par] + 1;
for (int i = 0; i < h.size() - 1; i++) {
if (a[i] == v || b[i] == v) {
int u = a[i] + b[i] - v;
if (u != par) {
edge_in[u] = i;
dfs(u, v, h, edge_in, a, b);
}
}
}
}
int mark(int v, int u, vector<int> &h, vector<int> &edge_in, vector<int> &a,
vector<int> &b) {
int mask = 0;
while (h[v] > h[u]) {
mask += 1 << edge_in[v];
int f = a[edge_in[v]] + b[edge_in[v]] - v;
v = f;
}
while (h[v] < h[u]) {
mask += 1 << edge_in[u];
int f = a[edge_in[u]] + b[edge_in[u]] - u;
u = f;
}
while (v != u) {
mask += 1 << edge_in[v];
int f = a[edge_in[v]] + b[edge_in[v]] - v;
v = f;
mask += 1 << edge_in[u];
f = a[edge_in[u]] + b[edge_in[u]] - u;
u = f;
}
return mask;
}
const int N = 206;
const int M = (1 << 19) + 2;
ll dp[M];
ll EV[M];
ll ans[M];
int on_right[M];
ll Supersigmacnk[N][N];
ll Supersigmacnkdec[N][N];
ll Supersigmacnkinc[N][N];
ll cnk[N][N];
ll fact[N];
ll rev[N];
inline ll supersigmacnkdec(ll i, ll k, ll n) {
ll ans = Supersigmacnk[k][n] * (i + MOD - 1) % MOD;
ans = (ans + Supersigmacnkdec[k][n]) % MOD;
return ans;
}
inline ll supersigmacnkinc(ll i, ll k, ll n) {
ll ans = Supersigmacnk[k][n] * i % MOD;
ans = (ans + Supersigmacnkinc[k][n]) % MOD;
return ans;
}
signed main() {
srand(time(NULL));
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
fact[0] = 1;
rev[1] = 1;
for (int i = 1; i < N; i++)
fact[i] = (fact[i - 1] * i) % MOD;
for (int i = 2; i < N; i++)
rev[i] = MOD - (MOD / i) * rev[MOD % i] % MOD;
for (int i = 0; i < N; i++) {
cnk[i][0] = cnk[i][i] = 1;
for (int j = 1; j < i; j++) {
cnk[i][j] = (cnk[i - 1][j - 1] + cnk[i - 1][j]) % MOD;
}
}
for (int k = 0; k < N; k++) {
for (int n = k; n < N; n++) {
Supersigmacnk[k][n] =
((n != k ? Supersigmacnk[k][n - 1] : 0) + cnk[n][k]) % MOD;
Supersigmacnkdec[k][n] =
((n != k ? Supersigmacnkdec[k][n - 1] : 0) + Supersigmacnk[k][n]) %
MOD;
Supersigmacnkinc[k][n] =
((n != k ? Supersigmacnkinc[k][n - 1] : 0) + (n - k) * cnk[n][k]) %
MOD;
}
}
int n, m;
cin >> n >> m;
vector<int> a(m), b(m);
for (int i = 0; i < m; i++) {
cin >> a[i] >> b[i];
a[i]--, b[i]--;
}
vector<int> h(n), edge_in(n);
dfs(0, 0, h, edge_in, a, b);
vector<int> suba(m);
for (int i = n - 1; i < m; i++) {
int z = mark(a[i], b[i], h, edge_in, a, b);
suba[i] = z;
}
int M = 1 << (n - 1);
{
for (int i = n - 1; i < m; i++) {
int w = M - 1 - suba[i];
on_right[w]++;
}
for (int b = 0; b < n - 1; b++) {
for (int i = M - 1; i >= 0; i--) {
if (i & (1 << b))
continue;
on_right[i] += on_right[i + (1 << b)];
}
}
for (int mask = 1; mask < M; mask++) {
on_right[mask] = m - n + 1 - on_right[mask];
on_right[mask] += __builtin_popcount(mask) - 1;
}
on_right[0] = -1;
dp[0] = 1;
for (int mask = 1; mask < M; mask++) {
ll summ_right = 0, cnt_left = 0;
for (int p = 0; p < n - 1; p++) {
if (mask & (1 << p)) {
int pmask = mask - (1 << p);
if (pmask == 0) {
dp[mask] = fact[on_right[mask]];
EV[mask] = fact[on_right[mask]];
ans[mask] = fact[on_right[mask]] * (m - on_right[mask]) % MOD;
continue;
}
int cnt = on_right[mask] - on_right[pmask] - 1;
ll ways = cnk[on_right[mask]][on_right[pmask] + 1] *
fact[on_right[mask] - on_right[pmask] - 1] % MOD;
ll dpways = dp[pmask] * ways % MOD;
dp[mask] = (dp[mask] + dpways) % MOD;
ll W = fact[cnt] * dp[pmask] % MOD;
ll SS1 = Supersigmacnkdec[on_right[pmask]][on_right[mask] - 1];
cnt_left = (cnt_left + SS1 * W) % MOD;
ll SS2 = supersigmacnkinc(on_right[pmask] + 1, on_right[pmask],
on_right[mask] - 1);
summ_right =
(summ_right + SS2 * fact[cnt] % MOD * (EV[pmask] + dp[pmask])) %
MOD;
ll SS3 = Supersigmacnk[on_right[pmask]][on_right[mask] - 1];
ll SS4 = supersigmacnkinc(0, on_right[pmask], on_right[mask] - 1);
ans[mask] = (ans[mask] + ans[pmask] * fact[cnt] % MOD * SS3 +
(m - on_right[mask]) * W % MOD * SS3 -
EV[pmask] * fact[cnt] % MOD * SS4) %
MOD;
if (ans[mask] < 0)
ans[mask] += MOD;
}
}
if (__builtin_popcount(mask) > 1) {
// cout << mask << " " << summ_right << " " << cnt_left << " " <<
// cnt_right << "\n";
EV[mask] = (cnt_left + summ_right) * rev[on_right[mask] + 1] % MOD;
}
// cout << mask << " " << dp[mask] << " " << EV[mask] << " " << ans[mask]
// << "\n";
}
// cout << dp[M - 1] << "\n";
cout << ans[M - 1] << "\n";
}
}
/* Note:
Check constants at the beginning of the code (MOD, INF, INFLL)
Check corner cases.
N = 1
No def int long long for now.
Add something here.
*/
| [] | 870,764 | 870,765 | u798339690 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << floor(t / (a + 0.5)) * b << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << floor((t + 0.5) / a) * b << endl;
} | [
"expression.operation.binary.remove",
"identifier.change",
"io.output.change"
] | 870,775 | 870,776 | u010806195 | cpp |
p03059 | #include <iostream>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << A * (T / B) << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << B * (T / A) << endl;
return 0;
} | [
"identifier.change",
"io.output.change"
] | 870,791 | 870,792 | u113960459 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << b * t / a;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << (t / a) * b;
return 0;
}
| [
"io.output.change"
] | 870,806 | 870,807 | u000770457 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << ((T + 0.5) / A) * B << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << (T / A) * B << endl;
}
| [] | 870,842 | 870,843 | u922449177 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << ((T - 0.5) / A) * B << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << (T / A) * B << endl;
}
| [] | 870,844 | 870,843 | u922449177 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << ((t + 0.5) / a) * b << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << (t / a) * b << endl;
return 0;
}
| [] | 870,847 | 870,848 | u977062184 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << t / a * 2 << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << t / a * b << endl;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"io.output.change"
] | 870,856 | 870,857 | u569361260 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << (T + 0.5) / A * B << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << T / A * B << endl;
}
| [] | 870,872 | 870,873 | u425231382 | cpp |
p03059 | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
int main() {
int a, b, t;
cin >> a >> b >> t;
int x = t / b;
cout << x * a << endl;
}
| #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
int main() {
int a, b, t;
cin >> a >> b >> t;
int x = t / a;
cout << x * b << endl;
}
| [
"identifier.change",
"expression.operation.binary.change",
"io.output.change"
] | 870,880 | 870,881 | u485925545 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << (t % a) * b << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << (t / a) * b << endl;
}
| [
"expression.operator.arithmetic.change",
"io.output.change"
] | 870,890 | 870,891 | u820690792 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTINOUT \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
const ll mod = 1e9 + 7;
const int N = 2e5 + 9;
int main() {
FASTINOUT;
int a, b, c;
cin >> a >> b >> c;
cout << (c + 0.5) / a * b;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTINOUT \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
const ll mod = 1e9 + 7;
const int N = 2e5 + 9;
int main() {
FASTINOUT;
int a, b, c;
cin >> a >> b >> c;
cout << c / a * b;
return 0;
}
| [] | 870,896 | 870,897 | u257571179 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << ((t + 0.5) / a) * b << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << (t / a) * b << endl;
} | [] | 870,900 | 870,901 | u176218583 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s, i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << b * (a / t) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s, i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << b * (t / a) << endl;
return 0;
} | [
"expression.operation.binary.remove"
] | 870,906 | 870,907 | u985524697 | cpp |
p03059 | // 007naruto
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < n; i++)
int main() {
ll a, b, c;
cin >> a >> b >> c;
cout << (a / c) * b;
} | // 007naruto
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < n; i++)
int main() {
ll a, b, c;
cin >> a >> b >> c;
cout << (c / a) * b;
}
| [
"expression.operation.binary.remove"
] | 870,916 | 870,917 | u564430087 | cpp |
p03059 | #include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;
int main() {
int a, b, c;
cin >> a >> b >> c;
int ans;
ans = b * (c + 0.5) / a;
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;
int main() {
int a, b, c;
cin >> a >> b >> c;
int ans;
ans = b * (c / a);
cout << ans << endl;
return 0;
}
| [] | 870,918 | 870,919 | u281876921 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;
int main() {
ll a, b, c;
in3(a, b, c);
out(a * (c / b));
memi;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;
int main() {
ll a, b, c;
in3(a, b, c);
out(b * (c / a));
memi;
} | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 870,930 | 870,931 | u917049698 | cpp |
p03059 | #include <iostream>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << t / 3 * b;
}
| #include <iostream>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << t / a * b;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"io.output.change"
] | 870,934 | 870,935 | u639300218 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << B * (A / T) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << B * (T / A) << endl;
}
| [
"expression.operation.binary.remove"
] | 870,947 | 870,948 | u457196771 | cpp |
p03059 | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << b * (a / t) << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << b * (t / a) << endl;
return 0;
} | [
"expression.operation.binary.remove"
] | 870,949 | 870,950 | u190761897 | cpp |
p03059 | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << b * (a / 7) << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << b * (t / a) << endl;
return 0;
} | [
"identifier.change",
"io.output.change",
"identifier.replace.add",
"literal.replace.remove"
] | 870,951 | 870,950 | u190761897 | cpp |
p03059 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int a, b, t;
cin >> a, b, t;
int ans = t / a;
cout << (ans * b) << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
int ans = t / a;
cout << ans * b << endl;
return 0;
}
| [] | 870,958 | 870,959 | u589238650 | cpp |
p03059 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int a, b, t;
cin >> a, b, t;
int ans = t / a;
cout << ans * b << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
int ans = t / a;
cout << ans * b << endl;
return 0;
}
| [] | 870,960 | 870,959 | u589238650 | cpp |
p03059 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int a, b, t;
cin >> a, b, t;
int g = t / a;
int ans = g * b;
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
int g = t / a;
int ans = g * b;
cout << ans << endl;
return 0;
}
| [] | 870,961 | 870,962 | u589238650 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << t * b;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << (t / a) * b;
}
| [] | 870,979 | 870,980 | u065898443 | cpp |
p03059 | #pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(), (V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) \
SORT(V); \
REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define RAPID \
cin.tie(0); \
ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a, b) cin >> a >> b
#define IN3(a, b, c) cin >> a >> b >> c
#define VIN(V) \
for (int i = 0; i < (V).size(); i++) { \
cin >> (V).at(i); \
}
#define OUT(n) cout << n << endl
#define VOUT(V) \
REP(i, (V).size()) { cout << (V)[i] << endl; }
#define VOUT2(V) \
REP(i, (V).size()) { cout << (V)[i] << " "; } \
cout << endl;
// 型マクロ定義
#define int long long
#define P pair<ll, ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll, ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue < ll, V, greater<ll>
//
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //最小公倍数
// デフォルト変数定義
double n, m, a, b, c, x, y, z;
double d, e, f;
string s, t;
//
signed main() {
RAPID;
IN3(a, b, x);
OUT(floor(c / a) * b);
} | #pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(), (V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) \
SORT(V); \
REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define RAPID \
cin.tie(0); \
ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a, b) cin >> a >> b
#define IN3(a, b, c) cin >> a >> b >> c
#define VIN(V) \
for (int i = 0; i < (V).size(); i++) { \
cin >> (V).at(i); \
}
#define OUT(n) cout << n << endl
#define VOUT(V) \
REP(i, (V).size()) { cout << (V)[i] << endl; }
#define VOUT2(V) \
REP(i, (V).size()) { cout << (V)[i] << " "; } \
cout << endl;
// 型マクロ定義
#define int long long
#define P pair<ll, ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll, ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue < ll, V, greater<ll>
//
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //最小公倍数
// デフォルト変数定義
double n, m, a, b, c, x, y, z;
double d, e, f;
string s, t;
//
signed main() {
RAPID;
IN3(a, b, x);
OUT(floor(x / a) * b);
} | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 870,999 | 871,000 | u154645927 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << (t + 0.5) / a * b << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, t;
cin >> a >> b >> t;
cout << t / a * b << endl;
} | [] | 871,014 | 871,015 | u294721290 | cpp |
p03059 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A, B, T;
cout << (T / A) * B << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, T;
cin >> A >> B >> T;
cout << (T / A) * B << endl;
return 0;
} | [] | 871,020 | 871,021 | u767481489 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.