buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <algorithm> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long const int mod = 1000000007; const ll INF = 1000000000000000000; int A[100010]; i...
#include <algorithm> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long const int mod = 1000000007; const ll INF = 1000000000000000000; int A[200010]; i...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
135
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0, i##_len = int(n); i < i##_len; ++i) #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) #define All(x) (x).begin(), (x).end() #define rAll(x) (x).rbegin(), (x).rend() using namespace std; using ll = long long; int main() { int N; cin >> N; vector<...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0, i##_len = int(n); i < i##_len; ++i) #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) #define All(x) (x).begin(), (x).end() #define rAll(x) (x).rbegin(), (x).rend() using namespace std; using ll = long long; int main() { int N; cin >> N; vector<...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
136
#line 1 "D.cpp" #include <algorithm> #include <array> #include <cstdio> #include <map> #include <string> #line 1 "~/git/library/utility/io.cpp" /** * @brief 入出力 * @author えびちゃん */ #include <cctype> #include <cstddef> #include <iomanip> #include <iostream> #include <tuple> #include <utility> class format { public...
#line 1 "D.cpp" #include <algorithm> #include <array> #include <cstdio> #include <map> #include <string> #line 1 "~/git/library/utility/io.cpp" /** * @brief 入出力 * @author えびちゃん */ #include <cctype> #include <cstddef> #include <iomanip> #include <iostream> #include <tuple> #include <utility> class format { public...
[["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
1,253
#include <bits/stdc++.h> using namespace std; #define INF 100000000 #define YJ 1145141919 #define INF_INT_MAX 2147483647 #define INF_LL 9223372036854775 #define INF_LL_MAX 9223372036854775807 #define EPS 1e-10 #define MOD 1000000007 #define MOD9 998244353 #define Pi acos(-1) #define LL long long #define ULL unsigned ...
#include <bits/stdc++.h> using namespace std; #define INF 100000000 #define YJ 1145141919 #define INF_INT_MAX 2147483647 #define INF_LL 9223372036854775 #define INF_LL_MAX 9223372036854775807 #define EPS 1e-10 #define MOD 1000000007 #define MOD9 998244353 #define Pi acos(-1) #define LL long long #define ULL unsigned ...
[["-", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["-", 0, 1, 0, 11, 12, 2, 63, 118, 119, 120], ["+", 0, 1, 0, 11, 12, 2, 63, 118, 119, 120]]
1
352
import sys from collections import deque import bisect import copy import heapq import itertools import math import random input = sys.stdin.readline sys.setrecursionlimit(1000000) mod = 10 ** 9 + 7 def read_values(): return map(int, input().split()) def read_index(): return map(lambda x: int(x) - 1, input().split()) ...
import sys from collections import deque import bisect import copy import heapq import itertools import math import random input = sys.stdin.readline sys.setrecursionlimit(1000000) mod = 10 ** 9 + 7 def read_values(): return map(int, input().split()) def read_index(): return map(lambda x: int(x) - 1, input().split()) ...
[["-", 0, 679, 12, 666, 0, 657, 31, 652, 63, 22], ["-", 12, 666, 0, 657, 31, 652, 3, 4, 0, 24], ["-", 12, 666, 0, 657, 31, 652, 3, 4, 0, 22], ["-", 12, 666, 0, 657, 31, 652, 3, 4, 0, 25], ["+", 12, 23, 0, 679, 12, 666, 0, 657, 31, 22]]
5
425
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int a[200005]; long long ans = 1; int main() { int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + 1 + n); if (k % 2 == 0) { int p1 = 1, p2 = n; while (p2 > p1 && k) { if (a[p2] * a[p2...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long a[200005]; long long ans = 1; int main() { int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + 1 + n); if (k % 2 == 0) { int p1 = 1, p2 = n; while (p2 > p1 && k) { if (a[p2] ...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 12, 22]]
1
388
/*input 10 10 1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1 */ #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu....
/*input 10 10 1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1 */ #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu....
[["-", 0, 57, 75, 76, 0, 1, 0, 16, 17, 60], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 17, 32]]
1
774
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; int main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); int n, k; cin >> n >> k; int cnt = 0; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; if (a[i] > 0) ++cnt; } sort(a.begin(), a.end(), [&]...
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; int main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); int n, k; cin >> n >> k; int cnt = 0; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; if (a[i] > 0) ++cnt; } sort(a.begin(), a.end(), [&]...
[["-", 31, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 31, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 12, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22]]
1
552
#include <memory.h> #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <uti...
#include <memory.h> #include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <uti...
[["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["-", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13]]
1
503
// Author: Mostafa Mounir Shehab #include <bits/stdc++.h> using namespace std; #define PI acos(-1) #define EPS (1e-10) #define endl "\n" #define SZ(v) (int)(v.size()) #define IO \ ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL), c...
// Author: Mostafa Mounir Shehab #include <bits/stdc++.h> using namespace std; #define PI acos(-1) #define EPS (1e-10) #define endl "\n" #define SZ(v) (int)(v.size()) #define IO \ ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL), c...
[["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]]
1
670
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1000000007; struct mint { ll x; 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 &...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1000000007; struct mint { ll x; 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 &...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 85], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
921
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; typedef long long ll; int mod(int a, int b, int d); int main() { int n, k; int div = 1000000007; cin >> n >> k; vector<int> a(n), ap, am; for (int i = 0; i < n; ++i) { cin ...
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; typedef long long ll; int mod(int a, int b, int d); int main() { int n, k; int div = 1000000007; cin >> n >> k; vector<int> a(n), ap, am; for (int i = 0; i < n; ++i) { cin ...
[["-", 0, 2, 63, 346, 3, 347, 0, 77, 39, 40], ["+", 0, 2, 63, 346, 3, 347, 0, 77, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
559
N, K = map(int, input().split()) A = list(map(int, input().split())) MOD = 10**9+7 def solve(): A.sort(key=lambda x: abs(x), reverse=True) ans = 1 nneg = 0 a, b, c, d = -1, -1, -1, -1 for k in range(K): ans = (ans * A[k])%MOD if A[k] < 0: nneg += 1 b = k ...
N, K = map(int, input().split()) A = list(map(int, input().split())) MOD = 10**9+7 def solve(): A.sort(key=lambda x: abs(x), reverse=True) ans = 1 nneg = 0 a, b, c, d = -1, -1, -1, -1 for k in range(K): ans = (ans * A[k])%MOD if A[k] < 0: nneg += 1 b = k ...
[["-", 75, 76, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 75, 76, 8, 196, 0, 57, 15, 666, 667, 47]]
5
346
#include <algorithm> #include <cmath> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace s...
#include <algorithm> #include <cmath> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace s...
[["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35], ["-", 0, 11, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 16, 31, 69, 341, 342, 0, 22], ["-", 12, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 31, 22]]
1
625
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9 + 7; inline int mult(int a, int b) { return 1ll * a * b % MOD; } int power(int a, int b) { if (!b) { return 1; } if (b % 2) { return mult(power(a, b - 1), a); } return power(mult(a, a), b / 2); } signed main()...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9 + 7; inline int mult(int a, int b) { return (ll)a * b % MOD; } int power(int a, int b) { if (!b) { return 1; } if (b % 2) { return mult(power(a, b - 1), a); } return power(mult(a, a), b / 2); } signed main() {...
[["-", 0, 37, 0, 16, 31, 16, 31, 16, 31, 13], ["-", 0, 37, 0, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 37, 0, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 16, 31, 16, 31, 74, 39, 77, 39, 78], ["+", 0, 37, 0, 16, 31, 16, 31, 74, 0, 25], ["-", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78], ["+", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78...
1
611
#include <bits/stdc++.h> using namespace std; // #include <bits/stdtr1c++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // #pragma GCC optimize("Ofast,no-stack-protector") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=nat...
#include <bits/stdc++.h> using namespace std; // #include <bits/stdtr1c++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // #pragma GCC optimize("Ofast,no-stack-protector") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=nat...
[["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
1,352
#include <bits/stdc++.h> using namespace std; #define SORT(A) std::sort(A.begin(), A.end()) #define RSORT(A) std::sort(A.begin(), A.end(), std::greater<>()) #define FR(A, e) for (auto &e : A) #define SHOW(A) \ for (auto &e : A) { ...
#include <bits/stdc++.h> using namespace std; #define SORT(A) std::sort(A.begin(), A.end()) #define RSORT(A) std::sort(A.begin(), A.end(), std::greater<>()) #define FR(A, e) for (auto &e : A) #define SHOW(A) \ for (auto &e : A) { ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
775
#include <bits/stdc++.h> using namespace std; #define name "" #define ini \ freopen(name ".inp", "r", stdin); \ freopen(name ".out", "w", stdout) #define long long long #define db double #define pii pair<i...
#include <bits/stdc++.h> using namespace std; #define name "" #define ini \ freopen(name ".inp", "r", stdin); \ freopen(name ".out", "w", stdout) #define long long long #define db double #define pii pair<i...
[["+", 51, 16, 12, 16, 31, 16, 31, 16, 31, 13], ["+", 51, 16, 12, 16, 31, 16, 31, 16, 17, 48], ["+", 51, 16, 12, 16, 12, 16, 31, 16, 31, 13], ["+", 51, 16, 12, 16, 12, 16, 31, 16, 17, 48]]
1
480
n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort() mod=10**9+7 ans=1 i=0 j=-1 k_1=k while k_1>1: if a[i]*a[i+1]>a[j]*a[j-1]: ans=ans*a[i]*a[i+1]%mod i+=2 k_1-=2 else: ans=ans*a[j]%mod j-=1 k_1-=1 if k_1==1: ans=ans*a[j]%mod if a[-1]<0 and k%2==1: for i in a[n-k:]: ...
n,k=map(int,input().split()) a=list(map(int,input().split())) a.sort() mod=10**9+7 ans=1 i=0 j=-1 k_1=k while k_1>1: if a[i]*a[i+1]>a[j]*a[j-1]: ans=ans*a[i]*a[i+1]%mod i+=2 k_1-=2 else: ans=ans*a[j]%mod j-=1 k_1-=1 if k_1==1: ans=ans*a[j]%mod if a[-1]<0 and k%2==1: ans=1 for i in a[n-...
[["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]]
5
181
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) #define cint(a) \ int a; \ cin >> a; #define cstr(str) ...
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) #define cint(a) \ int a; \ cin >> a; #define cstr(str) ...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 108]]
1
810
#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; typedef pair<l_l, ll> lll; typedef vector<string> vs; const ll dx[4] = {1, -1, 0, 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; typedef pair<l_l, ll> lll; typedef vector<string> vs; const ll dx[4] = {1, -1, 0, 0...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
989
#include <bits/stdc++.h> using ll = long long; using namespace std; constexpr ll MOD = 1000000007; ll f2(vector<ll> v, int K) { if (K & 1) sort(v.rbegin(), v.rend()); else sort(v.begin(), v.end()); ll res = 1; for (int i = 0; i < K; i++) { res *= v[i]; res %= MOD; } if (res < 0) res += ...
#include <bits/stdc++.h> using ll = long long; using namespace std; constexpr ll MOD = 1000000007; ll f2(vector<ll> v, int K) { if (K & 1) sort(v.rbegin(), v.rend()); else sort(v.begin(), v.end()); ll res = 1; for (int i = 0; i < K; i++) { res *= v[i]; res %= MOD; } if (res < 0) res += ...
[["-", 8, 9, 0, 7, 15, 16, 31, 16, 17, 18], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 19]]
1
473
#include <bits/stdc++.h> using namespace std; typedef long lint; typedef long long llint; typedef pair<int, int> pint; typedef pair<long long, long long> pllint; typedef tuple<long long, long long, long long> tllint; // static const int MAX = 1e6; // static const int NIL = -1; // static const llint INF = 1<<21; stati...
#include <bits/stdc++.h> using namespace std; typedef long lint; typedef long long llint; typedef pair<int, int> pint; typedef pair<long long, long long> pllint; typedef tuple<long long, long long, long long> tllint; // static const int MAX = 1e6; // static const int NIL = -1; // static const llint INF = 1<<21; stati...
[["-", 49, 50, 51, 2, 63, 346, 3, 347, 0, 13], ["+", 49, 50, 51, 2, 63, 346, 3, 347, 0, 13]]
1
783
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> //#include<unordered_map> using namespace std; #define ll long long #define dd cout << endl const long long int inf = 1e18 + 7;...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> //#include<unordered_map> using namespace std; #define ll long long #define dd cout << endl const long long int inf = 1e18 + 7;...
[["+", 8, 9, 0, 57, 64, 1, 0, 34, 0, 21], ["+", 0, 57, 64, 1, 0, 34, 12, 27, 28, 22], ["+", 0, 57, 64, 1, 0, 34, 12, 27, 17, 68]]
1
466
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define DEBUG(x) cout << #x << "=...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define DEBUG(x) cout << #x << "=...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 140], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
809
#include <bits/stdc++.h> using namespace std; bool cmp(int a, int b) { return (b < a); } long long int num = 1e9 + 7; long long mod(long long a) { return (a % num + num) % num; } long long modi(long long a, long long b) { return mod(mod(a) * mod(b)); } int main() { int n, k; cin >> n >> k; long long in; vecto...
#include <bits/stdc++.h> using namespace std; bool cmp(long long a, long long b) { return (b < a); } long long int num = 1e9 + 7; long long mod(long long a) { return (a % num + num) % num; } long long modi(long long a, long long b) { return mod(mod(a) * mod(b)); } int main() { int n, k; cin >> n >> k; long long...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96]]
1
535
#include <bits/stdc++.h> #define int long long using namespace std; const int MOD = 1e9 + 7; vector<int> vec; vector<int> vec2; const int INF = 9e18; int n, k, z = 0, ans = 1; bool ok() { if (vec.size() >= k) return 1; for (int i = 0; i < vec2.size(); i += 2) { if (k >= i && k <= i + vec.size()) retur...
#include <bits/stdc++.h> #define int long long using namespace std; const int MOD = 1e9 + 7; vector<int> vec; vector<int> vec2; const int INF = 9e18; int n, k, z = 0, ans = 1; bool ok() { if (vec.size() >= k) return 1; for (int i = 0; i <= vec2.size(); i += 2) { if (k >= i && k <= i + vec.size()) retu...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
519
#include <algorithm> #include <array> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include ...
#include <algorithm> #include <array> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include ...
[["-", 12, 23, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 51, 16, 12, 23, 0, 16, 31, 16, 17, 47], ["+", 12, 23, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 51, 16, 12, 23, 0, 16, 31, 16, 17, 18], ["-", 12, 23, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 12, 23, 0, 16, 31, 16, 12, 16, 12, 22]]
1
3,940
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(v) (v).begin(), (v).end() #define debug(x) cerr << #x << ": " << (x) << endl #define INF (int)1e9 #define EPS (double)1e-9 #define MOD ((int)1e9 + 7) using namespace std; typedef long long llong; typedef vector<int> vi; typedef vector<...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(v) (v).begin(), (v).end() #define debug(x) cerr << #x << ": " << (x) << endl #define INF (int)1e9 #define EPS (double)1e-9 #define MOD ((int)1e9 + 7) using namespace std; typedef long long llong; typedef vector<int> vi; typedef vector<...
[["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33]]
1
691
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, k; cin >> n >> k; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } long long mod = 1000000007; vector<long long> b(0), c(0); for (int i = 0; i < n; i++) { if (a[i] < 0) { ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, k; cin >> n >> k; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } long long mod = 1000000007; vector<long long> b(0), c(0); for (int i = 0; i < n; i++) { if (a[i] < 0) { ...
[["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 24], ["+", 51, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 51, 16, 12, 23, 0, 16, 31, 16, 17, 18], ["+", 51, 16, 12, 23, 0, 16, 31, 16, 12, 13], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 25]]
1
592
#n,k,*a=map(int,open(0).read().split()) n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] a.sort() print(a) mod=10**9+7 ans=1 i=0 j=-1 kk=k while kk>1: if a[i]*a[i+1]>a[j]*a[j-1]: ans=ans*a[i]*a[i+1]%mod i+=2 kk-=2 else: ans=ans*a[j]%mod j...
#n,k,*a=map(int,open(0).read().split()) n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] a.sort() mod=10**9+7 ans=1 i=0 j=-1 kk=k while kk>1: if a[i]*a[i+1]>a[j]*a[j-1]: ans=ans*a[i]*a[i+1]%mod i+=2 kk-=2 else: ans=ans*a[j]%mod j-=1 ...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
194
import copy from sys import exit n, k = map(int, input().split()) A = list(map(int, input().split())) mod = 10**9 + 7 plus = [] minus = [] for a in A: if a >= 0: plus.append(a) else: minus.append(a) plus.sort() minus.sort(reverse=True) def is_ans_plus(): if len(plus) > 0: if n == ...
import copy from sys import exit n, k = map(int, input().split()) A = list(map(int, input().split())) mod = 10**9 + 7 plus = [] minus = [] for a in A: if a >= 0: plus.append(a) else: minus.append(a) plus.sort() minus.sort(reverse=True) def is_ans_plus(): if len(plus) > 0: if n == ...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]]
5
311
#include <algorithm> #include <cmath> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <vector> using namespace std; #define int long long #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) ...
#include <algorithm> #include <cmath> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <vector> using namespace std; #define int long long #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) ...
[["-", 0, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 11, 12, 2, 3, 4, 0, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
2,677
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 2e5 + 5, mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; vector<ll> pos, neg; bool found = 0; ll ans = 1; for (int i = 0; i < n; i++) { int x; cin >> x;...
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 2e5 + 5, mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; vector<ll> pos, neg; bool found = 0; ll ans = 1; for (int i = 0; i < n; i++) { int x; cin >> x;...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78]]
1
507
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int using namespace __gnu_pbds; typedef tree<pair<ll, pair<ll, ll>>, null_type, less<pair<ll, pair<ll, ll>>>, rb_tree_tag, tree_order_statistics_node_update> ...
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int using namespace __gnu_pbds; typedef tree<pair<ll, pair<ll, ll>>, null_type, less<pair<ll, pair<ll, ll>>>, rb_tree_tag, tree_order_statistics_node_update> ...
[["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22]]
1
430
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef pa...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef pa...
[["-", 0, 57, 64, 1, 0, 2, 63, 118, 28, 22], ["+", 0, 57, 64, 1, 0, 2, 63, 118, 28, 22], ["-", 0, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 0, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 108]]
1
826
n, k = gets.chomp.split.map(&:to_i) pos = [] neg = [] gets.chomp.split.map(&:to_i).each do |e| if e >= 0 pos << e else neg << -e end end pos.sort! neg.sort! MOD = 10 ** 9 + 7 ans = 1 if ([neg.size, k].min & ~1) + pos.size >= k if k % 2 == 1 ans = ans * pos.pop % MOD k -= 1 end while k > ...
n, k = gets.chomp.split.map(&:to_i) pos = [] neg = [] gets.chomp.split.map(&:to_i).each do |e| if e >= 0 pos << e else neg << -e end end pos.sort! neg.sort! MOD = 10 ** 9 + 7 ans = 1 if ([neg.size, k].min & ~1) + pos.size >= k if k % 2 == 1 ans = ans * pos.pop % MOD k -= 1 end while k > ...
[["+", 12, 739, 0, 738, 12, 738, 31, 739, 0, 24], ["+", 12, 739, 0, 738, 12, 738, 12, 739, 0, 25]]
4
225
#include <bits/stdc++.h> using namespace std; int main() { int n, k, mod = 1e9 + 7; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); long long ans = 1; int l = 0, r = n - 1, sign = 1; if (k % 2 == 1) { ans = a[r]; r--; if (ans < ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, mod = 1e9 + 7; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); long long ans = 1; int l = 0, r = n - 1, sign = 1; if (k % 2 == 1) { ans = a[r]; r--; if (ans < ...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
279
MOD = 10**9+7 n, k = map(int, input().split()) a = list(map(int, input().split())) p, q = [], [] for x in a: if x >= 0: p.append(x) else: q.append(x) lp, lq = len(p), len(q) def sp(): p.sort(reverse=True) q.sort() ans = p[0] if k % 2 else 1 s = [] for i in range(0, lq-1, 2): s.appe...
MOD = 10**9+7 n, k = map(int, input().split()) a = list(map(int, input().split())) p, q = [], [] for x in a: if x >= 0: p.append(x) else: q.append(x) lp, lq = len(p), len(q) def sp(): p.sort(reverse=True) q.sort() ans = p[0] if k % 2 else 1 s = [] for i in range(0, lq-1, 2): s.appe...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
288
#include <algorithm> #include <cstdio> #define LL long long #define maxn 200010 #define mod 1000000007 using namespace std; int a[maxn]; LL ans = 1, x, y; int main() { int n, k, i, l, r, b = 1; scanf("%d%d", &n, &k); for (i = 1; i <= n; i++) scanf("%d", &a[i]); sort(a + 1, a + 1 + n); if (k & 1) ans =...
#include <algorithm> #include <cstdio> #define LL long long #define maxn 200010 #define mod 1000000007 using namespace std; int a[maxn]; LL ans = 1, x, y; int main() { int n, k, i, l, r, b = 1; scanf("%d%d", &n, &k); for (i = 1; i <= n; i++) scanf("%d", &a[i]); sort(a + 1, a + 1 + n); if (k & 1) ans =...
[["+", 0, 34, 31, 11, 12, 16, 31, 74, 0, 24], ["+", 31, 11, 12, 16, 31, 74, 39, 77, 39, 78], ["+", 0, 34, 31, 11, 12, 16, 31, 74, 0, 25], ["+", 0, 34, 12, 11, 12, 16, 31, 74, 0, 24], ["+", 12, 11, 12, 16, 31, 74, 39, 77, 39, 78], ["+", 0, 34, 12, 11, 12, 16, 31, 74, 0, 25]]
1
253
#include <algorithm> #include <cmath> #include <cstdint> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define FOR(i, m, n) for (int(i)...
#include <algorithm> #include <cmath> #include <cstdint> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define FOR(i, m, n) for (int(i)...
[["-", 51, 16, 31, 2, 3, 4, 0, 16, 12, 22], ["+", 51, 16, 31, 2, 3, 4, 0, 16, 12, 22], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 51, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 51, 16, 12, 2, 3, 4, 0, 16, 31, 22]]
1
908
#include <bits/stdc++.h> using namespace std; int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0); // int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv // ./prog.exe") >> 8), 0); using Int = long long; const Int MOD = 1000000007; int main()...
#include <bits/stdc++.h> using namespace std; int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0); // int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv // ./prog.exe") >> 8), 0); using Int = long long; const Int MOD = 1000000007; int main()...
[["+", 64, 1, 0, 11, 12, 16, 12, 2, 63, 22], ["+", 0, 11, 12, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 11, 12, 16, 12, 2, 3, 4, 0, 25], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22]]
1
633
#include <bits/stdc++.h> #define int long long using namespace std; const int MOD = 1e9 + 7; int mod(int n, int m = MOD) { n %= m; return n < 0 ? n + m : n; } signed main() { int n, k, ans = 1; cin >> n >> k; vector<int> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr.begin(), arr.end(...
#include <bits/stdc++.h> #define int long long using namespace std; const int MOD = 1e9 + 7; int mod(int n, int m = MOD) { n %= m; return n < 0 ? n + m : n; } signed main() { int n, k, ans = 1; cin >> n >> k; vector<int> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr.begin(), arr.end(...
[["+", 12, 2, 3, 4, 0, 16, 12, 2, 63, 22], ["+", 3, 4, 0, 16, 12, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 16, 12, 2, 3, 4, 0, 25]]
1
346
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; 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 &o...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; 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 &o...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 52, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 9, 0, 52, 8, 9, 0, 43, 39, 78]]
1
815
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) typedef long long ll; const ll MOD = 1000000007; int main() { ll n, k; cin >> n >> k; vector<ll> plus; vector<ll> minus; rep(i, n) { ll a; cin >> a; if (a < ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) typedef long long ll; const ll MOD = 1000000007; int main() { ll n, k; cin >> n >> k; vector<ll> plus; vector<ll> minus; rep(i, n) { ll a; cin >> a; if (a < ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
504
#include <algorithm> #include <fstream> #include <iostream> #include <vector> // BE CAREFUL WITH HASH TABLE & UNORDERED MAP // #include <ext/pb_ds/assoc_container.hpp> // using namespace __gnu_pbds; using namespace std; #define MOD 1000000007 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define F0R(i, b) FOR(...
#include <algorithm> #include <fstream> #include <iostream> #include <vector> // BE CAREFUL WITH HASH TABLE & UNORDERED MAP // #include <ext/pb_ds/assoc_container.hpp> // using namespace __gnu_pbds; using namespace std; #define MOD 1000000007 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define F0R(i, b) FOR(...
[["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22]]
1
535
n,k=map(int,input().split()) arr=list(map(int,input().split())) arr.sort(reverse=True) n=len(arr) l=0 r=n-1 ans=1 if k%2==1: ans=arr[0] l=1 m=10**9+7 if ans<0: for i in range(k): ans*=arr[i] ans%=m print(ans) quit() for i in range(k//2): po=arr[l]*arr[l+1] ne=arr[r]*arr[r-1] ...
n,k=map(int,input().split()) arr=list(map(int,input().split())) arr.sort(reverse=True) n=len(arr) l=0 r=n-1 ans=1 if k%2==1: ans=arr[0] l=1 m=10**9+7 if ans<0: ans=1 for i in range(k): ans*=arr[i] ans%=m print(ans) quit() for i in range(k//2): po=arr[l]*arr[l+1] ne=arr[r]...
[["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]]
5
175
#include <bits/stdc++.h> #define SZ(x) ((int)(x).size()) typedef long long ll; typedef long double ld; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20); int n, k; cin >> n >> k; vector<ll> a(n); for (ll &x : a) { ...
#include <bits/stdc++.h> #define SZ(x) ((int)(x).size()) typedef long long ll; typedef long double ld; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20); int n, k; cin >> n >> k; vector<ll> a(n); for (ll &x : a) { ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
771
import sys input = sys.stdin.readline N, K = [int(x) for x in input().split()] A = [int(x) for x in input().split()] s = []; t = []; for a in A: if a < 0: t.append(a) else: s.append(a) P = 10 ** 9 + 7 # 非負にできるか判定 S = len(s) T = len(t) ok = False if S > 0: if N == K: ok = (T % 2 =...
import sys input = sys.stdin.readline N, K = [int(x) for x in input().split()] A = [int(x) for x in input().split()] s = []; t = []; for a in A: if a < 0: t.append(a) else: s.append(a) P = 10 ** 9 + 7 # 非負にできるか判定 S = len(s) T = len(t) ok = False if S > 0: if N == K: ok = (T % 2 =...
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 109], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
312
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define repn(i, n) for (int i = 1; i <= n; i++) #define LL long long #define pii pair<int, int> #define fi first #define se second #define pb push_back #define mpr make_pair using namespace std; const LL MOD = 1e9 + 7; LL n, t, a[200010], neg = ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define repn(i, n) for (int i = 1; i <= n; i++) #define LL long long #define pii pair<int, int> #define fi first #define se second #define pb push_back #define mpr make_pair using namespace std; const LL MOD = 1e9 + 7; LL n, t, a[200010], neg = ...
[["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 31, 22], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 17, 48], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 12, 22]]
1
590
#include <bits/stdc++.h> using namespace std; using lint = long int; #define pb push_back #define MOD 1000000007 lint N, K, val; lint res = 1; lint plen, nlen; bool sign; vector<lint> pA; vector<lint> nA; bool is_plus(lint p, lint k) { if (k & 1) { if (p > 0) return true; //正の数が皆無 else return fa...
#include <bits/stdc++.h> using namespace std; using lint = long int; #define pb push_back #define MOD 1000000007 lint N, K, val; lint res = 1; lint plen, nlen; bool sign; vector<lint> pA; vector<lint> nA; bool is_plus(lint p, lint k) { if (k & 1) { if (p > 0) return true; //正の数が皆無 else return fa...
[["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 147], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 146]]
1
882
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define mp make_pair #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define rep(i, a, b) for (int i = (a); i < (b); ++i) std::mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); using namespace s...
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define mp make_pair #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define rep(i, a, b) for (int i = (a); i < (b); ++i) std::mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); using namespace s...
[["-", 49, 50, 51, 2, 3, 4, 0, 118, 119, 120], ["+", 49, 50, 51, 2, 3, 4, 0, 118, 119, 120]]
1
1,279
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const long long MOD = 1000000007; struct mint { long long x; mint(long long x = 0) noexcept : x((x + MOD) % MOD) {} mint &operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const long long MOD = 1000000007; struct mint { long long x; mint(long long x = 0) noexcept : x((x + MOD) % MOD) {} mint &operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } ...
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22]]
1
731
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned; using pcc = pair<char, char>; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using tuplis = array<ll, 3>; template <class T> using p...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned; using pcc = pair<char, char>; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using tuplis = array<ll, 3>; template <class T> using p...
[["+", 15, 339, 51, 16, 31, 16, 31, 16, 31, 22], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 20], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 12, 13], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 98]]
1
4,574
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> VI; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; typedef tuple<ll, ll, ll, ll, ll> t5; #define rep(a, n) for (ll ...
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> VI; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; typedef tuple<ll, ll, ll, ll, ll> t5; #define rep(a, n) for (ll ...
[["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
319
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include...
[["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 33], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13]]
1
573
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define repi(i, s, n) for (int i = (s); i < (n); i++) #ifdef LOCAL #define INPUT_FILE \ ifstream in("abc173/abc173_e.txt"); ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define repi(i, s, n) for (int i = (s); i < (n); i++) #ifdef LOCAL #define INPUT_FILE \ ifstream in("abc173/abc173_e.txt"); ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48]]
1
883
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define int ll mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int mod = 1e9 + 7; int pot(int a, int b) { if (b == 0) return 1; int x = pot(a, b / 2); if (b % 2) return x * x % mod * a ...
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define int ll mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int mod = 1e9 + 7; int pot(int a, int b) { if (b == 0) return 1; int x = pot(a, b / 2); if (b % 2) return x * x % mod * a ...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
754
#include <bits/stdc++.h> #define FASTIO using namespace std; using ll = long long; using Vi = vector<int>; using Vl = vector<ll>; using Pii = pair<int, int>; using Pll = pair<ll, ll>; constexpr int I_INF = numeric_limits<int>::max(); constexpr ll L_INF = numeric_limits<ll>::max(); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
#include <bits/stdc++.h> #define FASTIO using namespace std; using ll = long long; using Vi = vector<int>; using Vl = vector<ll>; using Pii = pair<int, int>; using Pll = pair<ll, ll>; constexpr int I_INF = numeric_limits<int>::max(); constexpr ll L_INF = numeric_limits<ll>::max(); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
1,478
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unorder...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unorder...
[["-", 31, 16, 12, 23, 0, 16, 12, 16, 17, 19], ["+", 31, 16, 12, 23, 0, 16, 12, 16, 17, 60], ["-", 12, 23, 0, 16, 12, 16, 12, 16, 17, 72], ["-", 12, 23, 0, 16, 12, 16, 12, 16, 12, 13], ["-", 0, 11, 12, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 11, 12, 16, 31, 16, 12, 69, 28, 22]]
1
1,967
n, k = map(int, input().split()) A = list(map(int, input().split())) MOD = 10 ** 9 + 7 AA = sorted(A, key=lambda x: -abs(x)) nega1 = [] posi1 = [] for a in AA[:k]: if a < 0: nega1.append(a) else: posi1.append(a) nega2 = [] posi2 = [] for a in AA[k:]: if a < 0: nega2.append(a) else: posi2.app...
n, k = map(int, input().split()) A = list(map(int, input().split())) MOD = 10 ** 9 + 7 AA = sorted(A, key=lambda x: -abs(x)) nega1 = [] posi1 = [] for a in AA[:k]: if a < 0: nega1.append(a) else: posi1.append(a) nega2 = [] posi2 = [] for a in AA[k:]: if a < 0: nega2.append(a) else: posi2.app...
[["-", 0, 57, 64, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 18]]
5
346
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) #else #define trace(...) 42 #endif template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << ": " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *na...
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) #else #define trace(...) 42 #endif template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << ": " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *na...
[["-", 0, 2, 63, 346, 3, 347, 0, 77, 39, 40], ["+", 0, 2, 63, 346, 3, 347, 0, 77, 39, 78]]
1
677
#include <algorithm> #include <array> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stac...
#include <algorithm> #include <array> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stac...
[["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
8,250
#include <bits/stdc++.h> #define ll long long #define str string #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define vc vector<char> #define vvc vector<vc> #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define vvll vector<vll> #define vvvll vector<vvll...
#include <bits/stdc++.h> #define ll long long #define str string #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define vc vector<char> #define vvc vector<vc> #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define vvll vector<vll> #define vvvll vector<vvll...
[["-", 0, 11, 12, 118, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 118, 28, 69, 341, 342, 0, 22]]
1
984
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <vector> #define MOD 1000000007 #...
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <vector> #define MOD 1000000007 #...
[["-", 31, 2, 3, 4, 0, 11, 12, 69, 28, 22], ["+", 31, 2, 3, 4, 0, 11, 12, 69, 28, 22]]
1
1,262
#include <bits/stdc++.h> using namespace std; #define ran 202202 struct modular_arithmetic { int mod; modular_arithmetic() { mod = 1000000007; } // No specific settings. int add(int x, int y) { return (x += y) < mod ? x : x - mod; } int sub(int x, int y) { return (x -= y) >= 0 ? x : x + mod; } int mul(in...
#include <bits/stdc++.h> using namespace std; #define ran 202202 struct modular_arithmetic { int mod; modular_arithmetic() { mod = 1000000007; } // No specific settings. int add(int x, int y) { return (x += y) < mod ? x : x - mod; } int sub(int x, int y) { return (x -= y) >= 0 ? x : x + mod; } int mul(in...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47]]
1
762
#include <bits/stdc++.h> using namespace std; using lint = long long; constexpr lint mod = 1e9 + 7; #define all(x) (x).begin(), (x).end() #define bitcount(n) __builtin_popcountl((lint)(n)) #define fcout cout << fixed << setprecision(15) #define highest(x) (63 - __builtin_clzl(x)) #define rep(i, n) for (int i = 0; i < i...
#include <bits/stdc++.h> using namespace std; using lint = long long; constexpr lint mod = 1e9 + 7; #define all(x) (x).begin(), (x).end() #define bitcount(n) __builtin_popcountl((lint)(n)) #define fcout cout << fixed << setprecision(15) #define highest(x) (63 - __builtin_clzl(x)) #define rep(i, n) for (int i = 0; i < i...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
1,640
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long LL; const LL MOD = 1e9 + 7; const LL INF = 1e18; LL prod(vector<LL> &a, int k, int j = -1) { LL ans = 1; for (int i = 0; i < k; i++) if (i != j) ans = (ans * a[i]) % MOD; return ans; } bool any_positive(vec...
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long LL; const LL MOD = 1e9 + 7; const LL INF = 1e18; LL prod(vector<LL> &a, int k, int j = -1) { LL ans = 1; for (int i = 0; i < k; i++) if (i != j) ans = (ans * a[i]) % MOD; return ans; } bool any_positive(vec...
[["-", 15, 339, 51, 16, 31, 16, 31, 91, 17, 33], ["-", 51, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 15, 339, 51, 16, 12, 16, 31, 91, 17, 33], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 51, 16, 12, 16, 12, 69, 341, ...
1
705
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; #define mod 1000000007 int main() { int n, k; int a[200002]; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%lld", &a[i]); sort(a, a + n); int l = 0, r = n - 1, w = 1; long ...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; #define mod 1000000007 int main() { int n, k; long long a[200002]; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%lld", &a[i]); sort(a, a + n); int l = 0, r = n - 1, w = 1; ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
240
#include <bits/stdc++.h> const int N = 200010; const int moder = int(1e9) + 7; using ll = long long; int a[N]; int powermod(int a, int exp) { int ret = 1; for (; exp > 0; exp >>= 1) { if (exp & 1) { ret = 1ll * ret * a % moder; } a = 1ll * a * a % moder; } return ret; } int main() { int ...
#include <bits/stdc++.h> const int N = 200010; const int moder = int(1e9) + 7; using ll = long long; int a[N]; int powermod(int a, int exp) { int ret = 1; for (; exp > 0; exp >>= 1) { if (exp & 1) { ret = 1ll * ret * a % moder; } a = 1ll * a * a % moder; } return ret; } int main() { int ...
[["-", 341, 342, 0, 69, 28, 69, 341, 342, 0, 13], ["+", 341, 342, 0, 69, 28, 69, 341, 342, 0, 13], ["-", 12, 69, 341, 342, 0, 69, 341, 342, 0, 13], ["+", 12, 69, 341, 342, 0, 69, 341, 342, 0, 13]]
1
959
#include <bits/stdc++.h> using namespace std; using ll = long long; 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; r...
#include <bits/stdc++.h> using namespace std; using ll = long long; 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; r...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 108]]
1
792
// includes #include <bits/stdc++.h> using namespace std; // macros #define pb emplace_back #define mk make_pair #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define irep(itr, st) for (auto itr = (st).begin(); itr != (st)...
// includes #include <bits/stdc++.h> using namespace std; // macros #define pb emplace_back #define mk make_pair #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define irep(itr, st) for (auto itr = (st).begin(); itr != (st)...
[["+", 8, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 67], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 25]]
1
1,966
#include <algorithm> #include <array> #include <bitset> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <stdint.h> #include <string> #include <tim...
#include <algorithm> #include <array> #include <bitset> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <stdint.h> #include <string> #include <tim...
[["-", 12, 41, 15, 16, 12, 2, 63, 118, 28, 22], ["+", 12, 41, 15, 16, 12, 2, 63, 118, 28, 22]]
1
555
#include <bits/stdc++.h> using namespace std; #pragma region void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print...
#include <bits/stdc++.h> using namespace std; #pragma region void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print...
[["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 17, 109], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
962
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; constexpr int MX = 200005, MOD = 1e9 + 7; int n, k, a, ps, ns; ll ans = 1, as[MX], rp = MOD, rn = MOD, lp = MOD, ln = MOD; ll inv(ll a) { ll ret = 1; for (int t = MOD - 2; t; t /= 2, (a *= a) %= MOD) ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; constexpr int MX = 200005, MOD = 1e9 + 7; int n, k, a, ps, ns; ll ans = 1, as[MX], rp = MOD, rn = MOD, lp = MOD, ln = MOD; ll inv(ll a) { ll ret = 1; for (int t = MOD - 2; t; t /= 2, (a *= a) %= MOD) ...
[["-", 51, 16, 12, 23, 0, 16, 12, 16, 17, 47], ["+", 51, 16, 12, 23, 0, 16, 12, 16, 17, 18]]
1
437
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) #define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--) 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) { ...
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) #define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--) 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) { ...
[["-", 0, 57, 64, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
741
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) #define loop(k) rep(author_is_masa, k) #define chmin(a, b) \ if ((a)...
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) #define loop(k) rep(author_is_masa, k) #define chmin(a, b) \ if ((a)...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 17, 72], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20]]
1
647
import operator from functools import reduce N, K = map(int, input().split()) A = list(map(int, input().split())) MOD = 10 ** 9 + 7 positives = [a for a in A if a > 0] negatives = [a for a in A if a < 0] positive_cnt = len(positives) negative_cnt = len(negatives) zero_cnt = A.count(0) if 2 * min(K // 2, negative_cnt...
import operator from functools import reduce N, K = map(int, input().split()) A = list(map(int, input().split())) MOD = 10 ** 9 + 7 positives = [a for a in A if a > 0] negatives = [a for a in A if a < 0] positive_cnt = len(positives) negative_cnt = len(negatives) zero_cnt = A.count(0) if 2 * min(K // 2, negative_cnt...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
319
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define repp(i, n, m) for (int(i) = (n); (i) < (m); (i)++) #define repn(i, n) for (int(i) = 1; (i) <= (n); (i)++) #define repr(i, n) for (int(i) = (n - 1); (i) >= 0; (i)--) #define all(x) (x).begin(), (x).end() #define l...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define repp(i, n, m) for (int(i) = (n); (i) < (m); (i)++) #define repn(i, n) for (int(i) = 1; (i) <= (n); (i)++) #define repr(i, n) for (int(i) = (n - 1); (i) >= 0; (i)--) #define all(x) (x).begin(), (x).end() #define l...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
1,011
n,k=map(int, input().split()) A=sorted(list(map(int, input().split()))) mod=10**9+7 if A[-1]<0 and k%2==1: now=1 for i in range(k): now*=A[-i-1]%mod now%=mod # print(now) exit() l=0 r=n-1 ans=1 if k%2==1: ans=A[-1] # print(ans) r-=1 for i in range(k//2): mi=A[l]*A[l+1] ...
n,k=map(int,input().split()) A=sorted(list(map(int, input().split()))) mod=10**9+7 if A[-1]<0 and k%2==1: now=1 for i in range(k): now*=A[-i-1]%mod now%=mod print(now) exit() l=0 r=n-1 ans=1 if k%2==1: ans=A[-1] # print(ans) r-=1 for i in range(k//2): mi=A[l]*A[l+1] #...
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
189
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using vll = vector<ll>; using vi = vector<int>; using vb = vector<bool>; using vs = vector<string>; using pll = pair<ll, ll>; using pii = pair<int, int>; using vpii = vector<pii>; using vpll = vector<pll>; const ll LIN...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using vll = vector<ll>; using vi = vector<int>; using vb = vector<bool>; using vs = vector<string>; using pll = pair<ll, ll>; using pii = pair<int, int>; using vpii = vector<pii>; using vpll = vector<pll>; const ll LIN...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 13]]
1
1,907
// Problem: // E - Multiplication 4 // Editorial // // Contest: AtCoder - AtCoder Beginner Contest 173 // URL: https://atcoder.jp/contests/abc173/tasks/abc173_e // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) //#pragma GCC optimize("Ofast,no-stack-p...
// Problem: // E - Multiplication 4 // Editorial // // Contest: AtCoder - AtCoder Beginner Contest 173 // URL: https://atcoder.jp/contests/abc173/tasks/abc173_e // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) //#pragma GCC optimize("Ofast,no-stack-p...
[["-", 51, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 12, 16, 31, 74, 51, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 74, 51, 69, 341, 342, 0, 22]]
1
1,071
n,k = map(int,input().split()) a = list(map(int,input().split())) s = sorted(a,reverse=True) mod = 10**9 + 7 ans = 1 if k % 2 == 1 and s[0] < 0: for i in range(k): ans = ans * s[i] % mod print(ans) exit() l = 0 r = n - 1 if k % 2 == 1: ans = ans * s[r] r -= 1 for _ in range(k...
n,k = map(int,input().split()) a = list(map(int,input().split())) s = sorted(a,reverse=True) mod = 10**9 + 7 ans = 1 if k % 2 == 1 and s[0] < 0: for i in range(k): ans = ans * s[i] % mod print(ans) exit() l = 0 r = n - 1 if k % 2 == 1: ans = ans * s[l] l += 1 for _ in range(k...
[["-", 0, 1, 0, 662, 12, 657, 12, 206, 206, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 206, 206, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]]
5
185
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; bool comp(ll a, ll b) { return a > b; } ll calcFinal(vector<ll> &v) { ll res = 1; for (ll i : v) { if (i < 0) res *= MOD + i; else res *= i; res %= MOD; } return ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; bool comp(ll a, ll b) { return a > b; } ll calcFinal(vector<ll> &v) { ll res = 1; for (ll i : v) { if (i < 0) res *= MOD + i; else res *= i; res %= MOD; } return ...
[["-", 51, 16, 12, 23, 0, 16, 12, 16, 17, 47], ["+", 51, 16, 12, 23, 0, 16, 12, 16, 17, 18]]
1
611
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) def solve(): N, K = mapint() As = list(mapint()) mod = 10**9+7 pos = [] neg = [] for a in As: if a>=0: pos.append(a) else: ...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) def solve(): N, K = mapint() As = list(mapint()) mod = 10**9+7 pos = [] neg = [] for a in As: if a>=0: pos.append(a) else: ...
[["+", 0, 1, 0, 677, 12, 206, 206, 657, 17, 48], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
422
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" const ll mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); ll n, k; cin >> n >> k; pair<ll, ll> a[n + 1]; for (ll i = 1; i <= n; i++) { cin >> a[i].second; a[i].first = abs(a[i].second); } sort(a +...
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" const ll mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); ll n, k; cin >> n >> k; pair<ll, ll> a[n + 1]; for (ll i = 1; i <= n; i++) { cin >> a[i].second; a[i].first = abs(a[i].second); } sort(a +...
[["-", 51, 16, 31, 23, 0, 16, 31, 118, 119, 120], ["+", 51, 16, 31, 23, 0, 16, 31, 118, 119, 120], ["-", 51, 16, 31, 23, 0, 16, 12, 118, 119, 120], ["+", 51, 16, 31, 23, 0, 16, 12, 118, 119, 120], ["-", 51, 16, 12, 23, 0, 16, 31, 118, 119, 120], ["+", 51, 16, 12, 23, 0, 16, 31, 118, 119, 120], ["-", 51, 16, 12, 23, 0, ...
1
839
#pragma GCC target("avx") //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define LL long long #define DB double #define LD long double #define ST string #define BS bitset #define PA pair<LL...
#pragma GCC target("avx") //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define LL long long #define DB double #define LD long double #define ST string #define BS bitset #define PA pair<LL...
[["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
2,280
# AFTER EDITORIAL, WIP def solve(ls, k, debug=0): modulo = 10 ** 9 + 7 n = len(ls) n_neg = 0 for i in range(n): n_neg += ls[i] < 0 n_pos = n - n_neg # Sort by abs ls_abs = [abs(x) for x in ls] ls_abs_argsort = sorted(list(range(n)), key=lambda i: -ls_abs[i]) # Check if pos...
# AFTER EDITORIAL, WIP def solve(ls, k, debug=0): modulo = 10 ** 9 + 7 n = len(ls) n_neg = 0 for i in range(n): n_neg += ls[i] < 0 n_pos = n - n_neg # Sort by abs ls_abs = [abs(x) for x in ls] ls_abs_argsort = sorted(list(range(n)), key=lambda i: -ls_abs[i]) # Check if pos...
[["-", 8, 196, 0, 1, 0, 662, 31, 684, 0, 21], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32]]
5
644
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #define ull unsigned long long #define ld long double #define vi vector<int> #define vll vector<ll> #define vc vector<char> #define vs vector<string> #define vpii vector<pii> #define vpll vector<pl...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #define ull unsigned long long #define ld long double #define vi vector<int> #define vll vector<ll> #define vc vector<char> #define vs vector<string> #define vpii vector<pii> #define vpll vector<pl...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 31, 22]]
1
888
N,K=map(int, input().split()) A=list(map(int, input().split())) D,E=[],[] zcnt,scnt,fcnt=0,0,0 for i in A: if i==0: zcnt+=1 D.append(0) elif i>0: D.append(i) scnt+=1 else: E.append(i) fcnt+=1 mod=10**9+7 ans=1 #全て使う場合は問答無用でかける if K==N: for i in A: ans*=i ans%=mod print(ans) e...
N,K=map(int, input().split()) A=list(map(int, input().split())) D,E=[],[] zcnt,scnt,fcnt=0,0,0 for i in A: if i==0: zcnt+=1 D.append(0) elif i>0: D.append(i) scnt+=1 else: E.append(i) fcnt+=1 mod=10**9+7 ans=1 #全て使う場合は問答無用でかける if K==N: for i in A: ans*=i ans%=mod print(ans) e...
[["-", 0, 656, 0, 57, 15, 666, 0, 657, 17, 109], ["-", 0, 656, 0, 57, 15, 666, 0, 657, 12, 612], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 12, 22]]
5
462
n, k = map(int, input().split()) a = list(map(int, input().split())) mod = 10**9 + 7 ans = 1 if k == n: for i in range(n): ans *= a[i] ans %= mod print(ans) exit() if max(a) < 0 and k%2 == 1: a.sort(reverse=True) for i in range(k): ans *= a[i] ans %= mod print(an...
n, k = map(int, input().split()) a = list(map(int, input().split())) mod = 10**9 + 7 ans = 1 if k == n: for i in range(n): ans *= a[i] ans %= mod print(ans) exit() if max(a) < 0 and k%2 == 1: a.sort(reverse=True) for i in range(k): ans *= a[i] ans %= mod print(an...
[["-", 15, 679, 31, 666, 0, 206, 206, 664, 28, 612], ["+", 15, 679, 31, 666, 0, 206, 206, 664, 28, 22]]
5
426
import sys s2nn = lambda s: [int(c) for c in s.split(' ')] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] ii2sss = lambda...
import sys s2nn = lambda s: [int(c) for c in s.split(' ')] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] ii2sss = lambda...
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 60], ["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 667, 60], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 0, 612], ["+", 8, 196, 0, 57, 75, 665, 15, 66...
5
555
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int infI = 1e9 + 5; const long long ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int infI = 1e9 + 5; const long long ...
[["-", 15, 339, 51, 16, 12, 16, 31, 16, 31, 22], ["+", 15, 339, 51, 16, 12, 16, 31, 16, 31, 22]]
1
1,077
#include <algorithm> #include <iostream> #include <math.h> #include <string> using namespace std; int main() { int n, k; cin >> n >> k; long long a[n], b[n], c[n]; int al = 0, bl = 0; int i, j; for (i = 0; i < n; i++) { cin >> j; if (j < 0) { b[bl] = -j; c[i] = -j; bl++; } else...
#include <algorithm> #include <iostream> #include <math.h> #include <string> using namespace std; int main() { int n, k; cin >> n >> k; long long a[n], b[n], c[n]; int al = 0, bl = 0; int i, j; for (i = 0; i < n; i++) { cin >> j; if (j < 0) { b[bl] = -j; c[i] = -j; bl++; } else...
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
540
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define Rep(i, n) for (intl i = 0, nn = (intl)(n); i < nn; ++i) #define Rep1(i, n) for (intl i = 1, nn = (intl)(n) + 1; i < nn; ++i) #define vec vector #define fi first #define se second #define eb emplace_back #define SortA(v) sort(v.begin(), v.end()...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define Rep(i, n) for (intl i = 0, nn = (intl)(n); i < nn; ++i) #define Rep1(i, n) for (intl i = 1, nn = (intl)(n) + 1; i < nn; ++i) #define vec vector #define fi first #define se second #define eb emplace_back #define SortA(v) sort(v.begin(), v.end()...
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 79], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 79], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 17, 47]]
1
1,079
n, k = gets.chomp.split(' ').map(&:to_i) a = gets.chomp.split(' ').map(&:to_i).sort M = (1e9+7).to_i if a.any? { |i| i > 0 } || k % 2 == 0 b = [] (0...(k / 2)).each do |m| if a[0] * a[1] >= a[-2] * a[-1] b.append(a.shift(2)) else b.append(a.pop(2)) end end if k % 2 == 1 b.append(a...
n, k = gets.chomp.split(' ').map(&:to_i) a = gets.chomp.split(' ').map(&:to_i).sort M = (1e9+7).to_i if a.any? { |i| i > 0 } || k % 2 == 0 b = [] (0...(k / 2)).each do |m| if a[0] * a[1] >= a[-2] * a[-1] b.append(a.shift(2)) else b.append(a.pop(2)) end end if k % 2 == 1 b.append(a...
[["+", 0, 493, 0, 121, 64, 749, 0, 652, 486, 22], ["+", 0, 493, 0, 121, 64, 749, 0, 652, 17, 131], ["+", 0, 493, 0, 121, 64, 749, 0, 652, 735, 22]]
4
197
/*** akshaykumar99 ***/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template <typename T> using id_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const long long MOD = 1e9 + 7; const long double PI = acos(...
/*** akshaykumar99 ***/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template <typename T> using id_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const long long MOD = 1e9 + 7; const long double PI = acos(...
[["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]]
1
749
// #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, ll> pll; typedef pair<int, pint> ppint; typedef pair<ll, pll> ppll; typedef vector<int> vint; typedef vector<ll> vll; const double pi = 3.141592653589793; const int INF10 = 1000000001; const ll INF15 ...
// #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, ll> pll; typedef pair<int, pint> ppint; typedef pair<ll, pll> ppll; typedef vector<int> vint; typedef vector<ll> vll; const double pi = 3.141592653589793; const int INF10 = 1000000001; const ll INF15 ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46], ["-", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46]]
1
1,591
require 'pp' def puts_answer(ans) o = 1 ans.each do |t| o = (o * t) % MOD end o end MOD = 10 ** 9 + 7 n, k = gets.split.map(&:to_i) a_n = gets.split.map(&:to_i) # 全選択するしかない if a_n.length == k ans = a_n puts puts_answer(ans) exit 0 end # 0 を除く len = a_n.length a_n.delete_if {|a| ...
require 'pp' def puts_answer(ans) o = 1 ans.each do |t| o = (o * t) % MOD end o end MOD = 10 ** 9 + 7 n, k = gets.split.map(&:to_i) a_n = gets.split.map(&:to_i) # 全選択するしかない if a_n.length == k ans = a_n puts puts_answer(ans) exit 0 end # 0 を除く len = a_n.length a_n.delete_if {|a| ...
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22]]
4
407
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1e9 + 7; 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; r...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1e9 + 7; 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; r...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 107], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 110]]
1
1,251