#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
string s; cin >> s;
int ans = 0;
for (int i = 3; i < 6; i++) {
ans = ans * 10 + s[i] - '0';
}
if (ans >= 1 && ans <= 349 && ans != 316) {
cout << "Yes\n";
}
else {
cout << "No\n";
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n, q; cin >> n >> q;
vector <bool> vis(n + 1);
int ans = n;
while (q--) {
int x; cin >> x;
if (!vis[x]) {
ans --; vis[x] = 1;
}
else {
ans ++; vis[x] = 0;
}
}
cout << ans << '\n';
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n; cin >> n;
vector <int> a(n + 1), rev(n + 1);
vector <pair <int, int>> p;
for (int i = 1; i <= n; i++) {
cin >> a[i];
rev[a[i]] = i;
}
int cnt = 0;
for (int i = 1; i <= n; i++) {
if (a[i] != i) {
cnt ++;
p.push_back({rev[a[i]], rev[i]});
int pos = rev[i];
swap(a[i], a[pos]);
rev[a[pos]] = pos;
rev[a[i]] = i;
}
}
cout << cnt << '\n';
for (const pair <int, int> i : p) {
cout << i.first << ' ' << i.second << '\n';
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, f[N], m, sz[N];
using i64 = long long;
i64 ans = 0;
void init() {
for (int i = 1; i <= n; i++) f[i] = i, sz[i] = 1;
}
int find(int x) {
return f[x] == x ? x : f[x] = find(f[x]);
}
void merge(int x, int y) {
x = find(x); y = find(y);
if (x == y) return ;
if (sz[x] < sz[y]) {
swap(sz[x], sz[y]);
}
f[y] = x; sz[x] += sz[y];
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m;
init();
for (int i = 1; i <= m; i++) {
int x, y; cin >> x >> y;
merge(x, y);
}
for (int i = 1; i <= n; i++) {
if (f[i] == i) {
ans += 1LL * (sz[i]) * (sz[i] - 1) / 2;
}
}
cout << ans - 1LL * m << '\n';
return 0;
}
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
i64 a, x, y;
map <i64, double> dp;
double dfs(i64 n) {
if (!n) return 0;
if (dp[n]) return dp[n];
return dp[n] = min(dfs(n / a) + x, (dfs(n / 6) + dfs(n / 5) + dfs(n / 4) + dfs(n / 3) + dfs(n / 2) + 6 * y) / 5);
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
i64 n; cin >> n >> a >> x >> y;
dfs(n);
cout << fixed << setprecision(30) << dp[n] << '\n';
return 0;
}
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
string s;
stack <int> st;
int a[N];
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '(') {
st.push(i);
}
else if (s[i] == ')') {
a[st.top()] = i;
a[i] = st.top(); st.pop();
}
}
int ok = 0;
for (int i = 0; i < s.size(); i = (ok ? i - 1 : i + 1)) {
if (s[i] == '(' || s[i] == ')') {
i = a[i];
ok ^= 1;
}
else {
if (ok) cout << char(s[i] ^ 32);
else cout << char(s[i]);
}
}
return 0;
}