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
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline X, N = map(int, input().split()) P = set(map(int, input().split())) val = 1000 ans = -1 for x in range(0, 101): if x in P: continue if abs(X - x) < val: ans = x ...
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline X, N = map(int, input().split()) P = set(map(int, input().split())) val = 1000 ans = -1 for x in range(0, 102): if x in P: continue if abs(X - x) < val: ans = x ...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
114
import collections def main(): n = int(input()) al = list(map(int, input().split())) al.sort() dp = [1]*(10**6+1) for a in al: if dp[a]: dp[a] -= 1 for i in range(2,10**6//a + 1): dp[a*i] -= 2 ans = 0 for a in al: if dp[a] >= 0...
import collections def main(): n = int(input()) al = list(map(int, input().split())) al.sort() dp = [1]*(10**6+1) for a in al: if dp[a] >= 0: dp[a] -= 1 for i in range(2,10**6//a + 1): dp[a*i] -= 2 ans = 0 for a in al: if dp[a]...
[["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612]]
5
124
n = gets.to_i arr = gets.to_s.split.map(&:to_i) max = arr.max hash = {} arr.each do |num| hash[num] = hash[num].nil? ? true : false (2..max).each do |i| if num * i > max p [num, i] break end hash[num * i] = false end end count = 0 hash.each do |_num, bool| count += 1 if bool end puts c...
n = gets.to_i arr = gets.to_s.split.map(&:to_i) max = arr.max hash = {} arr.each do |num| hash[num] = hash[num].nil? ? true : false (2..max).each do |i| if num * i > max break end hash[num * i] = false end end count = 0 hash.each do |_num, bool| count += 1 if bool end puts count
[["-", 8, 736, 0, 121, 64, 749, 0, 652, 735, 22], ["-", 64, 749, 0, 652, 3, 4, 0, 516, 0, 70], ["-", 64, 749, 0, 652, 3, 4, 0, 516, 0, 22], ["-", 64, 749, 0, 652, 3, 4, 0, 516, 0, 21], ["-", 64, 749, 0, 652, 3, 4, 0, 516, 0, 73]]
4
104
import java.util.*; public class Main { public static void main(String[] args) throws Exception { // Your code here! Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] minfactor = new int[101]; boolean[] ng = new boolean[101]; for (int i = 0; i < n; i++) { int num = sc.nex...
import java.util.*; public class Main { public static void main(String[] args) throws Exception { // Your code here! Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] minfactor = new int[1000001]; boolean[] ng = new boolean[1000001]; for (int i = 0; i < n; i++) { int num ...
[["-", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499], ["+", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 499], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 499], ["-", 0, 57, 64, 196, 0, 7, 15, 16, 12, 499], ["+", 0, 57, 64, 196, 0, 7, 15, 16, 12, 499]]
3
198
#include "bits/stdc++.h" //#include <intrin.h> //AtCoder (gcc) //上ではこれがあると動かない。__popcnt用のincludeファイル。 using namespace std; typedef long long ll; typedef long double ld; #define int long long #define rep(i, n) for (long long i = 0; i < (n); i++) #define sqrt(d) pow((long double)(d), 0.50) #define PII pair<int, int> #...
#include "bits/stdc++.h" //#include <intrin.h> //AtCoder (gcc) //上ではこれがあると動かない。__popcnt用のincludeファイル。 using namespace std; typedef long long ll; typedef long double ld; #define int long long #define rep(i, n) for (long long i = 0; i < (n); i++) #define sqrt(d) pow((long double)(d), 0.50) #define PII pair<int, int> #...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
4,373
/* lib.cpp */ #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define overload4(_1, _2, _3, _4, name...
/* lib.cpp */ #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define overload4(_1, _2, _3, _4, name...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
3,305
#include <algorithm> #include <cmath> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <vector> using namespace std; #define int long long #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) ...
#include <algorithm> #include <cmath> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <vector> using namespace std; #define int long long #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
2,296
N = int(input()) A = sorted(list(map(int,input().split()))) B = (10**6+1)*[0] for a in A: B[a]+=1 if B[a]==1: for n in range(2*a,10**6+1,a): B[n]+=1 print(B.count(1))
N = int(input()) A = sorted(list(map(int,input().split()))) B = (10**6+1)*[0] for a in A: B[a]+=1 if B[a]==1: for n in range(2*a,10**6+1,a): B[n]+=2 print(B.count(1))
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612]]
5
93
#pragma region header #include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #i...
#pragma region header #include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #i...
[["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
416
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) \ for (int i = 0; i < (int)(n); i++) \ ; #define _GLIBCXX_DEBUG #define _LIBCPP_DEBUG 0 int main() { ll n; cin >> n; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) \ for (int i = 0; i < (int)(n); i++) \ ; #define _GLIBCXX_DEBUG #define _LIBCPP_DEBUG 0 int main() { ll n; cin >> n; ...
[["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 12, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 12, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 11, 31, 2, 3, 4, 0, 16, 17, 72], ...
1
293
#include <bits/stdc++.h> using namespace std; #define int long long int const int N = 1e6 + 2; int dv[N]; signed main() { int t = 1; // cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int mx = *max_element(a.begin(), a.end()); for (in...
#include <bits/stdc++.h> using namespace std; #define int long long int const int N = 1e6 + 2; int dv[N]; signed main() { int t = 1; // cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int mx = *max_element(a.begin(), a.end()); for (in...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
179
N = int(input()) As = sorted(list(map(int, input().split()))) sieve = [True] * 1000001 prev = 0 for i in range(N): if As[i] == prev: sieve[As[i]] = False continue else: prev = As[i] try: for j in range(2, 1000000 // prev + 1): sieve[prev * j] = Fals...
N = int(input()) As = sorted(list(map(int, input().split()))) sieve = [True] * 1000001 prev = 0 for i in range(N): if As[i] == prev: sieve[As[i]] = False continue else: prev = As[i] try: for j in range(2, 1000000 // prev + 1): sieve[prev * j] = Fals...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
137
def main(): n = int(input()) A = list(map(int,input().split())) ans = n A.sort() table = [True]*(A[-1]+1) for k,a in enumerate(A): if table[a]: if k+1<n and table[k+1]==a: ans-=1 for i in range(a,A[-1]+1,a): table[i] = False ...
def main(): n = int(input()) A = list(map(int,input().split())) ans = n A.sort() table = [True]*(A[-1]+1) for k,a in enumerate(A): if table[a]: if k+1<n and A[k+1]==a: ans-=1 for i in range(a,A[-1]+1,a): table[i] = False e...
[["-", 0, 57, 15, 679, 12, 666, 0, 206, 51, 22], ["+", 0, 57, 15, 679, 12, 666, 0, 206, 51, 22]]
5
124
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define MAX_SIZE 1000005 int main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; sort(A.begin(), A.end()); vector<bool> check(MAX_SIZE, true); for (int i = 0; i < N; i++) { if (!check[A[i]]) ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define MAX_SIZE 1000005 int main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; sort(A.begin(), A.end()); vector<bool> check(MAX_SIZE, true); for (int i = 0; i < N; i++) { if (!check[A[i]]) ...
[["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 35]]
1
210
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) using namespace std; using ll = long long; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; re...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) using namespace std; using ll = long long; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; re...
[["-", 0, 27, 28, 69, 341, 342, 0, 69, 28, 22], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
407
n = int(input()) A = list(map(int,input().split())) A.sort() # print(A) multiple = [0]*(A[-1]+1) for i in range(n): now = A[i] while(now <= A[-1]): multiple[now] += 1 now += now ans = 0 for i in range(n): if(multiple[A[i]] == 1): ans += 1 # print(multiple) print(ans)
n = int(input()) A = list(map(int,input().split())) A.sort() # print(A) multiple = [0]*(A[-1]+1) for i in range(n): now = A[i] while(now <= A[-1]): multiple[now] += 1 now += A[i] ans = 0 for i in range(n): if(multiple[A[i]] == 1): ans += 1 # print(multiple) print(ans)
[["-", 0, 52, 8, 196, 0, 1, 0, 677, 12, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 0, 73]]
5
112
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) typedef long long ll; constexpr auto INFI = 2147483647; const ll INFL = 9223372036854775807; int main() { const int MAX = 1000001; int n, tmp, a_max = 0; cin >> n; ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) typedef long long ll; constexpr auto INFI = 2147483647; const ll INFL = 9223372036854775807; int main() { const int MAX = 1000001; int n, tmp, a_max = 0; cin >> n; ...
[["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
196
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a[i]; } sort(a.begin(), a.end()); vector<int> v(40, 0); for (ll x : a) { if (v[x] != 0) { v[x] = 2; // ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a[i]; } sort(a.begin(), a.end()); vector<int> v(1000005, 0); for (ll x : a) { if (v[x] != 0) { v[x] = 2; ...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 75, 76, 0, 9, 0, 7, 15, 16, 12, 13], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 338, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 338, 8, 9, 0, 57, 64, 9, 0, 46]]
1
169
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int vis[N], in[N]; int main() { int n, x, mx = 0, ans = 0; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &x), mx = max(mx, x), in[x]++; for (int i = 1; i <= mx; i++) { if (!in[i]) continue; if (!vis[i] && in[x] == ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int vis[N], in[N]; int main() { int n, x, mx = 0, ans = 0; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &x), mx = max(mx, x), in[x]++; for (int i = 1; i <= mx; i++) { if (!in[i]) continue; if (!vis[i] && in[i] == ...
[["-", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 16, 31, 69, 341, 342, 0, 22]]
1
171
#include <bits/stdc++.h> using namespace std; #define CIN \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); #define TES...
#include <bits/stdc++.h> using namespace std; #define CIN \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); #define TES...
[["-", 0, 43, 49, 50, 51, 16, 31, 74, 51, 13], ["+", 0, 43, 49, 50, 51, 16, 31, 74, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
236
#include <bits/stdc++.h> using namespace std; int main() { int n, c, i, ans, j; cin >> n; int a[n]; ans = n; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (j = 0; j < n; j++) { for (i = 1; i * i <= a[j]; i++) { if (a[j] % i == 0) { if (j == 0) { if (binary...
#include <bits/stdc++.h> using namespace std; int main() { // freopen("input.txt","r",stdin); int n, c, i, ans, j; cin >> n; int a[n]; ans = n; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (j = 0; j < n; j++) { for (i = 1; i * i <= a[j]; i++) { if (a[j] % i == 0) { ...
[["-", 51, 16, 12, 2, 3, 4, 0, 16, 12, 13], ["+", 51, 16, 12, 2, 3, 4, 0, 16, 12, 13]]
1
308
<?php $n = intval(fgets(STDIN)); $data = explode(" ", trim(fgets(STDIN))); sort($data); $max = $data[$n-1]; $flags = []; for($i=0; $i<$n; $i++){ if($i>0 && $data[$i-1]==$data[$i]){ //同じ数字2回目なので、自身もフラグオン $flags[$data[$i]] = true; }else{ $j = 2; //自身を含まないように2倍からスタート while($d...
<?php $n = intval(fgets(STDIN)); $data = explode(" ", trim(fgets(STDIN))); sort($data); $max = $data[$n-1]; $flags = []; for($i=0; $i<$n; $i++){ if($i>0 && $data[$i-1]==$data[$i]){ //同じ数字2回目なので、自身もフラグオン $flags[$data[$i]] = true; }else{ $j = 2; //自身を含まないように2倍からスタート while($d...
[["-", 8, 9, 0, 52, 15, 23, 0, 16, 17, 18], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 17, 19]]
6
221
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define mp make_pair #define ff first #define ss second #define pb push_back #define fo(i, n) for (i = 0; i < n; i++) #define fo1(i, n) for (i = 1; i <= n; i++) #define FO(i, k, n) for (i = k; k <= n ? i <= n : i >= n; k <= n ? ...
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define mp make_pair #define ff first #define ss second #define pb push_back #define fo(i, n) for (i = 0; i < n; i++) #define fo1(i, n) for (i = 1; i <= n; i++) #define FO(i, k, n) for (i = k; k <= n ? i <= n : i >= n; k <= n ? ...
[["-", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46]]
1
773
n = int(input()) a = list(map(int, input().split())) a.sort() MAX = int(1e6) + 10 sieve = [0] * int(MAX) for i in a: sieve[i] += 1 ans = 0 for idx, val in enumerate(sieve): if val == 0: continue if val > 1: sieve[idx] = 0 continue ans += 1 for i in range(idx * 2, MAX, idx): ...
n = int(input()) a = list(map(int, input().split())) a.sort() MAX = int(1e6) + 10 sieve = [0] * int(MAX) for i in a: sieve[i] += 1 ans = 0 for idx, val in enumerate(sieve): if val == 0: continue elif val > 1: sieve[idx] = 0 else: ans += 1 for i in range(idx * 2, MAX, idx): ...
[["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 665, 0, 683], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102]]
5
117
N = int(input()) A = list(map(int, input().split())) S = set(A) M = max(S) A.sort() for a in A: if a == pre_a: S.discard(a) if a in S: j = a * 2 while j <= M: S.discard(j) j += a pre_a = a print(len(S))
N = int(input()) A = list(map(int, input().split())) S = set(A) M = max(S) A.sort() pre_a = 0 for a in A: if a == pre_a: S.discard(a) if a in S: j = a * 2 while j <= M: S.discard(j) j += a pre_a = a print(len(S))
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
92
#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>; const ll MX = 1000005; int main() { int n; cin >> n; vector<int> a; vector<int> cnt(MX); int ans = 0; rep(i, n) cin >> a[i]; for (int x : a) { if (cnt[x] != 0)...
#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>; const ll MX = 1000005; int main() { int n; cin >> n; vector<int> a(n); vector<int> cnt(MX); int ans = 0; rep(i, n) cin >> a[i]; for (int x : a) { if (cnt[x] !=...
[["+", 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], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22]]
1
161
#include <bits/stdc++.h> using namespace std; using p = pair<int, int>; #define int long long #define rep(i, N) for (int i = 0; i < N; i++) signed main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; vector<int> Erat(1000001); for (int C : A) { if (Erat[C] != 0) { Erat[C] = 0; ...
#include <bits/stdc++.h> using namespace std; using p = pair<int, int>; #define int long long #define rep(i, N) for (int i = 0; i < N; ++i) signed main() { int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; vector<int> Erat(1000001); for (int C : A) { if (Erat[C] != 0) { Erat[C] = 2; ...
[["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
159
N = int(input()) intList = list(map(int, input().split())) intList.sort() cntList = [1] * (intList[-1] + 1) i = 0 j = 1 ans = 0 while i < (N - 1): base = intList[i] j = 1 num = base if cntList[num] == 1: while num < intList[-1]: if cntList[num] == 1: cntList[num] = 0 j += 1 num...
N = int(input()) intList = list(map(int, input().split())) intList.sort() cntList = [1] * (intList[-1] + 1) i = 0 j = 1 ans = 0 while i < (N - 1): base = intList[i] j = 1 num = base if cntList[num] == 1: while num <= intList[-1]: if cntList[num] == 1: cntList[num] = 0 j += 1 nu...
[["-", 0, 57, 64, 196, 0, 52, 15, 666, 667, 18], ["+", 0, 57, 64, 196, 0, 52, 15, 666, 667, 19], ["-", 15, 666, 0, 206, 206, 206, 206, 664, 28, 612], ["+", 15, 666, 0, 206, 206, 206, 206, 664, 28, 612]]
5
152
// please refer from line no. 207 /////*31022618*///// //_MONU KUMAR #include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); ...
// please refer from line no. 207 /////*31022618*///// //_MONU KUMAR #include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46]]
1
1,179
from collections import Counter def main(): n = int(input()) a = sorted([int(i) for i in input().split()]) table = [True for i in range(max(a))] res = 0 amax = max(a) for i in a: if (amax ** 0.5) + 1 < i: break if table[i-1] is False: continue fo...
from collections import Counter def main(): n = int(input()) a = sorted([int(i) for i in input().split()]) table = [True for i in range(max(a))] res = 0 amax = max(a) for i in a: if (amax/2) + 1 < i: break if table[i-1] is False: continue for j i...
[["-", 15, 666, 0, 657, 31, 23, 0, 657, 17, 578], ["-", 15, 666, 0, 657, 31, 23, 0, 657, 12, 531], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 17, 85], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 12, 612]]
5
161
#include <algorithm> #include <bits/stdc++.h> #include <cassert> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #includ...
#include <algorithm> #include <bits/stdc++.h> #include <cassert> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #includ...
[["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35], ["+", 75, 76, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 75, 76, 0, 57, 64, 9, 0, 37, 0, 38]]
1
9,116
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> a(n); set<int> ss; for (int i = 0; i < n; i++) cin >> a.at(i); sort(a.begin(), a.end()); for (int i = 0; i < n - 1; i++) { if (a.at(i) == a.at(i + 1)) ss.insert(a.at(i)); } vect...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> a(n); set<int> ss; for (int i = 0; i < n; i++) cin >> a.at(i); sort(a.begin(), a.end()); for (int i = 0; i < n - 1; i++) { if (a.at(i) == a.at(i + 1)) ss.insert(a.at(i)); } vect...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 31, 13], ["+", 64, 9, 0, 7, 15, 16, 12, 16, 31, 13]]
1
238
import numpy as np def main(): N = int(input()) A = list(map(int,input().split())) A.sort() d = np.zeros(A[-1]+1, dtype=np.unit64) for i in range(N): a = A[i] a1 = A[i-1] if a != a1: d[a::a] += 1 else: d[a] += 1 print(np.count_nonzero(d[A] == 1)) print(main())
import numpy as np def main(): N = int(input()) A = list(map(int,input().split())) A.sort() d = np.zeros(A[-1]+1, dtype=np.uint64) for i in range(N): a = A[i] a1 = A[i-1] if a != a1: d[a::a] += 1 else: d[a] += 1 print(np.count_nonzero(d[A] == 1)) main()
[["-", 12, 652, 3, 4, 0, 653, 51, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 653, 51, 319, 319, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
123
n=int(input()) a=list(map(int,input().split())) dp=[False]*(10**6+1) for i in a: dp[i]=True for i in range(10**6+1): if dp[i]: for j in range(2*i,10**6+1,i): dp[j]=False print(dp.count(1))
n=int(input()) a=list(map(int,input().split())) dp=[0]*(10**6+1) for i in a: dp[i]+=1 for i in range(1,10**6+1): if dp[i]: for j in range(2*i,10**6+1,i): dp[j]=0 print(dp.count(1))
[["-", 0, 1, 0, 662, 12, 657, 31, 634, 0, 147], ["+", 0, 1, 0, 662, 12, 657, 31, 634, 0, 612], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 146], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0...
5
100
n = int(input()) a = list(map(int, input().split())) M=max(a) ok = [0]*(M+1) a.sort() for i in range(n): ok[a[i]] += 1 for i in range(n): if ok[a[i]] == 1: for g in range(a[i], M+1, a[i]): if g != a[i]: ok[g] = 0 print(ok.count(1))
n = int(input()) a = list(map(int, input().split())) M = max(a) ok = [0]*(M+1) a.sort() for i in range(n): ok[a[i]] += 1 for i in range(n): if ok[a[i]] != 0: for g in range(a[i], M+1, a[i]): if g != a[i]: ok[g] = 0 print(ok.count(1))
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 60], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612]]
5
126
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); vector<bool> dp(1000001, true); sort(A.begin(), A.end()); for (int i = 0; i < N - 1; i++) { if (!dp.at(i)) continue; if (A.at(i) == A.at(i + 1)) ...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); vector<bool> dp(1000001, true); sort(A.begin(), A.end()); for (int i = 0; i < N - 1; i++) { if (!dp.at(A.at(i))) continue; if (A.at(i) == A.at(i + 1)...
[["+", 28, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["+", 28, 2, 3, 4, 0, 2, 63, 118, 17, 131], ["+", 28, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 28, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 28, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
222
N = int(input()) A = list(map(int, input().split())) A.sort() MAX = 10**6+1 cnt = [0]*MAX for x in A: if cnt[x] != 0: cnt[i] = 2 else: for i in range(x, MAX, x): cnt[i] += 1 ans = 0 for x in A: # 2回以上通った数字 (cnt[x]>1) は,その数字より小さい約数が存在する (割り切れる他の数が存在する)。 if cnt[x] == 1: ans += 1 print(...
N = int(input()) A = list(map(int, input().split())) A.sort() MAX = 10**6+1 cnt = [0]*MAX for x in A: if cnt[x] != 0: cnt[x] = 2 else: for i in range(x, MAX, x): cnt[i] += 1 ans = 0 for x in A: # 2回以上通った数字 (cnt[x]>1) は,その数字より小さい約数が存在する (割り切れる他の数が存在する)。 if cnt[x] == 1: ans += 1 print(...
[["-", 64, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 206, 22]]
5
107
n = int(input()) a = list(map(int,input().split())) m = max(a) li = [0]*m for x in a: li[x] += 1 ans = 0 for i in range(1,m): if li[i]: if li[i]==1: ans += 1 for j in range(i,m,i): li[j] = 0 print(ans)
n = int(input()) a = list(map(int,input().split())) m = max(a) + 1 li = [0]*m for x in a: li[x] += 1 ans = 0 for i in range(1,m): if li[i]: if li[i]==1: ans += 1 for j in range(i,m,i): li[j] = 0 print(ans)
[["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]]
5
101
n = int(input()) a = list(map(int,input().split())) cnt = [0] * 40 for x in a: if cnt[x] != 0: cnt[x] = 2 else: for i in range(x,40,x): cnt[i] += 1 ans = 0 for x in a: if cnt[x] == 1: ans += 1 print(ans)
n = int(input()) a = list(map(int,input().split())) cnt = [0] * 1000005 for x in a: if cnt[x] != 0: cnt[x] = 2 else: for i in range(x,1000005,x): cnt[i] += 1 ans = 0 for x in a: if cnt[x] == 1: ans += 1 print(ans)
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
94
n=int(input()) a=list(map(int,input().split())) a.sort() am=max(a) dp=[[True,0] for _ in range(am+1)] count=0 for i in a: if dp[i][0]==False: continue else: if dp[i][1]==1: dp[i][0]=False count-=1 else: dp[i][1]=1 count+=1 for j...
n=int(input()) a=list(map(int,input().split())) a.sort() am=max(a) dp=[[True,0] for _ in range(am+1)] count=0 for i in a: if dp[i][0]==False: continue else: if dp[i][1]==1: dp[i][0]=False count-=1 else: dp[i][1]=1 count+=1 for j...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 48]]
5
140
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_string(const s...
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_string(const s...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
874
def main(): N = int(input()) A = list(map(int, input().split())) A = sorted(A) Amax = A[-1] count = [0 for _ in range(Amax+1)] for a in A: for i in range(1, Amax//a+1): count[i*a] += 1 ans = 0 for i in range(N): a = A[i] if count[a] == 1: ...
def main(): N = int(input()) A = list(map(int, input().split())) A = sorted(A) Amax = A[-1] count = [0 for _ in range(Amax+1)] for a in A: for i in range(1, Amax//a+1): count[i*a] += 1 ans = 0 for i in range(N): a = A[i] if count[a] == 1: # ...
[["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
131
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int a_max = *max_element(a.begin(), a.end()); vector<int> b(a_max + 1, 0); for (int i = 0; i < n - 1; i++) { if (b[a[i]] != 0)...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int a_max = *max_element(a.begin(), a.end()); vector<int> b(a_max + 1, 0); for (int i = 0; i < n; i++) { if (b[a[i]] != 0) { ...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
226
n=int(input()) a=list(map(int,input().split())) a.sort() ans=0 x=[0]+[True]*10**6 for i in range(len(a)): cnt=a[i] if x[a[i]]==True and (i==0 or a[i]!=a[i-1]) and (i==(n-1) or a[i]!=a[i+1]): ans+=1 while cnt<=10**6: x[cnt]=False cnt+=a[i] elif x[a[i]]==True and (i!...
n=int(input()) a=list(map(int,input().split())) a.sort() ans=0 x=[0]+[True]*10**6 for i in range(len(a)): cnt=a[i] if x[a[i]]==True and (i==0 or a[i]!=a[i-1]) and (i==(n-1) or a[i]!=a[i+1]): ans+=1 while cnt<=10**6: x[cnt]=False cnt+=a[i] elif x[a[i]]==True and ((i...
[["+", 15, 679, 12, 23, 0, 679, 31, 23, 0, 24], ["-", 8, 196, 0, 57, 75, 665, 15, 679, 17, 355], ["+", 75, 665, 15, 679, 12, 23, 0, 679, 17, 354], ["+", 15, 679, 12, 23, 0, 679, 12, 23, 0, 25]]
5
210
#include <algorithm> #include <iostream> #include <vector> using namespace std; const int mxN = 2e5; int n, a[mxN], ans, amt[1000001]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (int i = 0; i < n; i++) { for (int j = a[i]; j < a[n - 1]; j += a[i]) ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; const int mxN = 2e5; int n, a[mxN], ans, amt[1000001]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (int i = 0; i < n; i++) { for (int j = a[i]; j <= a[n - 1]; j += a[i]) ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
160
n = int(input()) a = list(map(int,input().split())) a = sorted(a) aMax = a[-1] l = len(a) count = 0 k = 0 kSet = set() for i in range(n): value = a[i] if not(value in kSet): if a[i-1] == value: count -= 1 kSet.add(value) continue count += 1 j = 2 ...
n = int(input()) a = list(map(int,input().split())) a = sorted(a) aMax = a[-1] l = len(a) count = 0 k = 0 kSet = set() for i in range(n): value = a[i] if not(value in kSet): if i != 0 and a[i-1] == value: count -= 1 kSet.add(value) continue count += 1 ...
[["+", 64, 196, 0, 57, 15, 679, 31, 666, 0, 22], ["+", 64, 196, 0, 57, 15, 679, 31, 666, 667, 79], ["+", 64, 196, 0, 57, 15, 679, 31, 666, 0, 612], ["+", 0, 57, 64, 196, 0, 57, 15, 679, 17, 355]]
5
134
n=int(input()) a=list(map(int,input().split())) m=max(a) alsit=[0]*(m+1) for i in a: for j in range(i,m+1,i): alist[j]+=1 cnt=0 for i in a: if alist[i]==1: cnt+=1 print(cnt)
n=int(input()) a=list(map(int,input().split())) m=max(a) alist=[0]*(m+1) for i in a: for j in range(i,m+1,i): alist[j]+=1 cnt=0 for i in a: if alist[i]==1: cnt+=1 print(cnt)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22]]
5
90
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; vector<int> v; // bool arr[MAXN] ; vector<bool> arr(MAXN); int countz[MAXN]; void sieve() { for (auto x : v) { if (!arr[x]) { for (int i = 2 * x; i < MAXN; i += x) { arr[i] = true; } } } } int main() { int n; cin...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; vector<int> v; // bool arr[MAXN] ; vector<bool> arr(MAXN); int countz[MAXN]; void sieve() { for (auto x : v) { if (!arr[x]) { for (int i = 2 * x; i < MAXN; i += x) { arr[i] = true; } } } } int main() { int n; cin...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 28, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 17, 131], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 119, 120], ["+", 0, 7, 15, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 7, 15, 16, 12, 2, 3, 4, 0, 25]]
1
237
import itertools N = int(input()) A = list(map(int, input().split())) count = {} for a in A: if a not in count: count[a] = 0 count[a] += 1 def check(a): if count[a] > 1: return 0 if 1 in count: if a == 1 and count[1] == 1: return 1 return 0 #print(a) ok = True sqr_a = 1 + int(a**0...
import itertools N = int(input()) A = list(map(int, input().split())) count = {} for a in A: if a not in count: count[a] = 0 count[a] += 1 def check(a): if count[a] > 1: return 0 if 1 in count: if a == 1 and count[1] == 1: return 1 return 0 #print(a) ok = True sqr_a = 1 + int(a**0...
[["-", 0, 7, 8, 196, 0, 52, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 52, 15, 666, 0, 22]]
5
189
#include <iostream> using namespace std; int pos[1000001]; #include <cmath> bool done[1000001]; int main() { int n; cin >> n; int arr[n]; int ans = n; for (int i = 0; i < n; i++) { cin >> arr[i]; pos[arr[i]]++; // if(pos[arr[i]]>1)ans--; } for (int i = 1; i <= 1e6; i++) { if (pos[i] > 1) ...
#include <iostream> using namespace std; int pos[1000001]; #include <cmath> bool done[1000001]; int main() { int n; cin >> n; int arr[n]; int ans = n; for (int i = 0; i < n; i++) { cin >> arr[i]; pos[arr[i]]++; } for (int i = 1; i <= 1e6; i++) { if (pos[i] > 1) { ans -= pos[i]; do...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
265
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) #define MAX(a, b) a = a > b ? a : b #define MIN(a, b) a = a < b ? a : b #define REP(i, x, n) for (int i = x; i < n; i++) #define REPR(i, x, n) for (int i = n - 1; i >= x; i--) #define pb push_back ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) #define MAX(a, b) a = a > b ? a : b #define MIN(a, b) a = a < b ? a : b #define REP(i, x, n) for (int i = x; i < n; i++) #define REPR(i, x, n) for (int i = n - 1; i >= x; i--) #define pb push_back ...
[["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22]]
1
1,471
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define endl "\n" const ll limit = 1e6 + 10; ll arr[limit]; void sieve() { for (ll i = 2; i < limit; i++) { if (arr[i] > 0) { for (ll j = i + i; j < limit; j +=...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define endl "\n" const ll limit = 1e6 + 10; ll arr[limit]; void sieve() { for (ll i = 1; i < limit; i++) { if (arr[i] > 0) { for (ll j = i + i; j < limit; j +=...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 14, 8,...
1
185
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; using P = pair<int, int>; const int M = 1000005; int main() { int n; cin >> n; vector<int> as(n); rep(i, n) cin >> as[i]; vector<int> cnt(M); for (int x : as) { if (cnt[x] != 0) { ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; using P = pair<int, int>; const int M = 1000005; int main() { int n; cin >> n; vector<int> as(n); rep(i, n) cin >> as[i]; vector<int> cnt(M); for (int x : as) { if (cnt[x] != 0) { ...
[["+", 0, 14, 8, 9, 0, 338, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 338, 8, 9, 0, 46]]
1
166
#include <bits/stdc++.h> #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++) #define pi 3.14159265359 #define all(i) i.begin(), i.end() using namespace std; const long long INF = 1e9 + 7; const string alp = "abcdefghijklmnopqrstuvwxyz"; // 26 const string ALP ...
#include <bits/stdc++.h> #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++) #define pi 3.14159265359 #define all(i) i.begin(), i.end() using namespace std; const long long INF = 1e9 + 7; const string alp = "abcdefghijklmnopqrstuvwxyz"; // 26 const string ALP ...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46]]
1
272
#include <bits/stdc++.h> #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++) #define pi 3.14159265359 #define all(i) i.begin(), i.end() using namespace std; const long long INF = 1e9 + 7; const string alp = "abcdefghijklmnopqrstuvwxyz"; // 26 const string ALP ...
#include <bits/stdc++.h> #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++) #define pi 3.14159265359 #define all(i) i.begin(), i.end() using namespace std; const long long INF = 1e9 + 7; const string alp = "abcdefghijklmnopqrstuvwxyz"; // 26 const string ALP ...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46]]
1
279
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; bool a[1000005]; for (int i = 0; i <= 1000004; i++) { a[i] = true; } int in; map<int, int> m; for (int i = 0; i < n; i++) { cin >> in; m[in]++; } for (auto j : m) { ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; bool a[1000005]; for (int i = 0; i <= 1000004; i++) { a[i] = true; } int in; map<int, int> m; for (int i = 0; i < n; i++) { cin >> in; m[in]++; } for (auto j : m) { ...
[["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 35]]
1
191
n = int(input()) a = set(map(int, input().split())) xs = [0] * (max(a) + 1) for v in a: if xs[v] == 0: for j in range(v, len(xs), v): xs[j] += 1 else: xs[v] += 1 print(len(list(filter(lambda v: xs[v] == 1, a))))
n = int(input()) a = list(map(int, input().split())) xs = [0] * (max(a) + 1) for v in a: if xs[v] == 0: for j in range(v, len(xs), v): xs[j] += 1 else: xs[v] += 1 print(len(list(filter(lambda v: xs[v] == 1, a))))
[["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22]]
5
104
n=int(input()) A=list(map(int,input().split())) m=max(A) X=[True]*(m+1) A.sort() for i in range(n): for j in range(A[i]*2,m+1,A[i]): X[j]=False ans=0 for i in range(n): if X[A[i]]==True: ans+=1 print(ans)
n=int(input()) A=list(map(int,input().split())) m=max(A) X=[0]*(m+1) A.sort() for i in range(n): for j in range(A[i],m+1,A[i]): X[j]+=1 ans=0 for i in range(n): if X[A[i]]==1: ans+=1 print(ans)
[["-", 0, 1, 0, 662, 12, 657, 31, 634, 0, 146], ["+", 0, 1, 0, 662, 12, 657, 31, 634, 0, 612], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 48], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 147], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["+", ...
5
112
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <iostream> #include <map> using namespace std; const int MAXN = 1e6 + 5; int a[MAXN] = {0}; map<int, int> mm; int solve(int n) { /* if(mm[n]>1||mm[1]) return 0; for(int i=2;i*i<=n;++i){ if(n%i==0){ mm[n]--; if...
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <iostream> #include <map> using namespace std; const int MAXN = 1e6 + 5; int a[MAXN] = {0}; map<int, int> mm; int solve(int n) { /* if(mm[n]>1||mm[1]) return 0; for(int i=2;i*i<=n;++i){ if(n%i==0){ mm[n]--; if...
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
221
n = int(input()) A = list(map(int, input().split())) MAX_N = max(A)+1 cnt = [0] * MAX_N for a in A: for i in range(a, MAX_N, a): if cnt[i] >= 2: break cnt[i] += 1 ans = 0 for a in A: if cnt[a] == 1: ans += 1 print(ans)
n = int(input()) A = list(map(int, input().split())) MAX_N = max(A)+ 1 cnt = [0] * MAX_N for a in A: for i in range(a, MAX_N, a): if cnt[i] <= 2: cnt[i] += 1 ans = 0 for a in A: if cnt[a] == 1: ans += 1 print(ans)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
95
#include <algorithm> #include <climits> #include <cmath> #include <functional> #include <iostream> #include <vector> int main(void) { int N, res = 0; std::vector<bool> dp(1000001, false); std::cin >> N; std::vector<int> A(N, 0); for (int i = 0; i < N; i++) { std::cin >> A[i]; dp[A[i]] = true; } s...
#include <algorithm> #include <climits> #include <cmath> #include <functional> #include <iostream> #include <vector> int main(void) { int N, res = 0; std::vector<bool> dp(1000001, false); std::cin >> N; std::vector<int> A(N, 0); for (int i = 0; i < N; i++) { std::cin >> A[i]; dp[A[i]] = true; } s...
[["-", 0, 57, 75, 76, 0, 57, 64, 9, 0, 45], ["-", 75, 76, 0, 57, 64, 9, 0, 1, 0, 35], ["-", 75, 76, 0, 57, 64, 9, 0, 116, 0, 117], ["-", 0, 57, 75, 76, 0, 57, 64, 9, 0, 46]]
1
239
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define mp make_pair #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define rep(i, a, b) for (int i = (a); i < (b); ++i) std::mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); using namespace s...
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define mp make_pair #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define rep(i, a, b) for (int i = (a); i < (b); ++i) std::mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); using namespace s...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
650
#include <stdio.h> #include <stdlib.h> int main() { int N, A[(int)2e5], max = 0; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d", &A[i]); if (max < A[i]) max = A[i]; } // end input int e[(int)1e6 + 1] = {0}; for (int i = 0; i < N; i++) { int n = A[i]; for (int j = A[i] * ...
#include <stdio.h> #include <stdlib.h> int main() { int N, A[(int)2e5], max = 0; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d", &A[i]); if (max < A[i]) max = A[i]; } // end input int e[(int)1e6 + 1] = {0}; for (int i = 0; i < N; i++) { int n = A[i]; for (int j = A[i] * ...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
0
242
n,*a=map(int,open(0).read().split()) a.sort() num=[True for i in range(a[-1]+1)] for i in range(n): if num[a[i]]: for j in range(a[-1]//a[i]): if j<2: continue num[a[i]*j]=False if i==n-1: pass elif a[i]==a[i+1]: num[a[i]]=False else: pass else: continue ans...
n,*a=map(int,open(0).read().split()) a.sort() num=[True for i in range(a[-1]+1)] for i in range(n): if num[a[i]]: for j in range(a[-1]//a[i]+1): if j<2: continue num[a[i]*j]=False if i==n-1: pass elif a[i]==a[i+1]: num[a[i]]=False else: pass else: continue a...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
159
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collection...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collection...
[["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]]
5
203
#include <bits/stdc++.h> using namespace std; typedef long long lol; //マクロ // forループ関係 //引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか // Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる #define REP(i, n) for (lol i = 0; i < lol(n); i++) #define REPD(i, n) for (lol i = n - 1; i >= 0; i--) #define FOR(i, a, b) fo...
#include <bits/stdc++.h> using namespace std; typedef long long lol; //マクロ // forループ関係 //引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか // Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる #define REP(i, n) for (lol i = 0; i < lol(n); i++) #define REPD(i, n) for (lol i = n - 1; i >= 0; i--) #define FOR(i, a, b) fo...
[["-", 15, 339, 51, 16, 31, 23, 0, 16, 17, 47], ["+", 15, 339, 51, 16, 31, 23, 0, 16, 17, 20]]
1
398
#import time def main(): N = int(input()) As = list(map(int, input().split())) As.sort() amax = max(As) + 1 lis = [True] * amax ans = 0 for i in range(N-1): if lis[As[i]]: for j in range(As[i], amax, As[i]): lis[j] = False if a[i] < a[i+1]: ...
#import time def main(): N = int(input()) As = list(map(int, input().split())) As.sort() amax = max(As) + 1 lis = [True] * amax ans = 0 for i in range(N-1): if lis[As[i]]: for j in range(As[i], amax, As[i]): lis[j] = False if As[i] < As[i+1]...
[["-", 64, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 64, 196, 0, 57, 15, 666, 0, 206, 51, 22]]
5
141
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const ll mod = 1e9 + 7; const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i];...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const ll mod = 1e9 + 7; const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i];...
[["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 45], ["-", 64, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]]
1
241
counter = [0 for i in range(10**6+1)] n = int(input()) a = sorted(list(map(int,input().split()))) for i in a: counter[i] += 1 l = [0 for i in range(10**6+1)] cou = 0 for i in range(n): b = a[i] if l[b]==0: cou += 1 for j in range(b,10**6+1,b): l[j] = 1 if counter[j]>=2: cou -=1 print(cou)
counter = [0 for i in range(10**6+1)] n = int(input()) a = sorted(list(map(int,input().split()))) for i in a: counter[i] += 1 l = [0 for i in range(10**6+1)] cou = 0 for i in range(n): b = a[i] if l[b]==0: cou += 1 for j in range(b,10**6+1,b): l[j] = 1 if counter[b]>=2: cou -=1 print(cou)
[["-", 64, 196, 0, 57, 15, 666, 0, 206, 206, 22], ["+", 64, 196, 0, 57, 15, 666, 0, 206, 206, 22]]
5
136
n = int(input()) *A, = map(int, input().split()) # C[a] = A内のaの個数 C = {a: 0 for a in A} for a in A: C[a] += 1 # D[a]=1: Aにaより小さいaの約数が存在する D = {a: 0 for a in A} for a in A: if C[a] > 0: tmp = 2 while a * tmp <= maxA: D[a * tmp] = 1 tmp += 1 ans = 0 for a in A: if C[a] ...
n = int(input()) *A, = map(int, input().split()) maxA = max(A) # C[a] = A内のaの個数 C = {a: 0 for a in A} for a in A: C[a] += 1 # D[a]=1: Aにaより小さいaの約数が存在する D = {a: 0 for a in A} for a in A: if C[a] > 0: tmp = 2 while a * tmp <= maxA: D[a * tmp] = 1 tmp += 1 ans = 0 for a in A...
[["+", 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
123
#include <bits/stdc++.h> using namespace std; typedef long long int lli; #define MAX 200005 #define INF 1000005 #define endl "\n" int arr[MAX]; int f[INF]; bool p[INF]; bool flag[MAX]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); for (int i = 2; i <= INF; i++) { if (!p[i]) { for (lli j ...
#include <bits/stdc++.h> using namespace std; typedef long long int lli; #define MAX 200005 #define INF 1000005 #define endl "\n" int arr[MAX]; int f[INF]; bool p[INF]; bool flag[MAX]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); for (lli i = 2; i <= INF; i++) { if (!p[i]) { for (lli j ...
[["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 39, 78], ["-", 0, 7, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 7, 8, 9, 0, 7, 10, 43, 39, 78]]
1
326
#include <bits/stdc++.h> using namespace std; int N, A[200005], freq[1000005]; bool isPossible(int currIdx) { int currNum = A[currIdx]; for (int i = 2; i * i <= currNum; i++) { if (currNum % i == 0) { if (freq[i] > 0 || freq[currNum / i] > 0) return false; } } if (freq[currNum] > 1) ...
#include <bits/stdc++.h> using namespace std; int N, A[200005], freq[1000005]; bool isPossible(int currIdx) { int currNum = A[currIdx]; for (int i = 2; i * i <= currNum; i++) { if (currNum % i == 0) { if (freq[i] > 0 || freq[currNum / i] > 0) return false; } } if (freq[currNum] > 1) ...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
205
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, b, n) for (int i = b; i < (b) + (n); i++) using namespace std; using ll = long long; const int M = 1000005; int main() { int n; cin >> n; vector<int> a(n); vector<int> p(M); rep(i, n) cin >> a[i]; rep(i, n) { if (p...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, b, n) for (int i = b; i < (b) + (n); i++) using namespace std; using ll = long long; const int M = 1000005; int main() { int n; cin >> n; vector<int> a(n); vector<int> p(M); rep(i, n) cin >> a[i]; rep(i, n) { if (p...
[["+", 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
173
#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 int long long #define ordered_set \ tree < int, null_type, ...
#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 int long long #define ordered_set \ tree < int, null_type, ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
237
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; using namespace std; const double PI = 3.14159265358979323846; typedef long long ll; const double EPS = 1e-9; #define rep(i, n) for (int i = 0; i < (n); ++i) //#define rep(i, n) for (ll i = 0; i < (n); ++i)...
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; using namespace std; const double PI = 3.14159265358979323846; typedef long long ll; const double EPS = 1e-9; #define rep(i, n) for (int i = 0; i < (n); ++i) //#define rep(i, n) for (ll i = 0; i < (n); ++i)...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
413
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; #define repi(i, a, b) for (ll i = a; i < b; i++) #define rep(i, a) repi(i, 0, a) #define rrep(i, a) for (ll i = a - 1; i >= 0; i--) #define MOD 1000000007 // debug #define debug(arr) ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; #define repi(i, a, b) for (ll i = a; i < b; i++) #define rep(i, a) repi(i, 0, a) #define rrep(i, a) for (ll i = a - 1; i >= 0; i--) #define MOD 1000000007 // debug #define debug(arr) ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
211
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10) func main() { N := getStdinInt64() A := getStdinIntArr64() var i int64 = 0 //var j int64 = 0 //var cnt int64 = 0 var max int64 = 0 // 最大値を求める for i = 0; i < N; i++ { if A[i] > max { ...
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10) func main() { N := getStdinInt64() A := getStdinIntArr64() var i int64 = 0 //var j int64 = 0 //var cnt int64 = 0 var max int64 = 0 // 最大値を求める for i = 0; i < N; i++ { if A[i] > max { ...
[["-", 8, 196, 0, 57, 15, 16, 31, 437, 439, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 437, 0, 70], ["-", 8, 196, 0, 57, 15, 16, 31, 437, 71, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 437, 0, 73], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98]]
7
906
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, ans = 0, Max = 0; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; Max = max(A[i], Max); } sort(A.begin(), A.end()); vector<bool> OK(Max, true); vector<int> overlap(Max, 0);...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, ans = 0, Max = 0; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; Max = max(A[i], Max); } sort(A.begin(), A.end()); vector<bool> OK(Max + 1, true); vector<int> overlap(Max ...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
220
#include <bits/stdc++.h> #define ss second #define ff first #define all(x) x.begin(), x.end() using namespace std; using ll = long long; using pii = pair<ll, ll>; const int oo = 1e9 + 7; const int mod = 1e9 + 7, maxn = 1000010; const long double PI = acos(-1); int main() { ios_base::sync_with_stdio(false); cin.t...
#include <bits/stdc++.h> #define ss second #define ff first #define all(x) x.begin(), x.end() using namespace std; using ll = long long; using pii = pair<ll, ll>; const int oo = 1e9 + 7; const int mod = 1e9 + 7, maxn = 1000010; const long double PI = acos(-1); int main() { ios_base::sync_with_stdio(false); cin.t...
[["-", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46], ["+", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46]]
1
244
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n = int(readline()) a = list(map(int,readline().split())) a.sort() if a[0] == a[-1]: if n > 1: print(0) else: print(1) exit() if a[0] == 1: if a[0] == a[1]: print(0) else: prin...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n = int(readline()) a = list(map(int,readline().split())) a.sort() if a[0] == a[-1]: if n > 1: print(0) else: print(1) exit() if a[0] == 1: if a[0] == a[1]: print(0) else: prin...
[["+", 15, 679, 12, 23, 0, 679, 31, 23, 0, 24], ["+", 8, 196, 0, 57, 15, 679, 12, 23, 0, 25]]
5
410
from collections import Counter import bisect n = int(input()) #リストの要素数 a = list(map(int, input().split())) #リストの要素 cnt = Counter(a) #aの要素数についての辞書 a.sort()#aを小さい順にソート ans = 0 mx = 10 ** 6 p = [0] * (mx + 1) for i in a: if p[a] == 0: for j in range(mx + 1): x = i * j if x > mx: ...
from collections import Counter import bisect n = int(input()) #リストの要素数 a = list(map(int, input().split())) #リストの要素 cnt = Counter(a) #aの要素数についての辞書 a.sort()#aを小さい順にソート ans = 0 mx = 10 ** 6 p = [0] * (mx + 1) for i in a: if p[i] == 0: for j in range(mx + 1): x = i * j if x > mx: ...
[["-", 8, 196, 0, 57, 15, 666, 0, 206, 206, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 206, 22], ["-", 64, 196, 0, 57, 15, 666, 0, 206, 206, 22], ["+", 64, 196, 0, 57, 15, 666, 0, 206, 206, 22]]
5
122
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using i64 = int64_t; using P = p...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using i64 = int64_t; using P = p...
[["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 73]]
1
286
#include <bits/stdc++.h> using namespace std; #define MAX 1000000 int dp[MAX + 1]; int main() { int N; cin >> N; int A[N]; for (int i = 0; i < N; i++) { cin >> A[i]; } for (int i = 0; i < MAX + 1; i++) { dp[i] = 0; } for (int x : A) { if (dp[x] != 0) { dp[x] = 2; continue; ...
#include <bits/stdc++.h> using namespace std; #define MAX 1000005 int dp[MAX]; int main() { int N; cin >> N; int A[N]; for (int i = 0; i < N; i++) { cin >> A[i]; } for (int i = 0; i < MAX; i++) { dp[i] = 0; } for (int x : A) { if (dp[x] != 0) { dp[x] = 2; continue; } fo...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 30, 0, 43, 49, 80, 81, 16, 17, 72], ["-", 0, 30, 0, 43, 49, 80, 81, 16, 12, 13], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 1, 0, 27, 28, 69, 341, 342, 0, 22], ["+", 0,...
1
183
n = int(input()) l = [int(x) for x in input().split()] set_l = set(l) set_l = sorted(set_l) limit = 10**6+1 mp = [0]*(limit) pre = None for i in range(n): num = l[i] if(pre==num): mp[num] += 1 pre = num for x in set_l: for y in range(x,limit,x): mp[y] += 1 cnt = 0 for num in ...
n = int(input()) l = [int(x) for x in input().split()] l.sort() set_l = set(l) set_l = sorted(set_l) limit = 10**6+1 mp = [0]*(limit) pre = None for i in range(n): num = l[i] if(pre==num): mp[num] += 1 pre = num for x in set_l: for y in range(x,limit,x): mp[y] += 1 cnt = 0 for...
[["+", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
135
#include <algorithm> #include <assert.h> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #includ...
#include <algorithm> #include <assert.h> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #includ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 9, 0, 57, 64, 116, 0, 117], ["-", 8, 9, 0, 9, 0, 57, 64, 116, 0, 35], ["+", 8, 9, 0, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 9, 0, 57, 64, 9, 0, 46], ["+", 8, 9, 0, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 9, 0, 1, 0, 2,...
1
288
N = int(input()) A = list(map(int, input().split())) M = 10**6 + 2 cnt = [0 for _ in range(M)] A.sort() for i in A: if cnt[i] != 0: # cnt[i]がそれまでに出てきた数値で割り切れていたとき cnt[i] = 2 # cnt[i]の倍数はどうせすでに1か2になっているので考慮しなくていい continue j = i while j < M: cnt[j] += 1 j += i ans = 0 for i in...
N = int(input()) A = list(map(int, input().split())) M = 10**6 + 2 cnt = [0 for _ in range(M)] A.sort() for i in A: if cnt[i] != 0: # cnt[i]がそれまでに出てきた数値で割り切れていたとき cnt[i] = 2 # cnt[i]の倍数はどうせすでに1か2になっているので考慮しなくていい continue j = i while j < M: cnt[j] += 1 j += i ans = 0 for i in...
[["-", 36, 36, 36, 36, 0, 656, 0, 7, 12, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 12, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 0, 70], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 0, 73]]
5
108
// g++ -std=c++11 a.cpp #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #incl...
// g++ -std=c++11 a.cpp #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #incl...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 33], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
479
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define INX(x) (cin >> x) #define INXV(vec, cnt) \ for (ll i; i < cnt; i++) \ INX(vec[i]) #define OUTX(x) (cout <...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define INX(x) (cin >> x) #define INXV(vec, cnt) \ for (ll i; i < cnt; i++) \ INX(vec[i]) #define OUTX(x) (cout <...
[["+", 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
298
#include <bits/stdc++.h> #include <unordered_map> #define mp make_pair #define pb push_back #define f first #define s second #define REP(i, a, b) for (int i = a; i <= b; i++) using namespace std; typedef long long ll; typedef pair<ll, ll> pi; const int LIM = 2000111; int y[LIM] = {0}; int main() { ios::sync_with_s...
#include <bits/stdc++.h> #include <unordered_map> #define mp make_pair #define pb push_back #define f first #define s second #define REP(i, a, b) for (int i = a; i <= b; i++) using namespace std; typedef long long ll; typedef pair<ll, ll> pi; const int LIM = 2000111; int y[LIM] = {0}; int main() { ios::sync_with_s...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
243
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline n = int(input()) a = list( map(int, input().split())) a.sort() from collections import Counter cnt = Counter(a) if a[0]==1: if n==1: print(1) else: print(0) exit() limit = a[-1] is_prime = [0] * (limit + 1) for aa in a...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline n = int(input()) a = list( map(int, input().split())) a.sort() from collections import Counter cnt = Counter(a) if a[0]==1: if cnt[1]==1: print(1) else: print(0) exit() limit = a[-1] is_prime = [0] * (limit + 1) for a...
[["-", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22], ["+", 64, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 64, 196, 0, 57, 15, 666, 0, 206, 0, 70], ["+", 64, 196, 0, 57, 15, 666, 0, 206, 206, 612], ["+", 64, 196, 0, 57, 15, 666, 0, 206, 0, 73]]
5
190
def main(): N = int(input()) A = list(map(int, input().split())) A.sort() MAX = A[-1] dp = [1] * (MAX + 5) ANS = 0 for i in range(N): if dp[A[i]] == 0: continue for j in range(MAX): if A[i]*j > MAX: break dp[A[i]*j] = 0 ...
def main(): N = int(input()) A = list(map(int, input().split())) A.sort() MAX = A[-1] dp = [1] * (MAX + 5) ANS = 0 for i in range(N): if dp[A[i]] == 0: continue for j in range(MAX+1): if A[i]*j > MAX: break dp[A[i]*j] = 0 ...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
152
N=int(input()) A=list(map(int,input().split())) A.sort(reverse=True) max_a=A[0] dp=[True]*(max_a+1) ans=0 for i in range(N): a=A[i] #print(a) if dp[a]==True: if i==N-1: ans+=1 elif a!=A[i+1]: ans+=1 k=a while k<=max_a: dp[k]=False k+=a print(ans)
N=int(input()) A=list(map(int,input().split())) A.sort() max_a=A[-1] dp=[True]*(max_a+1) ans=0 for i in range(N): a=A[i] #print(a) if dp[a]==True: if i==N-1: ans+=1 elif a!=A[i+1]: ans+=1 k=a while k<=max_a: dp[k]=False k+=a print(ans)
[["-", 0, 1, 0, 652, 3, 4, 0, 653, 141, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 653, 0, 32], ["-", 0, 1, 0, 652, 3, 4, 0, 653, 51, 146], ["-", 0, 656, 0, 1, 0, 662, 12, 206, 206, 612], ["+", 0, 1, 0, 662, 12, 206, 206, 664, 17, 33], ["+", 0, 1, 0, 662, 12, 206, 206, 664, 28, 612]]
5
120
N = int(input()) A = list(map(int, input().split())) MAX = max(A) dp = [True for _ in range(MAX+1)] for a in set(A): for k in range(2*a,MAX+1,a): dp[k] = False B = sorted(A) for i in range(len(B)-1): if B[i] == B[i-1]: dp[B[i]] = False print(sum(dp[a] for a in set(A)))
N = int(input()) A = list(map(int, input().split())) MAX = max(A) dp = [True for _ in range(MAX+1)] for a in set(A): for k in range(2*a,MAX+1,a): dp[k] = False B = sorted(A) for i in range(len(B)-1): if B[i] == B[i+1]: dp[B[i]] = False print(sum(dp[a] for a in set(A)))
[["-", 0, 57, 15, 666, 0, 206, 206, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 206, 206, 657, 17, 72]]
5
133
#include <bits/stdc++.h> using namespace std; #define ll long long typedef pair<ll, ll> P; 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) { a = b; return true; } return false; }...
#include <bits/stdc++.h> using namespace std; #define ll long long typedef pair<ll, ll> P; 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) { a = b; return true; } return false; }...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19]]
1
411
n=int(input()) from collections import Counter as co l=co(list(map(int,input().split()))) ans=len(l) ng=set() for k in l: if l[k]>=2:ng.add(k);continue for i in range(2*k,2*10**5+1,k): if i in l: ng.add(i) print(ans-len(ng))
n=int(input()) from collections import Counter as co l=co(list(map(int,input().split()))) ans=len(l) ng=set() for k in l: if l[k]>=2:ng.add(k) for i in range(2*k,10**6+1,k): if i in l: ng.add(i) print(ans-len(ng))
[["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 12, 652, 3, 4, 0, 657, 31, 657, 31, 612], ["-", 12, 652, 3, 4, 0, 657, 31, 657, 17, 48], ["-", 3, 4, 0, 657, 31, 657, 12, 657, 12, 612], ["+", 12, 652, 3, 4, 0, 657, 31, 657, 12, 612]]
5
106
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() using namespace std; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(all(a)); int m = a[n - 1]; vector<int> b(m + 1, 1); rep(i, n) { if (b[a[i]]) { if (i...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() using namespace std; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(all(a)); int m = a[n - 1]; vector<int> b(m + 1, 1); rep(i, n) { if (b[a[i]]) { if (i...
[["-", 51, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
203
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) typedef long long ll; typedef pair<int, int> P; const int INF = 100100100; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; struct Edge { ll to; ll cost; }; s...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) typedef long long ll; typedef pair<int, int> P; const int INF = 100100100; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; struct Edge { ll to; ll cost; }; s...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 17, 131], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
453
n = int(input(())) a = list(map(int,input().split())) dp = [0]*(10**6 + 1) ans = 0 for i in a: if dp[i] == 0: for j in range(1,10**6+1): if i * j > 10**6: break dp[i*j] += 1 elif dp[i] == 1: dp[i] += 1 for i in a: if dp[i] == 1: ans += 1 p...
n = int(input()) a = list(map(int,input().split())) dp = [0]*(10**6 + 1) ans = 0 for i in a: if dp[i] == 0: for j in range(1,10**6+1): if i * j > 10**6: break dp[i*j] += 1 elif dp[i] == 1: dp[i] += 1 for i in a: if dp[i] == 1: ans += 1 pri...
[["-", 3, 4, 0, 652, 3, 4, 0, 660, 0, 24], ["-", 3, 4, 0, 652, 3, 4, 0, 660, 0, 25]]
5
122
N=int(input()) A=list(map(int,input().split())) M=max(A) check=[0]*(M+1) for i in range(N): a=A[i] if check[a]>0: continue while a<=M: check[a]+=1 a+=A[i] ans=0 for i in range(N): if check[A[i]]==1: ans+=1 print(ans)
N=int(input()) A=list(map(int,input().split())) M=max(A) check=[0]*(M+1) #A.sort() for i in range(N): a=A[i] if check[a]>1: continue while a<=M: check[a]+=1 a+=A[i] ans=0 for i in range(N): if check[A[i]]==1: ans+=1 print(ans)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612]]
5
111
n = int(input()) A = sorted(list(map(int, input().split()))) M = 10**6 + 1 L = [0]*M ans = 0 for a in A: L[a] += 1 if L[a] == 1: # k>=2として k*aは全て不適 for i in range(2*a, M+1, a): L[i] += 2 # flagの数が答え print(L.count(1))
n = int(input()) A = sorted(list(map(int, input().split()))) M = 10**6 + 1 L = [0]*M for a in A: L[a] += 1 if L[a] == 1: # k>=2として k*aは全て不適 for i in range(2*a, M, a): L[i] += 2 # flagの数が答え print(L.count(1))
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
97