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 def rs(): return sys.stdin.readline().rstrip() def ri(): return int(sys.stdin.readline()) def ria(): return list(map(int, sys.stdin.readline().split())) def ws(s): sys.stdout.write(s); sys.stdout.write('\n') def wi(n): sys.stdout.write(str(n)); sys.stdout.write('\n') def wia(a, sep=' '): sys.stdout.write(sep...
import sys def rs(): return sys.stdin.readline().rstrip() def ri(): return int(sys.stdin.readline()) def ria(): return list(map(int, sys.stdin.readline().split())) def ws(s): sys.stdout.write(s); sys.stdout.write('\n') def wi(n): sys.stdout.write(str(n)); sys.stdout.write('\n') def wia(a, sep=' '): sys.stdout.write(sep...
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612]]
5
376
///#pragma GCC optimize("O3,unroll-loops") ///#pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define ull unsigned long long #define ld long double #define inf...
///#pragma GCC optimize("O3,unroll-loops") ///#pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define ull unsigned long long #define ld long double #define inf...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
1,042
N = int(input()) X = input() arr = [0 for _ in range(N+1)] for i in range(1, N+1): cnt = bin(i).count('1') arr[i] = arr[i%cnt] + 1 x = int(X, 2) pop = X.count('1') plu = x % (pop+1) mai = x % (pop-1) if pop>1 else 0 #bi = 1 << N for i in range(N): #bi = bi >> 1 if X[i] == '0': #res = (plu + b...
N = int(input()) X = input() arr = [0 for _ in range(N+1)] for i in range(1, N+1): cnt = bin(i).count('1') arr[i] = arr[i%cnt] + 1 x = int(X, 2) pop = X.count('1') plu = x % (pop+1) mai = x % (pop-1) if pop>1 else 0 #bi = 1 << N for i in range(N): #bi = bi >> 1 if X[i] == '0': #res = (plu + b...
[["-", 0, 662, 12, 657, 31, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 17, 33]]
5
202
from collections import Counter import sys sys.setrecursionlimit(10 ** 6) def dfs(n): if memo[n] >= 0: rst = memo[n] else: tmp = n one = 0 while tmp > 0: one += tmp & 1 tmp >>= 1 m = n % one rst = 1 if m == 0 else 1 + dfs(m) memo[...
from collections import Counter import sys sys.setrecursionlimit(10 ** 6) def dfs(n): if memo[n] >= 0: rst = memo[n] else: tmp = n one = 0 while tmp > 0: one += tmp & 1 tmp >>= 1 m = n % one rst = 1 if m == 0 else 1 + dfs(m) memo[...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72]]
5
313
N = int(input()) X = input() c = X.count('1') if c == 0: for i in range(N): print(1) quit() if c == 1: if int(X[-1]): for i in range(N-1): print(2) print(0) else: for i in range(N): if int(X[i]): print(0) else: print(1) quit() memo = {0:0, 1:1, 2:1} def calc(...
N = int(input()) X = input() c = X.count('1') if c == 0: for i in range(N): print(1) quit() if c == 1: if int(X[-1]): for i in range(N-1): print(2) print(0) else: for i in range(N-1): if int(X[i]): print(0) else: print(1) print(2) quit() memo = {0:0, 1:1,...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
382
#!python3 import sys iim = lambda: map(int, sys.stdin.readline().rstrip().split()) def resolve(): N = int(input()) S = input() cnt0 = S.count("1") if cnt0 == 0: print("\n".join(map(str, [1]*N))) raise 1 return X = int(S, 2) def f2(): cache = [0] * (cnt0 + 1) ...
#!python3 import sys iim = lambda: map(int, sys.stdin.readline().rstrip().split()) def resolve(): N = int(input()) S = input() cnt0 = S.count("1") if cnt0 == 0: print("\n".join(map(str, [1]*N))) return X = int(S, 2) def f2(): cache = [0] * (cnt0 + 1) i = 1 ...
[["-", 8, 196, 0, 57, 64, 196, 0, 706, 0, 707], ["-", 8, 196, 0, 57, 64, 196, 0, 706, 0, 612], ["-", 0, 1, 0, 662, 12, 657, 12, 206, 206, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 206, 206, 22]]
5
440
#include <bits/stdc++.h> using namespace std; #define ll long long #define debug(x) cout << x #define pb push_back #include <string.h> ll modex(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b % 2) ans = (ans * a) % mod; a = (a * a) % mod; b /= 2; } return ans; } ll count(ll val) { ll cnt...
#include <bits/stdc++.h> using namespace std; #define ll long long #define debug(x) cout << x #define pb push_back #include <string.h> ll modex(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b % 2) ans = (ans * a) % mod; a = (a * a) % mod; b /= 2; } return ans; } ll count(ll val) { ll cnt...
[["+", 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
540
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define REP(i, n) rep(i, 0, n) #define int long long using namespace std; typedef pair<int, int> P; const int mod = 1000000007; const int INF = 1e18; int calc(string &s, int m) { int res = 0; for (auto c : s) { res = res * 2 + (c == '1')...
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define REP(i, n) rep(i, 0, n) #define int long long using namespace std; typedef pair<int, int> P; const int mod = 1000000007; const int INF = 1e18; int calc(string &s, int m) { int res = 0; for (auto c : s) { res = res * 2 + (c == '1')...
[["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 35], ["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
447
/* this->author = Fuad Ashraful Mehmet, CSE-UAP ToDo-- uva 1223 */ #include <bits/stdc++.h> #define forn(i, n) for (int i = 0; i < (int)n; ++i) #define all(o) (o).begin(), (o).end() #define dbg(o) cerr << "at " << __LINE__ << " response = " << o << endl; using namespace std; /* #include <ext/pb_ds/assoc_container...
/* this->author = Fuad Ashraful Mehmet, CSE-UAP ToDo-- uva 1223 */ #include <bits/stdc++.h> #define forn(i, n) for (int i = 0; i < (int)n; ++i) #define all(o) (o).begin(), (o).end() #define dbg(o) cerr << "at " << __LINE__ << " response = " << o << endl; using namespace std; /* #include <ext/pb_ds/assoc_container...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
865
// created by mtnshh #include <algorithm> #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define rep(i, a, b) for (ll i = a; i < b; i++) #define repb(i, a, b) for (ll i = a; i >= b; i--) #define err() cout << "--------------------------" << endl; #define errA(A) ...
// created by mtnshh #include <algorithm> #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define rep(i, a, b) for (ll i = a; i < b; i++) #define repb(i, a, b) for (ll i = a; i >= b; i--) #define err() cout << "--------------------------" << endl; #define errA(A) ...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 110], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 107], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 107], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 110]]
1
679
n,x=int(input()),input() o=x.count("1") if o==1: for i,v in enumerate(x): if v=="1":print(0) else: if i!=n-1: if x[-1]=="0":print(1) else:print(2) else:print(0) else: m=o-1 M=o+1 mp,mm={0:1},{0:1} for i in range(1,n): m...
n,x=int(input()),input() o=x.count("1") if o==1: for i,v in enumerate(x): if v=="1":print(0) else: if i!=n-1: if x[-1]=="0":print(1) else:print(2) else:print(2) else: m=o-1 M=o+1 mp,mm={0:1},{0:1} for i in range(1,n): m...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
276
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long ul; // for文短縮類 #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++) #define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--) //...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long ul; // for文短縮類 #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++) #define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--) //...
[["-", 0, 1, 0, 11, 12, 23, 0, 16, 17, 72], ["+", 0, 1, 0, 11, 12, 23, 0, 16, 17, 33]]
1
606
import sys #DEBUG=True DEBUG=False if DEBUG: f=open("202007_2nd/D_input.txt") else: f=sys.stdin #from 2nd count def cnt_func(num): cnt=0 while num: num%=bin(num).count("1") cnt+=1 return cnt+1 n=int(f.readline().strip()) s=f.readline().strip() input_val=int(s,2) input_one_count=s.cou...
import sys #DEBUG=True DEBUG=False if DEBUG: f=open("202007_2nd/D_input.txt") else: f=sys.stdin #from 2nd count def cnt_func(num): cnt=0 while num: num%=bin(num).count("1") cnt+=1 return cnt+1 n=int(f.readline().strip()) s=f.readline().strip() input_val=int(s,2) input_one_count=s.cou...
[["-", 75, 76, 8, 196, 0, 1, 0, 662, 12, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 12, 612]]
5
229
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; template <typename T> T modpow(T base, T exp, T modulus) { base %= modulus; T result = 1; while (exp > 0) { if (exp & 1) result = (result * base) % modulus; base = (base * base) ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; template <typename T> T modpow(T base, T exp, T modulus) { base %= modulus; T result = 1; while (exp > 0) { if (exp & 1) result = (result * base) % modulus; base = (base * base) ...
[["-", 64, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 64, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
1
476
# coding: utf-8 import sys #from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read #from heapq import heappop, heappush #from collections import defaultdict sys.setrecursionlimit(10**7) #import math #from itertools import product, accumulate, combinations, product #import bisec...
# coding: utf-8 import sys #from operator import itemgetter sysread = sys.stdin.buffer.readline read = sys.stdin.buffer.read #from heapq import heappop, heappush #from collections import defaultdict sys.setrecursionlimit(10**7) #import math #from itertools import product, accumulate, combinations, product #import bisec...
[["-", 8, 196, 0, 1, 0, 662, 12, 432, 0, 21], ["-", 8, 196, 0, 1, 0, 662, 12, 432, 0, 612]]
5
556
from sys import stdin def mpow(n, p, mod): if mod == 0: return 0 r = 1 while p > 0: if p & 1 == 1: r = r * n % mod n = n * n % mod p >>= 1 return r def popcount(u): if u == 0: return 0 a = u % bin(u).count('1') return 1 + popcount(a) def m...
from sys import stdin def mpow(n, p, mod): if mod == 0: return 0 r = 1 while p > 0: if p & 1 == 1: r = r * n % mod n = n * n % mod p >>= 1 return r def popcount(u): if u == 0: return 0 a = u % bin(u).count('1') return 1 + popcount(a) def m...
[["-", 0, 57, 75, 665, 64, 196, 0, 1, 0, 22], ["+", 0, 57, 75, 665, 64, 196, 0, 116, 0, 117]]
5
265
#include <bits/stdc++.h> using namespace std; using llong = long long; using ldbl = long double; using lpair = pair<llong, llong>; #define ALL(x) x.begin(), x.end() constexpr llong mod = 1e9 + 7; constexpr llong inf = mod * mod; int main() { llong N; string X; llong cnt = 0; cin >> N >> X; reverse(ALL(X)...
#include <bits/stdc++.h> using namespace std; using llong = long long; using ldbl = long double; using lpair = pair<llong, llong>; #define ALL(x) x.begin(), x.end() constexpr llong mod = 1e9 + 7; constexpr llong inf = mod * mod; int main() { llong N; string X; llong cnt = 0; cin >> N >> X; reverse(ALL(X)...
[["+", 49, 50, 51, 16, 31, 23, 0, 16, 17, 72], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 12, 22]]
1
543
N=int(input()) X=input() c=X.count('1') r1=int(X,2)%(c-1) r2=int(X,2)%(c+1) d=[0]*(N+1) for i in range(N): d[i+1]=d[(i+1)%bin(i+1).count('1')]+1 for i in range(N): if X[i]=='0': n=(r2+pow(2,N-i-1,c+1))%(c+1) else: if c==1: print(0) continue n=(r1-pow(2,N-i-1,c...
N=int(input()) X=input() c=X.count('1') r1=int(X,2)%(c-1) if c>1 else 0 r2=int(X,2)%(c+1) d=[0]*(N+1) for i in range(N): d[i+1]=d[(i+1)%bin(i+1).count('1')]+1 for i in range(N): if X[i]=='0': n=(r2+pow(2,N-i-1,c+1))%(c+1) else: if c==1: print(0) continue n=(r1...
[["+", 0, 656, 0, 1, 0, 662, 12, 41, 0, 121], ["+", 0, 1, 0, 662, 12, 41, 0, 666, 0, 22], ["+", 0, 1, 0, 662, 12, 41, 0, 666, 667, 47], ["+", 0, 1, 0, 662, 12, 41, 0, 666, 0, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 41, 0, 95], ["+", 0, 656, 0, 1, 0, 662, 12, 41, 0, 612]]
5
192
n = int(input()) x = input() original_pop_count = x.count('1') one_pop_count = original_pop_count - 1 # 0になりうる zero_pop_count = original_pop_count + 1 one_mod = 0 zero_mod = 0 for b in x: if one_pop_count != 0: one_mod = (one_mod * 2 + int(b)) % one_pop_count zero_mod = (zero_mod * 2 + int(b)) % zero_...
n = int(input()) x = input() original_pop_count = x.count('1') one_pop_count = original_pop_count - 1 # 0になりうる zero_pop_count = original_pop_count + 1 one_mod = 0 zero_mod = 0 for b in x: if one_pop_count != 0: one_mod = (one_mod * 2 + int(b)) % one_pop_count zero_mod = (zero_mod * 2 + int(b)) % zero_...
[["-", 3, 4, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 657, 31, 206, 0, 70], ["-", 3, 4, 0, 657, 31, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 657, 31, 206, 0, 73], ["-", 0, 57, 75, 665, 15, 666, 0, 557, 0, 6], ["+", 0, 57, 75, 665, 15, 666, 0, 557, 0, 6]]
5
294
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(System.in); int n = sc.nextInt(); int[] cnt = new int[n]; for (int i = 1; i < n; i++) { int now = i; int c = 0; while (now != 0) { ...
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(System.in); int n = sc.nextInt(); int[] cnt = new int[n]; for (int i = 1; i < n; i++) { int now = i; int c = 0; while (now != 0) { ...
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
3
838
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] x = sc.next().toCharArray(); int pc = 0; for (int i = 0; i < n; i++) { if (x[i] == '1') pc++; } StringBuilder sb = new StringBu...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] x = sc.next().toCharArray(); int pc = 0; for (int i = 0; i < n; i++) { if (x[i] == '1') pc++; } StringBuilder sb = new StringBu...
[["-", 51, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 49, 200, 51, 16, 31, 23, 0, 16, 17, 33]]
3
525
n = int(input()) x = list(input()) def popcount(n): bin_n = bin(n)[2:] count = 0 for i in bin_n: count += int(i) return count cnt = 0 for i in range(n): if x[i] == '1': cnt += 1 lst = [0 for i in range(n+1)] for i in range(1, n+1): num = i%popcount(i) lst[i] = lst[num] + 1...
n = int(input()) x = list(input()) def popcount(n): bin_n = bin(n)[2:] count = 0 for i in bin_n: count += int(i) return count cnt = 0 for i in range(n): if x[i] == '1': cnt += 1 lst = [0 for i in range(n+1)] for i in range(1, n+1): num = i%popcount(i) lst[i] = lst[num] + 1...
[["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 79], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102]]
5
338
package main import ( "bufio" "fmt" "io" "math/bits" "os" "strconv" ) const mod = 998244353 const facNum = 300001 var dp []int func main() { sc := newScanner(os.Stdin) N := sc.i() X := sc.s() // popcount dp = make([]int, 1000000) p := popcountStr(X) b0 := make([]int, N) b1 := make([]int, N) p0 := p ...
package main import ( "bufio" "fmt" "io" "math/bits" "os" "strconv" ) const mod = 998244353 const facNum = 300001 var dp []int func main() { sc := newScanner(os.Stdin) N := sc.i() X := sc.s() // popcount dp = make([]int, 1000000) p := popcountStr(X) b0 := make([]int, N) b1 := make([]int, N) p0 := p ...
[["-", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22]]
7
1,302
#AIsing2020 d def f(n): cnt = 0 while n: cnt+= 1 n = n%bin(n).count('1') return cnt def main(): N = int(input()) X = input() X10 = int(X,2) X10_num1 = X.count('1') X10_pulse = X10%(X10_num1+1) X10_ninus = X10%(X10_num1-1) if X10_num1 >1 else 0 ...
#AIsing2020 d def f(n): cnt = 0 while n: cnt+= 1 n = n%bin(n).count('1') return cnt def main(): N = int(input()) X = input() X10 = int(X,2) X10_num1 = X.count('1') X10_pulse = X10%(X10_num1+1) X10_ninus = X10%(X10_num1-1) if X10_num1 >1 else 0 ...
[["-", 0, 657, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 657, 12, 652, 3, 4, 0, 657, 17, 33]]
5
212
n=int(input()) x=input() val=int(x,2) cnt=x.count("1") p_cnt=cnt+1 m_cnt=cnt-1 p_amari,m_amari=0,0 p_amari=val%(cnt+1) if cnt-1!=0: m_amari=val%(cnt-1) else: m_amari=0 for i in range(n): ans=0 if x[i]=="0": amari=p_amari+pow(2,n-i-1,p_cnt) amari%p_cnt elif x[i]=="1": if cnt-1==0: print(0)...
n=int(input()) x=input() val=int(x,2) cnt=x.count("1") p_cnt=cnt+1 m_cnt=cnt-1 p_amari,m_amari=0,0 p_amari=val%(cnt+1) if cnt-1!=0: m_amari=val%(cnt-1) else: m_amari=0 for i in range(n): ans=0 if x[i]=="0": amari=p_amari+pow(2,n-i-1,p_cnt) amari%=p_cnt elif x[i]=="1": if cnt-1==0: print(0...
[["-", 0, 57, 64, 196, 0, 1, 0, 657, 17, 109], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 132]]
5
187
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; typedef pair<ll, ll> l_l; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; typedef pair<l_l, ll> lll; typedef vector<string> vs; const ll dx[4] = {1, -1, 0, 0...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; typedef pair<ll, ll> l_l; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; typedef pair<l_l, ll> lll; typedef vector<string> vs; const ll dx[4] = {1, -1, 0, 0...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22]]
1
606
import sys input_methods=['clipboard','file','key'] using_method=0 input_method=input_methods[using_method] tin=lambda : map(int, input().split()) lin=lambda : list(tin()) mod=1000000007 #+++++ dd={} def get_f(v): global dd if v == 0: return 0 if v in dd: return dd[v] pn = bin(v).count('1') ret = 1+ge...
import sys input_methods=['clipboard','file','key'] using_method=1 input_method=input_methods[using_method] tin=lambda : map(int, input().split()) lin=lambda : list(tin()) mod=1000000007 #+++++ dd={} def get_f(v): global dd if v == 0: return 0 if v in dd: return dd[v] pn = bin(v).count('1') ret = 1+ge...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 8, 196, 0, 57, 15, 666, 0, 557, 0, 654], ["-", 8, 196, 0, 57, 15, 666, 0, 557, 0, 655]]
5
507
package main import ( "bufio" "container/heap" "fmt" "math/bits" "os" "sort" "strconv" "strings" ) const ( initialBufSize = 1e4 maxBufSize = 1e6 + 7 ) var buf []byte = make([]byte, maxBufSize) var sc = bufio.NewScanner(os.Stdin) func init() { sc.Split(bufio.ScanWords) sc.Buffer(buf, maxBufSize) } f...
package main import ( "bufio" "container/heap" "fmt" "math/bits" "os" "sort" "strconv" "strings" ) const ( initialBufSize = 1e4 maxBufSize = 1e6 + 7 ) var buf []byte = make([]byte, maxBufSize) var sc = bufio.NewScanner(os.Stdin) func init() { sc.Split(bufio.ScanWords) sc.Buffer(buf, maxBufSize) } f...
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 433], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 433]]
7
1,702
N=int(input()) X=input() def calc(n,count): if n==0: return count popcount=bin(n).count("1") next_n=n%popcount #print(next_n) if next_n==0: return count+1 else: return calc(next_n, count+1) popcount=X.count("1") if popcount==1: plus=0 for i in range(N): x...
N=int(input()) X=input() def calc(n,count): if n==0: return count popcount=bin(n).count("1") next_n=n%popcount #print(next_n) if next_n==0: return count+1 else: return calc(next_n, count+1) popcount=X.count("1") if popcount==1: plus=0 for i in range(N): x...
[["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 654], ["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 655]]
5
348
/*The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep.*/ // PRABHJOT SINGH A.K.A. PRABHI //~~~~~conquizztador~~~~~ #include <bits/stdc++.h> using namespace std; using lli = long long int; #define pb push_back #define eb emplace_back #define ...
/*The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep.*/ // PRABHJOT SINGH A.K.A. PRABHI //~~~~~conquizztador~~~~~ #include <bits/stdc++.h> using namespace std; using lli = long long int; #define pb push_back #define eb emplace_back #define ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
480
// In the name of God // #include <bits/stdc++.h> #define ll long long #define all(x) (x).begin(), (x).end() #define pii pair<int, int> using namespace std; const ll mod = 998244353; int power(ll x, ll y, ll p) { if (y == 0) { return 1 % p; } ll res = 1; // Initialize result x = x % p; // Update x if it ...
// In the name of God // #include <bits/stdc++.h> #define ll long long #define all(x) (x).begin(), (x).end() #define pii pair<int, int> using namespace std; const ll mod = 998244353; int power(ll x, ll y, ll p) { if (y == 0) { return 1 % p; } ll res = 1; // Initialize result x = x % p; // Update x if it ...
[["+", 8, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 25]]
1
620
import java.io.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] x = sc.next().toCharArray(); sc.close(); int cnt = 0; for (int i = 0; i < n; i++) { if (...
import java.io.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] x = sc.next().toCharArray(); sc.close(); int cnt = 0; for (int i = 0; i < n; i++) { if (...
[["-", 75, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 15, 0, 16, 31, 22]]
3
506
import sys readline = sys.stdin.buffer.readline read = sys.stdin.buffer.read import numpy as np #N = 2 * 10 ** 5 #X = np.random.randint(0, 2, N) #Y = int('0b' + ''.join(X.astype(str).tolist()), 0) N = int(input()) X = input() Y = int('0b' + X, 0) X = np.array(list(X), int) p = int(X.sum()) m1 = Y % (p + 1) m2 = Y ...
import sys readline = sys.stdin.buffer.readline read = sys.stdin.buffer.read import numpy as np #N = 2 * 10 ** 5 #X = np.random.randint(0, 2, N) #Y = int('0b' + ''.join(X.astype(str).tolist()), 0) N = int(input()) X = input() Y = int('0b' + X, 0) X = np.array(list(X), int) p = int(X.sum()) m1 = Y % (p + 1) m2 = Y ...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]]
5
305
from collections import deque n = int(input()) x = input() memo = {0: 0} def solve(X): x = X stack = deque([]) while x: if x in memo: break stack.append(x) x = x % bin(x).count("1") cnt = memo[x] + 1 while stack: x = stack.pop() memo[x] = cnt ...
from collections import deque n = int(input()) x = input() memo = {0: 0} def solve(X): x = X stack = deque([]) while x: if x in memo: break stack.append(x) x = x % bin(x).count("1") cnt = memo[x] + 1 while stack: x = stack.pop() memo[x] = cnt ...
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 102]]
5
342
class Integer def popcount to_s(2).count('1') end end def f(n) c = 0 while n > 0 n %= n.popcount c += 1 end c end def modpow(base, n, mod) result = 1 while n > 0 if n.odd? result = result * base % mod end base = (base * base) % mod n /= 2 end result % mod end n...
class Integer def popcount to_s(2).count('1') end end def f(n) c = 0 while n > 0 n %= n.popcount c += 1 end c end def modpow(base, n, mod) result = 1 while n > 0 if n.odd? result = result * base % mod end base = (base * base) % mod n /= 2 end result % mod end n...
[["-", 36, 36, 0, 493, 0, 745, 15, 738, 12, 612], ["+", 36, 36, 0, 493, 0, 745, 15, 738, 12, 612]]
4
230
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long int #define mp make_pair #define S second #define F first ll mod = 1e9 + 7; #define fastIO \ ios_base::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long int #define mp make_pair #define S second #define F first ll mod = 1e9 + 7; #define fastIO \ ios_base::sync_with_stdio(false); ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
569
#include "bits/stdc++.h" using namespace std; const long long INF = (long long)(1e18) + 1; int f(int n) { int ans = 0; while (n != 0) { ans++; int ncopy = n; int tmp = 0; while (0 != ncopy) { tmp += ncopy % 2; ncopy /= 2; } n %= n / tmp; } return ans; } int main() { int N...
#include "bits/stdc++.h" using namespace std; const long long INF = (long long)(1e18) + 1; int f(int n) { int ans = 0; while (n != 0) { ans++; int ncopy = n; int tmp = 0; while (0 != ncopy) { tmp += ncopy % 2; ncopy /= 2; } n %= tmp; } return ans; } int main() { int N; ...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85]]
1
455
#include <bits/stdc++.h> using namespace std; long long pop(long long num) { long long cnt = 0; while (num > 0) { if (num % 2 != 0) { cnt++; } num /= 2; } return cnt; } int main(void) { long long digit; cin >> digit; string s; cin >> s; long long cnt = 0; for (int i = 0; i < s...
#include <bits/stdc++.h> using namespace std; long long pop(long long num) { long long cnt = 0; while (num > 0) { if (num % 2 != 0) { cnt++; } num /= 2; } return cnt; } int main(void) { long long digit; cin >> digit; string s; cin >> s; long long cnt = 0; for (int i = 0; i < s...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 67], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109]]
1
589
from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter import itertools from itertools import permutations, combinations, accumulate, product, combinations_with_replacement import sys import bisect import string import math import time def I(): return int(input()) def S(): re...
from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter import itertools from itertools import permutations, combinations, accumulate, product, combinations_with_replacement import sys import bisect import string import math import time def I(): return int(input()) def S(): re...
[["-", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22]]
5
786
package main import ( "bufio" "fmt" "math/bits" "os" "strings" ) func main() { N := ReadInt() X := ReadString() originalPopcount := strings.Count(X, "1") originalMinusOneMod := 0 originalPlusOneMod := 0 for _, c := range X { b := 0 if c == '1' { b = 1 } if originalPopcount > 1 { originalMinu...
package main import ( "bufio" "fmt" "math/bits" "os" "strings" ) func main() { N := ReadInt() X := ReadString() originalPopcount := strings.Count(X, "1") originalMinusOneMod := 0 originalPlusOneMod := 0 for _, c := range X { b := 0 if c == '1' { b = 1 } if originalPopcount > 1 { originalMinu...
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 433], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 165], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
7
482
#include <bits/stdc++.h> using namespace std; #ifdef _DEBUG #include "_DEBUG.hpp" #endif #define int long long const int INF = 1LL << 60; int mod_pow(int n, int p, int MOD) { int r = 1; for (; p > 0; p >>= 1) { if (p & 1LL) r = (r * n) % MOD; n = (n * n) % MOD; } return r; // r = n^p % MOD } int...
#include <bits/stdc++.h> using namespace std; #ifdef _DEBUG #include "_DEBUG.hpp" #endif #define int long long const int INF = 1LL << 60; int mod_pow(int n, int p, int MOD) { int r = 1; for (; p > 0; p >>= 1) { if (p & 1LL) r = (r * n) % MOD; n = (n * n) % MOD; } return r; // r = n^p % MOD } int...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
580
#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for (ll i = 0; i < (n); i++) #define rrep(i, n) for (ll i = (n)-1; i >= 0; i--) #define ALL(v) v.begin(), v.end() #define rALL(v) v.rbegin(), v.rend() #define FOR(i, j, k) for (ll i = j; i < k; i++) #define debug_print(var) cerr << #var << "=" << var <<...
#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for (ll i = 0; i < (n); i++) #define rrep(i, n) for (ll i = (n)-1; i >= 0; i--) #define ALL(v) v.begin(), v.end() #define rALL(v) v.rbegin(), v.rend() #define FOR(i, j, k) for (ll i = j; i < k; i++) #define debug_print(var) cerr << #var << "=" << var <<...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13]]
1
1,214
N = int(input()) X = input().strip() C = X.count("1") D = int(X, 2) Mm, Mp = 0, D % (C+1) if C > 0: Mm = D % (C-1) p = [0]*(2*10**5+2) for i in range(1, len(p)): n = i while True: b = bin(n).count("1") if b <= 0: break p[i] += 1 n = n % b for i in range(1, N+1):...
N = int(input()) X = input().strip() C = X.count("1") D = int(X, 2) Mm, Mp = 0, D % (C+1) if C > 1: Mm = D % (C-1) p = [0]*(2*10**5+2) for i in range(1, len(p)): n = i while True: b = bin(n).count("1") if b <= 0: break p[i] += 1 n = n % b for i in range(1, N+1):...
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612]]
5
230
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <funct...
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <funct...
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
1,687
import collections N=int(input()) X=list(input()) X=list(map(int,X)) #print(X) ans1=0 ans2=0 c=collections.Counter(X) div=c[1] for i in range(N): ans1=(ans1+X[i]*pow(2,N-i-1,div+1))%(div+1) if div-1!=0: ans2=(ans2+X[i]*pow(2,N-i-1,div-1))%(div-1) else: ans2=None #print(ans1) #print(ans1,...
import collections N=int(input()) X=list(input()) X=list(map(int,X)) #print(X) ans1=0 ans2=0 c=collections.Counter(X) div=c[1] for i in range(N): ans1=(ans1+X[i]*pow(2,N-i-1,div+1))%(div+1) if div-1!=0: ans2=(ans2+X[i]*pow(2,N-i-1,div-1))%(div-1) else: ans2=None #print(ans1) #print(ans1,...
[["-", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 57, 75, 76, 8, 196, 0, 93, 0, 94], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 76, 8...
5
282
import sys readline = sys.stdin.buffer.readline def even(n): return 1 if n%2==0 else 0 n = int(readline()) lst1 = list(readline().rstrip().decode('utf-8')) res = lst1.copy() res = "".join(res) ct = res.count("1") res = int(res,2) if ct == 0: for i in range(n): print(0) exit() if ct == 1: amari_of...
import sys readline = sys.stdin.buffer.readline def even(n): return 1 if n%2==0 else 0 n = int(readline()) lst1 = list(readline().rstrip().decode('utf-8')) res = lst1.copy() res = "".join(res) ct = res.count("1") res = int(res,2) if ct == 0: for i in range(n): print(1) exit() if ct == 1: amari_of...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 8, 196,...
5
364
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef u...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef u...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 11, 12, 16, 31, 16, 31, 69, 28, 22], ["+", 0, 11, 12, 16, 31, 16, 31, 69, 28, 22]]
1
755
#include <bits/stdc++.h> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, n, m) for (int i = m; i < (n); ++i) #define repl(i, n) for (long long i = 0; i < (n); ++i) #d...
#include <bits/stdc++.h> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, n, m) for (int i = m; i < (n); ++i) #define repl(i, n) for (long long i = 0; i < (n); ++i) #d...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
795
#include <algorithm> #include <iostream> #include <string> using namespace std; int v[2][200010], res[200010]; int f(int n) { int res = 0; while (n > 0) { n %= __builtin_popcount(n); ++res; } return res; } int main() { int n; cin >> n; string x; cin >> x; int d = count(begin(x), end(x), '1'...
#include <algorithm> #include <iostream> #include <string> using namespace std; int v[2][200010], res[200010]; int f(int n) { int res = 0; while (n > 0) { n %= __builtin_popcount(n); ++res; } return res; } int main() { int n; cin >> n; string x; cin >> x; int d = count(begin(x), end(x), '1'...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 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, 14, 8, 9, 0, 57, 15, 339, 0, 25]]
1
408
// Optional FAST //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native") // Required Libraries #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> ...
// Optional FAST //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native") // Required Libraries #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 64, 9, 0, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 64, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 64, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
1
808
#include <iostream> #include <string> #include <vector> typedef long long int ll; using namespace std; ll calc(ll num) { ll ret = 0; while (num != 0) { ll cnt = __builtin_popcount(num); num %= cnt; ret++; } return ret; } int main(int argc, char const *argv[]) { ll n; std::cin >> n; string s;...
#include <iostream> #include <string> #include <vector> typedef long long int ll; using namespace std; ll calc(ll num) { ll ret = 0; while (num != 0) { ll cnt = __builtin_popcount(num); num %= cnt; ret++; } return ret; } int main(int argc, char const *argv[]) { ll n; std::cin >> n; string s;...
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13]]
1
510
N = int(input()) X = input() cnt = X.count('1') Y, Z = 0, 0 for i in range(N): Y = (Y + int(X[i])*pow(2, N-i-1, cnt-1))%(cnt-1) Z = (Z + int(X[i])*pow(2, N-i-1, cnt+1))%(cnt+1) def popcount(n): c = bin(n).count('1') return c for i in range(N): if X[i] == '1': pc = cnt - 1 if pc == ...
N = int(input()) X = input() cnt = X.count('1') Y, Z = 0, 0 for i in range(N): if cnt > 1: Y = (Y + int(X[i])*pow(2, N-i-1, cnt-1))%(cnt-1) Z = (Z + int(X[i])*pow(2, N-i-1, cnt+1))%(cnt+1) def popcount(n): c = bin(n).count('1') return c for i in range(N): if X[i] == '1': pc = cnt -...
[["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102], ["-", 0, 57, 64, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 19]]
5
262
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define codefor \ int test; \ scanf("...
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define codefor \ int test; \ scanf("...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
1,047
/* これを入れて実行 g++ code.cpp ./a.out */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include ...
/* これを入れて実行 g++ code.cpp ./a.out */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include ...
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
835
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) typedef long long ll; typedef pair<ll, ll> P; int dfs(int n) { if (n == 0) { return 0; } int now = n; int co = 0; while (now > 0) { if (now % 2 ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) typedef long long ll; typedef pair<ll, ll> P; int dfs(int n) { if (n == 0) { return 0; } int now = n; int co = 0; while (now > 0) { if (now % 2 ...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
444
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1e9 + 7; const int maxn = 2e6 + 1; ll f(int x) { ll ans = 0; while (__builtin_popcount(x)) { x = x % __builtin_popcount(x); ans++; } return ans; } long long binpow(long long a, long long b, long long m) { a %= m; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1e9 + 7; const int maxn = 2e6 + 1; ll f(int x) { ll ans = 0; while (__builtin_popcount(x)) { x = x % __builtin_popcount(x); ans++; } return ans; } long long binpow(long long a, long long b, long long m) { a %= m; ...
[["-", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
445
N = int(input()) X = list(input()) one = X.count('1') L1 = [1] L2 = [1] for _ in range(N-1): if one == 0: L1.append(0) else: L1.append((L1[-1] * 2) % (one - 1)) L2.append((L2[-1] * 2) % (one + 1)) x1 = 0 x2 = 0 power1 = 1 power2 = 1 for i in range(N): if X[N-i-1] == '1': if on...
N = int(input()) X = list(input()) one = X.count('1') L1 = [1] L2 = [1] for _ in range(N-1): if one - 1 == 0: L1.append(0) else: L1.append((L1[-1] * 2) % (one - 1)) L2.append((L2[-1] * 2) % (one + 1)) x1 = 0 x2 = 0 power1 = 1 power2 = 1 for i in range(N): if X[N-i-1] == '1': i...
[["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]]
5
302
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) Xs = list(map(int, list(input()))) rXs = Xs[::-1] num = sum(Xs) pos = 0 neg = 0 pow_pos = [0]*N pow_neg = [0]*N dic = {0: 0, 1: 1, 2: 1, 3: 2, 4: 1, 5: 2, 6: 1, 7: ...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) Xs = list(map(int, list(input()))) rXs = Xs[::-1] num = sum(Xs) pos = 0 neg = 0 pow_pos = [0]*N pow_neg = [0]*N dic = {0: 0, 1: 1, 2: 1, 3: 2, 4: 1, 5: 2, 6: 1, 7: ...
[["-", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22]]
5
363
n = int(input()) x = [int(x) for x in list(input())] x_cnt = 0 for i, y in enumerate(x): if y == 1: x_cnt += 1 aa = x_cnt + 1 bb = x_cnt - 1 a = [1 % aa] if bb > 0: b = [1 % bb] else: b = [0] for _ in range(n-1): a.append(a[-1]*2 % aa) b.append(b[-1]*2 % bb) a = a[::-1] b = b[::-1] x_p...
n = int(input()) x = [int(x) for x in list(input())] x_cnt = 0 for i, y in enumerate(x): if y == 1: x_cnt += 1 aa = x_cnt + 1 bb = x_cnt - 1 a = [1 % aa] if bb > 0: b = [1 % bb] else: bb = 1 b = [0] for _ in range(n-1): a.append(a[-1]*2 % aa) b.append(b[-1]*2 % bb) a = a[::-1] b = b...
[["+", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 12, 612]]
5
338
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <vector> using namespace std; using ll = long long; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR...
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <vector> using namespace std; using ll = long long; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR...
[["+", 0, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["+", 0, 69, 341, 342, 0, 16, 31, 16, 17, 33], ["+", 31, 23, 0, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 23, 0, 69, 341, 342, 0, 16, 12, 13]]
1
664
n = int(input()) s = input()[::-1] cnt = s.count('1') p1 = sum(pow(2, i, cnt+1) * (s[i] == '1') for i in range(n)) if cnt > 1: m1 = sum(pow(2, i, cnt-1) * (s[i] == '1') for i in range(n)) def op(n): popcnt = bin(n).count('1') return n%popcnt pre = [0]*100000 for i in range(1,100000): pre[i] = pre[op(...
n = int(input()) s = input()[::-1] cnt = s.count('1') p1 = sum(pow(2, i, cnt+1) * (s[i] == '1') for i in range(n)) if cnt > 1: m1 = sum(pow(2, i, cnt-1) * (s[i] == '1') for i in range(n)) def op(n): popcnt = bin(n).count('1') return n%popcnt pre = [0]*1000000 for i in range(1,1000000): pre[i] = pre[o...
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 612], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 612]]
5
252
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define maxn 100005 #define Mod 1000000007 typedef pair<int, int> pii; typedef map<int, int> mii; typedef vector<int> vi; typedef vector<vector<int>> vii; typedef vector<long long> vll; typedef vector<bool> vb; typedef set<int> ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define maxn 100005 #define Mod 1000000007 typedef pair<int, int> pii; typedef map<int, int> mii; typedef vector<int> vi; typedef vector<vector<int>> vii; typedef vector<long long> vll; typedef vector<bool> vb; typedef set<int> ...
[["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
587
import collections memo = collections.defaultdict(int) memo[0] = 0 memo[1] = 1 def f(x): if x in memo: return memo[x] else: y = x % bin(x).count('1') ret = 1 + f(y) memo[x] = ret return ret N = int(input()) sX = input() modX = sX.count('1') if modX == 0: for _ in ...
import collections memo = collections.defaultdict(int) memo[0] = 0 memo[1] = 1 def f(x): if x in memo: return memo[x] else: y = x % bin(x).count('1') ret = 1 + f(y) memo[x] = ret return ret N = int(input()) sX = input() modX = sX.count('1') if modX == 0: for _ in ...
[["+", 0, 1, 0, 662, 31, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 662, 31, 206, 206, 657, 12, 612]]
5
382
#line 1 "D.cpp" #include <algorithm> #include <cstdio> #include <string> #include <vector> #line 1 "~/git/library/utility/io.cpp" /** * @brief 入出力 * @author えびちゃん */ #include <cctype> #include <cstddef> #include <iomanip> #include <iostream> #include <tuple> #include <utility> class format { public: using size...
#line 1 "D.cpp" #include <algorithm> #include <cstdio> #include <string> #include <vector> #line 1 "~/git/library/utility/io.cpp" /** * @brief 入出力 * @author えびちゃん */ #include <cctype> #include <cstddef> #include <iomanip> #include <iostream> #include <tuple> #include <utility> class format { public: using size...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
2,488
#include <bits/stdc++.h> using namespace std; using ll = long long; // pow2[0][j] = 2^i mod (popcnt(x)+1) // pow2[1][j] = 2^i mod (popcnt(x)-1) ただし popcnt(x)=0 のときは 0 constexpr int MAX_N = 200005; ll pow2[2][MAX_N] = {}; ll f[MAX_N] = {}; int main() { int n; string x; cin >> n >> x; // popcount(x) を計算する int p...
#include <bits/stdc++.h> using namespace std; using ll = long long; // pow2[0][j] = 2^i mod (popcnt(x)+1) // pow2[1][j] = 2^i mod (popcnt(x)-1) ただし popcnt(x)=0 のときは 0 constexpr int MAX_N = 200005; ll pow2[2][MAX_N] = {}; ll f[MAX_N] = {}; int main() { int n; string x; cin >> n >> x; // popcount(x) を計算する int p...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
484
#include <bits/stdc++.h> #include <functional> // for less #include <iostream> #define ll long long #define ull unsigned long long #define ld long double #define all(ar) ar.begin(), ar.end() #define mp make_pair #define sot(bello) bello.begin(), bello.end() #define bitc __builtin_popcountl #define fr(i, a, b) for (int ...
#include <bits/stdc++.h> #include <functional> // for less #include <iostream> #define ll long long #define ull unsigned long long #define ld long double #define all(ar) ar.begin(), ar.end() #define mp make_pair #define sot(bello) bello.begin(), bello.end() #define bitc __builtin_popcountl #define fr(i, a, b) for (int ...
[["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 64, 9, 0, 14, 8, 9, 0, 1, 0, 35]]
1
2,129
#include <bits/stdc++.h> using namespace std; constexpr long long power(long long b, long long e, long long mod) { long long ret = 1; while (e) { if (e & 1) { ret *= b; ret %= mod; } b *= b; b %= mod; e >>= 1; } return ret; } long long rec(int d, vector<long long> &f) { if...
#include <bits/stdc++.h> using namespace std; constexpr long long power(long long b, long long e, long long mod) { long long ret = 1; while (e) { if (e & 1) { ret *= b; ret %= mod; } b *= b; b %= mod; e >>= 1; } return ret; } long long rec(int d, vector<long long> &f) { if...
[["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 104]]
1
615
import sys n=int(input()) x=input() if n==1: if x=="0": print(1) else: print(0) sys.exit() lis=[0,1] for i in range(2,n+1): ni=i cnti=0 while ni!=0: if ni%2==1: cnti+=1 ni=ni//2 lis.append(lis[i%cnti]+1) cnt=0 for i in range(len(x)): if x...
import sys n=int(input()) x=input() if n==1: if x=="0": print(1) else: print(0) sys.exit() lis=[0,1] for i in range(2,n+1): ni=i cnti=0 while ni!=0: if ni%2==1: cnti+=1 ni=ni//2 lis.append(lis[i%cnti]+1) cnt=0 for i in range(len(x)): if x...
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 102]]
5
340
#include <bits/stdc++.h> using namespace std; using i64 = long long; #define rep(i, s, e) for (i64(i) = (s); (i) < (e); (i)++) #define all(x) x.begin(), x.end() #define STRINGIFY(n) #n #define TOSTRING(n) STRINGIFY(n) #define PREFIX "#" TOSTRING(__LINE__) "| " #define debug(x) ...
#include <bits/stdc++.h> using namespace std; using i64 = long long; #define rep(i, s, e) for (i64(i) = (s); (i) < (e); (i)++) #define all(x) x.begin(), x.end() #define STRINGIFY(n) #n #define TOSTRING(n) STRINGIFY(n) #define PREFIX "#" TOSTRING(__LINE__) "| " #define debug(x) ...
[["-", 8, 9, 0, 57, 64, 9, 0, 43, 39, 78]]
1
937
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++) #define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) RFOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define bra(first, second) '(' << fi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++) #define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) RFOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define bra(first, second) '(' << fi...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79]]
1
577
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second #define lll long long #define llf __float128 #define lld long double using namespace std; const int NR = 2e5 + 20, oo = 1e5 + 10, MOD = 1e9 + 7; const long double pi = 2 * acos(0.0); int ans[NR], bits, bits_plus, bits...
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second #define lll long long #define llf __float128 #define lld long double using namespace std; const int NR = 2e5 + 20, oo = 1e5 + 10, MOD = 1e9 + 7; const long double pi = 2 * acos(0.0); int ans[NR], bits, bits_plus, bits...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
592
#include <bits/stdc++.h> using namespace std; #define lli long long #define all(i) i.begin(), i.end() #define rall(i) i.rbegin(), i.rend() #define rep0(i, j) for (int i = 0; i < j; i++) #define rep1(i, j) for (int i = 1; i <= j; i++) #define rep0d(i, j) for (int i = j - 1; i >= 0; i--) #define MOD 1000000007 #define M...
#include <bits/stdc++.h> using namespace std; #define lli long long #define all(i) i.begin(), i.end() #define rall(i) i.rbegin(), i.rend() #define rep0(i, j) for (int i = 0; i < j; i++) #define rep1(i, j) for (int i = 1; i <= j; i++) #define rep0d(i, j) for (int i = j - 1; i >= 0; i--) #define MOD 1000000007 #define M...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
1,737
#include "bits/stdc++.h" using namespace std; const auto start_time = std::chrono::high_resolution_clock::now(); void timecalculater() { #ifndef ONLINE_JUDGE auto end_time = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> diff = end_time - start_time; cerr << "Time Taken : " << diff.count...
#include "bits/stdc++.h" using namespace std; const auto start_time = std::chrono::high_resolution_clock::now(); void timecalculater() { #ifndef ONLINE_JUDGE auto end_time = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> diff = end_time - start_time; cerr << "Time Taken : " << diff.count...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
1,061
#include <iostream> #include <vector> using namespace std; int main() { int n; scanf("%d", &n); vector<int> ans(n); for (int i = 1; i < n; i++) { int b = 0, t = i; while (t) { b += (t & 1); t >>= 1; } if (i % b == 0) ans[i] = 1; else ans[i] = ans[i % b] + 1; } ...
#include <iostream> #include <vector> using namespace std; int main() { int n; scanf("%d", &n); vector<int> ans(n); for (int i = 1; i < n; i++) { int b = 0, t = i; while (t) { b += (t & 1); t >>= 1; } if (i % b == 0) ans[i] = 1; else ans[i] = ans[i % b] + 1; } ...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72]]
1
443
/* * ┌─┐ ┌─┐ + + * ┌──┘ ┴───────┘ ┴──┐++ * │ │ * │ ─── │++ + + + * ███████───███████ │+ * │ │+ * │ ─┴─ │ * │ │ * └───┐ ┌───┘ * │ │ * │ │ + + * │ │ Code...
/* * ┌─┐ ┌─┐ + + * ┌──┘ ┴───────┘ ┴──┐++ * │ │ * │ ─── │++ + + + * ███████───███████ │+ * │ │+ * │ ─┴─ │ * │ │ * └───┐ ┌───┘ * │ │ * │ │ + + * │ │ Code...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
1,087
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <bitset> #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #in...
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <bitset> #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #in...
[["+", 0, 34, 31, 11, 12, 16, 31, 16, 17, 72], ["+", 0, 34, 31, 11, 12, 16, 31, 16, 12, 22], ["+", 64, 1, 0, 34, 31, 11, 12, 16, 17, 33], ["+", 64, 1, 0, 34, 31, 11, 12, 16, 12, 13]]
1
809
#include <bits/stdc++.h> using namespace std; #define debug(n) cerr << #n << ':' << n << endl; #define dline cerr << __LINE__ << endl; using ll = long long; template <class T, class U> using P = pair<T, U>; template <class T> using Heap = priority_queue<T>; template <class T> using heaP = priority_queue<T, vector<T>...
#include <bits/stdc++.h> using namespace std; #define debug(n) cerr << #n << ':' << n << endl; #define dline cerr << __LINE__ << endl; using ll = long long; template <class T, class U> using P = pair<T, U>; template <class T> using Heap = priority_queue<T>; template <class T> using heaP = priority_queue<T, vector<T>...
[["+", 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
684
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; ll mod_pow(ll x, ll n, ll MOD) { //べき乗 ll ans = 1; x %= MOD; while (n != 0) { if (n & 1) ans = ans * x % MOD; x = x * x % MOD; n = n >> 1; } return ans % MOD; } int main() {...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; ll mod_pow(ll x, ll n, ll MOD) { //べき乗 ll ans = 1; x %= MOD; while (n != 0) { if (n & 1) ans = ans * x % MOD; x = x * x % MOD; n = n >> 1; } return ans % MOD; } int main() {...
[["+", 51, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 31, 23, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 12, 13], ["+", 31, 23, 0, 16, 31, 16, 12, 23, 0, 25]]
1
452
import sys,collections as cl,bisect as bs sys.setrecursionlimit(100000) input = sys.stdin.readline mod = 10**9+7 Max = sys.maxsize def l(): #intのlist return list(map(int,input().split())) def m(): #複数文字 return map(int,input().split()) def onem(): #Nとかの取得 return int(input()) def s(x): #圧縮 a = [] if len(x) == 0: r...
import sys,collections as cl,bisect as bs sys.setrecursionlimit(100000) input = sys.stdin.readline mod = 10**9+7 Max = sys.maxsize def l(): #intのlist return list(map(int,input().split())) def m(): #複数文字 return map(int,input().split()) def onem(): #Nとかの取得 return int(input()) def s(x): #圧縮 a = [] if len(x) == 0: r...
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
588
//ヘッダー #include <bits/stdc++.h> using namespace std; //型定義 typedef long long ll; //定数 const int INF = 1e+9; const int MOD = 1e+9 + 7; // REPマクロ #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define REP2(i, a, b) for (ll i = a; i < (ll)(b); i++) #define REPD2(i,...
//ヘッダー #include <bits/stdc++.h> using namespace std; //型定義 typedef long long ll; //定数 const int INF = 1e+9; const int MOD = 1e+9 + 7; // REPマクロ #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define REP2(i, a, b) for (ll i = a; i < (ll)(b); i++) #define REPD2(i,...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31...
1
729
#include <bits/stdc++.h> using namespace std; /////////////////////////////////////////// const long long int INF = 1LL << 60; const long long int Mod = 1000000007; using ll = long long int; using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using P = pair<int, int>; using PLL = pair<ll, ll...
#include <bits/stdc++.h> using namespace std; /////////////////////////////////////////// const long long int INF = 1LL << 60; const long long int Mod = 1000000007; using ll = long long int; using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using P = pair<int, int>; using PLL = pair<ll, ll...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
924
#include <bits/extc++.h> #include <bits/stdc++.h> using namespace std; using namespace __gnu_pbds; using vi = vector<int>; using ii = pair<int, int>; using vii = vector<ii>; using ll = long long; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #def...
#include <bits/extc++.h> #include <bits/stdc++.h> using namespace std; using namespace __gnu_pbds; using vi = vector<int>; using ii = pair<int, int>; using vii = vector<ii>; using ll = long long; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #def...
[["+", 8, 9, 0, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 8, 9, 0, 9, 0, 57, 64, 9, 0, 46]]
1
836
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ui unsigned int #define us unsigned short #define IOS ios_base::sync_with_stdio(0); #define INF LONG_MAX #define PI 3.1415926535897932384626 #define mp make_pair #define fi first #define se second #define pb push_b...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ui unsigned int #define us unsigned short #define IOS ios_base::sync_with_stdio(0); #define INF LONG_MAX #define PI 3.1415926535897932384626 #define mp make_pair #define fi first #define se second #define pb push_b...
[["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6]]
1
564
#include <bits/stdc++.h> #define ll long long int using namespace std; ll solve(ll x, map<ll, ll> &memo) { if (x == 0LL) return 0LL; if (memo.find(x) != memo.end()) { return memo.at(x); } ll p = 0; for (ll tmp = x; tmp > 0; tmp = tmp >> 1) { if (tmp & 1LL != 0LL) { ++p; } } if (p ...
#include <bits/stdc++.h> #define ll long long int using namespace std; ll solve(ll x, map<ll, ll> &memo) { if (x == 0LL) return 0LL; if (memo.find(x) != memo.end()) { return memo.at(x); } ll p = 0; for (ll tmp = x; tmp > 0; tmp = tmp >> 1) { if (tmp & 1LL != 0LL) { ++p; } } if (p ...
[["-", 64, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 64, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
1
501
#include <bits/stdc++.h> using namespace std; #define int long int mod; vector<int> ar; int expo(int a, int n) { if (n <= 0) return 1; if (n == 1) return a; int tmp = expo(a, n / 2); tmp = (tmp * tmp) % mod; if (n & 1) tmp = (tmp * a) % mod; return tmp; } signed main() { int n; cin >> n; a...
#include <bits/stdc++.h> using namespace std; #define int long int mod; vector<int> ar; int expo(int a, int n) { if (n <= 0) return 1; if (n == 1) return a; int tmp = expo(a, n / 2); tmp = (tmp * tmp) % mod; if (n & 1) tmp = (tmp * a) % mod; return tmp; } signed main() { int n; cin >> n; a...
[["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
546
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define FOR(i, l, r) for (i = l; i < r; i++) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define P pair<ll, ll> #define F first #define S second ll A = 0, B = 0, N, x; ll Q(ll &i, string &S, vector<ll> &F, vector<ll> &G) { if...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define FOR(i, l, r) for (i = l; i < r; i++) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define P pair<ll, ll> #define F first #define S second ll A = 0, B = 0, N, x; ll Q(ll &i, string &S, vector<ll> &F, vector<ll> &G) { if...
[["-", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125], ["+", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125]]
1
491
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; // *st.find_by_order(index), 0-based //...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; // *st.find_by_order(index), 0-based //...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
563
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (i = 0; i < n; ++i) #define all(v) v.begin(), v.end() using ll = long long; ll pow_mod(ll a, ll n, ll p) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % p; a = a * a % p; n >>= 1; } return res; } int main() { ll ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (i = 0; i < n; ++i) #define all(v) v.begin(), v.end() using ll = long long; ll pow_mod(ll a, ll n, ll p) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % p; a = a * a % p; n >>= 1; } return res; } int main() { ll ...
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 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
509
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> //...
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> //...
[["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13]]
1
695
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i, m, n) for (int i = m; i < n; i++) ll mod = 1e9 + 7; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; rep(i, 0, n) { cnt += s[i] - '0'; } if (cnt == 0) { rep(i, 0, n) { cout << 1 ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i, m, n) for (int i = m; i < n; i++) ll mod = 1e9 + 7; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; rep(i, 0, n) { cnt += s[i] - '0'; } if (cnt == 0) { rep(i, 0, n) { cout << 1 ...
[["-", 64, 9, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 64, 9, 0, 9, 0, 1, 0, 11, 31, 22]]
1
513
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll; #define pb push_back #define mp make_pair #define mod 1000000007 #define F first #define S second #d...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll; #define pb push_back #define mp make_pair #define mod 1000000007 #define F first #define S second #d...
[["-", 49, 50, 51, 16, 31, 23, 0, 16, 17, 72], ["+", 51, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 17, 72], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 12, 22]]
1
662
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define pb emplace_back #define eb emplace_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #defi...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define pb emplace_back #define eb emplace_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #defi...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
1,337
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> #define pb push_back #define vi vector<int> int f(int x) { int ans = 0; if (x == 0) return 0; while (x > 0) { x %= __builtin_popcount(x); ans++; } return ans; } signed main() { ios_base::sync_with_std...
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> #define pb push_back #define vi vector<int> int f(int x) { int ans = 0; if (x == 0) return 0; while (x > 0) { x %= __builtin_popcount(x); ans++; } return ans; } signed main() { ios_base::sync_with_s...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
468
#include <cmath> #include <iostream> #include <string> using namespace std; int main() { int N; cin >> N; string X; cin >> X; int help[N + 1]; for (int i = 0; i < N + 1; i++) help[i] = 0; for (int i = 0; i < N + 1; i++) { if (i == 0) continue; int count = 0; int a = 1; int b =...
#include <cmath> #include <iostream> #include <string> using namespace std; int main() { int N; cin >> N; string X; cin >> X; int help[N + 1]; for (int i = 0; i < N + 1; i++) help[i] = 0; for (int i = 0; i < N + 1; i++) { if (i == 0) continue; int count = 0; int a = 1; int b =...
[["-", 0, 57, 75, 76, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 75, 76, 0, 1, 0, 11, 12, 13]]
1
625
#include <bits/stdc++.h> using namespace std; #define LL long long #define F(i, a, b) for (int i = a; i <= b; ++i) const int maxn = 2e5 + 5; int n, a[maxn], pw1[maxn], pw2[maxn], f[maxn], sum1 = 0, sum2 = 0, tot = 0; char s[maxn]; int pct(int x) { return x == 0 ? x : pct(x >> 1) + (x & 1); } void run(int p) { a[p] ^=...
#include <bits/stdc++.h> using namespace std; #define LL long long #define F(i, a, b) for (int i = a; i <= b; ++i) const int maxn = 2e5 + 5; int n, a[maxn], pw1[maxn], pw2[maxn], f[maxn], sum1 = 0, sum2 = 0, tot = 0; char s[maxn]; int pct(int x) { return x == 0 ? x : pct(x >> 1) + (x & 1); } void run(int p) { a[p] ^=...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
517
#include <bits/stdc++.h> #define int long long #define ld long double #define ri register int #define il inline #define mk make_pair #define pb push_back #define fi first #define se second #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define all(x) x.begin(), x.end() #define rep(i, a, b) fo...
#include <bits/stdc++.h> #define int long long #define ld long double #define ri register int #define il inline #define mk make_pair #define pb push_back #define fi first #define se second #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define all(x) x.begin(), x.end() #define rep(i, a, b) fo...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
543
#include <bits/stdc++.h> using namespace std; int main() { int n; string x; cin >> n >> x; vector<int> r(2), p(2); for (auto e : x) p[0] += e == '1'; p[0]++; p[1] = p[0] - 2; for (auto e : x) { for (int i = 0; i < 2; i++) { if (p[i] == 0) continue; r[i] <<= 1; r[i] +=...
#include <bits/stdc++.h> using namespace std; int main() { int n; string x; cin >> n >> x; vector<int> r(2), p(2); for (auto e : x) p[0] += e == '1'; p[0]++; p[1] = p[0] - 2; for (auto e : x) { for (int i = 0; i < 2; i++) { if (p[i] == 0) continue; r[i] <<= 1; r[i] +=...
[["-", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
424
#include <bits/stdc++.h> #define LL long long #define dl double template <class T> void rd(T &x) { x = 0; T f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar(); x *= f; } ...
#include <bits/stdc++.h> #define LL long long #define dl double template <class T> void rd(T &x) { x = 0; T f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar(); x *= f; } ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 2, 3, 4, 0, 16, 31, 23, 0, 25], ["-", 64, 1, 0, 2, 3, 4, 0, 23, 0, 25]]
1
492
#!/usr/bin/env python3 ''' Author: andyli Time: 2020-07-11 19:58:49 ''' import os from io import BytesIO, IOBase import sys def main(): n = int(input()) x = input() popcounts = x.count('1') if popcounts == 1: for i in range(n): if x[i] == 1: print(0) ...
#!/usr/bin/env python3 ''' Author: andyli Time: 2020-07-11 19:58:49 ''' import os from io import BytesIO, IOBase import sys def main(): n = int(input()) x = input() popcounts = x.count('1') if popcounts == 1: for i in range(n): if x[i] == '1': print(0) ...
[["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 654], ["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 655]]
5
993
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repi(i, a, b) for (ll i = (a); i < (b); ++i) #define rep(i, a) repi(i, 0, ...
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repi(i, a, b) for (ll i = (a); i < (b); ++i) #define rep(i, a) repi(i, 0, ...
[["+", 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, 72], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 7, 8, 57, 15, 339, 0, 25]]
1
883