buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
N = gets.to_i array = gets.split.map(&:to_i) result = Array.new(10**6, 0) array.each do |num| i = 1 if result[i * num] == 0 while 10 ** 6 >= i * num result[i * num] += 1 i += 1 end else result[i * num] = 2 end end count = 0 array.each do |num| count += 1 if result[num] == 1 end puts ...
N = gets.to_i array = gets.split.map(&:to_i) result = Array.new(10**6+5, 0) array.each do |num| i = 1 if result[i * num] == 0 while 10 ** 6 >= i * num result[i * num] += 1 i += 1 end else result[i * num] = 2 end end count = 0 array.each do |num| count += 1 if result[num] == 1 end put...
[["+", 0, 662, 12, 652, 3, 4, 0, 738, 17, 72], ["+", 0, 662, 12, 652, 3, 4, 0, 738, 12, 612]]
4
101
#include <bits/stdc++.h> using namespace std; #define PI 3.14159265359 #define MODULO 1000000007 typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; // large array has to be declared outside main, allocated statically // if stored inside main, this variable lives in stack, caused overflow int cnt[1...
#include <bits/stdc++.h> using namespace std; #define PI 3.14159265359 #define MODULO 1000000007 typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; // large array has to be declared outside main, allocated statically // if stored inside main, this variable lives in stack, caused overflow int cnt[1...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
202
#include <bits/stdc++.h> typedef long long ll; #define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0])) #define rep(i, n) for (int i = 0; i < (n); ++i) #define AA(i) cout << i << endl; #define AS(i) cout << i << " "; const int INF = 1001001001; const double PI = 3.14159; using namespace std; // vector<ll> ...
#include <bits/stdc++.h> typedef long long ll; #define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0])) #define rep(i, n) for (int i = 0; i < (n); ++i) #define AA(i) cout << i << endl; #define AS(i) cout << i << " "; const int INF = 1001001001; const double PI = 3.14159; using namespace std; // vector<ll> ...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
186
def func(n, a): mx = max(a) x = [0] * (mx + 1) # len(x) for i in a: x[i] += 1 for i in range(1, mx + 1): if x[i] != 0: for j in range(2 * i, mx + 1, i): x[j] = 0 if x[i] > 1: x[i] = 0 return sum(x) # 31401 n = int(input()) a = list(map...
def func(n, a): mx = max(a) x = [0] * (mx + 1) # len(x) for i in a: x[i] += 1 for i in range(1, mx + 1): if x[i] != 0: for j in range(2 * i, mx + 1, i): x[j] = 0 if x[i] > 1: x[i] = 0 print(sum(x)) # 31401 n = int(input()) a = list(map...
[["-", 0, 656, 0, 14, 8, 196, 0, 37, 0, 38], ["+", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22]]
5
130
import sys input = sys.stdin.readline n=int(input()) L=list(map(int,input().split())) L.sort() hb = L[-1] dp = [-1 for i in range(hb+1)] print(L) for i in L: if dp[i]!=0: if dp[i]==1: dp[i]=0 continue dp[i]=1 for j in range(2*i,hb+1,i): dp[j]=0 ans=0 for...
import sys input = sys.stdin.readline n=int(input()) L=list(map(int,input().split())) L.sort() hb = L[-1] dp = [-1 for i in range(hb+1)] for i in L: if dp[i]!=0: if dp[i]==1: dp[i]=0 continue dp[i]=1 for j in range(2*i,hb+1,i): dp[j]=0 ans=0 for i in L: ...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
144
/* Miles Morales : When will I know I'm ready? Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith. */ // KEEP IT SIMPLE STUPID #include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("avx") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #prag...
/* Miles Morales : When will I know I'm ready? Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith. */ // KEEP IT SIMPLE STUPID #include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("avx") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #prag...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20]]
1
375
#include <bits/stdc++.h> using namespace std; typedef long long ll; using P = pair<int, int>; /* ちゃんと考えてわかって実装 */ const int MAX_N = 1000100; int main(void) { int n; cin >> n; vector<int> A(n); vector<int> all(MAX_N); for (int i = 0; i < MAX_N; i++) all[i] = 0; for (int i = 0; i < n; i++) { cin >> ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; using P = pair<int, int>; /* ちゃんと考えてわかって実装 */ const int MAX_N = 1000100; int main(void) { int n; cin >> n; vector<int> A(n); vector<int> all(MAX_N); for (int i = 0; i < MAX_N; i++) all[i] = 0; for (int i = 0; i < n; i++) { cin >> ...
[["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["+", 31, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
214
n = int(input()) a = [int(i) for i in input().split()] maxa = max(a) l = [0] * (maxa+1) for i in a: c = 1 while True: if i*c >= maxa: break l[i*c - 1] += 1 c += 1 ans = 0 for i in set(a): if l[i-1] == 1: ans += 1 print(ans)
n = int(input()) a = [int(i) for i in input().split()] maxa = max(a) l = [0] * (maxa+1) for i in a: c = 1 while True: if i*c >= maxa+1: break l[i*c - 1] += 1 c += 1 ans = 0 for i in set(a): if l[i-1] == 1: ans += 1 print(ans)
[["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 72], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]]
5
103
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define vv(T) std::vector<std::vector<T>> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() using namespace std; using ll = long long; int main(void) { int x, n; cin >> x >> n; set<int> P; for (int i = 0; i < n; ++i) { int p; ...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define vv(T) std::vector<std::vector<T>> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() using namespace std; using ll = long long; int main(void) { int x, n; cin >> x >> n; set<int> P; for (int i = 0; i < n; ++i) { int p; ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
144
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <limits> #include <stack> #include <string> #include <vector> using namespace std; int gcd(int a, int b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } int mod = 1...
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <limits> #include <stack> #include <string> #include <vector> using namespace std; int gcd(int a, int b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } int mod = 1...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
338
x, n = map(int, input().split()) if(n == 0): print(x) exit() p = set(map(int, input().split())) a = set([i for i in range(101)]) np = a-p ans = 0 dist = 1000000 for i in np: if(abs(x-i) < dist): dist = abs(x-i) ans = i elif(abs(x-i) == dist): ans = min(i, ans) else: pass print(ans)
x, n = map(int, input().split()) if(n == 0): print(x) exit() p = set(map(int, input().split())) a = set([i for i in range(105)]) np = a-p ans = 0 dist = 1000000 for i in np: if(abs(x-i) < dist): dist = abs(x-i) ans = i elif(abs(x-i) == dist): ans = min(i, ans) else: pass print(ans)
[["-", 0, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 0, 658, 0, 659, 12, 652, 3, 4, 0, 612]]
5
128
#include <bits/stdc++.h> #define F first #define S second #define ll long long #define pb push_back using namespace std; int n, y, x, ans; bool b[105]; int main() { cin >> x >> n; for (int i = 0; i < n; i++) { cin >> y; b[y] = 1; } for (int l = x, r = x; l > 0, r < 101; l--, r++) { if (!b[l]) { ...
#include <bits/stdc++.h> #define F first #define S second #define ll long long #define pb push_back using namespace std; int n, y, x, ans; bool b[105]; int main() { cin >> x >> n; for (int i = 0; i < n; i++) { cin >> y; b[y] = 1; } for (int l = x, r = x; l > -1, r < 102; l--, r++) { if (!b[l]) {...
[["-", 8, 9, 0, 7, 15, 34, 31, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 34, 31, 16, 12, 13], ["-", 8, 9, 0, 7, 15, 34, 12, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 34, 12, 16, 12, 13]]
1
140
#include <stdio.h> int main() { int p[110], m[110], x, n, t, i; scanf("%d%d", &x, &n); for (i = 0; i < 110; i++) p[i] = m[i] = 1; for (i = 0; i < n; i++) { scanf("%d", &t); if (x < t) p[t - x] = 0; else if (x > t) m[x - t] = 0; else p[0] = m[0] = 0; } for (i = 0; i < n;...
#include <stdio.h> int main() { int p[110], m[110], x, n, t, i; scanf("%d%d", &x, &n); for (i = 0; i < 110; i++) p[i] = m[i] = 1; for (i = 0; i < n; i++) { scanf("%d", &t); if (x < t) p[t - x] = 0; else if (x > t) m[x - t] = 0; else p[0] = m[0] = 0; } for (i = 0; i < 11...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
0
195
/* AUTHOR : Ankit Kumar BRANCH : Information Technology INSTITUTE : Birla Institute of Technology */ #include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(0); ...
/* AUTHOR : Ankit Kumar BRANCH : Information Technology INSTITUTE : Birla Institute of Technology */ #include <bits/stdc++.h> using namespace std; #define fast \ ios_base::sync_with_stdio(0); ...
[["-", 51, 16, 12, 91, 28, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 91, 28, 69, 341, 342, 0, 22]]
1
1,371
import sys input = sys.stdin.readline def S(): return input().rstrip() def I(): return int(input()) def MI(): return map(int, input().split()) x, n = MI() pl = list(MI()) nums = set(list(range(1, 102))) - set(pl) dmin = 1000000 for p in nums: d = abs(x - p) if d < dmin: temp = [] ...
import sys input = sys.stdin.readline def S(): return input().rstrip() def I(): return int(input()) def MI(): return map(int, input().split()) x, n = MI() pl = list(MI()) nums = set(list(range(102))) - set(pl) dmin = 1000000 for p in nums: d = abs(x - p) if d < dmin: temp = [] ...
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21]]
5
138
#include <bits/stdc++.h> #include <map> // pair using namespace std; typedef long long ll; #define vec vector<int> #define vecll vector<ll> #define rep(i, n) for (int i = (int)0; i < (int)n; i++) #define llrep(i, n) for (ll i = (ll)0; i < (ll)n; i++) #define REP(i, m, n) for (int i = (int)m; i < (int)n; i++) #define p...
#include <bits/stdc++.h> #include <map> // pair using namespace std; typedef long long ll; #define vec vector<int> #define vecll vector<ll> #define rep(i, n) for (int i = (int)0; i < (int)n; i++) #define llrep(i, n) for (ll i = (ll)0; i < (ll)n; i++) #define REP(i, m, n) for (int i = (int)m; i < (int)n; i++) #define p...
[["-", 0, 57, 64, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
400
import bisect x, n = map(int, input().split()) if n == 0: print(x) exit() p = list(map(int, input().split())) tmp = [] for i in range(1, 101): if i not in p: tmp.append((abs(i - x), i)) print(min(tmp)[1])
x, n = map(int, input().split()) if n == 0: print(x) exit() p = list(map(int, input().split())) tmp = [] for i in range(-1, 103): if i not in p: tmp.append((abs(i - x), i)) print(min(tmp)[1])
[["-", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["-", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 664, 17, 33], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]]
5
92
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define MOD 1000000007 #define pi 3.14159265358979323846 using namespace std; int main() { int x, n; cin >> x >> n; vector<int> p; p.push_back(-1); if (n != 0) { for (int i = 0; i < n; i++) { int tmp; cin >> tmp; p.push_ba...
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define MOD 1000000007 #define pi 3.14159265358979323846 using namespace std; int main() { int x, n; cin >> x >> n; vector<int> p; p.push_back(-1); if (n != 0) { for (int i = 0; i < n; i++) { int tmp; cin >> tmp; p.push_ba...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
188
#include <bits/stdc++.h> using namespace std; signed main() { int x, n, a; int p[1000] = {}; cin >> x >> n; for (int i = 0; i < n; i++) { cin >> a; p[a] = 1; } int num = 0, ab = x; for (int i = 0; i <= 100; i++) { if (ab >= abs(x - i) && p[i] == 0) { ab = abs(x - i); num = i; }...
#include <bits/stdc++.h> using namespace std; signed main() { int x, n, a; int p[1000] = {}; cin >> x >> n; for (int i = 0; i < n; i++) { cin >> a; p[a] = 1; } int num = 0, ab = x; for (int i = -10000; i <= 10000; i++) { if (ab > abs(x - i) && p[i] == 0) { ab = abs(x - i); num = i;...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47]]
1
127
#include <bits/stdc++.h> using namespace std; #define deb(var) \ cout << "[" << (#var) << " : " << var << "]" \ << " " #define debv(v) \ cout << "[" <<...
#include <bits/stdc++.h> using namespace std; #define deb(var) \ cout << "[" << (#var) << " : " << var << "]" \ << " " #define debv(v) \ cout << "[" <<...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
197
#include <bits/stdc++.h> using namespace std; #define ll long long const ll MOD = 1000000007; const ll INF = 1061109567; const double EPS = 1e-10; int main() { int x, n; cin >> x >> n; vector<int> p(n); int buf; int min = 101; int ans = 0; for (int i = 0; i < n; i++) { cin >> buf; p[i] = buf; } ...
#include <bits/stdc++.h> using namespace std; #define ll long long const ll MOD = 1000000007; const ll INF = 1061109567; const double EPS = 1e-10; int main() { int x, n; cin >> x >> n; vector<int> p(n); int buf; int min = 101; int ans = 0; for (int i = 0; i < n; i++) { cin >> buf; p[i] = buf; } ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
167
#include <bits/stdc++.h> #define rep(i, x, n) for (int i = x; i < n; i++) #define repr(i, x, n) for (int i = x; i > n; i--) #define pii pair<int, int> #define ll long long const long long iinf = 1e18; const int inf = 1e9; const int MOD = (1e6 + 3); int dir4[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; int knight[8][2] =...
#include <bits/stdc++.h> #define rep(i, x, n) for (int i = x; i < n; i++) #define repr(i, x, n) for (int i = x; i > n; i--) #define pii pair<int, int> #define ll long long const long long iinf = 1e18; const int inf = 1e9; const int MOD = (1e6 + 3); int dir4[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; int knight[8][2] =...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33]]
1
357
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pii pair<int, int> #define pb push_back #define INF INT_MAX #define mod 1000000007ll #define fi first #define se second #define f(i, p, q) for (int i = p; i < q; i++) #define si(a) scanf("%d", &a) #define sii(a, b) scanf("%d %d", &a, &b) #de...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pii pair<int, int> #define pb push_back #define INF INT_MAX #define mod 1000000007ll #define fi first #define se second #define f(i, p, q) for (int i = p; i < q; i++) #define si(a) scanf("%d", &a) #define sii(a, b) scanf("%d %d", &a, &b) #de...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72]]
1
376
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #include <map> typedef long long ll; #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using Graph = vector<vec...
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #include <map> typedef long long ll; #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using Graph = vector<vec...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
281
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ld = long double; using VI = vector<ll>; using VD = vector<ld>; using VVI = vector<VI>; using VC = vector<char>; using VB = vector<bool>; using VVC = vector<VC>; using VS = vector<string>; using PLL = pair<ll, ll>; using PLD = pair<ld, ld>; u...
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ld = long double; using VI = vector<ll>; using VD = vector<ld>; using VVI = vector<VI>; using VC = vector<char>; using VB = vector<bool>; using VVC = vector<VC>; using VS = vector<string>; using PLL = pair<ll, ll>; using PLD = pair<ld, ld>; u...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
720
#include <bits/stdc++.h> #define ll long long int using namespace std; inline void IO() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } int main(int argc, char const *argv[]) { // IO(); int x, n; cin >> x >> n; unordered_set<int> a; for (int i = 0; i < n; i++) { int m; ...
#include <bits/stdc++.h> #define ll long long int using namespace std; inline void IO() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } int main(int argc, char const *argv[]) { // IO(); int x, n; cin >> x >> n; unordered_set<int> a; for (int i = 0; i < n; i++) { int m; ...
[["-", 75, 76, 0, 9, 0, 43, 49, 50, 51, 13], ["+", 75, 76, 0, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
193
#include <bits/stdc++.h> #define ll long long #define pb push_back #define pf push_front #define fr first #define sc second #define r_0 return 0 #define ld long double using namespace std; const ll N = 1e2 + 7; const ll mod = 1e9 + 7; void solve() { int x, n, k; cin >> x >> n; map<int, int> mp; for (int i = 1...
#include <bits/stdc++.h> #define ll long long #define pb push_back #define pf push_front #define fr first #define sc second #define r_0 return 0 #define ld long double using namespace std; const ll N = 1e2 + 7; const ll mod = 1e9 + 7; void solve() { int x, n, k; cin >> x >> n; map<int, int> mp; for (int i = 1...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
205
x,n=map(int,input().split()) if n!=0: p=list(map(int,input().split())) dif=1000 ans=-1 for i in range(0,101): if i not in p: if abs(x-i)<dif: ans=i dif=abs(x-i) print(ans) else: print(x)
x,n=map(int,input().split()) if n!=0: p=list(map(int,input().split())) dif=1000 ans=-1 for i in range(0,102): if i not in p: if abs(x-i)<dif: ans=i dif=abs(x-i) print(ans) else: print(x)
[["-", 64, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
92
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, x, n) for (int i = x; i < (n); i++) #define all(n) begin(n), end(n) struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; const long long INF = numeric_limits<long long>::max(); in...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, x, n) for (int i = x; i < (n); i++) #define all(n) begin(n), end(n) struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; const long long INF = numeric_limits<long long>::max(); in...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
233
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで #include <bits/stdc++.h> #define mod 1000000007 #define INF 1001001001 #define ll long long #define ln cout << endl #define Yes cout << "Yes" << endl #define No cout << "No" << endl #define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++) #define rep(i...
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで #include <bits/stdc++.h> #define mod 1000000007 #define INF 1001001001 #define ll long long #define ln cout << endl #define Yes cout << "Yes" << endl #define No cout << "No" << endl #define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++) #define rep(i...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
219
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; using ll = long long; using ld = long double; const ld pi = 3.141592653589793; #ifdef EBUG #define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n"; #else #...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> using namespace std; using ll = long long; using ld = long double; const ld pi = 3.141592653589793; #ifdef EBUG #define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n"; #else #...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
182
X, N = map(int, input().split()) try: P = list(map(int, input().split())) except: P = [] tmp = 10**9 ans = 10**9 if P: for p in range(0, 101): if p in P: continue abs_PX = abs(X-p) if abs_PX < tmp: ans = p tmp = abs_PX else: ans = X prin...
X, N = map(int, input().split()) try: P = list(map(int, input().split())) except: P = [] tmp = 10**9 ans = 10**9 if P: for p in range(-20, 110): if p in P: continue abs_PX = abs(X-p) if abs_PX < tmp: ans = p tmp = abs_PX else: ans = X print(...
[["-", 64, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 664, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 664, 28, 612], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
98
import sys input = sys.stdin.readline X,N=(int(x) for x in input().rstrip('\n').split()) ps=[int(x) for x in input().rstrip('\n').split()] if N==0: print(X) else: for i in range(X): if X-i not in ps: print(X-i) break elif X+i not in ps: print(X+i) break
import sys input = sys.stdin.readline X,N=(int(x) for x in input().rstrip('\n').split()) ps=[int(x) for x in input().rstrip('\n').split()] if N==0: print(X) else: for i in range(100): if X-i not in ps: print(X-i) break elif X+i not in ps: print(X+i) break
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
110
import sys sys.setrecursionlimit(10**6) from math import floor,ceil,sqrt,factorial,log,gcd from heapq import heappop, heappush, heappushpop from collections import Counter,defaultdict,deque from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from bisect import bisect_left,bi...
import sys sys.setrecursionlimit(10**6) from math import floor,ceil,sqrt,factorial,log,gcd from heapq import heappop, heappush, heappushpop from collections import Counter,defaultdict,deque from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from bisect import bisect_left,bi...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]]
5
455
#include <algorithm> #include <assert.h> #include <climits> #include <cmath> #include <iostream> #include <queue> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; constexpr int64_t MOD = 1e9 + 7; int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); int32_t X, N...
#include <algorithm> #include <assert.h> #include <climits> #include <cmath> #include <iostream> #include <queue> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; constexpr int64_t MOD = 1e9 + 7; int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); int32_t X, N...
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 18], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 17, 19]]
1
186
X, N = [int(i) for i in input().split(' ')] if N>0: p = [int(i) for i in input().split(' ')] abs_list = {} for i in range(-100,100): if(i in p): continue abs_list[i] = abs(X - i) min_k = min(abs_list, key=abs_list.get) print(min_k) else: print(X)
X, N = [int(i) for i in input().split(' ')] if N>0: p = [int(i) for i in input().split(' ')] abs_list = {} for i in range(-100,200): if(i in p): continue abs_list[i] = abs(X - i) min_k = min(abs_list, key=abs_list.get) print(min_k) else: print(X)
[["-", 64, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
105
/* Author : manu_sy */ #include "bits/stdc++.h" using namespace std; /** Template Begins **/ typedef long long ll; typedef pair<int, int> PII; #define IOS \ ios_base::sync_with_stdio(false); \ cin.ti...
/* Author : manu_sy */ #include "bits/stdc++.h" using namespace std; /** Template Begins **/ typedef long long ll; typedef pair<int, int> PII; #define IOS \ ios_base::sync_with_stdio(false); \ cin.ti...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
430
n = int(input()) a = [int(i) for i in input().split(" ")] a.sort() dp = [True for i in range(a[-1]+1)] count=0 for i in range(n): if dp[a[i]]: count+=1 for j in range(1,n-i): if a[i]!=a[i+j]: break elif j==1: count-=1 dp[a[i+j]]=F...
n = int(input()) a = [int(i) for i in input().split(" ")] a.sort() dp = [True for i in range(a[-1]+1)] count=0 for i in range(n): if dp[a[i]]: count+=1 for j in range(1,n-i): if a[i]!=a[i+j]: break elif j==1: count-=1 dp[a[i+j]]=F...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
158
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define all(a) a.begin(), a.end() #define mod 1000000007 #define MOD 998244353 #define INF 40000000000000000 int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1}; int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0}; int dx4[4] = ...
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define all(a) a.begin(), a.end() #define mod 1000000007 #define MOD 998244353 #define INF 40000000000000000 int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1}; int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0}; int dx4[4] = ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 57, 64, 116, 0, 117], ["-", 0, 7, 8, 9, 0, 57, 64, 116, 0, 35]]
1
329
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define mp make_pair #define N 200005 int mark[N * 5]; int check(int n) { int p = sqrt(n); int val = 1; if (n == 1 && mark[1] > 1) return 0; else return 1; if (mark[n] > 1 || mark[1] > 0) val = 0; f...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define mp make_pair #define N 200005 int mark[N * 5]; int check(int n) { int p = sqrt(n); int val = 1; if (n == 1) if (mark[n] > 1) return 0; else return 1; if (mark[n] > 1 || mark[1] > 0) v...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 57, 64, 57, 0, 121], ["+", 8, 9, 0, 57, 64, 57, 15, 339, 0, 24], ["-", 51, 16, 12, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22]]
1
279
n=int(input()) l=list(map(int,input().split())) ml=max(l) m=[0]*(ml+1) for i in l: m[i]+=1 for i in range(ml+1): if m[i]>=1: for j in range(i,ml+1,i): if m[j]>0: m[j]=0 for i in range(ml+1): if m[i]>=2: m[i]=0 print(sum(m))
n=int(input()) l=list(map(int,input().split())) ml=max(l) m=[0]*(ml+1) for i in l: m[i]+=1 for i in range(ml+1): if m[i]>=1: for j in range(2*i,ml+1,i): if m[j]>0: m[j]=0 #print(j) for i in range(ml+1): if m[i]>=2: m[i]=0 print(sum(m))
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 48]]
5
130
from collections import deque,Counter N = int(input()) A = list(map(int,input().split())) memo = [0] * (10**6+10) cnt = Counter(A) for k,v in cnt.items(): if memo[k] > 1: continue for j in range(k,10**6+1,k): memo[j] += v ans = 0 for num in cnt: ans += (memo[num] == 0) print(ans)
from collections import deque,Counter N = int(input()) A = list(map(int,input().split())) memo = [0] * (10**6+10) cnt = Counter(A) for k,v in cnt.items(): if memo[k] > 1: continue for j in range(k,10**6+1,k): memo[j] += v # print(memo[:max(A)+1]) ans = 0 for num in cnt: ans += (memo[num...
[["-", 0, 1, 0, 677, 12, 23, 0, 666, 0, 612], ["+", 0, 1, 0, 677, 12, 23, 0, 666, 0, 612]]
5
114
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using P = pair<int, int>; using ll = long long; const int INF = 1001001001; const int M = 1000005; int main() { int n; cin >> n; int a[n]; rep(i, n) cin >> a[i]; vector<int> cnt(M, 0); rep(i, n) { if (cnt[a[i]...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using P = pair<int, int>; using ll = long long; const int INF = 1001001001; const int M = 1000005; int main() { int n; cin >> n; int a[n]; rep(i, n) cin >> a[i]; vector<int> cnt(M, 0); rep(i, n) { if (cnt[a[i]...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["-", 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
185
#include <bits/stdc++.h> using namespace std; #define amod 998244353 #define mod 1e9 + 7 #define ll long long #define N (ll)(1000005) signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n, count = 0, a; cin >> n; vector<int> ff(N); map<ll, ll> mp; while (n--) { cin >> a; ...
#include <bits/stdc++.h> using namespace std; #define amod 998244353 #define mod 1e9 + 7 #define ll long long #define N (ll)(1000005) signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n, count = 0, a; cin >> n; vector<int> ff(N); map<ll, ll> mp; while (n--) { cin >> a; ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
161
import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.InputMismatchException; public class Main { static InputStream is = System.in; static String INPUT = ""; public static void main(String[] args) throws Exception { int n = ni(); int M = 1000001; int W = ...
import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.InputMismatchException; public class Main { static InputStream is = System.in; static String INPUT = ""; public static void main(String[] args) throws Exception { int n = ni(); int M = 1000001; int W = ...
[["-", 64, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 64, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 64, 196, 0, 503, 49, 200, 51, 16, 31, 22], ["+", 64, 196, 0, 503, 49, 200, 51, 16, 17, 33]]
3
1,028
//~ while (clock()<=69*CLOCKS_PER_SEC) //~ #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") #pragma GCC optimize("-Ofast", "-funroll-all-loops", "-ffast-math") //~ #pragma GCC target ("avx2") //~ #pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <algorithm> #...
//~ while (clock()<=69*CLOCKS_PER_SEC) //~ #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") #pragma GCC optimize("-Ofast", "-funroll-all-loops", "-ffast-math") //~ #pragma GCC target ("avx2") //~ #pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <algorithm> #...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
619
#include <algorithm> #include <assert.h> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <time.h> #include <un...
#include <algorithm> #include <assert.h> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <time.h> #include <un...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
759
N = gets.to_i a = gets.split(" ").map(&:to_i).sort b = Array.new(a[-1] + 1, true) ans = 0 (N - 1).times do |i| next if b[i] == false v = a[i] * 2 while v <= a[-1] do b[v] = false v += a[i] end b[a[i]] = false if a[i] == a[i + 1] end a.each do |x| ans += 1 if b[x] ==true end put...
N = gets.to_i a = gets.split(" ").map(&:to_i).sort b = Array.new(a[-1] + 1, true) ans = 0 (N - 1).times do |i| next if b[a[i]] == false v = a[i] * 2 while v <= a[-1] do b[v] = false v += a[i] end b[a[i]] = false if a[i] == a[i + 1] end a.each do |x| ans += 1 if b[x] == true end...
[["+", 0, 751, 15, 738, 31, 742, 0, 742, 500, 22], ["+", 0, 751, 15, 738, 31, 742, 0, 742, 0, 70], ["+", 0, 751, 15, 738, 31, 742, 0, 742, 0, 73]]
4
133
n = int(input()) A = list(map(int, input().split())) Cnt = [0 for i in range(10**6 + 7)] for i in A: if Cnt[i] != 0: Cnt[i] = 2 continue else: pass for j in range(i, 10**6 + 8, i): Cnt[j] += 1 ans = 0 for i in A: if Cnt[i] == 1: ans += 1 else: pass ...
n = int(input()) A = list(map(int, input().split())) Cnt = [0 for i in range(10**6 + 8)] for i in A: if Cnt[i] != 0: Cnt[i] = 2 continue else: pass for j in range(i, 10**6 + 8, i): Cnt[j] += 1 ans = 0 for i in A: if Cnt[i] == 1: ans += 1 else: pass ...
[["-", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
112
#include <bits/stdc++.h> #define rep(i, x, n) for (int i = x; i < (int)(n); i++) #define rep_ll(i, x, n) for (ll i = x; i < (ll)(n); i++) using namespace std; typedef long long ll; typedef unsigned long long u_ll; typedef pair<int, int> pair_; const long double PI = (acos(-1)); const int INF = 1001001001; const int dx[...
#include <bits/stdc++.h> #define rep(i, x, n) for (int i = x; i < (int)(n); i++) #define rep_ll(i, x, n) for (ll i = x; i < (ll)(n); i++) using namespace std; typedef long long ll; typedef unsigned long long u_ll; typedef pair<int, int> pair_; const long double PI = (acos(-1)); const int INF = 1001001001; const int dx[...
[["-", 8, 9, 0, 9, 0, 7, 15, 16, 31, 22], ["+", 8, 9, 0, 9, 0, 7, 15, 16, 31, 22]]
1
274
#include <bits/stdc++.h> using namespace std; int k; int main() { int N; cin >> N; vector<int> A(N, 0); vector<int> keep(1000000 + 5, 0); for (int i = 0; i < N; i++) { cin >> k; A[i] = k; keep[k]++; } if (keep[1] > 1) { cout << 0 << endl; return 0; } if (keep[1] == 1) { cout <...
#include <bits/stdc++.h> using namespace std; int k; int main() { int N; cin >> N; vector<int> A(N, 0); vector<int> keep(1000000 + 5, 0); for (int i = 0; i < N; i++) { cin >> k; A[i] = k; keep[k]++; } if (keep[1] > 1) { cout << 0 << endl; return 0; } if (keep[1] == 1) { cout <...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
231
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair<int, int>; template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; } template <class T> void chmax(T &a, const T &b) noexcep...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair<int, int>; template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; } template <class T> void chmax(T &a, const T &b) noexcep...
[["-", 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, 22], ["-", 28, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 0, 1, 0, 27, 28, 69, 341, 342, 0, 22]]
1
333
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; const double pi = 3.14159265358979323846; #define speed \ ios_base::sync_with_stdio(0); ...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; const double pi = 3.14159265358979323846; #define speed \ ios_base::sync_with_stdio(0); ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
215
from collections import Counter max_=10**6+1 ans=0 n=int(input()) data=list(map(int,input().split())) b=[True]*(max_+1) data.sort() c=Counter(data) print(c) for d in data: if b[d]: for j in range(d,max_,d): b[j]=False if c[d]==1: ans+=1 print(ans)
from collections import Counter max_=10**6+1 ans=0 n=int(input()) data=list(map(int,input().split())) b=[True]*(max_+1) data.sort() c=Counter(data) #print(c) for d in data: if b[d]: for j in range(d,max_,d): b[j]=False if c[d]==1:#複数存在考慮 ans+=1 print(ans)
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
109
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); ++i) #define orep(i, n) for (long long i = 1; i <= (n); ++i) // one rep #define drep(i, n) for (long long i = (n)-1; i >= 0; --i) // down rep #define srep(i, s, t) for (long long i = (s); i < (t); ++i) // set rep #define rng(x) (x).begin(),...
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); ++i) #define orep(i, n) for (long long i = 1; i <= (n); ++i) // one rep #define drep(i, n) for (long long i = (n)-1; i >= 0; --i) // down rep #define srep(i, s, t) for (long long i = (s); i < (t); ++i) // set rep #define rng(x) (x).begin(),...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46]]
1
455
#include <bits/stdc++.h> typedef long long ll; using namespace std; #define all(x) (x).begin(), (x).end() #define eb emplace_back #define mp make_pair #define pb push_back #define fi first #define se second #define sz(x) ((int)(x).size()) #define rep(x, y, z) for (int x = y; x < z; x++) #define per(x, z, y) for (int x...
#include <bits/stdc++.h> typedef long long ll; using namespace std; #define all(x) (x).begin(), (x).end() #define eb emplace_back #define mp make_pair #define pb push_back #define fi first #define se second #define sz(x) ((int)(x).size()) #define rep(x, y, z) for (int x = y; x < z; x++) #define per(x, z, y) for (int x...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
280
n = gets.to_i a = gets.chomp.split(" ").map(&:to_i).sort INF = (10 ** 6) arr = Array.new(INF+1,0) a.each do |i| next if arr[i] == 2 i.step(INF, i) do |j| arr[i] += 1 end end count = 0 a.each do |i| count += 1 if arr[i] == 1 end puts count
n = gets.to_i a = gets.chomp.split(" ").map(&:to_i).sort INF = (10 ** 6) arr = Array.new(INF+1,0) a.each do |i| next if arr[i] == 2 i.step(INF, i) do |j| arr[j] += 1 end end count = 0 a.each do |i| count += 1 if arr[i] == 1 end puts count
[["-", 196, 737, 8, 736, 0, 755, 31, 742, 0, 22], ["+", 196, 737, 8, 736, 0, 755, 31, 742, 0, 22]]
4
102
#include <bits/stdc++.h> using namespace std; int ara[200005], freq[1000006], val[1000006]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &ara[i]), freq[ara[i]]++; for (int i = 2; i <= 1000000; i++) for (int j = i; j <= 1000000; j += i) val[j] += freq[i], val[j] = mi...
#include <bits/stdc++.h> using namespace std; int ara[200005], freq[1000006], val[1000006]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &ara[i]), freq[ara[i]]++; for (int i = 1; i <= 1000000; i++) for (int j = i; j <= 1000000; j += i) val[j] += freq[i], val[j] = mi...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
177
from sys import stdin,stdout from collections import Counter n=int(stdin.readline()) a=sorted(map(int,stdin.readline().split())) d=Counter(a) m1=max(a);ans=0 vis=[0]*(m1+1) for v in a: if not vis[v]: if d[v]>1:ans+=1 for mul in range(v,m1+1,v): vis[mul]=1 stdout.write(str(ans))
from sys import stdin,stdout from collections import Counter n=int(stdin.readline()) a=sorted(map(int,stdin.readline().split())) d=Counter(a) m1=max(a);ans=0 vis=[0]*(m1+1) for v in a: if not vis[v]: if d[v]==1:ans+=1 for mul in range(v,m1+1,v): vis[mul]=1 stdout.write(str(ans))
[["-", 0, 57, 64, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 60]]
5
118
#include "bits/stdc++.h" using namespace std; // 定義 typedef long long ll; typedef pair<ll, ll> P; #define ALL(x) (x).begin(), (x).end() #define REP(i, n) for (ll i = 0; i < (ll)n; ++i) #define REPN(i, m, n) for (ll i = m; i < (ll)n; ++i) #define REVREP(i, n) for (ll i = n - 1; i >= 0; i--) #define VL vector<ll> #defin...
#include "bits/stdc++.h" using namespace std; // 定義 typedef long long ll; typedef pair<ll, ll> P; #define ALL(x) (x).begin(), (x).end() #define REP(i, n) for (ll i = 0; i < (ll)n; ++i) #define REPN(i, m, n) for (ll i = m; i < (ll)n; ++i) #define REVREP(i, n) for (ll i = n - 1; i >= 0; i--) #define VL vector<ll> #defin...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["-", 15, 339, 51, 16, 12, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["+", 15, 339, 51, 16, 12, 2, 63, 118, 28, 22], ["-", 15, 339, 51, 16, 12, 2, 63, 118, 119,...
1
444
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<int> vec(n); map<int, int> ma, ma1; for (int i = 0; i < n; ++i) { cin >> vec[i]; ma[vec[i]] = 0; ma1[vec[i]]++; } sor...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<int> vec(n); map<int, int> ma, ma1; for (int i = 0; i < n; ++i) { cin >> vec[i]; ma[vec[i]] = 0; ma1[vec[i]]++; } sor...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45]]
1
242
N = int(input()) A = list(map(int, input().split())) + [10**7] A.sort() e = np.zeros(10**6 + 1) ans = 0 for i in range(N): if e[A[i]] == 0: e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。 # 同じ値が重複していないか判定 if A[i] != A[i+1]: ans += 1 print(ans)
import numpy as np N = int(input()) A = list(map(int, input().split())) + [10**7] A.sort() e = np.zeros(10**6 + 1) ans = 0 for i in range(N): if e[A[i]] == 0: e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。 # 同じ値が重複していないか判定 if A[i] != A[i+1]: ans += 1 print(ans)
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 0, 656, 0, 596, 141, 704, 141, 673, 0, 22], ["+", 36, 36, 0, 656, 0, 596, 141, 704, 0, 272], ["+", 36, 36, 0, 656, 0, 596, 141, 704, 705, 22]]
5
103
#include <iostream> #include <vector> #define For(i, x, y) for (register int i = (x); i <= (y); i++) using namespace std; typedef long long ll; const int maxx = 1e6 + 10; ll a[maxx]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, x; cin >> n; For(i, 1, n) cin >> x, a[x]++; vector<bo...
#include <iostream> #include <vector> #define For(i, x, y) for (register int i = (x); i <= (y); i++) using namespace std; typedef long long ll; const int maxx = 1e6 + 10; ll a[maxx]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, x; cin >> n; For(i, 1, n) cin >> x, a[x]++; vector<bo...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
178
import sys import collections input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): n = I() mylist = list(MI()) max_a = max(mylist) exlude_list = set() tlist = [False] * (max_a+1) for a in...
import sys import collections input = sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): n = I() mylist = list(MI()) max_a = max(mylist) exclude_set = set() tlist = [False] * (max_a+1) for a in...
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 57, 15, 679, 12, 681, 28, 666, 0, 22], ["+", 0, 57, 15, 679, 12, 681, 28, 666, 0, 22]]
5
215
#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[i]; } vector<int> cmm(1000001); for (int x : a) { if (cmm[x] != 0) { cmm[x] == 2; continue; } for (int j = x; j < 1000001; j += x) { cmm[j...
#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[i]; } vector<int> cmm(1000001); for (int x : a) { if (cmm[x] != 0) { cmm[x] = 2; continue; } for (int j = x; j < 1000001; j += x) { cmm[j]...
[["-", 0, 57, 64, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
148
n = int(input()) a = sorted(list(map(int, input().split()))) x = max(a) dp = [0] * x for ai in a: i = 1 while i * ai < x: dp[i * ai - 1] += 1 i += 1 ans = 0 for ai in a: if dp[ai-1] <= 1: ans += 1 print(ans)
n = int(input()) a = sorted(list(map(int, input().split()))) x = max(a) dp = [0] * x for ai in a: i = 1 while i * ai <= x: dp[i * ai - 1] += 1 i += 1 ans = 0 for ai in a: if dp[ai-1] <= 1: ans += 1 print(ans)
[["-", 0, 7, 8, 196, 0, 52, 15, 666, 667, 18], ["+", 0, 7, 8, 196, 0, 52, 15, 666, 667, 19]]
5
94
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define faster \ ios_base::sync_with_stdio(false); ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define faster \ ios_base::sync_with_stdio(false); ...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
284
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') import collections N = int(input()) A = list(map(int, input().split())) cA = collections.Counter(A) LIM = 10 ** 6 + 1 # LIM = 25 A.sort() dp = [1] * LI...
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') import collections N = int(input()) A = list(map(int, input().split())) cA = collections.Counter(A) LIM = 10 ** 6 + 1 # LIM = 25 A.sort() dp = [1] * LI...
[["-", 0, 7, 8, 196, 0, 52, 15, 666, 667, 19], ["+", 0, 7, 8, 196, 0, 52, 15, 666, 667, 18]]
5
158
N = int(input()) A = list(map(int,input().split())) MAX = max(A) #Aの中の最大値 Adic={} for i in range(N): if A[i] not in Adic: Adic[A[i]] = 1 else: Adic[A[i]] += 1 Aset = set(A) if 1 in Aset: #1がある場合 if Adic[1] == 1: print(1) else: print(0) exit() ans = 0 for j in range(N): Flag = True temp = A...
N = int(input()) A = list(map(int,input().split())) MAX = max(A) #Aの中の最大値 Adic={} for i in range(N): if A[i] not in Adic: Adic[A[i]] = 1 else: Adic[A[i]] += 1 Aset = set(A) if 1 in Aset: #1がある場合 if Adic[1] == 1: print(1) else: print(0) exit() ans = 0 for j in range(N): temp = A[j] if Adic[...
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 146], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
189
#include <bits/stdc++.h> using namespace std; int main() { int n; const int max_n = 2 * 1e5; cin >> n; int a[max_n + 1]; for (int i = 0; i < n; i++) cin >> a[i]; vector<int> dp(2 * 1e6, 0); for (int i = 0; i < n; i++) { int now = a[i]; if (dp[now] != 1) { dp[now]++; // continue; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; const int max_n = 2 * 1e5; cin >> n; int a[max_n + 1]; for (int i = 0; i < n; i++) cin >> a[i]; vector<int> dp(2 * 1e6, 0); for (int i = 0; i < n; i++) { int now = a[i]; if (dp[now] != 0) { dp[now]++; // continue; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
182
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <typeinfo> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; static const double pi = 3.14159265358...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <typeinfo> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; static const double pi = 3.14159265358...
[["-", 0, 57, 75, 76, 0, 9, 0, 116, 0, 117], ["-", 0, 57, 75, 76, 0, 9, 0, 116, 0, 35]]
1
259
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #incl...
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #incl...
[["-", 0, 27, 28, 69, 341, 342, 0, 118, 28, 22], ["-", 0, 27, 28, 69, 341, 342, 0, 118, 17, 131], ["-", 0, 27, 28, 69, 341, 342, 0, 118, 119, 120], ["+", 0, 1, 0, 27, 28, 69, 341, 342, 0, 22]]
1
2,746
#include "bits/stdc++.h" using namespace std; using ll = long long; #define print(n) cout << n << endl #define rep(i, a, n) for (ll i = a; i < n; i++) #define ALL(s) s.begin(), s.end() #define P pair<ll, ll> #define vl vector<ll> #define vi vector<int> #define vvl vector<vector<ll>> #define vvi vector<vector<int>> cons...
#include "bits/stdc++.h" using namespace std; using ll = long long; #define print(n) cout << n << endl #define rep(i, a, n) for (ll i = a; i < n; i++) #define ALL(s) s.begin(), s.end() #define P pair<ll, ll> #define vl vector<ll> #define vi vector<int> #define vvl vector<vector<ll>> #define vvi vector<vector<int>> cons...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 146], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
967
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #includ...
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #includ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109]]
1
787
#include <bits/stdc++.h> #define ll long long #define dl double #define mp make_pair #define pb push_back using namespace std; //*********************************************************************** // hash struct for unordered_map struct hash_pair { template <class T1, class T2> size_t operator()(const pair<T1, ...
#include <bits/stdc++.h> #define ll long long #define dl double #define mp make_pair #define pb push_back using namespace std; //*********************************************************************** // hash struct for unordered_map struct hash_pair { template <class T1, class T2> size_t operator()(const pair<T1, ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
352
#include <bits/stdc++.h> using namespace std; #define ll long long int int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int max = *max_element(a, a + n); int mark[max + 1] = {0}; for (int i = 0; i < n; i++) { for (int x = 2 * a[i]; x <= max; x += a[i]) { ...
#include <bits/stdc++.h> using namespace std; #define ll long long int int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int max = *max_element(a, a + n); int mark[max + 1] = {0}; for (int i = 0; i < n; i++) { for (int x = a[i]; x <= max; x += a[i]) { m...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 31, 13], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 48], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
168
n = int(input()) A = list(map(int, input().split())) A.sort() A.append(-1) x = A[0] flag = True for a in A: if a % x != 0: flag = False if flag: print(0) exit() used = [False] * A[-2] ans = 0 for idx, a in enumerate(A[:-1]): if used[a - 1]: continue if a != A[idx + 1]: ans...
n = int(input()) A = list(map(int, input().split())) A.sort() A.append(-1) x = A[0] if x != 1: flag = True for a in A: if a % x != 0: flag = False if flag: print(0) exit() used = [False] * A[-2] ans = 0 for idx, a in enumerate(A[:-1]): if used[a - 1]: conti...
[["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 79], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102]]
5
151
#!python3.8 # -*- coding: utf-8 -*- # abc170/abc170_d import sys from collections import Counter i2s = sys.stdin.readline().rstrip def main(): N = int(i2s()) A = sorted(map(int, i2s().split(' '))) B = Counter(A) for a in A: if B[a] == 0: continue if B[a] > 1: B[...
#!python3.8 # -*- coding: utf-8 -*- # abc170/abc170_d import sys from collections import Counter i2s = lambda: sys.stdin.readline().rstrip() def main(): N = int(i2s()) A = sorted(map(int, i2s().split(' '))) B = Counter(A) for a in A: if B[a] == 0: continue if B[a] > 1: ...
[["+", 0, 656, 0, 1, 0, 662, 12, 670, 0, 670], ["+", 0, 656, 0, 1, 0, 662, 12, 670, 0, 102], ["+", 0, 662, 12, 670, 8, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 670, 8, 652, 3, 4, 0, 25]]
5
136
#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]; vector<int> cnt(n); for (int x : a) { if (cnt[x] != 0) { cnt[x] = 2; continue; } for (int i = x; i < 1000005; i += x) cnt[i]++...
#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]; vector<int> cnt(1000005); for (int x : a) { if (cnt[x] != 0) { cnt[x] = 2; continue; } for (int i = x; i < 1000005; i += x) cn...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]]
1
145
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define ll long long #define rep(i, l, r) for (ll i = (l); i < (r); i++) #define repp(i, l, r, k) for (ll i = (l); i < (r); i += (k)) #define INF ((1LL << 62) - (1LL << 31)) #define max(p, q) ((p) > (q) ? (p) : (q)) #define min(p, q) ((p) < (q...
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define ll long long #define rep(i, l, r) for (ll i = (l); i < (r); i++) #define repp(i, l, r, k) for (ll i = (l); i < (r); i += (k)) #define INF ((1LL << 62) - (1LL << 31)) #define max(p, q) ((p) > (q) ? (p) : (q)) #define min(p, q) ((p) < (q...
[["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 0, 57, 15, 23, 0, 16, 31, 69, 71, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 69, 71, 22], ["-", 0, 11, 12, 16, 31, 69, 71, 69, 71, 22], ["+", 0, 11, 12, 16, 31, 69, 71, 69, 71, 22]]
0
686
n = int(input()) A = sorted(map(int, input().split())) used = set() U = A[-1]+1 is_prime = [1]*U cnt = [0]*U depri = 0 for a in A: cnt[a] += 1 if cnt[a] == 2 and is_prime[a]: depri += 1 if is_prime[a]: used.add(a) for q in range(2*a, U, a): is_prime[q] = 0 print(used) pr...
n = int(input()) A = sorted(map(int, input().split())) used = set() U = A[-1]+1 is_prime = [1]*U cnt = [0]*U depri = 0 for a in A: cnt[a] += 1 if cnt[a] == 2 and is_prime[a]: depri += 1 if is_prime[a]: used.add(a) for q in range(2*a, U, a): is_prime[q] = 0 print(len(used...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
128
n = int(input()) a = list(map(int, input().split())) s = ([0]*100) a.sort() for i in a: s[i] += 1 ans = 0 for j in range(100): if s[j] == 1: ans += 1 if s[j] > 0: for k in range(j, 100, j): s[k] = 0 print(ans)
n = int(input()) a = list(map(int, input().split())) s = ([0]*1000001) a.sort() for i in a: s[i] += 1 ans = 0 for j in range(1000001): if s[j] == 1: ans += 1 if s[j] > 0: for k in range(j, 1000001, j): s[k] = 0 print(ans)
[["-", 0, 1, 0, 662, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 23, 0, 657, 12, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 64, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
102
N = gets.to_i ary = gets.split.map(&:to_i).sort.uniq nums = Hash.new(0) ans = Array.new(ary.max + 1, 0) result = 0 ary.each do |i| nums[i] += 1 ans[i] = 1 end ary.each do |k| next if ans[k] == 0 result += 1 if nums[k] == 1 k.step(ary.max, k) do |l| ans[l] = 0 end end puts result
N = gets.to_i ary = gets.split.map(&:to_i).sort nums = Hash.new(0) ans = Array.new(ary.last + 1, 0) result = 0 ary.each do |i| nums[i] += 1 ans[i] = 1 end ary.each do |k| next if ans[k] == 0 result += 1 if nums[k] == 1 k.step(ary.last, k) do |l| ans[l] = 0 end end puts result
[["-", 36, 36, 0, 493, 0, 662, 12, 652, 17, 131], ["-", 36, 36, 0, 493, 0, 662, 12, 652, 735, 22], ["-", 12, 652, 3, 4, 0, 738, 31, 652, 735, 22], ["+", 12, 652, 3, 4, 0, 738, 31, 652, 735, 22], ["-", 8, 736, 0, 652, 3, 4, 0, 652, 735, 22], ["+", 8, 736, 0, 652, 3, 4, 0, 652, 735, 22]]
4
114
N=int(input()) #5 A=sorted(map(int,input().split())) #24 11 8 3 16 dp = [1]*max(A) l = len(dp) for a in A: if dp[a-1] == 1: dp[a-1] = 2 for i in range(2*a, l+1, a): dp[i-1] = 0 elif dp[a-1] == 2: dp[a-1] = 0 sum([1 for a in A if dp[a-1] != 0])
N=int(input()) #5 A=sorted(map(int,input().split())) #24 11 8 3 16 dp = [1]*max(A) l = len(dp) for a in A: if dp[a-1] == 1: dp[a-1] = 2 for i in range(2*a, l+1, a): dp[i-1] = 0 elif dp[a-1] == 2: dp[a-1] = 0 print(sum([1 for a in A if dp[a-1] != 0]))
[["+", 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
127
#include <bits/stdc++.h> using namespace std; void __print(int x) { cout << x; } void __print(long x) { cout << x; } void __print(long long x) { cout << x; } void __print(unsigned x) { cout << x; } void __print(unsigned long x) { cout << x; } void __print(unsigned long long x) { cout << x; } void __print(float x) { co...
#include <bits/stdc++.h> using namespace std; void __print(int x) { cout << x; } void __print(long x) { cout << x; } void __print(long long x) { cout << x; } void __print(unsigned x) { cout << x; } void __print(unsigned long x) { cout << x; } void __print(unsigned long long x) { cout << x; } void __print(float x) { co...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 57, 64, 9, 0, 57, 75, 76, 0, 95], ["-", 64, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 75, 76, 0, 9, 0, 7, 8, 9, 0, 46]]
1
698
#include <bits/stdc++.h> #define MAX int(2 * 10e5) #define ll long long int using namespace std; int main() { vector<ll> sieve(MAX + 1, true); int n; cin >> n; vector<ll> arr(n + 1, 0); vector<ll> freq(MAX + 1, 0); for (int i = 1; i <= n; i++) { cin >> arr[i]; freq[arr[i]] += 1; } sort(arr.beg...
#include <bits/stdc++.h> #define MAX int(2 * 10e5) #define ll long long int using namespace std; int main() { vector<ll> sieve(MAX + 1, true); int n; cin >> n; vector<ll> arr(n + 1, 0); vector<ll> freq(MAX + 1, 0); for (int i = 1; i <= n; i++) { cin >> arr[i]; freq[arr[i]] += 1; } sort(arr.beg...
[["-", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]]
1
258
from sys import stdin import numpy as np input = stdin.readline N = int(input()) A_list = list(map(int, input().split())) # ans_list =np.ones(N) # A_list = np.array(A_list) # for i in range(N-1): # for j in range(i+1,N): # if A_list[i] % A_list[j] == 0: # ans_list[i] = 0 # if (A_l...
from sys import stdin import numpy as np input = stdin.readline N = int(input()) A_list = list(map(int, input().split())) # ans_list =np.ones(N) # A_list = np.array(A_list) # for i in range(N-1): # for j in range(i+1,N): # if A_list[i] % A_list[j] == 0: # ans_list[i] = 0 # if (A_l...
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612], ["-", 0, 57, 64, 196, 0, 1, 0, 206, 0, 70], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 57, 64, 196, 0, 1, 0, 206, 0, 73], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
195
require "prime" n = gets.chomp.to_i arr = gets.chomp.split.map(&:to_i) #ダブってるか hash = {} arr.each do |a| hash[a] = hash.has_key?(a) ? false : true end arr = arr.uniq.sort pri = Array.new(arr[arr.length-1]+1, true) p arr cnt = 0 arr.each do |a| #a = arr[i] aa = a cnt += 1 if pri[a] && hash[a] # puts "-----a=#{a} ...
require "prime" n = gets.chomp.to_i arr = gets.chomp.split.map(&:to_i) #ダブってるか hash = {} arr.each do |a| hash[a] = hash.has_key?(a) ? false : true end arr = arr.uniq.sort pri = Array.new(arr[arr.length-1]+1, true) #p arr cnt = 0 arr.each do |a| #a = arr[i] aa = a cnt += 1 if pri[a] && hash[a] # puts "-----a=#{a}...
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22]]
4
138
n = int(input()) A = list(map(int,input().split())) d = {} for a in A: d.setdefault(a,0)#setdefault(key,value):辞書の既存のkeyについては変更せず d[a] += 1 #新規のkeyにのみ新たなvalueで要素を追加できる #今は({A1:1,A2:1,...An:1}となっている) A = sorted(set(A))#重複要素なくしてかつ昇順にする t = [True] * (10 ** 6 + 1)#Aiの制約範囲最大までのTrueのリストを作る print(d) for a in ...
n = int(input()) A = list(map(int,input().split())) d = {} for a in A: d.setdefault(a,0)#setdefault(key,value):辞書の既存のkeyについては変更せず d[a] += 1 #新規のkeyにのみ新たなvalueで要素を追加できる #今は({A1:1,A2:1,...An:1}となっている) A = sorted(set(A))#重複要素なくしてかつ昇順にする t = [True] * (10 ** 6 + 1)#Aiの制約範囲最大までのTrueのリストを作る for a in A: i...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
141
#ifndef TEMPLATE_HPP #define TEMPLATE_HPP #include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <numeric> #include <set> #include <string> #include <tuple> #inc...
#ifndef TEMPLATE_HPP #define TEMPLATE_HPP #include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <numeric> #include <set> #include <string> #include <tuple> #inc...
[["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 78], ["+", 8, 9, 0, 7, 10, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
3,845
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const int INF = 1001001001; using P = pair<int, int>; const int Max = 1000005; int main(void) { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> memo(Max); rep(i, n...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const int INF = 1001001001; using P = pair<int, int>; const int Max = 1000005; int main(void) { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<int> memo(Max); rep(i, n...
[["-", 75, 76, 0, 9, 0, 7, 26, 11, 12, 22], ["+", 0, 9, 0, 7, 26, 11, 12, 69, 28, 22], ["+", 0, 7, 26, 11, 12, 69, 341, 342, 0, 70], ["+", 0, 7, 26, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 7, 26, 11, 12, 69, 341, 342, 0, 73]]
1
180
import sys from collections import Counter sys.setrecursionlimit(10 ** 7) rl = sys.stdin.readline def solve(): _ = int(rl()) A = list(map(int, rl().split())) counter = Counter(A) B = [True] * (10 ** 6 + 1) ans = 0 for ai in A: if B[ai]: for i in range(ai, 10 ** 6 + 1,...
import sys from collections import Counter sys.setrecursionlimit(10 ** 7) rl = sys.stdin.readline def solve(): _ = int(rl()) A = list(map(int, rl().split())) counter = Counter(A) A.sort() B = [True] * (10 ** 6 + 1) ans = 0 for ai in A: if B[ai]: for i in range(ai,...
[["+", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
131
n = int(input()) a = list(map(int, input().split())) a.sort() l = [True] * (10**6 + 1) cnt = 0 for i in range(n): d = a[i] if l[d]: if i < n-1 and a[i] != a[i+1]: cnt += 1 elif i == n-1: cnt += 1 for j in range(d, 10**6 + 1, d): l[d] = False print(cnt)
n = int(input()) a = list(map(int, input().split())) a.sort() l = [True] * (10**6 + 1) cnt = 0 for i in range(n): d = a[i] if l[d]: if i < n-1 and a[i] != a[i+1]: cnt += 1 elif i == n-1: cnt += 1 for j in range(d, 10**6 + 1, d): l[j] = False print(cnt)
[["-", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22]]
5
124
import collections N = int(input()) A = list(map(int,input().split())) S = set() D = set() for a in A: if a in S: D.add(a) else: S.add(a) M = max(S) A = [0]*(M+1) for s in S: if s in D: A[s] += 1 continue else: for i in range(2*s,M+1,s): A[i]+=1 count ...
import collections N = int(input()) A = list(map(int,input().split())) S = set() D = set() for a in A: if a in S: D.add(a) else: S.add(a) M = max(S) A = [0]*(M+1) for s in S: if s in D: A[s] += 1 for i in range(2*s,M+1,s): A[i]+=1 count = 0 for s in S: if A[s]==0: ...
[["-", 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
142
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); int amax = -1; for (int i = 0; i < n; ++i) { cin >> a[i]; amax = max(amax, a[i]); } sort(a.begin(), a.end()); vector<int> tmp(amax, 0); for (int i = 0; i < n; ++i) { if (tmp[a[i]] == 0) { f...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); int amax = -1; for (int i = 0; i < n; ++i) { cin >> a[i]; amax = max(amax, a[i]); } sort(a.begin(), a.end()); vector<int> tmp(amax + 10, 0); for (int i = 0; i < n; ++i) { if (tmp[a[i]] == 0) { ...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
208
#include <bits/stdc++.h> using namespace std; #include <cmath> #include <cstdlib> #include <iostream> #include <math.h> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using pint = pa...
#include <bits/stdc++.h> using namespace std; #include <cmath> #include <cstdlib> #include <iostream> #include <math.h> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using pint = pa...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 338, 8, 9, 0, 7, 26, 11, 17, 108], ["-", 0, 338, 8, 9, 0, 7, 26, 11, 12, 13], ["+", 0, 338, 8, 9, 0, 7, 26, 11, 17, 107], ["+", 0, 338, 8, 9, 0, 7, 26, 11, 12, 22], ["-", 0, 1, 0, 27, 28, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 2...
1
291
#include <algorithm> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define REP(i, n) for (int i = 1...
#include <algorithm> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define REP(i, n) for (int i = 1...
[["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22]]
1
274
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { ll n; cin >> n; vector<int> a(n); REP(i, n) cin >> a[i]; vector<int> num(1000000, 0); num[0] = 2; ll ans = 0; REP(i, n) { ll p = a[i]; if (p != 0) { num[p] = 2...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { ll n; cin >> n; vector<int> a(n); REP(i, n) cin >> a[i]; vector<int> num(1000000, 0); num[0] = 2; ll ans = 0; REP(i, n) { ll p = a[i]; if (num[p] != 0) { num[p...
[["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
172
def main(): n, *a = map(int, open(0).read().split()) if n == 1: print(1) return m = max(a) + 1 l = [0] * m for i in a: for j in range(i, m, i): l[j] += 2 l[i] -= 1 ans = sum(l[i] == -1 for i in a) print(ans) if __name__ == "__main__": main(...
def main(): n, *a = map(int, open(0).read().split()) if n == 1: print(1) return m = max(a) + 1 l = [0] * m for i in a: for j in range(i, m, i): l[j] += 2 l[i] -= 1 ans = sum(l[i] == 1 for i in a) print(ans) if __name__ == "__main__": main()...
[["-", 12, 652, 3, 668, 8, 666, 0, 664, 17, 33]]
5
111
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <chrono> #include <climits> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include ...
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <chrono> #include <climits> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 107], ["-", 0, 57, 64, 1, 0, 11, 12, 69, 28, 22], ["-", 64, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["-", 64, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["-", 64, 1, 0, 11, 12, 69, 341, 342, 0, 73], ["+"...
1
285