buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
N = int(input()) X = list(map(int, list(input()))) X.reverse() def int2bit(n): ret = [0 for i in range(18)] cnt = 0 i = 0 while n > 0: ret[i] = n % 2 cnt += n % 2 n = n // 2 i += 1 return (ret, cnt) def func(bit, popcount): ret = 0 base = 1 for b in bit: ret = (ret + base*b) % popcount base = (base...
N = int(input()) X = list(map(int, list(input()))) X.reverse() def int2bit(n): ret = [0 for i in range(18)] cnt = 0 i = 0 while n > 0: ret[i] = n % 2 cnt += n % 2 n = n // 2 i += 1 return (ret, cnt) def func(bit, popcount): ret = 0 base = 1 for b in bit: ret = (ret + base*b) % popcount base = (base...
[["-", 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
374
#include <bits/stdc++.h> #include <iostream> using namespace std; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; /*---------------------DEBUGGING--------------------------------------------*/ void __print(int x) { cerr << x; } void __print(long x) { cerr...
#include <bits/stdc++.h> #include <iostream> using namespace std; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; /*---------------------DEBUGGING--------------------------------------------*/ void __print(int x) { cerr << x; } void __print(long x) { cerr...
[["+", 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, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
978
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define PI 3.14159265359 using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define bit(n, k) (((ll)n >> (ll)k) & 1) /*nのk bit目*/ #define pb push_back #define eb emplace_back #define SZ(x) ((ll)(x).size()) #define all(x) (x).begin(), (x).end() #def...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define PI 3.14159265359 using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define bit(n, k) (((ll)n >> (ll)k) & 1) /*nのk bit目*/ #define pb push_back #define eb emplace_back #define SZ(x) ((ll)(x).size()) #define all(x) (x).begin(), (x).end() #def...
[["+", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 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], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25]]
1
918
import java.io.*; import java.util.*; public class Main { private void solve() throws Exception { int n = nextInt(); int bit[] = new int[n + 1]; String s = nextLine(); int cnt = 0; for (int i = 1; i <= n; i++) { bit[i] = s.charAt(i - 1) - '0'; if (bit[i] == 1) cnt++; } ...
import java.io.*; import java.util.*; public class Main { private void solve() throws Exception { int n = nextInt(); int bit[] = new int[n + 1]; String s = nextLine(); int cnt = 0; for (int i = 1; i <= n; i++) { bit[i] = s.charAt(i - 1) - '0'; if (bit[i] == 1) cnt++; } ...
[["+", 64, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 64, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
3
634
#include <bits/stdc++.h> using namespace std; #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chma...
#include <bits/stdc++.h> using namespace std; #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chma...
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13]]
1
596
#define _CRT_SECURE_NO_WARNINGS #include <ctype.h> #include <inttypes.h> #include <limits.h> #include <math.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <wchar.h> #define N_MAX (100) #define P_MAX (100) #define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1) ...
#define _CRT_SECURE_NO_WARNINGS #include <ctype.h> #include <inttypes.h> #include <limits.h> #include <math.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <wchar.h> #define N_MAX (100) #define P_MAX (100) #define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1) ...
[["-", 64, 9, 0, 57, 15, 23, 0, 16, 31, 13], ["+", 64, 9, 0, 57, 15, 23, 0, 16, 31, 13]]
0
3,584
def main(): import sys N=int(sys.stdin.readline()) X=sys.stdin.readline() no=X.count('1') np=no+1 nm=no-1 nm_flag=bool(nm) np_mods=[-1]*N nm_mods=[-1]*N np_mods[0]=1 nm_mods[0]=1 for i in range(1,N): np_mods[i]=(np_mods[i-1]*2)%np if nm_flag: ...
def main(): import sys N=int(sys.stdin.readline()) X=sys.stdin.readline() no=X.count('1') np=no+1 nm=no-1 nm_flag=bool(nm) np_mods=[-1]*N nm_mods=[-1]*N np_mods[0]=1 nm_mods[0]=1 for i in range(1,N): np_mods[i]=(np_mods[i-1]*2)%np if nm_flag: ...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
289
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; #define sync \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define input(arr, n) ...
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; #define sync \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define input(arr, n) ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 132], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
520
n = int(input()) x = list(input()) c1 = x.count("1")+1 c2 = c1-2 now1 = 0 now2 = 0 for i in range(n): if x[-1-i] == "1": now1 += pow(2,i,c1) if c2 != 0: now2 += pow(2,i,c2) now1 %= c1 if c2 != 0: now2 %= c2 for i in range(n): if x[i] == "1": #print...
n = int(input()) x = list(input()) c1 = x.count("1")+1 c2 = c1-2 now1 = 0 now2 = 0 for i in range(n): if x[-1-i] == "1": now1 += pow(2,i,c1) if c2 != 0: now2 += pow(2,i,c2) now1 %= c1 if c2 != 0: now2 %= c2 for i in range(n): if x[i] == "1": #print...
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
238
#include <bits/stdc++.h> #define itn int #define REP(i, n) for (ll i = 0; i < n; i++) #define IREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < b + 1; i++) #define all(v) v.begin(), v.end() #define SENTINEL 2000000000 #define NIL -1 using namespace std; typedef long long ll; const ll M...
#include <bits/stdc++.h> #define itn int #define REP(i, n) for (ll i = 0; i < n; i++) #define IREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < b + 1; i++) #define all(v) v.begin(), v.end() #define SENTINEL 2000000000 #define NIL -1 using namespace std; typedef long long ll; const ll M...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
579
def popcnt1(n): return bin(n).count("1") def okikae(n): kaisu = 0 if n == 0: return 0 while 1: P = popcnt1(n) n %= P kaisu += 1 if n == 0: return kaisu OKI = [okikae(i) for i in range(200001)] X = int(input()) Norig = input() N = int(Norig,2) Npop = ...
def popcnt1(n): return bin(n).count("1") def okikae(n): kaisu = 0 if n == 0: return 0 while 1: P = popcnt1(n) n %= P kaisu += 1 if n == 0: return kaisu OKI = [okikae(i) for i in range(200001)] X = int(input()) Norig = input() N = int(Norig,2) Npop = ...
[["-", 3, 4, 0, 657, 12, 206, 206, 657, 12, 22], ["+", 3, 4, 0, 657, 12, 206, 206, 657, 12, 22]]
5
316
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n = int(input()) a = input() d = {} def sub(val): if val in d: return d[val] pc = 0 for i in range(val.bit_length()): if val>>i&1: pc += ...
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n = int(input()) a = input() d = {} def sub(val): if val in d: return d[val] pc = 0 for i in range(val.bit_length()): if val>>i&1: pc += ...
[["+", 64, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]]
5
355
#include <bits/stdc++.h> using namespace std; long modpow(long a, long b, long mod) { long res = 1; while (b > 0) { if (b & 1) res = res * a % mod; a = a * a % mod; b /= 2; } return res; } int main() { int n; string s; cin >> n >> s; int one = 0; for (int i = 0; i < n; i++) if (s...
#include <bits/stdc++.h> using namespace std; long modpow(long a, long b, long mod) { long res = 1; while (b > 0) { if (b & 1) res = res * a % mod; a = a * a % mod; b /= 2; } return res; } int main() { int n; string s; cin >> n >> s; int one = 0; for (int i = 0; i < n; i++) if (s...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
462
#include <bits/stdc++.h> using namespace std; #define mx 200005 #define ll long long char ch[mx]; ll besi[mx], kom[mx]; ll csum[mx], csum1[mx]; int n, m, k, ii; ll mod; ll bigmod(ll e, ll x) { if (!x) return 1; ll p = bigmod(e, x / 2); p = (p * p) % mod; if (x % 2) p = (p * e) % mod; return p; } v...
#include <bits/stdc++.h> using namespace std; #define mx 200005 #define ll long long char ch[mx]; ll besi[mx], kom[mx]; ll csum[mx], csum1[mx]; int n, m, k, ii; ll mod; ll bigmod(ll e, ll x) { if (!x) return 1; ll p = bigmod(e, x / 2); p = (p * p) % mod; if (x % 2) p = (p * e) % mod; return p; } v...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
543
#include <bits/stdc++.h> #define int long long #define p pair<int, int> #define endl '\n' const int INF = 1000000001; using namespace std; int popcount(int n) { int q1 = 0; while (n > 0) { q1 += n % 2; n /= 2; } return q1; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.ti...
#include <bits/stdc++.h> #define int long long #define p pair<int, int> #define endl '\n' const int INF = 1000000001; using namespace std; int popcount(int n) { int q1 = 0; while (n > 0) { q1 += n % 2; n /= 2; } return q1; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.ti...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
540
#include <bits/stdc++.h> using namespace std; long long mpow(long long x, long long y, long long mod) { if (y == 0) return 1; long long ret = mpow(x, y / 2, mod); ret *= ret; ret %= mod; if (y % 2 == 1) ret *= x; ret %= mod; return ret; } int main() { long long N; string X; cin >> N >> X; ...
#include <bits/stdc++.h> using namespace std; long long mpow(long long x, long long y, long long mod) { if (y == 0) return 1; long long ret = mpow(x, y / 2, mod); ret *= ret; ret %= mod; if (y % 2 == 1) ret *= x; ret %= mod; return ret; } int main() { long long N; string X; cin >> N >> X; ...
[["-", 0, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["-", 0, 9, 0, 57, 64, 9, 0, 37, 0, 13], ["+", 0, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
1
419
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long ll gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; } //最大公約数 ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数 using Graph = vector<vector<int>>; ll inf = 300000000000000000...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long ll gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; } //最大公約数 ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数 using Graph = vector<vector<int>>; ll inf = 300000000000000000...
[["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 13], ["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35]]
1
557
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; typedef vector<ll> vll; typedef vector<ld> vld; typedef vector<pll> vpl; typedef vector<vll> vvll; #define ALL(a) a.begin(), a.end() #define SZ(a)...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; typedef vector<ll> vll; typedef vector<ld> vld; typedef vector<pll> vpl; typedef vector<vll> vvll; #define ALL(a) a.begin(), a.end() #define SZ(a)...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
624
def rem(n, a): if a == 0: return 0 ans=0 for i in n: ans*=2 ans+=i ans%=a return ans def popcnt(n): c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555) c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333) c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4)...
def rem(n, a): if a == 0: return 0 ans=0 for i in n: ans*=2 ans+=i ans%=a return ans def popcnt(n): c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555) c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333) c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4)...
[["-", 12, 657, 31, 23, 0, 657, 12, 206, 51, 22], ["+", 12, 657, 31, 23, 0, 657, 12, 206, 51, 22]]
5
371
import math #import numpy as np import itertools import queue import bisect from collections import deque,defaultdict import heapq as hpq from sys import stdin,setrecursionlimit #from scipy.sparse.csgraph import dijkstra #from scipy.sparse import csr_matrix ipt = stdin.readline setrecursionlimit(10**7) def popcorn(i,k...
import math #import numpy as np import itertools import queue import bisect from collections import deque,defaultdict import heapq as hpq from sys import stdin,setrecursionlimit #from scipy.sparse.csgraph import dijkstra #from scipy.sparse import csr_matrix ipt = stdin.readline setrecursionlimit(10**7) def popcorn(i,k...
[["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
341
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } char s[200200]; ll ans[200200]; int qp(ll a, ll b, ll md) { ll ret = 1; a = a % md; while (b) { if (b & 1) ret = ret * a % md; a = a * a % md; b >>= 1; } return ret; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } char s[200200]; ll ans[200200]; int qp(ll a, ll b, ll md) { ll ret = 1; a = a % md; while (b) { if (b & 1) ret = ret * a % md; a = a * a % md; b >>= 1; } return ret; ...
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13]]
1
574
#include <bits/stdc++.h> using namespace std; typedef long long ll; constexpr int Inf = 1000000010; constexpr ll INF = 1000000000000000000; constexpr ll MOD = 1000000007; const double PI = 3.1415926535897; typedef pair<int, int> P; template <typename T> T Pow(T a, T b) { T ret = 1; for (int i = 0; i < b; i++) { ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; constexpr int Inf = 1000000010; constexpr ll INF = 1000000000000000000; constexpr ll MOD = 1000000007; const double PI = 3.1415926535897; typedef pair<int, int> P; template <typename T> T Pow(T a, T b) { T ret = 1; for (int i = 0; i < b; i++) { ...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 156], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
783
#include <bits/stdc++.h> using namespace std; long long N; string Xstr; long long ups[200005]; long long downs[200005]; long long modpow(long long ori, long long po, long long div) { long long res = 1; while (po > 0) { if (po & 1) { res *= ori; res %= div; } ori *= ori; ori %= div; ...
#include <bits/stdc++.h> using namespace std; long long N; string Xstr; long long ups[200005]; long long downs[200005]; long long modpow(long long ori, long long po, long long div) { long long res = 1; while (po > 0) { if (po & 1) { res *= ori; res %= div; } ori *= ori; ori %= div; ...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
544
#import sys #input = sys.stdin.readline from collections import Counter def func(x): cnt = 0 y = x while x > 0: if x%2 == 1: cnt += 1 x //= 2 return y%cnt def main(): N = int( input()) X = list( map( int, list( input()))) base_plus = 0 base_minus = 0 ...
#import sys #input = sys.stdin.readline from collections import Counter def func(x): cnt = 0 y = x while x > 0: if x%2 == 1: cnt += 1 x //= 2 return y%cnt def main(): N = int( input()) X = list( map( int, list( input()))) base_plus = 0 base_minus = 0 ...
[["+", 0, 656, 0, 14, 8, 196, 0, 57, 0, 121], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 656, 0, 14, 8, 196, 0, 57, 0, 102]]
5
311
package main import ( "bufio" "os" "strconv" "strings" "fmt" ) func Solve() { var N int NextInt(&N) X := make([]int, N) cnt := 0 for i, s := range NextLine() { if s == '1' { X[i]++; cnt++ } } B := make([][]int, N) for i := range B { B[i] = make([]int, 2) } B[0] = []int{1, 1} for i := ...
package main import ( "bufio" "os" "strconv" "strings" "fmt" ) func Solve() { var N int NextInt(&N) X := make([]int, N) cnt := 0 for i, s := range NextLine() { if s == '1' { X[i]++; cnt++ } } B := make([][]int, N) for i := range B { B[i] = make([]int, 2) } B[0] = []int{1, 1} for i := ...
[["-", 75, 196, 0, 1, 0, 2, 3, 4, 0, 433], ["+", 75, 196, 0, 1, 0, 2, 3, 4, 0, 433]]
7
1,054
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define For(i, n, k) for (int i = (n); i < (k); i++) #define ALL(a) (a).begin(), (a).end() ll ans = 0; void Main() { int n; string s; cin >> n >> s; vector<int> vec(n), ans(n, 1); int t = count(ALL(s), '1'); if (t == 0) { For(i, 0, n) {...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define For(i, n, k) for (int i = (n); i < (k); i++) #define ALL(a) (a).begin(), (a).end() ll ans = 0; void Main() { int n; string s; cin >> n >> s; vector<int> vec(n), ans(n, 1); int t = count(ALL(s), '1'); if (t == 0) { For(i, 0, n) {...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
471
import math mod = 1000000007 dp = [0, 1] num = [0, 1] for i in range(2, 200000): if i % 2 == 0: num.append(num[i//2]) else: num.append(num[i//2]+1) dp.append(dp[i % num[i]]+1) N = int(input()) x = input() ones = 0 for c in x: if c == '1': ones += 1 powlow = [1] powhigh = [1] mod...
import math mod = 1000000007 dp = [0, 1] num = [0, 1] for i in range(2, 200000): if i % 2 == 0: num.append(num[i//2]) else: num.append(num[i//2]+1) dp.append(dp[i % num[i]]+1) N = int(input()) x = input() ones = 0 for c in x: if c == '1': ones += 1 powlow = [1] powhigh = [1] mod...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
324
package main import ( "fmt" ) func main() { var n int fmt.Scan(&n) var x []byte fmt.Scan(&x) var cnt int for i := range x { if x[i] == '1' { cnt++ } } ms := make([]int, 0) ms = append(ms, cnt+1) if cnt > 1 { ms = append(ms, cnt-1) } as := make([][]int, n) for i := range as { as[i] = make([]i...
package main import ( "fmt" ) func main() { var n int fmt.Scan(&n) var x []byte fmt.Scan(&x) var cnt int for i := range x { if x[i] == '1' { cnt++ } } ms := make([]int, 0) ms = append(ms, cnt+1) if cnt > 1 { ms = append(ms, cnt-1) } as := make([][]int, n) for i := range as { as[i] = make([]i...
[["-", 0, 57, 64, 196, 0, 57, 15, 16, 12, 433], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 433]]
7
574
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll, ll> p2; #define sz(a) ll(a.size()) ll a[200005], p[200005][2]; void solve() { ll n, sum = 0, val1 = 0, val2 = 0; string s; cin >> n >> s; for (ll i = 0; i < n; i++) if (s[i] == '1') sum++; ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll, ll> p2; #define sz(a) ll(a.size()) ll a[200005], p[200005][2]; void solve() { ll n, sum = 0, val1 = 0, val2 = 0; string s; cin >> n >> s; for (ll i = 0; i < n; i++) if (s[i] == '1') sum++; ...
[["-", 0, 57, 64, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 17, 33]]
1
542
#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++) ...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 355], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
1,370
#include <bits/stdc++.h> using namespace std; int a[210000], n, sum, f[210000], b1[210000], b2[210000], ans[210000], s1, s2; int getach() { char ch = getchar(); while (ch != '0' && ch != '1') ch = getchar(); return ch - '0'; } int work(int x) { int temp = x, sum = 0; while (temp) { if (temp & 1) ...
#include <bits/stdc++.h> using namespace std; int a[210000], n, sum, f[210000], b1[210000], b2[210000], ans[210000], s1, s2; int getach() { char ch = getchar(); while (ch != '0' && ch != '1') ch = getchar(); return ch - '0'; } int work(int x) { int temp = x, sum = 0; while (temp) { if (temp & 1) ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
503
#pragma region head #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define mp make_pair #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; ...
#pragma region head #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define mp make_pair #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; ...
[["+", 0, 57, 64, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 51, 13]]
1
824
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
744
END { load __FILE__ unless $stdin.eof? } n = gets.to_i x = gets.chomp.chars.map!(&:to_i) c = x.count(1) c0 = c + 1 m0 = x.inject(0) { |result, bit| (result * 2 + bit) % c0 } c1 = c - 1 m1 = x.inject(0) { |result, bit| (result * 2 + bit) % c1 } if c1 > 0 y0 = 1 y1 = 1 x = x.reverse!.map! do |xi| xi = ( if xi ==...
END { load __FILE__ unless $stdin.eof? } n = gets.to_i x = gets.chomp.chars.map!(&:to_i) c = x.count(1) c0 = c + 1 m0 = x.inject(0) { |result, bit| (result * 2 + bit) % c0 } c1 = c - 1 m1 = x.inject(0) { |result, bit| (result * 2 + bit) % c1 } if c1 > 0 y0 = 1 y1 = 1 x = x.reverse!.map! do |xi| xi = ( if xi ==...
[["+", 486, 652, 196, 737, 8, 736, 0, 751, 0, 121], ["+", 196, 737, 8, 736, 0, 751, 15, 738, 31, 22], ["+", 196, 737, 8, 736, 0, 751, 15, 738, 17, 47], ["+", 196, 737, 8, 736, 0, 751, 15, 738, 12, 612]]
4
213
#include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define all(v) (v).begin(), (v).end() #define sz(v) (int)((v).size()) #define fs first #define sd second typedef long long ll; typedef pair<int, int> pi; typedef pair<pi, int> ppi; typedef vector<int> vi; typedef vector<vecto...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define all(v) (v).begin(), (v).end() #define sz(v) (int)((v).size()) #define fs first #define sd second typedef long long ll; typedef pair<int, int> pi; typedef pair<pi, int> ppi; typedef vector<int> vi; typedef vector<vecto...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
786
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> int main() { int N; std::string X; std::cin >> N >> X; const int popcount = std::count(X.begin(), X.end(), '1'); std::map<int, int> x_map; std::vector<std::map<int, int>> digit_map(N); for (int mod = std::max(1, p...
#include <algorithm> #include <iostream> #include <map> #include <string> #include <vector> int main() { int N; std::string X; std::cin >> N >> X; const int popcount = std::count(X.begin(), X.end(), '1'); std::map<int, int> x_map; std::vector<std::map<int, int>> digit_map(N); for (int mod = std::max(1, p...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
338
import sys sys.setrecursionlimit(10 ** 8) def Z(): return int(input()) def ZZ(): return [int(_) for _ in input().split()] def main(): N = Z() X = input() pcnt = 0 ans = [] for x in X: if x == '1': pcnt += 1 if pcnt == 0: for _ in range(N): print(0) retur...
import sys sys.setrecursionlimit(10 ** 8) def Z(): return int(input()) def ZZ(): return [int(_) for _ in input().split()] def main(): N = Z() X = input() pcnt = 0 ans = [] for x in X: if x == '1': pcnt += 1 if pcnt == 0: for _ in range(N): print(1) retur...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612]]
5
373
N = int(input()) X = input() def popcount(n): return bin(n).count('1') def process(n): return n % popcount(n) def func(n): ret = 0 while n > 0: n = process(n) ret += 1 return ret pcnt = X.count('1') mods_plus = [] totalmod_plus = 0 tmp_plus = 1 pp = pcnt+1 mods_minus = [] totalmo...
N = int(input()) X = input() def popcount(n): return bin(n).count('1') def process(n): return n % popcount(n) def func(n): ret = 0 while n > 0: n = process(n) ret += 1 return ret pcnt = X.count('1') mods_plus = [] totalmod_plus = 0 tmp_plus = 1 pp = pcnt+1 mods_minus = [] totalmo...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612]]
5
253
#include <bits/stdc++.h> using namespace std; int n; string s; const int N = 2e5 + 5; int ans[N], fd[N], fx[N]; int poww(int a, int b, int c) { int ans = 1, base = a; while (b) { if (b & 1) ans = 1ll * ans * base % c; base = 1ll * base * base % c; b >>= 1; } return ans; } int get(int x) { if...
#include <bits/stdc++.h> using namespace std; int n; string s; const int N = 2e5 + 5; int ans[N], fd[N], fx[N]; int poww(int a, int b, int c) { int ans = 1, base = a; while (b) { if (b & 1) ans = 1ll * ans * base % c; base = 1ll * base * base % c; b >>= 1; } return ans; } int get(int x) { if...
[["-", 0, 7, 8, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 57, 64, 1, 0, 11, 12, 13]]
1
503
#include <bits/stdc++.h> using namespace std; typedef long long ll; char str[300010]; ll mod1[300010], mod2[300010]; // c+1, c-1 ll popcount(ll num) { ll ret = 0; while (num) { ret += num & 1; num >>= 1; } return ret; } int main() { int n, c = 0; scanf("%d", &n); scanf("%s", str); for (int i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; char str[300010]; ll mod1[300010], mod2[300010]; // c+1, c-1 ll popcount(ll num) { ll ret = 0; while (num) { ret += num & 1; num >>= 1; } return ret; } int main() { int n, c = 0; scanf("%d", &n); scanf("%s", str); for (int i...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]]
1
499
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, a, b) for (int i = a; i <= b; ++i) #define filei freopen("input.txt", "r", stdin); #define fileo freopen("output.txt", "w", stdout); #d...
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, a, b) for (int i = a; i <= b; ++i) #define filei freopen("input.txt", "r", stdin); #define fileo freopen("output.txt", "w", stdout); #d...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
595
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; (i) < (n); i++) ...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; (i) < (n); i++) ...
[["-", 0, 57, 75, 76, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 91, 17, 92]]
1
805
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int maxn = 1e6 + 23; int qpow(int a, int b, int mod) { if (mod <= 0) return 0; ll ans = 1; while (b) { if (b & 1) ans = 1ll * ans * a % mod; b >>= 1; a = 1ll * a * a % mod; } return ans...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int maxn = 1e6 + 23; int qpow(int a, int b, int mod) { if (mod <= 0) return 0; ll ans = 1; while (b) { if (b & 1) ans = 1ll * ans * a % mod; b >>= 1; a = 1ll * a * a % mod; } return ans...
[["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
511
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <vector> #define F first #define S second #define all(a) a.begin(), a.end() #define setDP(arr) memset(arr, -1, sizeof arr) #define ...
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <vector> #define F first #define S second #define all(a) a.begin(), a.end() #define setDP(arr) memset(arr, -1, sizeof arr) #define ...
[["+", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 33], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25]]
1
587
#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(v) begin(v), end(v) #define fi first #define se second template <typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; } ...
#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(v) begin(v), end(v) #define fi first #define se second template <typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; } ...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72]]
1
560
#include <bits/stdc++.h> #define st first #define nd second using ll = long long; using namespace std; using pii = pair<int, int>; const int N = 2e5 + 10; char s[N]; int val[2][N], sum[2]; int add(int a, int b, int mod) { a += b; a %= mod; if (a < 0) a += mod; return a; } int pop_cnt(int num, int mod) { ...
#include <bits/stdc++.h> #define st first #define nd second using ll = long long; using namespace std; using pii = pair<int, int>; const int N = 2e5 + 10; char s[N]; int val[2][N], sum[2]; int add(int a, int b, int mod) { a += b; a %= mod; if (a < 0) a += mod; return a; } int pop_cnt(int num, int mod) { ...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13]]
1
577
#include <bits/stdc++.h> using namespace std; using UL = unsigned int; using ULL = unsigned long long; using LL = long long; #define rep(i, n) for (UL i = 0; i < (n); i++) UL N; UL P; char X[200001]; UL M[200001]; UL D[200001]; UL ans[200000]; UL B; UL popcount(UL x) { x = (x & 0x55555555) + ((x >> 1) & 0x55555555)...
#include <bits/stdc++.h> using namespace std; using UL = unsigned int; using ULL = unsigned long long; using LL = long long; #define rep(i, n) for (UL i = 0; i < (n); i++) UL N; UL P; char X[200001]; UL M[200001]; UL D[200001]; UL ans[200000] = {}; UL B; UL popcount(UL x) { x = (x & 0x55555555) + ((x >> 1) & 0x5555...
[["+", 36, 36, 0, 30, 0, 43, 49, 50, 0, 32], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 46], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
516
#pragma GCC optimize("Ofast") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, // tree_order_statistics...
#pragma GCC optimize("Ofast") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, // tree_order_statistics...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["-", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
1,068
//#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using db = double; using ld = long double; template <typename T> usin...
//#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using db = double; using ld = long double; template <typename T> usin...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
874
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define mod 1000000007 #include <string.h> #define inf 1000000000000000000 typedef pair<ll, ll> pll; typedef pair<int, int> pint; #define PI 3.14159265359 #define endl '\n' #define mapint_iterator map<int, int>::iterator #define mapll_iterator map<...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define mod 1000000007 #include <string.h> #define inf 1000000000000000000 typedef pair<ll, ll> pll; typedef pair<int, int> pint; #define PI 3.14159265359 #define endl '\n' #define mapint_iterator map<int, int>::iterator #define mapll_iterator map<...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, ...
1
1,919
#include <stdio.h> #include <stdlib.h> #include <fstream> #include <iomanip> #include <iostream> #include <sstream> #include <stdint.h> #include <string.h> #define _USE_MATH_DEFINES #include <math.h> #include <deque> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #i...
#include <stdio.h> #include <stdlib.h> #include <fstream> #include <iomanip> #include <iostream> #include <sstream> #include <stdint.h> #include <string.h> #define _USE_MATH_DEFINES #include <math.h> #include <deque> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #i...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
805
#include <bits/stdc++.h> #define maxn 202333 using namespace std; char str[maxn]; int a[maxn]; int ans[maxn]; int calc(int digit) { if (!digit) return 0; else return 1 + calc(digit % __builtin_popcount(digit)); } long long powmod(long long x, long long p, long long mod) { long long ret = 1; for (; p; ...
#include <bits/stdc++.h> #define maxn 202333 using namespace std; char str[maxn]; int a[maxn]; int ans[maxn]; int calc(int digit) { if (!digit) return 0; else return 1 + calc(digit % __builtin_popcount(digit)); } long long powmod(long long x, long long p, long long mod) { long long ret = 1; for (; p; ...
[["-", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13]]
1
438
#define INF 10000000000 #define MOD 1000000007 #if 1 // use_templates #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <st...
#define INF 10000000000 #define MOD 1000000007 #if 1 // use_templates #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <st...
[["-", 0, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 31, 22]]
1
568
import sys readline = sys.stdin.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prn = lambda x: print(*x, sep='\n') def popcount(x): x = x - ((x >> 1) & 0x55555555) ...
import sys readline = sys.stdin.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prn = lambda x: print(*x, sep='\n') def popcount(x): x = x - ((x >> 1) & 0x55555555) ...
[["+", 8, 196, 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, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
386
#include <bits/stdc++.h> #define ll long long #define eb emplace_back #define fi first #define se second using namespace std; const int nm = 200002; int n; string s; ll powmod[nm][2]; ll f(ll n) { if (!n) { return 0; } return f(n % __builtin_popcount(n)) + 1; } int main() { #ifdef LOCAL freopen("input...
#include <bits/stdc++.h> #define ll long long #define eb emplace_back #define fi first #define se second using namespace std; const int nm = 200002; int n; string s; ll powmod[nm][2]; ll f(ll n) { if (!n) { return 0; } return f(n % __builtin_popcount(n)) + 1; } int main() { #ifdef LOCAL freopen("input...
[["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
563
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define FORR(i, m, n) for (ll i = m; i >= n; i--) #define REPO(i, n) for (ll i = 1; i <= n; i++) #define ll long long #define INF (ll...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define FORR(i, m, n) for (ll i = m; i >= n; i--) #define REPO(i, n) for (ll i = 1; i <= n; i++) #define ll long long #define INF (ll...
[["+", 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
483
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using ld = long double; template <typename T> int sz(T &x) { return (int)(x.size()); } const int inf = 1'000'000'007; int calc(int x) { return x == 0 ? 0 : calc(x % __builtin_popcount(x)) + 1; } void solve() { int n;...
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using ld = long double; template <typename T> int sz(T &x) { return (int)(x.size()); } const int inf = 1'000'000'007; int calc(int x) { return x == 0 ? 0 : calc(x % __builtin_popcount(x)) + 1; } void solve() { int n;...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
676
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> dp(n + 1); for (int i = 1; i <= n; i++) { int cnt = 0; for (int j = 0; j < 20; j++) if (i & (1 << j)) cnt++; dp[i] = dp[i % cnt] + 1; } int modulo = 0; vect...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> dp(n + 1); for (int i = 1; i <= n; i++) { int cnt = 0; for (int j = 0; j < 20; j++) if (i & (1 << j)) cnt++; dp[i] = dp[i % cnt] + 1; } int modulo = 0; vect...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
490
#include "bits/stdc++.h" using namespace std; #define int long long #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define all(x) (x).begin(), (x).end() #define uniq(v) (v).erase(unique(all(v)), (v).end()) #define sz(x) (int)((x).size()) #define fr first #define sc second #define ...
#include "bits/stdc++.h" using namespace std; #define int long long #define pb push_back #define ppb pop_back #define pf push_front #define ppf pop_front #define all(x) (x).begin(), (x).end() #define uniq(v) (v).erase(unique(all(v)), (v).end()) #define sz(x) (int)((x).size()) #define fr first #define sc second #define ...
[["+", 64, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 64, 9, 0, 57, 64, 9, 0, 116, 0, 35]]
1
692
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(input()) X = input().rstrip('\n') M = X.count("1") flg = 0 if M == 1: flg = 1 x_major = 0 x_minor = 0 for i in range(N): add = int(X[i]) x_major = (x_major * 2 + ad...
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(input()) X = input().rstrip('\n') M = X.count("1") flg = 0 if M == 1: flg = 1 x_major = 0 x_minor = 0 for i in range(N): add = int(X[i]) x_major = (x_major * 2 + ad...
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
240
#include <iostream> using namespace std; int N; int memo[2 << 17]; string X; int d[2]; int pw[2][2 << 17]; main() { cin >> N >> X; for (int i = 1; i < 2 << 17; i++) { memo[i] = memo[i % __builtin_popcount(i)] + 1; } int pc = 0; for (int i = 0; i < N; i++) pc += X[i] == '1'; for (int i = 0; i < 2; i+...
#include <iostream> using namespace std; int N; int memo[2 << 17]; string X; int d[2]; int pw[2][2 << 17]; main() { cin >> N >> X; for (int i = 1; i < 2 << 17; i++) { memo[i] = memo[i % __builtin_popcount(i)] + 1; } int pc = 0; for (int i = 0; i < N; i++) pc += X[i] == '1'; for (int i = 0; i < 2; i+...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 16, 12, 69, 28, 69, 341, 342, 0, 13], ["+", 0, 16, 12, 69, 28, 69, 341, 342, 0, 13]]
1
370
#include "bits/stdc++.h" using namespace std; // Inserted snippets: io, root #define rep(i, a, b) for (int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; template <typename H> bool chmin(H &v1, const H v2) { ...
#include "bits/stdc++.h" using namespace std; // Inserted snippets: io, root #define rep(i, a, b) for (int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; template <typename H> bool chmin(H &v1, const H v2) { ...
[["+", 0, 14, 8, 9, 0, 7, 8, 57, 0, 121], ["+", 8, 9, 0, 7, 8, 57, 15, 339, 0, 24], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 7, 8, 57, 15, 339, 0, 25]]
1
619
#include "algorithm" #include "bitset" #include "cassert" #include "climits" #include "cmath" #include "cstdio" #include "ctime" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "numeric" #include "queue" #include "random" #include "set" #include "stack" #include "str...
#include "algorithm" #include "bitset" #include "cassert" #include "climits" #include "cmath" #include "cstdio" #include "ctime" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "numeric" #include "queue" #include "random" #include "set" #include "stack" #include "str...
[["-", 341, 342, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 341, 342, 0, 16, 31, 23, 0, 16, 17, 33]]
1
596
#include "bits/stdc++.h" using namespace std; long long Calc(long long P) { if (P == 0) return 0; long long COUNT = 0; long long Q = P; while (Q > 0) { COUNT += Q % 2; Q /= 2; } return Calc(P % COUNT) + 1; } long long Pow(long long A, long long B, long long M) { if (B == 0) return 1 % M;...
#include "bits/stdc++.h" using namespace std; long long Calc(long long P) { if (P == 0) return 0; long long COUNT = 0; long long Q = P; while (Q > 0) { COUNT += Q % 2; Q /= 2; } return Calc(P % COUNT) + 1; } long long Pow(long long A, long long B, long long M) { if (B == 0) return 1 % M;...
[["+", 75, 76, 0, 9, 0, 57, 75, 76, 0, 95], ["+", 0, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 0, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
414
from heapq import* i=input for s in[0]*int(i()): n,x,*y=int(i()),[] for _ in'_'*n:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r) for x in x,y: x.sort();n=len(x);h=[(0,0)]*n while h: while[[n]]<x[-1:]:k,l,r=x.pop();heappush(h,(r-l,l,r)) s+=heappop(h)[~(n>0)];n-=1 print(s)
from heapq import* i=input for s in[0]*int(i()): n,x,*y=int(i()),[] for _ in'_'*n:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r) for x in x,y: x.sort();n=len(x);h=[(0,0)]*n*2 while h: while[[n]]<x[-1:]:k,l,r=x.pop();heappush(h,(r-l,l,r)) s+=heappop(h)[~(n>0)];n-=1 print(s)
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 48], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612]]
5
197
#################### #################### #################### #################### from heapq import* i=input for s in[0]*int(i()): n,x,*y=int(i()),[] for _ in'_'*n: k,l,r=map(int,i().split()) if l>=r:x+=[[k,l,r]] else:y+=[[n-k,r,l]] for x in x,y: x.sort();h=[] for k,l,r in x: if k:s+=l;heappush(h,l-r)...
#################### #################### #################### #################### from heapq import* i=input for s in[0]*int(i()): n,x,*y=int(i()),[] for _ in'_'*n: k,l,r=map(int,i().split()) if l>=r:x+=[[k,l,r]] else:y+=[[n-k,r,l]] for x in x,y: x.sort();h=[] for k,l,r in x: if k:s+=l;heappush(h,l-r)...
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 110]]
5
163
#################### #################### #################### #################### from heapq import* i=input for s in[0]*int(i()): n,x,*y=int(i()),[] for _ in'_'*n: k,l,r=map(int,i().split()) if l>=r:s+=r;x+=[[n,r-l]] else:s+=l;y+=[[n-k,l-r]]*(k<n) for x in x,y: x.sort();h=[] for k,d in x: heappush(h,...
#################### #################### #################### #################### from heapq import* i=input for s in[0]*int(i()): n,x,*y=int(i()),[] for _ in'_'*n: k,l,r=map(int,i().split()) if l>=r:s+=r;x+=[[k,r-l]] else:s+=l;y+=[[n-k,l-r]]*(k<n) for x in x,y: x.sort();h=[] for k,d in x: heappush(h,...
[["-", 0, 1, 0, 677, 12, 634, 0, 634, 0, 22], ["+", 0, 1, 0, 677, 12, 634, 0, 634, 0, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]]
5
167
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #defin...
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #defin...
[["-", 64, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 64, 9, 0, 1, 0, 2, 63, 118, 28, 22]]
1
403
#pragma region template 2.4 #include <bits/stdc++.h> using namespace std; template <typename T> using pq_asc = priority_queue<T, vector<T>, greater<T>>; typedef long long ll; typedef vector<ll> vi; typedef vector<vi> vvi; typedef pair<ll, ll> ii; typedef vector<ii> vii; typedef vector<string> vs; #define REP(i, n) for ...
#pragma region template 2.4 #include <bits/stdc++.h> using namespace std; template <typename T> using pq_asc = priority_queue<T, vector<T>, greater<T>>; typedef long long ll; typedef vector<ll> vi; typedef vector<vi> vvi; typedef pair<ll, ll> ii; typedef vector<ii> vii; typedef vector<string> vs; #define REP(i, n) for ...
[["-", 0, 1, 0, 2, 3, 4, 0, 91, 17, 33]]
1
1,010
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <prettyprint.hpp> #define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__); #else #define debug(...) 83; #endif void d_err() { cerr << endl; } template <typename H, typename... T> void d_err(H h, T......
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <prettyprint.hpp> #define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__); #else #define debug(...) 83; #endif void d_err() { cerr << endl; } template <typename H, typename... T> void d_err(H h, T......
[["-", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120], ["+", 0, 43, 49, 50, 51, 2, 63, 118, 119, 120]]
1
524
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; void solve() { ll N; cin >> N; vector<P> num; ll ans = 0; for (int i = 0; i < N; i++) { ll K, L, R; cin >> K >> L >> R; ans += L; num.push_back(P(L - R, K)); } // cerr <<"ans=" << ans << endl; se...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; void solve() { ll N; cin >> N; vector<P> num; ll ans = 0; for (int i = 0; i < N; i++) { ll K, L, R; cin >> K >> L >> R; ans += L; num.push_back(P(L - R, K)); } // cerr <<"ans=" << ans << endl; se...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22]]
1
397
import java.io.*; import java.math.*; import java.util.*; public class Main { static PrintWriter out; static Reader in; public static void main(String[] args) throws IOException { // out = new PrintWriter(new File("out.txt")); // PrintWriter out = new PrintWriter(System.out); // in = new Reader(new F...
import java.io.*; import java.math.*; import java.util.*; public class Main { static PrintWriter out; static Reader in; public static void main(String[] args) throws IOException { // out = new PrintWriter(new File("out.txt")); // PrintWriter out = new PrintWriter(System.out); // in = new Reader(new F...
[["-", 0, 52, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 17, 19]]
3
1,493
#include <algorithm> #include <bits/stdc++.h> #include <chrono> #include <iomanip> #include <map> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <thread> #include <typeinfo> #include <vector> // define #define trav(i, v) for (auto i : v) #define rep(i, n) for (int i = 0; i < n; i...
#include <algorithm> #include <bits/stdc++.h> #include <chrono> #include <iomanip> #include <map> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <thread> #include <typeinfo> #include <vector> // define #define trav(i, v) for (auto i : v) #define rep(i, n) for (int i = 0; i < n; i...
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 19], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 20]]
1
858
from heapq import heappush, heappop T = int(input()) def process(arr): arr.sort() baseS = 0 diffS = 0 q = [] length = 0 for K, L, R in arr1: baseS += R diff = L - R heappush(q, diff) diffS += diff length += 1 while length > K: d = heap...
from heapq import heappush, heappop T = int(input()) def process(arr): arr.sort() baseS = 0 diffS = 0 q = [] length = 0 for K, L, R in arr: baseS += R diff = L - R heappush(q, diff) diffS += diff length += 1 while length > K: d = heapp...
[["-", 0, 656, 0, 14, 8, 196, 0, 7, 12, 22], ["+", 0, 656, 0, 14, 8, 196, 0, 7, 12, 22]]
5
186
import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) class SegmentTree(object): #N:処理する区間の長さ def __init__(self, N): self.N0 = 2 ** (N - 1).bit_length() self.data ...
import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) class SegmentTree(object): #N:処理する区間の長さ def __init__(self, N): self.N0 = 2 ** (N - 1).bit_length() self.data ...
[["+", 8, 196, 0, 57, 15, 666, 0, 664, 17, 33]]
5
728
#include <bits/stdc++.h> using namespace std; #define int long long #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 all(x) (x).begin(), (x).end() #define uniq(x) (x).erase(unique(all(x)), (x).end()) #define bit(n) (1LL << (n)) #define cdiv(a, b) (((a)...
#include <bits/stdc++.h> using namespace std; #define int long long #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 all(x) (x).begin(), (x).end() #define uniq(x) (x).erase(unique(all(x)), (x).end()) #define bit(n) (1LL << (n)) #define cdiv(a, b) (((a)...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 51, 16, 31, 2, 3, 4, 0, 16, 17, 72], ["-", 51, 16, 31, 2, 3, 4, 0, 16, 12, 13]]
1
1,772
#include <algorithm> #include <cassert> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define InfL 2000000000 #define InfLL 4000000000000000000LL #define mod 1000000007 #define rep(i, n) for (int i = 0; i < ...
#include <algorithm> #include <cassert> #include <cmath> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define InfL 2000000000 #define InfLL 4000000000000000000LL #define mod 1000000007 #define rep(i, n) for (int i = 0; i < ...
[["-", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78], ["+", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78]]
1
514
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from heapq import heappop,heappush t = int(readline()) q = list(map(int,read().split())) now = 0 ans = [0] * t for cyc in range(t): n = q[now] klr = q[now+1: now+1+3*n] now = now+1+3*n ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from heapq import heappop,heappush t = int(readline()) q = list(map(int,read().split())) now = 0 ans = [0] * t for cyc in range(t): n = q[now] klr = q[now+1: now+1+3*n] now = now+1+3*n ...
[["-", 8, 196, 0, 57, 15, 23, 0, 666, 667, 60], ["+", 8, 196, 0, 57, 15, 23, 0, 666, 667, 47], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117]]
5
322
// Left, Rightを決める. // Ki昇順 -> 上から全てLeft -> 上からValidになるよう最低限Right -> // 下から上限に注意してRight #include <algorithm> #include <functional> #include <iostream> #include <queue> #include <tuple> #define int long long #define rep(i, n) for (i = 0; i < n; i++) using namespace std; typedef tuple<int, int, int> T; typedef pair<int, ...
// Left, Rightを決める. // Ki昇順 -> 上から全てLeft -> 上からValidになるよう最低限Right -> // 下から上限に注意してRight #include <algorithm> #include <functional> #include <iostream> #include <queue> #include <tuple> #define int long long #define rep(i, n) for (i = 0; i < n; i++) using namespace std; typedef tuple<int, int, int> T; typedef pair<int, ...
[["-", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22]]
1
579
#include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <cstdlib> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std;...
#include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <cstdlib> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std;...
[["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 0, 57, 64, 1, 0, 11, 12, 118, 119, 120], ["+", 64, 9, 0, 1, 0, 11, 12, 118, 119, 120], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46]]
1
841
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define repA(i, a, n) for (int i = a; i <= (n); ++i) #define repD(i, a, n) for (int i = a; i >= (n); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define fill(a) me...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define repA(i, a, n) for (int i = a; i <= (n); ++i) #define repD(i, a, n) for (int i = a; i >= (n); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define fill(a) me...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, ...
1
518
from heapq import heapify, heappop, heappush Ncase = int(input()) for case in range(Ncase): N = int(input()) ans = 0 Left = [];Right = [] for i in range(N): K,L,R = map(int,input().split()) if L > R: Left.append((K-1,L-R)) ans += R elif R > L: if K != N: #K=Nの時はどこにおいても左と判定される。 ...
from heapq import heapify, heappop, heappush Ncase = int(input()) for case in range(Ncase): N = int(input()) ans = 0 Left = [];Right = [] for i in range(N): K,L,R = map(int,input().split()) if L > R: Left.append((K-1,L-R)) ans += R elif R > L: if K != N: #K=Nの時はどこにおいても左と判定される。 ...
[["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["+", 64, 196, 0, 1, 0, 662, 12, 664, 17, 33]]
5
295
#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 mp make_pair #define wzh(x) cerr << #x << ' ' << x << endl int t, n; struct uzi { int k, l; bool operator<(const uzi &t) const { return k < t.k; } } L[N], R[N];...
#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 mp make_pair #define wzh(x) cerr << #x << ' ' << x << endl int t, n; struct uzi { int k, l; bool operator<(const uzi &t) const { return k < t.k; } } L[N], R[N];...
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 72], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
1
443
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <stack> #include <string> #include <unordered_map> using namespace std; typedef long long ll; const ll INF = 1000000007; const ll mod = 998244353;...
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <stack> #include <string> #include <unordered_map> using namespace std; typedef long long ll; const ll INF = 1000000007; const ll mod = 998244353;...
[["-", 0, 7, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 7, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 0, 35], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78]]
1
403
import heapq T=int(input()) for _ in range(T): N=int(input()) llist=[] rlist=[] base=0 for _ in range(N): K,L,R=map(int,input().split()) if L>R: llist.append((K,L-R)) base+=R elif L<R: rlist.append((N-K,R-L)) base+=L llist.sort() rlist.sort() #pri...
import heapq T=int(input()) for _ in range(T): N=int(input()) llist=[] rlist=[] base=0 for _ in range(N): K,L,R=map(int,input().split()) if L>R: llist.append((K,L-R)) base+=R elif L<R: rlist.append((N-K,R-L)) base+=L else: base+=L llist.sort() r...
[["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 12, 22]]
5
213
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); vector<pii> d1, d2; long long ans = 0; for (int i = 0; i < n; i++) { int l, r, k; scanf("%d%d%d", &k, &l, &r); if (l >= r) { ...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); vector<pii> d1, d2; long long ans = 0; for (int i = 0; i < n; i++) { int l, r, k; scanf("%d%d%d", &k, &l, &r); if (l >= r) { ...
[["+", 10, 43, 49, 50, 51, 16, 31, 16, 31, 22], ["+", 10, 43, 49, 50, 51, 16, 31, 16, 17, 33]]
1
444
t=int(input()) import heapq for _ in range(t): n=int(input()) L=[];R=[] ans=0 for _ in range(n): ki,li,ri = map(int, input().split()) dif=li-ri if dif>=0: L.append((ki-1,dif)) ans+=ri else: R.append((n-ki-1,-dif)) ans+=li ...
t=int(input()) import heapq for _ in range(t): n=int(input()) L=[];R=[] ans=0 for _ in range(n): ki,li,ri = map(int, input().split()) dif=li-ri if dif>=0: L.append((ki-1,dif)) ans+=ri else: R.append((n-ki-1,-dif)) ans+=li ...
[["+", 0, 57, 75, 665, 15, 666, 0, 657, 17, 33], ["+", 0, 57, 75, 665, 15, 666, 0, 657, 12, 612], ["-", 75, 665, 15, 666, 0, 206, 51, 206, 51, 22], ["+", 75, 665, 15, 666, 0, 206, 51, 206, 51, 22]]
5
276
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair<ll, ll> P; #define yn ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair<ll, ll> P; #define yn ...
[["+", 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], ["+", 8, 9, 0, 14, 8, 9, 0, 1, 0, 35]]
1
361
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define prtd(var, i) cout << fixed << setprecision(i) << var << endl; #define ll long long #define P pair<int, int> using namespace std; int f(vector<P> p) { int n = p.size(); rep(i, n) p[i].first = min(p[i].first, n); vector<vector<int>> s...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define prtd(var, i) cout << fixed << setprecision(i) << var << endl; #define ll long long #define P pair<int, int> using namespace std; ll f(vector<P> p) { int n = p.size(); rep(i, n) p[i].first = min(p[i].first, n); vector<vector<int>> s(...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33]]
1
329
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll f(vector<pair<int, int>> a) { ll ans = 0; sort(a.begin(), a.end()); priority_queue<int, vector<int>, greater<>> q; for (auto i : a) { q.emplace(i.second); ans += i.second; while (q.size() > i.first) ans -= q.top(), q.pop();...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll f(vector<pair<int, int>> a) { ll ans = 0; sort(a.begin(), a.end()); priority_queue<int, vector<int>, greater<>> q; for (auto i : a) { q.emplace(i.second); ans += i.second; while (q.size() > i.first) ans -= q.top(), q.pop();...
[["-", 64, 1, 0, 34, 31, 2, 63, 118, 28, 22], ["+", 64, 1, 0, 34, 31, 2, 63, 118, 28, 22]]
1
258
#include <bits/stdc++.h> #define REP(i, n) for (long long i = 0; i < (long long)n; i++) //#define _GLIBCXX_DEBUG using namespace std; using ll = long long; using Pi = pair<int, int>; using Pl = pair<ll, ll>; using Vl = vector<ll>; using vi = vector<int>; using Graph = vector<vi>; #define INF 2000000000 void solve() { ...
#include <bits/stdc++.h> #define REP(i, n) for (long long i = 0; i < (long long)n; i++) //#define _GLIBCXX_DEBUG using namespace std; using ll = long long; using Pi = pair<int, int>; using Pl = pair<ll, ll>; using Vl = vector<ll>; using vi = vector<int>; using Graph = vector<vi>; #define INF 2000000000 void solve() { ...
[["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25]]
1
549
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using Z = long long; Z S(vector<pair<int, int>> a) { sort(a.begin(), a.end()); Z A; priority_queue<int, vector<int>, greater<>> Q; for (auto [k, d] : a) { Q.emplace(d); A += d; while (Q.size() > k) A ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using Z = long long; Z S(vector<pair<int, int>> a) { sort(a.begin(), a.end()); Z A = 0; priority_queue<int, vector<int>, greater<>> Q; for (auto [k, d] : a) { Q.emplace(d); A += d; while (Q.size() > k) ...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
275
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math #from math import gcd import bisect import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ############# # Const...
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math #from math import gcd import bisect import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ############# # Const...
[["-", 0, 1, 0, 677, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 319, 22]]
5
1,239
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string> #include <tuple> #include <vector> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) #de...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string> #include <tuple> #include <vector> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) #de...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
563
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i, s, n) for (int i = s; i < n; i++) #define NUM 2520 #define INF (1LL << 50) #define DEBUG 1 #define mp(a, b) make_pair(a, b) #define SORT(V) sort(V.begin(), V.end()) #define PI (3.141592653589794) #define TO_STRING(VariableName) #Var...
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i, s, n) for (int i = s; i < n; i++) #define NUM 2520 #define INF (1LL << 50) #define DEBUG 1 #define mp(a, b) make_pair(a, b) #define SORT(V) sort(V.begin(), V.end()) #define PI (3.141592653589794) #define TO_STRING(VariableName) #Var...
[["+", 8, 9, 0, 43, 39, 344, 3, 347, 0, 21], ["+", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78], ["+", 3, 347, 0, 77, 39, 344, 3, 347, 0, 18], ["+", 0, 77, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 3, 347, 0, 77, 39, 344, 3, 347, 0, 47]]
1
531
#include <bits/stdc++.h> #define fr(i, n) for (int i = 0; i < (n); ++i) #define foor(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, n) for (int i = (n); i-- > 0;) #define roof(i, b, a) for (int i = (b); i >= (a); --i) #define elsif else if #define all(x) x.begin(), x.end() #define Sort(x) sort(all(x)) #define ...
#include <bits/stdc++.h> #define fr(i, n) for (int i = 0; i < (n); ++i) #define foor(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, n) for (int i = (n); i-- > 0;) #define roof(i, b, a) for (int i = (b); i >= (a); --i) #define elsif else if #define all(x) x.begin(), x.end() #define Sort(x) sort(all(x)) #define ...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22]]
1
6,635
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define p_ary(ary, a, b) \ do { \ cout << "["; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define p_ary(ary, a, b) \ do { \ cout << "["; ...
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 19], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 20]]
1
502
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template <class T> using vc = vector<T>; template <class T> using vvc = vector<vector<T>>; #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (n); i++) #def...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template <class T> using vc = vector<T>; template <class T> using vvc = vector<vector<T>>; #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rep(i, n) for (ll i = 0; i < (n); i++) #def...
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 33], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
1
906
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++) #define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--) #define sort_vec(v) sort((v).begin(), (v).end()) typedef int64_t lint; // lint mod = 9982443...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++) #define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--) #define sort_vec(v) sort((v).begin(), (v).end()) typedef int64_t lint; // lint mod = 9982443...
[["-", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78], ["+", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78]]
1
393
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; for (int i = 0; i < T; i++) { int N; cin >> N; vector<long long> K(N), L(N), R(N); for (int j = 0; j < N; j++) cin >> K[j] >> L[j] >> R[j]; vector<pair<long long, long long>> l, r; long long ans = 0LL; ...
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; for (int i = 0; i < T; i++) { int N; cin >> N; vector<long long> K(N), L(N), R(N); for (int j = 0; j < N; j++) cin >> K[j] >> L[j] >> R[j]; vector<pair<long long, long long>> l, r; long long ans = 0LL; ...
[["+", 0, 57, 15, 339, 51, 16, 31, 74, 0, 24], ["+", 15, 339, 51, 16, 31, 74, 39, 77, 39, 40], ["+", 0, 57, 15, 339, 51, 16, 31, 74, 0, 25], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24]]
1
533