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 <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define all(x) (x).begin(), (x).end() #define cyes cout << "YES" << endl #define cno cout << "NO" << endl #define sp << " " << #define cst(x) cout << fixed << setprecision(x) #define pi 3.14159265359 #define mod 1000000007 using namespace std; using...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define all(x) (x).begin(), (x).end() #define cyes cout << "YES" << endl #define cno cout << "NO" << endl #define sp << " " << #define cst(x) cout << fixed << setprecision(x) #define pi 3.14159265359 #define mod 1000000007 using namespace std; using...
[["-", 0, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
403
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**7) from pprint import pprint as pp from pprint import pformat as pf # @pysnooper.snoop() #import pysnooper # debug import math #from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder import bisect if __name__ ...
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**7) from pprint import pprint as pp from pprint import pformat as pf # @pysnooper.snoop() #import pysnooper # debug import math #from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder import bisect if __name__ ...
[["+", 12, 23, 0, 657, 31, 206, 206, 657, 17, 33], ["+", 12, 23, 0, 657, 31, 206, 206, 657, 12, 612]]
5
186
def resolve(): n = int(input()) low = [] high = [] for i in range(n): a,b = map(int, input().split()) low.append(a) high.append(b) low.sort() high.sort() if n % 2: print(high[(n+1)//2-1] - low[(n+1)//2-1] + 1) else: hh = (high[(n)//2-1] + high[(n)...
def resolve(): n = int(input()) low = [] high = [] for i in range(n): a,b = map(int, input().split()) low.append(a) high.append(b) low.sort() high.sort() if n % 2: print(high[(n+1)//2-1] - low[(n+1)//2-1] + 1) else: hh = (high[(n)//2-1] + high[(n)...
[["+", 31, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]]
5
177
#include <bits/stdc++.h> using namespace std; #define MOD (long long int)(1e9 + 7) #define ll long long int #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, n) for (int i = 1; i <= (int)(n); i++) #define REP(i, n) for (int i = n - 1; i >= 0; i--) #define REPS(i, n) for (int i = n; i > 0; i--) #defin...
#include <bits/stdc++.h> using namespace std; #define MOD (long long int)(1e9 + 7) #define ll long long int #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, n) for (int i = 1; i <= (int)(n); i++) #define REP(i, n) for (int i = n - 1; i >= 0; i--) #define REPS(i, n) for (int i = n; i > 0; i--) #defin...
[["-", 31, 16, 31, 23, 0, 16, 12, 69, 28, 22], ["+", 31, 16, 31, 23, 0, 16, 12, 69, 28, 22], ["-", 31, 16, 12, 23, 0, 16, 31, 69, 28, 22], ["+", 31, 16, 12, 23, 0, 16, 31, 69, 28, 22]]
1
427
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) from collections import defaultdict, deque from sys import exit import math import copy from bisect import bisect_left, bisect_right from heapq import * import sys # sys.setre...
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) from collections import defaultdict, deque from sys import exit import math import copy from bisect import bisect_left, bisect_right from heapq import * import sys # sys...
[["+", 31, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 31, 652, 3, 4, 0, 657, 31, 23, 0, 25]]
5
456
#include <bits/stdc++.h> using namespace std; int n, a[200100], b[200100]; int main() { #ifndef DavidLaptop #ifdef FILIN freopen(FILIN, "r", stdin); freopen(FILOUT, "w", stdout); #endif #endif ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i...
#include <bits/stdc++.h> using namespace std; int n, a[200100], b[200100]; int main() { #ifndef DavidLaptop #ifdef FILIN freopen(FILIN, "r", stdin); freopen(FILOUT, "w", stdout); #endif #endif ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i...
[["-", 31, 16, 12, 16, 31, 16, 31, 16, 17, 85], ["-", 31, 16, 12, 16, 31, 16, 31, 16, 12, 13], ["-", 31, 16, 12, 16, 31, 16, 12, 16, 17, 85], ["-", 31, 16, 12, 16, 31, 16, 12, 16, 12, 13], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
226
N = int(input()) A = [tuple(map(int, input().split())) for _ in range(N)] B = A[:] A.sort(key=lambda x: x[0]) B.sort(key=lambda x: x[1]) if N%2: print(B[N//2][1] - A[N//2][0] + 1) else: print((A[N//2][1] + B[N//2-1][1]) - (B[N//2][0] + A[N//2-1][0])+1)
N = int(input()) A = [tuple(map(int, input().split())) for _ in range(N)] B = A[:] A.sort(key=lambda x: x[0]) B.sort(key=lambda x: x[1]) if N%2: print(B[N//2][1] - A[N//2][0] + 1) else: print((B[N//2][1] + B[N//2-1][1]) - (A[N//2][0] + A[N//2-1][0])+1)
[["-", 31, 23, 0, 657, 31, 206, 51, 206, 51, 22], ["+", 31, 23, 0, 657, 31, 206, 51, 206, 51, 22], ["-", 12, 23, 0, 657, 31, 206, 51, 206, 51, 22], ["+", 12, 23, 0, 657, 31, 206, 51, 206, 51, 22]]
5
151
N = int(input()) A, B = [], [] for i in range(N): tm, p = map(int, input().split()) A.append(tm), B.append(p) A.sort(), B.sort() a = A[N // 2] * 2 if N % 2 == 1 else A[N // 2 - 1] + A[N // 2] b = B[N // 2] * 2 if N % 2 == 1 else B[N // 2 - 1] + B[N // 2] print(b - a + 1 if N % 2 == 1 else b - a + 1)
N = int(input()) A, B = [], [] for i in range(N): tm, p = map(int, input().split()) A.append(tm), B.append(p) A.sort(), B.sort() a = A[N // 2] * 2 if N % 2 == 1 else A[N // 2 - 1] + A[N // 2] b = B[N // 2] * 2 if N % 2 == 1 else B[N // 2 - 1] + B[N // 2] print((b - a) // 2 + 1 if N % 2 == 1 else b - a + 1)
[["+", 0, 41, 0, 657, 31, 657, 31, 23, 0, 24], ["+", 0, 41, 0, 657, 31, 657, 31, 23, 0, 25], ["+", 3, 4, 0, 41, 0, 657, 31, 657, 17, 676], ["+", 3, 4, 0, 41, 0, 657, 31, 657, 12, 612]]
5
149
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep2(i, n, m) for (ll i = n; i <= m; i++) #define rep3(i, n, m) for (ll i = n; ...
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep2(i, n, m) for (ll i = n; i <= m; i++) #define rep3(i, n, m) for (ll i = n; ...
[["-", 0, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
305
import sys input = sys.stdin.readline n = int(input()) a = [] b = [] for i in range(n): ai, bi = map(int, input().split()) a.append(ai) b.append(bi) a.sort() b.sort() if n % 2 == 1: am = a[n // 2] bm = b[n // 2] ans = abs(bm - am) + 1 else: am1 = a[n // 2 - 1] am2 = a[n//2] bm1 = b[n...
import sys input = sys.stdin.readline n = int(input()) a = [] b = [] for i in range(n): ai, bi = map(int, input().split()) a.append(ai) b.append(bi) a.sort() b.sort() if n % 2 == 1: am = a[n // 2] bm = b[n // 2] ans = abs(bm - am) + 1 else: am1 = a[n // 2 - 1] am2 = a[n//2] bm1 = b[n...
[["-", 0, 662, 12, 657, 31, 657, 31, 657, 31, 22], ["+", 0, 662, 12, 657, 31, 657, 31, 657, 31, 22], ["-", 12, 657, 31, 657, 12, 23, 0, 657, 12, 22], ["+", 12, 657, 31, 657, 12, 23, 0, 657, 12, 22]]
5
159
N = int(input()) A = [] B = [] for _ in range(N): a,b = map(int,input().split()) A.append(a) B.append(b) A.sort() B.sort(reverse=True) #print(A,B) if N % 2 == 1: x = (N+1) // 2 ans = B[x-1] - A[x-1] + 1 else: x = N // 2 ans = (B[x-1]-B[x]) - (A[x-1]-A[x]) + 1 print(ans)
N = int(input()) A = [] B = [] for _ in range(N): a,b = map(int,input().split()) A.append(a) B.append(b) A.sort() B.sort(reverse=True) #print(A,B) if N % 2 == 1: x = (N+1) // 2 ans = B[x-1] - A[x-1] + 1 else: x = N // 2 ans = (B[x-1] + B[x]) - (A[x] + A[x-1]) + 1 print(ans)
[["-", 12, 657, 31, 657, 31, 23, 0, 657, 17, 33], ["+", 12, 657, 31, 657, 31, 23, 0, 657, 17, 72], ["-", 12, 23, 0, 657, 31, 206, 206, 657, 17, 33], ["-", 12, 23, 0, 657, 31, 206, 206, 657, 12, 612], ["-", 12, 657, 31, 657, 12, 23, 0, 657, 17, 33], ["+", 12, 657, 31, 657, 12, 23, 0, 657, 17, 72], ["+", 12, 23, 0, 657, ...
5
141
N = int(input()) A = [] B = [] for i in range(N): a,b = map(int,input().split()) A.append(a) B.append(b) A.sort() B.sort() if N%2==1: min_X = A[(N+1)//2-1] max_X = B[(N+1)//2-1] print(max_X - min_X + 1) else: min_X = (A[N//2-1] + A[N//2])//2 max_X = (B[N//2-1] + B[N//2])//2 print(...
N = int(input()) A = [] B = [] for i in range(N): a,b = map(int,input().split()) A.append(a) B.append(b) A.sort() B.sort() if N%2==1: min_X = A[(N+1)//2-1] max_X = B[(N+1)//2-1] print(max_X - min_X + 1) else: min_X = (A[N//2-1] + A[N//2])/2 max_X = (B[N//2-1] + B[N//2])/2 print(in...
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 676], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 0, 652, 3, 4, 0, 657, 31, 652, 63, 22], ["+", 31, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]]
5
161
#include <algorithm> #include <bitset> #include <cassert> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits.h> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #incl...
#include <algorithm> #include <bitset> #include <cassert> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits.h> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #incl...
[["-", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48], ["-", 0, 43, 49, 50, 51, 16, 31, 16, 12, 13], ["-", 64, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 17, 72]]
1
284
#!/usr/bin/env python3 def main(): N = int(input()) A = [None] * N B = [None] * N for i in range(N): A[i], B[i] = map(int, input().split()) A.sort() B.sort() if N % 2 == 1: print(B[(N-1)//2] - A[(N-1)//2] + 1) else: print(B[N//2]+A[N//2] - B[N//2-1] - A[N//2-1] ...
#!/usr/bin/env python3 def main(): N = int(input()) A = [None] * N B = [None] * N for i in range(N): A[i], B[i] = map(int, input().split()) A.sort() B.sort() if N % 2 == 1: print(B[(N-1)//2] - A[(N-1)//2] + 1) else: print(B[N//2]-A[N//2] +B[N//2-1]-A[N//2-1] + 1...
[["-", 0, 657, 31, 657, 31, 657, 31, 657, 17, 72], ["+", 0, 657, 31, 657, 31, 657, 31, 657, 17, 33], ["-", 3, 4, 0, 657, 31, 657, 31, 657, 17, 33], ["+", 3, 4, 0, 657, 31, 657, 31, 657, 17, 72]]
5
149
n = int(input()) la = [] lb = [] for i in range(n): a,b = map(int,input().split()) la.append(a) lb.append(b) la.sort() lb.sort() if n % 2 != 0: left = la[n//2] right = lb[n//2] print(right-left+1) else: left = (la[n//2]+la[n//2-1])/2 right = (lb[n//2]+lb[n//2-1])/2 print(int(right-l...
n = int(input()) la = [] lb = [] for i in range(n): a,b = map(int,input().split()) la.append(a) lb.append(b) la.sort() lb.sort() if n % 2 != 0: left = la[n//2] right = lb[n//2] print(right-left+1) else: left = (la[n//2]+la[n//2-1])/2 right = (lb[n//2]+lb[n//2-1])/2 print(int((right-...
[["+", 31, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]]
5
150
#include <bits/stdc++.h> using namespace std; using lint = long long; using P = pair<int, int>; using vec = vector<lint>; using mat = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define endl "\n" constexpr int MOD = 1000000007; const int INF = 1 << 30; i...
#include <bits/stdc++.h> using namespace std; using lint = long long; using P = pair<int, int>; using vec = vector<lint>; using mat = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define endl "\n" constexpr int MOD = 1000000007; const int INF = 1 << 30; i...
[["-", 12, 16, 31, 16, 12, 118, 28, 69, 28, 22], ["+", 12, 16, 31, 16, 12, 118, 28, 69, 28, 22], ["-", 0, 11, 12, 16, 31, 16, 12, 118, 119, 120], ["+", 0, 11, 12, 16, 31, 16, 12, 118, 119, 120]]
1
297
#include <bits/stdc++.h> using namespace std; using ll = long long; int n; ll a[200005], b[200005]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cin >> n; for (int i = 0; i < n; ++i) cin >> a[i] >> b[i]; sort(a, a + n); sort(b, b + n); if (n & 1) { cout << b[n / 2] - a[n / 2] + ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int n; ll a[200005], b[200005]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cin >> n; for (int i = 0; i < n; ++i) cin >> a[i] >> b[i]; sort(a, a + n); sort(b, b + n); if (n & 1) { cout << b[n / 2] - a[n / 2] + ...
[["-", 49, 50, 51, 16, 31, 23, 0, 16, 12, 22], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 12, 22], ["-", 49, 50, 51, 16, 31, 23, 0, 16, 31, 22], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 31, 22]]
1
230
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") //#pragma GCC target("avx,avx2") //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //# include <x86intrin.h> #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using...
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") //#pragma GCC target("avx,avx2") //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //# include <x86intrin.h> #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78]]
1
487
// Problem : E - Count Median // Contest : AtCoder - AtCoder Beginner Contest 169 // URL : https://atcoder.jp/contests/abc169/tasks/abc169_e // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) // look at my code // my code is amazing #include <bits/stdc++.h...
// Problem : E - Count Median // Contest : AtCoder - AtCoder Beginner Contest 169 // URL : https://atcoder.jp/contests/abc169/tasks/abc169_e // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) // look at my code // my code is amazing #include <bits/stdc++.h...
[["-", 75, 76, 0, 9, 0, 1, 0, 16, 17, 60], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 9, 0, 1, 0, 16, 12, 16, 17, 85], ["-", 0, 9, 0, 1, 0, 16, 12, 16, 12, 13], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 85], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
903
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define int long long const int mod = 1000000007; int a[200006], b[200006]; signed main() { int n; cin >> n; rep(i, n) cin >> a[i] >> b[i]; vector<int> A, B; rep(i, n) { A.push_back(a[i]); B.push_back(b[i]); ...
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define int long long const int mod = 1000000007; int a[200006], b[200006]; signed main() { int n; cin >> n; rep(i, n) cin >> a[i] >> b[i]; vector<int> A, B; rep(i, n) { A.push_back(a[i]); B.push_back(b[i]); ...
[["+", 31, 16, 31, 16, 31, 16, 31, 91, 17, 33], ["-", 0, 16, 31, 16, 12, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 17, 72]]
1
203
import sys def solve_even(n, aaa, bbb): li = n // 2 - 1 ri = n // 2 aaa.sort() bbb.sort() ll = aaa[li] lr = aaa[ri] rl = bbb[li] rr = bbb[ri] return (rr + lr) - (rl + ll) + 1 def solve_odd(n, aaa, bbb): k = n // 2 aaa.sort() bbb.sort() return bbb[k] - aaa[k] + 1 ...
import sys def solve_even(n, aaa, bbb): li = n // 2 - 1 ri = n // 2 aaa.sort() bbb.sort() ll = aaa[li] lr = aaa[ri] rl = bbb[li] rr = bbb[ri] return (rl + rr) - (lr + ll) + 1 def solve_odd(n, aaa, bbb): k = n // 2 aaa.sort() bbb.sort() return bbb[k] - aaa[k] + 1 ...
[["-", 0, 657, 31, 657, 31, 23, 0, 657, 31, 22], ["+", 0, 657, 31, 657, 31, 23, 0, 657, 31, 22], ["-", 0, 657, 31, 657, 31, 23, 0, 657, 12, 22], ["+", 0, 657, 31, 657, 31, 23, 0, 657, 12, 22], ["-", 0, 657, 31, 657, 12, 23, 0, 657, 31, 22], ["+", 0, 657, 31, 657, 12, 23, 0, 657, 31, 22]]
5
189
/*input 3 100 100 10 10000 1 1000000000 */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("unroll-loops,no-stack-protector") // order_of_key #of elements less than x // find_by_order kth elemen...
/*input 2 1 2 2 3 */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("unroll-loops,no-stack-protector") // order_of_key #of elements less than x // find_by_order kth element using ll = long long...
[["-", 49, 50, 51, 23, 0, 16, 31, 69, 28, 22], ["+", 49, 50, 51, 23, 0, 16, 31, 69, 28, 22], ["-", 0, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22], ["+", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 17...
1
454
def examA(): A, B = LI() ans = A*B print(ans) return def examB(): N = I() A = LI() for a in A: if a==0: print(0) return ans = 1 for a in A: ans *= a if ans>10**18: print(-1) return print(ans) return def...
def examA(): A, B = LI() ans = A*B print(ans) return def examB(): N = I() A = LI() for a in A: if a==0: print(0) return ans = 1 for a in A: ans *= a if ans>10**18: print(-1) return print(ans) return def...
[["-", 64, 196, 0, 1, 0, 662, 12, 657, 17, 676], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 85], ["+", 0, 1, 0, 662, 12, 657, 31, 652, 63, 22], ["+", 31, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25]]
5
698
n = int(input()) a = [] b = [] for i in range(n): x,y = map(int, input().split()) a.append(x) b.append(y) a.sort() b.sort() if n%2: mid_min = a[n//2] mid_max = b[n//2] print(mid_max-mid_min+1) else: mid_min = (a[n//2-1]+a[n//2])/2 mid_max = (b[n//2-1]+b[n//2])/2 print(int(mid_max-mid...
n = int(input()) a = [] b = [] for i in range(n): x,y = map(int, input().split()) a.append(x) b.append(y) a.sort() b.sort() if n%2: mid_min = a[n//2] mid_max = b[n//2] print(mid_max-mid_min+1) else: mid_min = (a[n//2-1]+a[n//2])/2 mid_max = (b[n//2-1]+b[n//2])/2 print(int((mid_max-mi...
[["+", 31, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25]]
5
148
N = int(input()) A, B = [], [] for _ in range(N): a, b = map(int, input().split()) A.append(a) B.append(b) if N%2==1: n = N//2 print(sorted(B, reverse=True)[n]-sorted(A)[n]+1) exit() l, r = (N-2)//2, N//2 A.sort() B.sort() print(A[r]-A[l]+B[r]-B[l]+1)
N = int(input()) A, B = [], [] for _ in range(N): a, b = map(int, input().split()) A.append(a) B.append(b) if N%2==1: n = N//2 print(sorted(B, reverse=True)[n]-sorted(A)[n]+1) exit() l, r = (N-2)//2, N//2 A.sort() B.sort() print(-A[r]-A[l]+B[r]+B[l]+1)
[["+", 31, 657, 31, 657, 31, 657, 31, 664, 17, 33], ["-", 0, 652, 3, 4, 0, 657, 31, 657, 17, 33], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 17, 72]]
5
141
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; void *wmem; char memarr[96000000]; template <class T> inline void walloc1d(T **arr, int x, void **mem = &wmem) { static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; (*mem) = (void *)(((char *)(*mem)) + skip[((unsig...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; void *wmem; char memarr[96000000]; template <class T> inline void walloc1d(T **arr, int x, void **mem = &wmem) { static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; (*mem) = (void *)(((char *)(*mem)) + skip[((unsig...
[["-", 341, 342, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 341, 342, 0, 16, 31, 23, 0, 16, 17, 33]]
1
941
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; typedef long long ll; int N; ll A[200000], B[200000]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> N; for (int ...
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> using namespace std; typedef long long ll; int N; ll A[200000], B[200000]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> N; for (int ...
[["-", 31, 16, 31, 16, 31, 16, 31, 69, 28, 22], ["+", 31, 16, 31, 16, 31, 16, 31, 69, 28, 22], ["-", 31, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 31, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 31, 16, 12, 16, 31, 16, 12, 69, 28, 22], ["+", 31, 16, 12, 16, 31, 16, 12, 69, 28, 22], ["-", 12, 16, 31, 16, 12, 69, 341, ...
1
216
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i < n; i++) #define all(v) v.begin(), v.end() #define P pair<int, int> #define len(s) (int)s.size() #define pb push_back template <class T> inline bool chmin(T &a, T b) { ...
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i < n; i++) #define all(v) v.begin(), v.end() #define P pair<int, int> #define len(s) (int)s.size() #define pb push_back template <class T> inline bool chmin(T &a, T b) { ...
[["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 73], ["+", 51, 23, 0, 16, 12, 69, 341, 342, 0, 73]]
1
273
N, S = map(int, input().split()) A = list(map(int, input().split())) mod = 998244353 dp = [-1 for _ in range(S+1)] visited = [0] dp[0] = 1 dp = tuple(dp) for k in range(N): a = A[k] nextdp = list(dp) nextvisit = [] for item in visited: #process1 追加する if item + a <= S: if nextdp[item+a] == -1: ...
N, S = map(int, input().split()) A = list(map(int, input().split())) mod = 998244353 dp = [-1 for _ in range(S+1)] visited = [0] dp[0] = 1 dp = tuple(dp) for k in range(N): a = A[k] nextdp = list(dp) nextvisit = [] for item in visited: #process1 追加する if item + a <= S: if nextdp[item+a] == -1: ...
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
187
#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) { ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
774
#include <iostream> using namespace std; const int64_t MOD = 998244353; int main() { int n, s; cin >> n >> s; int64_t dp[s + 1]; dp[0] = 1; for (int i = 0; i <= s; ++i) { dp[i] = 0; } for (int a; cin >> a;) { for (int j = s; j >= 0; --j) { dp[j] = (2 * dp[j] + j >= a ? dp[j - a] : 0) % MOD...
#include <iostream> using namespace std; const int64_t MOD = 998244353; int main() { int n, s; cin >> n >> s; int64_t dp[s + 1]; dp[0] = 1; for (int i = 1; i <= s; ++i) { dp[i] = 0; } for (int a; cin >> a;) { for (int j = s; j >= 0; --j) { dp[j] = (2 * dp[j] + (j >= a ? dp[j - a] : 0)) % M...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
134
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); const int N = 2e5 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f, MOD = 998244353; long...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); const int N = 2e5 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f, MOD = 998244353; long...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
434
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string.h> #include...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string.h> #include...
[["-", 51, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 51, 4, 0, 2, 3, 4, 0, 16, 31, 13]]
1
1,484
#include <bits/stdc++.h> #define rrep(i, n) for (int i = int(n - 1); i >= 0; i--) using namespace std; long dp[3001]; int main() { int n, s; cin >> n >> s; dp[0] = 1; rrep(i, n) { int a; cin >> a; rrep(j, s) { dp[j] *= 2; if (j - a >= 0) dp[j] += dp[j - a]; dp[j] %= 9982...
#include <bits/stdc++.h> #define rrep(i, n) for (int i = int(n - 1); i >= 0; i--) using namespace std; long dp[3001]; int main() { int n, s; cin >> n >> s; dp[0] = 1; rrep(i, n) { int a; cin >> a; rrep(j, s + 1) { dp[j] *= 2; if (j - a >= 0) dp[j] += dp[j - a]; dp[j] %= ...
[["+", 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
110
#include <bits/stdc++.h> #define FORR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (b); i >= (a); --i) #define REPP(i, a, b) for (int i = (a); i < (b); ++i) #define REPD(i, a, b) for (int i = (b); i > (a); --i) #define fi first #define se second #define mp make_pair #define pb push_back ...
#include <bits/stdc++.h> #define FORR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (b); i >= (a); --i) #define REPP(i, a, b) for (int i = (a); i < (b); ++i) #define REPD(i, a, b) for (int i = (b); i > (a); --i) #define fi first #define se second #define mp make_pair #define pb push_back ...
[["-", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22]]
1
386
//#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 <...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
428
import numpy as np import sys input = sys.stdin.readline def main(): n, s = map(int, input().split()) A = [int(i) for i in input().split()] MOD = 998244353 dp = np.zeros(s + 1, dtype="int32") dp[0] = 1 for a in A: p = (dp * 2) % MOD p %= MOD p[a:] += dp[:a] d...
import numpy as np import sys input = sys.stdin.readline def main(): n, s = map(int, input().split()) A = np.array([int(i) for i in input().split()]) MOD = 998244353 dp = np.zeros(s + 1, dtype="int32") dp[0] = 1 for a in A: p = (dp * 2) % MOD p %= MOD p[a:] += dp[:-a...
[["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["+", 0, 677, 12, 206, 206, 663, 0, 664, 17, 33]]
5
127
// 5/14 // 過去問ガリガリ #include <bits/stdc++.h> #include <string> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; const int mod = 998244353; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod +...
// 5/14 // 過去問ガリガリ #include <bits/stdc++.h> #include <string> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; const int mod = 998244353; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod +...
[["-", 51, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 51, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107]]
1
567
#include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using vb = vector<bool>; using P = pair<ll, ll>; template <typename T> using pq = priority_queue<T>; template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>; template <typename T, ty...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using vb = vector<bool>; using P = pair<ll, ll>; template <typename T> using pq = priority_queue<T>; template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>; template <typename T, ty...
[["+", 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
574
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; typedef long long ll; const int N = 3005; int n, s; ll dp[N]; int main() { ll inv2 = mod - mod / 2; dp[0] = 1; scanf("%d%d", &n, &s); ll ans = 0; for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); for (int j = s; j >= x; ...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; typedef long long ll; const int N = 3005; int n, s; ll dp[N]; int main() { ll inv2 = mod - mod / 2; dp[0] = 1; scanf("%d%d", &n, &s); ll ans = 0; for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); for (int j = s; j >= x; ...
[["+", 12, 16, 31, 23, 0, 16, 12, 16, 17, 48], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 12, 22]]
1
179
#include <bits/stdc++.h> using namespace std; #define rep(i, x, y) for (int i = x; i < y; i++) #define range(a) (a).begin(), (a).end() #define print(A, x, n) \ rep(i, 0, n) { cout << (i ? " " : "") << A[i] x; } \ cout << endl; #define...
#include <bits/stdc++.h> using namespace std; #define rep(i, x, y) for (int i = x; i < y; i++) #define range(a) (a).begin(), (a).end() #define print(A, x, n) \ rep(i, 0, n) { cout << (i ? " " : "") << A[i] x; } \ cout << endl; #define...
[["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13]]
1
190
#include <bits/stdc++.h> using namespace std; long long n, s; long long a[5010]; long long f[5010][5010]; int main() { cin >> n >> s; for (long long i = 1; i <= n; i++) { cin >> a[i]; } f[0][0] = 1; for (long long i = 1; i <= n; i++) { for (long long j = 0; j <= s; j++) { f[i][j] += f[i - 1][j] ...
#include <bits/stdc++.h> using namespace std; long long n, s; long long a[5010]; long long f[5010][5010]; int main() { cin >> n >> s; for (long long i = 1; i <= n; i++) { cin >> a[i]; } f[0][0] = 1; for (long long i = 1; i <= n + 1; i++) { for (long long j = 0; j <= s; j++) { f[i][j] += f[i - 1]...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
201
#include <bits/stdc++.h> using namespace std; #define BIT(n) (1LL << (n)) #define BITF(n, i) (((n) >> (i)) & 1) #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define REPI(i, x) for (int i = 1; i <= x; i++) #define FORI(i, m, n) for (int i = m; i <= n; i++) #define REPR(i...
#include <bits/stdc++.h> using namespace std; #define BIT(n) (1LL << (n)) #define BITF(n, i) (((n) >> (i)) & 1) #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define REPI(i, x) for (int i = 1; i <= x; i++) #define FORI(i, m, n) for (int i = m; i <= n; i++) #define REPR(i...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
983
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; const ll mod = 998244353; int main() { int n, s; cin >> n >> s; vector<vector<ll>> dp(n, vector<ll>(s + 5)); vector<int> a(n); rep(i, n) cin >> a[i]; dp[0][0] = 2; d...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; const ll mod = 998244353; int main() { int n, s; cin >> n >> s; vector<vector<ll>> dp(n, vector<ll>(3005)); vector<int> a(n); rep(i, n) cin >> a[i]; dp[0][0] = 2; dp...
[["-", 51, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 51, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 51, 4, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 49, 50, 51, 4, 0, 2, 3, 4, 0, 13]]
1
229
#include <bits/stdc++.h> using namespace std; using ll = long long; using p = pair<ll, ll>; constexpr ll INF = 1LL << 62; constexpr ll MOD = 998244353; int main(void) { ll N, S; cin >> N >> S; vector<ll> A(N); for (auto &&a : A) { cin >> a; } vector<vector<ll>> dp(N + 1, vector<ll>(S + 1, 0)); dp[0...
#include <bits/stdc++.h> using namespace std; using ll = long long; using p = pair<ll, ll>; constexpr ll INF = 1LL << 62; constexpr ll MOD = 998244353; int main(void) { ll N, S; cin >> N >> S; vector<ll> A(N); for (auto &&a : A) { cin >> a; } // Tを荷物候補、UをTの中から選ばれた荷物の集合と考える。 vector<vector<ll>> dp(N ...
[["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
1
249
MOD = 998244353 n,s = gets.split.map(&:to_i) a = gets.split.map(&:to_i) dp = Array.new(s*3, 0) dp[0] = 1 a.each do |a| s.downto(0) do |i| dp[a+i] += dp[i] dp[i] *= 2 dp[i] %= MOD end end puts dp[s] % MOD
MOD = 998244353 n,s = gets.split.map(&:to_i) a = gets.split.map(&:to_i) dp = Array.new(7000, 0) dp[0] = 1 a.each do |a| s.downto(0) do |i| dp[a+i] += dp[i] dp[i] *= 2 dp[i] %= MOD end end puts dp[s] % MOD
[["-", 0, 662, 12, 652, 3, 4, 0, 738, 31, 22], ["-", 0, 662, 12, 652, 3, 4, 0, 738, 17, 48], ["-", 0, 662, 12, 652, 3, 4, 0, 738, 12, 612], ["+", 0, 493, 0, 662, 12, 652, 3, 4, 0, 612]]
4
94
import numpy as np n,s,*a=map(int,open(0).read().split()) mod=998244353 d=np.zeros(s+1,dtype=np.int64) d[0]=1 for x in a: p=d*2 p[x:]+=d[:s-x+1] p%=mod d=p print(d[-1])
import numpy as np n,s,*a=map(int,open(0).read().split()) mod=998244353 d=np.zeros(s+1,dtype=np.int64) d[0]=1 for x in a: p=d*2 if x<=s: p[x:]+=d[:s-x+1] p%=mod d=p print(d[-1])
[["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102]]
5
92
#pragma GCC optimize("O3") #pragma GCC target("avx2") //#include<bits/stdc++.h> #include <algorithm> #include <cstdio> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (...
#pragma GCC optimize("O3") #pragma GCC target("avx2") //#include<bits/stdc++.h> #include <algorithm> #include <cstdio> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
860
#pragma GCC optimize("O3") #pragma GCC target("avx2") //#include<bits/stdc++.h> #include <algorithm> #include <cstdio> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (...
#pragma GCC optimize("O3") #pragma GCC target("avx2") //#include<bits/stdc++.h> #include <algorithm> #include <cstdio> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (...
[["-", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22]]
1
827
#pragma GCC optimize("O3") #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\...
#pragma GCC optimize("O3") #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
367
#pragma GCC optimize("O3") #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\...
#pragma GCC optimize("O3") #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\...
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32]]
1
299
mod = 998244353 n, s = map(int, input().split()) dp = np.zeros((n+1, s+1), dtype=int) dp[0, 0] = 1 for i, a in enumerate(map(int, input().split())): dp[i+1] = dp[i] * 2 % mod dp[i+1][a:] = (dp[i+1][a:] + dp[i][:-a]) % mod print(dp[-1, -1])
import numpy as np mod = 998244353 n, s = map(int, input().split()) dp = np.zeros((n+1, s+1), dtype=int) dp[0, 0] = 1 for i, a in enumerate(map(int, input().split())): dp[i+1] = dp[i] * 2 % mod dp[i+1][a:] = (dp[i+1][a:] + dp[i][:-a]) % mod print(dp[-1, -1])
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 0, 656, 0, 596, 141, 704, 141, 673, 0, 22], ["+", 36, 36, 0, 656, 0, 596, 141, 704, 0, 272], ["+", 36, 36, 0, 656, 0, 596, 141, 704, 705, 22]]
5
129
import sys from collections import defaultdict int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in ran...
import sys from collections import defaultdict int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in ran...
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 109], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
255
#pragma GCC optimize(2) #include <bits/stdc++.h> #define ll long long #define maxn 1005 #define inf 1e9 #define pb push_back #define rep(i, a, b) for (int i = a; i <= b; i++) #define per(i, a, b) for (int i = a; i >= b; i--) using namespace std; const ll mod = 998244353; inline ll read() { ll x = 0, w = 1; char c =...
#pragma GCC optimize(2) #include <bits/stdc++.h> #define ll long long #define maxn 1005 #define inf 1e9 #define pb push_back #define rep(i, a, b) for (int i = a; i <= b; i++) #define per(i, a, b) for (int i = a; i >= b; i--) using namespace std; const ll mod = 998244353; inline ll read() { ll x = 0, w = 1; char c =...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40]]
1
357
def resolve(): n, s = map(int, input().split()) a = list(map(int, input().split())) mod = 998244353 dp = [0] * (s + 1) dp[0] = 1 for i in a: for j in range(s - i, -1, -1): dp[j + i] = dp[j + i] * 2 + dp[j] dp[j + i] %= mod for j in range(min(i, s + 2)): ...
def resolve(): n, s = map(int, input().split()) a = list(map(int, input().split())) mod = 998244353 dp = [0] * (s + 1) dp[0] = 1 for i in a: for j in range(s - i, -1, -1): dp[j + i] = dp[j + i] * 2 + dp[j] dp[j + i] %= mod for j in range(min(i, s + 1)): ...
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
152
import sys input=sys.stdin.readline def calc(): mod=998244353 n,s=map(int,input().split()) arr=list(map(int,input().split())) dp=[0]*(s+1) dp[0]=1 ans=0 for i in range(1,n+1): val=arr[i-1] for k in range(s,-1,-1): dp[k]*=2 dp[k]%=mod if k>=val and dp[k-val]!=0: dp[k]+=dp...
import sys input=sys.stdin.readline def calc(): mod=998244353 n,s=map(int,input().split()) arr=list(map(int,input().split())) dp=[0]*(s+1) dp[0]=1 ans=0 for i in range(1,n+1): val=arr[i-1] for k in range(s,-1,-1): dp[k]*=2 dp[k]%=mod if k>=val and dp[k-val]!=0: dp[k]+=dp...
[["-", 0, 652, 3, 4, 0, 657, 31, 206, 206, 22], ["+", 0, 652, 3, 4, 0, 657, 31, 206, 206, 22]]
5
159
n, s = map(int, input().split()) a = list(map(int, input().split())) mod = 998244353 pows = [1] for i in range(10000): pows.append((pows[-1] * 2) % mod) dp = [0] * (s + 1) dp[0] = 1 if a[0] <= s: dp[a[0]] = 1 for i in range(1, n): dp_new = [0] * (s + 1) dp_new[0] = 1 for j in range(1, s + 1): ...
n, s = map(int, input().split()) a = list(map(int, input().split())) mod = 998244353 pows = [1] for i in range(10000): pows.append((pows[-1] * 2) % mod) dp = [0] * (s + 1) dp[0] = 1 if a[0] <= s: dp[a[0]] = 1 for i in range(1, n): dp_new = [0] * (s + 1) dp_new[0] = 1 for j in range(1, s + 1): ...
[["-", 15, 666, 0, 657, 12, 206, 206, 657, 17, 33], ["-", 15, 666, 0, 657, 12, 206, 206, 657, 12, 612], ["-", 12, 206, 206, 657, 12, 206, 206, 657, 17, 33], ["-", 12, 206, 206, 657, 12, 206, 206, 657, 12, 612], ["-", 75, 665, 15, 666, 0, 206, 206, 657, 17, 33], ["-", 75, 665, 15, 666, 0, 206, 206, 657, 12, 612]]
5
213
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 3e3 + 5; const int INF = 0x7f7f7f7f; const ll p = 998244353; #define DEBUG(x) cout << x << '\n' int n, s, t, f[MAXN]; ll f_pow(ll a, ll b) { ll res = 1; for (; b; b >>= 1, a = a * a % p) if (b & 1) res = res * a % p; r...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 3e3 + 5; const int INF = 0x7f7f7f7f; const ll p = 998244353; #define DEBUG(x) cout << x << '\n' int n, s, t, f[MAXN]; ll f_pow(ll a, ll b) { ll res = 1; for (; b; b >>= 1, a = a * a % p) if (b & 1) res = res * a % p; r...
[["-", 0, 7, 8, 9, 0, 7, 15, 91, 17, 92], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 20], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
226
#include <bits/stdc++.h> using namespace std; typedef long long ll; const static ll INF = 1e15; #define rep(i, n) for (int i = 0; i < (int)(n); i++) // __uint128_t const static ll MOD = 998244353; long long modpow(long long a, long long n, long long mod = MOD) { long long res = 1; while (n > 0) { if (n & 1) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const static ll INF = 1e15; #define rep(i, n) for (int i = 0; i < (int)(n); i++) // __uint128_t const static ll MOD = 998244353; long long modpow(long long a, long long n, long long mod = MOD) { long long res = 1; while (n > 0) { if (n & 1) ...
[["-", 51, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 51, 4, 0, 2, 3, 4, 0, 16, 31, 13]]
1
329
MOD = 998244353 N, S = map(int, input().split()) A = list(map(int, input().split())) dp = [[0 for j in range(S+1)] for i in range(N+1)] #dp[i][j] = i番目まで見て重さjのものを取る方法 dp[0][0] = 1 # for i in range(N): # for j in range(S+1): # dp[i+1][j] += 2*dp[i][j] # dp[i+1][j] %= MOD # if j + A[i] <= S:...
MOD = 998244353 N, S = map(int, input().split()) A = list(map(int, input().split())) dp = [[0 for j in range(S+1)] for i in range(N+1)] #dp[i][j] = i番目まで見て重さjのものを取る方法 dp[0][0] = 1 # for i in range(N): # for j in range(S+1): # dp[i+1][j] += 2*dp[i][j] # dp[i+1][j] %= MOD # if j + A[i] <= S:...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 15, 666, 0, 657, 12, 206, 206, 657, 17, 33], ["+", 15, 666, 0, 657, 12, 206, 206, 657, 12, 612], ["+", 12, 206, 206, 657, 12, 206, 206, 657, 17, 33], ["+", 12, 206, 206, 657, 12, 206, 206, 657, 12, 612]]
5
169
n, s = gets.split(" ").map(&:to_i) alist = gets.split(" ").map(&:to_i) m = 998244353 dp = Array.new(n+1) { Array.new(s+1, 0)} dp[0][0] = 1 for i in 0..n-1 do for j in 0..s do dp[i+1][j] = (dp[i+1][j]+ dp[i][j] << 1) % m if j + alist[i] <= s then dp[i+1][j + alist[i]] = (dp[i+1][j + al...
n, s = gets.split(" ").map(&:to_i) alist = gets.split(" ").map(&:to_i) m = 998244353 dp = Array.new(n+1) { Array.new(s+1, 0)} dp[0][0] = 1 for i in 0..n-1 do for j in 0..s do dp[i+1][j] = (dp[i+1][j] + (dp[i][j] << 1)) % m if j + alist[i] <= s then dp[i+1][j + alist[i]] = (dp[i+1][j +...
[["+", 12, 738, 31, 739, 0, 738, 12, 739, 0, 24], ["+", 12, 738, 31, 739, 0, 738, 12, 739, 0, 25]]
4
179
class Inv: def __init__(s, mod): s.MOD = mod def modpow(s, a, n): res = 1 while n > 0: if n & 1: res = res * a % s.MOD a = a * a % s.MOD n >>= 1 return res def invx(s, a): return s.modpow(a, s.MOD - 2) def invpowL(s, a, n): # a^-x (0 <= x <= n)リスト ia = s.invx(a)...
class Inv: def __init__(s, mod): s.MOD = mod def modpow(s, a, n): res = 1 while n > 0: if n & 1: res = res * a % s.MOD a = a * a % s.MOD n >>= 1 return res def invx(s, a): return s.modpow(a, s.MOD - 2) def invpowL(s, a, n): # a^-x (0 <= x <= n)リスト ia = s.invx(a)...
[["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117]]
5
450
#include "bits/stdc++.h" using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef vector<PII> VPII; typedef long long LL; typedef vector<LL> VL; typedef vector<VL> VVL; typedef pair<LL, LL> PLL; typedef vector<PLL> VPLL; typedef priority_queue...
#include "bits/stdc++.h" using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef vector<PII> VPII; typedef long long LL; typedef vector<LL> VL; typedef vector<VL> VVL; typedef pair<LL, LL> PLL; typedef vector<PLL> VPLL; typedef priority_queue...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
594
# -*- coding: utf-8 -*- import sys import numpy as np N,S, *A = map(int, sys.stdin.buffer.read().split()) mod = 998244353 A = sorted(A) answer = np.zeros(S+1).astype(np.int64) # [0 for _ in range(S+1)] power2 = 1 total = 0 for a in A: total = min(S,a+total) answer[a+1:total+1] = (2*answer[a+1:total+1]+answer[1:t...
# -*- coding: utf-8 -*- import sys import numpy as np N,S, *A = map(int, sys.stdin.buffer.read().split()) mod = 998244353 A = sorted(A) answer = np.zeros(3002).astype(np.int64) power2 = 1 total = 0 for a in A: total = min(3001,a+total) answer[a+1:total+1] = (2*answer[a+1:total+1]+answer[1:total-a+1])%mod answe...
[["-", 63, 319, 500, 652, 3, 4, 0, 657, 31, 22], ["-", 63, 319, 500, 652, 3, 4, 0, 657, 17, 72], ["-", 63, 319, 500, 652, 3, 4, 0, 657, 12, 612], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 612], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
170
eval"N,S,*A="+`dd`.split*?, d=1,*[0]*S*2 A.map{|a|S.downto(0){|i|d[a+i]+=t=d[i] d[i]=2*t%998244353}} p d[S]
eval"N,S,*A="+`dd`.split*?, d=1,*[0]*7e3 A.map{|a|S.downto(0){|i|d[a+i]+=t=d[i] d[i]=2*t%998244353}} p d[S]%998244353
[["-", 12, 762, 0, 741, 0, 738, 31, 738, 12, 743], ["-", 0, 662, 12, 762, 0, 741, 0, 738, 17, 48], ["-", 0, 662, 12, 762, 0, 741, 0, 738, 12, 612], ["+", 0, 662, 12, 762, 0, 741, 0, 738, 12, 531], ["+", 0, 493, 0, 652, 3, 4, 0, 738, 17, 109], ["+", 0, 493, 0, 652, 3, 4, 0, 738, 12, 612]]
4
71
n,s,*a=map(int,open().read().split());d=[0]*-~s;m=998244353;v=pow(2,m-2,m);d[0]=pow(2,n,m) for i in a: for j in range(s,i-1,-1):d[j]+=(d[j-i]*v)%m print(d[s])
n,s,*a=map(int,open(0).read().split());d=[0]*-~s;m=998244353;v=pow(2,m-2,m);d[0]=pow(2,n,m) for i in a: for j in range(s,i-1,-1):d[j]+=(d[j-i]*v)%m print(d[s]%m)
[["+", 500, 652, 63, 319, 500, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
108
#include <bits/stdc++.h> #define ll long long #define dl double #define mp make_pair #define pb push_back using namespace std; //*********************************************************************** // hash struct for unordered_map struct hash_pair { template <class T1, class T2> size_t operator()(const pair<T1, ...
#include <bits/stdc++.h> #define ll long long #define dl double #define mp make_pair #define pb push_back using namespace std; //*********************************************************************** // hash struct for unordered_map struct hash_pair { template <class T1, class T2> size_t operator()(const pair<T1, ...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["-", 51, 4, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 51, 4, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 49, 50, 51, 4, 0, 2, 3, 4, 0, 21], ["+", 49, 50, 51, 4, 0, 2, 3, 4, 0, 13]]
1
447
from collections import defaultdict N = int(input()) d = defaultdict(int) tmp = N for i in range(2, int(math.sqrt(N))+1): while tmp % i == 0: d[i] += 1 tmp /= i if tmp > 1: d[tmp] += 1 ans = 0 for key, value in d.items(): i = value j = 1 while value >= j: ans += 1 valu...
import math from collections import defaultdict N = int(input()) d = defaultdict(int) tmp = N for i in range(2, int(math.sqrt(N))+1): while tmp % i == 0: d[i] += 1 tmp /= i if tmp > 1: d[tmp] += 1 ans = 0 for key, value in d.items(): i = value j = 1 while value >= j: ans += 1...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
106
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAX = 1e6; bool isPrime[MAX + 1]; void prime() { fill(isPrime + 2, isPrime + MAX + 1, true); for (int i = 4; i <= MAX; i += 2) isPrime[i] = false; for (int i = 3; i * i <= MAX; i += 2) if (isPrime[i]) for (int j = i * ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAX = 1e6; bool isPrime[MAX + 1]; void prime() { fill(isPrime + 2, isPrime + MAX + 1, true); for (int i = 4; i <= MAX; i += 2) isPrime[i] = false; for (int i = 3; i * i <= MAX; i += 2) if (isPrime[i]) for (int j = i * ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106]]
1
319
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr ==...
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr ==...
[["-", 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
225
// Problem : D - Div Game // Contest : AtCoder - AtCoder Beginner Contest 169 // URL : https://atcoder.jp/contests/abc169/tasks/abc169_d // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/coder3101/cp-editor) // Mere bas ka nahi hai // still i'm trying // apna time aayega //...
// Problem : D - Div Game // Contest : AtCoder - AtCoder Beginner Contest 169 // URL : https://atcoder.jp/contests/abc169/tasks/abc169_d // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/coder3101/cp-editor) // Mere bas ka nahi hai // still i'm trying // apna time aayega //...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
375
#include <bits/stdc++.h> #include <cmath> #define pb push_back #define ld long double #define mp make_pair #define vl vector<ll> #define vd vector<double> #define vld vector<long double> #define ll long long int #define pl pair<ll, ll> #define all(a) a.begin(), a.end() #define forr(i, n) for (ll i = 0; i < n; i++) #def...
#include <bits/stdc++.h> #include <cmath> #define pb push_back #define ld long double #define mp make_pair #define vl vector<ll> #define vd vector<double> #define vld vector<long double> #define ll long long int #define pl pair<ll, ll> #define all(a) a.begin(), a.end() #define forr(i, n) for (ll i = 0; i < n; i++) #def...
[["-", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["-", 8, 9, 0, 57, 15, 339, 51, 91, 28, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
304
#import math #=input() n=int(input()) #a,b=map(float,input().split()) #=list(map(int,input().split())) #=[list(map(int,input().split())) for _ in range()] import collections def pf(x): a = [] while x % 2 == 0: a.append(2) x //= 2 f = 3 while f ** 2 <= x: if x % f == 0: ...
#import math #=input() n=int(input()) #a,b=map(float,input().split()) #=list(map(int,input().split())) #=[list(map(int,input().split())) for _ in range()] import collections def pf(x): a = [] while x % 2 == 0: a.append(2) x //= 2 f = 3 while f ** 2 <= x: if x % f == 0: ...
[["-", 64, 196, 0, 1, 0, 662, 12, 634, 0, 612], ["+", 64, 196, 0, 1, 0, 662, 12, 634, 0, 612]]
5
177
from math import floor,sqrt N=int(input()) p = [1]*floor(sqrt(10**6)) p[0]=p[1]=0 prime=[] for i in range(2,len(p)): if p[i]==0: continue prime.append(i) for j in range(i*2,len(p),i): p[j]=0 ans=0 for x in prime: if N%x!=0: continue cnt=0 while N%x==0: cnt+=1 ...
from math import floor,sqrt N=int(input()) p = [1]*floor((10**6)) p[0]=p[1]=0 prime=[] for i in range(2,len(p)): if p[i]==0: continue prime.append(i) for j in range(i*2,len(p),i): p[j]=0 ans=0 for x in prime: if N%x!=0: continue cnt=0 while N%x==0: cnt+=1 ...
[["-", 12, 657, 12, 652, 3, 4, 0, 652, 63, 22]]
5
158
# ANSHUL GAUTAM # IIIT-D from math import * from copy import * # ll = deepcopy(l) from heapq import * # heappush(hp,x) from string import * # alpha = ascii_lowercase from random import * # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference from bisect import * # bisect_left(arr,x,st...
# ANSHUL GAUTAM # IIIT-D from math import * from copy import * # ll = deepcopy(l) from heapq import * # heappush(hp,x) from string import * # alpha = ascii_lowercase from random import * # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference from bisect import * # bisect_left(arr,x,st...
[["+", 8, 196, 0, 52, 15, 23, 0, 681, 0, 372]]
5
300
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[]: arr...
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[]: arr...
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612]]
5
420
import java.io.*; import java.util.*; class Main { public static void main(String args[]) { long a = readLong(); ArrayList<Long> beki = new ArrayList<Long>(); boolean flg = true; for (long i = 2; a > 1;) { if (a % i == 0) { a /= i; if (flg) { beki.add(1L); flg...
import java.io.*; import java.util.*; class Main { public static void main(String args[]) { long a = readLong(); ArrayList<Long> beki = new ArrayList<Long>(); boolean flg = true; for (long i = 2; a > 1;) { if (a % i == 0) { a /= i; if (flg) { beki.add(1L); flg...
[["-", 0, 52, 8, 196, 0, 1, 0, 11, 17, 108], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 12, 499], ["+", 0, 52, 8, 196, 0, 1, 0, 27, 0, 29]]
3
713
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[]: arr...
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[]: arr...
[["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 21], ["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
177
#include <algorithm> #include <assert.h> #include <bitset> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include ...
#include <algorithm> #include <assert.h> #include <bitset> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include ...
[["+", 51, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 57, 15, 339, 51, 16, 31, 23, 0, 25], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 1, 0, 27, 17, 29]]
1
339
#include <bits/stdc++.h> using namespace std; int c_moon(long long n); signed main() { long long n; int ans; cin >> n; ans = c_moon(n); cout << ans << endl; return (0); } int c_moon(long long n) { int ans = 0, make[10000], step = 0, sum; long long tem; make[0] = 0; for (int i = 1; i < 10000; i...
#include <bits/stdc++.h> using namespace std; int c_moon(long long n); signed main() { long long n; int ans; cin >> n; ans = c_moon(n); cout << ans << endl; return (0); } int c_moon(long long n) { int ans = 0, make[10000], step = 0, sum; long long tem; make[0] = 0; for (int i = 1; i < 10000; i...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]]
1
217
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9 + 7; map<ll, int> factors; void setIO() { ios_base::sync_with_stdio(0); cin.tie(0); } void factorize(long long n) { int count = 0; while (!(n % 2)) { n /= 2; count++; } if (count) factors[2] += count; for...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9 + 7; map<ll, int> factors; void setIO() { ios_base::sync_with_stdio(0); cin.tie(0); } void factorize(long long n) { int count = 0; while (!(n % 2)) { n /= 2; count++; } if (count) factors[2] += count; for...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 338, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 338, 39, 78]]
1
276
#素因数分解 # order O(log(N)*N**0.5)? def fact(A): #fact(int A) c0 = A r = 2 lis = [] count = 1 while A != 1: if A%r == 0: A = A//r lis.append(r) r = 2 else: r += 1 if r > int(pow(c0,0.5))+1: lis.append(A) bre...
#素因数分解 # order O(log(N)*N**0.5)? def fact(A): #fact(int A) c0 = A r = 2 lis = [] count = 1 while A != 1: if A%r == 0: A = A//r lis.append(r) r = 2 else: r += 1 if r > int(pow(c0,0.5))+1: lis.append(A) bre...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
211
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; typedef vector<ll> vl; typedef vector<ull> vul; typedef vector<int> vi; typedef vector<string> vs; typedef vector<vector<ll>> vvl; typedef vector<vector<string>> vvs; typedef vector<vector<ull>> vvul; typedef vector<bool...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; typedef vector<ll> vl; typedef vector<ull> vul; typedef vector<int> vi; typedef vector<string> vs; typedef vector<vector<ll>> vvl; typedef vector<vector<string>> vvs; typedef vector<vector<ull>> vvul; typedef vector<bool...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
1
1,322
import sys if __name__ == '__main__': val = int(input().strip()) arr = [] i = 2 while i < int(val ** 0.5 + 1): if val % i == 0: arr.append(i) val //= i continue i += 1 arr.append(val) count = 0 cur_val = 0 for e in arr: ...
import sys if __name__ == '__main__': val = int(input().strip()) arr = [] i = 2 while i < int(val ** 0.5 + 1): if val % i == 0: arr.append(i) val //= i continue i += 1 if val != 1: arr.append(val) count = 0 cur_val = 0 ...
[["+", 0, 656, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 656, 0, 57, 64, 196, 0, 57, 0, 102]]
5
117
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fr(i, n) for (ll i = 0; i < (n); ++i) #define Fr(i, n) for (long long i = 2; i <= (n); ++i) #define ifr(i, n) for (long long i = (n)-1; i >= 0; --i) #define iFr(i, n) for (long long i = (n); i > 0; --i) int main() { cin.tie(nullptr); ios::...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fr(i, n) for (ll i = 0; i < (n); ++i) #define Fr(i, n) for (long long i = 2; i <= (n); ++i) #define ifr(i, n) for (long long i = (n)-1; i >= 0; --i) #define iFr(i, n) for (long long i = (n); i > 0; --i) int main() { cin.tie(nullptr); ios::...
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
148
n=int(input()) #xの約数を列挙する def divisor(x): ans=set([]) i=2 while(i*i<=x): if(x%i==0): ans.add(i) ans.add(x//i) i+=1 ans=sorted(list(ans)) return ans div_n=divisor(n) #print(div_n) prime_n=[] isprime=[True for _ in range(len(div_n))] for i in range(len(div_n)...
n=int(input()) #xの約数を列挙する def divisor(x): ans=set([]) i=1 while(i*i<=x): if(x%i==0): ans.add(i) ans.add(x//i) i+=1 ans=sorted(list(ans)) return ans div_n=divisor(n)[1:] #print(div_n) prime_n=[] isprime=[True for _ in range(len(div_n))] for i in range(len(di...
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 206, 0, 70], ["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 612], ["+", 0, 1, 0, 662, 12, 206, 206, 663, 0, 102], ["+", 0, 656, 0, 1, 0, 662, 12, 206, 0, 73]]
5
242
N = int(input()) import collections def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a c = c...
N = int(input()) import collections def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a c = c...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
141
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll N; cin >> N; ll q = N; map<ll, ll> mp; while (1) { ll R = sqrt(q); bool b = false; for (ll i = 2; i <= R; i++) { if (q % i == 0) { b = true; q /= i; mp[i] += 1; break; }...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll N; cin >> N; ll q = N; map<ll, ll> mp; while (1) { ll R = sqrt(q); bool b = false; for (ll i = 2; i <= R; i++) { if (q % i == 0) { b = true; q /= i; mp[i] += 1; break; }...
[["+", 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, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 25]]
1
213
#include <iostream> #include <vector> using namespace std; int main() { long n; cin >> n; long a = 2; int c, s; c = 0; s = 0; while (n >= a * a) { if (n % a == 0) { n /= a; c++; } else { if (c > 0) { for (int i = 1; i < 15; ++i) { c -= i; if (c < 0) ...
#include <iostream> #include <vector> using namespace std; int main() { long n; cin >> n; long a = 2; int c, s; c = 0; s = 0; while (n >= a * a) { if (n % a == 0) { n /= a; c++; } else { if (c > 0) { for (int i = 1; i < 15; ++i) { c -= i; if (c < 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, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
172
n=int(input()) def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr=...
n=int(input()) def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr=...
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612], ["-", 0, 57, 64, 196, 0, 52, 15, 666, 667, 47], ["+", 0, 57, 64, 196, 0, 52, 15, 666, 667, 20]]
5
194
def fa(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[]: arr.append([n,...
def fa(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[]: arr.append([n,...
[["+", 12, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 12, 652, 3, 4, 0, 657, 31, 23, 0, 25], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]]
5
351
def prime(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return list(set(a)) x=int(input()) p=prime(x) s=0 for j in p: ...
def prime(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return list(set(a)) x=int(input()) p=prime(x) s=0 for j in p: ...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
135
#include <bits/stdc++.h> #define ll long long int #define DEBUG(x) cerr << "> " << #x << ':' << x << endl; using namespace std; ll INF = 1e15; ll MOD = 1e9 + 7; vector<ll> prime; vector<bool> vis; ll quick_expo(ll x, ll y) { ll ans = 1; while (y != 0) { if ((y & 1) == 1) ans = (ans * x) % MOD; x = (x...
#include <bits/stdc++.h> #define ll long long int #define DEBUG(x) cerr << "> " << #x << ':' << x << endl; using namespace std; ll INF = 1e15; ll MOD = 1e9 + 7; vector<ll> prime; vector<bool> vis; ll quick_expo(ll x, ll y) { ll ans = 1; while (y != 0) { if ((y & 1) == 1) ans = (ans * x) % MOD; x = (x...
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 31, 22], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 31, 22]]
1
367
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main() { int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k; int ans = (h2 - h1) * 60; if (m1 < m2) ans -= 60 - m2 - m1; else ans -= m1 - m2; cout << ans - k << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main() { int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k; int ans = (h2 - h1) * 60; if (m1 <= m2) ans += m2 - m1; else ans -= m1 - m2; cout << ans - k << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 110], ["-", 64, 1, 0, 11, 12, 16, 31, 16, 31, 13], ["-", 64, 1, 0, 11, 12, 16, 31, 16, 17, 33], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 107]]
1
88
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)n; ++i) int main() { int a[5]; rep(i, 5) cin >> a[i]; cout << (a[2] - a[0]) * 60 - (a[3] - a[1]) - a[4] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)n; ++i) int main() { int a[5]; rep(i, 5) cin >> a[i]; cout << (a[2] - a[0]) * 60 + (a[3] - a[1]) - a[4] << endl; return 0; }
[["-", 0, 16, 31, 16, 12, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 17, 72]]
1
83
h = list(map(int, input().split())) if h[1] > h[3]: print((h[2]-h[0])*60+h[3]-h[1]-h[4]) else: print((h[2]-h[0]-1)*60+60-h[3]+h[1]-h[4])
h = list(map(int, input().split())) if h[1] < h[3]: print((h[2]-h[0])*60+h[3]-h[1]-h[4]) else: print((h[2]-h[0]-1)*60+60-h[1]+h[3]-h[4])
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18], ["-", 0, 657, 31, 657, 31, 657, 12, 206, 206, 612], ["+", 0, 657, 31, 657, 31, 657, 12, 206, 206, 612], ["-", 3, 4, 0, 657, 31, 657, 12, 206, 206, 612], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 206, 612]]
5
96
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<int, int>; using PLL = pair<ll, ll>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repn(i, n) for (int i = 0; i <= (int)(n); i++) #define srep(i, l, n) for (int i = l; i < (int)(n); i++) #define sre...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<int, int>; using PLL = pair<ll, ll>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repn(i, n) for (int i = 0; i <= (int)(n); i++) #define srep(i, l, n) for (int i = l; i < (int)(n); i++) #define sre...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
721
H1, M1, H2, M2, K = map(int, input()) m1 = 60*H1 + M1 m2 = 60*H2 + M2 print(m2-m1-K)
H1, M1, H2, M2, K = map(int, input().split()) m1 = 60*H1 + M1 m2 = 60*H2 + M2 print(m2-m1-K)
[["+", 12, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
40
h1,m1,h2,m2,k = map(int, input().split()) print(max(h2*60+m2 - h1*60+m1 - k, 0))
h1,m1,h2,m2,k = map(int, input().split()) print(max((h2*60+m2) - (h1*60+m1) - k, 0))
[["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 25], ["+", 3, 4, 0, 657, 31, 657, 12, 23, 0, 24], ["+", 3, 4, 0, 657, 31, 657, 12, 23, 0, 25]]
5
43
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int hour1 = input.nextInt(); int minute1 = input.nextInt(); int hour2 = input.nextInt(); int minute2 = input.nextInt(); int k = input.nextInt(); int result = (hour2 - hou...
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int hour1 = input.nextInt(); int minute1 = input.nextInt(); int hour2 = input.nextInt(); int minute2 = input.nextInt(); int k = input.nextInt(); int result = (hour2 - hou...
[["-", 0, 1, 0, 492, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 22]]
3
105