inline ll rd(){ ll x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
#define N 1000007
char s[N];
intmain(){ scanf("%s", s + 1); int n = strlen(s + 1); int x = 0, y = 0; for (int i = 1; i <= n; ++i, ++x) if (s[i] != 'a') break; for (int i = n; i; --i, ++y) if (s[i] != 'a') break; if (x > y) {puts("No"); return0;} int L = x + 1, R = n - y; for (int i = L; i <= R; ++i) if (s[i] != s[R - (i - L)]) {puts("No"); return0;} puts("Yes"); return0; }
inline ll rd(){ ll x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
#define N 200007
int n, m, tot, hd[N];
structedge {int to, nxt, w;} e[N << 1];
inlinevoidadd(int u, int v, int w){ e[++tot].to = v; e[tot].w = w; e[tot].nxt = hd[u]; hd[u] = tot; }
ll dis[N], h[N];
bool vis[N];
priority_queue<pair<ll, int> > q;
inlinevoiddij(int u){ memset(dis, 0x3f, sizeof(dis)); dis[u] = 0; q.push(make_pair(0, u)); while (!q.empty()) { u = q.top().second; q.pop(); if (vis[u]) continue; vis[u] = 1; for (int i = hd[u], v; i; i = e[i].nxt) if (dis[v = e[i].to] > dis[u] + e[i].w) { dis[v] = dis[u] + e[i].w; q.push(make_pair(-dis[v], v)); } } }
intmain(){ n = rd(); m = rd(); for (int i = 1; i <= n; ++i) h[i] = rd(); for (int i = 1, u, v, w; i <= m; ++i) { u = rd(); v = rd(); if (h[u] < h[v]) swap(u, v); add(u, v, 0); add(v, u, h[u] - h[v]); } dij(1); ll ans = 0; for (int u = 1; u <= n; ++u) ans = max(ans, -(dis[u] + h[u] - h[1])); printf("%lld\n", ans); return0; }
cin >> n >> m; for (int i = 1; i <= m; ++i) f[1][i][11][12] = 1;
for (int i = 1; i < n; ++i) for (int a = 1; a <= m; ++a) for (int b = a + 1; b <= 11; ++b) for (int c = b + 1; c <= 12; ++c) for (int j = 1; j <= min(c, m); ++j) { int tara = min(a, j); int tarb = (j > a ? min(b, j) : b); int tarc = (j > b ? min(c, j) : c); f[i + 1][tara][tarb][tarc] = (f[i + 1][tara][tarb][tarc] + f[i][a][b][c]) % mod; } int ans = 0; for (int i = 1; i <= m; ++i) for (int j = i + 1; j <= m; ++j) for (int k = j + 1; k <= m; ++k) ans = (ans + f[n][i][j][k]) % mod; cout << ans; return0; }
inline ll rd(){ ll x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == '-'); for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); return f ? -x : x; }
#define N 207 #define pb push_back
string str, a[N];
set<string> s;
inlineboolsubstr(int u, int v){ for (int i = 0; i + a[v].length() <= a[u].length(); ++i) { bool fl = true; for (int j = 0; j < a[v].length(); ++j) if (a[u][i + j] != a[v][j]) {fl = false; break;} if (fl) returntrue; } returnfalse; }
vector<int> e[N];
int match[N], vis[N];
booldfs(int u, int t){ for (auto v : e[u]) if (vis[v] != t) { vis[v] = t; if (!match[v] || dfs(match[v], t)) {match[v] = u; returntrue;} } returnfalse; }
intmain(){ cin >> str; int n = str.length(); for (int l = 0; l < n; ++l) for (int r = l; r < n; ++r) { bool fl = true; int len = r - l + 1; for (int i = 1; i <= len; ++i) if (str[l + i - 1] != str[r - i + 1]) fl = false; if (fl) s.insert(str.substr(l, len)); } int m = 0; for (auto x : s) a[++m] = x; for (int i = 1; i <= m; ++i) for (int j = 1; j <= m; ++j) if (i != j && substr(j, i)) e[i].pb(j); int ans = m; for (int i = 1; i <= m; ++i) ans -= dfs(i, i); printf("%d\n", ans); return0; }