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
import sys, math import io, os #data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from bisect import bisect_left as bl, bisect_right as br, insort from heapq import heapify, heappush, heappop from collections import defaultdict as dd, deque, Counter #from itertools import permutations,combinations def data(): ...
import sys, math import io, os #data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from bisect import bisect_left as bl, bisect_right as br, insort from heapq import heapify, heappush, heappop from collections import defaultdict as dd, deque, Counter #from itertools import permutations,combinations def data(): ...
[["-", 3, 4, 0, 657, 31, 652, 3, 4, 0, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 22], ["-", 12, 206, 206, 657, 12, 652, 3, 4, 0, 22], ["+", 12, 206, 206, 657, 12, 652, 3, 4, 0, 22]]
5
334
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pi 3.141592653589793238 #define int long long using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pi 3.141592653589793238 #define int long long using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_...
[["-", 15, 339, 51, 16, 31, 16, 31, 16, 17, 33], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 72], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 17, 72]]
1
537
from collections import deque n, k = map(int, input().split()) p = list(map(int, input().split())) c = list(map(int, input().split())) ans = -1000000000 for i in range(n): now = i j = 0 # visited = deque() score = deque([0]) # isLoop = True while j < k: # visited.append(now) sc...
from collections import deque n, k = map(int, input().split()) p = list(map(int, input().split())) c = list(map(int, input().split())) ans = -1000000000 for i in range(n): now = i j = 0 score = deque([0]) while j < k: score.append(score[j] +c[p[now]-1]) now = p[now]-1 j += 1 ...
[["-", 3, 4, 0, 206, 206, 663, 0, 657, 12, 612], ["+", 3, 4, 0, 206, 206, 663, 0, 657, 12, 612]]
5
223
R,C,K=map(int,input().split()) l=[[0] * C for i in range(R)] for i in range(K): a,b,c=map(int,input().split()) a-=1 b-=1 l[a][b]=c dp=[0]*C for i in range(R): ndp=[0]*C kdp=[0]*4 kdp[0]=dp[0] kdp[1]=l[i][0]+dp[0] ndp[0]=dp[0]+kdp[1] for j in range(1,C): kdp[0]=max(kdp[0],dp[j]) for k in rang...
R,C,K=map(int,input().split()) l=[[0] * C for i in range(R)] for i in range(K): a,b,c=map(int,input().split()) a-=1 b-=1 l[a][b]=c dp=[0]*C for i in range(R): ndp=[0]*C kdp=[0]*4 kdp[0]=dp[0] kdp[1]=l[i][0]+dp[0] ndp[0]=kdp[1] for j in range(1,C): kdp[0]=max(kdp[0],dp[j]) for k in range(2,-1...
[["-", 0, 1, 0, 662, 12, 657, 31, 206, 51, 22], ["-", 0, 1, 0, 662, 12, 657, 31, 206, 0, 70], ["-", 0, 1, 0, 662, 12, 657, 31, 206, 206, 612], ["-", 0, 1, 0, 662, 12, 657, 31, 206, 0, 73], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72]]
5
235
#include <bits/stdc++.h> using namespace std; #define ll long long ll N, M, K, cache[3000][3000][3]; map<pair<ll, ll>, ll> val; ll dp(ll i, ll j, ll col) { if (i >= N) { return LLONG_MIN; } else if (j >= M) { return LLONG_MIN; } else if (col > 3) { return LLONG_MIN; } else if (i == N - 1 && j == ...
#include <bits/stdc++.h> using namespace std; #define ll long long ll N, M, K, cache[3000][3000][4]; map<pair<ll, ll>, ll> val; ll dp(ll i, ll j, ll col) { if (i >= N) { return LLONG_MIN; } else if (j >= M) { return LLONG_MIN; } else if (col > 3) { return LLONG_MIN; } else if (i == N - 1 && j == ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
466
// Hail god Yato #include <bits/stdc++.h> using namespace std; #define hs \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0...
// Hail god Yato #include <bits/stdc++.h> using namespace std; #define hs \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0...
[["-", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
413
// Hail god Yato #include <bits/stdc++.h> using namespace std; #define hs \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0...
// Hail god Yato #include <bits/stdc++.h> using namespace std; #define hs \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0...
[["-", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
440
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> #define IOS ...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> #define IOS ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
484
R,C,K = map(int, input().split()) maze = [[0 for _ in range(C)] for _ in range(R)] dp = [[[0 for _ in range(C+1)] for _ in range(R+1)] for _ in range(4)] for i in range(K): r,c,v = map(int, input().split()) r -=1 c -= 1 maze[r][c] = v for i in range(R): for j in range(C): for k in...
R,C,K = map(int, input().split()) maze = [[0 for _ in range(C)] for _ in range(R)] dp = [[[0 for _ in range(C+1)] for _ in range(R+1)] for _ in range(4)] for i in range(K): r,c,v = map(int, input().split()) r -=1 c -= 1 maze[r][c] = v for i in range(R): for j in range(C): for k in...
[["-", 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
317
#include <bits/stdc++.h> #include <chrono> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <random> using namespace std; using namespace __gnu_pbds; #define endl '\n' typedef long long ll; typedef pair<int, int> pii; typedef tree<int, null_type, less<int>, rb_tree_tag, ...
#include <bits/stdc++.h> #include <chrono> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <random> using namespace std; using namespace __gnu_pbds; #define endl '\n' typedef long long ll; typedef pair<int, int> pii; typedef tree<int, null_type, less<int>, rb_tree_tag, ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
455
R, C, K = map(int, input().split()) grid = [[0 for c in range(C)] for r in range(R)] for k in range(K): r, c, v = map(int, input().split()) grid[r-1][c-1] = v dp = [[[-1000 for c in range(C)] for r in range(R)] for k in range(4)] if grid[0][0] > 0: dp[1][0][0] = grid[0][0] dp[0][0][0] = 0 for r in rang...
R, C, K = map(int, input().split()) grid = [[0 for c in range(C)] for r in range(R)] for k in range(K): r, c, v = map(int, input().split()) grid[r-1][c-1] = v dp = [[[-1000 for c in range(C)] for r in range(R)] for k in range(4)] if grid[0][0] > 0: dp[1][0][0] = grid[0][0] dp[0][0][0] = 0 for r in rang...
[["-", 0, 657, 31, 206, 51, 206, 51, 206, 206, 612], ["+", 0, 657, 31, 206, 51, 206, 51, 206, 206, 612]]
5
690
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define rep(i, n, m) for (int i = (n); i < (int)(m); i++) #define reps(i, n, m) for (int i...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define rep(i, n, m) for (int i = (n); i < (int)(m); i++) #define reps(i, n, m) for (int i...
[["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13]]
1
650
#include <bits/stdc++.h> #define pi acos(-1) #define ll long long #define pii pair<ll, ll> #define debug(a) cout << a << '\n' #define maxn 200009 /// I wanna be the wind #define MOD 1000000007 #define F first #define S second #define rep(i, a, b) for (ll i = a; i < (b); ++i) #define per(i, b, a) for (ll i = b - 1; i >=...
#include <bits/stdc++.h> #define pi acos(-1) #define ll long long #define pii pair<ll, ll> #define debug(a) cout << a << '\n' #define maxn 200009 /// I wanna be the wind #define MOD 1000000007 #define F first #define S second #define rep(i, a, b) for (ll i = a; i < (b); ++i) #define per(i, b, a) for (ll i = b - 1; i >=...
[["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 72], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
662
R,C,K = gets.chomp.split(" ").map(&:to_i) r,c,v = K.times.map{gets.split.map(&:to_i)}.transpose value = Array.new(R){Array.new(C,0)} K.times do |i| value[r[i]-1][c[i]-1] = v[i] end dp0 = Array.new(C+1){Array.new(4,0)} dp1 = Array.new(C+1){Array.new(4,0)} #dp0[0][0] = 0 #dp0[0][1] = value[0][0] R.times do |i| C.time...
R,C,K = gets.chomp.split(" ").map(&:to_i) r,c,v = K.times.map{gets.split.map(&:to_i)}.transpose value = Array.new(R){Array.new(C,0)} K.times do |i| value[r[i]-1][c[i]-1] = v[i] end #2つのdp配列を使いまわす dp0 = Array.new(C+1){Array.new(4,0)} dp1 = Array.new(C+1){Array.new(4,0)} R.times do |i| C.times do |j| #今いるマスを1つずつ処...
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 612]]
4
372
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define pf push_front #define eb emplace_back #define emp emplace #define ins insert #define mp make_pair #define mt make_tuple #define sz(s) (int)s.size() #define forp(i, a, b) for (int i = a; i <= b; i++) #define rep(i, n) for (int i = 0...
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define pf push_front #define eb emplace_back #define emp emplace #define ins insert #define mp make_pair #define mt make_tuple #define sz(s) (int)s.size() #define forp(i, a, b) for (int i = a; i <= b; i++) #define rep(i, n) for (int i = 0...
[["-", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 75, 76, 0, 9, 0, 57, 64, 9, 0, 46]]
1
1,032
r,c,k=map(int,input().split()) lst=[[0]*(c+1) for i in range(r+1)] for i in range(k): s,t,u=map(int,input().split()) lst[s][t]=u dp1=[[0]*(c+1) for i in range(r+1)] dp2=[[0]*(c+1) for i in range(r+1)] dp3=[[0]*(c+1) for i in range(r+1)] for i in range(1,r+1): for j in range(1,c+1): dp1[i][j]=max(dp1[i][j-1...
r,c,k=map(int,input().split()) lst=[[0]*(c+1) for i in range(r+1)] for i in range(k): s,t,u=map(int,input().split()) lst[s][t]=u dp1=[[0]*(c+1) for i in range(r+1)] dp2=[[0]*(c+1) for i in range(r+1)] dp3=[[0]*(c+1) for i in range(r+1)] for i in range(1,r+1): for j in range(1,c+1): dp1[i][j]=max(dp1[i][j-1...
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
352
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <stack> #include <st...
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <stack> #include <st...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 5...
1
712
import sys sys.setrecursionlimit(10**7) readline = sys.stdin.buffer.readline def readstr():return readline().rstrip().decode() def readstrs():return list(readline().decode().split()) def readint():return int(readline()) def readints():return list(map(int,readline().split())) def printrows(x):print('\n'.join(map(str,x)...
import sys sys.setrecursionlimit(10**7) readline = sys.stdin.buffer.readline def readstr():return readline().rstrip().decode() def readstrs():return list(readline().decode().split()) def readint():return int(readline()) def readints():return list(map(int,readline().split())) def printrows(x):print('\n'.join(map(str,x)...
[["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 354], ["-", 12, 652, 3, 4, 0, 206, 206, 657, 12, 612], ["+", 12, 652, 3, 4, 0, 206, 206, 657, 12, 22]]
5
435
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> //memset(dp,0,sizeof(dp)) #include <functional> #include <iomanip> #include <iostream> #include <locale> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define ll long long #d...
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> //memset(dp,0,sizeof(dp)) #include <functional> #include <iomanip> #include <iostream> #include <locale> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define ll long long #d...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 0, 2, 3, 4, 0, 2, 3...
1
650
//#include<bits/stdc++.h> #include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <set> #include <vector> /* #include <boost/multiprecision/cpp_dec_float.hpp> #include<boost/multiprecision/cpp_int.hpp> #include <boost/rational.hpp> namespace mp = boost::multiprecision; using Real = mp::numb...
//#include<bits/stdc++.h> #include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <set> #include <vector> /* #include <boost/multiprecision/cpp_dec_float.hpp> #include<boost/multiprecision/cpp_int.hpp> #include <boost/rational.hpp> namespace mp = boost::multiprecision; using Real = mp::numb...
[["+", 0, 14, 8, 9, 0, 43, 0, 114, 0, 115]]
1
751
def main(): import sys input=sys.stdin.readline h,w,k=map(int,input().split()) H=range(h) W=range(w) dp=[[[0]*w for j in H] for i in range(4)] for _ in range(k): r,c,v=map(int,input().split()) dp[r-1][c-1][0]=v if dp[0][0][0]!=0: dp[1][0][0]=dp[0][0][0] dp[0][0][0]=0 for y in H: fo...
def main(): import sys input=sys.stdin.readline h,w,k=map(int,input().split()) H=range(h) W=range(w) dp=[[[0]*w for j in H] for i in range(4)] for _ in range(k): r,c,v=map(int,input().split()) dp[0][r-1][c-1]=v if dp[0][0][0]!=0: dp[1][0][0]=dp[0][0][0] dp[0][0][0]=0 for y in H: fo...
[["+", 0, 662, 31, 206, 51, 206, 51, 206, 206, 612], ["+", 0, 662, 31, 206, 51, 206, 51, 206, 0, 73], ["+", 0, 1, 0, 662, 31, 206, 51, 206, 0, 70], ["-", 0, 1, 0, 662, 31, 206, 51, 206, 0, 73], ["-", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["-", 8, 196, 0, 1, 0, 662, 31, 206, 206, 612]]
5
455
#include <bits/stdc++.h> #define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a) #define rep2(i, s, n) rep3(i, s, n, 1) #define rep(i, n) rep2(i, 0, n) using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int, int>; int main() { int R, C, k; cin >> R >> C >> k; vect...
#include <bits/stdc++.h> #define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a) #define rep2(i, s, n) rep3(i, s, n, 1) #define rep(i, n) rep2(i, 0, n) using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int, int>; int main() { int R, C, k; cin >> R >> C >> k; vect...
[["-", 12, 2, 3, 4, 0, 69, 28, 69, 28, 22], ["+", 3, 4, 0, 69, 28, 69, 28, 69, 28, 22], ["+", 0, 69, 28, 69, 28, 69, 341, 342, 0, 70], ["+", 0, 69, 28, 69, 28, 69, 341, 342, 0, 13], ["+", 0, 69, 28, 69, 28, 69, 341, 342, 0, 73]]
1
428
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, ...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, ...
[["-", 0, 657, 31, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 657, 31, 657, 12, 23, 0, 657, 12, 612], ["-", 12, 23, 0, 657, 12, 23, 0, 657, 12, 612], ["+", 12, 23, 0, 657, 12, 23, 0, 657, 12, 612], ["-", 31, 657, 31, 657, 12, 23, 0, 657, 31, 22], ["+", 31, 657, 31, 657, 12, 23, 0, 657, 31, 22]]
5
413
R, C, K = map(int, input().split()) grid = [[0]*C for _ in range(R)] for i in range(K): r, c, v= map(int, input().split()) grid[r-1][c-1] = v dp = [[[0]*(C+1) for _ in range(R+1)] for _ in range(4)] for i in range(1,R+1): for k in range(1,C+1): tmp = max(dp[0][i-1][k],dp[1][i-1][k],dp[2][i-1][k],dp[...
R, C, K = map(int, input().split()) grid = [[0]*C for _ in range(R)] for i in range(K): r, c, v= map(int, input().split()) grid[r-1][c-1] = v dp = [[[0]*(C+1) for _ in range(R+1)] for _ in range(4)] for i in range(1,R+1): for k in range(1,C+1): tmp = max(dp[0][i-1][k],dp[1][i-1][k],dp[2][i-1][k],dp[...
[["-", 3, 4, 0, 206, 51, 206, 51, 206, 206, 612], ["+", 3, 4, 0, 206, 51, 206, 51, 206, 206, 612]]
5
509
#include <bits/stdc++.h> #define ll long long #define db double #define iosks \ std::ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0)...
#include <bits/stdc++.h> #define ll long long #define db double #define iosks \ std::ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0)...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
459
#include <bits/stdc++.h> #define int long long #define double long double using namespace std; const int MOD = 1000000007; const int INF = 1e14; using Graph = vector<vector<int>>; //既に同じ行でi個拾った状態でj行k列にいるときの最大値 int dp[4][3100][3100]; signed main() { int R, C, K; cin >> R >> C >> K; vector<vector<int>> L(R + 10,...
#include <bits/stdc++.h> #define int long long #define double long double using namespace std; const int MOD = 1000000007; const int INF = 1e14; using Graph = vector<vector<int>>; //既に同じ行でi個拾った状態でj行k列にいるときの最大値 int dp[4][3100][3100]; signed main() { int R, C, K; cin >> R >> C >> K; vector<vector<int>> L(R + 10,...
[["-", 31, 69, 28, 69, 28, 69, 341, 342, 0, 13], ["+", 31, 69, 28, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 69, 28, 69, 28, 69, 341, 342, 0, 13], ["+", 0, 69, 28, 69, 28, 69, 341, 342, 0, 22]]
1
386
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define Rrep(i, n) for (int i = ((int)n - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define INF 2e15 #define MOD 10e9 + 7 typedef vector<int> vint; typedef long long ll; ll ...
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define Rrep(i, n) for (int i = ((int)n - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define INF 2e15 #define MOD 10e9 + 7 typedef vector<int> vint; typedef long long ll; ll ...
[["-", 0, 9, 0, 1, 0, 11, 12, 91, 17, 33], ["-", 0, 9, 0, 1, 0, 11, 12, 91, 28, 22], ["+", 0, 9, 0, 9, 0, 1, 0, 11, 12, 13]]
1
418
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PRINT(a) cout << (a) << endl #define pb push_back #define eb emplace_back #define Fi first #define Se...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PRINT(a) cout << (a) << endl #define pb push_back #define eb emplace_back #define Fi first #define Se...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["-", 12, 2, 3, 4, 0, 69, 341, 342, 0, 13], ["+", 12, 2, 3, 4, 0, 69, 341, 342, 0, 13]]
1
646
#include <bits/stdc++.h> using namespace std; #define eb emplace_back #define ii pair<int, int> #define OK (cerr << "OK" << endl) #define debug(x) cerr << #x " = " << (x) << endl #define ff first #define ss second #define int long long #define tt tuple<int, int, int> #define all(x) x.begin(), x.end() #define vvi vect...
#include <bits/stdc++.h> using namespace std; #define eb emplace_back #define ii pair<int, int> #define OK (cerr << "OK" << endl) #define debug(x) cerr << #x " = " << (x) << endl #define ff first #define ss second #define int long long #define tt tuple<int, int, int> #define all(x) x.begin(), x.end() #define vvi vect...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
420
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repit(it, li) for (auto it = li.begin(); it != li.end(); it++) using namespace std; using ll = long long; using P = pair<int, int>; static ll dp[3000][4]; static int tem[3000][3000]; int main() { int r, c, k; cin >> r >> c >> k; re...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repit(it, li) for (auto it = li.begin(); it != li.end(); it++) using namespace std; using ll = long long; using P = pair<int, int>; static ll dp[3000][4]; static int tem[3000][3000]; int main() { int r, c, k; cin >> r >> c >> k; re...
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
355
#include <bits/stdc++.h> #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 \ int __tc; ...
#include <bits/stdc++.h> #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 \ int __tc; ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
425
import sys input = sys.stdin.buffer.readline R,C,K = map(int,input().split()) goods = [[0]*(C+1) for _ in range(R+1)] INF = 10**18 for i in range(K): ri,ci,vi = map(int,input().split()) goods[ri][ci] = vi DP = [[[-INF]*(C+1) for _ in range(R+1)] for _ in range(4)] DP[0][1][1] = 0 if goods[1][1]: DP[1][1][1]...
import sys input = sys.stdin.buffer.readline R,C,K = map(int,input().split()) goods = [[0]*(C+1) for _ in range(R+1)] INF = 10**18 for i in range(K): ri,ci,vi = map(int,input().split()) goods[ri][ci] = vi DP = [[[-INF]*(C+1) for _ in range(R+1)] for _ in range(4)] DP[0][1][1] = 0 if goods[1][1]: DP[1][1][1]...
[["+", 0, 57, 15, 206, 51, 206, 206, 657, 31, 22], ["+", 0, 57, 15, 206, 51, 206, 206, 657, 17, 72], ["-", 8, 196, 0, 57, 15, 206, 206, 657, 31, 22], ["-", 8, 196, 0, 57, 15, 206, 206, 657, 17, 72]]
5
894
R, C, K=map(int, input().split()) math=[[0]*C for _ in range(R)] for _ in range(K): r, c, v=map(int, input().split()) math[r-1][c-1]=v dp=[[[0]*C for __ in range(R)] for _ in range(4)] if math[0][0]>0: dp[1][0][0]=math[0][0]+0 for j in range(1, C): dp[0][0][j]=dp[0][j-1][0]+0 dp[1][0][j]=max(dp[1][0][j-...
R, C, K=map(int, input().split()) math=[[0]*C for _ in range(R)] for _ in range(K): r, c, v=map(int, input().split()) math[r-1][c-1]=v dp=[[[0]*C for __ in range(R)] for _ in range(4)] if math[0][0]>0: dp[1][0][0]=math[0][0]+0 for j in range(1, C): dp[0][0][j]=dp[0][0][j-1]+0 dp[1][0][j]=max(dp[1][0][j-...
[["+", 0, 662, 12, 657, 31, 206, 51, 206, 206, 612], ["+", 0, 662, 12, 657, 31, 206, 51, 206, 0, 73], ["+", 0, 1, 0, 662, 12, 657, 31, 206, 0, 70], ["-", 0, 662, 12, 657, 31, 206, 51, 206, 0, 73], ["-", 0, 1, 0, 662, 12, 657, 31, 206, 0, 70], ["-", 0, 1, 0, 662, 12, 657, 31, 206, 206, 612]]
5
761
#include <bits/stdc++.h> using namespace std; #define pr(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(...
#include <bits/stdc++.h> using namespace std; #define pr(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
428
#include <bits/stdc++.h> using namespace std; #define END '\n' #define int long long #define pb push_back #define pii pair<int, int> #define ff first #define ss second #define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " #define loop(i, a, b) for (int i = (a); i < (b); i++) #define loopb(i, b, a) for (in...
#include <bits/stdc++.h> using namespace std; #define END '\n' #define int long long #define pb push_back #define pii pair<int, int> #define ff first #define ss second #define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " #define loop(i, a, b) for (int i = (a); i < (b); i++) #define loopb(i, b, a) for (in...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
394
#pragma GCC optimize(2) #pragma GCC optimize(3) #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; #define fi first #define se second #define pb push_back #define wzh(x) cerr << #x << '=' << x << endl; int r, c, k; struct uzi { int r, c, v; bool operator<(const uzi &t) const...
#pragma GCC optimize(2) #pragma GCC optimize(3) #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; #define fi first #define se second #define pb push_back #define wzh(x) cerr << #x << '=' << x << endl; int r, c, k; struct uzi { int r, c, v; bool operator<(const uzi &t) const...
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
663
//#pragma GCC optimize ("-O3") #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <reg...
//#pragma GCC optimize ("-O3") #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <reg...
[["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13]]
1
3,118
#include <bits/stdc++.h> using namespace std; #define DEBUG(x) cerr << #x << ": " << x << endl; #define DEBUG_VEC(v) \ cerr << #v << ":"; \ for (int i = 0; i < v.size(); i++) ...
#include <bits/stdc++.h> using namespace std; #define DEBUG(x) cerr << #x << ": " << x << endl; #define DEBUG_VEC(v) \ cerr << #v << ":"; \ for (int i = 0; i < v.size(); i++) ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
995
#include <algorithm> #include <cctype> #include <cstdio> #include <cstring> #include <iostream> #include <utility> #include <vector> #define MAXN 200005 using namespace std; typedef long long ll; typedef pair<int, int> pi; inline pi read() { ll x = 0; pi ans; int f = 0; char c = getchar(); while (!isdigit(c) ...
#include <algorithm> #include <cctype> #include <cstdio> #include <cstring> #include <iostream> #include <utility> #include <vector> #define MAXN 200005 using namespace std; typedef long long ll; typedef pair<int, int> pi; inline pi read() { ll x = 0; pi ans; int f = 0; char c = getchar(); while (!isdigit(c) ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
574
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define IN freopen("alchemy_input.txt", "r", stdin) #define OUT freopen("output.txt", "w", stdout) #define pb push_back #define mp make_pair #define FOR(i, a, b) for (i = a; i <= b; i++) #define DBG printf("Hi\n") ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define IN freopen("alchemy_input.txt", "r", stdin) #define OUT freopen("output.txt", "w", stdout) #define pb push_back #define mp make_pair #define FOR(i, a, b) for (i = a; i <= b; i++) #define DBG printf("Hi\n") ...
[["-", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
585
#include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <complex> #include <ctime> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <unorder...
#include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <complex> #include <ctime> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <unorder...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
1,113
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; const int MAX = 60; vector<vector<int>> cnt(MAX, vector<int>(MAX)); for (int i = 0; i < n; i++) { long double x; cin >> x; long long y = (long long)(x * 1e9); int a = 0, b = 0; while (y % 2 == 0) { y /= 2; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; const int MAX = 60; vector<vector<int>> cnt(MAX, vector<int>(MAX)); for (int i = 0; i < n; i++) { long double x; cin >> x; long long y = (long long)(x * 1e9 + 0.1); int a = 0, b = 0; while (y % 2 == 0) { y ...
[["+", 49, 50, 51, 74, 51, 23, 0, 16, 17, 72], ["+", 49, 50, 51, 74, 51, 23, 0, 16, 12, 13]]
1
300
#include <iostream> #include <utility> #include <vector> using namespace std; double EPS = 1e-10; typedef pair<long long, long long> P; int main() { int N; cin >> N; vector<long long> A(N); for (int i = 0; i < N; i++) { long double a; cin >> a; A[i] = a * 1e9 + EPS; } vector<P> cnt(N); for (in...
#include <iostream> #include <utility> #include <vector> using namespace std; double EPS = 1e-10; typedef pair<long long, long long> P; int main() { int N; cin >> N; vector<long long> A(N); for (int i = 0; i < N; i++) { long double a; cin >> a; A[i] = a * 1e9 + 0.01; } vector<P> cnt(N); for (i...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
447
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; const int MAX = 60; vector<vector<int>> cnt(MAX, vector<int>(MAX)); for (int i = 0; i < n; i++) { long double x; cin >> x; long long y = (long long)(x * 1e9 + 0.5); int a = 0, b = 0; while (y % 2 == 0) { y ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; const int MAX = 60; vector<vector<int>> cnt(MAX, vector<int>(MAX)); for (int i = 0; i < n; i++) { long double x; cin >> x; long long y = (long long)(x * 1e9 + 0.5); int a = 0, b = 0; while (y % 2 == 0) { y ...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 85], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
304
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; inline int my_getchar_unlocked() { static char buf[1048576]; static int s = 1048576; static int e = 1048576; if (s == e && e == 1048576) { e = fread_unlocked(buf, 1, 1048576, stdin); s = 0; } if (s == e) { return EOF; ...
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; inline int my_getchar_unlocked() { static char buf[1048576]; static int s = 1048576; static int e = 1048576; if (s == e && e == 1048576) { e = fread_unlocked(buf, 1, 1048576, stdin); s = 0; } if (s == e) { return EOF; ...
[["-", 0, 52, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 68]]
1
1,189
#pragma region Headers #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #in...
#pragma region Headers #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #in...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 0, 7, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 7, 8, 9, 0, 43, 39, 86, 39, 40]]
1
1,336
from collections import defaultdict from decimal import Decimal N = int(input()) T = defaultdict(int) a = 0 b = 0 for i in range(N): A = Decimal((input())) A *= 10**9 A = int(A) t = 0 f = 0 while(True): if A % 2 != 0: break A = A // 2 t += 1 while (True): ...
from collections import defaultdict from decimal import Decimal N = int(input()) T = defaultdict(int) a = 0 b = 0 for i in range(N): A = Decimal((input())) A *= 10**9 A = int(A) t = 0 f = 0 while(True): if A % 2 != 0: break A = A // 2 t += 1 while (True): ...
[["-", 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
236
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from...
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from...
[["-", 0, 1, 0, 677, 12, 657, 12, 206, 206, 22], ["+", 0, 1, 0, 677, 12, 657, 12, 206, 206, 22]]
5
489
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repr(i, n) for (int i = (n); i >= 0; --i) #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define FORR(i, m, n) for (int i = (m); i >= (n); --i) #define equals(a, b) (fabs((a) - (b)) < EPS) using namespace std; typedef long long ll; t...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repr(i, n) for (int i = (n); i >= 0; --i) #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define FORR(i, m, n) for (int i = (m); i >= (n); --i) #define equals(a, b) (fabs((a) - (b)) < EPS) using namespace std; typedef long long ll; t...
[["-", 0, 1, 0, 27, 28, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 27, 28, 69, 341, 342, 0, 13]]
1
617
def mss(l,length,k): x = - 1000000001 for i in range(length): temp = 0 for j in range(i,i+k): temp += l[j] if temp > x: x = temp return x def mss2(l,length,total,k): x = - 1000000001 if k <= length: for i in range(length): te...
def mss(l,length,k): x = - 1000000001 for i in range(length): temp = 0 for j in range(i,i+k): temp += l[j] if temp > x: x = temp return x def mss2(l,length,total,k): x = - 1000000001 if k <= length: for i in range(length): te...
[["+", 0, 657, 12, 23, 0, 657, 31, 23, 0, 24], ["+", 0, 657, 12, 23, 0, 657, 12, 23, 0, 25], ["+", 12, 657, 12, 23, 0, 657, 12, 23, 0, 24], ["+", 12, 657, 12, 23, 0, 657, 12, 23, 0, 25]]
5
415
N,K=map(int,input().split()) P=list(map(int,input().split())) C=list(map(int,input().split())) for i in range(N): P[i]-=1 ans=-float('inf') for start in range(N): loop_len=1 pos=P[start] score=C[pos] scores=[score] while pos!=start: loop_len+=1 pos=P[pos] score+=C[pos...
N,K=map(int,input().split()) P=list(map(int,input().split())) C=list(map(int,input().split())) for i in range(N): P[i]-=1 ans=-float('inf') for start in range(N): loop_len=1 pos=P[start] score=C[pos] scores=[score] while pos!=start: loop_len+=1 pos=P[pos] score+=C[pos...
[["-", 0, 206, 206, 663, 0, 23, 0, 657, 17, 109], ["+", 0, 206, 206, 663, 0, 23, 0, 657, 17, 33], ["+", 206, 663, 0, 23, 0, 657, 12, 657, 17, 48], ["+", 206, 663, 0, 23, 0, 657, 12, 657, 12, 22]]
5
188
import sys def main(): input = sys.stdin.readline n, k = map(int, input().split()) p = list(map(lambda x:int(x) - 1, input().split())) c = list(map(int, input().split())) seen = [0] * n accumulate = [] for i in range(n): if seen[i] == 0: accumulate.append([c[i]]) ...
import sys def main(): input = sys.stdin.readline n, k = map(int, input().split()) p = list(map(lambda x:int(x) - 1, input().split())) c = list(map(int, input().split())) seen = [0] * n accumulate = [] for i in range(n): if seen[i] == 0: accumulate.append([c[i]]) ...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
498
N, K = map(int, input().split()) P = list(map(int, input().split())) C = list(map(int, input().split())) for i in range(N): P[i] -= 1 ans = max(C) S = set(range(N)) while S: scores = [] x = S.pop() while True: scores.append(C[x]) x = P[x] if x not in S: break S.remove(x) l = len(scores...
N, K = map(int, input().split()) P = list(map(int, input().split())) C = list(map(int, input().split())) for i in range(N): P[i] -= 1 ans = max(C) S = set(range(N)) while S: scores = [] x = S.pop() while True: scores.append(C[x]) x = P[x] if x not in S: break S.remove(x) l = len(scores...
[["-", 3, 4, 0, 657, 12, 23, 0, 41, 0, 612], ["+", 3, 4, 0, 657, 12, 23, 0, 41, 0, 22], ["-", 0, 657, 12, 23, 0, 41, 0, 666, 667, 47], ["+", 0, 657, 12, 23, 0, 41, 0, 666, 667, 18], ["-", 3, 4, 0, 657, 12, 23, 0, 41, 0, 22], ["+", 3, 4, 0, 657, 12, 23, 0, 41, 0, 612]]
5
277
ma = lambda :map(int,input().split()) lma = lambda :list(map(int,input().split())) tma = lambda :tuple(map(int,input().split())) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") import collections import math import itertools import heapq as hq n,k = ma() Pt = lma() P = [p-1 for p in Pt] C = ...
ma = lambda :map(int,input().split()) lma = lambda :list(map(int,input().split())) tma = lambda :tuple(map(int,input().split())) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") import collections import math import itertools import heapq as hq n,k = ma() Pt = lma() P = [p-1 for p in Pt] C = ...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
5
603
import java.math.*; import java.util.*; import java.util.function.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = Integer.valueOf(s.next()); int K = Integer.valueOf(s.next()); int[] P = new int[N + 1]; int[] C = new int[N + 1]; for (...
import java.math.*; import java.util.*; import java.util.function.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = Integer.valueOf(s.next()); int K = Integer.valueOf(s.next()); int[] P = new int[N + 1]; int[] C = new int[N + 1]; for (...
[["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 499], ["+", 64, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 64, 196, 0, 7, 15, 16, 12, 16, 17, 72]]
3
400
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int gp[5005]; ll gp_sc[5005]; ll gp_size[5005]; int main() { ll N, K; cin >> N >> K; vector<int> P(N + 1); vector<ll> C(N + 1); REP(i, N) cin >> P[i], P[i]--; REP(i, N) cin >> C[i]; // グル...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int gp[5005]; ll gp_sc[5005]; ll gp_size[5005]; int main() { ll N, K; cin >> N >> K; vector<int> P(N + 1); vector<ll> C(N + 1); REP(i, N) cin >> P[i], P[i]--; REP(i, N) cin >> C[i]; // グル...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
386
n, k = map(int, input().split()) P = list(map(lambda x:int(x)-1, input().split())) C = list(map(int, input().split())) D = [-1]*n ans = -float("inf") for i, p in enumerate(P): ans = max(ans, C[p]) temp = p res = C[p] cnt = 1 while temp != i and cnt < k: temp = P[temp] res += C[temp] ...
n, k = map(int, input().split()) P = list(map(lambda x:int(x)-1, input().split())) C = list(map(int, input().split())) D = [-1]*n ans = -float("inf") for i, p in enumerate(P): ans = max(ans, C[p]) temp = p res = C[p] cnt = 1 while temp != i and cnt < k: temp = P[temp] res += C[temp] ...
[["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 33], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 12, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72]]
5
235
#include <bits/stdc++.h> using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v).begin(), (v).end() #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) \ for (__typeof__((s).begin()...
#include <bits/stdc++.h> using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v).begin(), (v).end() #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) \ for (__typeof__((s).begin()...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
874
N,K = map(int,input().split()) P=list(map(lambda x:int(x)-1,input().split())) C=list(map(int,input().split())) ans=-float("inf") for start in range(N): cur=P[start] scores=[C[cur]] for _ in range(K): if cur==start: break cur = P[cur] scores.append(C[cur]+scores[-1]) ...
N,K = map(int,input().split()) P=list(map(lambda x:int(x)-1,input().split())) C=list(map(int,input().split())) ans=-float("inf") for start in range(N): cur=P[start] scores=[C[cur]] for _ in range(K): if cur==start: break cur = P[cur] scores.append(C[cur]+scores[-1]) ...
[["+", 0, 1, 0, 662, 12, 657, 31, 657, 12, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33]]
5
196
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define sz(x) int(x.size()) typedef long long ll; typedef long double ld; typedef pair<int, int> P; constexpr ll INF = (1LL << 60); int main() { int n, k; cin >> n >> k; vector<int> p(n), c(n); rep(i, n) cin >> p[i], ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define sz(x) int(x.size()) typedef long long ll; typedef long double ld; typedef pair<int, int> P; constexpr ll INF = (1LL << 60); int main() { int n, k; cin >> n >> k; vector<int> p(n), c(n); rep(i, n) cin >> p[i], ...
[["-", 8, 9, 0, 43, 49, 50, 51, 27, 17, 68], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
510
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; typedef pair<int, int> Pi; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define fi first #define se second #define endl "\n" template <typename T> inline b...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; typedef pair<int, int> Pi; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define fi first #define se second #define endl "\n" template <typename T> inline b...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 91, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 91, 28, 22]]
1
901
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; typedef pair<int, int> Pi; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define fi first #define se second #define endl "\n" template <typename T> inline b...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; typedef pair<int, int> Pi; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define fi first #define se second #define endl "\n" template <typename T> inline b...
[["-", 12, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["-", 12, 16, 12, 23, 0, 16, 31, 16, 17, 85], ["+", 12, 16, 12, 23, 0, 16, 31, 16, 17, 85], ["+", 12, 16, 12, 23, 0, 16, 31, 16, 12, 22]]
1
948
#include <bits/stdc++.h> using namespace std; void chmax(int64_t &a, int64_t b) { a = max(a, b); } int nth_bit(int64_t num, int n) { return (num >> n) & 1; } int main() { int N; int64_t K; cin >> N >> K; vector<int> P(N); for (int i = 0; i < N; i++) cin >> P[i], P[i]--; vector<int64_t> C(N); for (i...
#include <bits/stdc++.h> using namespace std; void chmax(int64_t &a, int64_t b) { a = max(a, b); } int nth_bit(int64_t num, int n) { return (num >> n) & 1; } int main() { int N; int64_t K; cin >> N >> K; vector<int> P(N); for (int i = 0; i < N; i++) cin >> P[i], P[i]--; vector<int64_t> C(N); for (i...
[["-", 8, 7, 8, 7, 8, 1, 0, 11, 12, 13], ["+", 8, 7, 8, 7, 8, 1, 0, 11, 12, 13], ["-", 0, 43, 49, 50, 51, 23, 0, 41, 15, 22], ["+", 0, 43, 49, 50, 51, 23, 0, 41, 15, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
657
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define FOR(i, n) for (int i = 0; i < n; i++) #define FOR1(i, n) for (int i = 1; i <= n; i++) #define FORI(i, n) for (int i = n - 1; i >= 0; i--) template <class T, class U> void umin(T &x, const U &y) { x = min(x, (T)y); }...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define FOR(i, n) for (int i = 0; i < n; i++) #define FOR1(i, n) for (int i = 1; i <= n; i++) #define FORI(i, n) for (int i = n - 1; i >= 0; i--) template <class T, class U> void umin(T &x, const U &y) { x = min(x, (T)y); }...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 51, 16, 31, 23, 0, 16, 12, 16, 31, 13], ["+", 51, 16, 31, 23, 0, 16, 12, 16, 17, 48]]
1
552
#include <bits/stdc++.h> using namespace std; #define reps(i, a, n) for (int i = (a); i < (n); ++i) #define rep(i, n) reps(i, 0, n) #define deps(i, a, n) for (int i = (a); i >= (n); --i) #define dep(i, n) deps(i, n, 0) #define inf 2147483647 #define int long long signed main(void) { int n, k; cin >> n >> k; int ...
#include <bits/stdc++.h> using namespace std; #define reps(i, a, n) for (int i = (a); i < (n); ++i) #define rep(i, n) reps(i, 0, n) #define deps(i, a, n) for (int i = (a); i >= (n); --i) #define dep(i, n) deps(i, n, 0) #define inf 2147483647 #define int long long signed main(void) { int n, k; cin >> n >> k; int ...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 9, 0, 57, 15, 339, 0, 25], ["+", 8, 9, 0, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]]
1
387
/* このコード、と~おれ! Be accepted! ∧_∧  (。・ω・。)つ━☆・*。 ⊂   ノ    ・゜+.  しーJ   °。+ *´¨)          .· ´¸.·*´¨) ¸.·*¨)           (¸.·´ (¸.·'* ☆ */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <ioma...
/* このコード、と~おれ! Be accepted! ∧_∧  (。・ω・。)つ━☆・*。 ⊂   ノ    ・゜+.  しーJ   °。+ *´¨)          .· ´¸.·*´¨) ¸.·*¨)           (¸.·´ (¸.·'* ☆ */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <ioma...
[["-", 8, 9, 0, 57, 15, 339, 51, 91, 17, 372], ["-", 0, 57, 15, 339, 51, 91, 28, 69, 28, 22], ["-", 15, 339, 51, 91, 28, 69, 341, 342, 0, 70], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 15, 339, 51, 91, 28, 69, 341, 342, 0, 73]]
1
925
// Problem Link: // Tutorial Link: #include <bits/stdc++.h> using namespace std; #define LL long long #define ll long long #define all(v) v.begin(), v.end() #define pb push_back #define pLL pair<LL, LL> #define ff first #define ss second #define rep(i, a, b) for (LL i = a; i < b; ++i) #define repb(i, a, b) for (LL i...
// Problem Link: // Tutorial Link: #include <bits/stdc++.h> using namespace std; #define LL long long #define ll long long #define all(v) v.begin(), v.end() #define pb push_back #define pLL pair<LL, LL> #define ff first #define ss second #define rep(i, a, b) for (LL i = a; i < b; ++i) #define repb(i, a, b) for (LL i...
[["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 12, 13], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 12, 13]]
1
426
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, n) for...
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, n) for...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 2, 63, 118, 28, 22], ["+", 0, 11, 12, 16, 31, 2, 63, 118, 17, 131], ["+", 0, 11, 12, 16, 31, 2, 63, 118, 119, 120], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 25]]
1
476
#include <bits/stdc++.h> using namespace std; #define int long long #define PB push_back #define ALL(x) (x).begin(), (x).end() #define ALLR(x) (x).rbegin(), (x).rend() #define MP make_pair template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_stri...
#include <bits/stdc++.h> using namespace std; #define int long long #define PB push_back #define ALL(x) (x).begin(), (x).end() #define ALLR(x) (x).rbegin(), (x).rend() #define MP make_pair template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_stri...
[["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 51, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 51, 16, 12, 16, 31, 23, 0, 16, 12, 13]]
1
1,690
n, limit = list(map(int, input().split())) permute = list(map(int, input().split())) score = list(map(int, input().split())) visited = [False] * n ans = -10 ** 16 for i in range(n): if visited[i]: continue score_circle = [] now = i while True: visited[now] = True score_circle...
n, limit = list(map(int, input().split())) permute = list(map(int, input().split())) score = list(map(int, input().split())) visited = [False] * n ans = -10 ** 16 for i in range(n): if visited[i]: continue score_circle = [] now = i while True: visited[now] = True score_circle...
[["+", 0, 657, 12, 652, 3, 4, 0, 206, 0, 70], ["+", 12, 652, 3, 4, 0, 206, 206, 663, 0, 612], ["+", 12, 652, 3, 4, 0, 206, 206, 663, 0, 102], ["+", 0, 657, 12, 652, 3, 4, 0, 206, 0, 73]]
5
328
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; using vvl = vector<vector<ll>>; using P = pair<ll, ll>; using um = unordered_map<ll, ll>; #define fl cout << flush; #define endl '\n' template <typename T> inline void prt(T v) {...
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; using vvl = vector<vector<ll>>; using P = pair<ll, ll>; using um = unordered_map<ll, ll>; #define fl cout << flush; #define endl '\n' template <typename T> inline void prt(T v) {...
[["-", 64, 9, 0, 7, 15, 16, 12, 2, 63, 22], ["+", 64, 9, 0, 7, 15, 16, 12, 2, 63, 22]]
1
1,279
#include <bits/stdc++.h> #define ll long long #define ld long double #define FAST \ { \ ios_base::sync_with_stdio(false); \ cin....
#include <bits/stdc++.h> #define ll long long #define ld long double #define FAST \ { \ ios_base::sync_with_stdio(false); \ cin....
[["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 109], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 22]]
1
387
#include <cstdio> typedef long long LL; int n, k, p[5001]; LL c[5001], ans; LL getmax(LL a, LL b) { return a > b ? a : b; } int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; i++) scanf("%d", &p[i]); for (int i = 1; i <= n; i++) scanf("%lld", &c[i]); ans = c[1]; for (int i = 1; i <= n; i++...
#include <cstdio> typedef long long LL; int n, k, p[5001]; LL c[5001], ans; LL getmax(LL a, LL b) { return a > b ? a : b; } int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; i++) scanf("%d", &p[i]); for (int i = 1; i <= n; i++) scanf("%lld", &c[i]); ans = c[1]; for (int i = 1; i <= n; i++...
[["-", 3, 4, 0, 16, 12, 16, 31, 16, 31, 22], ["-", 3, 4, 0, 16, 12, 16, 31, 16, 17, 48], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 17, 48], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 12, 22]]
1
261
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef vector<int> vi; typedef long long ll; #define f first #define s second #define pb push_back #define lb lower_bound #define ub upper_bound #define sz(x) (int)x.size() #define all(x) ...
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef vector<int> vi; typedef long long ll; #define f first #define s second #define pb push_back #define lb lower_bound #define ub upper_bound #define sz(x) (int)x.size() #define all(x) ...
[["+", 51, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 69, 28, 69, 341, 342, 0, 73], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["+", 51, 16, 12, 69, 28, 69, 341, 342, 0, 70], ["+", 51, 16, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 69, 28, 69, 341, 342, 0, 73]]
1
1,079
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, int> pli; typedef pair<pli, pii> plii; #define mkp make_pair #define fi first #define se second int n; ll dis[53][21][2]; char c[53][23]; int len[53], C[53]; priority_queue<plii, vector<plii>, greater<plii>>...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, int> pli; typedef pair<pli, pii> plii; #define mkp make_pair #define fi first #define se second int n; ll dis[53][21][2]; char c[53][23]; int len[53], C[53]; priority_queue<plii, vector<plii>, greater<plii>>...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47]]
1
1,245
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define sz(x) ((int)(x.size())) string s[55]; long long C[55]; int dist[55][22][55][22]; bool pal(string s) { for (int i = 0; i < sz(s); i++) if (s[i] != s[sz(s) - 1 - i]) return 0; return 1; } bool pal(string x, string y) { for (int i...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define sz(x) ((int)(x.size())) string s[55]; long long C[55]; long long dist[55][22][55][22]; bool pal(string s) { for (int i = 0; i < sz(s); i++) if (s[i] != s[sz(s) - 1 - i]) return 0; return 1; } bool pal(string x, string y) { for ...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 13], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
1,320
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <s...
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <s...
[["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25]]
1
536
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; map<P, int> mp; int main() { int n; cin >> n; while (n--) { int cnt2 = 0, cnt5 = 0; ld x; cin >> x; ll t = ll(x * 1000000000); while (t % 2 == 0) t /= 2, cnt2++; whi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; map<P, int> mp; int main() { int n; cin >> n; while (n--) { int cnt2 = 0, cnt5 = 0; ld x; cin >> x; ll t = llround(x * 1000000000); while (t % 2 == 0) t /= 2, cnt2++; ...
[["-", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22]]
1
225
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9; const long long INF = 1e15; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n; cin >> n; vector<long double> a(n); vector<ll> b(n); for (ll i = 0; i < n; i++) cin >> a[i]; for...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9; const long long INF = 1e15; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n; cin >> n; vector<long double> a(n); vector<ll> b(n); for (ll i = 0; i < n; i++) cin >> a[i]; for...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
388
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define mp make_pair #define PI pair<ll, ll> #define poly vector<ll> #define mem(a) memset((a), 0, sizeof(a)) #define For(i, l, r) for (int i = (int)(l); i <= (int)(r); i++) #define Rep(i, r, l) f...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define mp make_pair #define PI pair<ll, ll> #define poly vector<ll> #define mem(a) memset((a), 0, sizeof(a)) #define For(i, l, r) for (int i = (int)(l); i <= (int)(r); i++) #define Rep(i, r, l) f...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
752
/* @uthor: Amit Kumar user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; //#include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; //...
/* @uthor: Amit Kumar user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; //#include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; //...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 176], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 0, 16, 31, 16, 12, 118, 28, 118, 28, 22], ["+", 0, 16, 31, 16, 12, 118, 28, 118, 28, 22]]
1
384
import sys import math import collections import bisect import itertools import decimal # import numpy as np sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 # MOD = 10 ** 9 + 7 MOD = 998244353 ni = lambda: int(sys.stdin.readline().rstrip()) ns = lambda: map(int, sys.stdin.readline().rstrip().split()) na = lambda: list...
import sys import math import collections import bisect import itertools import decimal # import numpy as np sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 # MOD = 10 ** 9 + 7 MOD = 998244353 ni = lambda: int(sys.stdin.readline().rstrip()) ns = lambda: map(int, sys.stdin.readline().rstrip().split()) na = lambda: list...
[["-", 31, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 31, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
395
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> #include <cstring> #include <string.h> using namespace std; #define pb push_back #define all(v) v.begin(), v.end() #define rep(i, n, v) for (i = n; i < v; i++) #define per(i, n, v) for (i = n; i > v; i--) #define ff first #define ss seco...
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> #include <cstring> #include <string.h> using namespace std; #define pb push_back #define all(v) v.begin(), v.end() #define rep(i, n, v) for (i = n; i < v; i++) #define per(i, n, v) for (i = n; i > v; i--) #define ff first #define ss seco...
[["-", 12, 16, 31, 16, 31, 118, 28, 118, 28, 22], ["+", 12, 16, 31, 16, 31, 118, 28, 118, 28, 22], ["-", 64, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["-", 64, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
354
#include <bits/stdc++.h> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define pb push_back #define ff first ...
#include <bits/stdc++.h> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define pb push_back #define ff first ...
[["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25]]
1
325
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long double temp; map<pair<long long, long long>, long long> n25; for (int i = 0; i < n; i++) { cin >> temp; temp *= 1000000000; long long ltemp = (long long)temp; long long n2 = 0; long long ltemptemp = lte...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long double temp; map<pair<long long, long long>, long long> n25; for (int i = 0; i < n; i++) { cin >> temp; temp *= 1000000000; long long ltemp = (long long)(temp + 0.5); // cout<<setprecision(18)<<temp<<endl; ...
[["+", 0, 43, 49, 50, 51, 74, 51, 23, 0, 24], ["+", 49, 50, 51, 74, 51, 23, 0, 16, 17, 72], ["+", 49, 50, 51, 74, 51, 23, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 74, 51, 23, 0, 25]]
1
273
#!/usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, itertools, math, time sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF(): return l...
#!/usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, itertools, math, time sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF(): return l...
[["+", 0, 1, 0, 662, 12, 634, 0, 206, 0, 70], ["+", 0, 662, 12, 634, 0, 206, 206, 663, 0, 102], ["+", 12, 634, 0, 206, 206, 663, 0, 664, 17, 33], ["+", 12, 634, 0, 206, 206, 663, 0, 664, 28, 612], ["+", 0, 1, 0, 662, 12, 634, 0, 206, 0, 73]]
5
632
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a); i <= (b); ++i) #define rrep(i, a, b) for (int i = (a); i >= (b); --i) #define PB push_back #define ar2 array<int, 2> typedef long long LL; const LL P = 998244353; const int N = 2e5 + 5; mt19937 rng(time(0)); int n, last[N][26]; string...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a); i <= (b); ++i) #define rrep(i, a, b) for (int i = (a); i >= (b); --i) #define PB push_back #define ar2 array<int, 2> typedef long long LL; const LL P = 998244353; const int N = 2e5 + 5; mt19937 rng(time(0)); int n, last[N][26]; string...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 28, 69, 28, 2, 3, 4, 0, 16, 17, 33], ["+", 28, 69, 28, 2, 3, 4, 0, 16, 12, 13], ["+", 8, 9, 0, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 9, 0, 57, 64, 9, 0, 46]]
1
506
//#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("avx2") // 293206GT #include <algorithm> #include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <stri...
//#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("avx2") // 293206GT #include <algorithm> #include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <stri...
[["+", 0, 27, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 28, 69, 341, 342, 0, 16, 12, 103, 0, 104], ["+", 28, 69, 341, 342, 0, 16, 12, 103, 0, 125]]
1
850
#include <algorithm> #include <cstdio> #include <cstring> #include <queue> #define re register using namespace std; const int Mxdt = 100000; //单次大小 inline char gc() { static char buf[Mxdt], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, Mxdt, stdin), p1 == p2) ? EOF ...
#include <algorithm> #include <cstdio> #include <cstring> #include <queue> #define re register using namespace std; const int Mxdt = 100000; //单次大小 inline char gc() { static char buf[Mxdt], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, Mxdt, stdin), p1 == p2) ? EOF ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
836
#include <algorithm> #include <cassert> #include <chrono> #include <cmath> #include <cstdio> #include <ctime> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #include <tuple> #include <utility> #include <v...
#include <algorithm> #include <cassert> #include <chrono> #include <cmath> #include <cstdio> #include <ctime> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #include <tuple> #include <utility> #include <v...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22]]
1
1,533
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() using namespace std; typedef pair<long long, long long> ii; typedef long long lint; map<ii, int> pre; int mod = 1000000007; int P = 97; int P2 = 101; long long qexp(long long b, long...
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() using namespace std; typedef pair<long long, long long> ii; typedef long long lint; map<ii, int> pre; int mod = 1000000007; int P = 97; int P2 = 101; long long qexp(long long b, long...
[["-", 0, 43, 49, 50, 51, 16, 31, 16, 12, 22], ["+", 0, 43, 49, 50, 51, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22]]
1
496
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long int LL; typedef pair<int, int> ...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long int LL; typedef pair<int, int> ...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40]]
1
1,055
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define ff(i, a, b) for (int(i) = (a); (i) <= (b); ++(i)) #define fb(i, a, b) for (int(i) = (a); (i) >= (b); --(i)) #define mod 998244353 #define xx first #define yy second #define all(a) (a).begi...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define ff(i, a, b) for (int(i) = (a); (i) <= (b); ++(i)) #define fb(i, a, b) for (int(i) = (a); (i) >= (b); --(i)) #define mod 998244353 #define xx first #define yy second #define all(a) (a).begi...
[["-", 0, 30, 0, 122, 8, 123, 0, 124, 39, 40], ["+", 0, 30, 0, 122, 8, 123, 0, 124, 39, 78], ["+", 0, 14, 8, 9, 0, 9, 0, 57, 0, 121], ["+", 8, 9, 0, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 0, 9, 0, 57, 15, 339, 51, 91, 28, 22], ["+", 8, 9, 0, 9, 0, 57, 15, 339, 0, 25]]
1
633
#include <bits/stdc++.h> using namespace std; #define MAXN 200007 int n; string a[MAXN]; struct node { int to[26]; int subtree; int en; int cnt[26]; node() { subtree = 0; for (int i = 0; i < 26; ++i) { to[i] = cnt[i] = 0; } } }; node v[7 * MAXN]; int tpsz = 1; long long ans = 0; void ...
#include <bits/stdc++.h> using namespace std; #define MAXN 200007 int n; string a[MAXN]; struct node { int to[26]; int subtree; int en; int cnt[26]; node() { subtree = 0; for (int i = 0; i < 26; ++i) { to[i] = cnt[i] = 0; } } }; node v[7 * MAXN]; int tpsz = 1; long long ans = 0; void ...
[["-", 0, 57, 64, 9, 0, 57, 75, 76, 0, 95], ["-", 64, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 64, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
555
#include <algorithm> #include <cstdio> #include <cstring> using namespace std; typedef long long ll; int n, ch[2000005][26], vis[2000005], cnt, sum[105]; char tmp[10000005], *s[1000005], *f = tmp; ll ans = 0; void ins(const char *s) { int len = strlen(s), p = 1; for (int i = len - 1; i >= 0; i--) { int c = s[i]...
#include <algorithm> #include <cstdio> #include <cstring> using namespace std; typedef long long ll; int n, ch[2000005][26], vis[2000005], cnt = 1, sum[105]; char tmp[10000005], *s[1000005], *f = tmp; ll ans = 0; void ins(const char *s) { int len = strlen(s), p = 1; for (int i = len - 1; i >= 0; i--) { int c = ...
[["+", 36, 36, 0, 30, 0, 43, 49, 50, 0, 32], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
437
#include <algorithm> #include <array> #ifdef _MSC_VER #include <intrin.h> #endif namespace atcoder { namespace internal { // @param n `0 <= n` // @return minimum non-negative `x` s.t. `n <= 2**x` int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; } // @param n `1 <= n...
#include <algorithm> #include <array> #ifdef _MSC_VER #include <intrin.h> #endif namespace atcoder { namespace internal { // @param n `0 <= n` // @return minimum non-negative `x` s.t. `n <= 2**x` int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; } // @param n `1 <= n...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78]]
1
5,330
#include <bits/stdc++.h> #include <algorithm> #include <array> #ifdef _MSC_VER #include <intrin.h> #endif namespace atcoder { namespace internal { // @param n `0 <= n` // @return minimum non-negative `x` s.t. `n <= 2**x` int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return ...
#include <bits/stdc++.h> #include <algorithm> #include <array> #ifdef _MSC_VER #include <intrin.h> #endif namespace atcoder { namespace internal { // @param n `0 <= n` // @return minimum non-negative `x` s.t. `n <= 2**x` int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return ...
[["-", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
6,009
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; const int Maxd = 19; const int mult = 1000000000; int has[Maxd][Maxd]; ll res; int main() { std::ios_base::sync_with_stdio(0); int n; cin >> n; for (int i = 0; i < n; i++) { ld num; cin >> num; ll got = l...
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; const int Maxd = 19; const int mult = 1000000000; int has[Maxd][Maxd]; ll res; int main() { std::ios_base::sync_with_stdio(0); int n; cin >> n; for (int i = 0; i < n; i++) { ld num; cin >> num; ll got = l...
[["-", 8, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 8, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
241
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pp; typedef tree<pp, null_type, less<pp>, rb_tree_tag, tree_order_statistics_node_updat...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pp; typedef tree<pp, null_type, less<pp>, rb_tree_tag, tree_order_statistics_node_updat...
[["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 13], ["+", 0, 338, 8, 57, 15, 339, 51, 16, 17, 79], ["+", 0, 338, 8, 57, 15, 339, 51, 16, 12, 13]]
1
592
// This code wrote by chtholly_micromaker(MicroMaker) #pragma GCC optimize(3, "Ofast", "inline") #pragma GCC target("avx,avx2") #include <bits/stdc++.h> #define reg register #define ALL(x) (x).begin(), (x).end() #define mem(x, y) memset(x, y, sizeof x) #define sz(x) (int)(x).size() #define ln puts("") #define lsp putch...
// This code wrote by chtholly_micromaker(MicroMaker) #pragma GCC optimize(3, "Ofast", "inline") #pragma GCC target("avx,avx2") #include <bits/stdc++.h> #define reg register #define ALL(x) (x).begin(), (x).end() #define mem(x, y) memset(x, y, sizeof x) #define sz(x) (int)(x).size() #define ln puts("") #define lsp putch...
[["+", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 79], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 17, 98]]
1
807