buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <bits/stdc++.h> 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++) int main() { int n; cin >> n; vector<int> a(1010); rep2(i, 1, 100) { rep2(j, 1, 100) { rep2(k, 1, 100) { if (i * i + j * j + k * k + i ...
#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++) int main() { int n; cin >> n; vector<int> a(10010); rep2(i, 1, 100) { rep2(j, 1, 100) { rep2(k, 1, 100) { if (i * i + j * j + k * k + i...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
159
N = int(input()) d={} for a in range(100): for b in range(100): z=(a+1)**2+(b+1)**2+(a+1)*(b+1) for c in range(100): gokei=z+(c+a+3+b)*(c+1) if gokei in d: d[gokei]+=1 else: d[gokei]=1 for i in range(N): if i in d: print(d[i]) else: print(0)
N = int(input()) d={} for a in range(100): for b in range(100): z=(a+1)**2+(b+1)**2+(a+1)*(b+1) for c in range(100): gokei=z+(c+a+3+b)*(c+1) if gokei in d: d[gokei]+=1 else: d[gokei]=1 for i in range(N): if i+1 in d: print(d[i+1]) else: print(0)
[["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 72], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["+", 0, 652, 3, 4, 0, 206, 206, 657, 17, 72], ["+", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]]
5
129
n = int(input()) x = int(n**0.5)+1 cnt = [0]*(n+1) for i in range(1,x): for j in range(1,x): for k in range(1,x): res = i**2+j**2+k**2+i*j+j*k+k*i if res < n: cnt[res] += 1 for i in range(1,n+1): print(cnt[i])
n = int(input()) x = int(n**0.5)+1 cnt = [0]*(n+1) for i in range(1,x): for j in range(1,x): for k in range(1,x): res = i**2+j**2+k**2+i*j+j*k+k*i if res <= n: cnt[res] += 1 for i in range(1,n+1): print(cnt[i])
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19]]
5
114
/* ID: alec3 LANG: C++14 PROG: pprime CLASSIFICATION: brute force */ #include <bits/stdc++.h> #define check(x) cout << (#x) << ": " << x << " "; #define io \ ios_base::sync_with_stdio(0); \ cin.tie(0)...
/* ID: alec3 LANG: C++14 PROG: pprime CLASSIFICATION: brute force */ #include <bits/stdc++.h> #define check(x) cout << (#x) << ": " << x << " "; #define io \ ios_base::sync_with_stdio(0); \ cin.tie(0)...
[["+", 0, 43, 49, 50, 49, 80, 81, 16, 17, 72], ["+", 0, 43, 49, 50, 49, 80, 81, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
277
n = gets.to_i ans = Array.new(n,0) for i in 1..100 for j in 1..100 for k in 1..100 x = i**2 + j**2 + k**2 + i*j + j*k + k*i if x >= 1 && x <= n ans[x] += 1 end end end end puts ans
n = gets.to_i ans = Array.new(n,0) for i in 1..100 for j in 1..100 for k in 1..100 x = i**2 + j**2 + k**2 + i*j + j*k + k*i if x >= 1 && x <= n ans[x-1] += 1 end end end end puts ans
[["+", 64, 749, 0, 755, 31, 742, 0, 738, 17, 33], ["+", 64, 749, 0, 755, 31, 742, 0, 738, 12, 612]]
4
78
#include <bits/stdc++.h> #include <math.h> using namespace std; long long inf = 1000000007; int main() { long long n; cin >> n; vector<long long> num(n + 1, 0); for (long long i = 1; i + i <= n; i++) { for (long long j = 1; j * j <= n; j++) { long long hoge = i * i + j * j + i * j; long long...
#include <bits/stdc++.h> #include <math.h> using namespace std; long long inf = 1000000007; int main() { long long n; cin >> n; vector<long long> num(n + 1, 0); for (long long i = 1; i + i <= n; i++) { for (long long j = 1; j * j <= n; j++) { long long hoge = i * i + j * j + i * j; long long...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
243
#include <bits/stdc++.h> using namespace std; #define sint(a) scanf("%d", &a) #define sint2(a, b) scanf("%d %d", &a, &b) #define sll(a) scanf("%lld", &a) #define sll2(a, b) scanf("%lld %lld", &a, &b) #define mem(a, i) memset(a, i, sizeof(a)) #define pb push_back #define ll long long #define lson node << 1 #define rson...
#include <bits/stdc++.h> using namespace std; #define sint(a) scanf("%d", &a) #define sint2(a, b) scanf("%d %d", &a, &b) #define sll(a) scanf("%lld", &a) #define sll2(a, b) scanf("%lld %lld", &a, &b) #define mem(a, i) memset(a, i, sizeof(a)) #define pb push_back #define ll long long #define lson node << 1 #define rson...
[["-", 15, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["+", 8, 7, 15, 16, 31, 16, 31, 16, 17, 72], ["-", 8, 7, 8, 57, 64, 9, 0, 43, 39, 40], ["+", 8, 7, 8, 57, 64, 9, 0, 43, 39, 78]]
1
251
def solve(n): li = [0] * (n ** 3 + 1) for x in range(1, n + 1): for y in range(1, n + 1): for z in range(1, n + 1): li[x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x] += 1 return li N = int(input()) ans = solve(50) [print(ans[i]) for i in range(1, N + 1)]
def solve(n): li = [0] * (n ** 3 + 1) for x in range(1, n + 1): for y in range(1, n + 1): for z in range(1, n + 1): li[x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x] += 1 return li N = int(input()) ans = solve(100) [print(ans[i]) for i in range(1, N + 1)]
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
119
N = int(input()) N_list = [0]*(N+1) for i in range(1,11): for j in range(1,11): for k in range(1,11): if(i**2+j**2+k**2+i*j+j*k+k*i<=N): N_list[i**2+j**2+k**2+i*j+j*k+k*i]+=1 for i in N_list[1:]: print(i)
N = int(input()) N_list = [0]*(N+1) for i in range(1,101): for j in range(1,101): for k in range(1,101): if(i**2+j**2+k**2+i*j+j*k+k*i<=N): N_list[i**2+j**2+k**2+i*j+j*k+k*i]+=1 for i in N_list[1:]: print(i)
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
119
/* Ujjawal Pabreja [cuber_coder] */ #include <bits/stdc++.h> #include <functional> using namespace std; #define speed_cubing \ ios_base::sync_with_stdio(false); \ cin.tie(0); ...
/* Ujjawal Pabreja [cuber_coder] */ #include <bits/stdc++.h> #include <functional> using namespace std; #define speed_cubing \ ios_base::sync_with_stdio(false); \ cin.tie(0); ...
[["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
551
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define REP(i, a) for (int i = 0; i < (a); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, a, b) for (int i = (a); i >= (b); --i) #define ALL(obj) (obj)....
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define REP(i, a) for (int i = 0; i < (a); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, a, b) for (int i = (a); i >= (b); --i) #define ALL(obj) (obj)....
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
187
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using ULL = unsigned long long; using LL = long long; using String = std::string; using Ints = std::vector<int>; ...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using ULL = unsigned long long; using LL = long long; using String = std::string; using Ints = std::vector<int>; ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
290
/// Nahid Hasan Raju #include <bits/stdc++.h> #define MS(ARRAY, VALUE) memset(ARRAY, VALUE, sizeof(ARRAY)) #define Fin freopen("input.txt", "r", stdin) #define FAST \ ios_base::sync_with_stdio(false); \ cin...
/// Nahid Hasan Raju #include <bits/stdc++.h> #define MS(ARRAY, VALUE) memset(ARRAY, VALUE, sizeof(ARRAY)) #define Fin freopen("input.txt", "r", stdin) #define FAST \ ios_base::sync_with_stdio(false); \ cin...
[["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
429
from collections import defaultdict N = int(input()) def fun(x, y, z): return x**2 + y**2 + z**2 + x*y + y*z + z*x res = defaultdict(int) for x in range(1, 50): for y in range(1, 50): for z in range(1, 50): res[fun(x, y, z)] += 1 for n in range(1, N+1): print(res[n])
from collections import defaultdict N = int(input()) def fun(x, y, z): return x**2 + y**2 + z**2 + x*y + y*z + z*x res = defaultdict(int) for x in range(1, 100): for y in range(1, 100): for z in range(1, 100): res[fun(x, y, z)] += 1 for n in range(1, N+1): print(res[n])
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
114
#include <bits/stdc++.h> // definitions #define __Imperial_Lord__ \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define _cps CLOCKS_P...
#include <bits/stdc++.h> // definitions #define __Imperial_Lord__ \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define _cps CLOCKS_P...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 52, 8, 9, 0, 9, 0, 45], ["-", 8, 9, 0, 52, 8, 9, 0, 9, 0, 46]]
1
467
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pull = pair<ull, ll>; using pis = pair<int, string>; #define INF 1000000000 #define LLINF 10000000000000000ll #define MOD 1000000007LL int main() { cin.tie(0...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pull = pair<ull, ll>; using pis = pair<int, string>; #define INF 1000000000 #define LLINF 10000000000000000ll #define MOD 1000000007LL int main() { cin.tie(0...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
220
from collections import defaultdict,deque from sys import stdin,setrecursionlimit import heapq,bisect,math,itertools,string,queue,copy setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inpl(): return list(map(int, stdin.readline().split())) N = int(input()) d = [0]*(10**6 + 1) for x in range...
from collections import defaultdict,deque from sys import stdin,setrecursionlimit import heapq,bisect,math,itertools,string,queue,copy setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inpl(): return list(map(int, stdin.readline().split())) N = int(input()) d = [0]*(10**6 + 1) for x in range...
[["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21]]
5
171
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, const T &b...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, const T &b...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
257
// author-Shivam gupta #include <bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, (b), sizeof(a)) #define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++) #define IN(A, B, C) assert(B <= A && A <= C) #define MP make_pair #define FOR(i, a) for (int i = 0; i < a; i++) #define FOR1(i, j...
// author-Shivam gupta #include <bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, (b), sizeof(a)) #define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++) #define IN(A, B, C) assert(B <= A && A <= C) #define MP make_pair #define FOR(i, a) for (int i = 0; i < a; i++) #define FOR1(i, j...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
246
#include <algorithm> #include <bits/stdc++.h> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #includ...
#include <algorithm> #include <bits/stdc++.h> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #includ...
[["+", 0, 57, 64, 9, 0, 57, 75, 76, 0, 95], ["+", 64, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 46]]
1
1,272
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define ff first #define ss second #define ll long long #define ll_MAX LONG_LONG_MAX #define ll_MIN LONG_LONG_MIN #define pi pair<int, int> #define endl "\n" #define MAXN 100005 using namespace std; int n; map<int, int> m; void solve() { cin >> n; ...
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define ff first #define ss second #define ll long long #define ll_MAX LONG_LONG_MAX #define ll_MIN LONG_LONG_MIN #define pi pair<int, int> #define endl "\n" #define MAXN 100005 using namespace std; int n; map<int, int> m; void solve() { cin >> n; ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
198
def main(): import sys N=int(sys.stdin.readline()) L=[0]*(10**4+1) for x in range(1,1000): for y in range(x,1000): for z in range(y,1000): r=x**2+y**2+z**2+x*y+y*z+z*x if r>10**4: break c=len(set((x,...
def main(): import sys N=int(sys.stdin.readline()) L=[0]*(10**4+1) for x in range(1,1000): for y in range(x,1000): for z in range(y,1000): r=x**2+y**2+z**2+x*y+y*z+z*x if r>10**4: break c=len(set((x,...
[["+", 0, 7, 12, 206, 206, 663, 0, 657, 17, 72], ["+", 0, 7, 12, 206, 206, 663, 0, 657, 12, 612]]
5
160
import java.io.*; // import java.io.BufferedReader; // import java.io.IOException; // import java.io.InputStreamReader; // import java.util.ArrayList; // import java.util.Arrays; // import java.util.Collections; // import java.util.List; // import java.util.HashSet; // import java.util.Set; // import java.util.Map; // ...
import java.io.*; // import java.io.BufferedReader; // import java.io.IOException; // import java.io.InputStreamReader; // import java.util.ArrayList; // import java.util.Arrays; // import java.util.Collections; // import java.util.List; // import java.util.HashSet; // import java.util.Set; // import java.util.Map; // ...
[["-", 0, 246, 8, 196, 0, 503, 39, 506, 0, 96], ["-", 0, 246, 8, 196, 0, 503, 49, 200, 141, 22], ["-", 0, 246, 8, 196, 0, 503, 49, 200, 0, 32], ["-", 0, 246, 8, 196, 0, 503, 49, 200, 51, 499], ["-", 8, 196, 0, 246, 8, 196, 0, 503, 0, 35], ["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 15, 0, 16, ...
3
663
#pragma GCC optimize("Ofast") #define _GLIBCXX_DEBUG #include <bits/stdc++.h> 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++) #define rep2(i, n) for (int i = 0; i <= n; i++) #define repr(i, a, n) for (int i = a; i < n; i++) #define...
#pragma GCC optimize("Ofast") #define _GLIBCXX_DEBUG #include <bits/stdc++.h> 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++) #define rep2(i, n) for (int i = 0; i <= n; i++) #define repr(i, a, n) for (int i = a; i < n; i++) #define...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
994
// #include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define rep(i, x, y) for (ll i = x; i < y; i++) #define nvarep(n, a) \ ll n; \ cin >> n; ...
// #include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define rep(i, x, y) for (ll i = x; i < y; i++) #define nvarep(n, a) \ ll n; \ cin >> n; ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
222
#include <bits/stdc++.h> using namespace std; // T+N //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #define endl "\n" typedef long long ll; typedef long double ld; typedef unsigned long long ull; template <class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template ...
#include <bits/stdc++.h> using namespace std; // T+N //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #define endl "\n" typedef long long ll; typedef long double ld; typedef unsigned long long ull; template <class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template ...
[["+", 0, 30, 0, 43, 49, 80, 81, 16, 17, 48], ["+", 0, 30, 0, 43, 49, 80, 81, 16, 12, 22]]
1
301
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; const double PI = 3.1415926535897932; /* a と b の最大公約数を返す...
#include <algorithm> #include <cmath> #include <iostream> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; const double PI = 3.1415926535897932; /* a と b の最大公約数を返す...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
221
#include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<int, int>; #define Rep(i, n) for (int i = 0; i < (int)(n); i++) #define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++) #define All(vec) vec.begin(), vec.end() #define Sum(vec) accumulate(vec.begin(), vec.end(), 0) #define Sort(vec)...
#include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<int, int>; #define Rep(i, n) for (int i = 0; i < (int)(n); i++) #define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++) #define All(vec) vec.begin(), vec.end() #define Sum(vec) accumulate(vec.begin(), vec.end(), 0) #define Sort(vec)...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
216
#include <algorithm> #include <cmath> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; double pie = 3.14159265358979; long long mod = 10...
#include <algorithm> #include <cmath> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; double pie = 3.14159265358979; long long mod = 10...
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
1
202
n = int(input()) x = input() f = [-1] * (n+10) f[0] = 0 for i in range(1, n+10): # python bitcount で見つけたこれを参考に https://ameblo.jp/316228/entry-10518720149.html f[i] = f[i % bin(i).count('1')] + 1 init_bitcount = x.count('1') # Xを init_bitcount+1とinit_bitcount-1で割った余り x_mod_01 = 0 x_mod_10 = 0 for digit in x:...
n = int(input()) x = input() f = [-1] * (n+10) f[0] = 0 for i in range(1, n+10): # python bitcount で見つけたこれを参考に https://ameblo.jp/316228/entry-10518720149.html f[i] = f[i % bin(i).count('1')] + 1 init_bitcount = x.count('1') # Xを init_bitcount+1とinit_bitcount-1で割った余り x_mod_01 = 0 x_mod_10 = 0 for digit in x:...
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
321
'''Author- Akshit Monga''' n=int(input()) x=input() x=x[::-1] ans1=0 ans2=0 c=x.count('1') for i in range(0,n): if x[i]: ans1=(ans1+pow(2,i,c+1))%(c+1) if c!=1: ans2=(ans2+pow(2,i,c-1))%(c-1) to_print=[] for i in range(0,n): if x[i]=='1': if c==1: to_print.append(...
'''Author- Akshit Monga''' n=int(input()) x=input() x=x[::-1] ans1=0 ans2=0 c=x.count('1') for i in range(0,n): if x[i]=='1': ans1=(ans1+pow(2,i,c+1))%(c+1) if c!=1: ans2=(ans2+pow(2,i,c-1))%(c-1) to_print=[] for i in range(0,n): if x[i]=='1': if c==1: to_print.ap...
[["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 60], ["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 654], ["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 6], ["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 655]]
5
278
// include //------------------------------------------ #include <bits/stdc++.h> using namespace std; // typedef //------------------------------------------ using LL = int64_t; using VL = vector<LL>; using VVL = vector<VL>; using VS = vector<string>; using PLL = pair<LL, LL>; // container util //--------------------...
// include //------------------------------------------ #include <bits/stdc++.h> using namespace std; // typedef //------------------------------------------ using LL = int64_t; using VL = vector<LL>; using VVL = vector<VL>; using VS = vector<string>; using PLL = pair<LL, LL>; // container util //--------------------...
[["+", 75, 76, 0, 9, 0, 7, 8, 9, 0, 46], ["-", 75, 76, 0, 9, 0, 7, 8, 9, 0, 46]]
1
1,564
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int f[N], ans[N]; char s[N]; int main() { int n, sum = 0, s1, s2, sum1 = 0, sum2 = 0, d1 = 1, d2 = 1; scanf("%d%s", &n, s); for (int i = 0; s[i]; i++) sum += (s[i] ^= 0x30); s1 = sum - 1, s2 = sum + 1; f[0] = 1; for (int i = 1; i <= s2...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int f[N], ans[N]; char s[N]; int main() { int n, sum = 0, s1, s2, sum1 = 0, sum2 = 0, d1 = 1, d2 = 1; scanf("%d%s", &n, s); for (int i = 0; s[i]; i++) sum += (s[i] ^= 0x30); s1 = sum - 1, s2 = sum + 1; f[0] = 1; for (int i = 1; i <= s2...
[["-", 0, 7, 8, 9, 0, 1, 0, 34, 0, 21], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 51, 22], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25]]
1
365
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i) #define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i) #define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--) #define rreps(i, n)...
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i) #define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i) #define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--) #define rreps(i, n)...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 51, 22], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25]]
1
805
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; #define rep(a, n) for (ll a = 0; a < n; a++) static const ll INF = 1e18; template <t...
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; #define rep(a, n) for (ll a = 0; a < n; a++) static const ll INF = 1e18; template <t...
[["-", 0, 43, 49, 50, 51, 16, 12, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 16, 12, 2, 63, 22], ["-", 0, 338, 8, 9, 0, 57, 15, 339, 51, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
717
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(ri, n) for (int ri = (int)(n - 1); ri >= 0; ri--) #define rep2(i, x, n) for (int i = (int)(x); i < (int)(n); i++) #define rrep2(ri, x, n) for (int ri = (int)(n - 1); ri >= (int)(x); ri--) #define repit(itr, x) for (auto itr = x.b...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(ri, n) for (int ri = (int)(n - 1); ri >= 0; ri--) #define rep2(i, x, n) for (int i = (int)(x); i < (int)(n); i++) #define rrep2(ri, x, n) for (int ri = (int)(n - 1); ri >= (int)(x); ri--) #define repit(itr, x) for (auto itr = x.b...
[["-", 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, 116, 0, 117]]
1
677
N=int(input()) X=input() num_X = int(X, base=2) pop_x = X.count("1") if pop_x <= 1: mod0 = pop_x + 1 res0 = num_X % mod0 else: mod1 = pop_x - 1 mod0 = pop_x + 1 res1 = num_X % (mod1) res0 = num_X % (mod0) # pops = [0]*(N+20) for i in range(N): tmp = 0 if X[i] == "0": # + ...
N=int(input()) X=input() num_X = int(X, base=2) pop_x = X.count("1") if pop_x <= 1: mod0 = pop_x + 1 res0 = num_X % mod0 else: mod1 = pop_x - 1 mod0 = pop_x + 1 res1 = num_X % (mod1) res0 = num_X % (mod0) # pops = [0]*(N+20) for i in range(N): tmp = 0 if X[i] == "0": # + ...
[["-", 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, 0, 57, 64, 196, 0, 116, 0, 117]]
5
192
gets; k = gets.strip c = k.count('1') ki = k.to_i(2) kr = k.reverse df1, df2 = ki % (c+1), (c == 1 ? 0 : ki % (c-1)) t1, t2 = 1, -1 def calc(x) ret = 1 while x != 0 ret += 1 x %= x.to_s(2).count('1') end return ret end kr.chars.map{|i| ans = 0 if i == '0' ans = calc((df1+t1+c+1) % (c+1)) elsif c == 1 an...
gets; k = gets.strip c = k.count('1') ki = k.to_i(2) kr = k.reverse df1, df2 = ki % (c+1), (c == 1 ? 0 : ki % (c-1)) t1, t2 = 1, -1 def calc(x) ret = 1 while x != 0 ret += 1 x %= x.to_s(2).count('1') end return ret end kr.chars.map{|i| ans = 0 if i == '0' ans = calc((df1+t1+c+1) % (c+1)) elsif c == 1 an...
[["-", 0, 121, 75, 759, 64, 749, 0, 662, 12, 612], ["+", 0, 121, 75, 759, 64, 749, 0, 662, 12, 612]]
4
205
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator impor...
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator impor...
[["-", 0, 662, 12, 657, 31, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 17, 33]]
5
409
# -*- coding: utf-8 -*- N = int(input()) X = input() X_10 = int(X, 2) popcount_X = X.count("1") popcount_X_plus = popcount_X + 1 popcount_X_minus = popcount_X - 1 f_plus = X_10 % popcount_X_plus f_minus = X_10 % popcount_X_minus if popcount_X_minus != 0 else 0 def popcount(n): return bin(n).count("1") def f(n): i...
# -*- coding: utf-8 -*- N = int(input()) X = input() X_10 = int(X, 2) popcount_X = X.count("1") popcount_X_plus = popcount_X + 1 popcount_X_minus = popcount_X - 1 f_plus = X_10 % popcount_X_plus f_minus = X_10 % popcount_X_minus if popcount_X_minus != 0 else 0 def popcount(n): return bin(n).count("1") def f(n): i...
[["-", 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, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 12, 657, 31, 23, 0, 657, 31, 657, 31, 22], ["+...
5
195
#include <algorithm> #include <climits> #include <cmath> #include <cstdint> #include <cstdlib> #include <ctime> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <random> #include <stdio.h> #include <string> #include <tuple> #include <vector> using name...
#include <algorithm> #include <climits> #include <cmath> #include <cstdint> #include <cstdlib> #include <ctime> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <random> #include <stdio.h> #include <string> #include <tuple> #include <vector> using name...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 176], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 33...
1
1,339
def pop_count(n): return sum(n >> i & 1 for i in range(n.bit_length())) def f(n): if n == 0: return 0 return f(n % pop_count(n)) + 1 N = int(input()) X = input() p = X.count("1") rem_plus = 0 rem_minus = 0 for i in range(N): k = N - i - 1 if X[i] == "0": continue elif p > 1: ...
def pop_count(n): return sum(n >> i & 1 for i in range(n.bit_length())) def f(n): if n == 0: return 0 return f(n % pop_count(n)) + 1 N = int(input()) X = input() p = X.count("1") rem_plus = 0 rem_minus = 0 for i in range(N): k = N - i - 1 if X[i] == "0": continue elif p > 1: ...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21]]
5
251
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() #define SZ(x) ((int)(x).size()) using ll = long long; using ull = unsigned long long; using P = pair<int, int>; using llP = pair<ll, ll>; using DoP ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() #define SZ(x) ((int)(x).size()) using ll = long long; using ull = unsigned long long; using P = pair<int, int>; using llP = pair<ll, ll>; using DoP ...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
1,082
#include <bits/stdc++.h> using namespace std; typedef int64_t Int; #define all(x) (x).begin(), (x).end() const double EPS = 1e-10; const Int INF = 1e18; const int inf = 1e9; const Int mod = 1e9 + 7; bool print_space_enable = false; void print() { cout << '\n'; print_space_enable = false; } template <class Head,...
#include <bits/stdc++.h> using namespace std; typedef int64_t Int; #define all(x) (x).begin(), (x).end() const double EPS = 1e-10; const Int INF = 1e18; const int inf = 1e9; const Int mod = 1e9 + 7; bool print_space_enable = false; void print() { cout << '\n'; print_space_enable = false; } template <class Head,...
[["+", 64, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
625
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; #define mp make_pair #define pb push_back #define f first #define s second // var int c1[200005], n, ar[200005], p2[200005][2], t1c = 0, vl[2]; char cc; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> ...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; #define mp make_pair #define pb push_back #define f first #define s second // var int c1[200005], n, ar[200005], p2[200005][2], t1c = 0, vl[2]; char cc; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> ...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
566
// includes #include <bits/stdc++.h> using namespace std; // macros #define pb emplace_back #define mk make_pair #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define irep(itr, st) for (auto itr = (st).begin(); itr != (st)...
// includes #include <bits/stdc++.h> using namespace std; // macros #define pb emplace_back #define mk make_pair #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define irep(itr, st) for (auto itr = (st).begin(); itr != (st)...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
1,411
N=int(input()) X=input() a=int(X,2) def popcount(x): return bin(x).count("1") p=X.count('1') pl=a%(p+1) if popcount!=1: mi=a%(p-1) def f(x): if x==0: return 1 else: return f(x%popcount(x))+1 for i in range(N): if X[i]=='0': b=pl b+=pow(2,N-i-1,p+1) b%=p+1 else: if popcount(a)!=1: ...
N=int(input()) X=input() a=int(X,2) def popcount(x): return bin(x).count("1") p=X.count('1') pl=a%(p+1) if p!=1: mi=a%(p-1) def f(x): if x==0: return 1 else: return f(x%popcount(x))+1 for i in range(N): if X[i]=='0': b=pl b+=pow(2,N-i-1,p+1) b%=p+1 else: if p!=1: b=mi ...
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 8, 196, 0, 57, 15, 666, 0, 652, 63, 22], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 22], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["+", 75, 76, 8, 196, 0, 57, 15, 666, 0, 22]]
5
189
#include <bits/stdc++.h> #define PI 3.14159265358979323846 #define MAXINF (1e18L) #define INF (1e9L) #define EPS (1e-9) #define MOD ((ll)(1e9 + 7)) #define REP(i, n) for (int i = 0; i < int(n); ++i) #define REPA(x, v) for (auto &&x : v) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define RREP(i, n) for (int i ...
#include <bits/stdc++.h> #define PI 3.14159265358979323846 #define MAXINF (1e18L) #define INF (1e9L) #define EPS (1e-9) #define MOD ((ll)(1e9 + 7)) #define REP(i, n) for (int i = 0; i < int(n); ++i) #define REPA(x, v) for (auto &&x : v) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define RREP(i, n) for (int i ...
[["-", 8, 9, 0, 43, 49, 53, 54, 55, 0, 24], ["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 8, 9, 0, 43, 49, 53, 54, 55, 0, 25], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
819
#include <bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define vi vector<ll> #define vvi vector<vi> #define BITLE(n) (1LL << ((ll)n)) #define SUBS(s, f, t) ((s).substr((f), (t) - (f))) #define ALL...
#include <bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define vi vector<ll> #define vvi vector<vi> #define BITLE(n) (1LL << ((ll)n)) #define SUBS(s, f, t) ((s).substr((f), (t) - (f))) #define ALL...
[["-", 64, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 31, 22]]
1
465
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int inf = 1001001001; int pcnt(int n) { return __builtin_popcount(n); } int f(int n) { if (n == 0) return 0; return f(n % pcnt(n)) + 1; } int main() { int n; string s; cin >> n >> s...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int inf = 1001001001; int pcnt(int n) { return __builtin_popcount(n); } int f(int n) { if (n == 0) return 0; return f(n % pcnt(n)) + 1; } int main() { int n; string s; cin >> n >> s...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
328
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template <class T> void debug(T itr1, T itr2) { auto now = itr1; while (now < itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i, from, to) for (ll i = (ll)from; i < (ll)to; i++) #define al...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template <class T> void debug(T itr1, T itr2) { auto now = itr1; while (now < itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i, from, to) for (ll i = (ll)from; i < (ll)to; i++) #define al...
[["-", 51, 16, 31, 16, 31, 69, 341, 342, 0, 13], ["+", 51, 16, 31, 16, 31, 69, 341, 342, 0, 22]]
1
772
#include <bits/stdc++.h> using namespace std; int main() { int N, o = 0, n, c, p, t, a = 0, b = 0; cin >> N; int A[N], B[N], s = N - 1, X[N]; A[0] = 1; B[0] = 1; char x; for (int i = 0; i < N; i++) { cin >> x; X[i] = x - 48; o += X[i]; } for (int i = 1; i < N; i++) A[i] = A[i - 1] * 2 ...
#include <bits/stdc++.h> using namespace std; int main() { int N, o = 0, n, c, p, t, a = 0, b = 0; cin >> N; int A[N], B[N], s = N - 1, X[N]; A[0] = 1; B[0] = 1; char x; for (int i = 0; i < N; i++) { cin >> x; X[i] = x - 48; o += X[i]; } for (int i = 1; i < N; i++) A[i] = A[i - 1] * 2 ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 67], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
429
def popcnt_int(n): # n:int return bin(n).count('1') def popcnt_bin(s): # s:str return s.count('1') def poptimes(n, cnt=1): #:int if n==0: return cnt else: n %= popcnt_int(n) cnt += 1 return poptimes(n, cnt) n = int(input()) s = input() s_int = int(s,2) pc = popcnt_bin...
def popcnt_int(n): # n:int return bin(n).count('1') def popcnt_bin(s): # s:str return s.count('1') def poptimes(n, cnt=1): #:int, popcntのcounter if n==0: return cnt else: n %= popcnt_int(n) cnt += 1 return poptimes(n, cnt) n = int(input()) s = input() #これが直接処理し難い大きさ → ...
[["+", 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
211
def popcnt_int(n): # n:int return bin(n).count('1') def popcnt_bin(s): # s:str return s.count('1') def poptimes(n, cnt=1): #:int if n==0: return cnt else: n %= popcnt_int(n) cnt += 1 return poptimes(n, cnt) n = int(input()) s = input() s_int = int(s,2) pc = popcnt_bin...
def popcnt_int(n): # n:int return bin(n).count('1') def popcnt_bin(s): # s:str return s.count('1') def poptimes(n, cnt=1): #:int if n==0: return cnt else: n %= popcnt_int(n) cnt += 1 return poptimes(n, cnt) n = int(input()) s = input() s_int = int(s,2) pc = popcnt_bin...
[["+", 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
211
#include <bits/stdc++.h> using namespace std; int getPopcount(const string &X) { int cnt = 0; for (char ch : X) cnt += (ch == '1') ? 1 : 0; return cnt; } int getPopcount(int X) { int cnt = 0; while (X > 0) { cnt += (X & 1); X = X >> 1; } return cnt; } int pow(long long base, long long p, lo...
#include <bits/stdc++.h> using namespace std; int getPopcount(const string &X) { int cnt = 0; for (char ch : X) cnt += (ch == '1') ? 1 : 0; return cnt; } int getPopcount(int X) { int cnt = 0; while (X > 0) { cnt += (X & 1); X = X >> 1; } return cnt; } int pow(long long base, long long p, lo...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
518
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define sec second #define fir first #define mo 1000000007 #define inf 1e18 #define rep(i, s, n) for (ll i = s; i < n; i = i + 1) #define rrep(i, s, n) for (ll i = s; i >= n; i--) ll mod(ll n) { return (n %...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define sec second #define fir first #define mo 1000000007 #define inf 1e18 #define rep(i, s, n) for (ll i = s; i < n; i = i + 1) #define rrep(i, s, n) for (ll i = s; i >= n; i--) ll mod(ll n) { return (n %...
[["-", 0, 2, 3, 4, 0, 16, 31, 91, 17, 33]]
1
1,021
n = int(input()) X = input() def goes_to_zero(n): cnt = 0 while(n > 0): n %= bin(n).count('1') cnt += 1 return cnt c1 = X.count('1') xint = int(X,2) xtp = xint % (c1 + 1) if (c1 - 1) == 0: xtm = 0 else: xtm = xint % (c1 - 1) for i in range(n) : if x[i] == '0': print(goes_to_zero( (xtp ...
n = int(input()) X = input() def goes_to_zero(n): cnt = 0 while(n > 0): n %= bin(n).count('1') cnt += 1 return cnt c1 = X.count('1') xint = int(X,2) xtp = xint % (c1 + 1) if (c1 - 1) == 0: xtm = 0 else: xtm = xint % (c1 - 1) for i in range(n) : if X[i] == '0': print(goes_to_zero( (xtp ...
[["-", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22]]
5
200
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <utility> #include <vector> using namespace std; typedef ...
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <utility> #include <vector> using namespace std; typedef ...
[["+", 3, 4, 0, 16, 31, 69, 341, 342, 0, 73], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 73]]
1
607
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int f(int a) { if (a == 0) return 0; return f(a % __builtin_popcount(a)) + 1; } int main() { int n; string x_; cin >> n >> x_; vector<int> x(n); int pc_ = 0; rep(i, n) { x[i] = x_[i] - '0'; pc_ += x...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int f(int a) { if (a == 0) return 0; return f(a % __builtin_popcount(a)) + 1; } int main() { int n; string x_; cin >> n >> x_; vector<int> x(n); int pc_ = 0; rep(i, n) { x[i] = x_[i] - '0'; pc_ += x...
[["-", 31, 16, 12, 23, 0, 41, 64, 91, 17, 33], ["+", 31, 16, 12, 23, 0, 41, 75, 91, 17, 33]]
1
263
def fun(n): ops = 0 while n: pc = format(n, 'b').count('1') n %= pc ops += 1 return ops n = int(input()) xs = input() sm = int(xs, 2) pc = xs.count('1') mp = sm % (pc + 1) mm = sm % (pc - 1) if pc > 1 else 0 for i, x in enumerate(xs, 1): df = 1 if x == '1' else -1 pci = p...
def fun(n): ops = 0 while n: pc = format(n, 'b').count('1') n %= pc ops += 1 return ops n = int(input()) xs = input() sm = int(xs, 2) pc = xs.count('1') mp = sm % (pc + 1) mm = sm % (pc - 1) if pc > 1 else 0 for i, x in enumerate(xs, 1): df = 1 if x == '0' else -1 pci = p...
[["-", 0, 662, 12, 41, 0, 666, 0, 557, 0, 6], ["+", 0, 662, 12, 41, 0, 666, 0, 557, 0, 6]]
5
188
#include <bits/stdc++.h> using namespace std; typedef long long ll; int count_bits(int n) { n = (n & 0x55555555) + (n >> 1 & 0x55555555); n = (n & 0x33333333) + (n >> 2 & 0x33333333); n = (n & 0x0f0f0f0f) + (n >> 4 & 0x0f0f0f0f); n = (n & 0x00ff00ff) + (n >> 8 & 0x00ff00ff); n = (n & 0x0000ffff) + (n >> 16 &...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int count_bits(int n) { n = (n & 0x55555555) + (n >> 1 & 0x55555555); n = (n & 0x33333333) + (n >> 2 & 0x33333333); n = (n & 0x0f0f0f0f) + (n >> 4 & 0x0f0f0f0f); n = (n & 0x00ff00ff) + (n >> 8 & 0x00ff00ff); n = (n & 0x0000ffff) + (n >> 16 &...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
488
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18; #define rep(i, a, b) for (int i = a; i < b; i++) #define per(i, a, b) for (int i = b - 1; i >= a; i--) #define int long long using pint = pair<int, int>; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int dxx[8] = {1, 1, 1, 0, 0...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18; #define rep(i, a, b) for (int i = a; i < b; i++) #define per(i, a, b) for (int i = b - 1; i >= a; i--) #define int long long using pint = pair<int, int>; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int dxx[8] = {1, 1, 1, 0, 0...
[["-", 8, 9, 0, 9, 0, 43, 49, 50, 49, 22], ["+", 8, 9, 0, 9, 0, 43, 49, 50, 49, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 8, 9, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 11...
1
505
#include <iostream> #include <string> #include <vector> int main() { int n; int sum = 0; std::string S; std::cin >> n >> S; for (int i = 0; i < n; i++) { if (S[i] == '1') sum++; } // 例外処理 if (sum == 0) { for (int i = 0; i < n; i++) { std::cout << 1 << std::endl; } return 0;...
#include <iostream> #include <string> #include <vector> int main() { int n; int sum = 0; std::string S; std::cin >> n >> S; for (int i = 0; i < n; i++) { if (S[i] == '1') sum++; } // 例外処理 if (sum == 0) { for (int i = 0; i < n; i++) { std::cout << 1 << std::endl; } return 0;...
[["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 35]]
1
676
#include <bits/stdc++.h> using namespace std; #define arep(i, x, n) for (int i = int(x); i < (int)(n); i++) #define rep(i, n) for (long long i = 0; i < n; ++i) #define rrep(i, n) for (int i = int(n - 1); i >= 0; i--) #define fs first #define sc second #define all(x) (x).begin(), (x).end() #define rall(x) (x).begin(), (...
#include <bits/stdc++.h> using namespace std; #define arep(i, x, n) for (int i = int(x); i < (int)(n); i++) #define rep(i, n) for (long long i = 0; i < n; ++i) #define rrep(i, n) for (int i = int(n - 1); i >= 0; i--) #define fs first #define sc second #define all(x) (x).begin(), (x).end() #define rall(x) (x).begin(), (...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
762
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> using pv = vector<pair<T, U>>; template <typename T> using matrix = vector<vector<T>>; template <typename T> using pque = priority_queue<T>; template <typename T> using lpque = priority_queue<T, vector<T>, greater<T>>; using ll = long lon...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> using pv = vector<pair<T, U>>; template <typename T> using matrix = vector<vector<T>>; template <typename T> using pque = priority_queue<T>; template <typename T> using lpque = priority_queue<T, vector<T>, greater<T>>; using ll = long lon...
[["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
1
1,155
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string S; cin >> S; vector<int> L(N), H(N); int m = count(S.begin(), S.end(), '1'); reverse(S.begin(), S.end()); int l = m - 1, h = m + 1; int sl = 0, sh = 0; int x = 1; if (l) { for (int i = 0; i < N; ++i) { ...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string S; cin >> S; vector<int> L(N), H(N); int m = count(S.begin(), S.end(), '1'); reverse(S.begin(), S.end()); int l = m - 1, h = m + 1; int sl = 0, sh = 0; int x = 1; if (l) { for (int i = 0; i < N; ++i) { ...
[["-", 64, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 64, 9, 0, 57, 64, 1, 0, 11, 12, 13]]
1
412
# import sys input=sys.stdin.readline def main(): N=int(input()) X=input().strip("\n") cnt=[0]*N for i in range(1,N): n=i while(n>0): pc=0 for j in range(19): if (n>>j)&1==1: pc+=1 n%=pc cnt[i]+=1 p...
# import sys input=sys.stdin.readline def main(): N=int(input()) X=input().strip("\n") cnt=[0]*N for i in range(1,N): n=i while(n>0): pc=0 for j in range(19): if (n>>j)&1==1: pc+=1 n%=pc cnt[i]+=1 p...
[["+", 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
343
def main(): N = int(input()) *X, = map(int, input()) memo = [-1] * 21 def f(x): ret = 0 while x > 0: x = x % bin(x)[2:].count('1') ret += 1 return ret for x in range(21): memo[x] = f(x) cnt = X.count(1) if cnt == 1: ans = [...
def main(): N = int(input()) *X, = map(int, input()) memo = [-1] * 21 def f(x): ret = 0 while x > 0: x = x % bin(x)[2:].count('1') ret += 1 return ret for x in range(21): memo[x] = f(x) cnt = X.count(1) if cnt == 1: ans = [...
[["+", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612]]
5
427
#include <algorithm> #include <iomanip> #include <iostream> using namespace std; long long mod_pow(long long x, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) { res = res * x % mod; } x = x * x % mod; n >>= 1; } return res; } int main() { std::cin.tie(0); ...
#include <algorithm> #include <iomanip> #include <iostream> using namespace std; long long mod_pow(long long x, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) { res = res * x % mod; } x = x * x % mod; n >>= 1; } return res; } int main() { std::cin.tie(0); ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
408
n = int(input()) x = input() x10 = int(x, 2) lenx = len(x) maxbit = x.count("1") xc0 = x10 % (maxbit + 1) xc1 = x10 % (maxbit - 1) if maxbit > 1 else 0 def f(ii): cnt = 0 while ii > 0: ii %= bin(ii).count("1") cnt += 1 return cnt for i in range(lenx): if x[i] == "0": t = xc0 + pow(2, (lenx - 1 - ...
n = int(input()) x = input() x10 = int(x, 2) lenx = len(x) maxbit = x.count("1") xc0 = x10 % (maxbit + 1) xc1 = x10 % (maxbit - 1) if maxbit > 1 else 0 def f(ii): cnt = 0 while ii > 0: ii %= bin(ii).count("1") cnt += 1 return cnt for i in range(lenx): if x[i] == "0": t = xc0 + pow(2, (lenx - 1 - ...
[["-", 3, 4, 0, 657, 12, 23, 0, 657, 17, 72], ["+", 3, 4, 0, 657, 12, 23, 0, 657, 17, 33]]
5
197
import sys def input(): return sys.stdin.readline().strip() def main(): N = int(input()) X = input() bit_num = X.count("1") X_minus = [0] * N # X_minus[i] = 2^i mod (bit_num - 1) X_plus = [0] * N # X_plus[i] = 2^i mod (bit_num + 1) X_minus[0], X_plus[0] = 1, 1 for i in range(1, N): ...
import sys def input(): return sys.stdin.readline().strip() def main(): N = int(input()) X = input() bit_num = X.count("1") X_minus = [0] * N # X_minus[i] = 2^i mod (bit_num - 1) X_plus = [0] * N # X_plus[i] = 2^i mod (bit_num + 1) X_minus[0], X_plus[0] = 1, 1 for i in range(1, N): ...
[["+", 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
324
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define per(i, b) gnr(i, 0, b) #define pb push_back #define eb emplace_back #define bg begin() #...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define per(i, b) gnr(i, 0, b) #define pb push_back #define eb emplace_back #define bg begin() #...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 9, 0, 57, 64, 1, 0, 11, 12, 13]]
1
470
N = int(input()) X = input() tmp = bin(int(X, 2)).count("1") big = int(X, 2) % (tmp + 1) small = int(X, 2) % (tmp - 1) if tmp - 1 else 0 for i in range(N): ans = 0 if X[i] == '1': if not tmp - 1: print(ans) exit() c = small - pow(2, (N - i - 1), tmp - 1) c = c %...
N = int(input()) X = input() tmp = bin(int(X, 2)).count("1") big = int(X, 2) % (tmp + 1) small = int(X, 2) % (tmp - 1) if tmp - 1 else 0 for i in range(N): ans = 0 if X[i] == '1': if not tmp - 1: print(ans) continue c = small - pow(2, (N - i - 1), tmp - 1) c = c...
[["-", 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], ["+", 64, 196, 0, 57, 64, 196, 0, 116, 0, 117]]
5
191
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, n) for (int i = (int)(n); i >= 0; i--) #define all(v) v.begin(), v.end() typedef long long ll; vector<ll> bitconversion(ll i, ll n, ll N) { ll x = 1; rep(j, N) { x *= n; } vector<ll> vec(N); rep(j...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, n) for (int i = (int)(n); i >= 0; i--) #define all(v) v.begin(), v.end() typedef long long ll; vector<ll> bitconversion(ll i, ll n, ll N) { ll x = 1; rep(j, N) { x *= n; } vector<ll> vec(N); rep(j...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 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
693
/*-In the name of God- Author : Syed Mujtaba Seek knowledge from the Cradle to the Grave !! https://www.linkedin.com/in/syed-mujtaba */ #include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define ll long long #define pb push_back #define fi first #define se second #define MAXN 2...
/*-In the name of God- Author : Syed Mujtaba Seek knowledge from the Cradle to the Grave !! https://www.linkedin.com/in/syed-mujtaba */ #include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define ll long long #define pb push_back #define fi first #define se second #define MAXN 2...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
489
#include <bits/stdc++.h> using namespace std; int f(int x) { int res = 0; while (x > 0) { x = x % __builtin_popcount(x); res++; } return res; } void solve(int N, string X) { int pcX = 0; for (int i = 0; i < N; i++) { if (X.at(i) == '1') pcX++; } vector<int> pow2p(N); int tp = 1; ...
#include <bits/stdc++.h> using namespace std; int f(int x) { int res = 0; while (x > 0) { x = x % __builtin_popcount(x); res++; } return res; } void solve(int N, string X) { int pcX = 0; for (int i = 0; i < N; i++) { if (X.at(i) == '1') pcX++; } vector<int> pow2p(N); int tp = 1; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
441
N = gets.to_i X = gets.chomp # N = 2 * 10**5 # X = "1"*(N-1) + "0" xcnt = X.count('1') @fmap = { 0 => 0, 1 => 1 } def popcount(x) m1 = 0x55555555 m2 = 0x33333333 m4 = 0x0f0f0f0f x -= (x >> 1) & m1 x = (x & m2) + ((x >> 2) & m2) x = (x + (x >> 4)) & m4 x += x >> 8 return (x + (x >> 16)) & 0x3f ...
N = gets.to_i X = gets.chomp # N = 2 * 10**5 # X = "1"*(N-1) + "0" xcnt = X.count('1') @fmap = { 0 => 0, 1 => 1 } def popcount(x) m1 = 0x55555555 m2 = 0x33333333 m4 = 0x0f0f0f0f x -= (x >> 1) & m1 x = (x & m2) + ((x >> 2) & m2) x = (x + (x >> 4)) & m4 x += x >> 8 return (x + (x >> 16)) & 0x3f ...
[["+", 196, 737, 8, 736, 0, 783, 0, 751, 0, 121], ["+", 196, 737, 8, 736, 0, 783, 0, 751, 15, 22]]
4
317
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb push_back #define f first #define s second int fun(int x, int n, int m) { int ans = 1; while (n > 0) { if (1 & n) ans = (ans * x) % m; n = n >> 1; x = (x * x) % m; } return ans; } signed main() { int n, p1 = ...
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb push_back #define f first #define s second int fun(int x, int n, int m) { int ans = 1; while (n > 0) { if (1 & n) ans = (ans * x) % m; n = n >> 1; x = (x * x) % m; } return ans; } signed main() { int n, p1 = ...
[["-", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22]]
1
482
N = int(input()) X = input() popcount_X = X.count('1') numX = int(X, 2) a = numX % (popcount_X + 1) b = numX % (popcount_X - 1) if popcount_X != 1 else 0 for i, x in enumerate(X, 1): #リストのインデクス,要素,第二引数に開始位置 if x == '1' and popcount_X == 1: print(0) continue ans = 1 if x == '1': temp ...
N = int(input()) X = input() popcount_X = X.count('1') numX = int(X, 2) a = numX % (popcount_X + 1) b = numX % (popcount_X - 1) if popcount_X != 1 else 0 for i, x in enumerate(X, 1): #リストのインデクス,要素,第二引数に開始位置 if x == '1' and popcount_X == 1: print(0) continue ans = 1 if x == '1': temp ...
[["-", 0, 657, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 657, 12, 652, 3, 4, 0, 657, 12, 22]]
5
175
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(): N = int(readline()) X = readline().rstrip().decode('utf-8') nx = int(X, 2) ans = [0] * N oc = X.count('1') if oc - 1 != 0: mx = nx % (oc - 1) f = ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(): N = int(readline()) X = readline().rstrip().decode('utf-8') nx = int(X, 2) ans = [0] * N oc = X.count('1') if oc - 1 != 0: mx = nx % (oc - 1) f = ...
[["+", 0, 57, 75, 76, 8, 196, 0, 116, 0, 117]]
5
253
n = gets.to_i x = gets.chomp.chars pc = x.count("1") ur = [] lr = [] ut = 1 lt = -1 n.times do ut %= pc + 1 ur.unshift(ut) ut <<= 1 if pc - 1 > 0 lt %= pc - 1 lr.unshift(lt) lt <<= 1 end end rl = x[0].to_i ru = x[0].to_i 1.step(n - 1) do |i| t = x[i] if pc - 1 > 0 rl <<= 1 rl += t.to...
n = gets.to_i x = gets.chomp.chars pc = x.count("1") ur = [] lr = [] ut = 1 lt = -1 n.times do ut %= pc + 1 ur.unshift(ut) ut <<= 1 if pc - 1 > 0 lt %= pc - 1 lr.unshift(lt) lt <<= 1 end end rl = x[0].to_i ru = x[0].to_i 1.step(n - 1) do |i| t = x[i] if pc - 1 > 0 rl <<= 1 rl += t.to...
[["+", 0, 121, 75, 759, 64, 749, 0, 746, 0, 746]]
4
237
#include <bits/stdc++.h> using namespace std; #define int long long #define ALL(x) (x).begin(), (x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) typedef pair<int, int> PI; typedef pair<int, pair<int, int>> PII; static const int INF = 1010000000000000017LL; static const double eps = 1...
#include <bits/stdc++.h> using namespace std; #define int long long #define ALL(x) (x).begin(), (x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) typedef pair<int, int> PI; typedef pair<int, pair<int, int>> PII; static const int INF = 1010000000000000017LL; static const double eps = 1...
[["+", 49, 50, 51, 2, 3, 4, 0, 2, 63, 22], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 21], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
811
def main(): N = int(input()) X = input() MOD = sum(map(lambda x: x == '1',X)) lowNumber = [] for i in range(MOD): anscur = i cnt = 1 while anscur != 0: oneCount = bin(x).count('1') anscur %= oneCount cnt += 1 lowNumber.append(cnt) ...
def main(): N = int(input()) X = input() MOD = sum(map(lambda x: x == '1',X)) lowNumber = [] for i in range(MOD + 1): anscur = i cnt = 1 while anscur != 0: oneCount = bin(anscur).count('1') anscur %= oneCount cnt += 1 lowNumber.appe...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 12, 652, 63, 319, 500, 652, 3, 4, 0, 22], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 22]]
5
443
n = int(input()) x = input() k = x.count("1") s = int(x, 2) def ev(n): cnt = 0 while n != 0: m = bin(n).count("1") n = n % m cnt += 1 return cnt if k != 1: k1 = s%(k-1) k2 = s%(k+1) for i in range(n): if x[i] == "0": print(ev((k2+pow(2, n-i-1, k+1)) % (k+1))+1) else: print(ev((k1-pow(2, n-i-1, k...
n = int(input()) x = input() k = x.count("1") s = int(x, 2) def ev(n): cnt = 0 while n != 0: m = bin(n).count("1") n = n % m cnt += 1 return cnt if k != 1: k1 = s%(k-1) k2 = s%(k+1) for i in range(n): if x[i] == "0": print(ev((k2+pow(2, n-i-1, k+1)) % (k+1))+1) else: print(ev((k1-pow(2, n-i-1, k...
[["+", 31, 652, 3, 4, 0, 657, 12, 23, 0, 24], ["+", 31, 652, 3, 4, 0, 657, 12, 23, 0, 25]]
5
240
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int, int>; #define rep(i, n) for (ll i = 0; i < (ll)n; i++) #define ALL(x) (x).begin(), (x).end() #define MOD 1000000007 void rem(int k, int &res) { if (k == 0) return; res++; rem(k % __builtin...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int, int>; #define rep(i, n) for (ll i = 0; i < (ll)n; i++) #define ALL(x) (x).begin(), (x).end() #define MOD 1000000007 void rem(int k, int &res) { if (k == 0) return; res++; rem(k % __builtin...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
426
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <iostream> // cou...
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <iostream> // cou...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
838
def modpow(a, n, mod) if n > 0 && mod > 1 exp = Math.log(n, 2).floor rep = modpow_cl(a, n, exp, mod) return rep[0] elsif mod == 1 return 0 else return 1 end end def modpow_cl(a, n, exp, mod) if exp < 0 rep = [1, a] else if n >= 2**exp rep = modpow_cl(a, n-2**exp, exp-1, mo...
def modpow(a, n, mod) if n > 0 && mod > 1 exp = Math.log(n, 2).floor rep = modpow_cl(a, n, exp, mod) return rep[0] elsif mod == 1 return 0 else return 1 end end def modpow_cl(a, n, exp, mod) if exp < 0 rep = [1, a] else if n >= 2**exp rep = modpow_cl(a, n-2**exp, exp-1, mo...
[["-", 75, 95, 0, 121, 75, 95, 0, 662, 12, 612], ["+", 75, 95, 0, 121, 75, 95, 0, 662, 12, 612]]
4
537
n = int(input()) x = input() pop = x.count("1") lst1 = [1] for i in range(n-1): lst1.append(lst1[-1] * 2 % (pop + 1)) lst1.reverse() num1 = 0 for i in range(n): if x[i] == "1": num1 += lst[i] num1 %= (pop + 1) if pop == 1 or pop == 2: lst2 = [0] * n else: lst2 = [1] for i in range(n-...
n = int(input()) x = input() pop = x.count("1") lst1 = [1] for i in range(n-1): lst1.append(lst1[-1] * 2 % (pop + 1)) lst1.reverse() num1 = 0 for i in range(n): if x[i] == "1": num1 += lst1[i] num1 %= (pop + 1) if pop == 1 or pop == 2: lst2 = [0] * n else: lst2 = [1] for i in range(n...
[["-", 64, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22]]
5
291
def Base_n_to_10(X,n): out = 0 for i in range(1,len(str(X))+1): out += int(X[-i])*(n**(i-1)) return out#int outn=int(input()) def Base_10_to_n(X, n): if (int(X/n)): return Base_10_to_n(int(X/n), n)+str(X%n) return str(X%n) n=int(input()) x=input() ans=[] pc=x.count("1") la=[float("in...
def Base_n_to_10(X,n): out = 0 for i in range(1,len(str(X))+1): out += int(X[-i])*(n**(i-1)) return out#int outn=int(input()) def Base_10_to_n(X, n): if (int(X/n)): return Base_10_to_n(int(X/n), n)+str(X%n) return str(X%n) n=int(input()) x=input() ans=[] pc=x.count("1") la=[float("in...
[["-", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 33]]
5
448
#include <bits/stdc++.h> using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(), A.end() #define RALL(A) A.rbegin(), A.rend() typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1000000007; const ll LINF = 1LL << 60; co...
#include <bits/stdc++.h> using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(), A.end() #define RALL(A) A.rbegin(), A.rend() typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1000000007; const ll LINF = 1LL << 60; co...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
672
#include <bits/stdc++.h> using namespace std; using lint = long long int; using pint = pair<int, int>; using plint = pair<lint, lint>; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) \ f...
#include <bits/stdc++.h> using namespace std; using lint = long long int; using pint = pair<int, int>; using plint = pair<lint, lint>; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) \ f...
[["-", 31, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
648
import sys import math from collections import defaultdict from bisect import bisect_left, bisect_right sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(input()) def LI(): return list(map(int, input().split())) def LIR(row,col): if row <= 0: ...
import sys import math from collections import defaultdict from bisect import bisect_left, bisect_right sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(input()) def LI(): return list(map(int, input().split())) def LIR(row,col): if row <= 0: ...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]]
5
594
#include <bits/stdc++.h> using namespace std; long n, onea = 1, oneb = -1, xla = 0, xlb = 0; string x; vector<long> a(200050); vector<long> b(200050); vector<long> ans(200050); long keisan(long x, long y) { if (x == 0) return y; long aaa = 0; for (long i = 1; i <= x; i *= 2) if (x / i % 2 == 1) aaa...
#include <bits/stdc++.h> using namespace std; long n, onea = 1, oneb = -1, xla = 0, xlb = 0; string x; vector<long> a(200050); vector<long> b(200050); vector<long> ans(200050); long keisan(long x, long y) { if (x == 0) return y; long aaa = 0; for (long i = 1; i <= x; i *= 2) if (x / i % 2 == 1) aaa...
[["-", 0, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 9, 0, 57, 64, 1, 0, 11, 12, 13]]
1
436
#!/usr/bin/env python3 n = int(input()) x = input() cnt = x.count("1") x_cnt_plus = 0 x_cnt_minus = 0 for i in range(n): if x[i] == "1": x_cnt_plus += pow(2, n - i - 1, cnt + 1) x_cnt_plus %= cnt + 1 else: if cnt > 1: x_cnt_minus += pow(2, n - i - 1, cnt - 1) x_cn...
#!/usr/bin/env python3 n = int(input()) x = input() cnt = x.count("1") x_cnt_plus = 0 x_cnt_minus = 0 for i in range(n): if x[i] == "1": x_cnt_plus += pow(2, n - i - 1, cnt + 1) x_cnt_plus %= cnt + 1 if cnt > 1: x_cnt_minus += pow(2, n - i - 1, cnt - 1) x_cnt_minus %=...
[["-", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102], ["+", 0, 662, 12, 657, 31, 657, 31, 657, 17, 72], ["+", 0, 662, 12, 657, 31, 657, 31, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 17, 33], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 12, 612]]
5
217
n = int(input()) x = input() one_num = x.count('1') ans_reduce,ans_add = 0,0 for i in range(n): if(one_num>1): ans_reduce = (ans_reduce+pow(2,n-i-1,one_num-1)*(1 if x[i] == '1' else 0))%(one_num-1) ans_add = (ans_add+pow(2,n-i-1,one_num+1)*(1 if x[i] == '1' else 0))%(1+one_num) for i in range(n): ...
n = int(input()) x = input() one_num = x.count('1') ans_reduce,ans_add = 0,0 for i in range(n): if(one_num>1): ans_reduce = (ans_reduce+pow(2,n-i-1,one_num-1)*(1 if x[i] == '1' else 0))%(one_num-1) ans_add = (ans_add+pow(2,n-i-1,one_num+1)*(1 if x[i] == '1' else 0))%(1+one_num) for i in range(n): ...
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]]
5
247
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double // const long long MOD=1e9+7; ll mod_pow(ll x, ll y, ll MOD) { // x^yを返す//計算量は0(log(y)) ll tmp = x, res = 1; while (y) { if (y % 2) { res = res * tmp % MOD; } y >>= 1; tmp = tmp * tmp % MOD; } return ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double // const long long MOD=1e9+7; ll mod_pow(ll x, ll y, ll MOD) { // x^yを返す//計算量は0(log(y)) ll tmp = x, res = 1; while (y) { if (y % 2) { res = res * tmp % MOD; } y >>= 1; tmp = tmp * tmp % MOD; } return ...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
513
def get_popcount(n): ret = 0 while n > 0: if n & 1 == 1: ret += 1 n >>= 1 return ret def main(): N = int(input()) X = input() ans = [0] * N # (1) 最初の1ステップ(n <- n % popconut(n))を行う X_popcount = len([x for x in X if x == '1']) popcounts = [X_popcount] * N ...
def get_popcount(n): ret = 0 while n > 0: if n & 1 == 1: ret += 1 n >>= 1 return ret def main(): N = int(input()) X = input() ans = [0] * N # (1) 最初の1ステップ(n <- n % popconut(n))を行う X_popcount = len([x for x in X if x == '1']) popcounts = [X_popcount] * N ...
[["-", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72]]
5
427
#include <bits/stdc++.h> #define watch(x) cout << (#x) << " is " << (x) << endl #define endl "\n" typedef long long ll; using namespace std; int static fast = []() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); return 0; }(); // freopen("input.txt", "r", stdin); int get_cnt(ll x) { int ans = 0; wh...
#include <bits/stdc++.h> #define watch(x) cout << (#x) << " is " << (x) << endl #define endl "\n" typedef long long ll; using namespace std; int static fast = []() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); return 0; }(); // freopen("input.txt", "r", stdin); int get_cnt(ll x) { int ans = 0; wh...
[["-", 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
590
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; bitset<200002> b; cin >> b; int a = b.count(); if (a == 0) { for (int i = 0; i < N; i++) { cout << 1 << endl; } return 0; } if (a == 1) { if (b.test(0)) { for (int i = 0; i < N - 1; i++) { co...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; bitset<200002> b; cin >> b; int a = b.count(); if (a == 0) { for (int i = 0; i < N; i++) { cout << 1 << endl; } return 0; } if (a == 1) { if (b.test(0)) { for (int i = 0; i < N - 1; i++) { co...
[["+", 51, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 51, 2, 3, 4, 0, 16, 31, 16, 17, 33], ["+", 15, 339, 51, 2, 3, 4, 0, 16, 17, 33], ["+", 15, 339, 51, 2, 3, 4, 0, 16, 12, 13]]
1
551
n=int(input()) x=input() xre = x[::-1] cou = x.count('1') if cou == 0: for _ in range(n): print(1) exit() if cou == 1: for i in range(n): if i == n and x[i] == '0': print(2) elif x[i] == '0' and x[n-1] == '1': print(2) elif x[i] == '0' and x[n-1]...
n=int(input()) x=input() xre = x[::-1] cou = x.count('1') if cou == 0: for _ in range(n): print(1) exit() if cou == 1: for i in range(n): if i == n-1 and x[i] == '0': print(2) elif x[i] == '0' and x[n-1] == '1': print(2) elif x[i] == '0' and x[n-...
[["+", 0, 57, 15, 679, 31, 666, 0, 657, 17, 33], ["+", 0, 57, 15, 679, 31, 666, 0, 657, 12, 612]]
5
322