buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <bits/stdc++.h> #define int long long using namespace std; int f[1000005] = {0}; const int N = 1000001; int p[1000001]; bool vis[N]; int get_prime() { vis[1] = 1; int k = 0; for (int i = 2; i < N; i++) { if (!vis[i]) p[k++] = i; for (int j = 0; j < k && p[j] * i < N; j++) { vis[p[j] *...
#include <bits/stdc++.h> #define int long long using namespace std; int f[1000005] = {0}; const int N = 1000001; int p[1000001]; bool vis[N]; int get_prime() { vis[1] = 1; int k = 0; for (int i = 2; i < N; i++) { if (!vis[i]) p[k++] = i; for (int j = 0; j < k && p[j] * i < N; j++) { vis[p[j] *...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
385
import math as mt n=int(input()) l=list(map(int,input().split())) gd=l[0] sv=[0]*(10**6+1) for i in range(2,len(sv)+1): if not sv[i]: sv[i]=i for j in range(2*i,len(sv),i): sv[j]=i an="not coprime" for i in range(n): gd=mt.gcd(gd,l[i]) if gd!=1: print(an) else: an="setwise coprime" pos=1 ...
import math as mt n=int(input()) l=list(map(int,input().split())) gd=l[0] sv=[0]*(10**6+1) for i in range(2,len(sv)): if not sv[i]: sv[i]=i for j in range(2*i,len(sv),i): sv[j]=i an="not coprime" for i in range(n): gd=mt.gcd(gd,l[i]) if gd!=1: print(an) else: an="setwise coprime" pos=1 ...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
221
#include <bits/stdc++.h> using namespace std; bool solve1(int N, vector<int> &A) { sort(A.begin(), A.end()); vector<bool> V(1000001, false), W(1000001, false); for (int i = 0; i < N; i++) { if (V[A[i]] && A[i] != 1) return false; V[A[i]] = true; } for (int i = 2; i <= 1000000; i++) { if (W...
#include <bits/stdc++.h> using namespace std; bool solve1(int N, vector<int> &A) { sort(A.begin(), A.end()); vector<bool> V(1000001, false), W(1000001, false); for (int i = 0; i < N; i++) { if (V[A[i]] && A[i] != 1) return false; V[A[i]] = true; } for (int i = 2; i <= 1000000; i++) { if (W...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
331
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ ...
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 147], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 146], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
803
/*starting with the name of almighty ALLAH*/ /*solved by RAKIB JOY*/ // Practice is the only shortcut to improve #include <bits/stdc++.h> #define ll long long int #define pb push_back #define vc vector #define vi vc<int> #define vl vc<ll> #define dbg(x) cout << x << endl; #define mp(x, y) make_pair(x, y) #define yes db...
/*starting with the name of almighty ALLAH*/ /*solved by RAKIB JOY*/ // Practice is the only shortcut to improve #include <bits/stdc++.h> #define ll long long int #define pb push_back #define vc vector #define vi vc<int> #define vl vc<ll> #define dbg(x) cout << x << endl; #define mp(x, y) make_pair(x, y) #define yes db...
[["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 57, 64, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 9, 0, 9, 0, 46]]
1
572
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vl; typedef vector<bool> vb; typedef vector<string> vs; typedef vector<char> vc; typedef queue<ll> ql; typedef deque<ll> dql; typedef priority_queue<ll /*, vl, greater<ll>*/> pql; //降順(/*昇順*/) typedef set<...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vl; typedef vector<bool> vb; typedef vector<string> vs; typedef vector<char> vc; typedef queue<ll> ql; typedef deque<ll> dql; typedef priority_queue<ll /*, vl, greater<ll>*/> pql; //降順(/*昇順*/) typedef set<...
[["-", 8, 9, 0, 57, 64, 7, 15, 16, 17, 18], ["+", 8, 9, 0, 57, 64, 7, 15, 16, 17, 19]]
1
648
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef pair<int, int> P; typedef long long ll; const int INF = 1001001001; const ll INFL = 1e17; const int MOD = 1e9 + 7; int main() { int n; cin >> n; vector<int> a(n); vector<int> e(1000001); rep(i, n) { cin >...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef pair<int, int> P; typedef long long ll; const int INF = 1001001001; const ll INFL = 1e17; const int MOD = 1e9 + 7; int main() { int n; cin >> n; vector<int> a(n); vector<int> e(1000001); rep(i, n) { cin >...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
229
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> PP; #define MOD 1000000007 //#define MOD 998244353 #define INF 2305843009213693951 //#define INF 810114514 #define PI 3.141592653589 #define setdouble setprecision #define REP(i, n) for (ll i = 0; i < (n); ++i) #define OREP(i, n) f...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> PP; #define MOD 1000000007 //#define MOD 998244353 #define INF 2305843009213693951 //#define INF 810114514 #define PI 3.141592653589 #define setdouble setprecision #define REP(i, n) for (ll i = 0; i < (n); ++i) #define OREP(i, n) f...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
401
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; using pll = pair<ll, ll>; using Graph = vector<vector<ll>>; #define all(v) v.begin(), v.end() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, l, r) for (ll i = (l); i <= (ll)(r); i++) #define rep3(i, l, r) for...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; using pll = pair<ll, ll>; using Graph = vector<vector<ll>>; #define all(v) v.begin(), v.end() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, l, r) for (ll i = (l); i <= (ll)(r); i++) #define rep3(i, l, r) for...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
385
N=int(input()) A=list(map(int,input().split())) c=[0]*(10**6+5) isPairwise=True isSetwise=True for i in range(N): c[A[i]]+=1 for i in range(2,1000005): cnt=0 for j in range(2,1000005,i): cnt+=c[j] if cnt>1: isPairwise=False def gcd(a,b): while b: a,b=b,a%b return...
N=int(input()) A=list(map(int,input().split())) c=[0]*(10**6+5) isPairwise=True isSetwise=True for i in range(N): c[A[i]]+=1 for i in range(2,1000005): cnt=0 for j in range(i,1000005,i): cnt+=c[j] if cnt>1: isPairwise=False def gcd(a,b): while b: a,b=b,a%b return...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
5
178
#include <bits/stdc++.h> #define pb push_back #define ll long long #define f first #define s second #define ld long double #define fa fflush(stdout); #define mp make_pair using namespace std; void data() { #ifdef NURS freopen("main.in", "r", stdin); freopen("main.out", "w", stdout); #endif ios_base::sync_with_st...
#include <bits/stdc++.h> #define pb push_back #define ll long long #define f first #define s second #define ld long double #define fa fflush(stdout); #define mp make_pair using namespace std; void data() { #ifdef NURS freopen("main.in", "r", stdin); freopen("main.out", "w", stdout); #endif ios_base::sync_with_st...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
357
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ ...
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ ...
[["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]]
1
841
#pragma GCC optimize(2) #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #inc...
#pragma GCC optimize(2) #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #inc...
[["-", 64, 9, 0, 52, 15, 339, 51, 16, 17, 79], ["+", 64, 9, 0, 52, 15, 339, 51, 16, 17, 60]]
1
680
import sys N = int(input()) A = list(map(int, input().split())) MAX = 10**6 not_pairwise_coprime = False #pairwise coprimeでないことを示すbool値(のちに更新) # Aの要素に重複がある場合、少なくともpairwise coprimeではない Ct = [0 for _ in range(MAX+1)] for a in A: Ct[a] += 1 if max(Ct[2:MAX+1]) > 1: not_pairwise_coprime = True if max(Ct[2:MAX+1]) =...
import sys N = int(input()) A = list(map(int, input().split())) MAX = 10**6 not_pairwise_coprime = False #pairwise coprimeでないことを示すbool値(のちに更新) # Aの要素に重複がある場合、少なくともpairwise coprimeではない Ct = [0 for _ in range(MAX+1)] for a in A: Ct[a] += 1 if max(Ct[2:MAX+1]) > 1: not_pairwise_coprime = True if max(Ct[2:MAX+1]...
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
196
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append(i) if temp!=1: arr.append(temp) if arr==[]: arr.append(n) ...
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append(i) if temp!=1: arr.append(temp) if arr==[]: arr.append(n) ...
[["-", 0, 1, 0, 662, 12, 634, 0, 557, 0, 6], ["+", 0, 1, 0, 662, 12, 634, 0, 557, 0, 6], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 0, 1, 0, 662, 12, 657, 12, 282, 0, 45], ["+", 0, 1, 0, 662, 12, 657, 12, 282, 0, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 282, 0, 46]]
5
232
import math import numpy as np class SieveOfEratosthenes: def __init__(self, V): self.is_prime = np.ones(V + 1, dtype=bool) self.is_prime[4::2] = False self.is_prime[9::3] = False self.is_prime[25::5] = False self.primes = [2, 3, 5] for i in range(7, V + 1, 2): ...
import math import numpy as np class SieveOfEratosthenes: def __init__(self, V): self.is_prime = np.ones(V + 1, dtype=bool) self.is_prime[4::2] = False self.is_prime[9::3] = False self.is_prime[25::5] = False self.primes = [2, 3, 5] for i in range(7, V + 1, 2): ...
[["-", 0, 57, 64, 196, 0, 37, 0, 557, 0, 6], ["+", 0, 57, 64, 196, 0, 37, 0, 557, 0, 6]]
5
353
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) scanf("&d", a[i]); vector<int> cnt(1000005); vector<int> m(1000005); rep(i, n) m[a[i]]++; bool flag = t...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) scanf("%d", &a[i]); vector<int> cnt(1000005); vector<int> m(1000005); rep(i, n) m[a[i]]++; bool flag = ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
1
251
#include <stdio.h> #define A 1000010 int mp[A]; int nxt[A]; int prs[A]; char ex[A]; int gcd(int x, int y) { while (y) { int r = x % y; x = y; y = r; } return x; } int main(void) { int k = 0; for (int i = 2; i < A; ++i) { if (!mp[i]) { mp[i] = i; prs[k++] = i; } int m = ...
#include <stdio.h> #define A 1000010 int mp[A]; int nxt[A]; int prs[A]; char ex[A]; int gcd(int x, int y) { while (y) { int r = x % y; x = y; y = r; } return x; } int main(void) { int k = 0; for (int i = 2; i < A; ++i) { if (!mp[i]) { mp[i] = i; prs[k++] = i; } int m = ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
340
/* これを入れて実行 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 <random> #include <set> #include <stack> #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 <random> #include <set> #include <stack> #include <...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
688
#include <bits/stdc++.h> const int N = 1e6; int cnt[N + 1]; bool flg[N + 1]; std::vector<int> prime; inline void eular() { memset(flg, true, sizeof flg); for (int i = 2; i <= N; ++i) { if (flg[i]) { prime.push_back(i); } for (std::vector<int>::iterator it = prime.begin(); it != prime.e...
#include <bits/stdc++.h> const int N = 1e6; int cnt[N + 1]; bool flg[N + 1]; std::vector<int> prime; inline void eular() { memset(flg, true, sizeof flg); for (int i = 2; i <= N; ++i) { if (flg[i]) { prime.push_back(i); } for (std::vector<int>::iterator it = prime.begin(); it != prime.e...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
460
from math import gcd from functools import reduce def gcd_list(A): return reduce(gcd, A) def primes(n): is_prime = [False] * 2 + [True] * (n - 1) for i in range(2, int(n ** 0.5) + 1): # 素数候補 if not is_prime[i]: continue for j in range(2 * i, n + 1, i): is_prime[j] = False r...
from math import gcd from functools import reduce def gcd_list(A): return reduce(gcd, A) def primes(n): is_prime = [False] * 2 + [True] * (n - 1) for i in range(2, int(n ** 0.5) + 1): # 素数候補 if not is_prime[i]: continue for j in range(2 * i, n + 1, i): is_prime[j] = False r...
[["+", 8, 196, 0, 57, 15, 679, 31, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 667, 20], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355]]
5
262
#include <algorithm> #include <iostream> #include <queue> #include <stack> #include <stdio.h> #include <vector> using ll = long long int; const int INF = (1 << 30); const ll INFLL = (1ll << 60); const ll MOD = (ll)(1e9 + 7); #define l_ength size void mul_mod(ll &a, ll b) { a *= b; a %= MOD; } void add_mod(ll &a...
#include <algorithm> #include <iostream> #include <queue> #include <stack> #include <stdio.h> #include <vector> using ll = long long int; const int INF = (1 << 30); const ll INFLL = (1ll << 60); const ll MOD = (ll)(1e9 + 7); #define l_ength size void mul_mod(ll &a, ll b) { a *= b; a %= MOD; } void add_mod(ll &a...
[["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
1
305
#include <bits/stdc++.h> using namespace std; using ll = long long; static const int MAX = 1e6; int d[MAX + 1]; void eratos(int n) { for (int i = 0; i <= n; i++) { d[i] = i; } for (int i = 2; i * i <= n; i++) { if (d[i] != i) continue; for (int j = i + i; j <= n; j += i) { if (d[j] != j)...
#include <bits/stdc++.h> using namespace std; using ll = long long; static const int MAX = 1e6; int d[MAX + 1]; void eratos(int n) { for (int i = 0; i <= n; i++) { d[i] = i; } for (int i = 2; i * i <= n; i++) { if (d[i] != i) continue; for (int j = i + i; j <= n; j += i) { if (d[j] != j)...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
306
#include <bits/stdc++.h> using namespace std; template <typename T> void out(T x) { cout << x << endl; exit(0); } #define watch(x) cout << (#x) << " is " << (x) << endl using ll = long long; const ll mod = 1e9 + 7; const int maxn = 1e6 + 5; int n; int a[maxn]; bool hit[maxn]; void proc(int x) { for (int i =...
#include <bits/stdc++.h> using namespace std; template <typename T> void out(T x) { cout << x << endl; exit(0); } #define watch(x) cout << (#x) << " is " << (x) << endl using ll = long long; const ll mod = 1e9 + 7; const int maxn = 1e6 + 5; int n; int a[maxn]; bool hit[maxn]; void proc(int x) { for (int i =...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
314
import java.io.*; import java.util.*; // i want to become the best class Main { public static HashMap<Long, Integer> hmprod = new HashMap<>(); public static HashMap<Long, Integer> hmlcm = new HashMap<>(); // public static long[] list = new public static void main(String[] args) throws Exception { BufferedRe...
import java.io.*; import java.util.*; // i want to become the best class Main { public static HashMap<Long, Integer> hmprod = new HashMap<>(); public static HashMap<Long, Integer> hmlcm = new HashMap<>(); // public static long[] list = new public static void main(String[] args) throws Exception { BufferedRe...
[["-", 3, 4, 0, 16, 12, 492, 3, 4, 0, 499], ["+", 3, 4, 0, 16, 12, 492, 3, 4, 0, 499], ["-", 0, 492, 3, 4, 0, 492, 3, 4, 0, 499], ["+", 0, 492, 3, 4, 0, 492, 3, 4, 0, 499]]
3
648
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) #define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { ...
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) #define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { ...
[["-", 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, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
405
#include <bits/stdc++.h> using namespace std; const int N = 2000010; int a[N], st[N]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a * b / gcd(a, b); } int main() { int n; cin >> n; int sgcd; for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); if (i == 1) ...
#include <bits/stdc++.h> using namespace std; const int N = 2000010; int a[N], st[N]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a * b / gcd(a, b); } int main() { int n; cin >> n; int sgcd; for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); if (i == 1) ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
250
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; const long long INF = 1001001001; const long long MOD = 1000000007; const double EPS = 1e-10; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int a[n]; int g = 0; for (int i = 0; i < n; i...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; const long long INF = 1001001001; const long long MOD = 1000000007; const double EPS = 1e-10; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int a[n]; int g = 0; for (int i = 0; i < n; i...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
309
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int64_t> s; for (int i = 2; i < 1000000; i++) { int C = 1; for (int x : s) { if (x * x > i) { break; } if (i % x == 0) { C = 0; break; } } if (C) { s.push_bac...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int64_t> s; for (int i = 2; i < 1000000; i++) { int C = 1; for (int x : s) { if (x * x > i) { break; } if (i % x == 0) { C = 0; break; } } if (C) { s.push_bac...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
398
def arrayF(n): F=[0]*(n+1) i=2 while i*i<=n: if F[i] == 0: k=i*i while k <= n: if F[k] == 0: F[k] = i k += i i += 1 return F def factorization(x, F): primeFactors = [] while F[x] > 0: prim...
def arrayF(n): F=[0]*(n+1) i=2 while i*i<=n: if F[i] == 0: k=i*i while k <= n: if F[k] == 0: F[k] = i k += i i += 1 return F def factorization(x, F): primeFactors = [] while F[x] > 0: prim...
[["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32]]
5
228
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int N; cin >> N; vector<int> isA(1000001, 0), is_prime(1000001, 1); for (int n = 0; n < N; ++n) { int a; cin >> a; ++isA[a]; } bool setwise = true, pairwise = true; fo...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int N; cin >> N; vector<int> isA(1000001, 0), is_prime(1000001, 1); for (int n = 0; n < N; ++n) { int a; cin >> a; ++isA[a]; } bool setwise = true, pairwise = true; fo...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
221
def main(): import sys input = sys.stdin.buffer.readline from math import gcd N = int(input()) A = list(map(int, input().split())) g = A[0] M = max(A) X = [i for i in range(M+1)] S = [True for i in range(M+1)] S[0] = False S[1] = False for i in range(1, M+1): if ...
def main(): import sys input = sys.stdin.buffer.readline from math import gcd N = int(input()) A = list(map(int, input().split())) g = A[0] M = max(A) X = [i for i in range(M+1)] S = [True for i in range(M+1)] S[0] = False S[1] = False for i in range(1, M+1): if ...
[["+", 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, 147]]
5
269
#include <bits/stdc++.h> using namespace std; bool p[1000006]; long long r[1000005], y, o, k[1000006], b, u, a, ans; int gp() { for (int i = 2; i <= 1000000; i++) { if (p[i] == 0) { for (int j = i * 2; j <= 1000000; j += i) p[j] = 1; } } for (int i = 2; i <= 1000000; i++) { if (p[i] == 0...
#include <bits/stdc++.h> using namespace std; bool p[1000006]; long long r[1000005], y, o, k[1000006], b, u, a, ans; int gp() { for (int i = 2; i <= 1000000; i++) { if (p[i] == 0) { for (int j = i * 2; j <= 1000000; j += i) p[j] = 1; } } for (int i = 2; i <= 1000000; i++) { if (p[i] == 0...
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
333
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (a); i < (b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ALL(x) x.begin(), x.end() #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = m...
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (a); i < (b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ALL(x) x.begin(), x.end() #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = m...
[["-", 64, 1, 0, 27, 28, 69, 341, 342, 0, 22], ["+", 64, 1, 0, 27, 28, 69, 341, 342, 0, 22]]
1
509
#include <algorithm> #include <iostream> #include <set> #include <vector> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int n; cin >> n; vector<int> a(n); set<int> s; for (int i = 0; i < n; i++) scanf("%d", &a[i]); int gc = gcd(a[0], a[1]); for (int i = 2...
#include <algorithm> #include <iostream> #include <set> #include <vector> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int n; cin >> n; vector<int> a(n); set<int> s; for (int i = 0; i < n; i++) scanf("%d", &a[i]); int gc = gcd(a[0], a[1]); for (int i = 2...
[["+", 0, 57, 15, 339, 51, 16, 31, 23, 0, 24], ["-", 0, 57, 15, 339, 51, 16, 12, 23, 0, 24], ["+", 31, 23, 0, 16, 12, 2, 3, 4, 0, 25], ["-", 12, 23, 0, 16, 12, 2, 3, 4, 0, 25]]
1
284
#include <bits/stdc++.h> #include <cmath> using namespace std; #define int long long int #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define F first #define S second #define all(a) a.begin(), a.end() #define endl '\n' #define boost ...
#include <bits/stdc++.h> #include <cmath> using namespace std; #define int long long int #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define F first #define S second #define all(a) a.begin(), a.end() #define endl '\n' #define boost ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22]]
1
361
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define For(i, a, b) for (auto i = (a); i <= (b); ++i) #define rFor(i, a, b) for (auto i = (b); i >= (a); --i) #define call(var) cerr << #var << "=" << var << "\n";...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define For(i, a, b) for (auto i = (a); i <= (b); ++i) #define rFor(i, a, b) for (auto i = (b); i >= (a); --i) #define call(var) cerr << #var << "=" << var << "\n";...
[["+", 0, 338, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 338, 8, 9, 0, 57, 64, 9, 0, 46]]
1
709
import sys, math def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5 // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([te...
import sys, math def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5 // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([te...
[["-", 0, 7, 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]]
5
247
#include <bits/stdc++.h> using namespace std; int max_n = 1e6 + 6; vector<int> spf; void sieve() { spf.resize(max_n, 1); for (int num = 2; num < max_n; num++) spf[num] = num; for (int num = 2; num < max_n; num++) { if (spf[num] != num) continue; for (int mult = 2 * num; mult < max_n; mult +...
#include <bits/stdc++.h> using namespace std; int max_n = 1e6 + 6; vector<int> spf; void sieve() { spf.resize(max_n, 1); for (int num = 2; num < max_n; num++) spf[num] = num; for (int num = 2; num < max_n; num++) { if (spf[num] != num) continue; for (int mult = 2 * num; mult < max_n; mult +...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
329
#include <bits/stdc++.h> using namespace std; int max_n = 1e6 + 6; vector<int> spf; void sieve() { spf.resize(max_n, 1); for (int num = 2; num < max_n; num++) spf[num] = num; for (int num = 2; num < max_n; num++) { if (spf[num] == num) { for (int mult = 2 * num; mult < max_n; mult += num) { ...
#include <bits/stdc++.h> using namespace std; int max_n = 1e6 + 6; vector<int> spf; void sieve() { spf.resize(max_n, 1); for (int num = 2; num < max_n; num++) spf[num] = num; for (int num = 2; num < max_n; num++) { if (spf[num] == num) { for (int mult = 2 * num; mult < max_n; mult += num) { ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
341
/*** Template Begin ***/ #pragma region template // #define USING_BOOST #define USING_NAMESPACE #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iomanip> #include <iostr...
/*** Template Begin ***/ #pragma region template // #define USING_BOOST #define USING_NAMESPACE #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iomanip> #include <iostr...
[["-", 0, 7, 8, 9, 0, 7, 26, 11, 17, 107], ["-", 0, 7, 8, 9, 0, 7, 26, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 26, 27, 17, 29]]
1
1,523
#include <bits/stdc++.h> using namespace std; #define DBG(x) \ (void)(cout << "L" << __LINE__ << ": " << #x << " = " << (x) << '\n') #define Lower_bound(v, x) \ distance(v.begin(), lower_bound(v.beg...
#include <bits/stdc++.h> using namespace std; #define DBG(x) \ (void)(cout << "L" << __LINE__ << ": " << #x << " = " << (x) << '\n') #define Lower_bound(v, x) \ distance(v.begin(), lower_bound(v.beg...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
311
#!ruby -narprime A=$F.map &:to_i d=A.tally puts Prime.each(1e6).all?{|b|a=((b..10**6)%b).sum{d[_1]||0}<2}?:pairwise:A.reduce(:gcd)<2?:setwise: :not,'coprime'if/ /
#!ruby -narprime A=$F.map &:to_i d=A.tally print Prime.each(1e6).all?{|b|a=((b..10**6)%b).sum{d[_1]||0}<2}?:pairwise:A.reduce(:gcd)<2?:setwise: :not,' coprime'if/ /
[["-", 36, 36, 0, 493, 0, 751, 8, 652, 735, 22], ["+", 36, 36, 0, 493, 0, 751, 8, 652, 735, 22], ["-", 0, 751, 8, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 751, 8, 652, 3, 4, 0, 557, 0, 6]]
4
75
from math import gcd from functools import reduce N = int(input()) *A, = map(int, input().split()) MAX_N = max(A)+5 primes = list(range(MAX_N+1)) for i in range(2, int(MAX_N**0.5)+1): if primes[i] < i: continue for j in range(2*i, MAX_N+1, i): primes[j] = i def check(): S = set() for a...
from math import gcd from functools import reduce N = int(input()) *A, = map(int, input().split()) MAX_N = max(A)+5 primes = list(range(MAX_N+1)) for i in range(2, int(MAX_N**0.5)+1): if primes[i] < i: continue for j in range(2*i, MAX_N+1, i): primes[j] = i def check(): S = set() for ...
[["+", 8, 196, 0, 57, 15, 679, 31, 666, 667, 79], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22]]
5
201
#include <bits/stdc++.h> using namespace std; typedef long long ll; inline ll read() { char ch = getchar(); ll x = 0; while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); return x; } ll n, cnt; ll a[2000010]; bool isnp[2000...
#include <bits/stdc++.h> using namespace std; typedef long long ll; inline ll read() { char ch = getchar(); ll x = 0; while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); return x; } ll n, cnt; ll a[2000010]; bool isnp[2000...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]]
1
447
import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scn = new Scanner(System.in); int n = scn.nextInt(); int[] arr = new int[n]; int max = 1; for (int i = 0; i ...
import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scn = new Scanner(System.in); int n = scn.nextInt(); int[] arr = new int[n]; int max = 1; for (int i = 0; i ...
[["-", 0, 195, 8, 196, 0, 7, 26, 27, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 11, 17, 107], ["+", 0, 195, 8, 196, 0, 7, 26, 11, 12, 499]]
3
559
/* Task: I. Kevin and Grid Link: http://codeforces.com/contest/1392/problem/I Lang: cpp17 */ #include <bits/stdc++.h> using namespace std; #define eb emplace_back #define pb push_back #define INF LLONG_MAX #define FLT_INF pow(10.0, 16) using ll = long long; using vll = vector<ll>; using ull = unsigned long long...
/* Task: I. Kevin and Grid Link: http://codeforces.com/contest/1392/problem/I Lang: cpp17 */ #include <bits/stdc++.h> using namespace std; #define eb emplace_back #define pb push_back #define INF LLONG_MAX #define FLT_INF pow(10.0, 16) using ll = long long; using vll = vector<ll>; using ull = unsigned long long...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
951
#include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(NULL) typedef long long ll; typedef long double ld; #define trace(x) cerr << #x << ": " << x << endl; ...
#include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(NULL) typedef long long ll; typedef long double ld; #define trace(x) cerr << #x << ": " << x << endl; ...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 13]]
1
381
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; stri...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; stri...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
715
# Python3 implementation of the approach MAXN = 1000001 # Stores smallest prime factor for # every number spf = [i for i in range(MAXN)] # Hash to store prime factors count hash1 = [0 for i in range(MAXN)] # Function to calculate SPF (Smallest # Prime Factor) for every number till MAXN def sieve(): # Sepa...
MAXN = 1000001 spf = [i for i in range(MAXN)] hash1 = [0 for i in range(MAXN)] def sieve(): for i in range(4, MAXN, 2): spf[i] = 2 for i in range(3, MAXN): if i * i > MAXN: break if (spf[i] == i): for j in range(i * i, MAXN, i): if (spf[j] == j): spf[j] = i def getFactorization(x): ...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
349
#include <bits/stdc++.h> #define ll long long using namespace std; #define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int arr[100001]; int main() { fast int n, z; cin >> n; int g; bool b = 1; for (int i = 0; i < n; i++) { cin >> z; if (i == 0) g = z; else g = __gcd(z,...
#include <bits/stdc++.h> #define ll long long using namespace std; #define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int arr[1000001]; int main() { fast int n, z; cin >> n; int g; bool b = 1; for (int i = 0; i < n; i++) { cin >> z; if (i == 0) g = z; else g = __gcd(z...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 64, 9, 0, 52, 15, 339, 51, 16, 17, 79], ["+", 64, 9, 0, 52, 15, 339, 51, 16, 17, 60]]
1
213
#include <algorithm> #include <array> #include <cctype> #include <climits> #include <cmath> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string.h> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long...
#include <algorithm> #include <array> #include <cctype> #include <climits> #include <cmath> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string.h> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long...
[["+", 15, 339, 51, 69, 341, 342, 0, 16, 31, 22], ["+", 15, 339, 51, 69, 341, 342, 0, 16, 17, 85]]
1
1,228
#include <bits/stdc++.h> using namespace std; #define ll long long int int main() { ll n; cin >> n; ll a[n], ans = 0, mx = 1000000; vector<ll> v(mx + 10, 0); for (ll i = 0; i < n; i++) cin >> a[i], v[a[i]]++; for (ll i = 0; i < mx + 10; i++) if (v[i] > 1) ans = -1; for (ll i = 2; i <= mx; i...
#include <bits/stdc++.h> using namespace std; #define ll long long int int main() { ll n; cin >> n; ll a[n], ans = 0, mx = 1000000; vector<ll> v(mx + 10, 0); for (ll i = 0; i < n; i++) cin >> a[i], v[a[i]]++; for (ll i = 2; i < mx + 10; i++) if (v[i] > 1) ans = -1; for (ll i = 2; i <= mx; i...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
248
#!/usr/bin/env python3 import sys from math import gcd from functools import reduce def input(): return sys.stdin.readline().rstrip() def pairwaise(bools): for i in range(2,10**6): hantei=0 for j in range(i,10**6+1,i): hantei+=bools[j] if hantei>1: return False r...
#!/usr/bin/env python3 import sys from math import gcd from functools import reduce def input(): return sys.stdin.readline().rstrip() def pairwaise(bools): for i in range(2,10**6): hantei=0 for j in range(i,10**6+1,i): hantei+=bools[j] if hantei>1: return False r...
[["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 79], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612]]
5
202
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll mod = 1e9 + 7; template <typename T> vector<T> smallest_prime_factors(T n) { vector<T> spf(n + 1); for (int i = 0; i <= n; i++) spf[i] = i; for (T i = 2; i * i <= n; i++) { // 素数だったら if (spf[i] == i) { for (T j...
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll mod = 1e9 + 7; template <typename T> vector<T> smallest_prime_factors(T n) { vector<T> spf(n + 1); for (int i = 0; i <= n; i++) spf[i] = i; for (T i = 2; i * i <= n; i++) { // 素数だったら if (spf[i] == i) { for (T j...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
460
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define int long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, n) for (int i = 0; i < n; ++i) #define range(i, a, b) ((a) <= (i) && (i) < (b)) #defi...
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define int long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, n) for (int i = 0; i < n; ++i) #define range(i, a, b) ((a) <= (i) && (i) < (b)) #defi...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
1,504
#include <bits/stdc++.h> using namespace std; using ll = long long; void prime_factorization(vector<pair<ll, ll>> &res, ll x) { for (ll p = 2; p * p <= x; p++) { if (x % p != 0) { continue; } ll num = 0; while (x % p == 0) { ++num; x /= p; } res.push_back(make_pair(p, num...
#include <bits/stdc++.h> using namespace std; using ll = long long; void prime_factorization(vector<pair<ll, ll>> &res, ll x) { for (ll p = 2; p * p <= x; p++) { if (x % p != 0) { continue; } ll num = 0; while (x % p == 0) { ++num; x /= p; } res.push_back(make_pair(p, num...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
338
//! 尺卂乃卂.卂フ乇乇ㄒ #include <bits/stdc++.h> //#include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; // Using namespace __gnu_pbds; // typedef // tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> // Ordered_set; #define ll long long #define int long long #define ld long double #de...
//! 尺卂乃卂.卂フ乇乇ㄒ #include <bits/stdc++.h> //#include <ext/pb_ds/detail/standard_policies.hpp> using namespace std; // Using namespace __gnu_pbds; // typedef // tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> // Ordered_set; #define ll long long #define int long long #define ld long double #de...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 31, 13], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 48]]
1
717
def seachPrimeNum(N): max = int(N**.5) seachList = [i for i in range(2,N+1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum P=seachPri...
def seachPrimeNum(N): max = int(N**.5) seachList = [i for i in range(2,N+1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum P=seachPri...
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]]
5
327
m = 1000010 a = Array.new(m){[]} (2...m).each{|i| if a[i].empty? j = i while j < m a[i] << j j += i end end } f = Array.new(m) gets d = 0 t = true gets.split.map(&:to_i).each{|x| d = d.gcd(x) if t a[x].each{|y| t &&= !f[y] f[y] = true } end } puts (t ? "pairwise coprime" : d == 1 ? "setwise ...
m = 1000010 a = Array.new(m){[]} (2...m).each{|i| if a[i].empty? j = i while j < m a[j] << i j += i end end } f = Array.new(m) gets d = 0 t = true gets.split.map(&:to_i).each{|x| d = d.gcd(x) if t a[x].each{|y| t &&= !f[y] f[y] = true } end } puts (t ? "pairwise coprime" : d == 1 ? "setwise ...
[["-", 0, 89, 8, 170, 0, 738, 31, 742, 0, 22], ["+", 0, 89, 8, 170, 0, 738, 31, 742, 0, 22], ["-", 64, 749, 0, 89, 8, 170, 0, 738, 12, 22], ["+", 64, 749, 0, 89, 8, 170, 0, 738, 12, 22]]
4
138
#include <bits/stdc++.h> using namespace std; typedef vector<int> veci; typedef pair<int, int> pii; typedef vector<pii> vecii; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vecl; typedef vector<pll> vecll; #define EPS (1e-9) #define MOD (1e9 + 7) #define fi first #define se second #define endl '\n...
#include <bits/stdc++.h> using namespace std; typedef vector<int> veci; typedef pair<int, int> pii; typedef vector<pii> vecii; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vecl; typedef vector<pll> vecll; #define EPS (1e-9) #define MOD (1e9 + 7) #define fi first #define se second #define endl '\n...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]]
1
365
#include <iostream> #include <vector> using namespace std; // O(√n)で nを素因数分解したものをvectorに記録して返す typedef pair<long long int, int> P; vector<P> PF(long long int n) { vector<P> vec; long long int np = n, count; for (long long int i = 2; i <= np / i; i++) { if (n % i != 0) continue; count = 0; while ...
#include <iostream> #include <vector> using namespace std; // O(√n)で nを素因数分解したものをvectorに記録して返す typedef pair<long long int, int> P; vector<P> PF(long long int n) { vector<P> vec; long long int np = n, count; for (long long int i = 2; i <= np / i; i++) { if (n % i != 0) continue; count = 0; while ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
490
// Problem : E - Coprime // Contest : AtCoder - AtCoder Beginner Contest 177 // URL : https://atcoder.jp/contests/abc177/tasks/abc177_e // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/coder3101/cp-editor) // $%U%$ // Mere bas ka nahi hai // still i'm trying // apna time a...
// Problem : E - Coprime // Contest : AtCoder - AtCoder Beginner Contest 177 // URL : https://atcoder.jp/contests/abc177/tasks/abc177_e // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/coder3101/cp-editor) // $%U%$ // Mere bas ka nahi hai // still i'm trying // apna time a...
[["+", 51, 16, 31, 2, 3, 4, 0, 69, 28, 22], ["+", 31, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["+", 0, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
571
#include <bits/stdc++.h> using namespace std; #define int long long using vec_int = vector<int>; using P = pair<int, int>; using T = tuple<int, int, int>; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int charToInt(char c) { char zero_num = '0'; return (int)c - (int)zero_num; } signed...
#include <bits/stdc++.h> using namespace std; #define int long long using vec_int = vector<int>; using P = pair<int, int>; using T = tuple<int, int, int>; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int charToInt(char c) { char zero_num = '0'; return (int)c - (int)zero_num; } signed...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
558
// BISMILLAHIR RAHMANIR RAHIM #include <bits/stdc++.h> #define mem(a, b) (memset(a, b, sizeof(a))) #define pb push_back #define mk make_pair #define ff first #define ss second #define PI acos(-1) #define INF 2147483647 #define MOD 1000000007 #define MAX 200005 using namespace std; typedef long long ll; typedef vector<...
// BISMILLAHIR RAHMANIR RAHIM #include <bits/stdc++.h> #define mem(a, b) (memset(a, b, sizeof(a))) #define pb push_back #define mk make_pair #define ff first #define ss second #define PI acos(-1) #define INF 2147483647 #define MOD 1000000007 #define MAX 200005 using namespace std; typedef long long ll; typedef vector<...
[["-", 0, 14, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 14, 8, 9, 0, 7, 26, 11, 17, 107], ["+", 0, 14, 8, 9, 0, 7, 26, 11, 12, 13]]
1
538
// Problem: E - Coprime // Contest: AtCoder - AtCoder Beginner Contest 177 // URL: https://atcoder.jp/contests/abc177/tasks/abc177_e // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) // Muallif: Azimjon Mehmonali o'g'li //==================================...
// Problem: E - Coprime // Contest: AtCoder - AtCoder Beginner Contest 177 // URL: https://atcoder.jp/contests/abc177/tasks/abc177_e // Memory Limit: 1024 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) // Muallif: Azimjon Mehmonali o'g'li //==================================...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 31, 13], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 48]]
1
379
#pragma GCC optimize(2) #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #includ...
#pragma GCC optimize(2) #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #includ...
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 108], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 1, 0, 27, 28, 69, 28, 22], ["+", 64, 1, 0, 27, 28, 69, 341, 342, 0, 70], ["+", 64, 1, 0, 27, 28, 69, 341, 342, 0, 22], ["+", 64, 1, 0, 27, 28, 69, 341, 342, 0, 73], ["+", 8, 9...
1
685
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define int ll #define pb push_back #define setbits(x) __builtin_popcountll(x) #define endl "\n" typedef long long ll; #define mx 1000010 int dp[mx]; ll gcd(ll a, ll b) { // Write your code here if (b == 0) return a; return gcd(...
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define int ll #define pb push_back #define setbits(x) __builtin_popcountll(x) #define endl "\n" typedef long long ll; #define mx 1000010 int dp[mx]; ll gcd(ll a, ll b) { // Write your code here if (b == 0) return a; return gcd(...
[["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 15, 339, 51, 16, 12, 16, 31, 69, 28, 22], ["+", 51, 16, 12, 16, 31, 69, 341, 342, 0, 70], ["+", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 16, 31, 69, 341, 342, 0, 73]]
1
399
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define mp make_pair #define pb push_back #define pii pair<int, int> #define pll pair<long long, long long> #define fastio() \ ios_base::sync_with_stdio(false); ...
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define mp make_pair #define pb push_back #define pii pair<int, int> #define pll pair<long long, long long> #define fastio() \ ios_base::sync_with_stdio(false); ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
598
import java.io.*; import java.util.*; /** * Made by egor https://github.com/chermehdi/egor. * * @author Azuz * */ public class Main { void solve(Scanner in, PrintWriter out) { int n = in.nextInt(); int[] arr = new int[n]; int gcd = 0; boolean setwise = false; boolean pairwise = false; ...
import java.io.*; import java.util.*; /** * Made by egor https://github.com/chermehdi/egor. * * @author Azuz * */ public class Main { void solve(Scanner in, PrintWriter out) { int n = in.nextInt(); int[] arr = new int[n]; int gcd = 0; boolean setwise = false; boolean pairwise = false; ...
[["-", 0, 57, 15, 15, 0, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 31, 22]]
3
430
/* * John Wick is a man of * focus, commitment & sheer will */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> using namespace __gnu_pbds; using namespace std; // -----------------<fast IO>------------------ #define Speed ...
/* * John Wick is a man of * focus, commitment & sheer will */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> using namespace __gnu_pbds; using namespace std; // -----------------<fast IO>------------------ #define Speed ...
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 64, 116, 0, 117]]
1
1,240
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define F first #define S second #define endl '\n' #define all(v) (v).begin(), (v).end() template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep...
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define F first #define S second #define endl '\n' #define all(v) (v).begin(), (v).end() template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep...
[["-", 75, 76, 0, 9, 0, 1, 0, 16, 31, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["-", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
1
582
#include <algorithm> #include <cassert> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <string> #include <vector> #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() using namespace std; using l...
#include <algorithm> #include <cassert> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <string> #include <vector> #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() using namespace std; using l...
[["+", 15, 339, 51, 16, 31, 16, 31, 16, 31, 22], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 85]]
1
528
#include <bits/stdc++.h> using namespace std; #define ll long long #define Mid ((l + r) / 2) #define rep(i, a, b) for (int i = (a); i <= (b); ++i) #define drep(i, a, b) for (int i = (a); i >= (b); --i) #define file(a) freopen(#a ".in", "r", stdin), freopen(#a ".out", "w", stdout); const int maxn = 1e6 + 5, mod = 1e9 + ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define Mid ((l + r) / 2) #define rep(i, a, b) for (int i = (a); i <= (b); ++i) #define drep(i, a, b) for (int i = (a); i >= (b); --i) #define file(a) freopen(#a ".in", "r", stdin), freopen(#a ".out", "w", stdout); const int maxn = 1e6 + 5, mod = 1e9 + ...
[["-", 8, 9, 0, 1, 0, 34, 12, 11, 17, 32], ["-", 8, 9, 0, 1, 0, 34, 12, 11, 12, 13], ["+", 8, 9, 0, 1, 0, 34, 12, 27, 17, 29]]
1
412
#include <bits/stdc++.h> using namespace std; #define rep(i, x, y) for (ll i = (x); i < (y); i++) #define rrep(i, x, y) for (ll i = (ll)(y)-1; i >= (x); i--) #define all(x) (x).begin(), (x).end() #define itrout(x) \ for (int i = 0; i < x.size(); i++) { ...
#include <bits/stdc++.h> using namespace std; #define rep(i, x, y) for (ll i = (x); i < (y); i++) #define rrep(i, x, y) for (ll i = (ll)(y)-1; i >= (x); i--) #define all(x) (x).begin(), (x).end() #define itrout(x) \ for (int i = 0; i < x.size(); i++) { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 73], ["+", 0, 1, 0, 2, 3, 4, 0, 118, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 118, 17, 131], ["+", 0, 1, 0, 2, 3, 4, 0, 118, 119, 120]]
1
879
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define INF (1LL << 50) #define MOD 1000000007 std::vector<ll> Eratosthenes(ll N) { std::vector<bool> is_prime(N + 1); for (int i = 0; i <= N; i++) { is_prime[i] = true; } std::vector<ll> P; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define INF (1LL << 50) #define MOD 1000000007 std::vector<ll> Eratosthenes(ll N) { std::vector<bool> is_prime(N + 1); for (int i = 0; i <= N; i++) { is_prime[i] = true; } std::vector<ll> P; ...
[["-", 0, 9, 0, 7, 15, 16, 31, 16, 17, 48], ["-", 0, 7, 15, 16, 31, 16, 12, 69, 28, 22], ["-", 15, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["-", 15, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 15, 16, 31, 16, 12, 69, 341, 342, 0, 73]]
1
476
import sys input = sys.stdin.readline from math import gcd primes = set([i for i in range(2,10**6+1)]) for i in range(2,1001): for j in range(i*2,10**6+1,i): if j in primes: primes.remove(j) #primes = list(set(primes)) #print(primes[:10]) n = int(input()) a = list(map(int,input().split())) ok = ...
import sys input = sys.stdin.readline from math import gcd primes = set([i for i in range(2,10**6+1)]) for i in range(2,1001): for j in range(i*2,10**6+1,i): if j in primes: primes.remove(j) n = int(input()) a = list(map(int,input().split())) ok = 1 tmp = a[0] for i in range(1,n): tmp = gcd(tm...
[["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 102], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 121]]
5
267
#include <bits/stdc++.h> using namespace std; string solve(int arr[], int n) { int g = arr[0]; int countEven = arr[0] % 2 == 0; int MAX = 0; for (int i = 1; i < n; i++) { g = __gcd(g, arr[i]); if (arr[i] % 2 == 0) countEven++; if (arr[i] > MAX) MAX = arr[i]; } if (g > 1) { ret...
#include <bits/stdc++.h> using namespace std; string solve(int arr[], int n) { int g = arr[0]; int countEven = arr[0] % 2 == 0; int MAX = 0; for (int i = 1; i < n; i++) { g = __gcd(g, arr[i]); if (arr[i] % 2 == 0) countEven++; if (arr[i] > MAX) MAX = arr[i]; } if (g > 1) { ret...
[["-", 8, 9, 0, 7, 15, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22]]
1
327
from math import gcd N = 1000001 sieve = [-1] * (N + 1) sieve[0] = sieve[1] = 0 for i in range(N + 1): if sieve[i] != -1: continue else: index = i * i while True: if index > N: break sieve[index] = i index += i isCounted = [0] * 100000...
from math import gcd N = 1000001 sieve = [-1] * (N + 1) sieve[0] = sieve[1] = 0 for i in range(N + 1): if sieve[i] != -1: continue else: index = i * i while True: if index > N: break sieve[index] = i index += i isCounted = [0] * 100000...
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22]]
5
243
import math import functools def gcd(num : list): return functools.reduce(math.gcd, num) def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: while temp%i==0: temp //= i arr.append(i) if temp!=1: arr...
import math import functools def gcd(num : list): return functools.reduce(math.gcd, num) def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: while temp%i==0: temp //= i arr.append(i) if temp!=1: arr...
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
220
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io() { std:...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io() { std:...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 15, 339, 51, 69, 341, 342, 0, 16, 17, 33], ["+", 15, 339, 51, 69, 341, 342, 0, 16, 17, 85]]
1
458
#include <bits/stdc++.h> using namespace std; constexpr int N = 1e6 + 100; int p[N]; void init() { for (int i = 2; i < N; i++) { if (p[i]) continue; for (int j = i; j < N; j += i) { p[j] = i; } } } int main() { init(); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i+...
#include <bits/stdc++.h> using namespace std; constexpr int N = 1e6 + 100; int p[N]; void init() { for (int i = 2; i < N; i++) { if (p[i]) continue; for (int j = i; j < N; j += i) { p[j] = i; } } } int main() { init(); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i+...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
334
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n = int(input()) a = list(map(int, input().split())) def hurui(n): """n以下の素数のリストを返す """ l = list(range(2,n+1)) p = 2 i = 0 while True: l = [item ...
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n = int(input()) a = list(map(int, input().split())) from math import gcd def hurui(n): """n以下の素数のリストを返す """ l = list(range(2,n+1)) p = 2 i = 0 while Tru...
[["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["+", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]]
5
299
#include <bits/stdc++.h> #define ll long long using namespace std; const int inf = 1e6 + 9; int n, a[inf]; bitset<inf> bs; vector<int> primes; int sieve_size, g; void sieves() { sieve_size = inf / 2; bs.set(); bs[0] = bs[1] = 0; for (int i = 2; i <= sieve_size; i++) { if (bs[i]) { for (int j = i * i;...
#include <bits/stdc++.h> #define ll long long using namespace std; const int inf = 1e6 + 9; int n, a[inf]; bitset<inf> bs; vector<int> primes; int sieve_size, g; void sieves() { sieve_size = 1e3; bs.set(); bs[0] = bs[1] = 0; for (int i = 2; i <= sieve_size; i++) { if (bs[i]) { for (int j = i * i; j ...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
362
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; vector<bool> prime_table(int n) { vector<bool> prime(n + 1, true); if (n >= 0) prime[0] = false; if (n >= 1) ...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; vector<bool> prime_table(int n) { vector<bool> prime(n + 1, true); if (n >= 0) prime[0] = false; if (n >= 1) ...
[["-", 0, 338, 8, 9, 0, 1, 0, 11, 17, 107], ["-", 8, 9, 0, 1, 0, 11, 12, 118, 28, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 118, 17, 131], ["-", 8, 9, 0, 1, 0, 11, 12, 118, 119, 120], ["+", 0, 338, 8, 9, 0, 1, 0, 27, 17, 29]]
1
433
#include "bits/stdc++.h" using namespace std; const int maxn = 1000005; int a[maxn]; int cnt[maxn], mark[maxn]; vector<int> primes; int sz; void sieve() { mark[1] = 1; for (int i = 4; i < maxn; i += 2) mark[i] = 1; int root = sqrt(maxn); for (int i = 3; i <= root; i += 2) { if (!mark[i]) { for ...
#include "bits/stdc++.h" using namespace std; const int maxn = 1000005; int a[maxn]; int cnt[maxn], mark[maxn]; vector<int> primes; int sz; void sieve() { mark[1] = 1; for (int i = 4; i < maxn; i += 2) mark[i] = 1; int root = sqrt(maxn); for (int i = 3; i <= root; i += 2) { if (!mark[i]) { for ...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
493
#include <bits/stdc++.h> #define pb push_back #define ll long long #define mod 1000000007 using namespace std; int a[1000005]; int n; int np[1005], ha[1000005]; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf...
#include <bits/stdc++.h> #define pb push_back #define ll long long #define mod 1000000007 using namespace std; int a[1000005]; int n; int np[1005], ha[1000005]; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
348
#include <bits/stdc++.h> #include <cmath> #include <string> #define pb push_back #define x first #define y second #define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define all(x) x.begin(), x.end() #define int long long using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << ...
#include <bits/stdc++.h> #include <cmath> #include <string> #define pb push_back #define x first #define y second #define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define all(x) x.begin(), x.end() #define int long long using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << ...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 13]]
1
767
#include <bits/stdc++.h> #include <stdlib.h> #include <sys/time.h> #include <unistd.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> T; typedef pair<long double, ll> Ps; typedef pair<ll, bool> Pb; const ll INF = 1e18; const ll fact_table = 3200008; long double Pi = 3.14159265...
#include <bits/stdc++.h> #include <stdlib.h> #include <sys/time.h> #include <unistd.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> T; typedef pair<long double, ll> Ps; typedef pair<ll, bool> Pb; const ll INF = 1e18; const ll fact_table = 3200008; long double Pi = 3.14159265...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]]
1
940
#include <bits/stdc++.h> using namespace std; #define int ll #define ll long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807LL #define I64_MAX2 1223372036854775807LL #define INF I64_MAX2 #define MOD 1000000007 // #define MOD 998244353 #define MEM_SIZE 101010 #define DEBUG_OUT true #define ALL(x) (x)...
#include <bits/stdc++.h> using namespace std; #define int ll #define ll long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807LL #define I64_MAX2 1223372036854775807LL #define INF I64_MAX2 #define MOD 1000000007 // #define MOD 998244353 #define MEM_SIZE 101010 #define DEBUG_OUT true #define ALL(x) (x)...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38]]
1
1,128
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> vo...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> vo...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 354]]
1
731
#include <bits/stdc++.h> using namespace std; #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define int l...
#include <bits/stdc++.h> using namespace std; #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define int l...
[["-", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6]]
1
575
//#include <bits/stdc++.h> #include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<long long> vll, vLL; typed...
//#include <bits/stdc++.h> #include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<long long> vll, vLL; typed...
[["+", 51, 16, 31, 69, 341, 342, 0, 69, 28, 22], ["+", 31, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 31, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["+", 0, 11, 31, 69, 341, 342, 0, 69, 28, 22]]
1
592
#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, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
1,801
#include <algorithm> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #inclu...
#include <algorithm> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #inclu...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
527
#include <bits/stdc++.h> using namespace std; using ll = long long; string solve() { ll N; cin >> N; vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i]; ll AMAX = 1e6 + 1; vector<ll> primes(AMAX, -1); for (ll i = 2; i < AMAX; i++) { if (primes[i] > 0) continue; for (ll k = i; k * ...
#include <bits/stdc++.h> using namespace std; using ll = long long; string solve() { ll N; cin >> N; vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i]; ll AMAX = 1e6 + 1; vector<ll> primes(AMAX, -1); for (ll i = 2; i < AMAX; i++) { if (primes[i] > 0) continue; for (ll k = i; k < ...
[["-", 8, 9, 0, 7, 15, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
308
#include <bits/stdc++.h> using namespace std; const int N = 1e6; bool vis[N + 5]; int p[N + 5], a[N + 5], f[N + 5]; int cnt, n, gcdtot; void initial() { int i, j; for (i = 2; i <= N; i++) { if (!vis[i]) { f[i] = i; p[++p[0]] = i; } int t; for (j = 1; (t = i * p[j]) <= N; j++) { vi...
#include <bits/stdc++.h> using namespace std; const int N = 1e6; bool vis[N + 5]; int p[N + 5], a[N + 5], f[N + 5]; int cnt, n, gcdtot; void initial() { int i, j; for (i = 2; i <= N; i++) { if (!vis[i]) { f[i] = i; p[++p[0]] = i; } int t; for (j = 1; (t = i * p[j]) <= N; j++) { vi...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 90]]
1
374
#include <bits/stdc++.h> using namespace std; template <typename T, typename = typename std::enable_if< std::is_integral<T>::value, T>::type> vector<pair<T, int>> prime_factorize(T n) { vector<pair<T, int>> cnts{}; if (n == 1) { return cnts; } T a = 2; while (n >= a * a) { ...
#include <bits/stdc++.h> using namespace std; template <typename T, typename = typename std::enable_if< std::is_integral<T>::value, T>::type> vector<pair<T, int>> prime_factorize(T n) { vector<pair<T, int>> cnts{}; if (n == 1) { return cnts; } T a = 2; while (n >= a * a) { ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
398
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int n, a[N], tot, head[N], nex[N * 10], to[N * 10]; void add(int u, int v) { to[++tot] = v; nex[tot] = head[u]; head[u] = tot; } bool vis[N]; int main() { for (int i = 2; i <= 1000000; i++) if (!vis[i]) { for (int j = i; j <= 1000000...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int n, a[N], tot, head[N], nex[N * 10], to[N * 10]; void add(int u, int v) { to[++tot] = v; nex[tot] = head[u]; head[u] = tot; } bool vis[N]; int main() { for (int i = 2; i <= 1000000; i++) if (!vis[i]) { for (int j = i; j <= 1000000...
[["+", 15, 339, 51, 69, 341, 342, 0, 69, 28, 22], ["+", 51, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 51, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["+", 0, 11, 31, 69, 341, 342, 0, 69, 28, 22], ["+", 31, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
315
#include <bits/stdc++.h> #define mp make_pair #define eb emplace_back #define ff first #define ss second using namespace std; typedef long long ll; typedef unsigned long long ull; #ifdef ONPC mt19937 rnd(228); #else mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); #endif const int MAXN = 100; /...
#include <bits/stdc++.h> #define mp make_pair #define eb emplace_back #define ff first #define ss second using namespace std; typedef long long ll; typedef unsigned long long ull; #ifdef ONPC mt19937 rnd(228); #else mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); #endif const int MAXN = 100; /...
[["-", 8, 9, 0, 7, 8, 1, 0, 11, 17, 32], ["-", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 1, 0, 27, 17, 29]]
1
344