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 8
values |
|---|---|---|---|---|---|---|---|
p02929
|
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = int(1e9) + 7;
int n;
char s[200005];
int a[200005];
int main() {
scanf("%d%s", &n, s);
n *= 2;
a[0] = 0;
char col = s[0];
int bal = 1;
int ans = 1;
for (int i = 1; i < n; ++i) {
if (s[i] != col) {
a[i] = 0;
++bal;
} else {
a[i] = 1;
ans = (LL)ans * bal % MOD;
--bal;
}
if (col == 'W') {
col = 'B';
} else {
col = 'W';
}
}
for (int i = 2; i <= n / 2; ++i) {
ans = (LL)ans * i % MOD;
}
if (col == 'B') {
ans = 0;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = int(1e9) + 7;
int n;
char s[200005];
int a[200005];
int main() {
scanf("%d%s", &n, s);
n *= 2;
a[0] = 0;
char col = s[0];
int bal = 1;
int ans = 1;
for (int i = 1; i < n; ++i) {
if (s[i] != col) {
a[i] = 0;
++bal;
} else {
a[i] = 1;
ans = (LL)ans * bal % MOD;
--bal;
}
if (col == 'W') {
col = 'B';
} else {
col = 'W';
}
}
for (int i = 2; i <= n / 2; ++i) {
ans = (LL)ans * i % MOD;
}
if (col == 'B' || bal != 0) {
ans = 0;
}
cout << ans << endl;
return 0;
}
|
[
"control_flow.branch.if.condition.change"
] | 732,092
| 732,093
|
u155202361
|
cpp
|
p02930
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(), (v).end()
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
const ll INF = 1LL << 60;
const int inf = (1 << 30) - 1;
const int mod = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
FOR(i, 1, n) {
FOR(j, i + 1, n) {
int cnt = 1;
int t = 2;
while (i % t == j % t) {
t *= 2;
cnt++;
}
cout << cnt << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(), (v).end()
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
const ll INF = 1LL << 60;
const int inf = (1 << 30) - 1;
const int mod = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
FOR(i, 1, n) {
FOR(j, i + 1, n + 1) {
int cnt = 1;
int t = 2;
while (i % t == j % t) {
t *= 2;
cnt++;
}
cout << cnt << " ";
}
cout << endl;
}
}
|
[
"expression.operation.binary.add"
] | 732,104
| 732,105
|
u244626757
|
cpp
|
p02929
|
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
using vs = vector<string>;
using tll = tuple<ll, ll, ll>;
using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i, j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head h, Tail... t) {
cerr << " " << h;
if (sizeof...(t) > 0)
cerr << " :";
debug_out(t...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> vec) {
for (size_t i = 0; i < vec.size(); i++)
os << vec[i] << (i + 1 == vec.size() ? "" : " ");
return os;
}
ll ctoi(char c) {
switch (c) {
case '0':
return 0;
case '1':
return 1;
case '2':
return 2;
case '3':
return 3;
case '4':
return 4;
case '5':
return 5;
case '6':
return 6;
case '7':
return 7;
case '8':
return 8;
case '9':
return 9;
default:
return 0;
}
}
bool pairCompare(const pll firstElof, pll secondElof) {
return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
// rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
// gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,
// doubling// dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal,
// RMQ, LCA//
ll i, j, k, l;
ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D;
vll path;
//***********//
int main() {
cin >> N;
string S;
cin >> S;
vl A(2 * N);
A[i] = 0;
if (S[0] == 'W' || S[2 * N - 1] == 'W') {
cout << 0;
exit(0);
}
for (i = 0; i < 2 * N - 1; i++) {
if (S[i] == S[i + 1]) {
A[i + 1] = (A[i] + 1) % 2;
} else {
A[i + 1] = A[i];
}
}
vl R(2 * N + 1), L(2 * N + 1);
R[0] = 0;
L[0] = 0;
for (i = 0; i < 2 * N; i++) {
R[i + 1] = R[i];
L[i + 1] = L[i];
if (A[i] == 0)
L[i + 1]++;
else
R[i + 1]++;
}
if (R[N] != L[N]) {
cout << 0;
exit(0);
}
ans = 1;
for (i = 0; i < 2 * N; i++) {
if (A[i] == 1) {
(ans *= (L[i] - R[i])) %= MOD;
}
}
for (i = 1; i <= N; i++) {
(ans *= i) %= MOD;
}
co(ans);
}
|
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
using vs = vector<string>;
using tll = tuple<ll, ll, ll>;
using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i, j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head h, Tail... t) {
cerr << " " << h;
if (sizeof...(t) > 0)
cerr << " :";
debug_out(t...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> vec) {
for (size_t i = 0; i < vec.size(); i++)
os << vec[i] << (i + 1 == vec.size() ? "" : " ");
return os;
}
ll ctoi(char c) {
switch (c) {
case '0':
return 0;
case '1':
return 1;
case '2':
return 2;
case '3':
return 3;
case '4':
return 4;
case '5':
return 5;
case '6':
return 6;
case '7':
return 7;
case '8':
return 8;
case '9':
return 9;
default:
return 0;
}
}
bool pairCompare(const pll firstElof, pll secondElof) {
return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
// rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
// gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,
// doubling// dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal,
// RMQ, LCA//
ll i, j, k, l;
ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D;
vll path;
//***********//
int main() {
cin >> N;
string S;
cin >> S;
vl A(2 * N);
A[i] = 0;
if (S[0] == 'W' || S[2 * N - 1] == 'W') {
cout << 0;
exit(0);
}
for (i = 0; i < 2 * N - 1; i++) {
if (S[i] == S[i + 1]) {
A[i + 1] = (A[i] + 1) % 2;
} else {
A[i + 1] = A[i];
}
}
vl R(2 * N + 1), L(2 * N + 1);
R[0] = 0;
L[0] = 0;
for (i = 0; i < 2 * N; i++) {
R[i + 1] = R[i];
L[i + 1] = L[i];
if (A[i] == 0)
L[i + 1]++;
else
R[i + 1]++;
}
if (R[2 * N] != L[2 * N]) {
cout << 0;
exit(0);
}
ans = 1;
for (i = 0; i < 2 * N; i++) {
if (A[i] == 1) {
(ans *= (L[i] - R[i])) %= MOD;
}
}
for (i = 1; i <= N; i++) {
(ans *= i) %= MOD;
}
co(ans);
}
|
[
"control_flow.branch.if.condition.change"
] | 732,110
| 732,111
|
u916974091
|
cpp
|
p02929
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#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)
const int INF = 1001001000;
const int mINF = -1001001000;
const ll LINF = 1010010010010010000;
const int mod = 1'000'000'007;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド:(典型)dp,dfs,bfs,最短経路,その他
int main() {
ll n;
cin >> n;
string s;
cin >> s;
vi d(n);
ll ans = 1;
if (s[0] == 'W' || s[sz(s) - 1] == 'W') {
cout << 0 << endl;
return 0;
}
rep(i, sz(s)) {
if (i == 0)
d[i] = 1;
else if (s[i] == s[i - 1]) {
if (d[i - 1] == 0)
d[i] = 1;
else
d[i] = 0;
} else if (s[i] != s[i - 1]) {
d[i] = d[i - 1];
}
}
ll cnt = 0;
rep(i, sz(s)) {
if (d[i] == 1) {
cnt++;
} else {
ans *= cnt;
ans %= mod;
cnt--;
}
if (cnt < 0) {
cout << 0 << endl;
return 0;
}
}
if (cnt != 0) {
cout << 0 << endl;
return 0;
}
for (int i = 1; i <= n; i++)
ans *= i;
ans %= mod;
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#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)
const int INF = 1001001000;
const int mINF = -1001001000;
const ll LINF = 1010010010010010000;
const int mod = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド:(典型)dp,dfs,bfs,最短経路,その他
int main() {
ll n;
cin >> n;
string s;
cin >> s;
vi d(2 * n);
ll ans = 1;
if (s[0] == 'W' || s[sz(s) - 1] == 'W') {
cout << 0 << endl;
return 0;
}
rep(i, sz(s)) {
if (i == 0)
d[i] = 1;
else if (s[i] == s[i - 1]) {
if (d[i - 1] == 0)
d[i] = 1;
else
d[i] = 0;
} else if (s[i] != s[i - 1]) {
d[i] = d[i - 1];
}
}
ll cnt = 0;
rep(i, sz(s)) {
if (d[i] == 1) {
cnt++;
} else {
ans *= cnt;
ans %= mod;
cnt--;
}
if (cnt < 0) {
cout << 0 << endl;
return 0;
}
}
if (cnt != 0) {
cout << 0 << endl;
return 0;
}
for (int i = 1; i <= n; i++) {
ans *= i;
ans %= mod;
}
cout << ans << endl;
return 0;
}
|
[
"literal.number.change",
"variable_declaration.value.change"
] | 732,134
| 732,132
|
u796877631
|
cpp
|
p02929
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#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)
const int INF = 1001001000;
const int mINF = -1001001000;
const ll LINF = 1010010010010010000;
const int mod = 1'000'000'007;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド:(典型)dp,dfs,bfs,最短経路,その他
int main() {
ll n;
cin >> n;
string s;
cin >> s;
vi d(n);
ll ans = 1;
if (s[0] == 'W' || s[sz(s) - 1] == 'W') {
cout << 0 << endl;
return 0;
}
rep(i, sz(s)) {
if (i == 0)
d[i] = 1;
else if (s[i] == s[i - 1]) {
if (d[i - 1] == 0)
d[i] = 1;
else
d[i] = 0;
} else if (s[i] != s[i - 1]) {
d[i] = d[i - 1];
}
}
ll cnt = 0;
rep(i, sz(s)) {
if (d[i] == 1) {
cnt++;
} else {
ans *= cnt;
ans %= mod;
cnt--;
}
if (cnt < 0) {
cout << 0 << endl;
return 0;
}
}
if (cnt != 0) {
cout << 0 << endl;
return 0;
}
for (int i = 1; i <= n; i++)
ans *= i;
ans %= mod;
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#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)
const int INF = 1001001000;
const int mINF = -1001001000;
const ll LINF = 1010010010010010000;
const int mod = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド:(典型)dp,dfs,bfs,最短経路,その他
int main() {
ll n;
cin >> n;
string s;
cin >> s;
vi d(2 * n);
ll ans = 1;
if (s[0] == 'W' || s[sz(s) - 1] == 'W') {
cout << 0 << endl;
return 0;
}
rep(i, sz(s)) {
if (i == 0)
d[i] = 1;
else if (s[i] == s[i - 1]) {
if (d[i - 1] == 0)
d[i] = 1;
else
d[i] = 0;
} else if (s[i] != s[i - 1]) {
d[i] = d[i - 1];
}
}
ll cnt = 0;
rep(i, sz(s)) {
if (d[i] == 1) {
cnt++;
} else {
ans *= cnt;
ans %= mod;
cnt--;
}
if (cnt < 0) {
cout << 0 << endl;
return 0;
}
}
if (cnt != 0) {
cout << 0 << endl;
return 0;
}
for (int i = 1; i <= n; i++) {
ans *= i;
ans %= mod;
}
cout << ans << endl;
return 0;
}
|
[
"literal.number.change",
"variable_declaration.value.change"
] | 732,135
| 732,132
|
u796877631
|
cpp
|
p02929
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template <typename T> inline istream &operator>>(istream &i, v(T) & v) {
rep(j, sz(v)) i >> v[j];
return i;
}
template <typename T1, typename T2>
inline istream &operator>>(istream &i, pair<T1, T2> &v) {
return i >> v.fi >> v.se;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
ll INF = 1001001001;
ll LINF = 1001001001001001001ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
string s;
cin >> s;
vector<bool> wb(2 * n);
rep(i, 2 * n) {
if (s[i] == 'W' && i % 2 == 0)
wb[i] = true;
else if (s[i] == 'B' && i % 2 == 1)
wb[i] = true;
}
ll cnt = 0;
rep(i, 2 * n) if (wb[i]) cnt++;
if (cnt != n) {
cout << -1 << endl;
return 0;
}
ll l = 0;
mint ans = 1;
rep(i, 2 * n) {
if (!wb[i])
l++;
else {
ans *= l;
l--;
}
}
rep(i, n) ans *= i + 1;
cout << ans << endl;
}
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template <typename T> inline istream &operator>>(istream &i, v(T) & v) {
rep(j, sz(v)) i >> v[j];
return i;
}
template <typename T1, typename T2>
inline istream &operator>>(istream &i, pair<T1, T2> &v) {
return i >> v.fi >> v.se;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
ll INF = 1001001001;
ll LINF = 1001001001001001001ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
string s;
cin >> s;
vector<bool> wb(2 * n);
rep(i, 2 * n) {
if (s[i] == 'W' && i % 2 == 0)
wb[i] = true;
else if (s[i] == 'B' && i % 2 == 1)
wb[i] = true;
}
ll cnt = 0;
rep(i, 2 * n) if (wb[i]) cnt++;
if (cnt != n) {
cout << 0 << endl;
return 0;
}
ll l = 0;
mint ans = 1;
rep(i, 2 * n) {
if (!wb[i])
l++;
else {
ans *= l;
l--;
}
}
rep(i, n) ans *= i + 1;
cout << ans << endl;
}
|
[
"literal.number.change",
"io.output.change"
] | 732,138
| 732,139
|
u482770395
|
cpp
|
p02929
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
ll n;
cin >> n;
string s;
cin >> s;
vector<bool> side(n);
side[0] = false;
ll t = 0, f = 1;
for (ll i = 1; i < 2 * n; i++) {
if (s[i - 1] != s[i]) {
side[i] = side[i - 1];
} else {
side[i] = !side[i - 1];
}
if (side[i]) {
t++;
} else {
f++;
}
}
if (s[0] == 'W' || s[2 * n - 1] == 'W' || t != f) {
cout << 0 << endl;
}
ll l = 0, r = 0;
ll ans = 1LL;
for (ll i = 0; i < 2 * n; i++) {
if (side[i]) {
ans *= max(l - r, 0LL);
ans %= MOD;
}
if (side[i]) {
r++;
} else {
l++;
}
}
for (ll i = 1; i <= n; i++) {
ans *= i;
ans %= MOD;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
ll n;
cin >> n;
string s;
cin >> s;
vector<bool> side(2 * n);
side[0] = false;
ll t = 0, f = 1;
for (ll i = 1; i < 2 * n; i++) {
if (s[i - 1] != s[i]) {
side[i] = side[i - 1];
} else {
side[i] = !side[i - 1];
}
if (side[i]) {
t++;
} else {
f++;
}
}
if (s[0] == 'W' || s[2 * n - 1] == 'W' || t != f) {
cout << 0 << endl;
return 0;
}
ll l = 0, r = 0;
ll ans = 1LL;
for (ll i = 0; i < 2 * n; i++) {
if (side[i]) {
ans *= max(l - r, 0LL);
ans %= MOD;
}
if (side[i]) {
r++;
} else {
l++;
}
}
for (ll i = 1; i <= n; i++) {
ans *= i;
ans %= MOD;
}
cout << ans << endl;
return 0;
}
|
[
"assignment.change",
"control_flow.return.add",
"control_flow.return.0.add"
] | 732,144
| 732,143
|
u904123392
|
cpp
|
p02929
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int base = 1e9 + 7;
int main() {
int n;
cin >> n;
string s;
cin >> s;
vector<int> dif(2 * n + 1, 0);
dif[0] = (s[0] == 'B' ? 1 : 0);
dif[2 * n] = (s[2 * n] == 'B' ? 1 : 0);
for (int i = 1; i < 2 * n; ++i)
if (s[i] != s[i - 1])
dif[i] = 1;
ll total = 1;
int cur = 0, cnt = 0;
for (int d : dif) {
if (cur == 0) {
if (d == 1)
++cnt;
else
cur = 1;
} else {
total = total * cnt % base;
if (d == 1)
--cnt;
else
cur = 0;
}
}
if (cnt == 0)
while (n)
total = total * n-- % base;
else
total = 0;
cout << total << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int base = 1e9 + 7;
int main() {
int n;
cin >> n;
string s;
cin >> s;
vector<int> dif(2 * n + 1, 0);
dif[0] = (s[0] == 'B' ? 1 : 0);
dif[2 * n] = (s[2 * n - 1] == 'B' ? 1 : 0);
for (int i = 1; i < 2 * n; ++i)
if (s[i] != s[i - 1])
dif[i] = 1;
ll total = 1;
int cur = 0, cnt = 0;
for (int d : dif) {
if (cur == 0) {
if (d == 1)
++cnt;
else
cur = 1;
} else {
total = total * cnt % base;
if (d == 1)
--cnt;
else
cur = 0;
}
}
if (cnt == 0)
while (n)
total = total * n-- % base;
else
total = 0;
cout << total << endl;
}
|
[
"assignment.change"
] | 732,145
| 732,146
|
u809975392
|
cpp
|
p02929
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a) for (int i = 0; i < (a); i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using ll = long long;
template <ll MOD = 1000000007> struct Mint {
ll x;
Mint() : x(0) {}
Mint(ll t) {
x = t % MOD;
if (x < 0)
x += MOD;
}
Mint pow(ll n) {
Mint res(1), t(x);
while (n > 0) {
if (n & 1)
res *= t;
t *= t;
n >>= 1;
}
return res;
}
Mint inv() const {
ll a = x, b = MOD, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
return Mint(u);
}
Mint &operator+=(Mint a) {
x += a.x;
if (x >= MOD)
x -= MOD;
return *this;
}
Mint &operator-=(Mint a) {
x += MOD - a.x;
if (x >= MOD)
x -= MOD;
return *this;
}
Mint &operator*=(Mint a) {
x = 1LL * x * a.x % MOD;
return *this;
}
Mint &operator/=(Mint a) { return (*this) *= a.inv(); }
Mint operator+(Mint a) const { return Mint(x) += a; }
Mint operator-(Mint a) const { return Mint(x) -= a; }
Mint operator*(Mint a) const { return Mint(x) *= a; }
Mint operator/(Mint a) const { return Mint(x) /= a; }
Mint operator-() const { return Mint(-x); }
bool operator==(const Mint a) { return x == a.x; }
bool operator!=(const Mint a) { return x != a.x; }
bool operator<(const Mint a) { return x < a.x; }
friend ostream &operator<<(ostream &os, const Mint &a) { return os << a.x; }
friend istream &operator>>(istream &is, Mint &a) {
ll t;
is >> t;
a = Mint<MOD>(t);
return (is);
}
};
/*
MODint依存
*/
template <typename T> struct Comb {
vector<T> fac, fin;
Comb(int sz) : fac(sz + 1), fin(sz + 1) {
fac[0] = fin[sz] = T(1);
for (int i = 1; i <= sz; i++) {
fac[i] = fac[i - 1] * T(i);
}
fin[sz] /= fac[sz];
for (int i = sz - 1; i >= 0; i--) {
fin[i] = fin[i + 1] * T(i + 1);
}
}
/* 階乗 */
inline T fact(int k) const { return fac[k]; }
inline T finv(int k) const { return fin[k]; }
/* 順列 */
T P(int n, int k) const {
if (k < 0 || n < k)
return T(0);
return fac[n] * fin[n - k];
}
/* 組み合わせ */
T C(int n, int k) const {
if (k < 0 || n < k)
return T(0);
return fac[n] * fin[n - k] * fin[k];
}
/* 重複組み合わせ */
T H(int n, int k) const {
if (n < 0 || k < 0)
return T(0);
return k == 0 ? T(1) : C(n + k - 1, k);
}
/* ベル数 */
T B(int n, int k) const {
if (n == 0)
return T(1);
k = min(k, n);
vector<T> dp(k + 1);
dp[0] = T(1);
for (int i = 1; i <= k; i++) {
if (i & 1)
dp[i] = dp[i - 1] - fin[i];
else
dp[i] = dp[i - 1] + fin[i];
}
T res(0);
for (int i = 1; i <= k; i++) {
/* MODint依存 */
res += T(i).pow(n) * fin[i] * dp[k - i];
}
return res;
}
/* スターリング数 */
T S(int n, int k) const {
T res(0);
for (int i = 1; i <= k; i++) {
/* MODint依存 */
T t = C(k, i) * T(i).pow(n);
if ((k - i) & 1)
res -= t;
else
res += t;
}
return res * fin[k];
}
};
/*
P(5, 3)の場合 :
0 + 0 + 5 = 0 + 1 + 4 = 0 + 2 + 3 = 1 + 1 + 3 = 1 + 2 + 2
よって、P(5, 3) = 5
*/
template <typename T> struct Partition {
vector<vector<T>> dp;
Partition(int sz) : dp(sz + 1, vector<T>(sz + 1)) {
dp[0][0] = T(1);
for (int i = 0; i <= sz; i++) {
for (int j = 1; j <= sz; j++) {
if (i - j >= 0)
dp[i][j] = dp[i][j - 1] + dp[i - j][j];
else
dp[i][j] = dp[i][j - 1];
}
}
}
/* 分割数 */
T P(int n, int k) {
if (n < 0 || k < 0)
return T(0);
return dp[n][k];
}
};
signed main() {
int n;
cin >> n;
string s;
cin >> s;
Mint<> ans = 1;
int now = 0;
bool inc = true;
char pre = 'W';
for (int i = 0; i < 2 * n; i++) {
if (s[i] != pre) {
if (inc)
now++;
else {
ans *= now;
now--;
}
} else {
inc = !inc;
if (inc)
now++;
else {
ans *= now;
now--;
}
}
pre = s[i];
}
Comb<Mint<>> C(n);
if (now == 0)
cout << 0 << endl;
else
cout << ans * C.fact(n) << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a) for (int i = 0; i < (a); i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using ll = long long;
template <ll MOD = 1000000007> struct Mint {
ll x;
Mint() : x(0) {}
Mint(ll t) {
x = t % MOD;
if (x < 0)
x += MOD;
}
Mint pow(ll n) {
Mint res(1), t(x);
while (n > 0) {
if (n & 1)
res *= t;
t *= t;
n >>= 1;
}
return res;
}
Mint inv() const {
ll a = x, b = MOD, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
return Mint(u);
}
Mint &operator+=(Mint a) {
x += a.x;
if (x >= MOD)
x -= MOD;
return *this;
}
Mint &operator-=(Mint a) {
x += MOD - a.x;
if (x >= MOD)
x -= MOD;
return *this;
}
Mint &operator*=(Mint a) {
x = 1LL * x * a.x % MOD;
return *this;
}
Mint &operator/=(Mint a) { return (*this) *= a.inv(); }
Mint operator+(Mint a) const { return Mint(x) += a; }
Mint operator-(Mint a) const { return Mint(x) -= a; }
Mint operator*(Mint a) const { return Mint(x) *= a; }
Mint operator/(Mint a) const { return Mint(x) /= a; }
Mint operator-() const { return Mint(-x); }
bool operator==(const Mint a) { return x == a.x; }
bool operator!=(const Mint a) { return x != a.x; }
bool operator<(const Mint a) { return x < a.x; }
friend ostream &operator<<(ostream &os, const Mint &a) { return os << a.x; }
friend istream &operator>>(istream &is, Mint &a) {
ll t;
is >> t;
a = Mint<MOD>(t);
return (is);
}
};
/*
MODint依存
*/
template <typename T> struct Comb {
vector<T> fac, fin;
Comb(int sz) : fac(sz + 1), fin(sz + 1) {
fac[0] = fin[sz] = T(1);
for (int i = 1; i <= sz; i++) {
fac[i] = fac[i - 1] * T(i);
}
fin[sz] /= fac[sz];
for (int i = sz - 1; i >= 0; i--) {
fin[i] = fin[i + 1] * T(i + 1);
}
}
/* 階乗 */
inline T fact(int k) const { return fac[k]; }
inline T finv(int k) const { return fin[k]; }
/* 順列 */
T P(int n, int k) const {
if (k < 0 || n < k)
return T(0);
return fac[n] * fin[n - k];
}
/* 組み合わせ */
T C(int n, int k) const {
if (k < 0 || n < k)
return T(0);
return fac[n] * fin[n - k] * fin[k];
}
/* 重複組み合わせ */
T H(int n, int k) const {
if (n < 0 || k < 0)
return T(0);
return k == 0 ? T(1) : C(n + k - 1, k);
}
/* ベル数 */
T B(int n, int k) const {
if (n == 0)
return T(1);
k = min(k, n);
vector<T> dp(k + 1);
dp[0] = T(1);
for (int i = 1; i <= k; i++) {
if (i & 1)
dp[i] = dp[i - 1] - fin[i];
else
dp[i] = dp[i - 1] + fin[i];
}
T res(0);
for (int i = 1; i <= k; i++) {
/* MODint依存 */
res += T(i).pow(n) * fin[i] * dp[k - i];
}
return res;
}
/* スターリング数 */
T S(int n, int k) const {
T res(0);
for (int i = 1; i <= k; i++) {
/* MODint依存 */
T t = C(k, i) * T(i).pow(n);
if ((k - i) & 1)
res -= t;
else
res += t;
}
return res * fin[k];
}
};
/*
P(5, 3)の場合 :
0 + 0 + 5 = 0 + 1 + 4 = 0 + 2 + 3 = 1 + 1 + 3 = 1 + 2 + 2
よって、P(5, 3) = 5
*/
template <typename T> struct Partition {
vector<vector<T>> dp;
Partition(int sz) : dp(sz + 1, vector<T>(sz + 1)) {
dp[0][0] = T(1);
for (int i = 0; i <= sz; i++) {
for (int j = 1; j <= sz; j++) {
if (i - j >= 0)
dp[i][j] = dp[i][j - 1] + dp[i - j][j];
else
dp[i][j] = dp[i][j - 1];
}
}
}
/* 分割数 */
T P(int n, int k) {
if (n < 0 || k < 0)
return T(0);
return dp[n][k];
}
};
signed main() {
int n;
cin >> n;
string s;
cin >> s;
Mint<> ans = 1;
int now = 0;
bool inc = true;
char pre = 'W';
for (int i = 0; i < 2 * n; i++) {
if (s[i] != pre) {
if (inc)
now++;
else {
ans *= now;
now--;
}
} else {
inc = !inc;
if (inc)
now++;
else {
ans *= now;
now--;
}
}
pre = s[i];
}
Comb<Mint<>> C(n);
if (now != 0)
cout << 0 << endl;
else
cout << ans * C.fact(n) << endl;
}
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 732,157
| 732,158
|
u366398972
|
cpp
|
p02929
|
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <math.h>
#include <queue>
using namespace std;
template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;
using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using vvvll = V<V<V<ll>>>;
using pll = P<ll, ll>;
using tpll = TP<ll, ll, ll>;
using vpll = V<pll>;
using vvpll = V<vpll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;
using vvch = V<vch>;
using dqll = deque<ll>;
using vdqll = V<dqll>;
using pqll = priority_queue<ll>;
using pqpll = priority_queue<pll>;
using vpqll = V<pqll>;
#define FOR(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define rFOR(i, a, b) for (ll i = (b); i > (ll)(a); i--)
#define oFOR(i, a, b) for (ll i = (a); i < (ll)(b); i += 2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn, (a).en)
#define REV(a) reverse((a).bgn, (a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a, b) __gcd(a, b)
#define co(a) cout << a << endl
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define ba back()
#define fr front()
#define pob pop_back()
#define pof pop_front()
#define mp make_pair
#define mt make_tuple
#define pbmp(a, b) push_back(mp(a, b))
#define subs(a, n) substr(a, n)
#define cfs(a) cout << fixed << setprecision(a) //
/*vvll v(n,vll(m)) n行m列 continue
A.erase(A.begin()+i); 配列Aのi番目を消せる
std::binary_search(v.bgn,v.en,a); 二分探索
abs(a,b) pow(a,n) to_string stoll
auto Iter=lower_bound(v.bgn,v.en,a); v[i]>=aとなる初のv[i]
v.insert(lower_bound(v.bgn,v.en,a),b); bを入れられる
lower upper co(*Iter) co(Iter-v.bgn) v[i]>=aとなる初のi
vvll v(100001,vll(0)); v[a].pb(b); v[b].pb(a);
pqll pq; pq.push(ai); pq.top(); pq.pop();
pqpll q; pll p; q.push(mp(ai,i)); p=q.top();
priority_queue<ll,vll,greater<ll>> pqg; 昇順
vdqll dq(3); dq[0].pb(1); dq[0].pb(2); dq[0].pf(0);
dq[0].fr→0 dq[0].ba→1 dq[0].pof; dq[0].fr→1
while(que.sz) while(!que.empty())
ll a=1,b=2,c=4,xo; xo=a^b^c; if(a^b^c==0)co(xo)→7(miss) if(xo==0)co(xo)→なし
a<<b→a*2^b a>>b→a/2^b
rep(i,1<<10)rep(j,10)if((i>>j)&1)→iの二進で1となる桁のjのみ
*/
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
#define comuse Comuse()
ll combi(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll pow_mod(ll a, ll n, ll mod) {
ll res = 1; // n=k_2 pow(a,k_2)
for (; n > 0; n /= 2) { // ex,pow(a,1011_2)=a^8*a^2*a^1
if (n % 2 == 1)
res = (res * a) % mod;
a = (a * a) % mod;
}
return res;
}
ll digit_sum(ll n) {
ll m = 0;
FOR(i, 0, 20) {
m += n % 10;
n /= 10;
if (n == 0)
break;
}
return m;
}
ll lcm(ll a, ll b) {
ll n;
n = a / gcd(a, b) * b;
return n;
}
int main() {
ll n;
cin >> n;
str s;
cin >> s;
str st;
FOR(i, 0, 2 * n) {
if (i % 2 == 0) {
if (s[i] == 'B') {
st += 'L';
} else {
st += 'R';
}
} else {
if (s[i] != 'B') {
st += 'L';
} else {
st += 'R';
}
}
}
ll c = 0, bns = 1;
FOR(i, 0, 2 * n) {
if (st[i] == 'L') {
c++;
} else {
bns *= c;
bns %= MOD;
c--;
}
}
if (bns < 0)
bns = 0;
comuse;
ll ans = bns * fac[n] % MOD;
co(ans);
}
|
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <math.h>
#include <queue>
using namespace std;
template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;
using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using vvvll = V<V<V<ll>>>;
using pll = P<ll, ll>;
using tpll = TP<ll, ll, ll>;
using vpll = V<pll>;
using vvpll = V<vpll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;
using vvch = V<vch>;
using dqll = deque<ll>;
using vdqll = V<dqll>;
using pqll = priority_queue<ll>;
using pqpll = priority_queue<pll>;
using vpqll = V<pqll>;
#define FOR(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define rFOR(i, a, b) for (ll i = (b); i > (ll)(a); i--)
#define oFOR(i, a, b) for (ll i = (a); i < (ll)(b); i += 2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn, (a).en)
#define REV(a) reverse((a).bgn, (a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a, b) __gcd(a, b)
#define co(a) cout << a << endl
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define ba back()
#define fr front()
#define pob pop_back()
#define pof pop_front()
#define mp make_pair
#define mt make_tuple
#define pbmp(a, b) push_back(mp(a, b))
#define subs(a, n) substr(a, n)
#define cfs(a) cout << fixed << setprecision(a) //
/*vvll v(n,vll(m)) n行m列 continue
A.erase(A.begin()+i); 配列Aのi番目を消せる
std::binary_search(v.bgn,v.en,a); 二分探索
abs(a,b) pow(a,n) to_string stoll
auto Iter=lower_bound(v.bgn,v.en,a); v[i]>=aとなる初のv[i]
v.insert(lower_bound(v.bgn,v.en,a),b); bを入れられる
lower upper co(*Iter) co(Iter-v.bgn) v[i]>=aとなる初のi
vvll v(100001,vll(0)); v[a].pb(b); v[b].pb(a);
pqll pq; pq.push(ai); pq.top(); pq.pop();
pqpll q; pll p; q.push(mp(ai,i)); p=q.top();
priority_queue<ll,vll,greater<ll>> pqg; 昇順
vdqll dq(3); dq[0].pb(1); dq[0].pb(2); dq[0].pf(0);
dq[0].fr→0 dq[0].ba→1 dq[0].pof; dq[0].fr→1
while(que.sz) while(!que.empty())
ll a=1,b=2,c=4,xo; xo=a^b^c; if(a^b^c==0)co(xo)→7(miss) if(xo==0)co(xo)→なし
a<<b→a*2^b a>>b→a/2^b
rep(i,1<<10)rep(j,10)if((i>>j)&1)→iの二進で1となる桁のjのみ
*/
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
#define comuse Comuse()
ll combi(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll pow_mod(ll a, ll n, ll mod) {
ll res = 1; // n=k_2 pow(a,k_2)
for (; n > 0; n /= 2) { // ex,pow(a,1011_2)=a^8*a^2*a^1
if (n % 2 == 1)
res = (res * a) % mod;
a = (a * a) % mod;
}
return res;
}
ll digit_sum(ll n) {
ll m = 0;
FOR(i, 0, 20) {
m += n % 10;
n /= 10;
if (n == 0)
break;
}
return m;
}
ll lcm(ll a, ll b) {
ll n;
n = a / gcd(a, b) * b;
return n;
}
int main() {
ll n;
cin >> n;
str s;
cin >> s;
str st;
FOR(i, 0, 2 * n) {
if (i % 2 == 0) {
if (s[i] == 'B') {
st += 'L';
} else {
st += 'R';
}
} else {
if (s[i] != 'B') {
st += 'L';
} else {
st += 'R';
}
}
}
ll c = 0, bns = 1;
FOR(i, 0, 2 * n) {
if (st[i] == 'L') {
c++;
} else {
bns *= c;
bns %= MOD;
c--;
}
}
if (bns < 0 || c != 0)
bns = 0;
comuse;
ll ans = bns * fac[n] % MOD;
co(ans);
}
|
[
"control_flow.branch.if.condition.change"
] | 732,179
| 732,180
|
u177143886
|
cpp
|
p02929
|
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using namespace std;
long long factorial[MAX] = {0}, finverse[MAX] = {0}, inverse[MAX] = {0};
void smodfact() {
factorial[0] = factorial[1] = 1;
finverse[0] = finverse[1] = 1;
inverse[1] = 1;
for (int i = 2; i < MAX; ++i) {
factorial[i] = factorial[i - 1] * i % N;
inverse[i] = N - (inverse[N % i] * (N / i)) % N;
finverse[i] = finverse[i - 1] * inverse[i] % N;
}
}
long long calccomb(long long n, long long k) {
if (n == k && n == 0)
return 1;
if (n < 0 || k < 0 || n < k)
return 0;
return factorial[n] * finverse[k] % N * finverse[n - k] % N;
}
long long n;
string s;
long long solve();
int main() {
cin >> n >> s;
cout << solve() << endl;
return 0;
}
long long solve() {
long long cnt = 1, ans = 1;
smodfact();
if (s[0] == 'W' || s[2 * n - 1] == 'W')
return 0;
ans = factorial[n];
for (int i = 1; i < 2 * n; ++i)
if (cnt % 2 == (s[i] == 'W'))
++cnt;
else
(ans *= cnt--) %= N;
assert(cnt == 0);
return ans;
}
|
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using namespace std;
long long factorial[MAX] = {0}, finverse[MAX] = {0}, inverse[MAX] = {0};
void smodfact() {
factorial[0] = factorial[1] = 1;
finverse[0] = finverse[1] = 1;
inverse[1] = 1;
for (int i = 2; i < MAX; ++i) {
factorial[i] = factorial[i - 1] * i % N;
inverse[i] = N - (inverse[N % i] * (N / i)) % N;
finverse[i] = finverse[i - 1] * inverse[i] % N;
}
}
long long calccomb(long long n, long long k) {
if (n == k && n == 0)
return 1;
if (n < 0 || k < 0 || n < k)
return 0;
return factorial[n] * finverse[k] % N * finverse[n - k] % N;
}
long long n;
string s;
long long solve();
int main() {
cin >> n >> s;
cout << solve() << endl;
return 0;
}
long long solve() {
long long cnt = 1, ans = 1;
smodfact();
if (s[0] == 'W' || s[2 * n - 1] == 'W')
return 0;
ans = factorial[n];
for (int i = 1; i < 2 * n; ++i)
if (cnt % 2 == (s[i] == 'W'))
++cnt;
else
(ans *= cnt--) %= N;
if (cnt != 0)
return 0;
return ans;
}
|
[
"misc.opposites",
"expression.operator.compare.change",
"call.arguments.change",
"expression.operation.binary.change",
"control_flow.return.add"
] | 732,206
| 732,207
|
u269963329
|
cpp
|
p02929
|
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int(i) = ((n)-1); (i) >= 0; (i)--)
#define itn int
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
long long kaijo(long long x) {
ll p = 1;
while (x != 0) {
p *= x;
p %= MOD;
x--;
}
return p;
}
signed main(void) {
int n;
cin >> n;
int s[2 * n];
rep(i, 2 * n) {
char a;
cin >> a;
if (a == 'W')
s[i] = 0;
else
s[i] = 1;
}
int c[2 * n + 1];
vector<int> res(2 * n);
int a = 0;
c[0] = 0;
rep(i, 2 * n) {
if ((a + s[i]) % 2) {
a++;
res[i] = 1;
} else {
a--;
res[i] = 0;
}
}
int ans = 0;
int cnt = 0;
ans = 1;
if (count(res.begin(), res.end(), 1) != count(res.begin(), res.end(), 0)) {
cout << 0 << endl;
return 0;
}
bool b = false;
rep(i, 2 * n) {
if (res[i])
b = true;
if (!res[i] && cnt != 0)
ans *= cnt;
if (b)
cnt += res[i] ? 1 : -1;
ans %= MOD;
}
cout << (ans * kaijo(n)) % MOD << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int(i) = ((n)-1); (i) >= 0; (i)--)
#define itn int
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
long long kaijo(long long x) {
ll p = 1;
while (x != 0) {
p *= x;
p %= MOD;
x--;
}
return p;
}
signed main(void) {
int n;
cin >> n;
int s[2 * n];
rep(i, 2 * n) {
char a;
cin >> a;
if (a == 'W')
s[i] = 0;
else
s[i] = 1;
}
int c[2 * n + 1];
vector<int> res(2 * n);
int a = 0;
c[0] = 0;
rep(i, 2 * n) {
if ((a + s[i]) % 2 && a >= 0) {
a++;
res[i] = 1;
} else {
a--;
res[i] = 0;
}
}
int ans = 0;
int cnt = 0;
ans = 1;
if (count(res.begin(), res.end(), 1) != count(res.begin(), res.end(), 0)) {
cout << 0 << endl;
return 0;
}
bool b = false;
rep(i, 2 * n) {
if (res[i])
b = true;
if (!res[i] && cnt != 0)
ans *= cnt;
if (b)
cnt += res[i] ? 1 : -1;
ans %= MOD;
}
cout << (ans * kaijo(n)) % MOD << endl;
}
|
[
"control_flow.branch.if.condition.change"
] | 732,212
| 732,213
|
u616029737
|
cpp
|
p02929
|
#include <bits/stdc++.h>
#define MODD 1000000007
using namespace std;
long long fac(int n) {
long long ans = 1;
for (int i = 2; i <= n; i++) {
ans = (ans * i) % MODD;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
string s;
cin >> n >> s;
int d[100005]; // 0 represents L, 1 represents R
int l[100005] = {0}, r[100005] = {0};
int len = s.size();
d[0] = 0;
for (int i = 1; i < len; i++) {
if (s[i] == s[i - 1])
d[i] = !d[i - 1];
else
d[i] = d[i - 1];
}
int cntL = 0, cntR = 0;
for (int i = 0; i < len; i++) {
if (d[i] == 0)
cntL++;
else
cntR++;
}
long long ans = 1;
if (cntL != cntR || s[0] == 'W' || s[n - 1] == 'W') {
ans = 0;
} else {
for (int i = 1; i < len; i++) {
if (d[i - 1] == 0) {
l[i] = l[i - 1] + 1;
r[i] = r[i - 1];
} else {
l[i] = l[i - 1];
r[i] = r[i - 1] + 1;
}
}
for (int i = 0; i < len; i++) {
if (d[i] == 1) {
ans = (ans * (l[i] - r[i])) % MODD;
}
}
ans = (ans * fac(n)) % MODD;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
#define MODD 1000000007
using namespace std;
long long fac(int n) {
long long ans = 1;
for (int i = 2; i <= n; i++) {
ans = (ans * i) % MODD;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
string s;
cin >> n >> s;
int d[200005]; // 0 represents L, 1 represents R
int l[200005] = {0}, r[200005] = {0}; // size should be 2N
int len = s.size();
d[0] = 0;
for (int i = 1; i < len; i++) {
if (s[i] == s[i - 1])
d[i] = !d[i - 1];
else
d[i] = d[i - 1];
}
int cntL = 0, cntR = 0;
for (int i = 0; i < len; i++) {
if (d[i] == 0)
cntL++;
else
cntR++;
}
long long ans = 1;
if (cntL != cntR || s[0] == 'W' || s[len - 1] == 'W') {
ans = 0;
} else {
for (int i = 1; i < len; i++) {
if (d[i - 1] == 0) {
l[i] = l[i - 1] + 1;
r[i] = r[i - 1];
} else {
l[i] = l[i - 1];
r[i] = r[i - 1] + 1;
}
}
for (int i = 0; i < len; i++) {
if (d[i] == 1) {
ans = (ans * (l[i] - r[i])) % MODD;
}
}
ans = (ans * fac(n)) % MODD;
}
cout << ans << endl;
return 0;
}
|
[
"literal.number.change",
"variable_declaration.array_dimensions.change",
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 732,220
| 732,219
|
u358689692
|
cpp
|
p02929
|
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rrep(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)
#define All(x) (x).begin(), (x).end()
#define rAll(x) (x).rbegin(), (x).rend()
#define ITR(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
constexpr ll mod = 1e9 + 7;
constexpr double eps = 1e-9;
void solve();
P bisearch(ll l, ll r, function<bool(ll)> f) {
while ((l + 1) < r) {
ll m = (l + r) / 2;
if (f(m))
r = m;
else
l = m;
}
return P(l, r);
}
ll SQRT(ll n) {
if (n == 1)
return 1;
return bisearch(0, n, [n](ll x) { return x > n / x; }).first;
}
ll roundup(ll n, ll div) {
if (n > 0)
return (n - 1) / div + 1;
else
return n / div;
}
bool square(ll a) {
ll n = SQRT(a);
return a == n * n;
}
ll npow(ll x, ll n) {
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x;
x = x * x;
n = n >> 1;
}
return ans;
}
ll mpow(ll x,
ll n) { // x^n(mod) ←普通にpow(x,n)では溢れてしまうため,随時mod計算
// 2分累乗法だから早い
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x % mod;
x = x * x % mod;
n = n >> 1;
}
return ans;
}
ll inv_mod(ll a) { return mpow(a, mod - 2); }
int digitsum(ll N, int a) {
if (N == 0)
return 0;
int ret = 0;
ret += digitsum(N / a, a) + N % a;
return ret;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }; // xとyの最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } // xとyの最小公倍数
void YN(bool flg) { std::cout << (flg ? "YES" : "NO") << endl; }
void Yn(bool flg) { std::cout << (flg ? "Yes" : "No") << endl; }
void yn(bool flg) { std::cout << (flg ? "yes" : "no") << endl; }
P splitint(string n, int a) {
int Len = n.length();
if (a < 0 || Len < a)
return {-1, -1};
string left, right;
if (a != 0)
left = n.substr(0, a);
if (a != Len)
right = n.substr(a);
return P(stoll(left), stoll(right));
}
ll manhattan(const P &a, const P &b) {
return llabs(a.first - b.first) + llabs(a.second - b.second);
}
bool kaibun(string s) { // O(|S|)
string sdash = s;
reverse(All(s));
return s == sdash;
}
class Ruiseki {
private:
vector<ll> LEFT, RIGHT;
function<ll(ll, ll)> F;
int N;
public:
Ruiseki(ll INI, const vector<ll> &a, function<ll(ll, ll)> f) {
N = a.size();
F = f;
LEFT.resize(N + 1);
RIGHT.resize(N + 1);
LEFT[0] = RIGHT[0] = INI;
REP(i, N) {
LEFT[i + 1] = F(LEFT[i], a[i]);
RIGHT[i + 1] = F(RIGHT[i], a[N - i - 1]);
}
}
ll out(int l, int r) { //[l,r)の外の累積
return F(LEFT[l], RIGHT[N - r]);
}
};
class mint {
private:
ll _num, _mod;
mint set(ll num) {
_num = num;
if (_num >= 0)
_num %= _mod;
else
_num += (1 - (_num + 1) / _mod) * _mod;
return *this;
}
ll imod(ll n) { return mpow(n, _mod - 2); }
public:
mint() {
_num = 0;
_mod = mod;
}
mint(ll num) {
_mod = mod;
_num = (num + (1LL << 25) * mod) % mod;
}
mint(ll num, ll M) {
_mod = M;
_num = (num + (1LL << 25) * mod) % _mod;
}
mint(const mint &cp) {
_num = cp._num;
_mod = cp._mod;
}
mint operator=(const ll x) { return set(x); }
mint operator+(const ll x) { return mint(_num + (x % _mod), _mod); }
mint operator-(const ll x) { return mint(_num - (x % _mod), _mod); }
mint operator*(const ll x) { return mint(_num * (x % _mod), _mod); }
mint operator/(ll x) { return mint(_num * imod(x), _mod); }
mint operator+=(const ll x) { return set(_num + (x % _mod)); }
mint operator-=(const ll x) { return set(_num - (x % _mod)); }
mint operator*=(const ll x) { return set(_num * (x % _mod)); }
mint operator/=(ll x) { return set(_num * imod(x)); }
mint operator+(const mint &x) { return mint(_num + x._num, _mod); }
mint operator-(const mint &x) { return mint(_num - x._num, _mod); }
mint operator*(const mint &x) { return mint(_num * x._num, _mod); }
mint operator/(mint x) { return mint(_num * imod(x._num), _mod); }
mint operator+=(const mint &x) { return set(_num + x._num); }
mint operator-=(const mint &x) { return set(_num - x._num); }
mint operator*=(const mint &x) { return set(_num * x._num); }
mint operator/=(mint x) { return set(_num * imod(x._num)); }
bool operator<(const mint &x) { return _num < x._num; }
friend mint operator+(ll x, const mint &m) {
return mint(m._num + (x % m._mod), m._mod);
}
friend mint operator-(ll x, const mint &m) {
return mint((x % m._mod) - m._num, m._mod);
}
friend mint operator*(ll x, const mint &m) {
return mint(m._num * (x % m._mod), m._mod);
}
friend mint operator/(ll x, mint m) {
return mint(m.imod(m._num) * x, m._mod);
}
explicit operator ll() { return _num; }
explicit operator int() { return (int)_num; }
friend ostream &operator<<(ostream &os, const mint &x) {
os << x._num;
return os;
}
friend istream &operator>>(istream &is, mint &x) {
ll val;
is >> val;
x.set(val);
return is;
}
};
template <typename T> class MAT {
private:
int row, col;
vector<vector<T>> _A;
MAT set(vector<vector<T>> A) {
_A = A;
return *this;
}
public:
MAT() {}
MAT(int n, int m) {
if (n < 1 || m < 0) {
cout << "err Matrix::Matrix" << endl;
exit(1);
}
row = n;
col = m ? m : n; // m=0のとき単位行列を作る
REP(i, row) {
vector<T> a(col, 0.0);
_A.push_back(a);
}
// 値の初期化
if (m == 0)
REP(i, n) _A[i][i] = 1.0;
}
MAT(const MAT &cp) {
_A = cp._A;
row = cp.row;
col = cp.col;
}
T *operator[](int i) { return _A[i].data(); }
MAT operator=(vector<vector<T>> x) { return set(x); }
MAT operator+(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator+" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j];
return r;
}
MAT operator-(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator-" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j];
return r;
}
MAT operator*(MAT x) {
if (col != x.row) {
cout << "err Matrix::operator*" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, x.col);
REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j];
return r;
}
MAT operator/(T a) {
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a;
return r;
}
MAT operator^(ll n) {
if (row != col) {
cout << "err Matrix::operator^" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, 0), A = *this;
while (n) {
if (n & 1)
r *= A;
A *= A;
n >>= 1;
}
return r;
}
MAT operator+=(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator+=" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j];
return set(r._A);
}
MAT operator-=(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator-=" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j];
return set(r._A);
}
MAT operator*=(MAT x) {
if (col != x.row) {
cout << "err Matrix::operator*" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, x.col);
REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j];
return set(r._A);
}
MAT operator/=(T a) {
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a;
return r;
}
friend MAT operator*(T n, MAT x) {
MAT r(x.row, x.col);
REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j];
return r;
}
friend MAT operator*(MAT x, T n) {
MAT r(x.row, x.col);
REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j];
return r;
}
explicit operator vector<vector<T>>() { return _A; }
friend ostream &operator<<(ostream &os, const MAT &x) {
REP(i, x.row) REP(j, x.col) os << x._A[i][j] << " \n"[j == x.col - 1];
return os;
}
friend istream &operator>>(istream &is, MAT &x) {
REP(i, x.row) REP(j, x.col) is >> x._A[i][j];
return is;
}
int size_row() { return row; }
int size_col() { return col; }
MAT transpose() {
MAT r(col, row);
REP(i, col) REP(j, row) r[i][j] = _A[j][i];
return r;
}
MAT inverse() {
T buf;
MAT<T> inv_a(row, 0);
vector<vector<T>> a = _A;
//掃き出し法
REP(i, row) {
buf = 1 / a[i][i];
REP(j, row) {
a[i][j] *= buf;
inv_a[i][j] *= buf;
}
REP(j, row) {
if (i != j) {
buf = a[j][i];
REP(k, row) {
a[j][k] -= a[i][k] * buf;
inv_a[j][k] -= inv_a[i][k] * buf;
}
}
}
}
return inv_a;
}
// O( n^3 ).
int rank() {
vector<vector<T>> A = _A;
const int n = row, m = col;
int r = 0;
for (int i = 0; r < n && i < m; ++i) {
int pivot = r;
for (int j = r + 1; j < n; ++j)
if (fabs(A[j][i]) > fabs(A[pivot][i]))
pivot = j;
swap(A[pivot], A[r]);
if (fabs(A[r][i]) < eps)
continue;
for (int k = m - 1; k >= i; --k)
A[r][k] /= A[r][i];
rep(j, r + 1, n) rep(k, i, m) A[j][k] -= A[r][k] * A[j][i];
++r;
}
return r;
}
};
class UnionFind { // UnionFind木
private:
vector<int> Parent;
vector<ll> diff_weight;
public:
UnionFind(int N) {
Parent.resize(N, -1);
diff_weight.resize(N, 0LL);
}
int root(int A) {
if (Parent[A] < 0)
return A;
else {
int r = root(Parent[A]);
diff_weight[A] += diff_weight[Parent[A]]; // 累積和をとる
return Parent[A] = r;
}
}
bool issame(int A, int B) { return root(A) == root(B); }
ll weight(int x) {
root(x); // 経路圧縮
return diff_weight[x];
}
ll diff(int x, int y) { return weight(y) - weight(x); }
int size(int A) { return -Parent[root(A)]; }
bool connect(int A, int B) {
A = root(A);
B = root(B);
if (A == B)
return false;
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
bool merge(int A, int B, ll w) {
// x と y それぞれについて、 root との重み差分を補正
w += weight(A);
w -= weight(B);
A = root(A);
B = root(B);
if (A == B)
return false;
if (size(A) < size(B))
swap(A, B), w = -w;
Parent[A] += Parent[B];
Parent[B] = A;
// x が y の親になるので、x と y の差分を diff_weight[y] に記録
diff_weight[B] = w;
return true;
}
};
class Factorial { //階乗とその逆元を求めて計算に利用するクラス
private:
vector<ll> fac;
vector<ll> ifac;
public:
Factorial(ll N) {
fac.push_back(1);
REP(i, N) fac.push_back(fac[i] * (i + 1) % mod);
ifac.resize(N + 1);
ifac[N] = inv_mod(fac[N]);
REP(i, N) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
}
ll fact(ll a) { return fac[a]; }
ll ifact(ll a) { return ifac[a]; }
ll cmb(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0 || b < 0)
return 0;
ll tmp = ifact(a - b) * ifact(b) % mod;
return tmp * fac[a] % mod;
}
ll per(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0 || b < 0)
return 0;
return fac[a] * ifac[a - b] % mod;
}
};
class SOSU {
private:
vector<ll> Prime_Number;
public:
SOSU(ll N) {
vector<bool> isp(N + 1, true);
isp[0] = isp[1] = false;
rep(i, 2, N + 1) {
if (isp[i]) {
Prime_Number.push_back(i);
for (int j = 2 * i; j <= N; j += i)
isp[j] = false;
}
}
}
ll operator[](int i) { return Prime_Number[i]; }
int size() { return Prime_Number.size(); }
ll back() { return Prime_Number.back(); }
bool isPrime(int q) { return binary_search(All(Prime_Number), q); }
};
class
Divisor { //素因数分解をしてから約数列挙、分解結果はP(底,指数)でpfacにまとめている
private:
vector<ll> F;
vector<P> pfactorize;
public:
Divisor(ll N) {
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0) {
F.push_back(i);
if (i * i != N)
F.push_back(N / i);
}
}
sort(begin(F), end(F));
SOSU p(SQRT(N) + 1);
REP(i, p.size()) {
pfactorize.push_back(P(p[i], 0));
while (N % p[i] == 0) {
N /= p[i];
pfactorize.back().second++;
}
if (pfactorize.size() == 0)
pfactorize.pop_back();
}
if (N > 1)
pfactorize.push_back(P(N, 1));
}
int size() { return F.size(); }
vector<P> pfac() { return pfactorize; }
ll operator[](int k) { return F[k]; }
};
struct Solutions {
ll napsack(int kinds, int MAX_W, const vl &weight, const vl &cost) {
vector<vector<ll>> dp(kinds + 1, vector<ll>(MAX_W + 1, 0));
REP(i, kinds) REP(j, MAX_W + 1) {
if (j < weight[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + cost[i]);
}
return dp[kinds][MAX_W];
}
ll cost_based_napsack(int kinds, int MAX_W, const vl &weight,
const vl &cost) {
int MAX_V = 0;
REP(i, kinds) MAX_V = max(MAX_V, (int)cost[i]);
vvl dp(kinds + 1, vl(kinds * MAX_V + 1, 1LL << 58));
dp[0][0] = 0;
REP(i, kinds) REP(j, kinds * MAX_V + 1) {
if (j < cost[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = min(dp[i][j], dp[i][j - cost[i]] + weight[i]);
}
int res = 0;
REP(i, kinds * MAX_V + 1) if (dp[kinds][i] <= MAX_W) res = i;
return res;
}
ll unlimited_napsack(int kinds, int MAX_W, const vl &weight, const vl &cost) {
vector<vector<ll>> dp(kinds + 1, vector<ll>(MAX_W + 1, 0));
REP(i, kinds) REP(j, MAX_W + 1) {
if (j < weight[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - weight[i]] + cost[i]);
}
return dp[kinds][MAX_W];
}
ll huge_napsack(int kinds, ll MAX_W, const vl &weight, const vl &cost) {
int n2 = kinds / 2;
vector<P> ps(1 << (kinds / 2));
REP(i, 1 << n2) {
ll sw = 0, sv = 0;
REP(j, n2) {
if (i >> j & 1) {
sw += weight[j];
sv += cost[j];
}
}
ps[i] = P(sw, sv);
}
sort(ps.begin(), ps.begin() + (1 << n2));
int m = 1;
rep(i, 1, 1 << n2) {
if (ps[m - 1].second < ps[i].second)
ps[m++] = ps[i];
}
ll res = 0;
REP(i, 1 << (kinds - n2)) {
ll sw = 0, sv = 0;
REP(j, kinds - n2) {
if ((i >> j) & 1) {
sw += weight[n2 + j];
sv += cost[n2 + j];
}
}
if (sw <= MAX_W) {
ll tv =
(lower_bound(ps.begin(), ps.begin() + m, P(MAX_W - sw, LLONG_MAX)) -
1)
->second;
res = max(res, sv + tv);
}
}
return res;
}
ll choose_MonN(int N, int M, const vl &cost) {
vvl dp(N + 1, vl(M + 1, -1LL << 58));
REP(i, N + 1) dp[i][0] = 0;
REP(i, N) REP(j, M) {
if (j > i)
break;
dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i][j] + cost[i]);
}
return dp[N][M];
}
ll Partition_Func(int n, int k) {
vector<vector<ll>> dp(k + 1, vector<ll>(n + 1, 0));
dp[0][0] = 1;
rep(i, 1, k + 1) REP(j, n + 1) {
if (j - i >= 0)
dp[i][j] = (dp[i][j - i] + dp[i - 1][j]);
else
dp[i][j] = dp[i - 1][j];
}
return dp[k][n];
}
int LCS(string s, string t) {
int n = s.length(), m = s.length();
vector<vector<int>> dp(n + 1, vector<int>(m + 1));
REP(i, n) REP(j, m) {
if (s[i] == t[j])
dp[i + 1][j + 1] = dp[i][j] + 1;
else
dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
}
return dp[n][m];
}
int LIS(const vector<ll> a) {
int n = a.size();
ll INF = 1 << 28;
vector<ll> dp(n + 1, INF);
REP(i, n) * lower_bound(All(dp), a[i]) = a[i];
int k = lower_bound(All(dp), INF) - dp.begin();
return k;
}
int max_flow(int s, int t, const vector<vector<P>> &g) {
struct edge_ {
int to, cap, rev;
};
vector<bool> used(g.size(), false);
vector<vector<edge_>> G(g.size());
REP(i, g.size()) REP(j, g[i].size()) {
int from = i, to = g[i][j].second;
int cap = g[i][j].first;
G[from].push_back((edge_){to, cap, (int)G[to].size()});
G[to].push_back((edge_){from, 0, (int)G[from].size() - 1});
}
auto dfs = [&](auto &&f, int v, int t, int fl) -> int {
if (v == t)
return fl;
used[v] = true;
REP(i, G[v].size()) {
edge_ &e = G[v][i];
if (!used[e.to] && e.cap > 0) {
int d = f(f, e.to, t, min(fl, e.cap));
if (d > 0) {
e.cap -= d;
G[e.to][e.rev].cap += d;
return d;
}
}
}
return 0;
};
int flow = 0;
while (1) {
used.assign(used.size(), false);
int f = dfs(dfs, s, t, INT_MAX);
if (f == 0)
return flow;
flow += f;
}
}
int bipartite_matching_calculate(const Graph &g) {
int V = g.size();
vi match(V, -1);
vector<bool> used(V, false);
auto dfs = [&](auto &&f, int v) -> bool {
used[v] = true;
REP(i, g[v].size()) {
int u = g[v][i], w = match[u];
if (w < 0 || !used[w] && f(f, w)) {
match[v] = u;
match[u] = v;
return true;
}
}
return false;
};
int res = 0;
REP(v, V) {
if (match[v] < 0) {
used.assign(V, false);
if (dfs(dfs, v))
res++;
}
}
return res;
}
int bipartite_matching(int l, int r, function<bool(int, int)> F) {
int V = l + r;
Graph G(V);
REP(i, l) REP(j, r) if (F(i, j)) {
G[i].push_back(l + j);
G[l + j].push_back(i);
}
return bipartite_matching_calculate(G);
}
};
struct compress {
map<ll, int> zip;
vector<ll> unzip;
compress(vector<ll> x) {
unzip = x;
sort(All(x));
x.erase(unique(All(x)), x.end());
REP(i, x.size()) { zip[x[i]] = i; }
}
int operator[](int k) { return zip[unzip[k]]; }
};
struct edge {
int from;
int to;
ll cost;
void push(int a, int b, int c) {
from = a;
to = b;
cost = c;
}
bool operator<(const edge &y) const {
if (cost != y.cost)
return cost < y.cost;
else if (to != y.to)
return to < y.to;
else
return from < y.from;
}
bool operator>(const edge &y) const {
if (cost != y.cost)
return cost > y.cost;
else if (to != y.to)
return to > y.to;
else
return from > y.from;
}
bool operator==(const edge &y) const { return *this == y; }
};
class lca {
public:
const int n = 0;
const int log2_n = 0;
std::vector<std::vector<int>> parent;
std::vector<int> depth;
lca() {}
lca(const Graph &g, int root)
: n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)),
depth(n) {
dfs(g, root, -1, 0);
for (int k = 0; k + 1 < log2_n; k++) {
for (int v = 0; v < (int)g.size(); v++) {
if (parent[k][v] < 0)
parent[k + 1][v] = -1;
else
parent[k + 1][v] = parent[k][parent[k][v]];
}
}
}
void dfs(const Graph &g, int v, int p, int d) {
parent[0][v] = p;
depth[v] = d;
REP(j, g[v].size()) {
if (g[v][j] != p)
dfs(g, g[v][j], v, d + 1);
}
}
int get(int u, int v) {
if (depth[u] > depth[v])
std::swap(u, v);
for (int k = 0; k < log2_n; k++) {
if ((depth[v] - depth[u]) >> k & 1) {
v = parent[k][v];
}
}
if (u == v)
return u;
for (int k = log2_n - 1; k >= 0; k--) {
if (parent[k][u] != parent[k][v]) {
u = parent[k][u];
v = parent[k][v];
}
}
return parent[0][u];
}
};
template <typename T, typename E> // SegmentTree((要素数) int n_,(演算) F
// f,(更新) G g,(初期値) T d1)
struct SegmentTree {
typedef function<T(T, T)> F;
typedef function<T(T, E)> G;
int n;
F f;
G g;
T d1;
E d0;
vector<T> dat;
SegmentTree(){};
SegmentTree(int n_, F f, G g, T d1, vector<T> v = vector<T>())
: f(f), g(g), d1(d1) {
init(n_);
if (n_ == (int)v.size())
build(n_, v);
}
void init(int n_) {
n = 1;
while (n < n_)
n *= 2;
dat.clear();
dat.resize(2 * n - 1, d1);
}
void build(int n_, vector<T> v) {
for (int i = 0; i < n_; i++)
dat[i + n - 1] = v[i];
for (int i = n - 2; i >= 0; i--)
dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
}
void update(int k, E a) {
k += n - 1;
dat[k] = g(dat[k], a);
while (k > 0) {
k = (k - 1) / 2;
dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
inline T query(int a, int b) {
T vl = d1, vr = d1;
for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
if (l & 1)
vl = f(vl, dat[(l++) - 1]);
if (r & 1)
vr = f(dat[(--r) - 1], vr);
}
return f(vl, vr);
}
};
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
solve();
return 0;
}
void solve() {
int N;
cin >> N;
string s;
cin >> s;
mint ans = Factorial(N).fact(N);
ll count = 0;
REP(i, 2 * N - 1) {
if (s[i] == 'B') {
if (count % 2 == 0)
count++;
else
ans *= count--;
}
if (s[i] == 'W') {
if (count % 2 == 0)
ans *= count--;
else
count++;
}
}
if (count > 0)
ans = 0;
cout << ans << endl;
}
|
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define rep(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rrep(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)
#define All(x) (x).begin(), (x).end()
#define rAll(x) (x).rbegin(), (x).rend()
#define ITR(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
constexpr ll mod = 1e9 + 7;
constexpr double eps = 1e-9;
void solve();
P bisearch(ll l, ll r, function<bool(ll)> f) {
while ((l + 1) < r) {
ll m = (l + r) / 2;
if (f(m))
r = m;
else
l = m;
}
return P(l, r);
}
ll SQRT(ll n) {
if (n == 1)
return 1;
return bisearch(0, n, [n](ll x) { return x > n / x; }).first;
}
ll roundup(ll n, ll div) {
if (n > 0)
return (n - 1) / div + 1;
else
return n / div;
}
bool square(ll a) {
ll n = SQRT(a);
return a == n * n;
}
ll npow(ll x, ll n) {
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x;
x = x * x;
n = n >> 1;
}
return ans;
}
ll mpow(ll x,
ll n) { // x^n(mod) ←普通にpow(x,n)では溢れてしまうため,随時mod計算
// 2分累乗法だから早い
ll ans = 1;
while (n != 0) {
if (n & 1)
ans = ans * x % mod;
x = x * x % mod;
n = n >> 1;
}
return ans;
}
ll inv_mod(ll a) { return mpow(a, mod - 2); }
int digitsum(ll N, int a) {
if (N == 0)
return 0;
int ret = 0;
ret += digitsum(N / a, a) + N % a;
return ret;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }; // xとyの最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } // xとyの最小公倍数
void YN(bool flg) { std::cout << (flg ? "YES" : "NO") << endl; }
void Yn(bool flg) { std::cout << (flg ? "Yes" : "No") << endl; }
void yn(bool flg) { std::cout << (flg ? "yes" : "no") << endl; }
P splitint(string n, int a) {
int Len = n.length();
if (a < 0 || Len < a)
return {-1, -1};
string left, right;
if (a != 0)
left = n.substr(0, a);
if (a != Len)
right = n.substr(a);
return P(stoll(left), stoll(right));
}
ll manhattan(const P &a, const P &b) {
return llabs(a.first - b.first) + llabs(a.second - b.second);
}
bool kaibun(string s) { // O(|S|)
string sdash = s;
reverse(All(s));
return s == sdash;
}
class Ruiseki {
private:
vector<ll> LEFT, RIGHT;
function<ll(ll, ll)> F;
int N;
public:
Ruiseki(ll INI, const vector<ll> &a, function<ll(ll, ll)> f) {
N = a.size();
F = f;
LEFT.resize(N + 1);
RIGHT.resize(N + 1);
LEFT[0] = RIGHT[0] = INI;
REP(i, N) {
LEFT[i + 1] = F(LEFT[i], a[i]);
RIGHT[i + 1] = F(RIGHT[i], a[N - i - 1]);
}
}
ll out(int l, int r) { //[l,r)の外の累積
return F(LEFT[l], RIGHT[N - r]);
}
};
class mint {
private:
ll _num, _mod;
mint set(ll num) {
_num = num;
if (_num >= 0)
_num %= _mod;
else
_num += (1 - (_num + 1) / _mod) * _mod;
return *this;
}
ll imod(ll n) { return mpow(n, _mod - 2); }
public:
mint() {
_num = 0;
_mod = mod;
}
mint(ll num) {
_mod = mod;
_num = (num + (1LL << 25) * mod) % mod;
}
mint(ll num, ll M) {
_mod = M;
_num = (num + (1LL << 25) * mod) % _mod;
}
mint(const mint &cp) {
_num = cp._num;
_mod = cp._mod;
}
mint operator=(const ll x) { return set(x); }
mint operator+(const ll x) { return mint(_num + (x % _mod), _mod); }
mint operator-(const ll x) { return mint(_num - (x % _mod), _mod); }
mint operator*(const ll x) { return mint(_num * (x % _mod), _mod); }
mint operator/(ll x) { return mint(_num * imod(x), _mod); }
mint operator+=(const ll x) { return set(_num + (x % _mod)); }
mint operator-=(const ll x) { return set(_num - (x % _mod)); }
mint operator*=(const ll x) { return set(_num * (x % _mod)); }
mint operator/=(ll x) { return set(_num * imod(x)); }
mint operator+(const mint &x) { return mint(_num + x._num, _mod); }
mint operator-(const mint &x) { return mint(_num - x._num, _mod); }
mint operator*(const mint &x) { return mint(_num * x._num, _mod); }
mint operator/(mint x) { return mint(_num * imod(x._num), _mod); }
mint operator+=(const mint &x) { return set(_num + x._num); }
mint operator-=(const mint &x) { return set(_num - x._num); }
mint operator*=(const mint &x) { return set(_num * x._num); }
mint operator/=(mint x) { return set(_num * imod(x._num)); }
bool operator<(const mint &x) { return _num < x._num; }
friend mint operator+(ll x, const mint &m) {
return mint(m._num + (x % m._mod), m._mod);
}
friend mint operator-(ll x, const mint &m) {
return mint((x % m._mod) - m._num, m._mod);
}
friend mint operator*(ll x, const mint &m) {
return mint(m._num * (x % m._mod), m._mod);
}
friend mint operator/(ll x, mint m) {
return mint(m.imod(m._num) * x, m._mod);
}
explicit operator ll() { return _num; }
explicit operator int() { return (int)_num; }
friend ostream &operator<<(ostream &os, const mint &x) {
os << x._num;
return os;
}
friend istream &operator>>(istream &is, mint &x) {
ll val;
is >> val;
x.set(val);
return is;
}
};
template <typename T> class MAT {
private:
int row, col;
vector<vector<T>> _A;
MAT set(vector<vector<T>> A) {
_A = A;
return *this;
}
public:
MAT() {}
MAT(int n, int m) {
if (n < 1 || m < 0) {
cout << "err Matrix::Matrix" << endl;
exit(1);
}
row = n;
col = m ? m : n; // m=0のとき単位行列を作る
REP(i, row) {
vector<T> a(col, 0.0);
_A.push_back(a);
}
// 値の初期化
if (m == 0)
REP(i, n) _A[i][i] = 1.0;
}
MAT(const MAT &cp) {
_A = cp._A;
row = cp.row;
col = cp.col;
}
T *operator[](int i) { return _A[i].data(); }
MAT operator=(vector<vector<T>> x) { return set(x); }
MAT operator+(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator+" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j];
return r;
}
MAT operator-(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator-" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j];
return r;
}
MAT operator*(MAT x) {
if (col != x.row) {
cout << "err Matrix::operator*" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, x.col);
REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j];
return r;
}
MAT operator/(T a) {
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a;
return r;
}
MAT operator^(ll n) {
if (row != col) {
cout << "err Matrix::operator^" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, 0), A = *this;
while (n) {
if (n & 1)
r *= A;
A *= A;
n >>= 1;
}
return r;
}
MAT operator+=(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator+=" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j];
return set(r._A);
}
MAT operator-=(MAT x) {
if (row != x.row || col != x.col) {
cout << "err Matrix::operator-=" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j];
return set(r._A);
}
MAT operator*=(MAT x) {
if (col != x.row) {
cout << "err Matrix::operator*" << endl;
cout << " not equal matrix size" << endl;
exit(0);
}
MAT r(row, x.col);
REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j];
return set(r._A);
}
MAT operator/=(T a) {
MAT r(row, col);
REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a;
return r;
}
friend MAT operator*(T n, MAT x) {
MAT r(x.row, x.col);
REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j];
return r;
}
friend MAT operator*(MAT x, T n) {
MAT r(x.row, x.col);
REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j];
return r;
}
explicit operator vector<vector<T>>() { return _A; }
friend ostream &operator<<(ostream &os, const MAT &x) {
REP(i, x.row) REP(j, x.col) os << x._A[i][j] << " \n"[j == x.col - 1];
return os;
}
friend istream &operator>>(istream &is, MAT &x) {
REP(i, x.row) REP(j, x.col) is >> x._A[i][j];
return is;
}
int size_row() { return row; }
int size_col() { return col; }
MAT transpose() {
MAT r(col, row);
REP(i, col) REP(j, row) r[i][j] = _A[j][i];
return r;
}
MAT inverse() {
T buf;
MAT<T> inv_a(row, 0);
vector<vector<T>> a = _A;
//掃き出し法
REP(i, row) {
buf = 1 / a[i][i];
REP(j, row) {
a[i][j] *= buf;
inv_a[i][j] *= buf;
}
REP(j, row) {
if (i != j) {
buf = a[j][i];
REP(k, row) {
a[j][k] -= a[i][k] * buf;
inv_a[j][k] -= inv_a[i][k] * buf;
}
}
}
}
return inv_a;
}
// O( n^3 ).
int rank() {
vector<vector<T>> A = _A;
const int n = row, m = col;
int r = 0;
for (int i = 0; r < n && i < m; ++i) {
int pivot = r;
for (int j = r + 1; j < n; ++j)
if (fabs(A[j][i]) > fabs(A[pivot][i]))
pivot = j;
swap(A[pivot], A[r]);
if (fabs(A[r][i]) < eps)
continue;
for (int k = m - 1; k >= i; --k)
A[r][k] /= A[r][i];
rep(j, r + 1, n) rep(k, i, m) A[j][k] -= A[r][k] * A[j][i];
++r;
}
return r;
}
};
class UnionFind { // UnionFind木
private:
vector<int> Parent;
vector<ll> diff_weight;
public:
UnionFind(int N) {
Parent.resize(N, -1);
diff_weight.resize(N, 0LL);
}
int root(int A) {
if (Parent[A] < 0)
return A;
else {
int r = root(Parent[A]);
diff_weight[A] += diff_weight[Parent[A]]; // 累積和をとる
return Parent[A] = r;
}
}
bool issame(int A, int B) { return root(A) == root(B); }
ll weight(int x) {
root(x); // 経路圧縮
return diff_weight[x];
}
ll diff(int x, int y) { return weight(y) - weight(x); }
int size(int A) { return -Parent[root(A)]; }
bool connect(int A, int B) {
A = root(A);
B = root(B);
if (A == B)
return false;
if (size(A) < size(B))
swap(A, B);
Parent[A] += Parent[B];
Parent[B] = A;
return true;
}
bool merge(int A, int B, ll w) {
// x と y それぞれについて、 root との重み差分を補正
w += weight(A);
w -= weight(B);
A = root(A);
B = root(B);
if (A == B)
return false;
if (size(A) < size(B))
swap(A, B), w = -w;
Parent[A] += Parent[B];
Parent[B] = A;
// x が y の親になるので、x と y の差分を diff_weight[y] に記録
diff_weight[B] = w;
return true;
}
};
class Factorial { //階乗とその逆元を求めて計算に利用するクラス
private:
vector<ll> fac;
vector<ll> ifac;
public:
Factorial(ll N) {
fac.push_back(1);
REP(i, N) fac.push_back(fac[i] * (i + 1) % mod);
ifac.resize(N + 1);
ifac[N] = inv_mod(fac[N]);
REP(i, N) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
}
ll fact(ll a) { return fac[a]; }
ll ifact(ll a) { return ifac[a]; }
ll cmb(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0 || b < 0)
return 0;
ll tmp = ifact(a - b) * ifact(b) % mod;
return tmp * fac[a] % mod;
}
ll per(ll a, ll b) {
if (a == 0 && b == 0)
return 1;
if (a < b || a < 0 || b < 0)
return 0;
return fac[a] * ifac[a - b] % mod;
}
};
class SOSU {
private:
vector<ll> Prime_Number;
public:
SOSU(ll N) {
vector<bool> isp(N + 1, true);
isp[0] = isp[1] = false;
rep(i, 2, N + 1) {
if (isp[i]) {
Prime_Number.push_back(i);
for (int j = 2 * i; j <= N; j += i)
isp[j] = false;
}
}
}
ll operator[](int i) { return Prime_Number[i]; }
int size() { return Prime_Number.size(); }
ll back() { return Prime_Number.back(); }
bool isPrime(int q) { return binary_search(All(Prime_Number), q); }
};
class
Divisor { //素因数分解をしてから約数列挙、分解結果はP(底,指数)でpfacにまとめている
private:
vector<ll> F;
vector<P> pfactorize;
public:
Divisor(ll N) {
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0) {
F.push_back(i);
if (i * i != N)
F.push_back(N / i);
}
}
sort(begin(F), end(F));
SOSU p(SQRT(N) + 1);
REP(i, p.size()) {
pfactorize.push_back(P(p[i], 0));
while (N % p[i] == 0) {
N /= p[i];
pfactorize.back().second++;
}
if (pfactorize.size() == 0)
pfactorize.pop_back();
}
if (N > 1)
pfactorize.push_back(P(N, 1));
}
int size() { return F.size(); }
vector<P> pfac() { return pfactorize; }
ll operator[](int k) { return F[k]; }
};
struct Solutions {
ll napsack(int kinds, int MAX_W, const vl &weight, const vl &cost) {
vector<vector<ll>> dp(kinds + 1, vector<ll>(MAX_W + 1, 0));
REP(i, kinds) REP(j, MAX_W + 1) {
if (j < weight[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + cost[i]);
}
return dp[kinds][MAX_W];
}
ll cost_based_napsack(int kinds, int MAX_W, const vl &weight,
const vl &cost) {
int MAX_V = 0;
REP(i, kinds) MAX_V = max(MAX_V, (int)cost[i]);
vvl dp(kinds + 1, vl(kinds * MAX_V + 1, 1LL << 58));
dp[0][0] = 0;
REP(i, kinds) REP(j, kinds * MAX_V + 1) {
if (j < cost[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = min(dp[i][j], dp[i][j - cost[i]] + weight[i]);
}
int res = 0;
REP(i, kinds * MAX_V + 1) if (dp[kinds][i] <= MAX_W) res = i;
return res;
}
ll unlimited_napsack(int kinds, int MAX_W, const vl &weight, const vl &cost) {
vector<vector<ll>> dp(kinds + 1, vector<ll>(MAX_W + 1, 0));
REP(i, kinds) REP(j, MAX_W + 1) {
if (j < weight[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - weight[i]] + cost[i]);
}
return dp[kinds][MAX_W];
}
ll huge_napsack(int kinds, ll MAX_W, const vl &weight, const vl &cost) {
int n2 = kinds / 2;
vector<P> ps(1 << (kinds / 2));
REP(i, 1 << n2) {
ll sw = 0, sv = 0;
REP(j, n2) {
if (i >> j & 1) {
sw += weight[j];
sv += cost[j];
}
}
ps[i] = P(sw, sv);
}
sort(ps.begin(), ps.begin() + (1 << n2));
int m = 1;
rep(i, 1, 1 << n2) {
if (ps[m - 1].second < ps[i].second)
ps[m++] = ps[i];
}
ll res = 0;
REP(i, 1 << (kinds - n2)) {
ll sw = 0, sv = 0;
REP(j, kinds - n2) {
if ((i >> j) & 1) {
sw += weight[n2 + j];
sv += cost[n2 + j];
}
}
if (sw <= MAX_W) {
ll tv =
(lower_bound(ps.begin(), ps.begin() + m, P(MAX_W - sw, LLONG_MAX)) -
1)
->second;
res = max(res, sv + tv);
}
}
return res;
}
ll choose_MonN(int N, int M, const vl &cost) {
vvl dp(N + 1, vl(M + 1, -1LL << 58));
REP(i, N + 1) dp[i][0] = 0;
REP(i, N) REP(j, M) {
if (j > i)
break;
dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i][j] + cost[i]);
}
return dp[N][M];
}
ll Partition_Func(int n, int k) {
vector<vector<ll>> dp(k + 1, vector<ll>(n + 1, 0));
dp[0][0] = 1;
rep(i, 1, k + 1) REP(j, n + 1) {
if (j - i >= 0)
dp[i][j] = (dp[i][j - i] + dp[i - 1][j]);
else
dp[i][j] = dp[i - 1][j];
}
return dp[k][n];
}
int LCS(string s, string t) {
int n = s.length(), m = s.length();
vector<vector<int>> dp(n + 1, vector<int>(m + 1));
REP(i, n) REP(j, m) {
if (s[i] == t[j])
dp[i + 1][j + 1] = dp[i][j] + 1;
else
dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
}
return dp[n][m];
}
int LIS(const vector<ll> a) {
int n = a.size();
ll INF = 1 << 28;
vector<ll> dp(n + 1, INF);
REP(i, n) * lower_bound(All(dp), a[i]) = a[i];
int k = lower_bound(All(dp), INF) - dp.begin();
return k;
}
int max_flow(int s, int t, const vector<vector<P>> &g) {
struct edge_ {
int to, cap, rev;
};
vector<bool> used(g.size(), false);
vector<vector<edge_>> G(g.size());
REP(i, g.size()) REP(j, g[i].size()) {
int from = i, to = g[i][j].second;
int cap = g[i][j].first;
G[from].push_back((edge_){to, cap, (int)G[to].size()});
G[to].push_back((edge_){from, 0, (int)G[from].size() - 1});
}
auto dfs = [&](auto &&f, int v, int t, int fl) -> int {
if (v == t)
return fl;
used[v] = true;
REP(i, G[v].size()) {
edge_ &e = G[v][i];
if (!used[e.to] && e.cap > 0) {
int d = f(f, e.to, t, min(fl, e.cap));
if (d > 0) {
e.cap -= d;
G[e.to][e.rev].cap += d;
return d;
}
}
}
return 0;
};
int flow = 0;
while (1) {
used.assign(used.size(), false);
int f = dfs(dfs, s, t, INT_MAX);
if (f == 0)
return flow;
flow += f;
}
}
int bipartite_matching_calculate(const Graph &g) {
int V = g.size();
vi match(V, -1);
vector<bool> used(V, false);
auto dfs = [&](auto &&f, int v) -> bool {
used[v] = true;
REP(i, g[v].size()) {
int u = g[v][i], w = match[u];
if (w < 0 || !used[w] && f(f, w)) {
match[v] = u;
match[u] = v;
return true;
}
}
return false;
};
int res = 0;
REP(v, V) {
if (match[v] < 0) {
used.assign(V, false);
if (dfs(dfs, v))
res++;
}
}
return res;
}
int bipartite_matching(int l, int r, function<bool(int, int)> F) {
int V = l + r;
Graph G(V);
REP(i, l) REP(j, r) if (F(i, j)) {
G[i].push_back(l + j);
G[l + j].push_back(i);
}
return bipartite_matching_calculate(G);
}
};
struct compress {
map<ll, int> zip;
vector<ll> unzip;
compress(vector<ll> x) {
unzip = x;
sort(All(x));
x.erase(unique(All(x)), x.end());
REP(i, x.size()) { zip[x[i]] = i; }
}
int operator[](int k) { return zip[unzip[k]]; }
};
struct edge {
int from;
int to;
ll cost;
void push(int a, int b, int c) {
from = a;
to = b;
cost = c;
}
bool operator<(const edge &y) const {
if (cost != y.cost)
return cost < y.cost;
else if (to != y.to)
return to < y.to;
else
return from < y.from;
}
bool operator>(const edge &y) const {
if (cost != y.cost)
return cost > y.cost;
else if (to != y.to)
return to > y.to;
else
return from > y.from;
}
bool operator==(const edge &y) const { return *this == y; }
};
class lca {
public:
const int n = 0;
const int log2_n = 0;
std::vector<std::vector<int>> parent;
std::vector<int> depth;
lca() {}
lca(const Graph &g, int root)
: n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)),
depth(n) {
dfs(g, root, -1, 0);
for (int k = 0; k + 1 < log2_n; k++) {
for (int v = 0; v < (int)g.size(); v++) {
if (parent[k][v] < 0)
parent[k + 1][v] = -1;
else
parent[k + 1][v] = parent[k][parent[k][v]];
}
}
}
void dfs(const Graph &g, int v, int p, int d) {
parent[0][v] = p;
depth[v] = d;
REP(j, g[v].size()) {
if (g[v][j] != p)
dfs(g, g[v][j], v, d + 1);
}
}
int get(int u, int v) {
if (depth[u] > depth[v])
std::swap(u, v);
for (int k = 0; k < log2_n; k++) {
if ((depth[v] - depth[u]) >> k & 1) {
v = parent[k][v];
}
}
if (u == v)
return u;
for (int k = log2_n - 1; k >= 0; k--) {
if (parent[k][u] != parent[k][v]) {
u = parent[k][u];
v = parent[k][v];
}
}
return parent[0][u];
}
};
template <typename T, typename E> // SegmentTree((要素数) int n_,(演算) F
// f,(更新) G g,(初期値) T d1)
struct SegmentTree {
typedef function<T(T, T)> F;
typedef function<T(T, E)> G;
int n;
F f;
G g;
T d1;
E d0;
vector<T> dat;
SegmentTree(){};
SegmentTree(int n_, F f, G g, T d1, vector<T> v = vector<T>())
: f(f), g(g), d1(d1) {
init(n_);
if (n_ == (int)v.size())
build(n_, v);
}
void init(int n_) {
n = 1;
while (n < n_)
n *= 2;
dat.clear();
dat.resize(2 * n - 1, d1);
}
void build(int n_, vector<T> v) {
for (int i = 0; i < n_; i++)
dat[i + n - 1] = v[i];
for (int i = n - 2; i >= 0; i--)
dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
}
void update(int k, E a) {
k += n - 1;
dat[k] = g(dat[k], a);
while (k > 0) {
k = (k - 1) / 2;
dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
inline T query(int a, int b) {
T vl = d1, vr = d1;
for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
if (l & 1)
vl = f(vl, dat[(l++) - 1]);
if (r & 1)
vr = f(dat[(--r) - 1], vr);
}
return f(vl, vr);
}
};
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
solve();
return 0;
}
void solve() {
int N;
cin >> N;
string s;
cin >> s;
mint ans = Factorial(N).fact(N);
ll count = 0;
REP(i, 2 * N) {
if (s[i] == 'B') {
if (count % 2 == 0)
count++;
else
ans *= count--;
}
if (s[i] == 'W') {
if (count % 2 == 0)
ans *= count--;
else
count++;
}
}
if (count > 0)
ans = 0;
cout << ans << endl;
}
|
[
"expression.operation.binary.remove"
] | 732,221
| 732,222
|
u203033720
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> x;
x.resize(n);
vector<int> y;
y.resize(n);
vector<pair<long double, int>> p;
p.resize(n);
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
p[i] = {atan2(y[i], x[i]), i};
}
sort(p.begin(), p.end());
long double ans = 0;
for (int i = 0; i < n; ++i) {
long double sx = 0;
long double sy = 0;
for (int j = i; j < n; ++j) {
sx += x[p[j].second];
sy += y[p[j].second];
ans = max(ans, sqrt(sx * sx + sy * sy));
}
}
cout << fixed << setprecision(10);
cout << ans << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> x;
x.resize(n);
vector<int> y;
y.resize(n);
vector<pair<long double, int>> p;
p.resize(n);
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
p[i] = {atan2(y[i], x[i]), i};
}
sort(p.begin(), p.end());
long double ans = 0;
for (int i = 0; i < n; ++i) {
long double sx = 0;
long double sy = 0;
for (int j = i; j < n + i; ++j) {
sx += x[p[j % n].second];
sy += y[p[j % n].second];
ans = max(ans, sqrt(sx * sx + sy * sy));
}
}
cout << fixed << setprecision(10);
cout << ans << '\n';
return 0;
}
|
[
"control_flow.loop.for.condition.change",
"assignment.change"
] | 732,223
| 732,224
|
u639210885
|
cpp
|
p02926
|
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef double ld;
ld PI = acos(-1), EPS = 1e-15, a[100], b[100];
ld n, ans, A, B, L;
int main(void) {
cin >> n;
// cout<<PI<<endl;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i];
for (int i = 0; i < 360; i++) {
A = 0, B = 0;
L = (ld)((ld)i / 180);
// cout<<L<<endl;
for (int j = 0; j < n; j++) {
if (a[j] * cos(PI * L) + b[j] * cos(PI * L) > 0) {
A += a[j], B += b[j];
}
}
ans = max(ans, A * A + B * B);
}
cout << setprecision(20) << pow(ans, 0.5) << endl;
}
|
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef double ld;
ld PI = acos(-1), EPS = 1e-15, a[100], b[100];
ld n, ans, A, B, L;
int main(void) {
cin >> n;
// cout<<PI<<endl;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i];
for (int i = 0; i < 360; i++) {
A = 0, B = 0;
L = (ld)((ld)i / 180);
// cout<<L<<endl;
for (int j = 0; j < n; j++) {
if (a[j] * cos(PI * L) + b[j] * sin(PI * L) > 0) {
A += a[j], B += b[j];
}
}
ans = max(ans, A * A + B * B);
}
cout << setprecision(20) << pow(ans, 0.5) << endl;
}
|
[
"identifier.change",
"call.function.change",
"control_flow.branch.if.condition.change"
] | 732,225
| 732,226
|
u050428930
|
cpp
|
p02926
|
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef double ld;
ld PI = 2 * acos(-1), EPS = 1e-15, a[100], b[100];
ld n, ans, A, B, L;
int main(void) {
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i];
for (int i = 0; i < 360; i++) {
A = 0, B = 0;
L = (ld)((ld)i / 360);
// cout<<L<<endl;
for (int j = 0; j < n; j++) {
if (a[j] * cos(PI * L) + b[j] * cos(PI * L) > 0) {
A += a[j], B += b[j];
}
}
ans = max(ans, A * A + B * B);
}
cout << setprecision(20) << pow(ans, 0.5) << endl;
}
|
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef double ld;
ld PI = acos(-1), EPS = 1e-15, a[100], b[100];
ld n, ans, A, B, L;
int main(void) {
cin >> n;
// cout<<PI<<endl;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i];
for (int i = 0; i < 360; i++) {
A = 0, B = 0;
L = (ld)((ld)i / 180);
// cout<<L<<endl;
for (int j = 0; j < n; j++) {
if (a[j] * cos(PI * L) + b[j] * sin(PI * L) > 0) {
A += a[j], B += b[j];
}
}
ans = max(ans, A * A + B * B);
}
cout << setprecision(20) << pow(ans, 0.5) << endl;
}
|
[
"expression.operation.binary.remove",
"literal.number.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change",
"identifier.change",
"call.function.change",
"control_flow.branch.if.condition.change"
] | 732,227
| 732,226
|
u050428930
|
cpp
|
p02926
|
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long double ld;
ld n, s[100], t[100], x, y, ans;
int main(void) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s[i] >> t[i];
}
for (int i = 0; i < 360; i++) {
x = 0.0, y = 0.0;
for (int j = 0; j < n; j++) {
if (cos(i * M_PI / 360) * s[j] + sin(i * M_PI / 360) * t[j] > 0) {
x += s[j], y += t[j];
}
}
ans = max(ans, x * x + y * y);
}
cout << setprecision(15) << sqrt(ans) << endl;
}
|
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long double ld;
ld n, s[100], t[100], x, y, ans;
int main(void) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s[i] >> t[i];
}
for (int i = 0; i < 360; i++) {
x = 0.0, y = 0.0;
for (int j = 0; j < n; j++) {
if (cos(i * M_PI / 180) * s[j] + sin(i * M_PI / 180) * t[j] > 0) {
x += s[j], y += t[j];
}
}
ans = max(ans, x * x + y * y);
}
cout << setprecision(15) << sqrt(ans) << endl;
}
|
[
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 732,228
| 732,229
|
u050428930
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"
const i64 MOD = 998244353;
int main() {
i64 N;
cin >> N;
vector<pair<i64, i64>> xy(N);
for (i64 i = 0; i < N; i++)
cin >> xy[i].first >> xy[i].second;
sort(xy.begin(), xy.end(),
[](const pair<i64, i64> &l, const pair<i64, i64> &r) {
return atan2(l.second, l.first) < atan2(r.second, r.first);
});
i64 ans = 0;
for (i64 i = 0; i < N; i++)
for (i64 j = 0; j < N; j++) {
i64 x = 0, y = 0;
for (i64 k = 0; k < j - i + 1; k++) {
x += xy[(i + k) % N].first;
y += xy[(i + k) % N].second;
}
ans = max(ans, x * x + y * y);
}
cout << fixed << setprecision(11) << sqrt(ans) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"
const i64 MOD = 998244353;
int main() {
i64 N;
cin >> N;
vector<pair<i64, i64>> xy(N);
for (i64 i = 0; i < N; i++)
cin >> xy[i].first >> xy[i].second;
sort(xy.begin(), xy.end(),
[](const pair<i64, i64> &l, const pair<i64, i64> &r) {
return atan2(l.second, l.first) < atan2(r.second, r.first);
});
i64 ans = 0;
for (i64 i = 0; i < N; i++)
for (i64 j = 1; j <= N; j++) {
i64 x = 0, y = 0;
for (i64 k = 0; k < j; k++) {
x += xy[(i + k) % N].first;
y += xy[(i + k) % N].second;
}
ans = max(ans, x * x + y * y);
}
cout << fixed << setprecision(11) << sqrt(ans) << endl;
return 0;
}
|
[
"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",
"expression.operation.binary.remove"
] | 732,237
| 732,238
|
u623115612
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
struct ST {
double x, y, arg;
ST(double x, double y, double arg) : x(x), y(y), arg(arg) {}
};
bool operator<(const ST &a, const ST &b) { return a.arg < b.arg; }
int main() {
int N;
cin >> N;
vector<ST> v;
rep(i, N) {
int a, b;
cin >> a >> b;
if (a == 0 && b == 0) {
v.emplace_back((double)a, (double)b, 0);
} else {
v.emplace_back((double)a, (double)b, atan2(b, a));
}
}
sort(ALLOF(v));
// rep(i,N){
// cout << " " << v[i].x << " " << v[i].y << " " << v[i].arg << endl;
//}
vector<ST> w;
rep(i, N) { w.push_back(v[i]); }
rep(i, N) { w.push_back(v[i]); }
double ret = 0.0;
rep(i, w.size()) {
double sumx = 0, sumy = 0;
REP(j, i, i + N + 1) {
sumx += w[j].x;
sumy += w[j].y;
ret = max(ret, sqrt(sumx * sumx + sumy * sumy));
}
}
printf("%.12lf\n", ret);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
struct ST {
double x, y, arg;
ST(double x, double y, double arg) : x(x), y(y), arg(arg) {}
};
bool operator<(const ST &a, const ST &b) { return a.arg < b.arg; }
int main() {
int N;
cin >> N;
vector<ST> v;
rep(i, N) {
int a, b;
cin >> a >> b;
if (a == 0 && b == 0) {
v.emplace_back((double)a, (double)b, 0);
} else {
v.emplace_back((double)a, (double)b, atan2(b, a));
}
}
sort(ALLOF(v));
// rep(i,N){
// cout << " " << v[i].x << " " << v[i].y << " " << v[i].arg << endl;
//}
vector<ST> w;
rep(i, N) { w.push_back(v[i]); }
rep(i, N) { w.push_back(v[i]); }
double ret = 0.0;
rep(i, w.size()) {
double sumx = 0, sumy = 0;
REP(j, i, i + N) {
sumx += w[j].x;
sumy += w[j].y;
ret = max(ret, sqrt(sumx * sumx + sumy * sumy));
}
}
printf("%.12lf\n", ret);
return 0;
}
|
[
"expression.operation.binary.remove"
] | 732,245
| 732,246
|
u624678037
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
struct ST {
double x, y, arg;
ST(double x, double y, double arg) : x(x), y(y), arg(arg) {}
};
bool operator<(const ST &a, const ST &b) { return a.arg < b.arg; }
int main() {
int N;
cin >> N;
vector<ST> v;
rep(i, N) {
int a, b;
cin >> a >> b;
if (a == 0 && b == 0) {
v.emplace_back((double)a, (double)b, 0);
} else {
v.emplace_back((double)a, (double)b, atan2(b, a));
}
}
sort(ALLOF(v));
// rep(i,N){
// cout << " " << v[i].x << " " << v[i].y << " " << v[i].arg << endl;
//}
vector<ST> w;
rep(i, N) { w.push_back(v[i]); }
rep(i, N) { w.push_back(v[i]); }
double ret = 0.0;
rep(i, w.size()) {
rep(j, N) {
double sumx = 0, sumy = 0;
REP(k, i, i + j) {
sumx += w[k].x;
sumy += w[k].y;
}
ret = max(ret, sqrt(sumx * sumx + sumy * sumy));
}
}
printf("%.12lf\n", ret);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
struct ST {
double x, y, arg;
ST(double x, double y, double arg) : x(x), y(y), arg(arg) {}
};
bool operator<(const ST &a, const ST &b) { return a.arg < b.arg; }
int main() {
int N;
cin >> N;
vector<ST> v;
rep(i, N) {
int a, b;
cin >> a >> b;
if (a == 0 && b == 0) {
v.emplace_back((double)a, (double)b, 0);
} else {
v.emplace_back((double)a, (double)b, atan2(b, a));
}
}
sort(ALLOF(v));
// rep(i,N){
// cout << " " << v[i].x << " " << v[i].y << " " << v[i].arg << endl;
//}
vector<ST> w;
rep(i, N) { w.push_back(v[i]); }
rep(i, N) { w.push_back(v[i]); }
double ret = 0.0;
rep(i, w.size()) {
rep(j, N) {
double sumx = 0, sumy = 0;
REP(k, i, i + 1 + j) {
sumx += w[k].x;
sumy += w[k].y;
}
ret = max(ret, sqrt(sumx * sumx + sumy * sumy));
}
}
printf("%.12lf\n", ret);
return 0;
}
|
[
"expression.operation.binary.add"
] | 732,247
| 732,248
|
u624678037
|
cpp
|
p02926
|
#include <iostream>
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <deque>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll, ll> P;
typedef map<ll, ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define each(x, c) for (auto x : (c))
#define LB(x, a) lower_bound(all(x), a)
#define UB(x, a) upper_bound(all(x), a)
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1.0e-10;
const ld PI = M_PI;
int main() {
int N;
cin >> N;
vector<pair<ld, int>> arg;
vector<ld> x(N), y(N);
rep(i, N) {
cin >> x[i] >> y[i];
arg.pb({atan2(y[i], x[i]), i});
arg.pb({atan2(y[i], x[i]) + 2.0 * PI, i});
}
sort(all(arg));
vector<ld> Theta(2 * N), Sx(2 * N + 1), Sy(2 * N + 1);
Sx[0] = Sy[0] = 0.0;
rep(i, 2 * N) {
Theta[i] = arg[i].st;
Sx[i + 1] = Sx[i] + x[arg[i].nd];
Sy[i + 1] = Sy[i] + y[arg[i].nd];
}
ld ans = 0.0;
rep(i, N) {
FOR(j, i, 2 * N) {
ans = max(ans, (ld)sqrt((Sx[j + 1] - Sx[i]) * (Sx[j + 1] - Sx[i]) +
(Sy[j + 1] - Sy[i]) * (Sy[j + 1] - Sy[i])));
}
}
printf("%.15Lf\n", ans);
return 0;
}
|
#include <iostream>
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <deque>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll, ll> P;
typedef map<ll, ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define each(x, c) for (auto x : (c))
#define LB(x, a) lower_bound(all(x), a)
#define UB(x, a) upper_bound(all(x), a)
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1.0e-10;
const ld PI = M_PI;
int main() {
int N;
cin >> N;
vector<pair<ld, int>> arg;
vector<ld> x(N), y(N);
rep(i, N) {
cin >> x[i] >> y[i];
arg.pb({atan2(y[i], x[i]), i});
arg.pb({atan2(y[i], x[i]) + 2.0 * PI, i});
}
sort(all(arg));
vector<ld> Theta(2 * N), Sx(2 * N + 1), Sy(2 * N + 1);
Sx[0] = Sy[0] = 0.0;
rep(i, 2 * N) {
Theta[i] = arg[i].st;
Sx[i + 1] = Sx[i] + x[arg[i].nd];
Sy[i + 1] = Sy[i] + y[arg[i].nd];
}
ld ans = 0.0;
rep(i, N) {
FOR(j, i, i + N) {
ans = max(ans, (ld)sqrt((Sx[j + 1] - Sx[i]) * (Sx[j + 1] - Sx[i]) +
(Sy[j + 1] - Sy[i]) * (Sy[j + 1] - Sy[i])));
}
}
printf("%.15Lf\n", ans);
return 0;
}
|
[] | 732,249
| 732,250
|
u215268883
|
cpp
|
p02926
|
#include <bits/stdc++.h>
#define MAX_N 200001
#define mod 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REV(i, n) for (ll i = n - 1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;
pair<double, P> rxy[MAX_N];
double deg(ll x, ll y) {
if (x == 0 && y == 0)
return 0;
return atan2(y, x) * 180 / M_PI;
}
signed main() {
cin >> n;
REP(i, n) cin >> rxy[i].second.first >> rxy[i].second.second;
REP(i, n) {
ll x, y;
x = rxy[i].second.first;
y = rxy[i].second.second;
rxy[i].first = deg(x, y);
// cout << x << " " << y << " " << rxy[i].first << endl;
}
sort(rxy, rxy + n);
// REP(i, n) cout << rxy[i].first << " " << rxy[i].second.first << " " <<
// rxy[i].second.first << endl;
P ret_xy = P(0, 0);
double ret = 0;
REP(i, n) {
REP(j, n) {
REP(k, n) {
if (i <= k && k <= j) {
ret_xy.first += rxy[k].second.first;
ret_xy.second += rxy[k].second.second;
}
}
ret = max(ret, sqrt(ret_xy.first * ret_xy.first +
ret_xy.second * ret_xy.second));
ret_xy = P(0, 0);
REP(k, n) {
if (k <= i && j <= k) {
ret_xy.first += rxy[k].second.first;
ret_xy.second += rxy[k].second.second;
}
}
ret = max(ret, sqrt(ret_xy.first * ret_xy.first +
ret_xy.second * ret_xy.second));
ret_xy = P(0, 0);
}
}
cout << setprecision(20) << ret << endl;
return 0;
}
|
#include <bits/stdc++.h>
#define MAX_N 200001
#define mod 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REV(i, n) for (ll i = n - 1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;
pair<double, P> rxy[MAX_N];
double deg(ll x, ll y) {
if (x == 0 && y == 0)
return 0;
return atan2(y, x) * 180 / M_PI;
}
signed main() {
cin >> n;
REP(i, n) cin >> rxy[i].second.first >> rxy[i].second.second;
REP(i, n) {
ll x, y;
x = rxy[i].second.first;
y = rxy[i].second.second;
rxy[i].first = deg(x, y);
// cout << x << " " << y << " " << rxy[i].first << endl;
}
sort(rxy, rxy + n);
// REP(i, n) cout << rxy[i].first << " " << rxy[i].second.first << " " <<
// rxy[i].second.first << endl;
P ret_xy = P(0, 0);
double ret = 0;
REP(i, n) {
REP(j, n) {
REP(k, n) {
if (i <= k && k <= j) {
ret_xy.first += rxy[k].second.first;
ret_xy.second += rxy[k].second.second;
}
}
ret = max(ret, sqrt(ret_xy.first * ret_xy.first +
ret_xy.second * ret_xy.second));
ret_xy = P(0, 0);
REP(k, n) {
if (k <= i || j <= k) {
ret_xy.first += rxy[k].second.first;
ret_xy.second += rxy[k].second.second;
}
}
ret = max(ret, sqrt(ret_xy.first * ret_xy.first +
ret_xy.second * ret_xy.second));
ret_xy = P(0, 0);
}
}
cout << setprecision(20) << ret << endl;
return 0;
}
|
[
"misc.opposites",
"control_flow.branch.if.condition.change"
] | 732,254
| 732,255
|
u876442898
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"
template <typename T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename T> ostream &operator<<(ostream &s, const complex<T> &d) {
return s << "(" << d.real() << ", " << d.imag() << ")";
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &d) {
return s << "(" << d.first << ", " << d.second << ")";
}
template <typename T> ostream &operator<<(ostream &s, const vector<T> &d) {
int len = d.size();
rep(i, len) {
s << d[i];
if (i < len - 1)
s << " ";
}
return s;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<vector<T>> &d) {
int len = d.size();
rep(i, len) { s << d[i] << endl; }
return s;
}
template <typename T> ostream &operator<<(ostream &s, const set<T> &v) {
s << "{ ";
for (auto itr = v.begin(); itr != v.end(); ++itr) {
if (itr != v.begin()) {
s << ", ";
}
s << (*itr);
}
s << " }";
return s;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const map<T1, T2> &m) {
s << "{" << endl;
for (auto itr = m.begin(); itr != m.end(); ++itr) {
s << " " << (*itr).first << " : " << (*itr).second << endl;
}
s << "}" << endl;
return s;
}
const ll mod = 1e9 + 7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
const double EPS = 1e-10;
struct v {
double x, y, ang;
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<v> p(n);
rep(i, n) {
cin >> p[i].x >> p[i].y;
p[i].ang = atan2(p[i].y, p[i].x);
}
double ans = 0;
sort(begin(p), end(p), [](const v &a, const v &b) { return a.ang < b.ang; });
vector<double> angle(2 * n);
rep(i, n) {
angle[i] = p[i].ang;
angle[i + n] = p[i].ang + 2 * PI;
}
rep(i, n) FOR(j, i, n) {
if (angle[j] - angle[i] > PI + EPS)
break;
double nx = 0, ny = 0;
FOR(k, i, j + 1) {
nx += p[k].x;
ny += p[k].y;
}
chmax(ans, nx * nx + ny * ny);
}
cout << setprecision(15) << sqrt(ans) << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"
template <typename T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename T> ostream &operator<<(ostream &s, const complex<T> &d) {
return s << "(" << d.real() << ", " << d.imag() << ")";
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &d) {
return s << "(" << d.first << ", " << d.second << ")";
}
template <typename T> ostream &operator<<(ostream &s, const vector<T> &d) {
int len = d.size();
rep(i, len) {
s << d[i];
if (i < len - 1)
s << " ";
}
return s;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<vector<T>> &d) {
int len = d.size();
rep(i, len) { s << d[i] << endl; }
return s;
}
template <typename T> ostream &operator<<(ostream &s, const set<T> &v) {
s << "{ ";
for (auto itr = v.begin(); itr != v.end(); ++itr) {
if (itr != v.begin()) {
s << ", ";
}
s << (*itr);
}
s << " }";
return s;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const map<T1, T2> &m) {
s << "{" << endl;
for (auto itr = m.begin(); itr != m.end(); ++itr) {
s << " " << (*itr).first << " : " << (*itr).second << endl;
}
s << "}" << endl;
return s;
}
const ll mod = 1e9 + 7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
const double EPS = 1e-10;
struct v {
double x, y, ang;
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<v> p(n);
rep(i, n) {
cin >> p[i].x >> p[i].y;
p[i].ang = atan2(p[i].y, p[i].x);
}
double ans = 0;
sort(begin(p), end(p), [](const v &a, const v &b) { return a.ang < b.ang; });
vector<double> angle(2 * n);
rep(i, n) {
angle[i] = p[i].ang;
angle[i + n] = p[i].ang + 2 * PI;
}
rep(i, n) FOR(j, i, 2 * n) {
if (angle[j] - angle[i] > PI + EPS)
break;
double nx = 0, ny = 0;
FOR(k, i, j + 1) {
nx += p[k % n].x;
ny += p[k % n].y;
}
chmax(ans, nx * nx + ny * ny);
}
cout << setprecision(15) << sqrt(ans) << endl;
}
|
[
"assignment.change"
] | 732,256
| 732,257
|
u340010271
|
cpp
|
p02926
|
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int N;
long double x[100], y[100];
pair<long double, pair<long double, long double>> a[200];
signed main() {
cin >> N;
rep(i, N) {
cin >> x[i] >> y[i];
a[i] = mp(atan2(y[i], x[i]), mp(x[i], y[i]));
}
sort(a, a + N);
rep(i, N) a[N + i] = a[i];
long double ans = 0;
rep(i, N) {
rep(j, N) {
long double X = 0, Y = 0;
rep(k, j + 1) {
X += a[i + k].second.first;
Y += a[i + k].second.second;
}
ans = max(ans, X * X + Y + Y);
}
}
cout << fixed << setprecision(16) << sqrt(ans) << endl;
}
|
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int N;
long double x[100], y[100];
pair<long double, pair<long double, long double>> a[200];
signed main() {
cin >> N;
rep(i, N) {
cin >> x[i] >> y[i];
a[i] = mp(atan2(y[i], x[i]), mp(x[i], y[i]));
}
sort(a, a + N);
rep(i, N) a[N + i] = a[i];
long double ans = 0;
rep(i, N) {
rep(j, N) {
long double X = 0, Y = 0;
rep(k, j + 1) {
X += a[i + k].second.first;
Y += a[i + k].second.second;
}
ans = max(ans, X * X + Y * Y);
}
}
cout << fixed << setprecision(16) << sqrt(ans) << endl;
}
|
[
"expression.operator.arithmetic.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 732,258
| 732,259
|
u422592877
|
cpp
|
p02926
|
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
using namespace std;
typedef vector<pair<ll, ll>> vll;
typedef vector<pair<int, int>> vii;
typedef pair<ll, ll> pll;
const ll N = 100001;
const ll M = 1;
void update(ll BIT[], ll n, ll x, ll i) {
for (; i <= n; i += (i) & (-i))
BIT[i] += x;
}
ll query(ll BIT[], ll l) {
ll sum1 = 0;
for (; l; l = l & (l - 1))
sum1 += BIT[l];
return sum1;
}
int main() {
fast;
int _ = 1;
// cin >> _;
while (_--) {
ll n, x, y;
cin >> n;
pair<long double, pair<int, int>> a[2 * n];
long double ans = 0;
for (int i = 0; i < n; i++) {
cin >> x >> y;
a[i].ff = atan2(y, x);
a[i].ss.ff = x;
a[i].ss.ss = y;
}
sort(a, a + n);
for (int i = n; i < 2 * n; i++)
a[i] = a[i - n], a[i].ff += 2 * PI;
for (int i = 0; i < n; i++) {
x = 0, y = 0;
for (int j = i; j < n - i; j++) {
x += a[j].ss.ff;
y += a[j].ss.ss;
ans = max((ll)ans, x * x + y * y);
}
}
ans = sqrt(ans);
cout << fixed << setprecision(11) << ans << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
using namespace std;
typedef vector<pair<ll, ll>> vll;
typedef vector<pair<int, int>> vii;
typedef pair<ll, ll> pll;
const ll N = 100001;
const ll M = 1;
void update(ll BIT[], ll n, ll x, ll i) {
for (; i <= n; i += (i) & (-i))
BIT[i] += x;
}
ll query(ll BIT[], ll l) {
ll sum1 = 0;
for (; l; l = l & (l - 1))
sum1 += BIT[l];
return sum1;
}
int main() {
fast;
int _ = 1;
// cin >> _;
while (_--) {
ll n, x, y;
cin >> n;
pair<long double, pair<int, int>> a[2 * n];
long double ans = 0;
for (int i = 0; i < n; i++) {
cin >> x >> y;
a[i].ff = atan2(y, x);
a[i].ss.ff = x;
a[i].ss.ss = y;
}
sort(a, a + n);
for (int i = n; i < 2 * n; i++)
a[i] = a[i - n], a[i].ff += 2 * PI;
for (int i = 0; i < n; i++) {
x = 0, y = 0;
for (int j = i; j < n + i; j++) {
x += a[j].ss.ff;
y += a[j].ss.ss;
ans = max((ll)ans, x * x + y * y);
}
}
ans = sqrt(ans);
cout << fixed << setprecision(11) << ans << "\n";
}
return 0;
}
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"control_flow.loop.condition.change"
] | 732,260
| 732,261
|
u775313130
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define debug(v) \
cout << #v << ":"; \
for (auto x : v) { \
cout << x << ' '; \
} \
cout << endl;
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(12);
int n;
cin >> n;
vector<complex<long double>> v(n);
rep(i, n) {
long double x, y;
cin >> x >> y;
v[i] = complex<long double>(x, y);
}
sort(ALL(v), [&](complex<long double> a, complex<long double> b) {
return atan2l(real(a), imag(a)) < atan2l(real(b), imag(b));
});
debug(v);
long double ans = 0;
rep(i, n) {
long double x = 0, y = 0;
rep(j, n) {
x += real(v[(i + j) % n]);
y += imag(v[(i + j) % n]);
chmax(ans, sqrt(x * x + y * y));
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define debug(v) \
cout << #v << ":"; \
for (auto x : v) { \
cout << x << ' '; \
} \
cout << endl;
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(12);
int n;
cin >> n;
vector<complex<long double>> v(n);
rep(i, n) {
long double x, y;
cin >> x >> y;
v[i] = complex<long double>(x, y);
}
sort(ALL(v), [&](complex<long double> a, complex<long double> b) {
return atan2l(real(a), imag(a)) < atan2l(real(b), imag(b));
});
long double ans = 0;
rep(i, n) {
long double x = 0, y = 0;
rep(j, n) {
x += real(v[(i + j) % n]);
y += imag(v[(i + j) % n]);
chmax(ans, sqrt(x * x + y * y));
}
}
cout << ans << endl;
return 0;
}
|
[
"call.remove"
] | 732,262
| 732,263
|
u022832318
|
cpp
|
p02926
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define yn \
{ puts("Yes"); } \
else { \
puts("No"); \
}
#define MAX_N 200005
int main() {
int n;
cin >> n;
vector<pair<double, pair<double, double>>> v;
rep(i, n) {
double x, y;
cin >> x >> y;
pair<double, pair<double, double>> p;
p.first = atan2(y, x);
p.second.first = x;
p.second.first = y;
v.push_back(p);
}
sort(v.begin(), v.end());
rep(i, n) { v.push_back(v[i]); }
double ans = 0;
rep(i, n) {
srep(j, 1, n + 1) {
ll tmpx = 0;
ll tmpy = 0;
rep(k, j) {
tmpx += v[i + k].second.first;
tmpy += v[i + k].second.second;
}
ans = max(ans, sqrt(tmpx * tmpx + tmpy * tmpy));
}
}
cout << fixed << setprecision(10) << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define yn \
{ puts("Yes"); } \
else { \
puts("No"); \
}
#define MAX_N 200005
int main() {
int n;
cin >> n;
vector<pair<double, pair<double, double>>> v;
rep(i, n) {
double x, y;
cin >> x >> y;
pair<double, pair<double, double>> p;
p.first = atan2(y, x);
p.second.first = x;
p.second.second = y;
v.push_back(p);
}
sort(v.begin(), v.end());
rep(i, n) { v.push_back(v[i]); }
double ans = 0;
rep(i, n) {
srep(j, 1, n + 1) {
ll tmpx = 0;
ll tmpy = 0;
rep(k, j) {
tmpx += v[i + k].second.first;
tmpy += v[i + k].second.second;
}
ans = max(ans, sqrt(tmpx * tmpx + tmpy * tmpy));
}
}
cout << fixed << setprecision(10) << ans << endl;
return 0;
}
|
[
"assignment.variable.change"
] | 732,270
| 732,271
|
u791593901
|
cpp
|
p02926
|
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define EPS (1e-12)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
bool LTE(double a, double b) { return equals(a, b) || a < b; }
bool LT(double a, double b) { return !equals(a, b) && a < b; }
class Point {
public:
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
Point operator+(Point p) { return Point(x + p.x, y + p.y); }
Point operator-(Point p) { return Point(x - p.x, y - p.y); }
Point operator*(double a) { return Point(a * x, a * y); }
Point operator/(double a) { return Point(x / a, y / a); }
Point operator*(Point a) {
return Point(x * a.x - y * a.y, x * a.y + y * a.x);
}
bool operator<(const Point &p) const {
return !equals(x, p.x) ? x < p.x : (!equals(y, p.y) && y < p.y);
}
bool operator==(const Point &p) const {
return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
}
};
ostream &operator<<(ostream &os, const Point &a) {
return os << "(" << a.x << "," << a.y << ")";
}
#define MAX 200
int n;
Point ps[MAX];
bool debug = 1;
struct Data {
Point p;
double arg;
bool operator<(const Data &d) const { return LT(arg, d.arg); }
};
void compute() {
vector<Data> vec;
rep(i, n) {
Data d;
d.p = ps[i];
d.arg = atan2(ps[i].y, ps[i].x) * 180.0 / M_PI;
if (LT(d.arg, 0))
d.arg += 360.0;
vec.push_back(d);
d.arg += 360.0;
vec.push_back(d);
}
sort(ALL(vec));
if (debug) {
cout << "---" << endl;
rep(i, (int)vec.size()) {
cout << vec[i].p << " : arg = " << vec[i].arg << endl;
}
}
double maxi = 0;
rep(L, n) {
Point p = Point(0, 0);
REP(R, L, L + n) {
p = p + vec[R].p;
double delta = vec[R].arg - vec[L].arg;
if (LT(180.0, delta))
break;
double dist = sqrt(p.x * p.x + p.y * p.y);
if (LT(maxi, dist))
maxi = dist;
}
}
printf("%.20f\n", maxi);
}
int main() {
cin >> n;
rep(i, n) cin >> ps[i].x >> ps[i].y;
compute();
return 0;
}
|
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define EPS (1e-12)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
bool LTE(double a, double b) { return equals(a, b) || a < b; }
bool LT(double a, double b) { return !equals(a, b) && a < b; }
class Point {
public:
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
Point operator+(Point p) { return Point(x + p.x, y + p.y); }
Point operator-(Point p) { return Point(x - p.x, y - p.y); }
Point operator*(double a) { return Point(a * x, a * y); }
Point operator/(double a) { return Point(x / a, y / a); }
Point operator*(Point a) {
return Point(x * a.x - y * a.y, x * a.y + y * a.x);
}
bool operator<(const Point &p) const {
return !equals(x, p.x) ? x < p.x : (!equals(y, p.y) && y < p.y);
}
bool operator==(const Point &p) const {
return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
}
};
ostream &operator<<(ostream &os, const Point &a) {
return os << "(" << a.x << "," << a.y << ")";
}
#define MAX 200
int n;
Point ps[MAX];
bool debug = 0;
struct Data {
Point p;
double arg;
bool operator<(const Data &d) const { return LT(arg, d.arg); }
};
void compute() {
vector<Data> vec;
rep(i, n) {
Data d;
d.p = ps[i];
d.arg = atan2(ps[i].y, ps[i].x) * 180.0 / M_PI;
if (LT(d.arg, 0))
d.arg += 360.0;
vec.push_back(d);
d.arg += 360.0;
vec.push_back(d);
}
sort(ALL(vec));
if (debug) {
cout << "---" << endl;
rep(i, (int)vec.size()) {
cout << vec[i].p << " : arg = " << vec[i].arg << endl;
}
}
double maxi = 0;
rep(L, n) {
Point p = Point(0, 0);
REP(R, L, L + n) {
p = p + vec[R].p;
double delta = vec[R].arg - vec[L].arg;
if (LT(180.0, delta))
break;
double dist = sqrt(p.x * p.x + p.y * p.y);
if (LT(maxi, dist))
maxi = dist;
}
}
printf("%.20f\n", maxi);
}
int main() {
cin >> n;
rep(i, n) cin >> ps[i].x >> ps[i].y;
compute();
return 0;
}
|
[
"literal.number.change",
"variable_declaration.value.change"
] | 732,286
| 732,287
|
u412073904
|
cpp
|
p02926
|
#pragma gcc optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;
typedef pair<int, pll> pip;
typedef pair<pll, int> ppi;
typedef pair<lld, pll> plp;
typedef pair<pll, lld> ppl;
typedef pair<pll, pll> ppp;
template <typename T> using maxHeap = priority_queue<T, vector<T>, less<T>>;
template <typename T> using minHeap = priority_queue<T, vector<T>, greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define jizz \
cin.tie(0); \
cout.tie(0); \
ios::sync_with_stdio(0);
inline void input(int &_x) {
_x = 0;
int _tmp = 1;
char _tc = getchar();
while ((_tc < '0' || _tc > '9') && _tc != '-')
_tc = getchar();
if (_tc == '-')
_tc = getchar(), _tmp = -1;
while (_tc >= '0' && _tc <= '9')
_x = _x * 10 + (_tc - 48), _tc = getchar();
_x *= _tmp;
}
inline void output(int _x) {
char _buff[20];
int _f = 0;
if (_x == 0)
putchar('0');
while (_x > 0) {
_buff[_f++] = _x % 10 + '0';
_x /= 10;
}
for (_f -= 1; _f >= 0; _f--)
putchar(_buff[_f]);
putchar('\n');
}
template <typename Iter> ostream &_out(ostream &s, Iter b, Iter e) {
s << "[";
for (auto it = b; it != e; it++)
s << (it == b ? "" : " ") << *it;
s << "]";
return s;
}
template <class T1, class T2>
ostream &operator<<(ostream &out, pair<T1, T2> p) {
return out << '(' << p.first << ", " << p.second << ')';
}
template <typename T> ostream &operator<<(ostream &s, const vector<T> &c) {
return _out(s, c.begin(), c.end());
}
#ifdef erd1
#define pprint(x) \
cerr << __PRETTY_FUNCTION__ << ":" << __LINE__ << " - " << (#x) << "=" \
<< (x) << endl
#else
#define pprint(x)
#endif
static constexpr double TAU = 2 * acos(-1);
// code starts here
vector<pii> v;
signed main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
v.pb({a, b});
}
int N = 100000;
lld ans = 0;
long double dt = TAU / N;
for (int i = 0; i < N; i++) {
long double c = cos(i * TAU), s = sin(i * TAU);
lld x = 0, y = 0;
for (auto i : v)
if (i.ff * s + i.ss * c > 0)
x += i.ff, y += i.ss;
ans = max(ans, x * x + y * y);
}
cout << fixed << setprecision(50) << (long double)sqrt(ans) << endl;
}
|
#pragma gcc optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;
typedef pair<int, pll> pip;
typedef pair<pll, int> ppi;
typedef pair<lld, pll> plp;
typedef pair<pll, lld> ppl;
typedef pair<pll, pll> ppp;
template <typename T> using maxHeap = priority_queue<T, vector<T>, less<T>>;
template <typename T> using minHeap = priority_queue<T, vector<T>, greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define jizz \
cin.tie(0); \
cout.tie(0); \
ios::sync_with_stdio(0);
inline void input(int &_x) {
_x = 0;
int _tmp = 1;
char _tc = getchar();
while ((_tc < '0' || _tc > '9') && _tc != '-')
_tc = getchar();
if (_tc == '-')
_tc = getchar(), _tmp = -1;
while (_tc >= '0' && _tc <= '9')
_x = _x * 10 + (_tc - 48), _tc = getchar();
_x *= _tmp;
}
inline void output(int _x) {
char _buff[20];
int _f = 0;
if (_x == 0)
putchar('0');
while (_x > 0) {
_buff[_f++] = _x % 10 + '0';
_x /= 10;
}
for (_f -= 1; _f >= 0; _f--)
putchar(_buff[_f]);
putchar('\n');
}
template <typename Iter> ostream &_out(ostream &s, Iter b, Iter e) {
s << "[";
for (auto it = b; it != e; it++)
s << (it == b ? "" : " ") << *it;
s << "]";
return s;
}
template <class T1, class T2>
ostream &operator<<(ostream &out, pair<T1, T2> p) {
return out << '(' << p.first << ", " << p.second << ')';
}
template <typename T> ostream &operator<<(ostream &s, const vector<T> &c) {
return _out(s, c.begin(), c.end());
}
#ifdef erd1
#define pprint(x) \
cerr << __PRETTY_FUNCTION__ << ":" << __LINE__ << " - " << (#x) << "=" \
<< (x) << endl
#else
#define pprint(x)
#endif
static constexpr double TAU = 2 * acos(-1);
// code starts here
vector<pii> v;
signed main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
v.pb({a, b});
}
int N = 1500000;
lld ans = 0;
long double dt = TAU / N;
for (int i = 0; i < N; i++) {
long double c = cos(i * dt), s = sin(i * dt);
lld x = 0, y = 0;
for (auto i : v)
if (i.ff * s + i.ss * c > 0)
x += i.ff, y += i.ss;
ans = max(ans, x * x + y * y);
}
cout << fixed << setprecision(50) << (long double)sqrt(ans) << endl;
}
|
[
"literal.number.change",
"variable_declaration.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 732,295
| 732,296
|
u579678749
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout << #x " = " << ((x)) << endl
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &p) {
o << "(" << p.fi << "," << p.se << ")";
return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
o << "[";
for (T t : v) {
o << t << ",";
}
o << "]";
return o;
}
const double PI = acos(-1);
const double EPS = 1e-9;
using pi = pair<int, int>;
using P = pair<double, pi>;
int main() {
int n;
scanf(" %d", &n);
vector<P> v;
rep(i, n) {
int x, y;
scanf(" %d %d", &x, &y);
double t = atan2(y, x);
if (t < 0)
t = 2 * PI + t;
v.pb({t, {x, y}});
v.pb({t + 2 * PI, {x, y}});
}
sort(all(v));
int V = v.size();
ll ans = 0;
rep(i, V) {
// dbg(i);
ll x = 0, y = 0;
for (int j = i; j < V; ++j) {
if (v[j].fi - v[i].fi > PI - EPS)
break;
// dbg(v[j].se);
x += v[j].se.fi;
y += v[j].se.se;
}
// dbg((pi(x,y)));
ans = max(ans, x * x + y * y);
}
printf("%.15f", sqrt(ans));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout << #x " = " << ((x)) << endl
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &p) {
o << "(" << p.fi << "," << p.se << ")";
return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
o << "[";
for (T t : v) {
o << t << ",";
}
o << "]";
return o;
}
const double PI = acos(-1);
const double EPS = 1e-8;
using pi = pair<int, int>;
using P = pair<double, pi>;
int main() {
int n;
scanf(" %d", &n);
vector<P> v;
rep(i, n) {
int x, y;
scanf(" %d %d", &x, &y);
double t = atan2(y, x);
if (t < 0)
t = 2 * PI + t;
v.pb({t, {x, y}});
v.pb({t + 2 * PI, {x, y}});
}
sort(all(v));
int V = v.size();
ll ans = 0;
rep(i, V) {
ll x = 0, y = 0;
for (int j = i; j < V; ++j) {
if (v[j].fi - v[i].fi > PI + EPS)
break;
x += v[j].se.fi;
y += v[j].se.se;
ans = max(ans, x * x + y * y);
}
}
printf("%.15f", sqrt(ans));
return 0;
}
|
[
"literal.number.change",
"variable_declaration.value.change",
"misc.opposites",
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change"
] | 732,300
| 732,301
|
u696805736
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout << #x " = " << ((x)) << endl
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &p) {
o << "(" << p.fi << "," << p.se << ")";
return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
o << "[";
for (T t : v) {
o << t << ",";
}
o << "]";
return o;
}
const double PI = acos(-1);
const double EPS = 1e-8;
using pi = pair<int, int>;
using P = pair<double, pi>;
int main() {
int n;
scanf(" %d", &n);
vector<P> v;
rep(i, n) {
int x, y;
scanf(" %d %d", &x, &y);
double t = atan2(y, x);
if (t < 0)
t = 2 * PI + t;
v.pb({t, {x, y}});
v.pb({t + 2 * PI, {x, y}});
}
sort(all(v));
int V = v.size();
ll ans = 0;
rep(i, V) {
// dbg(i);
ll x = 0, y = 0;
for (int j = i; j < V; ++j) {
if (v[j].fi - v[i].fi > PI - EPS)
break;
// dbg(v[j].se);
x += v[j].se.fi;
y += v[j].se.se;
}
// dbg((pi(x,y)));
ans = max(ans, x * x + y * y);
}
printf("%.15f", sqrt(ans));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout << #x " = " << ((x)) << endl
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &p) {
o << "(" << p.fi << "," << p.se << ")";
return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
o << "[";
for (T t : v) {
o << t << ",";
}
o << "]";
return o;
}
const double PI = acos(-1);
const double EPS = 1e-8;
using pi = pair<int, int>;
using P = pair<double, pi>;
int main() {
int n;
scanf(" %d", &n);
vector<P> v;
rep(i, n) {
int x, y;
scanf(" %d %d", &x, &y);
double t = atan2(y, x);
if (t < 0)
t = 2 * PI + t;
v.pb({t, {x, y}});
v.pb({t + 2 * PI, {x, y}});
}
sort(all(v));
int V = v.size();
ll ans = 0;
rep(i, V) {
ll x = 0, y = 0;
for (int j = i; j < V; ++j) {
if (v[j].fi - v[i].fi > PI + EPS)
break;
x += v[j].se.fi;
y += v[j].se.se;
ans = max(ans, x * x + y * y);
}
}
printf("%.15f", sqrt(ans));
return 0;
}
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change"
] | 732,302
| 732,301
|
u696805736
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;
signed main() {
int n;
cin >> n;
double x, y;
vector<pair<double, pair<double, double>>> p;
for (int i = 0; i < n; i++) {
cin >> x >> y;
if (x != 0 || y != 0)
p.push_back(make_pair(atan2(y, x), make_pair(x, y)));
}
sort(p.begin(), p.end());
int j = 0;
n = p.size();
double X = 0, Y = 0;
double ans = 0;
for (int i = 0; i < n; i++) {
while ((((p[j % n].first - p[i].first) > 0 &&
(p[j % n].first - p[i].first) < M_PI) ||
((p[j % n].first - p[i].first) < 0 &&
(p[j % n].first - p[i].first) < -1 * M_PI)) &&
j != i + n) {
X += (p[j % n].second).first;
Y += (p[j % n].second).second;
ans = max(ans, sqrt(X * X + Y * Y));
j++;
}
X -= (p[i].second).first;
Y -= (p[i].second).second;
ans = max(ans, sqrt(X * X + Y * Y));
}
cout << std::fixed << std::setprecision(50) << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;
signed main() {
int n;
cin >> n;
double x, y;
vector<pair<double, pair<double, double>>> p;
for (int i = 0; i < n; i++) {
cin >> x >> y;
if (x != 0 || y != 0)
p.push_back(make_pair(atan2(y, x), make_pair(x, y)));
}
sort(p.begin(), p.end());
int j = 0;
n = p.size();
double X = 0, Y = 0;
double ans = 0;
for (int i = 0; i < n; i++) {
while ((((p[j % n].first - p[i].first) >= 0 &&
(p[j % n].first - p[i].first) < M_PI) ||
((p[j % n].first - p[i].first) < 0 &&
(p[j % n].first - p[i].first) < -1 * M_PI)) &&
j != i + n) {
X += (p[j % n].second).first;
Y += (p[j % n].second).second;
ans = max(ans, sqrt(X * X + Y * Y));
j++;
}
X -= (p[i].second).first;
Y -= (p[i].second).second;
ans = max(ans, sqrt(X * X + Y * Y));
}
cout << std::fixed << std::setprecision(50) << ans;
return 0;
}
|
[
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 732,306
| 732,307
|
u651317892
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;
signed main() {
int n;
cin >> n;
float x, y;
vector<pair<double, pair<double, double>>> p;
for (int i = 0; i < n; i++) {
cin >> x >> y;
if (x != 0 || y != 0)
p.push_back(make_pair(atan2(y, x), make_pair(x, y)));
}
sort(p.begin(), p.end());
int j = 0;
n = p.size();
double X = 0, Y = 0;
double ans = 0;
for (int i = 0; i < n; i++) {
while ((((p[j % n].first - p[i].first) > 0 &&
(p[j % n].first - p[i].first) < M_PI) ||
((p[j % n].first - p[i].first) < 0 &&
(p[j % n].first - p[i].first) < -1 * M_PI)) &&
j != i + n) {
X += (p[j % n].second).first;
Y += (p[j % n].second).second;
ans = max(ans, sqrt(X * X + Y * Y));
j++;
}
X -= (p[i].second).first;
Y -= (p[i].second).second;
ans = max(ans, sqrt(X * X + Y * Y));
}
cout << std::fixed << std::setprecision(50) << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;
signed main() {
int n;
cin >> n;
double x, y;
vector<pair<double, pair<double, double>>> p;
for (int i = 0; i < n; i++) {
cin >> x >> y;
if (x != 0 || y != 0)
p.push_back(make_pair(atan2(y, x), make_pair(x, y)));
}
sort(p.begin(), p.end());
int j = 0;
n = p.size();
double X = 0, Y = 0;
double ans = 0;
for (int i = 0; i < n; i++) {
while ((((p[j % n].first - p[i].first) >= 0 &&
(p[j % n].first - p[i].first) < M_PI) ||
((p[j % n].first - p[i].first) < 0 &&
(p[j % n].first - p[i].first) < -1 * M_PI)) &&
j != i + n) {
X += (p[j % n].second).first;
Y += (p[j % n].second).second;
ans = max(ans, sqrt(X * X + Y * Y));
j++;
}
X -= (p[i].second).first;
Y -= (p[i].second).second;
ans = max(ans, sqrt(X * X + Y * Y));
}
cout << std::fixed << std::setprecision(50) << ans;
return 0;
}
|
[
"variable_declaration.type.primitive.change",
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 732,308
| 732,307
|
u651317892
|
cpp
|
p02926
|
//@Author: wxyww
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define pi pair<double, double>
const int N = 110;
ll read() {
ll x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0', c = getchar();
}
return x * f;
}
pi a[N];
bool cmp(const pi &A, const pi &B) {
return atan2(A.second, A.first) < atan2(B.second, B.first);
}
int main() {
int n = read();
for (int i = 0; i < n; ++i)
a[i].first = read(), a[i].second = read();
sort(a, a + n, cmp);
double ans = 0;
for (int i = 0; i < n; ++i) {
double X = a[i].first, Y = a[i].second;
ans = X * X + Y * Y;
for (int j = (i + 1) % n; j != i; j = (j + 1) % n) {
X += a[j].first, Y += a[j].second;
ans = max(ans, X * X + Y * Y);
}
}
printf("%.10lf", sqrt(ans));
return 0;
}
|
//@Author: wxyww
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define pi pair<double, double>
const int N = 110;
ll read() {
ll x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0', c = getchar();
}
return x * f;
}
pi a[N];
bool cmp(const pi &A, const pi &B) {
return atan2(A.second, A.first) < atan2(B.second, B.first);
}
int main() {
int n = read();
for (int i = 0; i < n; ++i)
a[i].first = read(), a[i].second = read();
sort(a, a + n, cmp);
double ans = 0;
for (int i = 0; i < n; ++i) {
double X = a[i].first, Y = a[i].second;
ans = max(ans, X * X + Y * Y);
for (int j = (i + 1) % n; j != i; j = (j + 1) % n) {
X += a[j].first, Y += a[j].second;
ans = max(ans, X * X + Y * Y);
}
}
printf("%.10lf", sqrt(ans));
return 0;
}
|
[
"call.add",
"call.arguments.change"
] | 732,314
| 732,315
|
u748042489
|
cpp
|
p02926
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
typedef long long ll;
using namespace std;
struct ConvexHull {
using cd = complex<double>;
vector<cd> ps, qs;
int sz;
ConvexHull(vector<cd> v) {
ps = v;
sz = ps.size();
qs.resize(sz * 2);
sort(ps.begin(), ps.end(), [](cd a, cd b) {
if (a.real() != b.real()) {
return a.real() < b.real();
}
return a.imag() < b.imag();
});
calc();
}
void calc() {
int k = 0;
for (int i = 0; i < sz; i++) {
while (k > 1 && ((qs[k - 1] - ps[i]) / (qs[k - 2] - ps[i])).imag() <= 0)
k--;
qs[k++] = ps[i];
}
int t = k;
for (int i = sz - 2; i >= 0; i--) {
while (k > t && ((qs[k - 1] - ps[i]) / (qs[k - 2] - ps[i])).imag() <= 0)
k--;
qs[k++] = ps[i];
}
qs.resize(k - 1);
}
/*最遠点 尺取
double farlen()
{
double res=0,tres=0;
int r=1;
rep(l,qs.size())
{
tres=abs(qs[l]-qs[r-1]);
while(r<qs.size() && chmax(tres,abs(qs[l]-qs[r])))r++;
chmax(res,tres);
if(l==r)r++;
}
return res;
}
*/
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
vector<complex<double>> conv;
int n;
cin >> n;
conv.push_back({0, 0});
rep(i, n) {
double x, y;
cin >> x >> y;
complex<double> vec(x, y);
auto tv = conv;
for (auto j : tv)
conv.push_back(j + vec);
ConvexHull ch(conv);
ch.calc();
conv = ch.qs;
conv.erase(unique(all(conv)));
// rep(i,ch.qs.size())conv.push_back(ch.qs[i]);
// rep(i,conv.size())cout<<conv[i]<<endl;
// cout<<endl;
}
double res = 0;
rep(i, conv.size()) { chmax(res, abs(conv[i])); }
cout << setprecision(12) << res << endl;
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
typedef long long ll;
using namespace std;
struct ConvexHull {
using cd = complex<double>;
vector<cd> ps, qs;
int sz;
ConvexHull(vector<cd> v) {
ps = v;
sz = ps.size();
qs.resize(sz * 2);
sort(ps.begin(), ps.end(), [](cd a, cd b) {
if (a.real() != b.real()) {
return a.real() < b.real();
}
return a.imag() < b.imag();
});
calc();
}
void calc() {
int k = 0;
for (int i = 0; i < sz; i++) {
while (k > 1 && ((qs[k - 1] - ps[i]) / (qs[k - 2] - ps[i])).imag() <= 0)
k--;
qs[k++] = ps[i];
}
int t = k;
for (int i = sz - 2; i >= 0; i--) {
while (k > t && ((qs[k - 1] - ps[i]) / (qs[k - 2] - ps[i])).imag() <= 0)
k--;
qs[k++] = ps[i];
}
qs.resize(k - 1);
}
/*最遠点 尺取
double farlen()
{
double res=0,tres=0;
int r=1;
rep(l,qs.size())
{
tres=abs(qs[l]-qs[r-1]);
while(r<qs.size() && chmax(tres,abs(qs[l]-qs[r])))r++;
chmax(res,tres);
if(l==r)r++;
}
return res;
}
*/
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
vector<complex<double>> conv;
int n;
cin >> n;
conv.push_back({0, 0});
rep(i, n) {
double x, y;
cin >> x >> y;
complex<double> vec(x, y);
auto tv = conv;
for (auto j : tv)
conv.push_back(j + vec);
ConvexHull ch(conv);
ch.calc();
conv = ch.qs;
conv.erase(unique(all(conv)), conv.end());
// rep(i,ch.qs.size())conv.push_back(ch.qs[i]);
// rep(i,conv.size())cout<<conv[i]<<endl;
// cout<<endl;
}
double res = 0;
rep(i, conv.size()) { chmax(res, abs(conv[i])); }
cout << setprecision(12) << res << endl;
return 0;
}
|
[
"call.arguments.add"
] | 732,318
| 732,319
|
u834415466
|
cpp
|
p02926
|
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (a); i <= (b); i++)
#define repR(i, n) for (int i = n; i >= 0; i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<int>
#define COUT(x) cout << (x) << endl
#define MA map<int, int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int, VE, greater<int>>
#define COUT(x) cout << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
if (a < b)
swap(a, b);
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
bool prime(int n) {
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
if (a.second != b.second) {
return a.second < b.second;
} else {
return a.first < b.first;
}
}
const long long MOD = 1000000007;
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>>
// AandB.push_back(make_pair(a[i],b[i]))
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
VE xs(n), ys(n);
rep(i, n) cin >> xs[i] >> ys[i];
double ans = 0;
rep(i, n) {
int gx = xs[i];
int gy = ys[i];
rep(k, 4) {
int nx = -gy;
int ny = gx;
gx = nx;
gy = ny;
}
int sx = 0, sy = 0;
int px = 0, py = 0;
int qx = 0, qy = 0;
auto dot = [&](int x1, int y1, int x2, int y2) {
return x1 * x2 + y1 * y2;
};
auto cross = [&](int x1, int y1, int x2, int y2) {
return x1 * y2 - x2 * y1;
};
rep(j, n) {
int res = dot(xs[j], ys[j], gx, gy);
if (res < 0)
continue;
if (res > 0) {
sx += xs[j];
sy += ys[j];
continue;
}
if (cross(xs[j], ys[j], gx, gy) > 0) {
px += xs[j];
py += ys[j];
} else {
qx += xs[j];
qy += ys[j];
}
}
rep(t, 4) {
double bx = sx, by = sy;
if (t & 1)
bx += px, by += py;
if (t & 2)
bx += qx, by += qy;
chmax(ans, bx * bx + by * by);
}
}
cout << fixed << setprecision(15) << sqrt(ans) << endl;
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (a); i <= (b); i++)
#define repR(i, n) for (int i = n; i >= 0; i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<int>
#define COUT(x) cout << (x) << endl
#define MA map<int, int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int, VE, greater<int>>
#define COUT(x) cout << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
if (a < b)
swap(a, b);
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
bool prime(int n) {
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
if (a.second != b.second) {
return a.second < b.second;
} else {
return a.first < b.first;
}
}
const long long MOD = 1000000007;
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>>
// AandB.push_back(make_pair(a[i],b[i]))
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
VE xs(n), ys(n);
rep(i, n) cin >> xs[i] >> ys[i];
double ans = 0;
rep(i, n) {
int gx = xs[i];
int gy = ys[i];
rep(k, 4) {
int nx = -gy;
int ny = gx;
gx = nx;
gy = ny;
int sx = 0, sy = 0;
int px = 0, py = 0;
int qx = 0, qy = 0;
auto dot = [&](int x1, int y1, int x2, int y2) {
return x1 * x2 + y1 * y2;
};
auto cross = [&](int x1, int y1, int x2, int y2) {
return x1 * y2 - x2 * y1;
};
rep(j, n) {
int res = dot(xs[j], ys[j], gx, gy);
if (res < 0)
continue;
if (res > 0) {
sx += xs[j];
sy += ys[j];
continue;
}
if (cross(xs[j], ys[j], gx, gy) > 0) {
px += xs[j];
py += ys[j];
} else {
qx += xs[j];
qy += ys[j];
}
}
rep(t, 4) {
double bx = sx, by = sy;
if (t & 1)
bx += px, by += py;
if (t & 2)
bx += qx, by += qy;
chmax(ans, bx * bx + by * by);
}
}
}
cout << fixed << setprecision(15) << sqrt(ans) << endl;
return 0;
}
|
[] | 732,324
| 732,325
|
u809967037
|
cpp
|
p02926
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define vv(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int>>
#define vvl std::vector<std::vector<ll>>
#define vvd std::vector<std::vector<long double>>
#define MODs 1000000007;
typedef long long int ll;
typedef long double ld;
using namespace std;
long double rad(long double r) {
if (r >= 0)
return (r / M_PI) * 180;
else
return ((M_PI + r) / M_PI) * 180 + 180;
}
int main(int argc, char const *argv[]) {
ld N, a, b, ans = 0;
std::cin >> N;
vvd T = vv(2 * N, 3, 0, ld);
for (ld i = 0; i < N; i++) {
std::cin >> a >> b;
T[i][0] = rad(arg(complex<ld>(a, b)));
T[N + i][0] = T[i][0] + 360.0;
T[i][1] = T[N + i][1] = a, T[i][2] = T[N + i][2] = b;
}
sort(T.begin(), T.end());
for (ld i = 0; i < N; i++) {
ld x = 0, y = 0;
for (ld j = i; j < 2 * N && T[j][0] - T[i][0] < 180; j++) {
x += T[j][1], y += T[j][2];
}
ans = max(ans, sqrt(x * x + y * y));
}
std::cout << fixed << setprecision(20) << ans << '\n';
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define vv(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int>>
#define vvl std::vector<std::vector<ll>>
#define vvd std::vector<std::vector<long double>>
#define MODs 1000000007;
typedef long long int ll;
typedef long double ld;
using namespace std;
long double rad(long double r) {
if (r >= 0)
return (r / M_PI) * 180;
else
return ((M_PI + r) / M_PI) * 180 + 180;
}
int main(int argc, char const *argv[]) {
ld N, a, b, ans = 0;
std::cin >> N;
vvd T = vv(2 * N, 3, 0, ld);
for (ld i = 0; i < N; i++) {
std::cin >> a >> b;
T[i][0] = rad(arg(complex<ld>(a, b)));
T[N + i][0] = T[i][0] + 360.0;
T[i][1] = T[N + i][1] = a, T[i][2] = T[N + i][2] = b;
}
sort(T.begin(), T.end());
for (ld i = 0; i < N; i++) {
ld x = 0, y = 0;
for (ld j = i; j < 2 * N && T[j][0] - T[i][0] <= 180; j++) {
x += T[j][1], y += T[j][2];
ans = max(ans, sqrt(x * x + y * y));
}
}
std::cout << fixed << setprecision(20) << ans << '\n';
return 0;
}
|
[
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 732,332
| 732,333
|
u816587940
|
cpp
|
p02926
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define puts(x) cout << x << endl
#define rep(i, m, n) for (ll i = m; i < n; ++i)
#define pb push_back
#define fore(i, a) for (auto &i : a)
#define rrep(i, m, n) for (ll i = m; i >= n; --i)
long double pi = 3.141592653589793238462643;
vector<pair<int, int>> p;
long double len(vector<int> num) {
ll x = 0;
ll y = 0;
fore(z, num) {
x += p[z].first;
y += p[z].second;
}
return sqrt(x * x + y * y);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
p.resize(N);
for (int i = 0; i < N; i++)
cin >> p[i].first >> p[i].second;
long double ans = 0.0;
for (int i = 0; i < 1000; i++) {
long double c = cos((2.0 * (long double)i * pi) / (long double)10000);
long double s = sin((2.0 * (long double)i * pi) / (long double)10000);
vector<int> temp;
for (int j = 0; j < N; j++) {
long double x = p[j].first;
long double y = p[j].second;
if (x * c + y * s >= 0.0)
temp.pb(j);
}
ans = max(ans, len(temp));
}
cout << setprecision(20) << ans << endl;
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define puts(x) cout << x << endl
#define rep(i, m, n) for (ll i = m; i < n; ++i)
#define pb push_back
#define fore(i, a) for (auto &i : a)
#define rrep(i, m, n) for (ll i = m; i >= n; --i)
long double pi = 3.141592653589793238462643;
vector<pair<int, int>> p;
long double len(vector<int> num) {
ll x = 0;
ll y = 0;
fore(z, num) {
x += p[z].first;
y += p[z].second;
}
return sqrt(x * x + y * y);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
p.resize(N);
for (int i = 0; i < N; i++)
cin >> p[i].first >> p[i].second;
long double ans = 0.0;
for (int i = 0; i < 100000; i++) {
long double c = cos((2.0 * (long double)i * pi) / (long double)10000);
long double s = sin((2.0 * (long double)i * pi) / (long double)10000);
vector<int> temp;
for (int j = 0; j < N; j++) {
long double x = p[j].first;
long double y = p[j].second;
if (x * c + y * s >= 0.0)
temp.pb(j);
}
ans = max(ans, len(temp));
}
cout << setprecision(20) << ans << endl;
return 0;
}
|
[
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 732,336
| 732,337
|
u632353278
|
cpp
|
p02926
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define puts(x) cout << x << endl
#define rep(i, m, n) for (ll i = m; i < n; ++i)
#define pb push_back
#define fore(i, a) for (auto &i : a)
#define rrep(i, m, n) for (ll i = m; i >= n; --i)
long double pi = 3.141592653589793238462643;
vector<pair<int, int>> p;
long double len(vector<int> num) {
ll x = 0;
ll y = 0;
fore(z, num) {
x += p[z].first;
y += p[z].second;
}
return sqrt(x * x + y * y);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
p.resize(N);
for (int i = 0; i < N; i++)
cin >> p[i].first >> p[i].second;
long double ans = 0.0;
for (int i = 0; i < 100; i++) {
long double c = cos((2.0 * (long double)i * pi) / (long double)10000);
long double s = sin((2.0 * (long double)i * pi) / (long double)10000);
vector<int> temp;
for (int j = 0; j < N; j++) {
long double x = p[j].first;
long double y = p[j].second;
if (x * c + y * s >= 0.0)
temp.pb(j);
}
ans = max(ans, len(temp));
}
cout << setprecision(20) << ans << endl;
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define puts(x) cout << x << endl
#define rep(i, m, n) for (ll i = m; i < n; ++i)
#define pb push_back
#define fore(i, a) for (auto &i : a)
#define rrep(i, m, n) for (ll i = m; i >= n; --i)
long double pi = 3.141592653589793238462643;
vector<pair<int, int>> p;
long double len(vector<int> num) {
ll x = 0;
ll y = 0;
fore(z, num) {
x += p[z].first;
y += p[z].second;
}
return sqrt(x * x + y * y);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
p.resize(N);
for (int i = 0; i < N; i++)
cin >> p[i].first >> p[i].second;
long double ans = 0.0;
for (int i = 0; i < 100000; i++) {
long double c = cos((2.0 * (long double)i * pi) / (long double)10000);
long double s = sin((2.0 * (long double)i * pi) / (long double)10000);
vector<int> temp;
for (int j = 0; j < N; j++) {
long double x = p[j].first;
long double y = p[j].second;
if (x * c + y * s >= 0.0)
temp.pb(j);
}
ans = max(ans, len(temp));
}
cout << setprecision(20) << ans << endl;
return 0;
}
|
[
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 732,338
| 732,337
|
u632353278
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
const double eps = 1e-9;
struct V {
double x, y;
V(double x = 0, double y = 0) : x(x), y(y) {}
V &operator+=(const V &v) {
x += v.x;
y += v.y;
return *this;
}
V operator+(const V &v) const { return V(*this) += v; }
double dot(const V &v) const { return x * v.x + y * v.y; }
double cross(const V &v) const { return x * v.y + v.x * y; }
double norm2() const { return x * x + y * y; }
double norm() const { return sqrt(norm2()); }
int ort() const { // orthant
if (abs(x) < eps && abs(y) < eps)
return 0;
if (y > 0)
return x > 0 ? 1 : 2;
else
return x < 0 ? 3 : 4;
}
bool operator<(const V &v) const {
int o = ort(), vo = v.ort();
if (o != vo)
return o < vo;
return cross(v) > 0;
}
};
istream &operator>>(istream &is, V &v) {
is >> v.x >> v.y;
return is;
}
ostream &operator<<(ostream &os, V &v) {
os << v.x << v.y;
return os;
}
int main(void) {
int n;
cin >> n;
vector<V> v(n);
rep(i, n) cin >> v[i];
sort(v.begin(), v.end());
double ans = 0;
rep(l, n) {
int r = l;
V now;
rep(i, n) {
now += v[r];
ans = max(ans, now.norm());
r = (r + 1) % n;
}
}
printf("%.12f", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
const double eps = 1e-9;
struct V {
double x, y;
V(double x = 0, double y = 0) : x(x), y(y) {}
V &operator+=(const V &v) {
x += v.x;
y += v.y;
return *this;
}
V operator+(const V &v) const { return V(*this) += v; }
double dot(const V &v) const { return x * v.x + y * v.y; }
double cross(const V &v) const { return x * v.y - v.x * y; }
double norm2() const { return x * x + y * y; }
double norm() const { return sqrt(norm2()); }
int ort() const { // orthant
if (abs(x) < eps && abs(y) < eps)
return 0;
if (y > 0)
return x > 0 ? 1 : 2;
else
return x < 0 ? 3 : 4;
}
bool operator<(const V &v) const {
int o = ort(), vo = v.ort();
if (o != vo)
return o < vo;
return cross(v) > 0;
}
};
istream &operator>>(istream &is, V &v) {
is >> v.x >> v.y;
return is;
}
ostream &operator<<(ostream &os, V &v) {
os << v.x << v.y;
return os;
}
int main(void) {
int n;
cin >> n;
vector<V> v(n);
rep(i, n) cin >> v[i];
sort(v.begin(), v.end());
double ans = 0;
rep(l, n) {
int r = l;
V now;
rep(i, n) {
now += v[r];
ans = max(ans, now.norm());
r = (r + 1) % n;
}
}
printf("%.12f", ans);
return 0;
}
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"function.return_value.change",
"expression.operation.binary.change"
] | 732,348
| 732,349
|
u326152409
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
int n;
cin >> n;
pair<double, double> xy[n];
for (int i = 0; i < n; ++i) {
cin >> xy[i].first >> xy[i].second;
}
sort(xy, xy + n, [](const auto &p1, const auto &p2) {
return atan2(p1.second, p1.first) < atan2(p2.second, p2.first);
});
double ans = .0;
for (int i = 0; i < n; ++i) {
for (int j = i; j < n; ++j) {
double xn = .0, yn = .0;
for (int k = i; k <= j; ++k) {
xn += xy[k].first;
yn += xy[k].second;
}
ans = max(ans, sqrt((xn * xn + yn * yn)));
}
}
printf("%.11f\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
int n;
cin >> n;
pair<double, double> xy[n];
for (int i = 0; i < n; ++i) {
cin >> xy[i].first >> xy[i].second;
}
sort(xy, xy + n, [](const auto &p1, const auto &p2) {
return atan2(p1.second, p1.first) < atan2(p2.second, p2.first);
});
double ans = .0;
for (int i = 0; i < n; ++i) {
for (int j = i; j < i + n; ++j) {
double xn = .0, yn = .0;
for (int k = i; k <= j; ++k) {
xn += xy[k % n].first;
yn += xy[k % n].second;
}
ans = max(ans, sqrt((xn * xn + yn * yn)));
}
}
printf("%.11f\n", ans);
return 0;
}
|
[
"control_flow.loop.for.condition.change",
"assignment.change"
] | 732,352
| 732,353
|
u399987025
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
#define _USES_MATH_DEFINES
#define x first
#define y second
int cmp(pair<int, int> a, pair<int, int> b) {
auto f = [](long double Rad) -> long double {
if (Rad < 0)
Rad += (2 * M_PI);
return Rad;
};
return f(atan2l(a.y, a.x)) < f(atan2l(b.y, b.x));
}
int more_than_rad(pair<int, int> a, pair<int, int> b) {
long double ang = atan2l(a.y - b.y, a.x - b.x);
if (ang < 0)
ang += (2 * M_PI);
//
return (ang > M_PI);
}
long double eulDist(int x, int y) { return sqrtl(x * x + y * y); }
int main() {
// pair<int, int> a = {0, 0}, b = {5, 5};
// cout << fixed << setprecision(5) << atan2l( a.y - b.y, a.x - b.x ) << endl;
// return 0;
//
int n;
cin >> n;
vector<pair<int, int>> P(n, {0, 0});
for (int i = 0; i < n; i++) {
cin >> P[i].x >> P[i].y;
}
//
sort(P.begin(), P.end(), cmp);
// vector< pair<int, int> > sumV = {{0, 0}};
// for(auto &p : P) {
// pair<int, int> pp = *(sumV.rbegin());
// sumV.push_back( {pp.x + p.x, pp.y + p.y} );
// }
//
// for(int i = 0; i < n; i++) {
// cerr << "Point " << i << " : " << P[i].x << " " << P[i].y << endl;
// }
// return 0;
int L = 0, R = 0;
long double maxR = 0.0;
while (L < n) {
int subx = P[L].x, suby = P[L].y;
maxR = max(maxR, eulDist(subx, suby));
// cerr << "@ L = " << L << endl;
//
R = (L + 1) % n;
while (L != R) {
// cerr << "@@ R = " << R << endl;
// cerr << "@@ maxR = " << maxR << endl;
subx += P[R].x;
suby += P[R].y;
maxR = max(maxR, eulDist(subx, suby));
R = (R + 1) % n;
if (L == R)
break;
}
//
L++;
}
//
cout << fixed << setprecision(50) << maxR;
}
|
#include <bits/stdc++.h>
using namespace std;
#define _USES_MATH_DEFINES
#define x first
#define y second
int cmp(pair<int, int> a, pair<int, int> b) {
auto f = [](long double Rad) -> long double {
if (Rad < 0)
Rad += (2 * M_PI);
return Rad;
};
return f(atan2l(a.y, a.x)) < f(atan2l(b.y, b.x));
}
int more_than_rad(pair<int, int> a, pair<int, int> b) {
long double ang = atan2l(a.y - b.y, a.x - b.x);
if (ang < 0)
ang += (2 * M_PI);
//
return (ang > M_PI);
}
long double eulDist(long long x, long long y) { return sqrtl(x * x + y * y); }
int main() {
// pair<int, int> a = {0, 0}, b = {5, 5};
// cout << fixed << setprecision(5) << atan2l( a.y - b.y, a.x - b.x ) << endl;
// return 0;
//
int n;
cin >> n;
vector<pair<int, int>> P(n, {0, 0});
for (int i = 0; i < n; i++) {
cin >> P[i].x >> P[i].y;
}
//
sort(P.begin(), P.end(), cmp);
// vector< pair<int, int> > sumV = {{0, 0}};
// for(auto &p : P) {
// pair<int, int> pp = *(sumV.rbegin());
// sumV.push_back( {pp.x + p.x, pp.y + p.y} );
// }
//
// for(int i = 0; i < n; i++) {
// cerr << "Point " << i << " : " << P[i].x << " " << P[i].y << endl;
// }
// return 0;
int L = 0, R = 0;
long double maxR = 0.0;
while (L < n) {
int subx = P[L].x, suby = P[L].y;
maxR = max(maxR, eulDist(subx, suby));
// cerr << "@ L = " << L << endl;
//
R = (L + 1) % n;
while (L != R) {
// cerr << "@@ R = " << R << endl;
// cerr << "@@ maxR = " << maxR << endl;
subx += P[R].x;
suby += P[R].y;
maxR = max(maxR, eulDist(subx, suby));
R = (R + 1) % n;
if (L == R)
break;
}
//
L++;
}
//
cout << fixed << setprecision(50) << maxR;
}
|
[
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 732,359
| 732,360
|
u206133536
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int n;
long long x[105], y[105], id[205];
long double ans;
int main() {
scanf("%d", &n);
rep(i, n) {
scanf("%lld%lld", x + i, y + i);
id[i] = i;
}
sort(id, id + n,
[](int a, int b) { return atan2(x[a], y[a]) > atan2(x[b], y[b]); });
rep(i, n) id[i + n] = id[i];
rep(i, n) {
long double ax = 0, ay = 0;
for (int j = i; j < 2 * n && x[id[i]] * y[id[j]] - y[id[i]] * x[id[j]] >= 0;
j++) {
ax += x[id[j]];
ay += y[id[j]];
ans = max(ans, hypot(ax, ay));
}
}
printf("%.20Lf\n", ans);
}
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int n;
long long x[105], y[105], id[205];
long double ans;
int main() {
scanf("%d", &n);
rep(i, n) {
scanf("%lld%lld", x + i, y + i);
id[i] = i;
}
sort(id, id + n,
[](int a, int b) { return atan2(x[a], y[a]) > atan2(x[b], y[b]); });
rep(i, n) id[i + n] = id[i];
rep(i, n) {
long double ax = 0, ay = 0;
for (int j = i; j < i + n && x[id[i]] * y[id[j]] - y[id[i]] * x[id[j]] >= 0;
j++) {
ax += x[id[j]];
ay += y[id[j]];
ans = max(ans, hypot(ax, ay));
}
}
printf("%.20Lf\n", ans);
}
|
[
"control_flow.loop.for.condition.change"
] | 732,361
| 732,362
|
u309985845
|
cpp
|
p02926
|
#include <bits/stdc++.h>
#define For(a, b, c) for (int a = b; a <= c; ++a)
using namespace std;
const int N = 107;
struct V {
int x, y;
bool operator<(const V &_) const { return atan2(y, x) < atan2(_.y, _.x); }
V operator+(const V &_) const { return (V){x + _.x, y + _.y}; }
long long len2() { return 1LL * x * x + 1LL * y * y; }
} A[N];
int n;
int main() {
scanf("%d", &n);
For(i, 1, n) scanf("%d%d", &A[n].x, &A[n].y);
sort(A + 1, A + 1 + n);
long long ans = 0;
For(i, 1, n) {
V r = (V){0, 0};
For(j, 0, n - 1) {
r = r + A[(i + j - 1) % n + 1];
ans = max(ans, r.len2());
}
}
printf("%.14f", sqrt(ans));
return 0;
}
|
#include <bits/stdc++.h>
#define For(a, b, c) for (int a = b; a <= c; ++a)
using namespace std;
const int N = 107;
struct V {
int x, y;
bool operator<(const V &_) const { return atan2(y, x) < atan2(_.y, _.x); }
V operator+(const V &_) const { return (V){x + _.x, y + _.y}; }
long long len2() { return 1LL * x * x + 1LL * y * y; }
} A[N];
int n;
int main() {
scanf("%d", &n);
For(i, 1, n) scanf("%d%d", &A[i].x, &A[i].y);
sort(A + 1, A + 1 + n);
long long ans = 0;
For(i, 1, n) {
V r = (V){0, 0};
For(j, 0, n - 1) {
r = r + A[(i + j - 1) % n + 1];
ans = max(ans, r.len2());
}
}
printf("%.14f", sqrt(ans));
return 0;
}
|
[
"identifier.change",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 732,363
| 732,364
|
u748639332
|
cpp
|
p02926
|
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC target ("avx,tune=native")
// Use above if bruteforcing with lots of small operations. Or just use it
// anytime, there's no downside. AVX is better slightly
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
ll inv(ll a, ll b) { return (a > 1 ? b - inv(b % a, a) * b / a : 1); }
#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
#define N 110
const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL << 62);
const int iinf = (1 << 30);
// CLOCKS_PER_SEC
int n;
pii a[N], dp[N];
ld dist = -1;
bool cmp(pii unu, pii doi) {
return (atan2(unu.se, unu.fi) < atan2(doi.se, doi.fi));
}
ld get(int da, int db) { return sqrt(1LL * da * da + 1LL * db * db); }
int main() {
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ios_base::sync_with_stdio(0); cin.tie(0);
// ifstream cin ("test.in");
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i].fi >> a[i].se;
sort(a + 1, a + 1 + n, cmp);
for (int i = n + 1; i <= 2 * n; i++)
a[i] = a[i - n];
for (int i = 1; i <= 2 * n; i++)
dp[i] = {dp[i - 1].fi + a[i].fi, dp[i - 1].se + a[i].se};
for (int i = 1; i <= n; i++)
for (int j = i; j <= n + i; j++)
dist = smax(dist, get(dp[j].fi - dp[i - 1].fi, dp[j].se - dp[i - 1].se));
cout << fixed << setprecision(10) << dist;
return 0;
}
|
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC target ("avx,tune=native")
// Use above if bruteforcing with lots of small operations. Or just use it
// anytime, there's no downside. AVX is better slightly
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
ll inv(ll a, ll b) { return (a > 1 ? b - inv(b % a, a) * b / a : 1); }
#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
#define N 1010
const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL << 62);
const int iinf = (1 << 30);
// CLOCKS_PER_SEC
int n;
pii a[N], dp[N];
ld dist = -1;
bool cmp(pii unu, pii doi) {
return (atan2(unu.se, unu.fi) < atan2(doi.se, doi.fi));
}
ld get(int da, int db) { return sqrt(1LL * da * da + 1LL * db * db); }
int main() {
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ios_base::sync_with_stdio(0); cin.tie(0);
// ifstream cin ("test.in");
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i].fi >> a[i].se;
sort(a + 1, a + 1 + n, cmp);
for (int i = n + 1; i <= 2 * n; i++)
a[i] = a[i - n];
for (int i = 1; i <= 2 * n; i++)
dp[i] = {dp[i - 1].fi + a[i].fi, dp[i - 1].se + a[i].se};
for (int i = 1; i <= n; i++)
for (int j = i; j < n + i; j++)
dist = smax(dist, get(dp[j].fi - dp[i - 1].fi, dp[j].se - dp[i - 1].se));
cout << fixed << setprecision(10) << dist;
return 0;
}
|
[
"preprocessor.define.value.change",
"literal.integer.change",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 732,365
| 732,366
|
u360501542
|
cpp
|
p02926
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define IFOR(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR((i), 0, (n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T> void print_container(T &container, string delim = " ") {
bool first = true;
for (auto &t : container) {
if (!first) {
cout << delim;
}
first = false;
cout << t;
}
cout << endl;
}
ll dot(pll v1, pll v2) { return v1.first * v2.first + v1.second * v2.second; }
int main() {
int n;
cin >> n;
vector<pll> dat(n);
REP(i, n) { cin >> dat[i].first >> dat[i].second; }
ll maxx = 0;
// ベクトルiに沿って境界線を決める
REP(i, n) {
pll vec = dat[i];
if (vec.first == 0 && vec.second == 0)
continue;
pll vec1 = make_pair(vec.second, -vec.first);
pll vec2 = make_pair(-vec.second, vec.first);
ll num1 = 0, num2 = 0;
pll p1 = {0, 0}, p2 = {0, 0};
REP(j, n) {
ll dot1 = dot(vec1, dat[j]);
ll dot2 = dot(vec2, dat[j]);
if (dot1 > 0 || (dot1 == 0 && dot(dat[i], dat[j]) > 0)) {
p1.first += dat[j].first;
p1.second += dat[j].second;
}
if (dot2 > 0 || (dot2 == 0 && dot(dat[i], dat[j]) > 0)) {
p2.first += dat[j].first;
p2.second += dat[j].second;
}
}
num1 = dot(p1, p1);
num2 = dot(p2, p2);
maxx = max({maxx, num1, num2});
}
printf("%.14f\n", sqrt(maxx));
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define IFOR(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR((i), 0, (n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T> void print_container(T &container, string delim = " ") {
bool first = true;
for (auto &t : container) {
if (!first) {
cout << delim;
}
first = false;
cout << t;
}
cout << endl;
}
ll dot(pll v1, pll v2) { return v1.first * v2.first + v1.second * v2.second; }
int main() {
int n;
cin >> n;
vector<pll> dat(n);
REP(i, n) { cin >> dat[i].first >> dat[i].second; }
ll maxx = 0;
// ベクトルiに沿って境界線を決める
REP(i, n) {
pll vec = dat[i];
if (vec.first == 0 && vec.second == 0)
continue;
pll vec1 = make_pair(vec.second, -vec.first);
pll vec2 = make_pair(-vec.second, vec.first);
ll num1 = 0, num2 = 0;
pll p1 = {0, 0}, p2 = {0, 0};
REP(j, n) {
ll dot1 = dot(vec1, dat[j]);
ll dot2 = dot(vec2, dat[j]);
if (dot1 > 0 || (dot1 == 0 && dot(dat[i], dat[j]) < 0)) {
p1.first += dat[j].first;
p1.second += dat[j].second;
}
if (dot2 > 0 || (dot2 == 0 && dot(dat[i], dat[j]) > 0)) {
p2.first += dat[j].first;
p2.second += dat[j].second;
}
}
num1 = dot(p1, p1);
num2 = dot(p2, p2);
maxx = max({maxx, num1, num2});
}
printf("%.14f\n", sqrt(maxx));
return 0;
}
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 732,376
| 732,377
|
u120810144
|
cpp
|
p02926
|
#include <bits/stdc++.h>
using namespace std;
struct Benri {
Benri() {
std::cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(12);
}
} benri;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353
typedef complex<double> P;
namespace std {
bool operator<(const P &a, const P &b) {
return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
} // namespace std
int main() {
int N;
cin >> N;
vector<pair<double, P>> AP(N); // arg, point
rep(i, N) {
double x, y;
cin >> x >> y;
AP[i].S = P(x, y);
AP[i].F = arg(P(x, y));
}
sort(all(AP));
double ans = 0;
for (int i = 0; i < N; i++) {
for (int j = i; j < N; j++) {
P tmp(0.0, 0.0);
for (int k = i; k <= i + j; k++) {
int l = k % N;
tmp += AP[l].S;
}
ans = max(ans, abs(tmp));
}
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
struct Benri {
Benri() {
std::cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(12);
}
} benri;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353
typedef complex<double> P;
namespace std {
bool operator<(const P &a, const P &b) {
return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
} // namespace std
int main() {
int N;
cin >> N;
vector<pair<double, P>> AP(N); // arg, point
rep(i, N) {
double x, y;
cin >> x >> y;
AP[i].S = P(x, y);
AP[i].F = arg(P(x, y));
}
sort(all(AP));
double ans = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
P tmp(0.0, 0.0);
for (int k = i; k <= i + j; k++) {
int l = k % N;
tmp += AP[l].S;
}
ans = max(ans, abs(tmp));
}
}
cout << ans << endl;
}
|
[
"variable_declaration.value.change",
"identifier.replace.remove",
"literal.replace.add",
"control_flow.loop.for.initializer.change"
] | 732,378
| 732,379
|
u073486874
|
cpp
|
p02926
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i, m, n) for (int i = int(m); i < int(n); i++)
#define all(c) begin(c), end(c)
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
#define MAX_X 100000001
//#define MAX_X 100001
class SegTree {
public:
const int MAX_N = 1 << 17;
int n;
vector<ll> dat;
const ll INITIAL_DAT = 0L;
SegTree(int n_) { init(n_); }
void init(int n_) {
n = 1;
while (n < n_)
n *= 2;
dat = vector<ll>(2 * n);
for (int i = 0; i < 2 * n - 1; ++i)
dat[i] = INITIAL_DAT;
}
//どんなSegTreeを構築するか(デフォルトはRMQ)
ll calc(ll vl, ll vr) { return min(vl, vr); }
// k番目の値(0-indexed)をaに変更
void update(int k, int a) {
k += n - 1;
dat[k] = a;
//登りながら更新
while (k > 0) {
k = (k - 1) / 2;
// dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
dat[k] = calc(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
//[a,b)の最小値を求める
// kは接点の番号,l,rはその接点が[l,r)に対応づいていることを表す。
//したがって、外からはquery(a,b,0,0,n)として呼ぶ。
ll query(int a, int b, int k, int l, int r) {
//[a,b)と[l,r)が交差しなければINITIAL_DAT
if (r <= a || b <= l)
return INITIAL_DAT;
//[a,b)が[l,r)が交差しなければ、INT_MAX
if (a <= l && r <= b)
return dat[k];
else {
//そうでなければ、2つの子に対する処理,デフォルトは最小値
ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return calc(vl, vr);
}
}
//[a,b)の最小値を求める
ll find(int a, int b) { return query(a, b, 0, 0, n); }
};
class Solve {
public:
int N = 0;
vector<Int> X, Y;
void solve() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
Int x, y;
cin >> x >> y;
if (x > 0 || y > 0) {
X.push_back(x);
Y.push_back(y);
N++;
}
}
double ans = 0.0;
vector<int> idxes(N);
for (int i = 0; i < N; ++i) {
idxes[i] = i;
}
sort(all(idxes), [&](int a, int b) {
double A = atan2(X[a], Y[a]);
double B = atan2(X[b], Y[b]);
return A < B;
});
for (int l = 0; l < N; ++l) {
for (int r = 0; r <= N; ++r) {
Int x1 = 0;
Int y1 = 0;
Int x2 = 0;
Int y2 = 0;
for (int i = 0; i < N; ++i) {
if (i >= l && i < r) {
x1 += X[idxes[i]];
y1 += Y[idxes[i]];
} else {
x2 += X[idxes[i]];
y2 += Y[idxes[i]];
}
}
Int tmp = max(x1 * x1 + y1 * y1, x2 * x2 + y2 * y2);
chmax(ans, sqrt(tmp));
}
}
cout << ans << endl;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
Solve().solve();
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i, m, n) for (int i = int(m); i < int(n); i++)
#define all(c) begin(c), end(c)
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
#define MAX_X 100000001
//#define MAX_X 100001
class SegTree {
public:
const int MAX_N = 1 << 17;
int n;
vector<ll> dat;
const ll INITIAL_DAT = 0L;
SegTree(int n_) { init(n_); }
void init(int n_) {
n = 1;
while (n < n_)
n *= 2;
dat = vector<ll>(2 * n);
for (int i = 0; i < 2 * n - 1; ++i)
dat[i] = INITIAL_DAT;
}
//どんなSegTreeを構築するか(デフォルトはRMQ)
ll calc(ll vl, ll vr) { return min(vl, vr); }
// k番目の値(0-indexed)をaに変更
void update(int k, int a) {
k += n - 1;
dat[k] = a;
//登りながら更新
while (k > 0) {
k = (k - 1) / 2;
// dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
dat[k] = calc(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
//[a,b)の最小値を求める
// kは接点の番号,l,rはその接点が[l,r)に対応づいていることを表す。
//したがって、外からはquery(a,b,0,0,n)として呼ぶ。
ll query(int a, int b, int k, int l, int r) {
//[a,b)と[l,r)が交差しなければINITIAL_DAT
if (r <= a || b <= l)
return INITIAL_DAT;
//[a,b)が[l,r)が交差しなければ、INT_MAX
if (a <= l && r <= b)
return dat[k];
else {
//そうでなければ、2つの子に対する処理,デフォルトは最小値
ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return calc(vl, vr);
}
}
//[a,b)の最小値を求める
ll find(int a, int b) { return query(a, b, 0, 0, n); }
};
class Solve {
public:
int N = 0;
vector<Int> X, Y;
void solve() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
Int x, y;
cin >> x >> y;
if (x || y) {
X.push_back(x);
Y.push_back(y);
N++;
}
}
double ans = 0.0;
vector<int> idxes(N);
for (int i = 0; i < N; ++i) {
idxes[i] = i;
}
sort(all(idxes), [&](int a, int b) {
double A = atan2(X[a], Y[a]);
double B = atan2(X[b], Y[b]);
return A < B;
});
for (int l = 0; l < N; ++l) {
for (int r = 0; r < N; ++r) {
Int x1 = 0;
Int y1 = 0;
Int x2 = 0;
Int y2 = 0;
for (int i = 0; i < N; ++i) {
if (i >= l && i <= r) {
x1 += X[idxes[i]];
y1 += Y[idxes[i]];
} else {
x2 += X[idxes[i]];
y2 += Y[idxes[i]];
}
}
Int tmp = max(x1 * x1 + y1 * y1, x2 * x2 + y2 * y2);
chmax(ans, sqrt(tmp));
}
}
cout << ans << endl;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
Solve().solve();
return 0;
}
|
[
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove",
"expression.operator.compare.change",
"expression.off_by_one",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change"
] | 732,384
| 732,385
|
u003873207
|
cpp
|
p02926
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i, m, n) for (int i = int(m); i < int(n); i++)
#define all(c) begin(c), end(c)
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
#define MAX_X 100000001
//#define MAX_X 100001
class SegTree {
public:
const int MAX_N = 1 << 17;
int n;
vector<ll> dat;
const ll INITIAL_DAT = 0L;
SegTree(int n_) { init(n_); }
void init(int n_) {
n = 1;
while (n < n_)
n *= 2;
dat = vector<ll>(2 * n);
for (int i = 0; i < 2 * n - 1; ++i)
dat[i] = INITIAL_DAT;
}
//どんなSegTreeを構築するか(デフォルトはRMQ)
ll calc(ll vl, ll vr) { return min(vl, vr); }
// k番目の値(0-indexed)をaに変更
void update(int k, int a) {
k += n - 1;
dat[k] = a;
//登りながら更新
while (k > 0) {
k = (k - 1) / 2;
// dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
dat[k] = calc(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
//[a,b)の最小値を求める
// kは接点の番号,l,rはその接点が[l,r)に対応づいていることを表す。
//したがって、外からはquery(a,b,0,0,n)として呼ぶ。
ll query(int a, int b, int k, int l, int r) {
//[a,b)と[l,r)が交差しなければINITIAL_DAT
if (r <= a || b <= l)
return INITIAL_DAT;
//[a,b)が[l,r)が交差しなければ、INT_MAX
if (a <= l && r <= b)
return dat[k];
else {
//そうでなければ、2つの子に対する処理,デフォルトは最小値
ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return calc(vl, vr);
}
}
//[a,b)の最小値を求める
ll find(int a, int b) { return query(a, b, 0, 0, n); }
};
class Solve {
public:
int N = 0;
vector<Int> X, Y;
void solve() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
Int x, y;
cin >> x >> y;
if (x > 0 || y > 0) {
X.push_back(x);
Y.push_back(y);
N++;
}
}
double ans = 0.0;
vector<int> idxes(N);
for (int i = 0; i < N; ++i) {
idxes[i] = i;
}
sort(all(idxes), [&](int a, int b) {
double A = atan2(X[a], Y[a]);
double B = atan2(X[b], Y[b]);
return A < B;
});
for (int l = 0; l < N; ++l) {
for (int r = 0; r < N; ++r) {
Int x1 = 0;
Int y1 = 0;
Int x2 = 0;
Int y2 = 0;
for (int i = 0; i < N; ++i) {
if (i >= l && i < r) {
x1 += X[idxes[i]];
y1 += Y[idxes[i]];
} else {
x2 += X[idxes[i]];
y2 += Y[idxes[i]];
}
}
Int tmp = max(x1 * x1 + y1 * y1, x2 * x2 + y2 * y2);
chmax(ans, sqrt(tmp));
}
}
cout << ans << endl;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
Solve().solve();
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i, m, n) for (int i = int(m); i < int(n); i++)
#define all(c) begin(c), end(c)
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
#define MAX_X 100000001
//#define MAX_X 100001
class SegTree {
public:
const int MAX_N = 1 << 17;
int n;
vector<ll> dat;
const ll INITIAL_DAT = 0L;
SegTree(int n_) { init(n_); }
void init(int n_) {
n = 1;
while (n < n_)
n *= 2;
dat = vector<ll>(2 * n);
for (int i = 0; i < 2 * n - 1; ++i)
dat[i] = INITIAL_DAT;
}
//どんなSegTreeを構築するか(デフォルトはRMQ)
ll calc(ll vl, ll vr) { return min(vl, vr); }
// k番目の値(0-indexed)をaに変更
void update(int k, int a) {
k += n - 1;
dat[k] = a;
//登りながら更新
while (k > 0) {
k = (k - 1) / 2;
// dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
dat[k] = calc(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
//[a,b)の最小値を求める
// kは接点の番号,l,rはその接点が[l,r)に対応づいていることを表す。
//したがって、外からはquery(a,b,0,0,n)として呼ぶ。
ll query(int a, int b, int k, int l, int r) {
//[a,b)と[l,r)が交差しなければINITIAL_DAT
if (r <= a || b <= l)
return INITIAL_DAT;
//[a,b)が[l,r)が交差しなければ、INT_MAX
if (a <= l && r <= b)
return dat[k];
else {
//そうでなければ、2つの子に対する処理,デフォルトは最小値
ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return calc(vl, vr);
}
}
//[a,b)の最小値を求める
ll find(int a, int b) { return query(a, b, 0, 0, n); }
};
class Solve {
public:
int N = 0;
vector<Int> X, Y;
void solve() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
Int x, y;
cin >> x >> y;
if (x || y) {
X.push_back(x);
Y.push_back(y);
N++;
}
}
double ans = 0.0;
vector<int> idxes(N);
for (int i = 0; i < N; ++i) {
idxes[i] = i;
}
sort(all(idxes), [&](int a, int b) {
double A = atan2(X[a], Y[a]);
double B = atan2(X[b], Y[b]);
return A < B;
});
for (int l = 0; l < N; ++l) {
for (int r = 0; r < N; ++r) {
Int x1 = 0;
Int y1 = 0;
Int x2 = 0;
Int y2 = 0;
for (int i = 0; i < N; ++i) {
if (i >= l && i <= r) {
x1 += X[idxes[i]];
y1 += Y[idxes[i]];
} else {
x2 += X[idxes[i]];
y2 += Y[idxes[i]];
}
}
Int tmp = max(x1 * x1 + y1 * y1, x2 * x2 + y2 * y2);
chmax(ans, sqrt(tmp));
}
}
cout << ans << endl;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
Solve().solve();
return 0;
}
|
[
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 732,386
| 732,385
|
u003873207
|
cpp
|
p02926
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i, m, n) for (int i = int(m); i < int(n); i++)
#define all(c) begin(c), end(c)
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
#define MAX_X 100000001
//#define MAX_X 100001
class SegTree {
public:
const int MAX_N = 1 << 17;
int n;
vector<ll> dat;
const ll INITIAL_DAT = 0L;
SegTree(int n_) { init(n_); }
void init(int n_) {
n = 1;
while (n < n_)
n *= 2;
dat = vector<ll>(2 * n);
for (int i = 0; i < 2 * n - 1; ++i)
dat[i] = INITIAL_DAT;
}
//どんなSegTreeを構築するか(デフォルトはRMQ)
ll calc(ll vl, ll vr) { return min(vl, vr); }
// k番目の値(0-indexed)をaに変更
void update(int k, int a) {
k += n - 1;
dat[k] = a;
//登りながら更新
while (k > 0) {
k = (k - 1) / 2;
// dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
dat[k] = calc(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
//[a,b)の最小値を求める
// kは接点の番号,l,rはその接点が[l,r)に対応づいていることを表す。
//したがって、外からはquery(a,b,0,0,n)として呼ぶ。
ll query(int a, int b, int k, int l, int r) {
//[a,b)と[l,r)が交差しなければINITIAL_DAT
if (r <= a || b <= l)
return INITIAL_DAT;
//[a,b)が[l,r)が交差しなければ、INT_MAX
if (a <= l && r <= b)
return dat[k];
else {
//そうでなければ、2つの子に対する処理,デフォルトは最小値
ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return calc(vl, vr);
}
}
//[a,b)の最小値を求める
ll find(int a, int b) { return query(a, b, 0, 0, n); }
};
class Solve {
public:
int N = 0;
vector<Int> X, Y;
void solve() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
Int x, y;
cin >> x >> y;
if (x > 0 || y > 0) {
X.push_back(x);
Y.push_back(y);
N++;
}
}
double ans = 0.0;
vector<int> idxes(N);
for (int i = 0; i < N; ++i) {
idxes[i] = i;
}
sort(all(idxes), [&](int a, int b) {
double A = atan2(X[a], Y[a]);
double B = atan2(X[b], Y[b]);
return A < B;
});
for (int l = 0; l < N; ++l) {
for (int r = 0; r < N; ++r) {
Int x1 = 0;
Int y1 = 0;
Int x2 = 0;
Int y2 = 0;
for (int i = 0; i < N; ++i) {
if (i >= l && i <= r) {
x1 += X[idxes[i]];
y1 += Y[idxes[i]];
} else {
x2 += X[idxes[i]];
y2 += Y[idxes[i]];
}
}
Int tmp = max(x1 * x1 + y1 * y1, x2 * x2 + y2 * y2);
chmax(ans, sqrt(tmp));
}
}
cout << ans << endl;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
Solve().solve();
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i, m, n) for (int i = int(m); i < int(n); i++)
#define all(c) begin(c), end(c)
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
#define MAX_X 100000001
//#define MAX_X 100001
class SegTree {
public:
const int MAX_N = 1 << 17;
int n;
vector<ll> dat;
const ll INITIAL_DAT = 0L;
SegTree(int n_) { init(n_); }
void init(int n_) {
n = 1;
while (n < n_)
n *= 2;
dat = vector<ll>(2 * n);
for (int i = 0; i < 2 * n - 1; ++i)
dat[i] = INITIAL_DAT;
}
//どんなSegTreeを構築するか(デフォルトはRMQ)
ll calc(ll vl, ll vr) { return min(vl, vr); }
// k番目の値(0-indexed)をaに変更
void update(int k, int a) {
k += n - 1;
dat[k] = a;
//登りながら更新
while (k > 0) {
k = (k - 1) / 2;
// dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
dat[k] = calc(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
//[a,b)の最小値を求める
// kは接点の番号,l,rはその接点が[l,r)に対応づいていることを表す。
//したがって、外からはquery(a,b,0,0,n)として呼ぶ。
ll query(int a, int b, int k, int l, int r) {
//[a,b)と[l,r)が交差しなければINITIAL_DAT
if (r <= a || b <= l)
return INITIAL_DAT;
//[a,b)が[l,r)が交差しなければ、INT_MAX
if (a <= l && r <= b)
return dat[k];
else {
//そうでなければ、2つの子に対する処理,デフォルトは最小値
ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return calc(vl, vr);
}
}
//[a,b)の最小値を求める
ll find(int a, int b) { return query(a, b, 0, 0, n); }
};
class Solve {
public:
int N = 0;
vector<Int> X, Y;
void solve() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
Int x, y;
cin >> x >> y;
if (x || y) {
X.push_back(x);
Y.push_back(y);
N++;
}
}
double ans = 0.0;
vector<int> idxes(N);
for (int i = 0; i < N; ++i) {
idxes[i] = i;
}
sort(all(idxes), [&](int a, int b) {
double A = atan2(X[a], Y[a]);
double B = atan2(X[b], Y[b]);
return A < B;
});
for (int l = 0; l < N; ++l) {
for (int r = 0; r < N; ++r) {
Int x1 = 0;
Int y1 = 0;
Int x2 = 0;
Int y2 = 0;
for (int i = 0; i < N; ++i) {
if (i >= l && i <= r) {
x1 += X[idxes[i]];
y1 += Y[idxes[i]];
} else {
x2 += X[idxes[i]];
y2 += Y[idxes[i]];
}
}
Int tmp = max(x1 * x1 + y1 * y1, x2 * x2 + y2 * y2);
chmax(ans, sqrt(tmp));
}
}
cout << ans << endl;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
Solve().solve();
return 0;
}
|
[
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 732,387
| 732,385
|
u003873207
|
cpp
|
p02926
|
/* _
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||_ \
| | \\\ - /'| | |
| \_| `\`---'// |_/ |
\ .-\__ `-. -'__/-. /
___`. .' /--.--\ `. .'___
."" '< `.___\_<|>_/___.' _> \"".
| | : `- \`. ;`. _/; .'/ / .' ; |
\ \ `-. \_\_`. _.'_/_/ -' _.' /
===========`-.`___`-.__\ \___ /__.-'_.'_.-'================
Please give me AC.
*/
#define pi 3.14159265358979323846264338327950288
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) \
rep(i, (v).size() - 1) cout << (v)[i] << ' '; \
cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) \
cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) \
cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " \
<< (z) << '\n'
#define dbg(v) \
for (size_t _ = 0; _ < v.size(); ++_) { \
cerr << #v << "[" << _ << "] : " << v[_] << '\n'; \
}
// constant
const int INF = (1 << 30) - 1;
const int64 INF64 = (1LL << 62) - 1;
// End of template.
int64 sq(int64 x) { return x * x; }
struct vec {
int64 x;
int64 y;
double r;
double t;
};
int main() {
cout << fixed << setprecision(15);
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
vec v[210];
cin >> n;
rep(i, n) {
cin >> v[i].x >> v[i].y;
v[i].r = sqrt(sq(v[i].x) + sq(v[i].y));
if (v[i].x == 0 && v[i].y == 0)
v[i].t = 0.0;
else
v[i].t = atan2(v[i].x, v[i].y);
}
sort(begin(v), begin(v) + n, [](vec a, vec b) { return a.r < b.r; });
copy(begin(v), begin(v) + n, begin(v) + n);
rep(i, n) v[n + i].r = v[i].r + 2.0 * pi;
double temp = 0.0;
int64 xsum[210];
int64 ysum[210];
xsum[0] = ysum[0] = 0;
rep(i, 2 * n) xsum[i + 1] = xsum[i] + v[i + 1].x;
rep(i, 2 * n) ysum[i + 1] = ysum[i] + v[i + 1].y;
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < 2 * n && j - i <= n; ++j) {
double r = sqrt(sq(xsum[j] - xsum[i]) + sq(ysum[j] - ysum[i]));
if (temp < r)
temp = r;
}
}
print(temp);
return 0;
}
|
/* _
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||_ \
| | \\\ - /'| | |
| \_| `\`---'// |_/ |
\ .-\__ `-. -'__/-. /
___`. .' /--.--\ `. .'___
."" '< `.___\_<|>_/___.' _> \"".
| | : `- \`. ;`. _/; .'/ / .' ; |
\ \ `-. \_\_`. _.'_/_/ -' _.' /
===========`-.`___`-.__\ \___ /__.-'_.'_.-'================
Please give me AC.
*/
#define pi 3.14159265358979323846264338327950288
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) \
rep(i, (v).size() - 1) cout << (v)[i] << ' '; \
cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) \
cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) \
cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " \
<< (z) << '\n'
#define dbg(v) \
for (size_t _ = 0; _ < v.size(); ++_) { \
cerr << #v << "[" << _ << "] : " << v[_] << '\n'; \
}
// constant
const int INF = (1 << 30) - 1;
const int64 INF64 = (1LL << 62) - 1;
// End of template.
int64 sq(int64 x) { return x * x; }
struct vec {
int64 x;
int64 y;
double r;
double t;
};
int main() {
cout << fixed << setprecision(15);
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
vec v[210];
cin >> n;
rep(i, n) {
cin >> v[i].x >> v[i].y;
v[i].r = sqrt(sq(v[i].x) + sq(v[i].y));
if (v[i].x == 0 && v[i].y == 0)
v[i].t = 0.0;
else
v[i].t = atan2(v[i].x, v[i].y);
}
sort(begin(v), begin(v) + n, [](vec a, vec b) { return a.t < b.t; });
copy(begin(v), begin(v) + n, begin(v) + n);
rep(i, n) v[n + i].r = v[i].r + 2.0 * pi;
double temp = 0.0;
int64 xsum[210];
int64 ysum[210];
xsum[0] = ysum[0] = 0;
rep(i, 2 * n) xsum[i + 1] = xsum[i] + v[i + 1].x;
rep(i, 2 * n) ysum[i + 1] = ysum[i] + v[i + 1].y;
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j <= 2 * n && j - i <= n; ++j) {
double r = sqrt(sq(xsum[j] - xsum[i]) + sq(ysum[j] - ysum[i]));
if (temp < r)
temp = r;
}
}
print(temp);
return 0;
}
|
[
"call.arguments.change",
"function.return_value.change",
"expression.operation.binary.change",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one"
] | 732,388
| 732,389
|
u061984624
|
cpp
|
p02926
|
/* _
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||_ \
| | \\\ - /'| | |
| \_| `\`---'// |_/ |
\ .-\__ `-. -'__/-. /
___`. .' /--.--\ `. .'___
."" '< `.___\_<|>_/___.' _> \"".
| | : `- \`. ;`. _/; .'/ / .' ; |
\ \ `-. \_\_`. _.'_/_/ -' _.' /
===========`-.`___`-.__\ \___ /__.-'_.'_.-'================
Please give me AC.
*/
#define pi 3.14159265358979323846264338327950288
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) \
rep(i, (v).size() - 1) cout << (v)[i] << ' '; \
cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) \
cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) \
cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " \
<< (z) << '\n'
#define dbg(v) \
for (size_t _ = 0; _ < v.size(); ++_) { \
cerr << #v << "[" << _ << "] : " << v[_] << '\n'; \
}
// constant
const int INF = (1 << 30) - 1;
const int64 INF64 = (1LL << 62) - 1;
// End of template.
int64 sq(int64 x) { return x * x; }
struct vec {
int64 x;
int64 y;
double r;
double t;
};
int main() {
cout << fixed << setprecision(15);
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
vec v[210];
cin >> n;
rep(i, n) {
cin >> v[i].x >> v[i].y;
v[i].r = sqrt(sq(v[i].x) + sq(v[i].y));
if (v[i].x == 0 && v[i].y == 0)
v[i].t = 0.0;
else
v[i].t = atan2(v[i].x, v[i].y);
}
sort(begin(v), begin(v) + n, [](vec a, vec b) { return a.r < b.r; });
copy(begin(v), begin(v) + n, begin(v) + n);
rep(i, n) v[n + i].r = v[i].r + 2.0 * pi;
double temp = 0.0;
int xsum[210];
int ysum[210];
xsum[0] = ysum[0] = 0;
rep(i, 2 * n) xsum[i + 1] = xsum[i] + v[i + 1].x;
rep(i, 2 * n) ysum[i + 1] = ysum[i] + v[i + 1].y;
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < 2 * n && j - i <= n; ++j) {
double r = sqrt(sq(xsum[j] - xsum[i]) + sq(ysum[j] - ysum[i]));
if (temp < r)
temp = r;
}
}
print(temp);
return 0;
}
|
/* _
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||_ \
| | \\\ - /'| | |
| \_| `\`---'// |_/ |
\ .-\__ `-. -'__/-. /
___`. .' /--.--\ `. .'___
."" '< `.___\_<|>_/___.' _> \"".
| | : `- \`. ;`. _/; .'/ / .' ; |
\ \ `-. \_\_`. _.'_/_/ -' _.' /
===========`-.`___`-.__\ \___ /__.-'_.'_.-'================
Please give me AC.
*/
#define pi 3.14159265358979323846264338327950288
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) \
rep(i, (v).size() - 1) cout << (v)[i] << ' '; \
cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) \
cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) \
cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " \
<< (z) << '\n'
#define dbg(v) \
for (size_t _ = 0; _ < v.size(); ++_) { \
cerr << #v << "[" << _ << "] : " << v[_] << '\n'; \
}
// constant
const int INF = (1 << 30) - 1;
const int64 INF64 = (1LL << 62) - 1;
// End of template.
int64 sq(int64 x) { return x * x; }
struct vec {
int64 x;
int64 y;
double r;
double t;
};
int main() {
cout << fixed << setprecision(15);
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
vec v[210];
cin >> n;
rep(i, n) {
cin >> v[i].x >> v[i].y;
v[i].r = sqrt(sq(v[i].x) + sq(v[i].y));
if (v[i].x == 0 && v[i].y == 0)
v[i].t = 0.0;
else
v[i].t = atan2(v[i].x, v[i].y);
}
sort(begin(v), begin(v) + n, [](vec a, vec b) { return a.t < b.t; });
copy(begin(v), begin(v) + n, begin(v) + n);
rep(i, n) v[n + i].r = v[i].r + 2.0 * pi;
double temp = 0.0;
int64 xsum[210];
int64 ysum[210];
xsum[0] = ysum[0] = 0;
rep(i, 2 * n) xsum[i + 1] = xsum[i] + v[i + 1].x;
rep(i, 2 * n) ysum[i + 1] = ysum[i] + v[i + 1].y;
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j <= 2 * n && j - i <= n; ++j) {
double r = sqrt(sq(xsum[j] - xsum[i]) + sq(ysum[j] - ysum[i]));
if (temp < r)
temp = r;
}
}
print(temp);
return 0;
}
|
[
"call.arguments.change",
"function.return_value.change",
"expression.operation.binary.change",
"variable_declaration.type.change",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one"
] | 732,390
| 732,389
|
u061984624
|
cpp
|
p02926
|
// Created by AboAbdoMC
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define db1(x) cout << #x << "=" << x << '\n'
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define db3(x, y, z) \
cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
<< '\n'
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
indexed_set;
const int OO = 1e9 + 7;
const int MOD = 1e9 + 7;
const int N = 1e2 + 7;
double x[N], y[N];
int n;
double f() {
vector<pair<double, double>> vec;
vec.pb({0, 0});
rep(i, n) {
vector<pair<double, double>> vec2;
for (auto p : vec) {
vec2.pb(p);
vec2.pb({p.f + x[i], p.s + y[i]});
}
sort(vec2.begin(), vec2.end());
reverse(vec2.begin(), vec2.end());
vec.clear();
for (auto p : vec2) {
if (vec.size() == 0 || p.f > vec2[vec2.size() - 1].f ||
p.s > vec2[vec2.size() - 1].s)
vec.pb(p);
}
}
double ret = 0;
for (auto p : vec)
ret = max(ret, sqrt(p.f * p.f + p.s * p.s));
return ret;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
rep(i, n) cin >> x[i] >> y[i];
double ans = f();
rep(i, n) x[i] *= -1;
ans = max(ans, f());
rep(i, n) y[i] *= -1;
ans = max(ans, f());
rep(i, n) x[i] *= -1;
ans = max(ans, f());
cout << fixed << setprecision(10);
cout << ans << '\n';
return 0;
}
|
// Created by AboAbdoMC
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define db1(x) cout << #x << "=" << x << '\n'
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define db3(x, y, z) \
cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
<< '\n'
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
indexed_set;
const int OO = 1e9 + 7;
const int MOD = 1e9 + 7;
const int N = 1e2 + 7;
double x[N], y[N];
int n;
double f() {
vector<pair<double, double>> vec;
vec.pb({0, 0});
rep(i, n) {
vector<pair<double, double>> vec2;
for (auto p : vec) {
vec2.pb(p);
vec2.pb({p.f + x[i], p.s + y[i]});
}
sort(vec2.begin(), vec2.end());
reverse(vec2.begin(), vec2.end());
vec.clear();
for (auto p : vec2) {
if (vec.size() == 0 || p.f > vec[vec.size() - 1].f ||
p.s > vec[vec.size() - 1].s)
vec.pb(p);
}
}
double ret = 0;
for (auto p : vec)
ret = max(ret, sqrt(p.f * p.f + p.s * p.s));
return ret;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
rep(i, n) cin >> x[i] >> y[i];
double ans = f();
rep(i, n) x[i] *= -1;
ans = max(ans, f());
rep(i, n) y[i] *= -1;
ans = max(ans, f());
rep(i, n) x[i] *= -1;
ans = max(ans, f());
cout << fixed << setprecision(10);
cout << ans << '\n';
return 0;
}
|
[
"identifier.change",
"control_flow.branch.if.condition.change",
"variable_access.subscript.index.change",
"call.function.change"
] | 732,391
| 732,392
|
u216673135
|
cpp
|
p02926
|
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<pair<int, int>> v;
int n;
cin >> n;
int x, y;
for (int i = 0; i < n; ++i) {
cin >> x >> y;
if (x != 0 || y != 0)
v.emplace_back(x, y);
}
sort(v.begin(), v.end(), [&](auto &p, auto &q) {
return atan2(p.second, p.first) < atan2(q.second, q.first);
});
n = v.size();
v.insert(v.end(), v.begin(), v.end());
int ans = 0;
for (int i = 0; i < n; ++i) {
x = 0;
y = 0;
for (int j = i; j < n + i; ++j) {
x += v[j].first;
y += v[j].second;
ans = max(ans, x * x + y * y);
}
}
cout << setprecision(16) << sqrt(ans) << '\n';
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<pair<int, int>> v;
int n;
cin >> n;
long long x, y;
for (int i = 0; i < n; ++i) {
cin >> x >> y;
if (x != 0 || y != 0)
v.emplace_back(x, y);
}
sort(v.begin(), v.end(), [&](auto &p, auto &q) {
return atan2(p.second, p.first) < atan2(q.second, q.first);
});
n = v.size();
v.insert(v.end(), v.begin(), v.end());
long long ans = 0;
for (int i = 0; i < n; ++i) {
x = 0;
y = 0;
for (int j = i; j < n + i; ++j) {
x += v[j].first;
y += v[j].second;
ans = max(ans, x * x + y * y);
}
}
cout << setprecision(16) << sqrt(ans) << '\n';
return 0;
}
|
[
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 732,393
| 732,394
|
u021107862
|
cpp
|
p02930
|
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++) {
int tmp = (i ^ j);
int ans = 0;
while (tmp) {
ans++;
tmp >>= 1;
}
printf("%d%c", ans, j == n ? '\n' : ' ');
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) {
int tmp = (i ^ j);
int ans = 0;
while (tmp) {
ans++;
tmp >>= 1;
}
printf("%d%c", ans, j == n - 1 ? '\n' : ' ');
}
return 0;
}
|
[
"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",
"misc.off_by_one"
] | 732,407
| 732,408
|
u276450837
|
cpp
|
p02930
|
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
template <class T> void byebye(T _rpl) {
cout << _rpl << endl;
exit(0);
}
int nextint() {
int x;
scanf("%d", &x);
return x;
}
ll nextll() {
ll x;
scanf("%lld", &x);
return x;
}
int read() {
int f = 1, ret = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
ret = ret * 10 + (c - '0');
c = getchar();
}
return ret * f;
}
int p[505][505];
int col[505];
int n, cnt;
void construct(int l, int r, int x) {
if (l >= r || l + 1 == r)
return;
int mid = l + r >> 1;
for (int i = l; i < mid; ++i) {
for (int j = mid; j < r; ++j)
p[i][j] = x;
}
construct(l, mid, x + 1);
construct(mid, r, x + 1);
}
int main() {
n = read();
construct(0, n, 0);
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
printf("%d ", p[i][j]);
}
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
template <class T> void byebye(T _rpl) {
cout << _rpl << endl;
exit(0);
}
int nextint() {
int x;
scanf("%d", &x);
return x;
}
ll nextll() {
ll x;
scanf("%lld", &x);
return x;
}
int read() {
int f = 1, ret = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
ret = ret * 10 + (c - '0');
c = getchar();
}
return ret * f;
}
int p[505][505];
int col[505];
int n, cnt;
void construct(int l, int r, int x) {
if (l >= r || l + 1 == r)
return;
int mid = l + r >> 1;
for (int i = l; i < mid; ++i) {
for (int j = mid; j < r; ++j)
p[i][j] = x;
}
construct(l, mid, x + 1);
construct(mid, r, x + 1);
}
int main() {
n = read();
construct(0, n, 1);
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
printf("%d ", p[i][j]);
}
puts("");
}
return 0;
}
|
[
"literal.number.change",
"call.arguments.change"
] | 732,427
| 732,428
|
u796167342
|
cpp
|
p02930
|
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
int main() {
int n;
cin >> n;
vector<int> v(500, 0);
for (int i = 0; i < 500; i += 2) {
v[i] = 1;
}
for (int i = 1; i < 500; i += 4) {
v[i] = 2;
}
for (int i = 3; i < 500; i += 8) {
v[i] = 3;
}
for (int i = 7; i < 500; i += 16) {
v[i] = 4;
}
for (int i = 15; i < 500; i += 32) {
v[i] = 5;
}
for (int i = 31; i < 500; i += 64) {
v[i] = 6;
}
for (int i = 63; i < 500; i += 128) {
v[i] = 7;
}
for (int i = 127; i < 500; i += 256) {
v[i] = 8;
}
for (int i = 255; i < 500; i += 512) {
v[i] = 9;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i; j++) {
cout << v[j] << " ";
}
cout << endl;
}
}
|
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
int main() {
int n;
cin >> n;
n--;
vector<int> v(500, 0);
for (int i = 0; i < 500; i += 2) {
v[i] = 1;
}
for (int i = 1; i < 500; i += 4) {
v[i] = 2;
}
for (int i = 3; i < 500; i += 8) {
v[i] = 3;
}
for (int i = 7; i < 500; i += 16) {
v[i] = 4;
}
for (int i = 15; i < 500; i += 32) {
v[i] = 5;
}
for (int i = 31; i < 500; i += 64) {
v[i] = 6;
}
for (int i = 63; i < 500; i += 128) {
v[i] = 7;
}
for (int i = 127; i < 500; i += 256) {
v[i] = 8;
}
for (int i = 255; i < 500; i += 512) {
v[i] = 9;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i; j++) {
cout << v[j] << " ";
}
cout << endl;
}
}
|
[
"expression.unary.arithmetic.add"
] | 732,431
| 732,432
|
u928536113
|
cpp
|
p02930
|
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i, s, n) for (int i = (s); (n) > i; i++)
#define REP(i, n) rep(i, 0, n)
#define RANGE(x, a, b) (min(a, b) <= (x) && (x) <= max(a, b)) // hei
#define DUPLE(a, b, c, d) \
(RANGE(a, c, d) || RANGE(b, c, d) || RANGE(c, a, b) || RANGE(d, a, b))
#define INCLU(a, b, c, d) (RANGE(a, c, d) && (b, c, d))
#define PW(x) ((x) * (x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a, b) ((a >> b) & 1)
#define bitset(a, b) (a |= (1 << b))
#define bitunset(a, b) (a &= ~(1 << b))
#define MP(a, b) make_pair((a), (b))
#define Manh(a, b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
pll Dir[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
//[a, b)
#define Getsum(ar, a, b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
struct Edge {
int from, to;
ll w;
bool operator<(const Edge &rhs) const {
return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
}
};
int ans[501][501] = {};
void func(int l, int r, int level) {
if (r - l <= 2)
return;
int mid = (l + r) / 2;
rep(i, l, mid) {
rep(j, mid, r) { ans[i][j] = level; }
}
func(l, mid, level + 1);
func(mid, r, level + 1);
}
signed main(void) {
int n;
cin >> n;
func(0, n, 0);
REP(i, n) {
rep(j, i + 1, n) { printf("%d ", ans[i][j]); }
printf("\n");
}
return 0;
}
|
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i, s, n) for (int i = (s); (n) > i; i++)
#define REP(i, n) rep(i, 0, n)
#define RANGE(x, a, b) (min(a, b) <= (x) && (x) <= max(a, b)) // hei
#define DUPLE(a, b, c, d) \
(RANGE(a, c, d) || RANGE(b, c, d) || RANGE(c, a, b) || RANGE(d, a, b))
#define INCLU(a, b, c, d) (RANGE(a, c, d) && (b, c, d))
#define PW(x) ((x) * (x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a, b) ((a >> b) & 1)
#define bitset(a, b) (a |= (1 << b))
#define bitunset(a, b) (a &= ~(1 << b))
#define MP(a, b) make_pair((a), (b))
#define Manh(a, b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
pll Dir[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
//[a, b)
#define Getsum(ar, a, b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
struct Edge {
int from, to;
ll w;
bool operator<(const Edge &rhs) const {
return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
}
};
int ans[501][501] = {};
void func(int l, int r, int level) {
if (r - l <= 1)
return;
int mid = (l + r) / 2;
rep(i, l, mid) {
rep(j, mid, r) { ans[i][j] = level; }
}
func(l, mid, level + 1);
func(mid, r, level + 1);
}
signed main(void) {
int n;
cin >> n;
func(0, n, 1);
REP(i, n) {
rep(j, i + 1, n) { printf("%d ", ans[i][j]); }
printf("\n");
}
return 0;
}
|
[
"literal.number.change",
"control_flow.branch.if.condition.change",
"call.arguments.change"
] | 732,449
| 732,450
|
u152129372
|
cpp
|
p02930
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; i++) {
for (int l = 0;; l++) {
if ((i ^ j) && 1 << l) {
if (j)
cout << ' ';
cout << l + 1;
break;
}
}
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
for (int l = 0;; l++) {
if ((i ^ j) & 1 << l) {
if (j)
cout << ' ';
cout << l + 1;
break;
}
}
}
cout << endl;
}
}
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 732,465
| 732,464
|
u946322619
|
cpp
|
p02930
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define double long double
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define VECCIN(x) \
for (auto &youso_ : (x)) \
cin >> youso_
#define bitcnt(x) __builtin_popcount(x)
#define lbit(x) __builtin_ffsll(x)
#define rbit(x) __builtin_clzll(x)
#define SZ(x) ((long long)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
#define cinfast() cin.tie(0), ios::sync_with_stdio(false)
#define PERM(c) \
sort(All(c)); \
for (bool cp = true; cp; cp = next_permutation(All(c)))
#define MKORDER(n) \
vector<int> od(n); \
iota(All(od), 0LL);
template <typename T = long long> inline T IN() {
T x;
cin >> x;
return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&...tail) {
cin >> head;
CIN(move(tail)...);
}
#define CCIN(...) \
char __VA_ARGS__; \
CIN(__VA_ARGS__)
#define DCIN(...) \
double __VA_ARGS__; \
CIN(__VA_ARGS__)
#define LCIN(...) \
long long __VA_ARGS__; \
CIN(__VA_ARGS__)
#define SCIN(...) \
string __VA_ARGS__; \
CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v) \
{ \
FOREACH(x, v) { cout << x << " "; } \
cout << "\n"; \
}
template <typename T = string> inline void eputs(T s) {
cout << s << "\n";
exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const double PI = atan(1.0) * 4.0;
const ll dw[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dh[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238
signed main() {
LCIN(N);
VVL ans(N, VL(N));
function<void(ll, ll, ll)> dfs = [&](ll l, ll r, ll d) {
if (r - l <= 0)
return;
ll mid = (r + l) / 2;
FOR(i, l, mid) FOR(j, mid, r) { ans[i][j] = d; }
dfs(l, mid, d + 1);
dfs(mid, r, d + 1);
};
dfs(0, N, 1);
REP(i, N) FOR(j, i + 1, N) { cout << ans[i][j] << (j == N - 1 ? "\n" : " "); }
}
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define double long double
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define VECCIN(x) \
for (auto &youso_ : (x)) \
cin >> youso_
#define bitcnt(x) __builtin_popcount(x)
#define lbit(x) __builtin_ffsll(x)
#define rbit(x) __builtin_clzll(x)
#define SZ(x) ((long long)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
#define cinfast() cin.tie(0), ios::sync_with_stdio(false)
#define PERM(c) \
sort(All(c)); \
for (bool cp = true; cp; cp = next_permutation(All(c)))
#define MKORDER(n) \
vector<int> od(n); \
iota(All(od), 0LL);
template <typename T = long long> inline T IN() {
T x;
cin >> x;
return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&...tail) {
cin >> head;
CIN(move(tail)...);
}
#define CCIN(...) \
char __VA_ARGS__; \
CIN(__VA_ARGS__)
#define DCIN(...) \
double __VA_ARGS__; \
CIN(__VA_ARGS__)
#define LCIN(...) \
long long __VA_ARGS__; \
CIN(__VA_ARGS__)
#define SCIN(...) \
string __VA_ARGS__; \
CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v) \
{ \
FOREACH(x, v) { cout << x << " "; } \
cout << "\n"; \
}
template <typename T = string> inline void eputs(T s) {
cout << s << "\n";
exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const double PI = atan(1.0) * 4.0;
const ll dw[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dh[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238
signed main() {
LCIN(N);
VVL ans(N, VL(N));
function<void(ll, ll, ll)> dfs = [&](ll l, ll r, ll d) {
if (r - l <= 1)
return;
ll mid = (r + l) / 2;
FOR(i, l, mid) FOR(j, mid, r) { ans[i][j] = d; }
dfs(l, mid, d + 1);
dfs(mid, r, d + 1);
};
dfs(0, N, 1);
REP(i, N) FOR(j, i + 1, N) { cout << ans[i][j] << (j == N - 1 ? "\n" : " "); }
}
|
[
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 732,466
| 732,467
|
u139031151
|
cpp
|
p02930
|
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int main() {
int N;
scanf("%d", &N);
for (int i = 1; i <= N; i++) {
for (int j = i + 1; j <= N; j++) {
int ans = 0, tmp = (i ^ j);
while (tmp) {
ans++;
tmp >>= 1;
}
printf("%d ", ans);
}
puts("");
}
return 0;
}
|
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int main() {
int N;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
int ans = 0, tmp = (i ^ j);
while (tmp) {
ans++;
tmp >>= 1;
}
printf("%d ", ans);
}
puts("");
}
return 0;
}
|
[
"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"
] | 732,468
| 732,469
|
u004342119
|
cpp
|
p02930
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <ciso646>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf = 1e9 + 7;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(), c.end()
#define pb push_back
#define debug(x) cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int>>;
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;
}
//#define int long long
// bitを見てもok
//構築は2の塁乗多い?(二部グラフだからか)
//奇閉路無し は 2部グラフ
//二部グラフで、分割統治(再帰利用で実装)
int n;
vector<vector<int>> res;
void rec(int left, int right, int v) {
//半開区間 [l, r) の利用
if (right - left <= 1)
return;
int mid = (left + right) / 2;
rec(left, mid, v + 1);
rec(mid, right, v + 1);
for (int i = left; i < mid; i++) {
for (int j = mid; j < right; j++) {
res[i][j] = v;
}
}
}
void solve() {
res.assign(n, vector<int>(n, -1));
rec(0, n, 1);
rep(i, n) {
for (int j = i + 1; j < n; j++) {
cout << res[i][j] << " ";
}
cout << endl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
// cout << fixed << setprecision(10);
// init();
solve();
// cout << "finish" << endl;
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <ciso646>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf = 1e9 + 7;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(), c.end()
#define pb push_back
#define debug(x) cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int>>;
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;
}
//#define int long long
// bitを見てもok
//構築は2の塁乗多い?(二部グラフだからか)
//奇閉路無し は 2部グラフ
//二部グラフで、分割統治(再帰利用で実装)
int n;
vector<vector<int>> res;
void rec(int left, int right, int v) {
//半開区間 [l, r) の利用
if (right - left <= 1)
return;
int mid = (left + right) / 2;
rec(left, mid, v + 1);
rec(mid, right, v + 1);
for (int i = left; i < mid; i++) {
for (int j = mid; j < right; j++) {
res[i][j] = v;
}
}
}
void solve() {
cin >> n;
res.assign(n, vector<int>(n, 1));
rec(0, n, 1);
rep(i, n) {
for (int j = i + 1; j < n; j++) {
cout << res[i][j] << " ";
}
cout << endl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
// cout << fixed << setprecision(10);
// init();
solve();
// cout << "finish" << endl;
return 0;
}
|
[
"expression.operation.unary.arithmetic.remove"
] | 732,476
| 732,477
|
u508571192
|
cpp
|
p02930
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
const int mod = 1000000007, MAX = 200003, INF = 1 << 30;
int main() {
int N;
cin >> N;
N--;
int ans, maxi;
for (int i = 29; i >= 0; i--) {
if (N & (1 << i)) {
ans = i;
maxi = (1 << (i + 1));
break;
}
}
vector<vector<int>> S(maxi, vector<int>(maxi, 0));
for (int k = 0; k < ans; k++) {
for (int i = 0; i < maxi; i++) {
for (int j = 0; j < maxi; j++) {
if ((i & (1 << k)) != (j & (1 << k)))
S[i][j] = k + 1;
}
}
}
for (int i = 0; i <= N - 1; i++) {
for (int j = i + 1; j <= N; j++) {
cout << S[i][j] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
const int mod = 1000000007, MAX = 200003, INF = 1 << 30;
int main() {
int N;
cin >> N;
N--;
int ans, maxi;
for (int i = 29; i >= 0; i--) {
if (N & (1 << i)) {
ans = i;
maxi = (1 << (i + 1));
break;
}
}
vector<vector<int>> S(maxi, vector<int>(maxi, 0));
for (int k = 0; k <= ans; k++) {
for (int i = 0; i < maxi; i++) {
for (int j = 0; j < maxi; j++) {
if ((i & (1 << k)) != (j & (1 << k)))
S[i][j] = k + 1;
}
}
}
for (int i = 0; i <= N - 1; i++) {
for (int j = i + 1; j <= N; j++) {
cout << S[i][j] << " ";
}
cout << endl;
}
}
|
[
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 732,480
| 732,481
|
u133391510
|
cpp
|
p02930
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
const int mod = 1000000007, MAX = 200003, INF = 1 << 30;
int main() {
int N;
cin >> N;
N--;
int ans, maxi;
for (int i = 29; i >= 0; i--) {
if (N & (1 << i)) {
ans = i;
maxi = (1 << (i + 1));
break;
}
}
vector<vector<int>> S(maxi, vector<int>(maxi, 0));
for (int k = 0; k < ans; k++) {
for (int i = 0; i < maxi; i++) {
for (int j = 0; j < maxi; j++) {
if ((i & (1 << k)) != (j & (1 << k)))
S[i][j] = k + 1;
}
}
}
for (int i = 0; i <= N; i++) {
for (int j = i + 1; j <= N; j++) {
cout << S[i][j] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
const int mod = 1000000007, MAX = 200003, INF = 1 << 30;
int main() {
int N;
cin >> N;
N--;
int ans, maxi;
for (int i = 29; i >= 0; i--) {
if (N & (1 << i)) {
ans = i;
maxi = (1 << (i + 1));
break;
}
}
vector<vector<int>> S(maxi, vector<int>(maxi, 0));
for (int k = 0; k <= ans; k++) {
for (int i = 0; i < maxi; i++) {
for (int j = 0; j < maxi; j++) {
if ((i & (1 << k)) != (j & (1 << k)))
S[i][j] = k + 1;
}
}
}
for (int i = 0; i <= N - 1; i++) {
for (int j = i + 1; j <= N; j++) {
cout << S[i][j] << " ";
}
cout << endl;
}
}
|
[
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change",
"misc.off_by_one"
] | 732,482
| 732,481
|
u133391510
|
cpp
|
p02930
|
#define _GLIBCXX_DEBUG // TLEの原因になるので注意!!!!!!!!!!!
#include <bits/stdc++.h>
#include <cmath>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int, int>> qu2;
priority_queue<int> pq;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
/*int P[10010];
void init(int n){//Union-find
for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
if(P[a]==a)return a;
return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
P[root(a)]=root(b);
}//対set,グラフ?
//セグメント木??
*/
// Unionfind ,Disjointset
class UnionFind {
public:
//親の番号を格納する 親の場合-(その集合のサイズ)
vector<int> Parent;
//作るときはParentの値を全て-1にする
UnionFind(int n) { Parent = vector<int>(n, -1); }
// Aがどのグループに属するか
int root(int A) {
if (Parent[A] < 0)
return A;
return Parent[A] = root(Parent[A]);
}
//自分のグループの頂点数
int size(int A) { return -Parent[root(A)]; }
// AとBをくっつける
int connect(int A, int B) {
// AとBを直接ではなくAのrootとBのrootをくっつける
A = root(A);
B = root(B);
if (A == B) {
return false; //すでにくっついている
}
if (size(A) < size(B))
swap(A, B);
// Aのサイズ更新
Parent[A] += Parent[B];
// Bの親をAに変更する
Parent[B] = A;
return true;
}
};
double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } //内積
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } //外積
xy_t projection(xy_t p, xy_t b) {
return b * dot_product(p, b) / norm(b);
} //投影
//対図形
#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく
ll pw(ll x, ll y){//euclidの互除法より
ll a= 1;
while(y){
if(y&1){//奇数なら
a = a*x%mod;
}
x = x*x%mod;
y /= 2;
}
return a;
}
ll modinv(ll x){//逆元を求める
return pw(x, mod - 2 );
}
ll comb(int n,int r){
if(n<r){
return 0;
}
return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/
struct BIT {
vector<int> dat;
int sz;
BIT(int n) {
for (sz = 1; sz < n; sz *= 2)
;
dat.resize(++sz);
}
int q(int n) {
int ret = 0;
for (int i = n; i > 0; i -= i & -i)
ret += dat[i]; //和の計算 iから最後の1のbit(i&-i 多分&はビット積)を減算
for (int i = n; i < sz; i += i & -i)
dat[i]++; //値の加算 iから最後mの1のbitを加算
return ret;
}
};
/*
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;//thisポインター thisで自分自身のアドレス
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
// for prime mod
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
*/
int main() {
int n;
int k = 0;
cin >> n;
//奇数辺の閉回路を作らないようにする
for (int i = 0; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
for (k = 0;; k++) {
if (((i ^ j) >> k) & 1)
break;
}
printf("%d ", k + 1);
}
puts("");
}
return 0;
}
|
#define _GLIBCXX_DEBUG // TLEの原因になるので注意!!!!!!!!!!!
#include <bits/stdc++.h>
#include <cmath>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int, int>> qu2;
priority_queue<int> pq;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
/*int P[10010];
void init(int n){//Union-find
for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
if(P[a]==a)return a;
return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
P[root(a)]=root(b);
}//対set,グラフ?
//セグメント木??
*/
// Unionfind ,Disjointset
class UnionFind {
public:
//親の番号を格納する 親の場合-(その集合のサイズ)
vector<int> Parent;
//作るときはParentの値を全て-1にする
UnionFind(int n) { Parent = vector<int>(n, -1); }
// Aがどのグループに属するか
int root(int A) {
if (Parent[A] < 0)
return A;
return Parent[A] = root(Parent[A]);
}
//自分のグループの頂点数
int size(int A) { return -Parent[root(A)]; }
// AとBをくっつける
int connect(int A, int B) {
// AとBを直接ではなくAのrootとBのrootをくっつける
A = root(A);
B = root(B);
if (A == B) {
return false; //すでにくっついている
}
if (size(A) < size(B))
swap(A, B);
// Aのサイズ更新
Parent[A] += Parent[B];
// Bの親をAに変更する
Parent[B] = A;
return true;
}
};
double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } //内積
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } //外積
xy_t projection(xy_t p, xy_t b) {
return b * dot_product(p, b) / norm(b);
} //投影
//対図形
#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく
ll pw(ll x, ll y){//euclidの互除法より
ll a= 1;
while(y){
if(y&1){//奇数なら
a = a*x%mod;
}
x = x*x%mod;
y /= 2;
}
return a;
}
ll modinv(ll x){//逆元を求める
return pw(x, mod - 2 );
}
ll comb(int n,int r){
if(n<r){
return 0;
}
return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/
struct BIT {
vector<int> dat;
int sz;
BIT(int n) {
for (sz = 1; sz < n; sz *= 2)
;
dat.resize(++sz);
}
int q(int n) {
int ret = 0;
for (int i = n; i > 0; i -= i & -i)
ret += dat[i]; //和の計算 iから最後の1のbit(i&-i 多分&はビット積)を減算
for (int i = n; i < sz; i += i & -i)
dat[i]++; //値の加算 iから最後mの1のbitを加算
return ret;
}
};
/*
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;//thisポインター thisで自分自身のアドレス
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
// for prime mod
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
*/
int main() {
int n;
int k = 0;
cin >> n;
//奇数辺の閉回路を作らないようにする
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
for (k = 0;; k++) {
if (((i ^ j) >> k) & 1)
break;
}
printf("%d ", k + 1);
}
puts("");
}
return 0;
}
|
[
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 732,493
| 732,494
|
u300866293
|
cpp
|
p02930
|
// warm heart, wagging tail,and a smile just for you!
//
// ▒█████▒▒
// ██████████▒
// ▒████████████▒
// ██████████████████
// ████████████████████▒
// ▒██████████████████████▒
// ▒███████████████████████
// ▒████▒▒▒▒▒▒█████████████████▒
// ███▒▒▒▒▒▒██████████████████████▒▒▒
// ▒██▒▒███████████████████████▒▒▒▒▒██████
// ▒█████████████████████████▒▒▒▒▒▒█████████▒
// ▒█████████████████████▒▒▒▒▒▒██████████████
// ▒████ ████▒▒▒▒▒████ ████▒
// ▒█████▒ ████ ▒▒▒▒███████ ████ ██████▒
// ▒██▒▒▒▒▒ ██████ █████████ ██████ ██▒▒▒██▒
// █████████ ████████ █████████ ████████ ▒▒▒▒█████
// ▒█████████ ██████ ████████▒ ██████ █████████
// ▒██████████ ████ █████▒▒▒▒▒▒ ████ ██████████
// ████████████ ▒▒▒▒▒▒▒████████ ███████████▒
// ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
// ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
// ▒▒▒▒▒▒▒▒▒██████████████ ███████▒▒▒▒███████████
// █████████████████████████ ███████▒▒▒██████████████▒
// █████████████████████████████ ███████▒▒▒██████████████████▒
// ██████████████████████████████████████████████████████████████████████
// ██████████████████████████████████████████████████████████████████▒
// ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL << 60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b - 1); i >= (a); --i)
#define REP(i, n) FOR(i, 0, (n))
#define RREP(i, n) RFOR(i, 0, (n))
#define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i, a, b) ((a) <= (i) && (i) < (b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int, int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
mat ans(550, vec(550, -1));
void solve(int l, int r, int lev) {
int mid = (l + r) / 2;
if (r - l <= 1)
return;
FOR(i, l, mid) { FOR(j, mid, r) ans[i][j + mid] = ans[j + mid][i] = lev; }
solve(l, mid, lev + 1);
solve(mid, r, lev + 1);
return;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
solve(0, n, 1);
REP(i, n) {
FOR(j, i + 1, n) cout << ans[i][j] << " ";
cout << endl;
}
return 0;
}
|
// warm heart, wagging tail,and a smile just for you!
//
// ▒█████▒▒
// ██████████▒
// ▒████████████▒
// ██████████████████
// ████████████████████▒
// ▒██████████████████████▒
// ▒███████████████████████
// ▒████▒▒▒▒▒▒█████████████████▒
// ███▒▒▒▒▒▒██████████████████████▒▒▒
// ▒██▒▒███████████████████████▒▒▒▒▒██████
// ▒█████████████████████████▒▒▒▒▒▒█████████▒
// ▒█████████████████████▒▒▒▒▒▒██████████████
// ▒████ ████▒▒▒▒▒████ ████▒
// ▒█████▒ ████ ▒▒▒▒███████ ████ ██████▒
// ▒██▒▒▒▒▒ ██████ █████████ ██████ ██▒▒▒██▒
// █████████ ████████ █████████ ████████ ▒▒▒▒█████
// ▒█████████ ██████ ████████▒ ██████ █████████
// ▒██████████ ████ █████▒▒▒▒▒▒ ████ ██████████
// ████████████ ▒▒▒▒▒▒▒████████ ███████████▒
// ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
// ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
// ▒▒▒▒▒▒▒▒▒██████████████ ███████▒▒▒▒███████████
// █████████████████████████ ███████▒▒▒██████████████▒
// █████████████████████████████ ███████▒▒▒██████████████████▒
// ██████████████████████████████████████████████████████████████████████
// ██████████████████████████████████████████████████████████████████▒
// ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL << 60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b - 1); i >= (a); --i)
#define REP(i, n) FOR(i, 0, (n))
#define RREP(i, n) RFOR(i, 0, (n))
#define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i, a, b) ((a) <= (i) && (i) < (b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int, int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
mat ans(550, vec(550, -1));
void solve(int l, int r, int lev) {
int mid = (l + r) / 2;
if (r - l <= 1)
return;
FOR(i, l, mid) { FOR(j, mid, r) ans[i][j] = ans[j][i] = lev; }
solve(l, mid, lev + 1);
solve(mid, r, lev + 1);
return;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
solve(0, n, 1);
REP(i, n) {
FOR(j, i + 1, n) cout << ans[i][j] << " ";
cout << endl;
}
return 0;
}
|
[
"expression.operation.binary.remove"
] | 732,495
| 732,496
|
u239493918
|
cpp
|
p02930
|
/**
* Created by hiramekun at 20:52 on 2019-08-24.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
ll n = list.size();
rep(i, n) out << list[i] << ' ';
return out;
}
template <class T> istream &operator>>(istream &in, vector<T> &list) {
ll n = list.size();
rep(i, n) in >> list[i];
return in;
}
template <class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
ll n = list.size();
rep(i, n) out << list[i] << '\n';
return out;
}
/* ------------- ANSWER ------------- */
/* ---------------------------------- */
void solve() {
ll n;
cin >> n;
vvl level(n, vl(n));
auto dfs = [&](auto &&f, ll l, ll r, ll lev) -> void {
if (l + 1 == r)
return;
ll mid = (l + r) / 2;
for (ll i = l; i < mid; ++i) {
for (ll j = mid; j < r; ++j) {
level[i][j] = lev;
}
}
f(f, l, mid, lev + 1);
f(f, mid, r, lev + 1);
};
dfs(dfs, 0, n, 1);
for (ll i = 0; i < n - 1; ++i) {
for (ll j = i; j < n; ++j) {
cout << level[i][j] << ' ';
}
}
}
int main() {
#ifdef MY_DEBUG
while (true) {
#endif
solve();
#ifdef MY_DEBUG
}
#endif
return 0;
}
|
/**
* Created by hiramekun at 20:52 on 2019-08-24.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
ll n = list.size();
rep(i, n) out << list[i] << ' ';
return out;
}
template <class T> istream &operator>>(istream &in, vector<T> &list) {
ll n = list.size();
rep(i, n) in >> list[i];
return in;
}
template <class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
ll n = list.size();
rep(i, n) out << list[i] << '\n';
return out;
}
/* ------------- ANSWER ------------- */
/* ---------------------------------- */
void solve() {
ll n;
cin >> n;
vvl level(n, vl(n));
auto dfs = [&](auto &&f, ll l, ll r, ll lev) -> void {
if (l + 1 == r)
return;
ll mid = (l + r) / 2;
for (ll i = l; i < mid; ++i) {
for (ll j = mid; j < r; ++j) {
level[i][j] = lev;
}
}
f(f, l, mid, lev + 1);
f(f, mid, r, lev + 1);
};
dfs(dfs, 0, n, 1);
for (ll i = 0; i < n - 1; ++i) {
for (ll j = i + 1; j < n; ++j) {
cout << level[i][j] << ' ';
}
}
}
int main() {
#ifdef MY_DEBUG
while (true) {
#endif
solve();
#ifdef MY_DEBUG
}
#endif
return 0;
}
|
[
"control_flow.loop.for.initializer.change"
] | 732,504
| 732,505
|
u136378781
|
cpp
|
p02930
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int n;
vector<int> v, vv;
int main() {
cin >> n;
for (int i = 0; i < n; i--) {
for (int j = i + 1; j < n; j++) {
cout << __builtin_ctz(i + j) + 1 << ' ';
}
cout << endl;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int n;
vector<int> v, vv;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
cout << __builtin_ctz(i - j) + 1 << ' ';
}
cout << endl;
}
return 0;
}
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"io.output.change"
] | 732,516
| 732,515
|
u386107860
|
cpp
|
p02931
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
int u[216000];
bool loop[216000];
void init() {
for (int i = 0; i < 216000; i++)
u[i] = i;
}
int rt(int x) {
if (u[x] == x)
return x;
return u[x] = rt(u[x]);
}
void unite(int x, int y) {
x = rt(x);
y = rt(y);
u[x] = y;
}
int n, h, w;
int r, c, a;
typedef pair<Int, P> T;
vector<T> edges;
Int res;
int main() {
init();
cin >> n >> h >> w;
for (int i = 0; i < n; i++) {
cin >> r >> c >> a;
r--, c--;
edges.push_back(T(a, P(r, c)));
}
sort(edges.rbegin(), edges.rend());
for (auto e : edges) {
a = e.first;
r = e.second.first;
c = e.second.second;
c += n;
int rtr = rt(r), rtc = rt(c);
if (loop[rtr] && loop[rtc])
continue;
res += a;
// cout << a << " " << r + 1 << " " << c - n + 1 << endl;
if (rtr == rtc) {
loop[rtr] = true;
continue;
}
if (!loop[rtr] && !loop[rtc]) {
unite(r, c);
continue;
} else {
unite(r, c);
loop[rt(r)] = true;
}
}
cout << res << endl;
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
int u[216000];
bool loop[216000];
void init() {
for (int i = 0; i < 216000; i++)
u[i] = i;
}
int rt(int x) {
if (u[x] == x)
return x;
return u[x] = rt(u[x]);
}
void unite(int x, int y) {
x = rt(x);
y = rt(y);
u[x] = y;
}
int n, h, w;
int r, c, a;
typedef pair<Int, P> T;
vector<T> edges;
Int res;
int main() {
init();
cin >> n >> h >> w;
for (int i = 0; i < n; i++) {
cin >> r >> c >> a;
r--, c--;
edges.push_back(T(a, P(r, c)));
}
sort(edges.rbegin(), edges.rend());
for (auto e : edges) {
a = e.first;
r = e.second.first;
c = e.second.second;
c += h;
int rtr = rt(r), rtc = rt(c);
if (loop[rtr] && loop[rtc])
continue;
res += a;
// cout << a << " " << r + 1 << " " << c - n + 1 << endl;
if (rtr == rtc) {
loop[rtr] = true;
continue;
}
if (!loop[rtr] && !loop[rtc]) {
unite(r, c);
continue;
} else {
unite(r, c);
loop[rt(r)] = true;
}
}
cout << res << endl;
return 0;
}
|
[
"assignment.value.change",
"identifier.change"
] | 732,521
| 732,522
|
u299869545
|
cpp
|
p02932
|
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
using ll = long long;
const int INF = 1 << 30;
const ll INFll = 1LL << 62;
const int mod = int(1e9) + 7;
// const int mod=998244353;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using ld = long double;
using V = vector<int>;
using Vl = vector<ll>;
using VV = vector<vector<int>>;
using VVl = vector<vector<ll>>;
// modint: mod 計算を int を扱うように扱える構造体
template <int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0)
val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
constexpr Fp &operator+=(const Fp &r) noexcept {
val += r.val;
if (val >= MOD)
val -= MOD;
return *this;
}
constexpr Fp &operator-=(const Fp &r) noexcept {
val -= r.val;
if (val < 0)
val += MOD;
return *this;
}
constexpr Fp &operator*=(const Fp &r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp &operator/=(const Fp &r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
constexpr bool operator==(const Fp &r) const noexcept {
return this->val == r.val;
}
constexpr bool operator!=(const Fp &r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0)
return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1)
t = t * a;
return t;
}
};
using mint = Fp<mod>;
const int MAX = 1001001;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll nPr(int n, int r) {
if (n < 0 || r < 0 || n < r)
return 0;
return fac[n] * finv[n - r] % mod;
}
int main() {
COMinit();
ll n, m, l, r;
cin >> n >> m >> l >> r;
mint ans;
//(1-x^m)/(1-x)^(n+1)
vector<mint> dp(r + 1, 0);
for (int i = 0; i <= r; ++i) {
dp[i] = COM(n + i, n);
}
auto nx = dp;
for (int i = m; i <= r; ++i) {
dp[i] -= nx[i - m];
}
// sum(k~)x^km*(1-x^k)^(n-m)
vector<mint> P(r + 1, 0);
for (int k = 1; k <= r; ++k) {
for (int i = k * m; i <= min(k * n, r); i += k) {
if (((i - k * m) / k) % 2 == 0) {
P[i] += COM(n - m, (i - k * m) / k);
} else {
P[i] -= COM(n - m, (i - k * m) / k);
}
}
}
mint U = COM(r + n, n);
mint plus = 0;
for (int i = 0; i <= r; ++i) {
plus += dp[i] * P[r - i];
}
plus = U - plus * COM(n, m);
U = COM(l - 1 + n, n);
mint sub = 0;
for (int i = 0; i < l; ++i) {
sub += dp[i] * P[l - i - 1];
}
sub = U - sub * COM(n, m);
ans = plus - sub;
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
using ll = long long;
const int INF = 1 << 30;
const ll INFll = 1LL << 62;
const int mod = int(1e9) + 7;
// const int mod=998244353;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using ld = long double;
using V = vector<int>;
using Vl = vector<ll>;
using VV = vector<vector<int>>;
using VVl = vector<vector<ll>>;
// modint: mod 計算を int を扱うように扱える構造体
template <int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0)
val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
constexpr Fp &operator+=(const Fp &r) noexcept {
val += r.val;
if (val >= MOD)
val -= MOD;
return *this;
}
constexpr Fp &operator-=(const Fp &r) noexcept {
val -= r.val;
if (val < 0)
val += MOD;
return *this;
}
constexpr Fp &operator*=(const Fp &r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp &operator/=(const Fp &r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
constexpr bool operator==(const Fp &r) const noexcept {
return this->val == r.val;
}
constexpr bool operator!=(const Fp &r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0)
return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1)
t = t * a;
return t;
}
};
using mint = Fp<mod>;
const int MAX = 1001001;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll nPr(int n, int r) {
if (n < 0 || r < 0 || n < r)
return 0;
return fac[n] * finv[n - r] % mod;
}
int main() {
COMinit();
ll n, m, l, r;
cin >> n >> m >> l >> r;
mint ans;
//(1-x^m)/(1-x)^(n+1)
vector<mint> dp(r + 1, 0);
for (int i = 0; i <= r; ++i) {
dp[i] = COM(n + i, n);
}
auto nx = dp;
for (int i = m; i <= r; ++i) {
dp[i] -= nx[i - m];
}
// sum(k~)x^km*(1-x^k)^(n-m)
vector<mint> P(r + 1, 0);
for (ll k = 1; k <= r; ++k) {
for (ll i = k * m; i <= min(k * n, r); i += k) {
if (((i - k * m) / k) % 2 == 0) {
P[i] += COM(n - m, (i - k * m) / k);
} else {
P[i] -= COM(n - m, (i - k * m) / k);
}
}
}
mint U = COM(r + n, n);
mint plus = 0;
for (int i = 0; i <= r; ++i) {
plus += dp[i] * P[r - i];
}
plus = U - plus * COM(n, m);
U = COM(l - 1 + n, n);
mint sub = 0;
for (int i = 0; i < l; ++i) {
sub += dp[i] * P[l - i - 1];
}
sub = U - sub * COM(n, m);
ans = plus - sub;
cout << ans << endl;
}
|
[
"variable_declaration.type.narrow.change",
"control_flow.loop.for.initializer.change",
"variable_declaration.type.change"
] | 732,523
| 732,524
|
u525008368
|
cpp
|
p02932
|
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
using ll = long long;
const int INF = 1 << 30;
const ll INFll = 1LL << 62;
const int mod = int(1e9) + 7;
// const int mod=998244353;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using ld = long double;
using V = vector<int>;
using Vl = vector<ll>;
using VV = vector<vector<int>>;
using VVl = vector<vector<ll>>;
// modint: mod 計算を int を扱うように扱える構造体
template <int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0)
val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
constexpr Fp &operator+=(const Fp &r) noexcept {
val += r.val;
if (val >= MOD)
val -= MOD;
return *this;
}
constexpr Fp &operator-=(const Fp &r) noexcept {
val -= r.val;
if (val < 0)
val += MOD;
return *this;
}
constexpr Fp &operator*=(const Fp &r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp &operator/=(const Fp &r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
constexpr bool operator==(const Fp &r) const noexcept {
return this->val == r.val;
}
constexpr bool operator!=(const Fp &r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0)
return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1)
t = t * a;
return t;
}
};
using mint = Fp<mod>;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll nPr(int n, int r) {
if (n < 0 || r < 0 || n < r)
return 0;
return fac[n] * finv[n - r] % mod;
}
int main() {
COMinit();
ll n, m, l, r;
cin >> n >> m >> l >> r;
mint ans;
//(1-x^m)/(1-x)^(n+1)
vector<mint> dp(r + 1, 0);
for (int i = 0; i <= r; ++i) {
dp[i] = COM(n + i, n);
}
auto nx = dp;
for (int i = m; i <= r; ++i) {
dp[i] -= nx[i - m];
}
// sum(k~)x^km*(1-x^k)^(n-m)
vector<mint> P(r + 1, 0);
for (int k = 1; k <= r; ++k) {
for (int i = k * m; i <= min(k * n, r); i += k) {
if (((i - k * m) / k) % 2 == 0) {
P[i] += COM(n - m, (i - k * m) / k);
} else {
P[i] -= COM(n - m, (i - k * m) / k);
}
}
// for(auto p:P){
// cout <<p<<" ";
// }
// cout <<endl;
}
// vector<mint>G(r+1,0);
// for (int k =1; k <=r; ++k){
// vector<mint>P2(r+1,0);
// P[0]=1;
// x^km
// vector<mint>nx(r+1,0);
// for (int i = 0; i <=r; ++i) {
// if(i+k*m>r)break;
// nx[i+k*m]=P2[i];
// }
// P=nx;
// for(auto p:P){
// cout <<p<<" ";
// }
// cout <<endl;
// ok
// *(1-x^k)^(n-m)
// for (int i = 0; i <=n-m; ++i) {
// for (int j = 0; j <=r; ++j) {
// if (j + k * i > r)break;
// G[j + k * i] += P2[j] * COM(n - m, i) * ((i % 2 == 1) ? -1 :
// 1);
// }
// }
// cout <<k<<endl;
// for(auto g:G){
// cout <<g<<" ";
// }
// cout <<endl;
// ok
// }
mint U = COM(r + n, n);
mint plus = 0;
for (int i = 0; i <= r; ++i) {
plus += dp[i] * P[r - i];
}
plus = U - plus * COM(n, m);
U = COM(l - 1 + n, n);
mint sub = 0;
for (int i = 0; i < l; ++i) {
sub += dp[i] * P[l - i - 1];
}
sub = U - sub * COM(n, m);
ans = plus - sub;
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
using ll = long long;
const int INF = 1 << 30;
const ll INFll = 1LL << 62;
const int mod = int(1e9) + 7;
// const int mod=998244353;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using ld = long double;
using V = vector<int>;
using Vl = vector<ll>;
using VV = vector<vector<int>>;
using VVl = vector<vector<ll>>;
// modint: mod 計算を int を扱うように扱える構造体
template <int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0)
val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
constexpr Fp &operator+=(const Fp &r) noexcept {
val += r.val;
if (val >= MOD)
val -= MOD;
return *this;
}
constexpr Fp &operator-=(const Fp &r) noexcept {
val -= r.val;
if (val < 0)
val += MOD;
return *this;
}
constexpr Fp &operator*=(const Fp &r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp &operator/=(const Fp &r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
constexpr bool operator==(const Fp &r) const noexcept {
return this->val == r.val;
}
constexpr bool operator!=(const Fp &r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0)
return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1)
t = t * a;
return t;
}
};
using mint = Fp<mod>;
const int MAX = 1001001;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll nPr(int n, int r) {
if (n < 0 || r < 0 || n < r)
return 0;
return fac[n] * finv[n - r] % mod;
}
int main() {
COMinit();
ll n, m, l, r;
cin >> n >> m >> l >> r;
mint ans;
//(1-x^m)/(1-x)^(n+1)
vector<mint> dp(r + 1, 0);
for (int i = 0; i <= r; ++i) {
dp[i] = COM(n + i, n);
}
auto nx = dp;
for (int i = m; i <= r; ++i) {
dp[i] -= nx[i - m];
}
// sum(k~)x^km*(1-x^k)^(n-m)
vector<mint> P(r + 1, 0);
for (ll k = 1; k <= r; ++k) {
for (ll i = k * m; i <= min(k * n, r); i += k) {
if (((i - k * m) / k) % 2 == 0) {
P[i] += COM(n - m, (i - k * m) / k);
} else {
P[i] -= COM(n - m, (i - k * m) / k);
}
}
}
mint U = COM(r + n, n);
mint plus = 0;
for (int i = 0; i <= r; ++i) {
plus += dp[i] * P[r - i];
}
plus = U - plus * COM(n, m);
U = COM(l - 1 + n, n);
mint sub = 0;
for (int i = 0; i < l; ++i) {
sub += dp[i] * P[l - i - 1];
}
sub = U - sub * COM(n, m);
ans = plus - sub;
cout << ans << endl;
}
|
[
"literal.number.change",
"variable_declaration.value.change",
"variable_declaration.type.narrow.change",
"control_flow.loop.for.initializer.change",
"variable_declaration.type.change"
] | 732,525
| 732,524
|
u525008368
|
cpp
|
p02932
|
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 600005;
const int MOD = 1000000007;
int n, m, L, R;
long long fac[N], inv[N];
long long ksm(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD, b >>= 1;
}
return res;
}
void init(int n = 600000) {
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % MOD;
inv[n] = ksm(fac[n], MOD - 2);
for (int i = n; i >= 1; i--)
inv[i - 1] = inv[i] * i % MOD;
return;
}
long long C(int n, int m) {
if (m > n)
return 0;
else
return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
long long calc(int x, int p, int q) {
x -= 1LL * m * p;
if (x < 0)
return 0;
long long res = 0;
for (int i = 0; i <= n - m && x - 1LL * i * q >= 0; i++)
if (i & 1)
res = (res - C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD + MOD) % MOD;
else
res = (res + C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD) % MOD;
res *= C(n, m);
return res;
}
long long solve(int x) {
long long res = 0;
for (int p = 1; p <= x; p++)
res = (res + (calc(x, p, p) - calc(x, p, p - 1) + MOD) % MOD) % MOD;
res = (C(x + n, n) - res + MOD) % MOD;
return res;
}
int main() {
init();
scanf("%d%d%d%d", &n, &m, &L, &R);
printf("%lld", (solve(R) - solve(L - 1) + MOD) % MOD);
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 600005;
const int MOD = 1000000007;
int n, m, L, R;
long long fac[N], inv[N];
long long ksm(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD, b >>= 1;
}
return res;
}
void init(int n = 600000) {
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % MOD;
inv[n] = ksm(fac[n], MOD - 2);
for (int i = n; i >= 1; i--)
inv[i - 1] = inv[i] * i % MOD;
return;
}
long long C(int n, int m) {
if (m > n)
return 0;
else
return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
long long calc(long long x, int p, int q) {
x -= 1LL * m * p;
if (x < 0)
return 0;
long long res = 0;
for (int i = 0; i <= n - m && x - 1LL * i * q >= 0; i++)
if (i & 1)
res = (res - C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD + MOD) % MOD;
else
res = (res + C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD) % MOD;
res *= C(n, m);
return res;
}
long long solve(int x) {
long long res = 0;
for (int p = 1; p <= x; p++)
res = (res + (calc(x, p, p) - calc(x, p + 1, p) + MOD) % MOD) % MOD;
res = (C(x + n, n) - res + MOD) % MOD;
return res;
}
int main() {
init();
scanf("%d%d%d%d", &n, &m, &L, &R);
printf("%lld", (solve(R) - solve(L - 1) + MOD) % MOD);
return 0;
}
|
[
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"assignment.change",
"expression.operation.binary.remove"
] | 732,526
| 732,527
|
u648316846
|
cpp
|
p02932
|
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 600005;
const int MOD = 1000000007;
int n, m, L, R;
long long fac[N], inv[N];
long long ksm(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD, b >>= 1;
}
return res;
}
void init(int n = 600000) {
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % MOD;
inv[n] = ksm(fac[n], MOD - 2);
for (int i = n; i >= 1; i--)
inv[i - 1] = inv[i] * i % MOD;
return;
}
long long C(int n, int m) {
if (m > n)
return 0;
else
return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
long long calc(int x, int p, int q) {
x -= 1LL * m * p;
if (x < 0)
return 0;
long long res = 0;
for (int i = 0; i <= n - m && x - 1LL * i * q >= 0; i++)
if (i & 1)
res = (res - C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD + MOD) % MOD;
else
res = (res + C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD) % MOD;
res *= C(n, m);
return res;
}
long long solve(int x) {
long long res = 0;
for (int p = 1; p <= x; p++)
res = (res + (calc(x, p, p) - calc(x, p, p - 1) + MOD) % MOD) % MOD;
res = (C(x + n, n) - res + MOD) % MOD;
return res;
}
int main() {
init();
scanf("%d%d%d%d", &n, &m, &L, &R);
printf("%lld", (solve(R) - solve(L - 1) + MOD) % MOD);
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 600005;
const int MOD = 1000000007;
int n, m, L, R;
long long fac[N], inv[N];
long long ksm(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD, b >>= 1;
}
return res;
}
void init(int n = 600000) {
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % MOD;
inv[n] = ksm(fac[n], MOD - 2);
for (int i = n; i >= 1; i--)
inv[i - 1] = inv[i] * i % MOD;
return;
}
long long C(int n, int m) {
if (m > n)
return 0;
else
return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
long long calc(long long x, int p, int q) {
x -= 1LL * m * p;
if (x < 0)
return 0;
long long res = 0;
for (int i = 0; i <= n - m && x - 1LL * i * q >= 0; i++)
if (i & 1)
res = (res - C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD + MOD) % MOD;
else
res = (res + C(n - m, i) * C(x - 1LL * i * q + n, n) % MOD) % MOD;
res *= C(n, m);
return res;
}
long long solve(int x) {
long long res = 0;
for (int p = 1; p <= x; p++)
res = (res + (calc(x, p, p) - calc(x, p, p - 1) + MOD) % MOD) % MOD;
res = (C(x + n, n) - res + MOD) % MOD;
return res;
}
int main() {
init();
scanf("%d%d%d%d", &n, &m, &L, &R);
printf("%lld", (solve(R) - solve(L - 1) + MOD) % MOD);
return 0;
}
|
[
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 732,526
| 732,528
|
u648316846
|
cpp
|
p02932
|
#include <iostream>
using namespace std;
long long mod = 1000000007;
long long fact[1 << 20], inv[1 << 20];
long long modpow(long long a, long long b, long long m) {
long long p = 1, q = a;
for (int i = 0; i < 33; i++) {
if ((b / (1LL << i)) % 2 == 1) {
p *= q;
p %= m;
}
q *= q;
q %= m;
}
return p;
}
long long Div(long long a, long long b, long long m) {
return (a * modpow(b, m - 2, m)) % m;
}
void init() {
fact[0] = 1;
for (int i = 1; i <= 600000; i++)
fact[i] = (1LL * i * fact[i - 1]) % mod;
for (int i = 0; i <= 600000; i++)
inv[i] = Div(1, fact[i], mod);
}
long long ncr(long long n, long long r) {
if (r < 0 || n < r)
return 0;
return (fact[n] * inv[r] % mod) * inv[n - r] % mod;
}
long long N, M, L, R;
long long solve(int border) {
long long V1 = ncr(N, M);
long long V2 = 0;
for (int i = 0; i <= N - M; i++) {
int cl = L - (M + i) * border + (N - 1),
el = L - (M + i) * border + (N - M - 1);
int cr = R - (M + i) * border + (N - 1),
er = R - (M + i) * border + (N - M - 1);
if (cr < 0)
break;
if (i % 2 == 0) {
V2 += ncr(N - M, i) * (ncr(cr + 1, N) - ncr(er + 1, N));
V2 = (V2 + mod * mod) % mod;
V2 -= ncr(N - M, i) * (ncr(cl + 0, N) - ncr(el + 0, N));
V2 = (V2 + mod * mod) % mod;
}
if (i % 2 == 1) {
V2 -= ncr(N - M, i) * (ncr(cr + 1, N) - ncr(er + 1, N));
V2 = (V2 + mod * mod) % mod;
V2 += ncr(N - M, i) * (ncr(cl + 0, N) - ncr(el + 0, N));
V2 = (V2 + mod * mod) % mod;
}
}
return V1 * V2 % mod;
}
int main() {
cin >> N >> M >> L >> R;
init();
long long Answer = 0;
for (int i = 1; i <= R; i++) {
Answer += solve(i);
Answer %= mod;
}
long long Answer2 = (ncr(R + N, N) - ncr(L + N - 1, N) + mod) % mod;
cout << (Answer2 - Answer + mod) % mod << endl;
return 0;
}
|
#include <iostream>
using namespace std;
long long mod = 1000000007;
long long fact[1 << 20], inv[1 << 20];
long long modpow(long long a, long long b, long long m) {
long long p = 1, q = a;
for (int i = 0; i < 33; i++) {
if ((b / (1LL << i)) % 2 == 1) {
p *= q;
p %= m;
}
q *= q;
q %= m;
}
return p;
}
long long Div(long long a, long long b, long long m) {
return (a * modpow(b, m - 2, m)) % m;
}
void init() {
fact[0] = 1;
for (int i = 1; i <= 600000; i++)
fact[i] = (1LL * i * fact[i - 1]) % mod;
for (int i = 0; i <= 600000; i++)
inv[i] = Div(1, fact[i], mod);
}
long long ncr(long long n, long long r) {
if (r < 0 || n < r)
return 0;
return (fact[n] * inv[r] % mod) * inv[n - r] % mod;
}
long long N, M, L, R;
long long solve(long long border) {
long long V1 = ncr(N, M);
long long V2 = 0;
for (int i = 0; i <= N - M; i++) {
long long cl = L - (M + i) * border + (N - 1),
el = L - (M + i) * border + (N - M - 1);
long long cr = R - (M + i) * border + (N - 1),
er = R - (M + i) * border + (N - M - 1);
if (cr < 0)
break;
if (i % 2 == 0) {
V2 += ncr(N - M, i) * (ncr(cr + 1, N) - ncr(er + 1, N));
V2 = (V2 + mod * mod) % mod;
V2 -= ncr(N - M, i) * (ncr(cl + 0, N) - ncr(el + 0, N));
V2 = (V2 + mod * mod) % mod;
}
if (i % 2 == 1) {
V2 -= ncr(N - M, i) * (ncr(cr + 1, N) - ncr(er + 1, N));
V2 = (V2 + mod * mod) % mod;
V2 += ncr(N - M, i) * (ncr(cl + 0, N) - ncr(el + 0, N));
V2 = (V2 + mod * mod) % mod;
}
}
return V1 * V2 % mod;
}
int main() {
cin >> N >> M >> L >> R;
init();
long long Answer = 0;
for (int i = 1; i <= R; i++) {
Answer += solve(i);
Answer %= mod;
}
long long Answer2 = (ncr(R + N, N) - ncr(L + N - 1, N) + mod) % mod;
cout << (Answer2 - Answer + mod) % mod << endl;
return 0;
}
|
[
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 732,529
| 732,530
|
u504103417
|
cpp
|
p02932
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
struct combination {
vector<mint> fact, ifact;
// init struct with \"n\" of \"nCk\" (maximum number in other words)
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
// c(n,k) returns mint that contains nCk (mod p (= 1e9+7)) in x
// i.e.) mint num = c(n,k), then num.x == nCk (mod p (= 1e9+7))
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
// nPk - permutation
mint p(int n, int k) { return fact[n] * ifact[n - k]; }
} nck(300300);
mint solve(ll n, ll m, ll r) {
auto calc = [&](ll offset) {
mint acc = 0;
for (int k = 0; k <= r; ++k) {
for (int i = 0; i <= m; ++i) {
ll deg = r - (i * (k + offset) + (k + 1) * (n - m));
if (deg < 0)
break;
acc += nck(n + deg, deg) * nck(m, i) * (1 - i % 2 * 2);
}
}
return acc;
};
mint all = 0;
for (int x = 0; x <= r; ++x) {
all += nck(x + n - 1, x);
}
return all - nck(n, m) * (calc(1) - calc(0));
}
int main() {
ll n, m, l, r;
cin >> n >> m >> l >> r;
m = n - m;
mint ans = solve(n, m, r) - solve(n, m, l - 1);
cout << ans.x << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
struct combination {
vector<mint> fact, ifact;
// init struct with \"n\" of \"nCk\" (maximum number in other words)
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
// c(n,k) returns mint that contains nCk (mod p (= 1e9+7)) in x
// i.e.) mint num = c(n,k), then num.x == nCk (mod p (= 1e9+7))
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
// nPk - permutation
mint p(int n, int k) { return fact[n] * ifact[n - k]; }
} nck(1000100);
mint solve(ll n, ll m, ll r) {
auto calc = [&](ll offset) {
mint acc = 0;
for (ll k = 0; k <= r; ++k) {
for (ll i = 0; i <= m; ++i) {
ll deg = r - (i * (k + offset) + (k + 1) * (n - m));
if (deg < 0)
break;
acc += nck(n + deg, deg) * nck(m, i) * (1 - i % 2 * 2);
}
}
return acc;
};
mint all = 0;
for (ll x = 0; x <= r; ++x) {
all += nck(x + n - 1, x);
}
return all - nck(n, m) * (calc(1) - calc(0));
}
int main() {
ll n, m, l, r;
cin >> n >> m >> l >> r;
m = n - m;
mint ans = solve(n, m, r) - solve(n, m, l - 1);
cout << ans.x << endl;
}
|
[
"literal.number.change",
"call.arguments.change",
"control_flow.loop.for.initializer.change",
"variable_declaration.type.change"
] | 732,531
| 732,532
|
u923105140
|
cpp
|
p02932
|
#include <bits/stdc++.h>
using namespace std;
template <int MAX> struct Combination {
vector<long long> _inv, _fac, _ifac;
const long long MOD;
Combination(long long mod)
: _inv(MAX + 1), _fac(MAX + 1), _ifac(MAX + 1), MOD(mod) {
init();
}
inline void init(long long mod = 0) { init_inv(), init_fac(); }
inline void init_inv() {
_inv[0] = 0;
for (int i = 1; i <= MAX; i++) {
if (i == 1)
_inv[i] = 1;
else {
_inv[i] = (MOD - (MOD / i) * _inv[MOD % i]) % MOD;
if (_inv[i] < 0)
_inv[i] += MOD;
}
}
}
inline void init_fac() {
_fac[0] = _ifac[0] = 1;
for (int i = 1; i <= MAX; i++) {
_fac[i] = _fac[i - 1] * i % MOD;
_ifac[i] = _ifac[i - 1] * _inv[i] % MOD;
}
}
inline long long modpow(long long n, long long r) {
n %= MOD, r %= (MOD - 1);
if (!n)
return 0;
long long ret = 1;
long long tmp = n;
while (r != 0) {
if (r % 2)
ret *= tmp;
tmp *= tmp;
tmp %= MOD;
ret %= MOD;
r /= 2;
}
return ret;
}
inline const long long invb(int i) {
return (i <= MAX) ? _inv[i] : this->modpow(i, MOD - 2);
}
inline const long long inv(int i) { return _inv[i]; }
inline const long long fac(int i) { return _fac[i]; }
inline const long long ifac(int i) { return _ifac[i]; }
const long long operator()(int n, int r) {
if (n < r)
return 0;
return fac(n) * ifac(r) % MOD * ifac(n - r) % MOD;
}
};
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
constexpr int MAX = 600000;
constexpr int mod = 1000000007;
Combination<MAX> C(mod);
int n, m, l, r;
cin >> n >> m >> l >> r;
vector<long long> x(r + 1, 0);
vector<long long> y(r + 1, 0);
for (int a = 1; a <= r; a++) {
for (int i = 0; i <= n - m; i++) {
if ((m + i) * a > r)
break;
if (i & 1)
x[(m + i) * a] -= C(n - m, i);
else
x[(m + i) * a] += C(n - m, i);
x[(m + i) * a] = (x[(m + i) * a] + mod) % mod;
}
}
for (int i = r; i >= m; i--) {
x[i] = (x[i] - x[i - m] + mod) % mod;
}
for (int i = 0; i <= r; i++)
y[i] = C(n + i, i);
auto calc = [&](int l) {
long long ret = 0;
for (int i = 0; i <= l; i++) {
ret += x[i] * y[l - i] % mod;
}
return ret % mod;
};
long long sub = (calc(r) - calc(l - 1) + mod) % mod * C(n, m) % mod;
long long all = 0;
for (int i = l; i <= r; i++)
all += C(i + n - 1, i);
cout << (all - sub + mod) % mod << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <int MAX> struct Combination {
vector<long long> _inv, _fac, _ifac;
const long long MOD;
Combination(long long mod)
: _inv(MAX + 1), _fac(MAX + 1), _ifac(MAX + 1), MOD(mod) {
init();
}
inline void init(long long mod = 0) { init_inv(), init_fac(); }
inline void init_inv() {
_inv[0] = 0;
for (int i = 1; i <= MAX; i++) {
if (i == 1)
_inv[i] = 1;
else {
_inv[i] = (MOD - (MOD / i) * _inv[MOD % i]) % MOD;
if (_inv[i] < 0)
_inv[i] += MOD;
}
}
}
inline void init_fac() {
_fac[0] = _ifac[0] = 1;
for (int i = 1; i <= MAX; i++) {
_fac[i] = _fac[i - 1] * i % MOD;
_ifac[i] = _ifac[i - 1] * _inv[i] % MOD;
}
}
inline long long modpow(long long n, long long r) {
n %= MOD, r %= (MOD - 1);
if (!n)
return 0;
long long ret = 1;
long long tmp = n;
while (r != 0) {
if (r % 2)
ret *= tmp;
tmp *= tmp;
tmp %= MOD;
ret %= MOD;
r /= 2;
}
return ret;
}
inline const long long invb(int i) {
return (i <= MAX) ? _inv[i] : this->modpow(i, MOD - 2);
}
inline const long long inv(int i) { return _inv[i]; }
inline const long long fac(int i) { return _fac[i]; }
inline const long long ifac(int i) { return _ifac[i]; }
const long long operator()(int n, int r) {
if (n < r)
return 0;
return fac(n) * ifac(r) % MOD * ifac(n - r) % MOD;
}
};
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
constexpr int MAX = 600000;
constexpr int mod = 1000000007;
Combination<MAX> C(mod);
int n, m, l, r;
cin >> n >> m >> l >> r;
vector<long long> x(r + 1, 0);
vector<long long> y(r + 1, 0);
for (int a = 1; a <= r; a++) {
for (int i = 0; i <= n - m; i++) {
if ((long long)(m + i) * a > r)
break;
if (i & 1)
x[(m + i) * a] -= C(n - m, i);
else
x[(m + i) * a] += C(n - m, i);
x[(m + i) * a] = (x[(m + i) * a] + mod) % mod;
}
}
for (int i = r; i >= m; i--) {
x[i] = (x[i] - x[i - m] + mod) % mod;
}
for (int i = 0; i <= r; i++)
y[i] = C(n + i, i);
auto calc = [&](int l) {
long long ret = 0;
for (int i = 0; i <= l; i++) {
ret += x[i] * y[l - i] % mod;
}
return ret % mod;
};
long long sub = (calc(r) - calc(l - 1) + mod) % mod * C(n, m) % mod;
long long all = 0;
for (int i = l; i <= r; i++)
all += C(i + n - 1, i);
cout << (all - sub + mod) % mod << "\n";
return 0;
}
|
[
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 732,533
| 732,534
|
u521364030
|
cpp
|
p02932
|
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, mod = 1e9 + 7;
typedef long long ll;
int n, m, l, r;
ll f[N], inv[N], invf[N];
ll C(int n, int m) { return f[n] * invf[n - m] % mod * invf[m] % mod; }
ll g(int x, int y, int k) {
int s = k - x * m;
ll res = 0;
for (int i = 0, f = 1; i * y <= s && i <= n - m; i++, f *= -1)
res = (res + f * C(n - m, i) % mod * C(s - i * y + n, n)) % mod;
return res;
}
ll solve(int k) {
ll ans = 0;
for (int x = 1; x * m <= k; x++)
ans = (ans + g(x, x, k) - g(x + 1, x, k)) % mod;
return (C(k + n, n) - ans * C(n, m)) % mod;
}
int main() {
f[0] = f[1] = invf[0] = invf[1] = inv[1] = 1;
for (int i = 2; i < N; i++) {
inv[i] = (mod - mod / i) * inv[mod % i] % mod;
f[i] = f[i - 1] * i % mod;
invf[i] = invf[i - 1] * inv[i] % mod;
}
scanf("%d%d%d%d", &n, &m, &l, &r);
printf("%lld\n", ((solve(r) - solve(l - 1)) % mod + mod) % mod);
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 6e5 + 5, mod = 1e9 + 7;
typedef long long ll;
int n, m, l, r;
ll f[N], inv[N], invf[N];
ll C(int n, int m) { return f[n] * invf[n - m] % mod * invf[m] % mod; }
ll g(int x, int y, int k) {
int s = k - x * m;
ll res = 0;
for (int i = 0, f = 1; i * y <= s && i <= n - m; i++, f *= -1)
res = (res + f * C(n - m, i) % mod * C(s - i * y + n, n)) % mod;
return res;
}
ll solve(int k) {
ll ans = 0;
for (int x = 1; x * m <= k; x++)
ans = (ans + g(x, x, k) - g(x + 1, x, k)) % mod;
return (C(k + n, n) - ans * C(n, m)) % mod;
}
int main() {
f[0] = f[1] = invf[0] = invf[1] = inv[1] = 1;
for (int i = 2; i < N; i++) {
inv[i] = (mod - mod / i) * inv[mod % i] % mod;
f[i] = f[i - 1] * i % mod;
invf[i] = invf[i - 1] * inv[i] % mod;
}
scanf("%d%d%d%d", &n, &m, &l, &r);
printf("%lld\n", ((solve(r) - solve(l - 1)) % mod + mod) % mod);
}
|
[
"literal.number.change",
"expression.operation.binary.change"
] | 732,537
| 732,538
|
u676323984
|
cpp
|
p02932
|
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int N = 300010;
const int mod = 1e9 + 7;
int n, m, fact[N << 1], invf[N << 1];
int qpow(int x, int y) {
int out = 1;
while (y) {
if (y & 1)
out = (ll)out * x % mod;
x = (ll)x * x % mod;
y >>= 1;
}
return out;
}
int c(int x, int y) { return (ll)fact[x] * invf[y] % mod * invf[x - y] % mod; }
int f(int x, int y) {
int out = 0;
for (int i = 0; i * x <= y && i <= n - m; ++i) {
out =
(out + (i & 1 ? -1ll : 1ll) * c(n - m, i) * c(n + y - i * x, n) % mod +
mod) %
mod;
}
return out;
}
int solve(int r) {
int out = c(n + r, r);
for (int x = 1; x <= r / m; ++x) {
out =
(out + (ll)c(n, m) * (f(x, r - m * (x + 1)) - f(x, r - m * x) + mod)) %
mod;
}
return out;
}
int main() {
int l, r;
cin >> n >> m >> l >> r;
fact[0] = 1;
for (int i = 1; i <= n + r; ++i)
fact[i] = (ll)fact[i - 1] * i % mod;
invf[n] = qpow(fact[n], mod - 2);
for (int i = n; i >= 1; --i)
invf[i - 1] = (ll)invf[i] * i % mod;
cout << (solve(r) - solve(l - 1) + mod) % mod;
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int N = 300010;
const int mod = 1e9 + 7;
int n, m, fact[N << 1], invf[N << 1];
int qpow(int x, int y) {
int out = 1;
while (y) {
if (y & 1)
out = (ll)out * x % mod;
x = (ll)x * x % mod;
y >>= 1;
}
return out;
}
int c(int x, int y) { return (ll)fact[x] * invf[y] % mod * invf[x - y] % mod; }
int f(int x, int y) {
int out = 0;
for (int i = 0; i * x <= y && i <= n - m; ++i) {
out =
(out + (i & 1 ? -1ll : 1ll) * c(n - m, i) * c(n + y - i * x, n) % mod +
mod) %
mod;
}
return out;
}
int solve(int r) {
int out = c(n + r, r);
for (int x = 1; x <= r / m; ++x) {
out =
(out + (ll)c(n, m) * (f(x, r - m * (x + 1)) - f(x, r - m * x) + mod)) %
mod;
}
return out;
}
int main() {
int l, r;
cin >> n >> m >> l >> r;
fact[0] = 1;
for (int i = 1; i <= n + r; ++i)
fact[i] = (ll)fact[i - 1] * i % mod;
invf[n + r] = qpow(fact[n + r], mod - 2);
for (int i = n + r; i >= 1; --i)
invf[i - 1] = (ll)invf[i] * i % mod;
cout << (solve(r) - solve(l - 1) + mod) % mod;
return 0;
}
|
[
"assignment.change",
"control_flow.loop.for.initializer.change"
] | 732,539
| 732,540
|
u872322009
|
cpp
|
p02932
|
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
const int P = 1e9 + 7;
#define fr(i, low, up, st) for (register int i = low; i <= up; i += st)
#define nfr(i, low, up, st) for (register int i = low; i >= up; i -= st)
#define size(a) a.size()
#define fill(a, b) memset(a, b, sizeof a)
int fact[N], inv[N];
inline int pow_mod(int x, int k) {
int res = 1, base = x;
while (k) {
if (k & 1)
res = 1LL * res * base % P;
k >>= 1;
base = 1LL * base * base % P;
}
return res;
}
void init() {
fact[0] = inv[0] = 1;
fr(i, 1, N - 1, 1) fact[i] = 1LL * fact[i - 1] * i % P;
inv[N - 1] = pow_mod(fact[N - 1], P - 2);
nfr(i, N - 2, 1, 1) inv[i] = 1LL * inv[i + 1] * (i + 1) % P;
}
inline int c(int n, int m) {
if (n < m)
return 0;
return 1LL * fact[n] * inv[n - m] % P * inv[m] % P;
}
void Mod(int &x) {
x = (x >= P) ? x - P : x;
x = (x < 0) ? x + P : x;
}
int n, m;
int calc(int up, int a, int b) {
int pans = 0;
for (int k = 0; k * (b + 1) + a * m <= up && k + m <= n; ++k) {
Mod(pans += 1LL * pow_mod(-1, k) * c(up - a * m - k * (b + 1) + n, n) *
c(n - m, k) % P);
}
// cerr << up <<' '<< a << ' ' << b <<' ' << pans << endl;
return 1LL * pans * c(n, m) % P;
}
int solve(int up) {
int ans = 0;
fr(i, 1, up, 1) {
Mod(ans += calc(up, i, i - 1) - calc(up, i + 1, i - 1));
// cerr << i <<' '<< ans << endl;
}
Mod(ans = c(up + n, n) - ans);
return ans;
}
int main() {
init();
int L, R;
scanf("%d%d%d%d", &n, &m, &L, &R);
int fans = 0;
Mod(fans = solve(R) - solve(L - 1));
printf("%d\n", fans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
const int P = 1e9 + 7;
#define fr(i, low, up, st) for (register int i = low; i <= up; i += st)
#define nfr(i, low, up, st) for (register int i = low; i >= up; i -= st)
#define size(a) a.size()
#define fill(a, b) memset(a, b, sizeof a)
int fact[N], inv[N];
inline int pow_mod(int x, int k) {
int res = 1, base = x;
while (k) {
if (k & 1)
res = 1LL * res * base % P;
k >>= 1;
base = 1LL * base * base % P;
}
return res;
}
void init() {
fact[0] = inv[0] = 1;
fr(i, 1, N - 1, 1) fact[i] = 1LL * fact[i - 1] * i % P;
inv[N - 1] = pow_mod(fact[N - 1], P - 2);
nfr(i, N - 2, 1, 1) inv[i] = 1LL * inv[i + 1] * (i + 1) % P;
}
inline int c(int n, int m) {
if (n < m)
return 0;
return 1LL * fact[n] * inv[n - m] % P * inv[m] % P;
}
void Mod(int &x) {
x = (x >= P) ? x - P : x;
x = (x < 0) ? x + P : x;
}
int n, m;
int calc(int up, int a, int b) {
int pans = 0;
for (int k = 0; 1LL * k * (b + 1) + 1LL * a * m <= up && k + m <= n; ++k) {
Mod(pans += 1LL * pow_mod(-1, k) * c(up - a * m - k * (b + 1) + n, n) *
c(n - m, k) % P);
}
// cerr << up <<' '<< a << ' ' << b <<' ' << pans << endl;
return 1LL * pans * c(n, m) % P;
}
int solve(int up) {
int ans = 0;
fr(i, 1, up, 1) {
Mod(ans += calc(up, i, i - 1) - calc(up, i + 1, i - 1));
// cerr << i <<' '<< ans << endl;
}
Mod(ans = c(up + n, n) - ans);
return ans;
}
int main() {
init();
int L, R;
scanf("%d%d%d%d", &n, &m, &L, &R);
int fans = 0;
Mod(fans = solve(R) - solve(L - 1));
printf("%d\n", fans);
return 0;
}
|
[
"control_flow.loop.for.condition.change"
] | 732,548
| 732,549
|
u106671729
|
cpp
|
p02932
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <ciso646>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop \
char nyaa; \
cin >> nyaa;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
ll mod_pow(ll x, ll n) {
ll ret = 1;
while (n > 0) {
if (n % 2)
ret = ret * x % mod;
x = x * x % mod;
n >>= 1;
}
return ret;
}
struct perm {
private:
int sz;
vector<ll> p, invp;
public:
perm(int n) {
sz = n + 1;
p.resize(sz), invp.resize(sz);
p[0] = 1;
rep1(i, sz - 1) { p[i] = p[i - 1] * i % mod; }
invp[sz - 1] = 1;
ll cop = mod - 2, x = p[sz - 1];
while (cop) {
if (cop % 2)
invp[sz - 1] = invp[sz - 1] * x % mod;
cop >>= 1;
x = x * x % mod;
}
per(i, sz - 1) { invp[i] = invp[i + 1] * (i + 1) % mod; }
}
ll comb(ll x, ll y) {
if (x < y || y < 0)
return 0;
ll ret = p[x];
(ret *= invp[y]) %= mod;
(ret *= invp[x - y]) %= mod;
return ret;
}
ll combP(ll x, ll y) {
if (x < y || y < 0)
return 0;
return p[x] * invp[x - y] % mod;
}
};
perm p(1 << 19);
ll calc(int n, int m, int r) {
ll res = 0;
// cout << "hello" << endl;
for (int t = 1; t <= r; t++) {
int s = r - m * t;
if (s < 0)
break;
ll sum = 0;
for (int j = 0; j <= n - m; j++) {
int ss = s - t * j;
if (ss < 0)
break;
ll csum = p.comb(n - m, j) * p.comb(n + ss, n) % mod;
if (j % 2 == 0) {
sum += csum;
} else {
sum -= csum;
}
}
sum = (sum % mod + mod) % mod;
s -= m;
if (s >= 0) {
for (int j = 0; j <= n - m; j++) {
int ss = s - t * j;
if (ss < 0)
break;
ll csum = p.comb(n - m, j) * p.comb(n + ss, n) % mod;
if (j % 2 == 0) {
sum -= csum;
} else {
sum += csum;
}
}
}
sum = (sum % mod + mod) % mod;
res += sum;
// cout << sum << endl;
}
res %= mod;
res = res * p.comb(n, m) % mod;
ll orians = p.comb(n + r, n);
// cout << res << " " << orians << endl;
orians -= res;
if (orians < 0)
orians += mod;
return orians;
}
void solve() {
int n, m, l, r;
cin >> n >> m >> l >> r;
ll ans = calc(n, m, r) - calc(n, m, l - 1);
if (ans < 0)
ans += mod;
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
// cout << fixed << setprecision(5);
// init();
solve();
// cout << "finish" << endl;
// stop
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <ciso646>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop \
char nyaa; \
cin >> nyaa;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
ll mod_pow(ll x, ll n) {
ll ret = 1;
while (n > 0) {
if (n % 2)
ret = ret * x % mod;
x = x * x % mod;
n >>= 1;
}
return ret;
}
struct perm {
private:
int sz;
vector<ll> p, invp;
public:
perm(int n) {
sz = n + 1;
p.resize(sz), invp.resize(sz);
p[0] = 1;
rep1(i, sz - 1) { p[i] = p[i - 1] * i % mod; }
invp[sz - 1] = 1;
ll cop = mod - 2, x = p[sz - 1];
while (cop) {
if (cop % 2)
invp[sz - 1] = invp[sz - 1] * x % mod;
cop >>= 1;
x = x * x % mod;
}
per(i, sz - 1) { invp[i] = invp[i + 1] * (i + 1) % mod; }
}
ll comb(ll x, ll y) {
if (x < y || y < 0)
return 0;
ll ret = p[x];
(ret *= invp[y]) %= mod;
(ret *= invp[x - y]) %= mod;
return ret;
}
ll combP(ll x, ll y) {
if (x < y || y < 0)
return 0;
return p[x] * invp[x - y] % mod;
}
};
perm p(1 << 20);
ll calc(int n, int m, int r) {
ll res = 0;
// cout << "hello" << endl;
for (int t = 1; t <= r; t++) {
int s = r - m * t;
if (s < 0)
break;
ll sum = 0;
for (int j = 0; j <= n - m; j++) {
int ss = s - t * j;
if (ss < 0)
break;
ll csum = p.comb(n - m, j) * p.comb(n + ss, n) % mod;
if (j % 2 == 0) {
sum += csum;
} else {
sum -= csum;
}
}
sum = (sum % mod + mod) % mod;
s -= m;
if (s >= 0) {
for (int j = 0; j <= n - m; j++) {
int ss = s - t * j;
if (ss < 0)
break;
ll csum = p.comb(n - m, j) * p.comb(n + ss, n) % mod;
if (j % 2 == 0) {
sum -= csum;
} else {
sum += csum;
}
}
}
sum = (sum % mod + mod) % mod;
res += sum;
// cout << sum << endl;
}
res %= mod;
res = res * p.comb(n, m) % mod;
ll orians = p.comb(n + r, n);
// cout << res << " " << orians << endl;
orians -= res;
if (orians < 0)
orians += mod;
return orians;
}
void solve() {
int n, m, l, r;
cin >> n >> m >> l >> r;
ll ans = calc(n, m, r) - calc(n, m, l - 1);
if (ans < 0)
ans += mod;
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
// cout << fixed << setprecision(5);
// init();
solve();
// cout << "finish" << endl;
// stop
return 0;
}
|
[
"literal.number.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 732,550
| 732,551
|
u294531924
|
cpp
|
p02932
|
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
const int Maxn = 1e6;
const ll Mod = 1e9 + 7;
ll fac[Maxn + 5], inv_fac[Maxn + 5];
ll QuickPow(ll a, ll k) {
ll ret = 1;
while (k) {
if (k & 1)
ret = (ret * a) % Mod;
a = (a * a) % Mod;
k >>= 1;
}
return ret;
}
void init() {
fac[0] = 1;
for (int i = 1; i <= Maxn; i++)
fac[i] = fac[i - 1] * i % Mod;
inv_fac[0] = 1, inv_fac[Maxn] = QuickPow(fac[Maxn], Mod - 2);
for (int i = Maxn - 1; i >= 1; i--)
inv_fac[i] = inv_fac[i + 1] * (i + 1) % Mod;
}
ll C(int n, int m) { return fac[n] * inv_fac[m] % Mod * inv_fac[n - m] % Mod; }
ll calc(int n, int m, int num, int l, int r) {
if (num - r * m < 0)
return 0;
else
num -= (r * m);
ll ret = 0;
for (int i = 0, dir = 1; i <= n - m && num >= 0; i++, num -= l, dir *= -1)
ret =
(ret + 1LL * dir * C(num + n, n) % Mod * C(n - m, i) % Mod + Mod) % Mod;
return ret * C(n, m) % Mod;
}
ll Solve(int n, int m, int num) {
ll ret = C(n + num, n);
for (int i = num; i >= 1; i--) {
int del = (calc(n, m, num, i, i) - calc(n, m, num, i, i + 1) + Mod) % Mod;
ret = (ret - del + Mod) % Mod;
}
return ret;
}
int main() {
#ifdef LOACL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int N, M, L, R;
init();
scanf("%d %d %d %d", &N, &M, &L, &R);
printf("%lld\n", (Solve(N, M, R) - Solve(N, M, L - 1) + Mod) % Mod);
return 0;
}
|
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
const int Maxn = 1e6;
const ll Mod = 1e9 + 7;
ll fac[Maxn + 5], inv_fac[Maxn + 5];
ll QuickPow(ll a, ll k) {
ll ret = 1;
while (k) {
if (k & 1)
ret = (ret * a) % Mod;
a = (a * a) % Mod;
k >>= 1;
}
return ret;
}
void init() {
fac[0] = 1;
for (int i = 1; i <= Maxn; i++)
fac[i] = fac[i - 1] * i % Mod;
inv_fac[0] = 1, inv_fac[Maxn] = QuickPow(fac[Maxn], Mod - 2);
for (int i = Maxn - 1; i >= 1; i--)
inv_fac[i] = inv_fac[i + 1] * (i + 1) % Mod;
}
ll C(int n, int m) { return fac[n] * inv_fac[m] % Mod * inv_fac[n - m] % Mod; }
ll calc(int n, int m, int num, int l, int r) {
if (num - 1LL * r * m < 0)
return 0;
else
num -= (r * m);
ll ret = 0;
for (int i = 0, dir = 1; i <= n - m && num >= 0; i++, num -= l, dir *= -1)
ret =
(ret + 1LL * dir * C(num + n, n) % Mod * C(n - m, i) % Mod + Mod) % Mod;
return ret * C(n, m) % Mod;
}
ll Solve(int n, int m, int num) {
ll ret = C(n + num, n);
for (int i = num; i >= 1; i--) {
int del = (calc(n, m, num, i, i) - calc(n, m, num, i, i + 1) + Mod) % Mod;
ret = (ret - del + Mod) % Mod;
}
return ret;
}
int main() {
#ifdef LOACL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int N, M, L, R;
init();
scanf("%d %d %d %d", &N, &M, &L, &R);
printf("%lld\n", (Solve(N, M, R) - Solve(N, M, L - 1) + Mod) % Mod);
return 0;
}
|
[
"control_flow.branch.if.condition.change"
] | 732,552
| 732,553
|
u327598261
|
cpp
|
p02932
|
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define FORall(it, a) \
for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int)1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int)1e9 + 23111992;
const ll LINF = (ll)1e18 + 23111992;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {
ll r;
while (b) {
r = a % b;
a = b;
b = r;
}
return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD) {
ll r = 1;
for (; k; k >>= 1) {
if (k & 1)
r = r * n % p;
n = n * n % p;
}
return r;
}
template <class T> inline int chkmin(T &a, const T &val) {
return val < a ? a = val, 1 : 0;
}
template <class T> inline int chkmax(T &a, const T &val) {
return a < val ? a = val, 1 : 0;
}
inline ull isqrt(ull k) {
ull r = sqrt(k) + 1;
while (r * r > k)
r--;
return r;
}
inline ll icbrt(ll k) {
ll r = cbrt(k) + 1;
while (r * r * r > k)
r--;
return r;
}
inline void addmod(int &a, int val, int p = MOD) {
if ((a = (a + val)) >= p)
a -= p;
}
inline void submod(int &a, int val, int p = MOD) {
if ((a = (a - val)) < 0)
a += p;
}
inline int mult(int a, int b, int p = MOD) { return (ll)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(ld x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(ld x, ld y) { return sign(x - y); }
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int mrand() { return abs((int)mt()); }
#define db(x) cerr << "[" << #x << ": " << (x) << "] ";
#define endln cerr << "\n";
void solve() {
int n, m, l, r;
cin >> n >> m >> l >> r;
vi fac(n + r + 1 << 1), ifac(n + r + 1 << 1);
fac[0] = 1;
FOR(i, 1, sz(fac)) fac[i] = mult(fac[i - 1], i);
FOR(i, 0, sz(fac)) ifac[i] = inv(fac[i]);
auto binom = [&](int n, int k) {
if (n < k)
return 0;
return mult(fac[n], mult(ifac[k], ifac[n - k]));
};
vi f(r + 1);
FOR(i, 0, n - m + 1) if (m + i <= r) {
f[m + i] = binom(n - m, i);
if (i & 1) {
f[m + i] = (MOD - f[m + i]) % MOD;
}
}
vector<vi> g(r + 1);
FOR(i, 1, r + 1) {
for (int j = 0; j <= r; j += i) {
g[j].pb(i);
}
}
vi h(r + 1);
FOR(i, 0, r + 1) {
for (int x : g[i]) {
addmod(h[i], f[x]);
}
}
auto func = [&](int t) {
int res = 0;
FOR(i, 0, t + 1) {
int coef = binom(n + i, i);
if (m <= i) {
submod(coef, binom(n + i - m, i - m));
}
addmod(res, mult(coef, h[t - i]));
}
return mult(res, binom(n, m));
};
int res = binom(r + n, n);
if (l)
submod(res, binom(l - 1 + n, n));
submod(res, func(r));
if (l)
addmod(res, func(l - 1));
cout << res << "\n";
}
int main(int argc, char *argv[]) {
ios_base::sync_with_stdio(0), cin.tie(0);
if (argc > 1) {
assert(freopen(argv[1], "r", stdin));
}
if (argc > 2) {
assert(freopen(argv[2], "wb", stdout));
}
solve();
cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define FORall(it, a) \
for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int)1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int)1e9 + 23111992;
const ll LINF = (ll)1e18 + 23111992;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {
ll r;
while (b) {
r = a % b;
a = b;
b = r;
}
return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD) {
ll r = 1;
for (; k; k >>= 1) {
if (k & 1)
r = r * n % p;
n = n * n % p;
}
return r;
}
template <class T> inline int chkmin(T &a, const T &val) {
return val < a ? a = val, 1 : 0;
}
template <class T> inline int chkmax(T &a, const T &val) {
return a < val ? a = val, 1 : 0;
}
inline ull isqrt(ull k) {
ull r = sqrt(k) + 1;
while (r * r > k)
r--;
return r;
}
inline ll icbrt(ll k) {
ll r = cbrt(k) + 1;
while (r * r * r > k)
r--;
return r;
}
inline void addmod(int &a, int val, int p = MOD) {
if ((a = (a + val)) >= p)
a -= p;
}
inline void submod(int &a, int val, int p = MOD) {
if ((a = (a - val)) < 0)
a += p;
}
inline int mult(int a, int b, int p = MOD) { return (ll)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(ld x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(ld x, ld y) { return sign(x - y); }
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int mrand() { return abs((int)mt()); }
#define db(x) cerr << "[" << #x << ": " << (x) << "] ";
#define endln cerr << "\n";
void solve() {
int n, m, l, r;
cin >> n >> m >> l >> r;
vi fac(n + r + 1 << 1), ifac(n + r + 1 << 1);
fac[0] = 1;
FOR(i, 1, sz(fac)) fac[i] = mult(fac[i - 1], i);
FOR(i, 0, sz(fac)) ifac[i] = inv(fac[i]);
auto binom = [&](int n, int k) {
if (n < k)
return 0;
return mult(fac[n], mult(ifac[k], ifac[n - k]));
};
vi f(r + 1);
FOR(i, 0, n - m + 1) if (m + i <= r) {
f[m + i] = binom(n - m, i);
if (i & 1) {
f[m + i] = (MOD - f[m + i]) % MOD;
}
}
vector<vi> g(r + 1);
FOR(i, 1, r + 1) {
for (int j = 0; j <= r; j += i) {
g[j].pb(i);
}
}
vi h(r + 1);
FOR(i, 1, r + 1) {
for (int x : g[i]) {
addmod(h[i], f[x]);
}
}
auto func = [&](int t) {
int res = 0;
FOR(i, 0, t + 1) {
int coef = binom(n + i, i);
if (m <= i) {
submod(coef, binom(n + i - m, i - m));
}
addmod(res, mult(coef, h[t - i]));
}
return mult(res, binom(n, m));
};
int res = binom(r + n, n);
if (l)
submod(res, binom(l - 1 + n, n));
submod(res, func(r));
if (l)
addmod(res, func(l - 1));
cout << res << "\n";
}
int main(int argc, char *argv[]) {
ios_base::sync_with_stdio(0), cin.tie(0);
if (argc > 1) {
assert(freopen(argv[1], "r", stdin));
}
if (argc > 2) {
assert(freopen(argv[2], "wb", stdout));
}
solve();
cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
|
[
"literal.number.change",
"call.arguments.change"
] | 732,556
| 732,557
|
u264312457
|
cpp
|
p02933
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
char s[100];
scanf("%d%s", &n, s);
if (n <= 3200)
printf("%s\n", s);
else
printf("red\n");
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
char s[100];
scanf("%d%s", &n, s);
if (n >= 3200)
printf("%s\n", s);
else
printf("red\n");
}
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 732,560
| 732,561
|
u854367220
|
cpp
|
p02933
|
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
#define all(v) (v).begin(), (v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
// typedef vector<vector<ll>> mat;
typedef vector<int> vec;
//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
ll res = 1;
while (n) {
if (n & 1)
res = res * a % m;
a = a * a % m;
n >>= 1;
}
return res;
}
struct modint {
ll n;
modint() : n(0) { ; }
modint(ll m) : n(m) {
if (n >= mod)
n %= mod;
else if (n < 0)
n = (n % mod + mod) % mod;
}
operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) {
a.n += b.n;
if (a.n >= mod)
a.n -= mod;
return a;
}
modint operator-=(modint &a, modint b) {
a.n -= b.n;
if (a.n < 0)
a.n += mod;
return a;
}
modint operator*=(modint &a, modint b) {
a.n = ((ll)a.n * b.n) % mod;
return a;
}
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
if (n == 0)
return modint(1);
modint res = (a * a) ^ (n / 2);
if (n % 2)
res = res * a;
return res;
}
//逆元(Eucledean algorithm)
ll inv(ll a, ll p) { return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p); }
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
fact[0] = modint(1);
for (int i = 0; i < max_n - 1; i++) {
fact[i + 1] = fact[i] * modint(i + 1);
}
factinv[max_n - 1] = modint(1) / fact[max_n - 1];
for (int i = max_n - 2; i >= 0; i--) {
factinv[i] = factinv[i + 1] * modint(i + 1);
}
}
modint comb(int a, int b) {
if (a < 0 || b < 0 || a < b)
return 0;
return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
void solve() {
int a;
string s;
cin >> a >> s;
if (a < 3200)
cout << "res" << endl;
else
cout << s << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
// cout << fixed << setprecision(10);
// init_f();
// init();
// int t; cin >> t; rep(i, t)solve();
solve();
// stop
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define Rep(i, sta, n) for (int i = sta; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define per1(i, n) for (int i = n; i >= 1; i--)
#define Rep1(i, sta, n) for (int i = sta; i <= n; i++)
#define all(v) (v).begin(), (v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
// typedef vector<vector<ll>> mat;
typedef vector<int> vec;
//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
ll res = 1;
while (n) {
if (n & 1)
res = res * a % m;
a = a * a % m;
n >>= 1;
}
return res;
}
struct modint {
ll n;
modint() : n(0) { ; }
modint(ll m) : n(m) {
if (n >= mod)
n %= mod;
else if (n < 0)
n = (n % mod + mod) % mod;
}
operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) {
a.n += b.n;
if (a.n >= mod)
a.n -= mod;
return a;
}
modint operator-=(modint &a, modint b) {
a.n -= b.n;
if (a.n < 0)
a.n += mod;
return a;
}
modint operator*=(modint &a, modint b) {
a.n = ((ll)a.n * b.n) % mod;
return a;
}
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
if (n == 0)
return modint(1);
modint res = (a * a) ^ (n / 2);
if (n % 2)
res = res * a;
return res;
}
//逆元(Eucledean algorithm)
ll inv(ll a, ll p) { return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p); }
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
fact[0] = modint(1);
for (int i = 0; i < max_n - 1; i++) {
fact[i + 1] = fact[i] * modint(i + 1);
}
factinv[max_n - 1] = modint(1) / fact[max_n - 1];
for (int i = max_n - 2; i >= 0; i--) {
factinv[i] = factinv[i + 1] * modint(i + 1);
}
}
modint comb(int a, int b) {
if (a < 0 || b < 0 || a < b)
return 0;
return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
void solve() {
int a;
string s;
cin >> a >> s;
if (a < 3200)
cout << "red" << endl;
else
cout << s << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
// cout << fixed << setprecision(10);
// init_f();
// init();
// int t; cin >> t; rep(i, t)solve();
solve();
// stop
return 0;
}
|
[
"literal.string.change",
"io.output.change"
] | 732,562
| 732,563
|
u132371041
|
cpp
|
p02933
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int A;
cin >> A;
string S;
cin >> S;
if (A < 3200) {
cout << S << endl;
} else {
cout << "red" << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int A;
cin >> A;
string S;
cin >> S;
if (A < 3200) {
cout << "red" << endl;
} else {
cout << S << endl;
}
}
|
[
"control_flow.branch.else.add"
] | 732,569
| 732,570
|
u187772564
|
cpp
|
p02933
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int main() {
int a;
string s;
cin >> a >> s;
if (a >= 3200)
cout << "red" << endl;
else
cout << s << endl;
return 0;
}
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int main() {
int a;
string s;
cin >> a >> s;
if (a >= 3200)
cout << s << endl;
else
cout << "red" << endl;
return 0;
}
|
[
"control_flow.branch.else_if.replace.remove",
"control_flow.branch.if.replace.add",
"control_flow.branch.else.remove"
] | 732,573
| 732,574
|
u629603666
|
cpp
|
p02933
|
#define _USE_MATH_DEFINES
#include <algorithm> //sort,min,max,count
#include <cmath> //sqrt,ceil,M_PI, pow
#include <cstdlib> //abs(int)
#include <deque> //deque
#include <iomanip> //setprecision
#include <ios> //fixed
#include <iostream> //cin, cout
#include <numeric> //gcd
#include <sstream> //stringstream,getline
#include <string> //string,getline
#include <utility> //swap
#include <vector> //vector
using namespace std;
int main() {
int a;
string S;
cin >> a >> S;
if (a <= 3200) {
cout << "red" << endl;
} else {
cout << S << endl;
}
return 0;
}
|
#define _USE_MATH_DEFINES
#include <algorithm> //sort,min,max,count
#include <cmath> //sqrt,ceil,M_PI, pow
#include <cstdlib> //abs(int)
#include <deque> //deque
#include <iomanip> //setprecision
#include <ios> //fixed
#include <iostream> //cin, cout
#include <numeric> //gcd
#include <sstream> //stringstream,getline
#include <string> //string,getline
#include <utility> //swap
#include <vector> //vector
using namespace std;
int main() {
int a;
string S;
cin >> a >> S;
if (a < 3200) {
cout << "red" << endl;
} else {
cout << S << endl;
}
return 0;
}
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 732,575
| 732,576
|
u076251280
|
cpp
|
p02933
|
#include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
vector<int> g[200005];
int main() {
int a;
string s;
cin >> a >> s;
if (a >= 3200) {
cout << "red" << endl;
} else {
cout << s << endl;
}
return 0;
}
|
#include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
vector<int> g[200005];
int main() {
int a;
string s;
cin >> a >> s;
if (a >= 3200) {
cout << s << endl;
} else {
cout << "red" << endl;
}
return 0;
}
|
[
"control_flow.branch.else.add"
] | 732,592
| 732,593
|
u909373588
|
cpp
|
p02933
|
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a;
string s;
cin >> a >> s;
if (a > 3200) {
cout << s;
} else if (a < 3200) {
cout << "red";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a;
string s;
cin >> a >> s;
if (a >= 3200) {
cout << s;
} else if (a < 3200) {
cout << "red";
}
return 0;
}
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 732,625
| 732,626
|
u611594870
|
cpp
|
p02933
|
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
ll a;
string s;
cin >> a >> s;
if (a < 3200)
cout << "red" << endl;
else
cout << "pink" << endl;
return 0;
}
|
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
ll a;
string s;
cin >> a >> s;
if (a < 3200)
cout << "red" << endl;
else
cout << s << endl;
return 0;
}
|
[
"io.output.change"
] | 732,637
| 732,638
|
u171400122
|
cpp
|
p02933
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
string s;
cin >> a >> s;
if (a >= 3200) {
cout << "red" << endl;
} else {
cout << s << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
string s;
cin >> a >> s;
if (a < 3200) {
cout << "red" << endl;
} else {
cout << s << endl;
}
}
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 732,647
| 732,648
|
u758405447
|
cpp
|
p02933
|
#include <bits/stdc++.h>
using namespace ::std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;
template <class T> istream &operator>>(istream &I, vector<T> &v) {
for (T &e : v)
I >> e;
return I;
}
template <class T> ostream &operator<<(ostream &O, const vector<T> &v) {
for (const T &e : v)
O << e << ' ';
return O;
}
void _main() {
int a;
cin >> a;
string s;
cin >> s;
if (a >= 3200)
cout << a;
else
cout << "red";
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("input.txt", "r", stdin);
int _t = 1;
// cin >> _t;
while (_t--)
_main();
return 0;
}
|
#include <bits/stdc++.h>
using namespace ::std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;
template <class T> istream &operator>>(istream &I, vector<T> &v) {
for (T &e : v)
I >> e;
return I;
}
template <class T> ostream &operator<<(ostream &O, const vector<T> &v) {
for (const T &e : v)
O << e << ' ';
return O;
}
void _main() {
int a;
cin >> a;
string s;
cin >> s;
if (a >= 3200)
cout << s;
else
cout << "red";
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("input.txt", "r", stdin);
int _t = 1;
// cin >> _t;
while (_t--)
_main();
return 0;
}
|
[
"identifier.change",
"io.output.change"
] | 732,651
| 732,652
|
u093681822
|
cpp
|
p02933
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
if (n < 3200)
cout << "red";
else
cout << "pink";
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
if (n < 3200)
cout << "red";
else
cout << s;
}
|
[
"io.output.change"
] | 732,670
| 732,671
|
u515638999
|
cpp
|
p02933
|
#include <iostream>
using namespace std;
int main(void) {
int a;
string s;
cin >> a;
cin >> s;
if (a <= 3200) {
cout << "red" << endl;
}
else {
cout << s << endl;
}
}
|
#include <iostream>
using namespace std;
int main(void) {
int a;
string s;
cin >> a;
cin >> s;
if (a < 3200) {
cout << "red" << endl;
}
else {
cout << s << endl;
}
}
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 732,672
| 732,673
|
u426670072
|
cpp
|
p02933
|
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
int n;
char str[11];
scanf("%d%s", &n, &str);
if (n < 3200)
printf("%s\n", str);
else
printf("red\n");
}
|
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
int n;
char str[11];
scanf("%d%s", &n, &str);
if (n >= 3200)
printf("%s\n", str);
else
printf("red\n");
}
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 732,685
| 732,686
|
u283907492
|
cpp
|
p02933
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
int main() {
ll a, s;
cin >> a >> s;
if (a >= 3200) {
cout << s;
} else {
cout << "red";
}
// your code goes here
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
int main() {
ll a;
string s;
cin >> a >> s;
if (a >= 3200) {
cout << s;
} else {
cout << "red";
}
// your code goes here
return 0;
}
|
[] | 732,687
| 732,688
|
u166378830
|
cpp
|
p02933
|
#include <iostream>
#include <map>
using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main() {
int a;
string s;
cin >> a;
cin >> s;
if (a <= 3200)
fin(s);
else
fin("red");
return 0;
}
|
#include <iostream>
#include <map>
using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main() {
int a;
string s;
cin >> a;
cin >> s;
if (a >= 3200)
fin(s);
else
fin("red");
return 0;
}
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 732,694
| 732,695
|
u568426505
|
cpp
|
p02933
|
#include <iostream>
using namespace std;
int main() {
int s;
int t;
cin >> s;
cin >> t;
if (3200 > s) {
cout << "red";
} else {
cout << t;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int s;
string t;
cin >> s;
cin >> t;
if (3200 > s) {
cout << "red";
} else {
cout << t;
}
return 0;
}
|
[
"variable_declaration.type.change"
] | 732,710
| 732,711
|
u742481447
|
cpp
|
p02933
|
#include <iostream>
using namespace std;
int main() {
int s;
int t;
cin >> s;
cin >> t;
if (3200 < s) {
cout << "red";
} else {
cout << "pink";
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int s;
string t;
cin >> s;
cin >> t;
if (3200 > s) {
cout << "red";
} else {
cout << t;
}
return 0;
}
|
[
"variable_declaration.type.change",
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"io.output.change"
] | 732,712
| 732,711
|
u742481447
|
cpp
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.