malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = (int)1e9;   const long long INFLL = (long long)1e16;   const int MOD = (int)1e9 + 7;   template <typename T>   void out(T x) {     cout << x << endl;     exit(0);   }   bool bysec(const pair<int, int> &a, const pair<int, int> &b) {     return a.second < b.second;   }   const int maxn = (int)2e5 + 5;   int n, a[maxn];   vector<int> zero, pos;   set<pair<int, int> > neg;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     bool deleted = false;     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       if (x > 0) {         pos.push_back(i);       } else if (x < 0) {         neg.insert(make_pair(x, i));       } else {         zero.push_back(i);       }     }     if (pos.size() == 0 && neg.size() == 1 && zero.size() > 0) {       if (zero.size() > 1) {         for (int i = 1; i < (int)zero.size(); i++) {           cout <<  1   << zero[i] <<     << zero[0] << endl;         }       }       cout <<  2   << neg.begin()->second << endl;       return 0;     }     if (pos.size() == 0 && neg.size() == 0 && zero.size() > 0) {       if (zero.size() > 1) {         for (int i = 1; i < (int)zero.size(); i++) {           cout <<  1   << zero[i] <<     << zero[0] << endl;         }       }       return 0;     }     if (zero.size() > 1) {       for (int i = 1; i < (int)zero.size(); i++) {         cout <<  1   << zero[i] <<     << zero[0] << endl;       }     }     if (pos.size() > 1) {       for (int i = 1; i < (int)pos.size(); i++) {         cout <<  1   << pos[i] <<     << pos[0] << endl;       }     }     if (neg.size() % 2 == 1) {       int ind = neg.rbegin()->second;       if (zero.size() > 0) {         cout <<  1   << ind <<     << zero[0] << endl;       } else {         deleted = true;         cout <<  2   << ind << endl;       }     }     int sz = neg.size();     if (sz > 1) {       int end = sz % 2 == 1 ? sz - 1 : sz;       int f = neg.begin()->second;       int i = 0;       for (auto &p : neg) {         if (i == 0) {           i++;           continue;         }         if (i == end) break;         int cur = p.second;         cout <<  1   << cur <<     << f << endl;         i++;       }     }     if (zero.size() > 0 && !deleted) {       cout <<  2   << zero[0] << endl;       deleted = true;     }     if (pos.size() > 0 && sz > 1) {       cout <<  1   << pos[0] <<     << neg.begin()->second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     string s;     cin >> s;     long long i = 0;     while (i + 1 < s.size() && s[i] == s[i + 1]) {       if (s[i] ==  0 ) {         cout << 3 <<     << 1 <<   n ;         cout << 1 <<     << 1 <<   n ;       } else {         cout << 1 <<     << 1 <<   n ;         cout << 1 <<     << 3 <<   n ;       }       i += 2;     }     bool r = 0, c = 0;     while (i < s.size()) {       if (s[i] ==  0 ) {         if (r) {           cout << 1 <<     << 1 <<   n ;           r = 0;         } else {           cout << 3 <<     << 1 <<   n ;           r = 1;         }       } else {         if (c) {           cout << 1 <<     << 1 <<   n ;           c = 0;         } else {           cout << 1 <<     << 3 <<   n ;           c = 1;         }       }       i++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   string s;   int main() {     cin >> s;     int i = 0, cnt = 0;     int len = s.size();     while ((i = s.find( VK )) != -1) {       s[i] = s[i + 1] =  . ;       cnt++;     }     if (s.find( VV ) != -1 || s.find( KK ) != -1) cnt++;     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const double PI = acos(-1.0);   int a[100005], s[100005], dp1[100005], dp2[100005], b[100005], ans[100005];   int main() {     int n, i, maxlen, k;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &a[i]), b[n - i + 1] = -a[i];     for (i = 0; i <= n; i++) s[i] = 0x3f3f3f3f;     maxlen = 0;     for (i = 1; i <= n; i++) {       k = lower_bound(s, s + n, a[i]) - s;       s[k] = a[i];       dp1[i] = k + 1;       maxlen = max(maxlen, dp1[i]);     }     for (i = 0; i <= n; i++) s[i] = 0x3f3f3f3f;     for (i = 1; i <= n; i++) {       k = lower_bound(s, s + n, b[i]) - s;       s[k] = b[i];       dp2[n - i + 1] = k + 1;     }     k = 0;     memset(ans, -1, sizeof(ans));     for (i = 1; i <= n; i++) {       if (dp1[i] + dp2[i] - 1 < maxlen)         ans[i] = 1;       else         s[k++] = dp1[i];     }     sort(s, s + k);     for (i = 1; i <= n; i++) {       if (ans[i] == 1)         printf( 1 );       else {         if (upper_bound(s, s + k, dp1[i]) - lower_bound(s, s + k, dp1[i]) > 1)           printf( 2 );         else           printf( 3 );       }     }     puts(  );   }
#include <bits/stdc++.h>   using namespace std;   int n, m, q, tot, rec[100010], cnt[100010][360], num[360], Limit, W,       tmp[100010];   long long delta[360], sum[360], a[100010];   struct Set {     int k, l, r;   } s[100010];   long long AskBig(int now) {     int pos = tmp[now];     long long ans = sum[pos];     for (int i = 1; i <= W; i++) ans += (long long)cnt[now][i] * delta[i];     return ans;   }   long long AskSmall(int now) {     long long ans = 0;     for (int i = s[now].l; i <= s[now].r; i++) ans += a[rec[i]];     for (int i = 1; i <= W; i++) ans += (long long)cnt[now][i] * delta[i];     return ans;   }   void ChangeSmall(int now, int v) {     for (int i = s[now].l; i <= s[now].r; i++) a[rec[i]] += v;     for (int i = 1; i <= W; i++) sum[i] += (long long)cnt[now][i] * v;   }   int main() {     scanf( %d%d%d , &n, &m, &q);     Limit = ceil(sqrt(n));     for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]);     for (int i = 1; i <= m; i++) {       int k;       scanf( %d , &k);       s[i].k = k;       s[i].l = tot + 1;       for (int j = 1; j <= k; j++) {         int x;         scanf( %d , &x);         rec[++tot] = x;       }       s[i].r = tot;       if (k > Limit) num[++W] = i;     }     for (int i = 1; i <= W; i++) {       int u = num[i];       for (int j = s[u].l; j <= s[u].r; j++) {         ++tmp[rec[j]];         sum[i] += a[rec[j]];       }       for (int j = 1; j <= m; j++)         for (int k = s[j].l; k <= s[j].r; k++) cnt[j][i] += tmp[rec[k]];       for (int j = s[u].l; j <= s[u].r; j++) --tmp[rec[j]];     }     for (int i = 1; i <= W; i++) tmp[num[i]] = i;     for (int i = 1; i <= q; i++) {       char c = getchar();       int x, v;       while (c !=  ?  && c !=  + ) c = getchar();       if (c ==  ? ) {         scanf( %d , &x);         if (s[x].k > Limit)           printf( %I64d n , AskBig(x));         else           printf( %I64d n , AskSmall(x));       } else {         scanf( %d%d , &x, &v);         if (s[x].k > Limit)           delta[tmp[x]] += v;         else           ChangeSmall(x, v);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x;   string case1[3] = { >.v ,  >.. ,  ^.< },          case2[5] = { >>>.v ,  >>.vv ,  .>..v ,  ^^.<. ,  ^.<<< };   int main() {     cin >> n >> x;     if (n == 5 && x == 5) {       for (int i = 0; i < 5; i++) cout << case2[i] << endl;       cout << 1 <<     << 1;     } else if (n == 3 && x == 2) {       for (int i = 0; i < 3; i++) cout << case1[i] << endl;       cout << 1 <<     << 1;     } else {       cout <<  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.>.>.>.>.>.>.>.                 >.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>v             << endl            <<  ^v.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<<<<<<<<<<<<<<<<<                 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<             << endl;       for (int i = 1; i <= 24; i++)         cout <<  .>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.>.>.>.>.>.>.                   >.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>v               << endl              <<  ^v.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<<<<<<<<<<<<<<<                   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<               << endl;       for (int i = 1; i <= 24; i++)         cout <<  ^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.>.>.>.>.>.>.                   >.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>v               << endl              <<  ^v.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<<<<<<<<<<<<<<<                   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<               << endl;       cout <<  ^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.>.>.>.>.>.>.>.                 >.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>v             << endl            <<  ^<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<<<<<<<<<<<<<<<<<                 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<             << endl            << 1 <<     << 1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e5 + 5;   long long n, a[maxn], dp[maxn][2], f[maxn][2], d[maxn];   long long head[maxn], ecnt;   struct edge {     long long to, next;   } e[maxn << 1];   void adde(long long u, long long v) {     e[++ecnt].to = v;     e[ecnt].next = head[u];     head[u] = ecnt;   }   long long read() {     long long res = 0, f = 1;     char ch;     do {       ch = getchar();       if (ch ==  - ) f = -1;     } while (!isdigit(ch));     do {       res = res * 10 + ch -  0 ;       ch = getchar();     } while (isdigit(ch));     return res * f;   }   void dfs1(long long u, long long fa) {     dp[u][0] = dp[u][1] = f[u][0] = d[u] = a[u];     for (long long i = head[u]; i; i = e[i].next) {       long long v = e[i].to;       if (v == fa) continue;       dfs1(v, u);       dp[u][0] = max(dp[u][0], dp[v][0]);       dp[u][0] = max(dp[u][0], dp[u][1] + dp[v][1]);       dp[u][0] = max(dp[u][0], d[u] + f[v][0]);       dp[u][0] = max(dp[u][0], d[v] + f[u][0]);       dp[u][1] = max(dp[u][1], dp[v][1]);       dp[u][1] = max(dp[u][1], d[u] + d[v]);       f[u][0] = max(f[u][0], a[u] + f[v][0]);       f[u][0] = max(f[u][0], d[u] + dp[v][1]);       f[u][0] = max(f[u][0], a[u] + d[v] + f[u][1]);       f[u][1] = max(f[u][1], dp[v][1]);       d[u] = max(d[u], d[v] + a[u]);     }   }   signed main() {     n = read();     for (long long i = (1); i <= (n); ++i) a[i] = read();     for (long long i = (1); i <= (n - 1); ++i) {       long long u = read(), v = read();       adde(u, v);       adde(v, u);     }     dfs1(1, 0);     printf( %lld n , dp[1][0]);   }
#include<bits/stdc++.h>   #define FOR(i,a,b) for( int i=(a); i<(b); ++i)   #define REP(i,a,b) for( int i=(a); i<=(b); ++i)   #define SHOW(x) for(auto i:(x)){ cout << i <<    ;} cout << endl;   #define MAXN 25   using namespace std;      typedef long long LL;   typedef pair<int,int> PII;   typedef vector<int> VI;   void solve(){       string s;cin >> s;       bool f1 = false,f2 = false;       for(int i = 1; i < s.size(); i++){           if(s[i] == s[i-1] && s[i] ==  1 ){               f1 = true;           }           if(f1 && s[i] == s[i-1] && s[i] ==  0 ){               f2 = true;               break;           }       }       if(f2) cout <<  NO  << endl;       else cout <<  YES  << endl;   }   int main(){       ios::sync_with_stdio(false);       cin.tie(0);       int n; cin >> n;       while(n--){           solve();       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2000000 + 77, Mod = 1000000007, L = 30;   int n, m, k, dp[N], T[L], P[N], Ps[N], SS[L];   char S[N];   int main() {     scanf( %d %d , &n, &k);     scanf( %s , S + 1);     m = strlen(S + 1);     dp[0] = Ps[0] = 1;     for (int i = 1; i <= m; ++i) {       P[i] = T[S[i] -  a ], T[S[i] -  a ] = i;       dp[i] = (Ps[i - 1] - SS[S[i] -  a ] + Mod) % Mod;       Ps[i] = (Ps[i - 1] + dp[i]) % Mod;       SS[S[i] -  a ] = (SS[S[i] -  a ] + dp[i]) % Mod;     }     for (int i = m + 1; i <= n + m; ++i) {       int Mn = 0;       for (int j = 1; j < k; ++j)         if (T[j] < T[Mn]) Mn = j;       P[i] = T[Mn], T[Mn] = i;       dp[i] = (Ps[i - 1] - SS[Mn] + Mod) % Mod;       Ps[i] = (Ps[i - 1] + dp[i]) % Mod;       SS[Mn] = (SS[Mn] + dp[i]) % Mod;     }     printf( %d n , Ps[n + m]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unordered_map<string, int> mp;   char ans[2][1005];   bool x[5005];   int oprd[2][5005];   char orig[5005][1005];   char op[5005][20];   char input[4][1005];   char line[4 * 1005];   int main() {     int n, m;     while (scanf( %d%d  , &n, &m) != EOF) {       mp.clear();       for (int i = (1); i <= (n); i++) {         fgets(line, 4 * 1005, stdin);         int num = sscanf(line,  %s := %s %s %s , input[0], input[1], input[2],                          input[3]);         mp[string(input[0])] = i;         if (num == 4) {           if (input[1][0] ==  ? )             oprd[0][i] = -1;           else             oprd[0][i] = mp[string(input[1])];           strcpy(op[i], input[2]);           if (input[3][0] ==  ? )             oprd[1][i] = -1;           else             oprd[1][i] = mp[string(input[3])];         } else           op[i][0] =  # , strcpy(orig[i], input[1]);       }       for (int i = (0); i <= (m - 1); i++) {         int val[2];         val[0] = val[1] = 0;         for (int j = (0); j <= (1); j++) {           for (int k = (1); k <= (n); k++) {             if (op[k][0] ==  # )               x[k] = orig[k][i] -  0 ;             else {               int oprd1 = (oprd[0][k] == -1 ? j : x[oprd[0][k]]);               int oprd2 = (oprd[1][k] == -1 ? j : x[oprd[1][k]]);               if (op[k][0] ==  X )                 x[k] = oprd1 ^ oprd2;               else if (op[k][0] ==  O )                 x[k] = oprd1 | oprd2;               else                 x[k] = oprd1 & oprd2;             }             val[j] += x[k];           }         }         ans[0][i] = (val[0] <= val[1] ?  0  :  1 );         ans[1][i] = (val[0] < val[1] ?  1  :  0 );       }       ans[0][m] = ans[1][m] =   0 ;       printf( %s n , ans[0]);       printf( %s n , ans[1]);     }     return 0;   }
#include <bits/stdc++.h>   const int inf = 0x3f3f3f3f;   const int maxn = 500050;   const int mod = 1e9 + 7;   using namespace std;   int main() {     ios::sync_with_stdio(0);     int n, a, b;     cin >> n >> a >> b;     int c = 0, ans = 0;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       if (x == 1) {         if (a > 0)           a--;         else {           if (b > 0) {             b--;             c++;           } else if (c > 0)             c--;           else             ans++;         }       } else {         if (b > 0)           b--;         else           ans += 2;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 2;   string s;   long long n;   long long func(vector<long long> a) {     stack<long long> st;     long long max_ = 0;     for (long long i = 0; i < n; i++) {       while (!st.empty() && a[i] > st.top()) {         long long cur = st.top();         st.pop();         max_ = max(cur ^ a[i], max_);       }       st.push(a[i]);     }     return max_;   }   void solve() {     cin >> n;     vector<long long> a(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     long long ans = func(a);     reverse(a.begin() + 0, a.end());     ans = max(ans, func(a));     cout << ans;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, b, g, ans = 0;     cin >> b >> g >> n;     if (n < b && n < g)       ans = n + 1;     else if (n < b && n > g)       ans = g + 1;     else if (n < g && n > b)       ans = b + 1;     else {       ans = min(b, g) + 1 - (n - max(b, g));     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void checkMin(T &a, T b) {     if (b < a) a = b;   }   template <typename T>   inline void checkMax(T &a, T b) {     if (a < b) a = b;   }   const int P = 1e7 + 19;   const int Q = 1e9 + 7;   const int MAX_N = 5005 + 30000;   int n, k, w[MAX_N], v[MAX_N];   long long dp[32][1001];   int beg[MAX_N], qc[MAX_N];   set<pair<int, int>, greater<pair<int, int>>> es[MAX_N];   void dfs(int depth, int l, int r) {     copy(dp[depth - 1], dp[depth], dp[depth]);     for (auto iter = es[l].begin(); iter != es[l].end();) {       if (iter->first < r) break;       int i = iter->second;       if (iter->first > r) {         es[r + 1].emplace(iter->first, i);       }       iter = es[l].erase(iter);       for (int j = k; j >= w[i]; --j) {         checkMax(dp[depth][j], dp[depth][j - w[i]] + v[i]);       }     }     if (l == r) {       if (!qc[l]) return;       int ans = 0;       for (int i = k; i >= 1; --i) {         ans = ((long long)ans * P + dp[depth][i]) % Q;       }       for (int i = 0; i < int(qc[l]); ++i) {         printf( %d n , ans);       }     } else {       int m = (l + r) >> 1;       dfs(depth + 1, l, m);       dfs(depth + 1, m + 1, r);     }   }   int main() {     while (~scanf( %d%d , &n, &k)) {       fill(qc, qc + MAX_N, 0);       fill(es, es + MAX_N, set<pair<int, int>, greater<pair<int, int>>>());       int ts = 1;       for (int i = 1; i <= n; ++i) {         scanf( %d%d , &v[i], &w[i]);         beg[i] = ts;       }       int q, type, x;       scanf( %d , &q);       for (int i = 0; i < int(q); ++i) {         scanf( %d , &type);         if (type == 1) {           ++ts;           ++n;           scanf( %d%d , &v[n], &w[n]);           beg[n] = ts;         } else if (type == 2) {           scanf( %d , &x);           es[beg[x]].emplace(ts++, x);           beg[x] = -1;         } else {           ++qc[ts];         }       }       for (int i = 1; i <= n; ++i) {         if (beg[i] == -1) continue;         es[beg[i]].emplace(ts, i);       }       dfs(1, 1, ts);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[10000006];   int main() {     long long n, x, y;     scanf( %lld%lld%lld , &n, &x, &y);     for (int i = 0; i <= n; ++i) dp[i] = 1e18 + 100;     dp[1] = x;     for (int i = 2; i <= n; ++i) {       if (i % 2 == 1)         dp[i] = min(dp[i - 1] + x, min(dp[i / 2] + y + x, dp[i / 2 + 1] + y + x));       else         dp[i] = min(dp[i - 1] + x, dp[i / 2] + y);     }     printf( %lld n , dp[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m, n, t = 0, a[6], d1, d2, d3, d4, s1, s2;     cin >> m >> n;     char s[m][n];     for (int i = 0; i < m; i++)       for (int j = 0; j < n; j++) {         cin >> s[i][j];         if (s[i][j] ==  * ) {           a[t] = i;           a[t + 1] = j;           t = t + 2;         }       }     for (int i = 0; i < m; i++) {       for (int j = 0; j < n; j++) {         if ((a[2] != a[0]) && (i != a[4])) {           s1 = (a[3] - a[1]) / (a[2] - a[0]);           s2 = (j - a[5]) / (i - a[4]);         }         if (s1 == s2 || s1 == (-s2) || (a[2] == a[0] && i == a[4])) {           d1 = pow((a[3] - a[1]), 2) + pow((a[2] - a[0]), 2);           d2 = pow((j - a[5]), 2) + pow((i - a[4]), 2);           d3 = pow((a[5] - a[3]), 2) + pow((a[4] - a[2]), 2);           d4 = pow((j - a[1]), 2) + pow((i - a[0]), 2);           if (d1 == d2 && d3 == d4) {             cout << i + 1 <<     << j + 1;             i = m;             j = n;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       long long n, m;       cin >> n >> m;       long long tot = n * (n + 1) / 2, zr = n - m, gr = m + 1;       long long k = zr / gr, ans = 0;       if (zr % gr == 0) {         ans = tot - (k * (k + 1) / 2) * gr;       } else {         ans = tot - (zr % gr) * ((k + 1) * (k + 2) / 2) -               (gr - (zr % gr)) * (k * (k + 1) / 2);       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fp(long long n, long long p) {     if (p == 0) return 1;     if (p == 1) return n;     long long res = fp(n, p / 2) % (long long)(1e9 + 7);     res = ((res) * (res)) % (long long)(1e9 + 7);     if (p % 2) res = (res * n) % (long long)(1e9 + 7);     return res;   }   int n, m, x[100005], a[100005], b[100005], cnt, suspects = 0;   int ans[100005];   char c[100005];   int main() {     ios::sync_with_stdio(0);     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     ;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> c[i] >> x[i];       if (c[i] ==  + ) {         a[x[i]]++;       } else {         b[x[i]]++;         cnt++;       }     }     for (int i = 1; i <= n; i++) {       if (a[i] - b[i] + cnt == m) ans[i] = 1, suspects++;     }     for (int i = 1; i <= n; i++) {       if (suspects > 1 && ans[x[i - 1]] == 1)         cout <<  Not defined  <<   n ;       else if (c[i - 1] ==  +  && ans[x[i - 1]] == 1)         cout <<  Truth  <<   n ;       else if (c[i - 1] ==  -  && ans[x[i - 1]] == 0)         cout <<  Truth  <<   n ;       else         cout <<  Lie  <<   n ;     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define int long long int   #define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)   #define pii pair<int,int>   #define F first   #define S second   #define pb push_back   const int mod1=998244353,mod2=(int) 1e9+7;   int power(int n,int k,int mod){int ans=1; n=n%mod;while(k>0){if(k&1)ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return (ans+mod)%mod;}//negative nos & 0^0   struct triplet{int a,b,c;};bool operator < (const triplet &t1,const triplet &t2){if(t1.a<t2.a)return true;if(t1.a==t2.a && t1.b <t2.b)return true;if(t1.a==t2.a && t1.b ==t2.b && t1.c<t2.c)return true;return false;}   // memset(dp, -1, sizeof dp);         void problemSolver()   {       int h,w;    cin>>h>>w;    string s[h];    for(int i=0;i<h;i++)     cin>>s[i];    int i=0,j=0,c=0;    if(s[0][0]== * )      c++;         while(i<=h-1 && j<=w-1)    {        if(j+1<w && s[i][j+1]== * )      j++;     else if(i+1<h && s[i+1][j]== * )      i++;     else if(j+1<w)      j++;     else       i++;        if(s[i][j]== * )      c++;     if(i==h-1 && j==w-1)      break;       }    cout<<c;   }             int32_t main()   {      //  fio;    #ifndef ONLINE_JUDGE    freopen( input.txt ,  r , stdin);    freopen( output.txt ,  w , stdout);    #endif    int testcases=1;       // cin>>testcases;       while(testcases--)       problemSolver();       }
#include <bits/stdc++.h>   using namespace std;   struct qnode {     int id;     long long val;     bool operator<(qnode b) const { return val > b.val; }   };   queue<int> qu[200100];   int w[200100], vis[200100], add[200100];   int n, m, Q, opt, x, y, z;   long long dis[200100];   priority_queue<qnode> q;   vector<pair<int, int> > edge[200100];   void Dijkstra() {     memset(dis, 0x3f, sizeof(dis));     dis[1] = 0;     memset(vis, false, sizeof(vis));     q.push((qnode){1, 0});     while (!q.empty()) {       int x = q.top().id;       q.pop();       if (vis[x]) continue;       vis[x] = true;       for (auto i : edge[x]) {         int upup = i.first, z = w[i.second];         dis[upup] = min(dis[upup], dis[x] + z);         if (!vis[upup]) q.push((qnode){upup, dis[upup]});       }     }   }   int main() {     scanf( %d%d%d , &n, &m, &Q);     for (int i = 1; i <= m; i++) {       scanf( %d%d%lld , &x, &y, &w[i]);       edge[x].push_back(make_pair(y, i));     }     Dijkstra();     while (Q--) {       scanf( %d , &opt);       if (opt == 1) {         scanf( %d , &x);         if (dis[x] == 0x3f3f3f3f3f3f3f3f)           puts( -1 );         else           printf( %lld n , dis[x]);       } else {         scanf( %d , &x);         for (int i = 1; i <= x; i++) {           scanf( %d , &y);           w[y]++;         }         for (int i = 1; i <= n; i++) add[i] = x + 1;         qu[add[1] = 0].push(1);         for (int i = 0; i <= x; i++)           for (; !qu[i].empty(); qu[i].pop()) {             int now = qu[i].front();             if (add[now] != i) continue;             for (auto j : edge[now]) {               int y = j.first, z = w[j.second];               long long d = dis[now] + z + add[now] - dis[y];               if (d < add[y]) qu[add[y] = d].push(y);             }           }         for (int i = 1; i <= n; i++)           if (add[i] != x + 1) dis[i] += add[i];       }     }   }