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
N,K=list(map(int,input().split())) a=list(map(int,input().split())) a.sort(key=lambda x:abs(x),reverse=True) mod=10**9+7 p=[] m=[] zero=False cntm=0 cntp=0 for aa in a: if aa>0: p.append(aa) if cntp+cntm<K: cntp+=1 elif aa<0: m.append(-aa) if cntp+cntm<K: ...
N,K=list(map(int,input().split())) a=list(map(int,input().split())) a.sort(key=lambda x:abs(x),reverse=True) mod=10**9+7 p=[] m=[] zero=False cntm=0 cntp=0 for aa in a: if aa>=0: p.append(aa) if cntp+cntm<K: cntp+=1 elif aa<0: m.append(-aa) if cntp+cntm<K: ...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20]]
5
346
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline n, k = map(int, input().split()) a = list( map(int, input().split())) p = 10**9+7 a.sort() from bisect import bisect_left, bisect_right zerostart = bisect_left(a, 0) posstart = bisect_right(a, 0) aneg = a[:zerostart] cntzero = posstart - zerosta...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline n, k = map(int, input().split()) a = list( map(int, input().split())) p = 10**9+7 a.sort() from bisect import bisect_left, bisect_right zerostart = bisect_left(a, 0) posstart = bisect_right(a, 0) aneg = a[:zerostart] cntzero = posstart - zerostar...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]]
5
419
# coding: utf-8 def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) B = sorted(A, key=lambda x: abs(x), reverse=True) Bp = [x for x in B if x > 0] Bm = [x for x in B if x < 0] Bpm = [x for x in B if x != 0] Bmm = [] for i in range(0, len(Bm)-1, 2): ...
# coding: utf-8 def main(): N, K = map(int, input().split()) A = list(map(int, input().split())) B = sorted(A, key=lambda x: abs(x), reverse=True) Bp = [x for x in B if x > 0] Bm = [x for x in B if x < 0] Bpm = [x for x in B if x != 0] Bmm = [] for i in range(0, len(Bm)-1, 2): ...
[["-", 28, 23, 0, 679, 12, 666, 0, 657, 31, 22], ["+", 0, 679, 12, 666, 0, 657, 31, 23, 0, 24], ["+", 12, 666, 0, 657, 31, 23, 0, 657, 31, 22], ["+", 12, 666, 0, 657, 31, 23, 0, 657, 17, 33], ["+", 12, 666, 0, 657, 31, 23, 0, 657, 12, 22], ["+", 0, 679, 12, 666, 0, 657, 31, 23, 0, 25]]
5
483
#include <bits/stdc++.h> using namespace std; using ll = long long; static const ll MOD = 1e9 + 7; // 繰り返し自乗法(x^nをmで割った余り) O(logn) ll power(ll x, ll n, ll m) { ll res = 1; if (n > 0) { res = power(x, n / 2, m); if (n % 2 == 0) res = (res * res) % m; else res = (((res * res) % m) * x) % m; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; static const ll MOD = 1e9 + 7; // 繰り返し自乗法(x^nをmで割った余り) O(logn) ll power(ll x, ll n, ll m) { ll res = 1; if (n > 0) { res = power(x, n / 2, m); if (n % 2 == 0) res = (res * res) % m; else res = (((res * res) % m) * x) % m; ...
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 19]]
1
1,276
#include <bits/stdc++.h> //Carefully Crafted by hetp111 using namespace std; #define int long long #define double long double #define all(v) (v).begin(), (v).end() #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define vii vector<pii> #define MOD 1000000007 #define MOD2 998244353 #define MOD3 ...
#include <bits/stdc++.h> //Carefully Crafted by hetp111 using namespace std; #define int long long #define double long double #define all(v) (v).begin(), (v).end() #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define vii vector<pii> #define MOD 1000000007 #define MOD2 998244353 #define MOD3 ...
[["-", 31, 16, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 31, 16, 31, 118, 28, 69, 341, 342, 0, 22], ["-", 12, 16, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 118, 28, 69, 341, 342, 0, 22]]
1
1,083
from heapq import heapify,heappush,heappop N, K = map(int,input().split()) A = list(map(int, input().split())) MOD =1_000_000_007 B = [a for a in A if a > 0] C = [a for a in A if a<= 0] B.sort() C.sort(reverse = True) ans = 1 if N == K: for a in A: ans *= a ans %= MOD elif len(B) == 0 and K % 2 == 1: for i...
from heapq import heapify,heappush,heappop N, K = map(int,input().split()) A = list(map(int, input().split())) MOD =1_000_000_007 B = [a for a in A if a > 0] C = [a for a in A if a<= 0] B.sort() C.sort(reverse = True) ans = 1 if N == K: for a in A: ans *= a ans %= MOD elif len(B) == 0 and K % 2 == 1: for i...
[["-", 0, 57, 15, 679, 31, 679, 31, 666, 667, 47], ["+", 0, 57, 15, 679, 31, 679, 31, 666, 667, 20], ["-", 0, 57, 15, 679, 31, 679, 12, 666, 667, 47], ["+", 0, 57, 15, 679, 31, 679, 12, 666, 667, 20], ["-", 0, 57, 75, 665, 15, 679, 12, 666, 667, 47], ["+", 0, 57, 75, 665, 15, 679, 12, 666, 667, 20], ["-", 0, 57, 64, 19...
5
357
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <time.h> #include <vector> #pragma warn...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <time.h> #include <vector> #pragma warn...
[["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 109], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
802
/* be name khoda */ #define long_enable #include <algorithm> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <numeric> #include <set> #include <vector> using namespace std; #ifdef long_enable typedef long long int ll; #else typedef int ll; #endif typedef pair<ll, ll> pii; typedef pa...
/* be name khoda */ #define long_enable #include <algorithm> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <numeric> #include <set> #include <vector> using namespace std; #ifdef long_enable typedef long long int ll; #else typedef int ll; #endif typedef pair<ll, ll> pii; typedef pa...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47]]
1
699
#!/usr/bin/env python def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) mod = 10**9+7 a.sort() ret = 1 if k % 2 == 0 or a[-1] >= 0: l = 0 r = -1 mlt1 = a[0] * a[1] mlt2 = a[-2] * a[-1] for _ in range(k//2): if m...
#!/usr/bin/env python def main(): n, k = map(int, input().split()) a = list(map(int, input().split())) mod = 10**9+7 a.sort() ret = 1 if k % 2 == 0 or a[-1] >= 0: l = 0 r = -1 mlt1 = a[0] * a[1] mlt2 = a[-2] * a[-1] for _ in range(k//2): if m...
[["-", 64, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["+", 64, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 33], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
232
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; 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 tr...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; 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 tr...
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68]]
1
850
#include <bits/stdc++.h> using namespace std; using i64 = int_fast64_t; #define INF (i64)1e18 #define MOD (i64)(1e9 + 7) #define REP(i, n) for (i64 i = 0; i < n; i++) #define RANGE(i, a, b) for (i64 i = a; i < b; i++) #define EACH(v, e, p) for_each(v.begin(), v.end(), [](auto &e) p) #define MIN(a, b) (a < b) ? a : b #...
#include <bits/stdc++.h> using namespace std; using i64 = int_fast64_t; #define INF (i64)1e18 #define MOD (i64)(1e9 + 7) #define REP(i, n) for (i64 i = 0; i < n; i++) #define RANGE(i, a, b) for (i64 i = a; i < b; i++) #define EACH(v, e, p) for_each(v.begin(), v.end(), [](auto &e) p) #define MIN(a, b) (a < b) ? a : b #...
[["-", 64, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 64, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
1,054
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using vec = vector<T>; template <class T> using vvec = vector<vec<T>>; constexpr ll mod = 1e9 + 7; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} friend ostream &operator<<(ostream &os, const mint &a) { retu...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using vec = vector<T>; template <class T> using vvec = vector<vec<T>>; constexpr ll mod = 1e9 + 7; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} friend ostream &operator<<(ostream &os, const mint &a) { retu...
[["-", 0, 57, 15, 339, 51, 16, 31, 91, 17, 111], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47]]
1
970
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define pb push_back #define mp make_pair #define fi first #define se second #define setbits(x) __builtin_popcount(x) #define zerobits(x) __builtin_ctz(x) #define setbitsll(x) __builtin_popcountll(x) #define zerobitsll(x) __builtin_ctz...
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define pb push_back #define mp make_pair #define fi first #define se second #define setbits(x) __builtin_popcount(x) #define zerobits(x) __builtin_ctz(x) #define setbitsll(x) __builtin_popcountll(x) #define zerobitsll(x) __builtin_ctz...
[["+", 31, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 109], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22]]
1
701
n, k = map(int, input().split()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 mia = sorted([i for i in a if i < 0], reverse=True) pla = sorted([i for i in a if i >= 0]) ans, num = 1, [] if len(pla) == 0 and k % 2 == 1: for i in mia[:k]: ans = ans * i % mod print(ans) exit() for _ in rang...
n, k = map(int, input().split()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 mia = sorted([i for i in a if i < 0], reverse=True) pla = sorted([i for i in a if i >= 0]) ans, num = 1, [] if len(pla) == 0 and k % 2 == 1: for i in mia[:k]: ans = ans * i % mod print(ans); exit() for _ in range(k...
[["+", 36, 36, 0, 656, 0, 57, 64, 196, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 35], ["-", 64, 196, 0, 57, 15, 679, 31, 679, 17, 355], ["+", 0, 57, 64, 196, 0, 57, 15, 679, 17, 354], ["+", 64, 196, 0, 57, 15, 679, 12, 23, 0, 24], ["+", 64, 196, 0, 57, 15, 679, 12, 23, 0, 25]]
5
421
n, k = map(int, input().split()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 mia, pla = [], [] for ai in a: if ai < 0: mia.append(ai) elif ai >= 0: pla.append(ai) mia.sort(reverse=True) pla.sort() cnt = 1 if len(pla) == 0 and k % 2 == 1: for i in mia[:k]: cnt = cnt * i el...
n, k = map(int, input().split()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 mia, pla = [], [] for ai in a: if ai < 0: mia.append(ai) elif ai >= 0: pla.append(ai) mia.sort(reverse=True) pla.sort() cnt = 1 if len(pla) == 0 and k % 2 == 1: for i in mia[:k]: cnt = cnt * i % ...
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 109], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
304
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define showmap(is, js, x) \ { ...
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define showmap(is, js, x) \ { ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
1,124
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define al...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define al...
[["+", 0, 1, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 16, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 12, 22]]
1
664
#include <bits/stdc++.h> #define MOD 1000000007 using namespace std; long long int solve(vector<long long int> a, int n, int k) { sort(a.begin(), a.end()); // case 1 if (a[n - 1] == 0) { return 0; } // case 2 if (a[n - 1] < 0 && k % 2 != 0) { long long int prod = 1; for (int i = n - 1; i >=...
#include <bits/stdc++.h> #define MOD 1000000007 using namespace std; long long int solve(vector<long long int> a, int n, int k) { sort(a.begin(), a.end()); // case 1 if (a[n - 1] == 0 && k & 1) { return 0; } // case 2 if (a[n - 1] < 0 && k % 2 != 0) { long long int prod = 1; for (int i = n ...
[["+", 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, 67], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
410
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimization("Ofast") #pragma GCC optimization("unroll-loops") #pragma comment(linker, "/stack:200000000") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; #define int long long typedef pair<int, int> pi; t...
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimization("Ofast") #pragma GCC optimization("unroll-loops") #pragma comment(linker, "/stack:200000000") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; #define int long long typedef pair<int, int> pi; t...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
730
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) #define show(x) \ { \ for (auto i : x) { ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) #define show(x) \ { \ for (auto i : x) { ...
[["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]]
1
984
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(ri, n) for (int ri = (int)(n - 1); ri >= 0; ri--) #define rep2(i, x, n) for (int i = (int)(x); i < (int)(n); i++) #define rrep2(ri, x, n) for (int ri = (int)(n - 1); ri >= (int)(x); ri--) #define repit(itr, x) for (auto itr = x.b...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(ri, n) for (int ri = (int)(n - 1); ri >= 0; ri--) #define rep2(i, x, n) for (int i = (int)(x); i < (int)(n); i++) #define rrep2(ri, x, n) for (int ri = (int)(n - 1); ri >= (int)(x); ri--) #define repit(itr, x) for (auto itr = x.b...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
513
M=10**9+7 n,k,*a=map(int,open(y:=0).read().split()) a.sort() x=s=1 r=k while r>0: if(t:=a[y]*a[y+1])>a[-x]*a[~x]:s=s*t%M;y+=2;r-=2 else:s=s*a[-x]%M;x+=1;r-=1 if r:s*=a[-x] if a[-1]<0<k%2: s=1 for i in a[-k:]:s=s*i%M print(s%M)
M=10**9+7 n,k,*a=map(int,open(y:=0).read().split()) a.sort() x=s=1 r=k while r>1: if(t:=a[y]*a[y+1])>a[-x]*a[~x]:s=s*t%M;y+=2;r-=2 else:s=s*a[-x]%M;x+=1;r-=1 if r:s*=a[-x] if a[-1]<0<k%2: s=1 for i in a[-k:]:s=s*i%M print(s%M)
[["-", 36, 36, 0, 656, 0, 52, 15, 666, 0, 612], ["+", 36, 36, 0, 656, 0, 52, 15, 666, 0, 612]]
5
165
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int main() { int N, K; cin >> N >> K; vector<long long> pos, neg; for (int i = 0; i < N; i++) { long long A; cin >> A; if (A >= 0) pos.push_back(A); else neg.push_back(-A); } int n_pos = int(pos.siz...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int main() { int N, K; cin >> N >> K; vector<long long> pos, neg; for (int i = 0; i < N; i++) { long long A; cin >> A; if (A >= 0) pos.push_back(A); else neg.push_back(-A); } int n_pos = int(pos.siz...
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 57, 64, 9, 0, 1, 0, 35]]
1
490
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define RREP(...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define RREP(...
[["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]]
1
1,021
#include <bits/stdc++.h> #define endl "\n" #define pb push_back #define SZ(x) ((int)(x.size())) #define FOR(i, s, n) for (ll i = (s); (i) < (n); ++i) #define FORD(i, s, l) for (ll i = (s); (i) >= l; --i) #define F first #define S second #define TC \ ...
#include <bits/stdc++.h> #define endl "\n" #define pb push_back #define SZ(x) ((int)(x.size())) #define FOR(i, s, n) for (ll i = (s); (i) < (n); ++i) #define FORD(i, s, l) for (ll i = (s); (i) >= l; --i) #define F first #define S second #define TC \ ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 109], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
579
import numpy as np N,K = map(int,input().split()) import math A = list(map(int,input().split())) flag = 0 if 0 in A: flag = 1 A.sort() plus = list(filter(lambda x:x>0, A))[::-1] plus = list(map(lambda x:np.longdouble(math.log(x,10000000)),plus)) from itertools import accumulate acc_plu = [0] + list(accumulate(plu...
import numpy as np N,K = map(int,input().split()) import math A = list(map(int,input().split())) flag = 0 if 0 in A: flag = 1 A.sort() plus = list(filter(lambda x:x>0, A))[::-1] plus = list(map(lambda x:np.longdouble(math.log(x,10000000)),plus)) from itertools import accumulate acc_plu = [0] + list(accumulate(plu...
[["+", 64, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
430
#include <algorithm> #include <stdio.h> #include <vector> using namespace std; const long long mod = 1000000007; vector<long long> pos, neg; int zero; int main() { int n, k; scanf("%d %d", &n, &k); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); if (x > 0) pos.push_back(x); else if (...
#include <algorithm> #include <stdio.h> #include <vector> using namespace std; const long long mod = 1000000007; vector<long long> pos, neg; int zero; int main() { int n, k; scanf("%d %d", &n, &k); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); if (x > 0) pos.push_back(x); else if (...
[["-", 0, 57, 15, 339, 51, 16, 31, 91, 17, 111], ["-", 0, 57, 15, 339, 51, 16, 12, 91, 17, 111]]
1
470
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) #define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++) #define repr(i, n) for (ll i = n; i >= 0; i--) #define pb push_back #define COUT(x) cout << (x) << "\n" #define COUTF(x) cout << setprecision(15) << (x) << "\n" #define ENDL cout << "\n" #d...
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) #define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++) #define repr(i, n) for (ll i = n; i >= 0; i--) #define pb push_back #define COUT(x) cout << (x) << "\n" #define COUTF(x) cout << setprecision(15) << (x) << "\n" #define ENDL cout << "\n" #d...
[["-", 0, 2, 3, 4, 0, 2, 63, 346, 141, 22], ["+", 0, 2, 3, 4, 0, 2, 63, 346, 141, 22]]
1
1,160
#include <bits/stdc++.h> #include <math.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define PI 3.14159265359 using namespace std; using ll = long long; using P = pair<int, int>; const int mod = 1000000007; struct mint { ll x; mint(ll x = 0) : x(x % mod) {} mint operator-() const { return mint(-x); } min...
#include <bits/stdc++.h> #include <math.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define PI 3.14159265359 using namespace std; using ll = long long; using P = pair<int, int>; const int mod = 1000000007; struct mint { ll x; mint(ll x = 0) : x(x % mod) {} mint operator-() const { return mint(-x); } min...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
878
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll MOD = 1000000007; // const ll MOD = 998244353; const ll INF = MOD * MOD; const long double EPS = 1e-12; struct mint { ll x; mint(ll x = 0) : x((x % MOD + MOD) % MOD) {} mint operator-() const { return mint(-x); }...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll MOD = 1000000007; // const ll MOD = 998244353; const ll INF = MOD * MOD; const long double EPS = 1e-12; struct mint { ll x; mint(ll x = 0) : x((x % MOD + MOD) % MOD) {} mint operator-() const { return mint(-x); }...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 108], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 90]]
1
13,204
#include <bits/stdc++.h> #define Int int64_t using namespace std; int main() { constexpr Int MOD = 1e9 + 7; Int N, K; cin >> N >> K; vector<Int> a(N), pos, neg; for (int i = 0; i < N; ++i) { cin >> a[i]; if (a[i] > 0) { pos.emplace_back(a[i]); } if (a[i] < 0) { neg.emplace_back(a...
#include <bits/stdc++.h> #define Int int64_t using namespace std; int main() { constexpr Int MOD = 1e9 + 7; Int N, K; cin >> N >> K; vector<Int> a(N), pos, neg; for (int i = 0; i < N; ++i) { cin >> a[i]; if (a[i] > 0) { pos.emplace_back(a[i]); } if (a[i] < 0) { neg.emplace_back(a...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 109], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 31, 23, 0, 16, 17, 109], ["+", 0, 1, 0, 11, 31, 23, 0, 16, 12, 22]]
1
436
#include <bits/stdc++.h> using namespace std; #define all(n) begin(n), end(n) const long long INF = numeric_limits<long long>::max(); typedef long long ll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef unsigned long long ull; template <clas...
#include <bits/stdc++.h> using namespace std; #define all(n) begin(n), end(n) const long long INF = numeric_limits<long long>::max(); typedef long long ll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef unsigned long long ull; template <clas...
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47]]
1
1,597
#include <bits/stdc++.h> using namespace std; /* typedef */ typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; /* constant */ const int INF = 1 << 30; const ll LINF = 1LL << 50; const int NIL = -1; const int MAX = 10000; const int mod = 1000000007; const double pi = 3.141592653589; /* struct fo...
#include <bits/stdc++.h> using namespace std; /* typedef */ typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; /* constant */ const int INF = 1 << 30; const ll LINF = 1LL << 50; const int NIL = -1; const int MAX = 10000; const int mod = 1000000007; const double pi = 3.141592653589; /* struct fo...
[["-", 0, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 0, 9, 0, 52, 8, 9, 0, 43, 39, 78], ["-", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22]]
1
858
(N, K), As = readlines.map{_1.split.map(&:to_i)} M = 10**9 + 7 as = As.sort if as.last < 0 puts as.last(K).inject(1){|r, a| r*a % M} else ans, c, l, r = 1, 0, 0, -1 while c < K - 1 ls, rs = as[l]*as[l + 1], as[r]*as[r - 1] if ls > rs ans = ans*ls % M l += 2 c += 2 else ans = a...
(N, K), As = readlines.map{_1.split.map(&:to_i)} M = 10**9 + 7 as = As.sort if as.last < 0 && K.odd? puts as.last(K).inject(1){|r, a| r*a % M} else ans, c, l, r = 1, 0, 0, -1 while c < K - 1 ls, rs = as[l]*as[l + 1], as[r]*as[r - 1] if ls > rs ans = ans*ls % M l += 2 c += 2 else ...
[["+", 36, 36, 0, 493, 0, 121, 15, 738, 17, 98], ["+", 0, 493, 0, 121, 15, 738, 12, 652, 486, 743], ["+", 0, 493, 0, 121, 15, 738, 12, 652, 17, 131], ["+", 0, 493, 0, 121, 15, 738, 12, 652, 735, 22]]
4
169
#pragma warning(disable : 4996) #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ld, ld> pld; // https://atcoder.jp/contests/abc173/tasks/abc173_e ll mod = 1e9 + 7; int main() { ios::sync_with_stdio...
#pragma warning(disable : 4996) #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ld, ld> pld; // https://atcoder.jp/contests/abc173/tasks/abc173_e ll mod = 1e9 + 7; int main() { ios::sync_with_stdio...
[["+", 64, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 64, 9, 0, 57, 64, 9, 0, 37, 0, 13], ["+", 64, 9, 0, 57, 64, 9, 0, 37, 0, 35], ["-", 0, 57, 75, 76, 0, 1, 0, 11, 17, 110], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 17, 107]]
1
351
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; typedef vector<ll> VI; typedef vector<VI> VVI; const ll MOD = 1000000007; const ll INF = 1e18; #define REP(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() ll power(ll x, ll y) { if (y == 0) return ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; typedef vector<ll> VI; typedef vector<VI> VVI; const ll MOD = 1000000007; const ll INF = 1e18; #define REP(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() ll power(ll x, ll y) { if (y == 0) return ...
[["+", 0, 11, 12, 2, 3, 4, 0, 91, 17, 33]]
1
595
#include <algorithm> #include <cstdio> int abs(int a) { return a > 0 ? a : -a; } bool cmp(int a, int b) { return abs(a) > abs(b); } using std::sort; const int mod = 1000000007l; int n, k, a[1000010]; int pos = 0, neg = 0; int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; ++i) { scanf("%d", a + i);...
#include <algorithm> #include <cstdio> int abs(int a) { return a > 0 ? a : -a; } bool cmp(int a, int b) { return abs(a) > abs(b); } using std::sort; const int mod = 1000000007l; int n, k, a[1000010]; int pos = 0, neg = 0; int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; ++i) { scanf("%d", a + i);...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
590
#include <bits/stdc++.h> using namespace std; #define TRACE(x) x #define WATCH(x) TRACE(cout << #x " = " << x << endl) #define PRINT(x) TRACE(printf(x)) #define WATCHR(a, b) \ TRACE(for (auto c = a; c != b;) cout << *(c++) << " "; cout << endl) #define WATCHC(...
#include <bits/stdc++.h> using namespace std; #define TRACE(x) x #define WATCH(x) TRACE(cout << #x " = " << x << endl) #define PRINT(x) TRACE(printf(x)) #define WATCHR(a, b) \ TRACE(for (auto c = a; c != b;) cout << *(c++) << " "; cout << endl) #define WATCHC(...
[["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]]
1
745
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vector<long long> all(n); for (int i = 0; i < n; i++) { cin >> all[i]; } sort(all.begin(), all.end(), [&](int a, int b) { return abs(a) > abs(b); }); int flag = 0, pi...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vector<long long> all(n); for (int i = 0; i < n; i++) { cin >> all[i]; } sort(all.begin(), all.end(), [&](int a, int b) { return abs(a) > abs(b); }); int flag = 0, pi...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 51, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["-", 0, 57, 15, 339, 51, 16, 12,...
1
458
#include <bits/stdc++.h> using namespace std; // #define int long long #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define REP(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (a); i >= (b); --i) inline bool EQ(double a, double b) {...
#include <bits/stdc++.h> using namespace std; // #define int long long #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define REP(i, n) for (int i = 0; i < int(n); ++i) #define FOR(i, a, b) for (int i = int(a); i <= int(b); ++i) #define FORD(i, a, b) for (int i = int(a); i >= int(b); --i) inline bool EQ(double...
[["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59]]
1
688
#include <bits/stdc++.h> #define SZ(x) ((int)x.size()) #define UNI(x) sort(ALL(x)), x.resize(unique(ALL(x)) - x.begin()); #define GETPOS(c, x) (lower_bound(ALL(c), x) - c.begin()) #define GETpos(c, x) (lower_bound(ALL(c), x) - c.begin()) //// #define MST(x, val) memset((x), val, sizeof((x))); #define ls rt << 1 #define...
#include <bits/stdc++.h> #define SZ(x) ((int)x.size()) #define UNI(x) sort(ALL(x)), x.resize(unique(ALL(x)) - x.begin()); #define GETPOS(c, x) (lower_bound(ALL(c), x) - c.begin()) #define GETpos(c, x) (lower_bound(ALL(c), x) - c.begin()) //// #define MST(x, val) memset((x), val, sizeof((x))); #define ls rt << 1 #define...
[["+", 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
1,028
#include <algorithm> #include <cassert> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(x) (x).begin(), (x).end() #d...
#include <algorithm> #include <cassert> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(x) (x).begin(), (x).end() #d...
[["+", 64, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 64, 9, 0, 57, 64, 9, 0, 37, 0, 13], ["+", 64, 9, 0, 57, 64, 9, 0, 37, 0, 35], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 12, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 17, 72]]
1
891
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() using in = int64_t; #define rep(i, n) for (in i = 0; i < (in)(n); i++) #define REP(i, a, b) for (in i = (in)(a); i < (in)(b); i++) #define Yes cout << "Yes" << endl #define No cout << "No" << endl #define yes cout <...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() using in = int64_t; #define rep(i, n) for (in i = 0; i < (in)(n); i++) #define REP(i, a, b) for (in i = (in)(a); i < (in)(b); i++) #define Yes cout << "Yes" << endl #define No cout << "No" << endl #define yes cout <...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
602
package main import ( "bufio" "os" "strconv" "strings" "fmt" "sort" ) const MOD = 1000000007 func Solve() { var N, K int var A []int NextInt(&N, &K) NextIntSlice(&A) P := make([]int, 0) M := make([]int, 0) Z := 0 for _, a := range A { if a > 0 { P = append(P, a) } if a < 0 { M = ap...
package main import ( "bufio" "os" "strconv" "strings" "fmt" "sort" ) const MOD = 1000000007 func Solve() { var N, K int var A []int NextInt(&N, &K) NextIntSlice(&A) P := make([]int, 0) M := make([]int, 0) Z := 0 for _, a := range A { if a > 0 { P = append(P, a) } if a < 0 { M = ap...
[["-", 0, 430, 15, 16, 31, 23, 0, 16, 17, 98], ["+", 0, 430, 15, 16, 31, 23, 0, 16, 17, 106], ["-", 75, 196, 0, 7, 0, 430, 15, 16, 17, 106], ["+", 75, 196, 0, 7, 0, 430, 15, 16, 17, 98]]
7
1,210
def main(): import sys N,K=list(map(int,sys.stdin.readline().split())) A=list(map(int,sys.stdin.readline().split())) Ap=[x for x in A if x>=0 ] Am=[abs(x) for x in A if x<0] if K==N: out=1 for a in A: out*=a out%=10**9+7 print(out) return...
def main(): import sys N,K=list(map(int,sys.stdin.readline().split())) A=list(map(int,sys.stdin.readline().split())) Ap=[x for x in A if x>=0 ] Am=[abs(x) for x in A if x<0] if K==N: out=1 for a in A: out*=a out%=10**9+7 print(out) return...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 22]]
5
366
#include <algorithm> #include <chrono> #include <cmath> #include <iostream> #include <map> #include <random> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; typedef long double ld; #define fastInp \ cin.tie...
#include <algorithm> #include <chrono> #include <cmath> #include <iostream> #include <map> #include <random> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; typedef long double ld; #define fastInp \ cin.tie...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
773
from collections import deque div = 10 ** 9 + 7 n, k = map(int, input().split()) A = deque(sorted([int(x) for x in input().split()])) maxA = A[-1] ans = 1 for i in range(k // 2): l1 = A[0] l2 = A[1] r1 = A[-1] r2 = A[-2] l = l1 * l2 r = r1 * r2 if k % 2 == 1 and maxA < 0: ans *= r ...
from collections import deque div = 10 ** 9 + 7 n, k = map(int, input().split()) A = deque(sorted([int(x) for x in input().split()])) maxA = A[-1] ans = 1 for i in range(k // 2): l1 = A[0] l2 = A[1] r1 = A[-1] r2 = A[-2] l = l1 * l2 r = r1 * r2 if k % 2 == 1 and maxA < 0: ans *= r ...
[["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 132], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 22]]
5
193
#include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using pl = pair<ll, ll>; const ll INF = ll(1e18); const ll mod = ll(1e9 + 7); const double pi = acos(-1); #define rep0(i, n) for (ll(i) = 0; (i) < (n); ++(i)) #define rrep0(i, n) for (ll(i) = (n)-1; (i) >=...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using pl = pair<ll, ll>; const ll INF = ll(1e18); const ll mod = ll(1e9 + 7); const double pi = acos(-1); #define rep0(i, n) for (ll(i) = 0; (i) < (n); ++(i)) #define rrep0(i, n) for (ll(i) = (n)-1; (i) >=...
[["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["+", 0, 14, 8, 9, 0, 14, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 14, 8, 9, 0, 46], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22]]
1
666
mod = 10**9 + 7 n, k = map(int, input().split()) a = list(map(int, input().split())) if n == k: ans = 1 for i in a: ans *= i ans %= mod print(ans) m = [] p = [] zero = 0 for i in a: if i < 0: m.append(-i) elif i > 0: p.append(i) else: zero += 1 if n - k...
mod = 10**9 + 7 n, k = map(int, input().split()) a = list(map(int, input().split())) if n == k: ans = 1 for i in a: ans *= i ans %= mod print(ans) exit() m = [] p = [] zero = 0 for i in a: if i < 0: m.append(-i) elif i > 0: p.append(i) else: zero += ...
[["+", 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, 25]]
5
401
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long modpow(long long x, long long y) { long long ret = 1; while (y > 0) { if (y & 1) { ret *= x; ret %= mod; } x *= x; x %= mod; y >>= 1; } return ret; } long long modinv(long long x) { x %= m...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long modpow(long long x, long long y) { long long ret = 1; while (y > 0) { if (y & 1) { ret *= x; ret %= mod; } x *= x; x %= mod; y >>= 1; } return ret; } long long modinv(long long x) { x %= m...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 110], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
834
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; //#define ll long long template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1;...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; //#define ll long long template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1;...
[["-", 31, 16, 12, 118, 28, 69, 341, 342, 0, 22], ["+", 31, 16, 12, 118, 28, 69, 341, 342, 0, 22], ["-", 12, 16, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 118, 28, 69, 341, 342, 0, 22], ["-", 12, 16, 12, 118, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 12, 118, 28, 69, 341, 342, 0, 22], ["-", 0, 57, 64, 9, 0, 1,...
1
740
#include <bits/stdc++.h> using namespace std; int const nax = 3e5 + 10; const int mod = 1e9 + 7; int n, k; vector<pair<int, int>> all; int suf[nax]; int pref[nax]; int mul(int a, int b) { return 1LL * a * b % mod; } int fix(int a) { return (a % mod + mod) % mod; } int main() { scanf("%d %d", &n, &k); for (int...
#include <bits/stdc++.h> using namespace std; int const nax = 3e5 + 10; const int mod = 1e9 + 7; int n, k; vector<pair<int, int>> all; int suf[nax]; int pref[nax]; int mul(int a, int b) { return 1LL * a * b % mod; } int fix(int a) { return (a % mod + mod) % mod; } int main() { scanf("%d %d", &n, &k); for (int...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
840
#include <algorithm> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace...
#include <algorithm> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
1,920
#include <bits/stdc++.h> using namespace std; using llong = long long; using ldbl = long double; using lpair = pair<llong, llong>; #define ALL(x) x.begin(), x.end() constexpr llong mod = 1e9 + 7; constexpr llong inf = mod * mod; llong moduro(llong n) { if (n > 0) { return n % mod; } else { return n + (-...
#include <bits/stdc++.h> using namespace std; using llong = long long; using ldbl = long double; using lpair = pair<llong, llong>; #define ALL(x) x.begin(), x.end() constexpr llong mod = 1e9 + 7; constexpr llong inf = mod * mod; llong moduro(llong n) { if (n > 0) { return n % mod; } else { return n + (-...
[["-", 0, 57, 75, 76, 0, 9, 0, 338, 12, 22], ["+", 0, 57, 75, 76, 0, 9, 0, 338, 12, 22], ["-", 75, 76, 0, 57, 64, 9, 0, 37, 0, 38], ["-", 75, 76, 0, 57, 64, 9, 0, 37, 0, 13], ["-", 75, 76, 0, 57, 64, 9, 0, 37, 0, 35]]
1
689
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") import math n,k = map(int, input().split()) a = list(map(int, input().split())) a1 = [item for item in a if item>0] a2 = [item for item in a if item<0] n1 = sum(item>0 for item ...
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") import math n,k = map(int, input().split()) a = list(map(int, input().split())) a1 = [item for item in a if item>0] a2 = [item for item in a if item<0] n1 = sum(item>0 for item ...
[["-", 0, 662, 12, 658, 8, 652, 63, 319, 319, 22], ["+", 0, 662, 12, 658, 8, 652, 63, 319, 319, 22], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 72], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 22], ["-", 12, 652, 3, 4, 0, 657, 12, 657,...
5
481
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define llint long ...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define llint long ...
[["-", 0, 9, 0, 1, 0, 34, 31, 11, 12, 22], ["+", 0, 9, 0, 1, 0, 34, 31, 11, 12, 22], ["-", 0, 34, 31, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 34, 31, 11, 12, 2, 3, 4, 0, 22]]
1
823
#define INF 10000000000 #define MOD 1000000007 #if 1 // use_templates #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <st...
#define INF 10000000000 #define MOD 1000000007 #if 1 // use_templates #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <st...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
1,921
#include <algorithm> #include <complex> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define REP(i, m, n) for (int i...
#include <algorithm> #include <complex> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define REP(i, m, n) for (int i...
[["+", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 109], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
1,285
<?php [$N, $K] = fscanf(STDIN, "%d%d"); const MOD = 1000000007; $list = fscanf(STDIN, str_repeat("%d", $N)); $zero = 0; $neg = []; $pos = []; foreach($list as $value){ if($value < 0){ $neg[] = $value; }elseif($value > 0){ $pos[] = $value; }else{ $zero++; } } $count_neg = count(...
<?php [$N, $K] = fscanf(STDIN, "%d%d"); const MOD = 1000000007; $list = fscanf(STDIN, str_repeat("%d", $N)); $zero = 0; $neg = []; $pos = []; foreach($list as $value){ if($value < 0){ $neg[] = $value; }elseif($value > 0){ $pos[] = $value; }else{ $zero++; } } $count_neg = count(...
[["-", 8, 9, 0, 57, 15, 23, 0, 613, 63, 141], ["-", 0, 57, 15, 23, 0, 613, 3, 3, 0, 24], ["-", 0, 57, 15, 23, 0, 613, 3, 3, 0, 25], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 612]]
6
634
n,k=map(int,input().split()) a = list(map(int, input().split())) b = [(abs(i), 1 if i >= 0 else -1) for i in a] b = sorted(b) b = list(reversed(b)) mod = int(1e9 + 7) def fp(x,y): res=1 while y > 0: if y % 2 == 1: res *= x x *= x y //= 2 x %= mod res %= mod return res def inv(x): return fp(x,mod-2)...
n,k=map(int,input().split()) a = list(map(int, input().split())) b = [(abs(i), 1 if i >= 0 else -1) for i in a] b = sorted(b) b = list(reversed(b)) mod = int(1e9 + 7) def fp(x,y): res=1 while y > 0: if y % 2 == 1: res *= x x *= x y //= 2 x %= mod res %= mod return res def inv(x): return fp(x,mod-2)...
[["-", 0, 662, 12, 657, 12, 206, 51, 206, 206, 22], ["+", 0, 662, 12, 657, 12, 206, 51, 206, 206, 22]]
5
570
#include <bits/stdc++.h> #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define F first #define S second #define pb push_back #define pp pop_back #define ubo upper_bound #define lbo lower_bound #define VI vector<int> #define VL vector<ll> #define VP vector<pll> #define a...
#include <bits/stdc++.h> #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define F first #define S second #define pb push_back #define pp pop_back #define ubo upper_bound #define lbo lower_bound #define VI vector<int> #define VL vector<ll> #define VP vector<pll> #define a...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
611
import sys input = sys.stdin.readline mod = 10**9+7 N, K = map(int, input().split()) A = list(map(int, input().split())) Mi = [] for a in A: if a != 0: Mi.append((abs(a), a//abs(a))) Mi.sort(reverse=True) if len(Mi) < K: ans = 0 else: ans = 1 seg = 1 lastinv = -1 lastpu = -1 for ...
import sys input = sys.stdin.readline mod = 10**9+7 N, K = map(int, input().split()) A = list(map(int, input().split())) Mi = [] for a in A: if a != 0: Mi.append((abs(a), a//abs(a))) Mi.sort(reverse=True) if len(Mi) < K: ans = 0 else: ans = 1 seg = 1 lastinv = -1 lastpu = -1 for ...
[["-", 0, 57, 75, 76, 8, 196, 0, 706, 0, 707], ["-", 0, 57, 75, 76, 8, 196, 0, 706, 0, 22]]
5
421
#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double #define F first #define S second #define pb push_back #define sqr(x) (x) * (x...
#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double #define F first #define S second #define pb push_back #define sqr(x) (x) * (x...
[["-", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
824
#include <bits/stdc++.h> // cervello|Phoenix using namespace std; #define ll long long int #define eb emplace_back #define mk make_pair #define all(x) x.begin(), x.end() #define mod 1000000007 int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n, k; cin >> n >> k; vector<ll> a(n); int pos = 0; ...
#include <bits/stdc++.h> // cervello|Phoenix using namespace std; #define ll long long int #define eb emplace_back #define mk make_pair #define all(x) x.begin(), x.end() #define mod 1000000007 int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n, k; cin >> n >> k; vector<ll> a(n); int pos = 0; ...
[["+", 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
381
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mems(p) memset(p, -1, sizeof(p)) #define mp make_pair #define pb push_back #define eb emplace_back #define nl "\n" const int mxN = 1e5; const ll MOD = 1e9 + 7; void fast() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); }...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mems(p) memset(p, -1, sizeof(p)) #define mp make_pair #define pb push_back #define eb emplace_back #define nl "\n" const int mxN = 1e5; const ll MOD = 1e9 + 7; void fast() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); }...
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]]
1
780
/* #region header */ #ifdef LOCAL #include "/Users/takakurashokichi/Desktop/atcoder/cxx-prettyprint-master/prettyprint.hpp" #define debug(x) cout << x << endl #else #define debug(...) 42 #endif #pragma GCC optimize("Ofast") #include <bits/stdc++.h> // types using namespace std; using ll = long long; using ull = unsign...
/* #region header */ #ifdef LOCAL #include "/Users/takakurashokichi/Desktop/atcoder/cxx-prettyprint-master/prettyprint.hpp" #define debug(x) cout << x << endl #else #define debug(...) 42 #endif #pragma GCC optimize("Ofast") #include <bits/stdc++.h> // types using namespace std; using ll = long long; using ull = unsign...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 1, 0, 11, 12, 2, 63, 118, 28, 22], ["+", 0, 1, 0, 11, 12, 2, 63, 118, 28, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]]
1
1,806
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; #define pp pair<int, int> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define ld long double #define al(a) (a).begin(), (a).end() #define mk make_pair #define check cout << "?" << endl; ll MOD = 1000000007; ll mod = 9...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll = long long; #define pp pair<int, int> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define ld long double #define al(a) (a).begin(), (a).end() #define mk make_pair #define check cout << "?" << endl; ll MOD = 1000000007; ll mod = 9...
[["+", 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, 109], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 25]]
1
529
#pragma GCC optimize("O3", "unroll-loops") //#pragma GCC target ("avx2") //#pragma comment(linker, "/stack:200000000") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define all(x) x.b...
#pragma GCC optimize("O3", "unroll-loops") //#pragma GCC target ("avx2") //#pragma comment(linker, "/stack:200000000") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define all(x) x.b...
[["-", 8, 9, 0, 57, 64, 9, 0, 126, 128, 129], ["+", 8, 9, 0, 57, 64, 9, 0, 126, 128, 129], ["-", 0, 57, 75, 76, 0, 9, 0, 126, 128, 129], ["+", 0, 57, 75, 76, 0, 9, 0, 126, 128, 129]]
1
3,504
from math import log2 from itertools import accumulate epsilon = 10 ** -5 MOD = 10 ** 9 + 7 N, K = map(int, input().split()) As = list(map(int, input().split())) negs = [] poss = [] for A in As: if A > 0: poss.append(A) elif A < 0: negs.append(-A) poss.sort(reverse = True) negs.sort(reverse...
from math import log2 from itertools import accumulate epsilon = 10 ** -5 MOD = 10 ** 9 + 7 N, K = map(int, input().split()) As = list(map(int, input().split())) negs = [] poss = [] for A in As: if A > 0: poss.append(A) elif A < 0: negs.append(-A) poss.sort(reverse = True) negs.sort(reverse...
[["+", 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, 25]]
5
492
#include <bits/stdc++.h> using namespace std; using lint = long long; lint Power(lint n, lint x, lint mod) { if (x == 0) return 1; lint res = Power(n, x / 2, mod); res = res * res % mod; if (x & 1) res = res * n % mod; return res; } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); ...
#include <bits/stdc++.h> using namespace std; using lint = long long; lint Power(lint n, lint x, lint mod) { if (x == 0) return 1; lint res = Power(n, x / 2, mod); res = res * res % mod; if (x & 1) res = res * n % mod; return res; } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); ...
[["-", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73]]
1
669
#define _CRT_SECURE_NO_WARNINGS #define REL #pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <iom...
#define _CRT_SECURE_NO_WARNINGS #define REL #pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <iom...
[["-", 75, 76, 0, 9, 0, 57, 15, 339, 51, 22], ["+", 75, 76, 0, 9, 0, 57, 15, 339, 51, 22]]
1
1,498
#include <bits/stdc++.h> using namespace std; #define int long long const int M = 1000000007; signed main() { int N, K; cin >> N >> K; vector<int> A(N); for (int &i : A) cin >> i; sort(A.begin(), A.end()); if (A[N - 1] <= 0) { int ans = 1; if (K % 2 == 0) { for (int i = 0; i < K; i++) ...
#include <bits/stdc++.h> using namespace std; #define int long long const int M = 1000000007; signed main() { int N, K; cin >> N >> K; vector<int> A(N); for (int &i : A) cin >> i; sort(A.begin(), A.end()); if (A[N - 1] <= 0) { int ans = 1; if (K % 2 == 1) { for (int i = 0; i < K; i++) ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
363
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define sz(x) int(x.size()) #define pb push_back #define eb emplace_back using ll = long long; using P = pair<int, int>; using LP = pair<ll, ll>; #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) const ll MOD...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define sz(x) int(x.size()) #define pb push_back #define eb emplace_back using ll = long long; using P = pair<int, int>; using LP = pair<ll, ll>; #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) const ll MOD...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
834
#include <bits/stdc++.h> #define ll long long using namespace std; ll a[200009], b[200009]; ll mod = 1e9 + 7; main() { ll n, k; vector<ll> P, N; cin >> n >> k; for (ll i = 1; i <= n; i++) { cin >> a[i]; if (a[i] < 0) N.push_back(-a[i]); else P.push_back(a[i]); } if (k == n) { ll ...
#include <bits/stdc++.h> #define ll long long using namespace std; ll a[200009], b[200009]; ll mod = 1e9 + 7; main() { ll n, k; vector<ll> P, N; cin >> n >> k; for (ll i = 1; i <= n; i++) { cin >> a[i]; if (a[i] < 0) N.push_back(-a[i]); else P.push_back(a[i]); } if (k == n) { ll ...
[["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 16, 12, 23, 0, 91, 17, 33], ["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 25]]
1
418
#include <bits/stdc++.h> using namespace std; const int max_n = -1, mod = 1000000007; int n, k; bool zero; vector<int> a, b; int mul(int x, int y) { return 1LL * x * y % mod; } int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); scanf("%d%d", &n, &k); for (int i = 0; i ...
#include <bits/stdc++.h> using namespace std; const int max_n = -1, mod = 1000000007; int n, k; bool zero; vector<int> a, b; int mul(int x, int y) { return 1LL * x * y % mod; } int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); scanf("%d%d", &n, &k); for (int i = 0; i ...
[["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 35], ["-", 0, 57, 64, 9, 0, 43, 49, 50, 51, 13], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
598
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sta...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sta...
[["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
700
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(v) (v).begin(), (v).end() using ll = long long; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(v) (v).begin(), (v).end() using ll = long long; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD...
[["-", 0, 41, 15, 16, 31, 16, 31, 16, 31, 13], ["+", 0, 41, 15, 16, 31, 16, 31, 16, 31, 13], ["-", 31, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 31, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 15, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 0, 41, 15, 16, 12, 16, 31, 16...
1
1,703
#include <bits/stdc++.h> #define int long long #define double long double #define override_rep(i, l, r, mes, ...) mes #define rep1(i, n) for (int i = 0; i < n; i++) #define rep2(i, l, r) for (int i = l; i < r; i++) #define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__) using namespace std; using P = pai...
#include <bits/stdc++.h> #define int long long #define double long double #define override_rep(i, l, r, mes, ...) mes #define rep1(i, n) for (int i = 0; i < n; i++) #define rep2(i, l, r) for (int i = l; i < r; i++) #define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__) using namespace std; using P = pai...
[["+", 75, 76, 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
1,169
def main(): n = int(input()) ans = n * (n + 1) * (n + 2) // 6 for i in range(n): x, y = map(int, input().split()) if x > y: y, x = x, y ans -= x * (n - y + 1) print(ans) main()
def main(): n = int(input()) ans = n * (n + 1) * (n + 2) // 6 for i in range(n-1): x, y = map(int, input().split()) if x > y: y, x = x, y ans -= x * (n - y + 1) print(ans) main()
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
84
#include <stdio.h> int main() { int i, N, u, w; long long ans = 0, tmp; scanf("%d", &N); for (i = 1; i <= N; i++) ans += (long long)(N - i + 2) * (N - i + 1) / 2; for (i = 1; i <= N; i++) { scanf("%d %d", &u, &w); if (u > w) { u ^= w; w ^= u; u ^= w; } ans -= (long long)...
#include <stdio.h> int main() { int i, N, u, w; long long ans = 0, tmp; scanf("%d", &N); for (i = 1; i <= N; i++) ans += (long long)(N - i + 2) * (N - i + 1) / 2; for (i = 1; i <= N - 1; i++) { scanf("%d %d", &u, &w); if (u > w) { u ^= w; w ^= u; u ^= w; } ans -= (long l...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
0
154
#include <stdio.h> #pragma GCC optimize("O2") static inline char CH() { static char buf[100000], *ptr1 = buf, *ptr2 = buf; return ptr1 == ptr2 && (ptr2 = (ptr1 = buf) + fread(buf, 1, 100000, stdin), ptr1 == ptr2) ? EOF : *ptr1++; } static inline int IN(void) { i...
#include <stdio.h> #pragma GCC optimize("O2") static inline char CH() { static char buf[100000], *ptr1 = buf, *ptr2 = buf; return ptr1 == ptr2 && (ptr2 = (ptr1 = buf) + fread(buf, 1, 100000, stdin), ptr1 == ptr2) ? EOF : *ptr1++; } static inline int IN(void) { i...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 107], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 110]]
1
268
#include <bits/stdc++.h> using namespace std; #define ll long long int int main() { ll i, n, u, v, ans; cin >> n; ans = (n * (n + 1) * (n + 2)) / 6; for (i = 0; i < n; i++) { cin >> u >> v; ans -= ((min(u, v)) * (n - max(u, v) + 1)); } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long int int main() { ll i, n, u, v, ans; cin >> n; ans = (n * (n + 1) * (n + 2)) / 6; for (i = 0; i < n - 1; i++) { cin >> u >> v; ans -= ((min(u, v)) * (n - max(u, v) + 1)); } cout << ans; return 0; }
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
104
#include <bits/stdc++.h> using namespace std; #define ll long long #define FOR(i, l, r) for (ll i = (l); i < (r); ++i) #define REP(i, n) FOR(i, 0, n) int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; ll res = n * (n - 1) * (n - 2) / 6; REP(i, n - 1) { ll u, v; cin >> u >>...
#include <bits/stdc++.h> using namespace std; #define ll long long #define FOR(i, l, r) for (ll i = (l); i < (r); ++i) #define REP(i, n) FOR(i, 0, n) int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; ll res = n * (n + 1) * (n + 2) / 6; REP(i, n - 1) { ll u, v; cin >> u >> ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 31, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["-", 51, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 51, 16, 31, 16, 12, 23, 0, 16, 17, 72]]
1
128
/* Mangal bhavan amangal haari Drabahu su Dasharath achar Bihari Raam Siya Raam Siya Raam jai jai Raam Raam Siya Raam Siya Raam jai jai Raam Ho hoi hai wohi jo Raam rachi raakha Ko kari tarak badhave saakha Raam Siya Raam Siya Raam jai jai Raam Ho dheeraj dharam mitra aru naari Aapad kaal parakhiye chaari Ho jehike jeh...
/* Mangal bhavan amangal haari Drabahu su Dasharath achar Bihari Raam Siya Raam Siya Raam jai jai Raam Raam Siya Raam Siya Raam jai jai Raam Ho hoi hai wohi jo Raam rachi raakha Ko kari tarak badhave saakha Raam Siya Raam Siya Raam jai jai Raam Ho dheeraj dharam mitra aru naari Aapad kaal parakhiye chaari Ho jehike jeh...
[["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13]]
1
663
N = int(input()) es = [[] for _ in range(N)] H = [] for i in range(N-1): a,b = map(int,input().split()) if a > b: a,b = b,a a-=1;b-=1 #es[a].append(b) #es[b].append(a) H.append([a,b]) print(es) ten = N*(N+1)*(N+2)//6 hen = 0 for i in range(N-1): p,q = H[i] hen += (p+1)*(N-1-q+1) ans = ten -hen prin...
N = int(input()) es = [[] for _ in range(N)] H = [] for i in range(N-1): a,b = map(int,input().split()) if a > b: a,b = b,a a-=1;b-=1 #es[a].append(b) #es[b].append(a) H.append([a,b]) ten = N*(N+1)*(N+2)//6 hen = 0 for i in range(N-1): p,q = H[i] hen += (p+1)*(N-1-q+1) ans = ten -hen print(ans)
[["-", 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
150
N = int(input()) V = 0 E = 0 for i in range(N+1): V += i * (N-i+1) for i in range(N): a, b = map(int, input().split()) if a > b: a, b = b, a E += a * (N-b+1) ans = V - E print(ans)
N = int(input()) V = 0 E = 0 for i in range(N+1): V += i * (N-i+1) for i in range(N-1): a, b = map(int, input().split()) if a > b: a, b = b, a E += a * (N-b+1) ans = V - E print(ans)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
91
#include <bits/stdc++.h> using namespace std; int main(void) { long long int ans = 0, n, a, b; cin >> n; for (int i = 1; i <= n; i++) ans += (i * (n - i + 1)); for (int i = 1; i <= n - 1; i++) { cin >> a >> b; if (a < b) swap(a, b); ans -= (a * (n - b + 1)); } cout << ans << "\n"; ...
#include <bits/stdc++.h> using namespace std; int main(void) { long long int ans = 0, n, a, b; cin >> n; for (int i = 1; i <= n; i++) ans += (i * (n - i + 1)); for (int i = 1; i <= n - 1; i++) { cin >> a >> b; if (a > b) swap(a, b); ans -= (a * (n - b + 1)); } cout << ans << "\n"; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
120
#include <bits/stdc++.h> using namespace std; using ll = long long; mt19937 mt; struct Settings { int D; int TMAX = 26; vector<ll> C; vector<vector<ll>> S; Settings(int d, vector<ll> &c, vector<vector<ll>> &s) : D(d), C(c), S(s) {} }; struct Schedule { Settings &ss; vector<int> T; // T[d]: type o...
#include <bits/stdc++.h> using namespace std; using ll = long long; mt19937 mt; struct Settings { int D; int TMAX = 26; vector<ll> C; vector<vector<ll>> S; Settings(int d, vector<ll> &c, vector<vector<ll>> &s) : D(d), C(c), S(s) {} }; struct Schedule { Settings &ss; vector<int> T; // T[d]: type o...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22]]
1
1,697
#include <bits/stdc++.h> using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math //--------...
#include <bits/stdc++.h> using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math //--------...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
1,390
import numpy as np D = int(input()) C = list(map(int, input().split())) for d in D: S = np.array(map(int, input().split())) print(np.argmax(S)+1)
import numpy as np D = int(input()) C = list(map(int, input().split())) for d in range(D): S = np.array(list(map(int, input().split()))) print(np.argmax(S)+1)
[["+", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
64
#include <algorithm> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; typedef vector<ll> vl; typedef vector<int> vi; typedef vector<char> vec; typedef vector<bool> veb; typedef vector<string> ves; typedef vector<vector<ll>>...
#include <algorithm> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; typedef vector<ll> vl; typedef vector<int> vi; typedef vector<char> vec; typedef vector<bool> veb; typedef vector<string> ves; typedef vector<vector<ll>>...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
657
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") D = int(input()) c = list(map(int, input().split())) s = [None]*D for i in range(D): s[i] = list(map(int, input().split())) current = [0]*26 ans = [None]*D def greedy()...
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") D = int(input()) c = list(map(int, input().split())) s = [None]*D for i in range(D): s[i] = list(map(int, input().split())) current = [0]*26 ans = [None]*D def greedy()...
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612]]
5
235
import sys input = sys.stdin.readline D = int(input()) cost = list(map(int, input().split())) S = [list(map(int, input().split())) for _ in range(D)] last_held = [0 for i in range(26)] ans = [] for date, line in enumerate(S): max_score = line[0] - cost[0]*last_held[0] max_index = 0 for i, score in enumera...
import sys input = sys.stdin.readline D = int(input()) cost = list(map(int, input().split())) S = [list(map(int, input().split())) for _ in range(D)] last_held = [-1 for i in range(26)] ans = [] for date, line in enumerate(S): max_score = line[0] - cost[0]*last_held[0] max_index = 0 for i, score in enumer...
[["-", 0, 656, 0, 1, 0, 662, 12, 658, 8, 612], ["+", 0, 1, 0, 662, 12, 658, 8, 664, 17, 33], ["+", 0, 1, 0, 662, 12, 658, 8, 664, 28, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
167
import java.util.*; public class Main { public static void main(String args[]) { Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); int c[] = new int[n]; int s[][] = new int[n][26]; for (int i = 0; i < n; i++) { c[i] = stdIn.nextInt(); } for (int i = 0; i < n; i++) {...
import java.util.*; public class Main { public static void main(String args[]) { Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); int c[] = new int[26]; int s[][] = new int[n][26]; for (int i = 0; i < 26; i++) { c[i] = stdIn.nextInt(); } for (int i = 0; i < n; i++)...
[["-", 0, 503, 49, 200, 51, 227, 497, 505, 0, 22], ["+", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 499]]
3
194
// pragma //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define YOU using #define DONT namespace #define SAY std YOU DONT SAY; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, int> pli; type...
// pragma //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define YOU using #define DONT namespace #define SAY std YOU DONT SAY; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, int> pli; type...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
734
D = int(input()) C = [int(c) for c in input().split()] S = [[int(s) for s in input().split()] for _ in range(D)] T = [0]*26 for i in range(D): temp = -1 for j in range(26): if temp < S[i][j]: temp = S[i][j] idx = j+1 T[i] = idx for t in T: print(t)
D = int(input()) C = [int(c) for c in input().split()] S = [[int(s) for s in input().split()] for _ in range(D)] T = [0]*D for i in range(D): temp = -1 for j in range(26): if temp < S[i][j]: temp = S[i][j] idx = j+1 T[i] = idx for t in T: print(t)
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22]]
5
120
import numpy as np D = int(input()) s = [input() for i in range(D+1)] for i in range(0,D+1): s[i] = s[i].split() s[i] = [int(p) for p in s[i]] a = [] b = [0]*len(s[0]) S = 0 for i in range (1,D+1): mx = np.argmax(s[i]) for j in range(0,len(s[0])): if j == mx: b[j] = 0 else: ...
import numpy as np D = int(input()) s = [input() for i in range(D+1)] for i in range(0,D+1): s[i] = s[i].split() s[i] = [int(p) for p in s[i]] a = [] b = [0]*len(s[0]) S = 0 for i in range (1,D+1): mx = np.argmax(s[i]) for j in range(0,len(s[0])): if j == mx: b[j] = 0 else: ...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
193
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int D = sc.nextInt(); int c[] = new int[26]; int s[][] = new int[D][26]; for (int i = 0; i < 26; i++) { c[i] = sc.nextInt(); } for (int i = 0; i < D; i++) { ...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int D = sc.nextInt(); int c[] = new int[26]; int s[][] = new int[D][26]; for (int i = 0; i < 26; i++) { c[i] = sc.nextInt(); } for (int i = 0; i < D; i++) { ...
[["+", 0, 492, 3, 4, 0, 16, 12, 23, 0, 24], ["+", 0, 492, 3, 4, 0, 16, 12, 23, 0, 25]]
3
350
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdint> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <random> #include <regex> #include...
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdint> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <random> #include <regex> #include...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
2,573
#include <bits/stdc++.h> using namespace std; #define FOR(i, start, end) for (uint64_t i = start; i < end; i++) #define REP(i, n) FOR(i, 0, n) // 最大公約数gcd // 最小公倍数lcm=m*n/gcd uint64_t gcd(uint64_t m, uint64_t n) { uint64_t temp; while (m % n != 0) { temp = n; n = m % n; m = temp; } return n; } ui...
#include <bits/stdc++.h> using namespace std; #define FOR(i, start, end) for (uint64_t i = start; i < end; i++) #define REP(i, n) FOR(i, 0, n) // 最大公約数gcd // 最小公倍数lcm=m*n/gcd uint64_t gcd(uint64_t m, uint64_t n) { uint64_t temp; while (m % n != 0) { temp = n; n = m % n; m = temp; } return n; } ui...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
1
1,097