malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long INF = (long long)1e12;   const int maxn = 100050;   struct STU {     int b, c, id;     bool operator<(const STU &s) const {       return c < s.c || (c == s.c && id < s.id);     }   };   map<STU, int> mp;   bool cmp(const STU &a, const STU &b) { return a.b < b.b; }   struct BUG {     int a, id;     bool operator<(const BUG &s) const { return a < s.a; }   };   STU stu[maxn];   BUG bug[maxn];   int N, M, S;   int ans[maxn];   bool judge(int times) {     mp.clear();     long long pass = 0;     int p = M - 1, q = N - 1;     map<STU, int>::iterator it;     for (; p >= 0; p--) {       while (q >= 0 && stu[q].b >= bug[p].a) {         mp[stu[q]] = times;         q--;       }       if (p == M - 1 || it->second <= 0) {         if (p != M - 1) mp.erase(it);         it = mp.begin();         if (it == mp.end()) return false;         pass += it->first.c;       }       ans[bug[p].id] = it->first.id;       it->second--;     }     return pass <= S;   }   int main() {     scanf( %d%d%d , &N, &M, &S);     int max_a = 0;     for (int i = 0; i < M; i++)       scanf( %d , &bug[i].a), bug[i].id = i + 1, max_a = max(max_a, bug[i].a);     for (int i = 0; i < N; i++) scanf( %d , &stu[i].b);     for (int i = 0; i < N; i++) scanf( %d , &stu[i].c), stu[i].id = i + 1;     bool ok = false;     for (int i = 0; i < N; i++)       if (stu[i].b >= max_a && stu[i].c <= S) ok = true;     if (!ok) {       printf( NO n );       return 0;     } else       printf( YES n );     sort(bug, bug + M);     sort(stu, stu + N, cmp);     int L = 1, H = M, mid;     while (L < H) {       mid = L + (H - L) / 2;       if (judge(mid))         H = mid;       else         L = mid + 1;     }     judge(L);     for (int i = 1; i < M; i++) printf( %d  , ans[i]);     printf( %d n , ans[M]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, i;       cin >> n;       string s;       int ans = 0;       cin >> s;       for (i = 1; i < n; i++) {         if (s[i] != s[0]) break;       }       if (i != n) {         int c = 1;         for (int j = i + 1; j != i; j = (j + 1) % n) {           if ((j != 0 && s[j] == s[j - 1]) || (j == 0 && s[0] == s[n - 1])) {             c++;           } else {             while (c >= 3) {               ans++;               c -= 3;             }             c = 1;           }         }         while (c >= 3) {           ans++;           c -= 3;         }       } else {         int c = n - 1;         ans = 1;         while (c >= 3) {           ans++;           c -= 3;         }       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, Minus, tmp, pos, lar_pos, ans;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   long long f(long long a, long long b) {     if (b == 0)       return 0ll;     else       return 1ll + f(a, b - gcd(a, b));   }   vector<long long> v, base;   int main() {     scanf( %lld %lld , &a, &b);     c = a;     for (long long i = 2; i * i <= c; i++) {       if (a % i == 0ll) v.push_back(i);       while (a % i == 0ll) a /= i;     }     if (a != 1ll) v.push_back(a);     for (int i = (0); i < (v.size()); i++) base.push_back(v[i]);     a = c;     while (b > 0) {       Minus = gcd(a, b);       for (int i = (0); i < (v.size()); i++)         while (Minus % v[i] == 0) v[i] *= base[i];       lar_pos = 0ll;       for (int i = (0); i < (v.size()); i++) {         if (a % v[i] != 0ll) continue;         tmp = lcm(Minus, v[i]);         pos = b / tmp * tmp;         lar_pos = max(pos, lar_pos);       }       ans += (b - lar_pos) / Minus;       b = lar_pos;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M, K;   vector<pair<int, char> > r, rr;   int main() {     scanf( %d %d %d , &N, &M, &K);     if (4 * N * M - 2 * N - 2 * M < K) return !printf( NO );     printf( YES n );     int c;     char d;     c = M - 1;     d =  R ;     r.push_back({min(c, K), d});     K -= c;     if (K <= 0) goto END;     for (int i = 0; i < M - 1; i++) {       c = N - 1;       d =  D ;       r.push_back({min(c, K), d});       K -= c;       if (K <= 0) goto END;       c = N - 1;       d =  U ;       r.push_back({min(c, K), d});       K -= c;       if (K <= 0) goto END;       c = 1;       d =  L ;       r.push_back({min(c, K), d});       K -= c;       if (K <= 0) goto END;     }     for (int i = 0; i < N - 1; i++) {       c = 1;       d =  D ;       r.push_back({min(c, K), d});       K -= c;       if (K <= 0) goto END;       c = M - 1;       d =  R ;       r.push_back({min(c, K), d});       K -= c;       if (K <= 0) goto END;       c = M - 1;       d =  L ;       r.push_back({min(c, K), d});       K -= c;       if (K <= 0) goto END;     }     c = N - 1;     d =  U ;     r.push_back({min(c, K), d});     K -= c;     if (K <= 0) goto END;   END:     for (int i = 0; i < r.size(); i++)       if (r[i].first > 0) rr.push_back(r[i]);     r = rr;     printf( %d n , r.size());     for (int i = 0; i < r.size(); i++) printf( %d %c n , r[i].first, r[i].second);     return 0;   }
#include <bits/stdc++.h>   int main(int argc, char const *argv[]) {     int h1, a1, c1, h2, a2;     std::cin >> h1 >> a1 >> c1;     std::cin >> h2 >> a2;     std::string s =  STRIKE n , h =  HEAL n ;     int n(0);     std::string ans;     while (h2 > 0) {       n++;       if (h1 <= a2 && h2 > a1) {         h1 += c1;         ans += h;       } else {         h2 -= a1;         ans += s;       }       h1 -= a2;     }     std::cout << n <<   n ;     std::cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t[123];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int a, n;     cin >> n >> a;     --a;     for (int i = 0; i < n; ++i) cin >> t[i];     int l, r;     l = r = a;     int res = 0;     while (l >= 0 || r < n) {       if (l >= 0 && r < n) {         if (t[l] > 0 && t[r] > 0) res += t[l] + t[r];       } else if (l >= 0)         res += t[l];       else         res += t[r];       --l, ++r;     }     if (t[a] > 0) res--;     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int lsone(int n) { return (n & -n); }   void mult(long long int a[25][25], long long int b[25][25],             long long int c[25][25], int m, int n, int p) {     for (int i = 1; i <= m; i++) {       for (int j = 1; j <= p; j++) {         c[i][j] = 0;         for (int k = 1; k <= n; k++) {           c[i][j] += (a[i][k] * b[k][j]) % 1000000007;           c[i][j] %= 1000000007;         }       }     }   }   void mat_pow(long long int a[25][25], long long int c[25][25], int n,                long long int p) {     if (p == 0) {       for (int i = 1; i <= n; i++) c[i][i] = 1;     } else if (p == 1) {       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) c[i][j] = a[i][j];       }     } else {       long long int d[25][25];       mat_pow(a, d, n, p / 2);       if (p % 2) {         long long int e[25][25];         mult(d, d, e, n, n, n);         mult(e, a, c, n, n, n);       } else {         mult(d, d, c, n, n, n);       }     }   }   long long int pow1(long long int a, long long int b) {     if (b == 0)       return 1ll;     else if (b == 1)       return a;     else {       long long int x = pow1(a, b / 2);       x *= x;       x %= 1000000007;       if (b % 2) {         x *= a;         x %= 1000000007;       }       return x;     }   }   int n, ans[110000];   int s(int y) {     int ans = 0;     while (y) {       y /= 10;       ans++;     }     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     ans[1] = 1;     for (int i = 2; i <= 1e5; i++) {       ans[i] = ans[i - 1] * 10;       ans[i] %= 210;     }     cin >> n;     int req = (210 - ans[n]) % 210;     if (n <= 2) {       cout << -1 <<   n ;     } else if (n == 3)       cout << 210 <<   n ;     else {       int numdig = s(req);       cout << 1;       for (int i = 0; i < n - numdig - 1; i++) cout << 0;       cout << req <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005;   char mp[N][N];   int deg[N][N];   int cnt[2], n, m;   int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};   string str =  ><v^ , tmp =  <>^v ;   bool check(int x, int y) { return x >= 1 && x <= n && y >= 1 && y <= m; }   int main() {     ios ::sync_with_stdio(0);     cin >> n >> m;     for (int i = (int)(1); i <= (int)(n); ++i) {       cin >> (mp[i] + 1);     }     for (int i = (int)(1); i <= (int)(n); ++i) {       for (int j = (int)(1); j <= (int)(m); ++j) {         if (mp[i][j] ==  . ) {           if ((i + j) & 1) {             cnt[1]++;           } else             cnt[0]++;         }       }     }     if (cnt[0] != cnt[1]) {       cout <<  Not unique  << endl;       return 0;     } else {       queue<int> q;       for (int i = (int)(1); i <= (int)(n); ++i) {         for (int j = (int)(1); j <= (int)(m); ++j) {           if (mp[i][j] ==  . ) {             for (int k = 0; k < (int)(4); ++k) {               int x = i + dx[k];               int y = j + dy[k];               if (check(x, y) && mp[x][y] ==  . ) {                 deg[i][j]++;               }             }             if (deg[i][j] == 1) {               q.push(i);               q.push(j);             }           }         }       }       while (q.size()) {         int x = q.front();         q.pop();         int y = q.front();         q.pop();         for (int k = 0; k < (int)(4); ++k) {           int tx = x + dx[k];           int ty = y + dy[k];           if (check(tx, ty) && mp[tx][ty] ==  .  && deg[tx][ty] > 0) {             mp[x][y] = tmp[k];             mp[tx][ty] = str[k];             deg[tx][ty] = 0;             deg[x][y] = 0;             for (int t = 0; t < (int)(4); ++t) {               int ax = tx + dx[t];               int ay = ty + dy[t];               if (check(ax, ay) && mp[ax][ay] ==  .  && deg[ax][ay] > 0) {                 deg[ax][ay]--;                 if (deg[ax][ay] == 1) {                   q.push(ax);                   q.push(ay);                 }               }             }             break;           }         }       }       for (int i = (int)(1); i <= (int)(n); ++i) {         for (int j = (int)(1); j <= (int)(m); ++j) {           if (deg[i][j] > 0 || mp[i][j] ==  . ) {             cout <<  Not unique  << endl;             return 0;           }         }       }       for (int i = (int)(1); i <= (int)(n); ++i) {         cout << mp[i] + 1 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void flash() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   void solve() {     long long n;     cin >> n;     vector<long long> v(n);     long long sm = 0;     long long mx = 0;     for (long long i = 0; i < n; i++) {       cin >> v[i];       sm += v[i];       mx = max(mx, v[i]);     }     function<long long(long long)> dfs = [&](long long l) -> long long {       if (l <= 0) return 0;       return dfs(l - 1);     };     long long val1 = mx;     long long val2 = sm - mx;     if (n == 1) {       cout <<  T             <<   n ;       return;     }     long long ok = dfs(n);     if (ok > 5) {       cout <<  T             <<   n ;       return;     }     ok = dfs(n - 1);     if (ok > 4) {       cout <<  HL             <<   n ;       return;     }     if (sm - n == 0) {       if (n % 2) {         cout <<  T               <<   n ;         return;       } else {         cout <<  HL               <<   n ;         return;       }     }     if (val1 > val2) {       cout <<  T             <<   n ;       return;     }     if (sm % 2 == 0) {       cout <<  HL             <<   n ;       return;     } else {       cout <<  T             <<   n ;       return;     }   }   int32_t main() {     flash();     long long t;     t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool SR(int &_x) { return scanf( %d , &_x) == 1; }   bool SR(long long &_x) { return scanf( %lld , &_x) == 1; }   bool SR(double &_x) { return scanf( %lf , &_x) == 1; }   bool SR(char *_s) { return scanf( %s , _s) == 1; }   bool RI() { return true; }   template <typename I, typename... T>   bool RI(I &_x, T &..._tail) {     return SR(_x) && RI(_tail...);   }   void SP(const int _x) { printf( %d , _x); }   void SP(const long long _x) { printf( %lld , _x); }   void SP(const double _x) { printf( %.16lf , _x); }   void SP(const char *s) { printf( %s , s); }   void PL() { puts(  ); }   template <typename I, typename... T>   void PL(const I _x, const T... _tail) {     SP(_x);     if (sizeof...(_tail)) putchar(   );     PL(_tail...);   }   const int maxn = 1e6 + 6;   char in[maxn];   void read() { RI(in); }   deque<char> q;   void build() {     q = deque<char>(in, in + strlen(in));     while (((int)(q).size()) && q[0] ==  F ) q.pop_front();   }   void sol() {     int prv = 0, cur = 0, cnt = 0;     for (int i = 0; i < int(((int)(q).size())); i++)       if (q[i] ==  F ) {         swap(prv, cur);         cur = max(prv + 1, i - (cnt++));       }     PL(cur);   }   int main() {     read();     build();     sol();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int n, a[100005], sta[100005];   vector<int> V;   int calc(int k) {     while (k) {       int d = k % 10;       k /= 10;       if (d != 4 && d != 7) return 0;     }     return 1;   }   using pii = pair<int, int>;   int tar[100005], to[100005];   vector<pii> Ans;   void Swap(int first, int second) {     if (first == second) return;     to[tar[first]] = second, to[tar[second]] = first;     swap(tar[second], tar[first]);     Ans.push_back(pii(first, second));     return;   }   int main() {     V.resize(1100800);     for (auto first : V) first = rand();     scanf( %d , &n);     int g = 0, pos = -1;     vector<pii> vec;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       sta[i] = calc(a[i]);       g += sta[i];       if (sta[i]) pos = i;       vec.push_back(pii(a[i], i));     }     sort(vec.begin(), vec.end());     for (int i = 0; i < vec.size(); i++) {       tar[vec[i].second] = i + 1;       to[i + 1] = vec[i].second;     }     if (g == 0) {       bool flag = 0;       for (int i = 1; i < n; i++)         if (a[i] > a[i + 1]) flag = 1;       if (flag)         puts( -1 );       else         puts( 0 );     } else {       assert(pos > 0);       for (int i = 1; i <= n; i++) {         Swap(pos, i);         pos = i;         int prv = to[i];         Swap(pos, to[i]);         pos = prv;       }       int sz = Ans.size();       printf( %d n , sz);       for (auto first : Ans) {         printf( %d %d n , first.first, first.second);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int lb, rb, l_max, r_max, s_max;   };   int n, m, l, r, k, offset = 1 << 19, a[300004], z, t;   long long d[600004];   node trn[1100000];   int sgn(long long x) {     if (x > 0) return 1;     if (x < 0) return -1;     return 0;   }   void update(int pos) {     if (pos < 0) return;     if (d[pos + 1] == 0) {       trn[pos + offset].l_max = 0;       trn[pos + offset].r_max = 0;       trn[pos + offset].s_max = 0;     } else {       trn[pos + offset].l_max = 1;       trn[pos + offset].r_max = 1;       trn[pos + offset].s_max = 1;     }     pos = (pos + offset) >> 1;     while (pos > 0) {       z = 2 * pos;       trn[pos].s_max = max(trn[z].s_max, trn[z + 1].s_max);       trn[pos].l_max = trn[z].l_max;       trn[pos].r_max = trn[z + 1].r_max;       if (sgn(d[trn[z].rb]) >= sgn(d[trn[z + 1].lb])) {         int len = trn[z].r_max + trn[z + 1].l_max;         trn[pos].s_max = max(len, trn[pos].s_max);         if (trn[z].l_max == trn[z].rb - trn[z].lb + 1)           trn[pos].l_max += trn[z + 1].l_max;         if (trn[z + 1].r_max == trn[z + 1].rb - trn[z + 1].lb + 1)           trn[pos].r_max += trn[z].r_max;       }       pos = pos >> 1;     }   }   int readInt() {     bool mnus = false;     int result = 0;     char ch;     ch = getchar();     while (true) {       if (ch ==  - ) break;       if (ch >=  0  && ch <=  9 ) break;       ch = getchar();     }     if (ch ==  - )       mnus = true;     else       result = ch -  0 ;     while (true) {       ch = getchar();       if (ch <  0  || ch >  9 ) break;       result = result * 10 + (ch -  0 );     }     if (mnus)       return -result;     else       return result;   }   int main() {     std::ios::sync_with_stdio(false);     n = readInt();     for (int i = 1; i <= n; ++i) a[i] = readInt();     for (int i = 1; i < n; ++i) d[i] = a[i + 1] - a[i];     for (int i = 0; i < offset; ++i) {       trn[i + offset].lb = i + 1;       trn[i + offset].rb = i + 1;       if (d[i + 1] == 0) {         trn[i + offset].l_max = 0;         trn[i + offset].r_max = 0;         trn[i + offset].s_max = 0;       } else {         trn[i + offset].l_max = 1;         trn[i + offset].r_max = 1;         trn[i + offset].s_max = 1;       }     }     for (int i = offset - 1; i >= 1; --i) {       t = 2 * i;       trn[i].lb = trn[t].lb;       trn[i].rb = trn[t + 1].rb;       trn[i].s_max = max(trn[t].s_max, trn[t + 1].s_max);       trn[i].l_max = trn[t].l_max;       trn[i].r_max = trn[t + 1].r_max;       if (sgn(d[trn[t].rb]) >= sgn(d[trn[t + 1].lb])) {         int len = trn[t].r_max + trn[t + 1].l_max;         trn[i].s_max = max(len, trn[i].s_max);         if (trn[t].l_max == trn[t].rb - trn[t].lb + 1)           trn[i].l_max += trn[t + 1].l_max;         if (trn[t + 1].r_max == trn[t + 1].rb - trn[t + 1].lb + 1)           trn[i].r_max += trn[t].r_max;       }     }     m = readInt();     for (int i = 0; i < m; ++i) {       l = readInt();       r = readInt();       k = readInt();       d[l - 1] += k;       d[r] -= k;       d[0] = 0;       d[n] = 0;       update(l - 2);       update(r - 1);       cout << trn[1].s_max + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x7fffffff;   const double eps = 1e-10;   const double pi = acos(-1.0);   inline int read() {     int x = 0, f = 1;     char ch;     ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   const int N = 2e5 + 10;   int n, a, b, k;   string s;   int mark[N];   int tot, ans[N];   int main() {     n = read();     a = read();     b = read();     k = read();     cin >> s;     for (int i = 1; i <= n; i++) mark[i] = (s[i - 1] -  0 );     int cnt = 0;     for (int i = 1; i <= n; ++i)       if (mark[i])         cnt = 0;       else {         if (++cnt == b) {           ans[++tot] = i;           cnt = 0;         }       }     tot -= a - 1;     printf( %d n , tot);     for (int i = 1; i <= tot; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   const long long int mrx = 1e6 + 5, M = 1e9 + 7;   long long int mx = INT_MIN, mn = INT_MAX;   using namespace std;   long long int x1, x2, s, t1, t2, p, d;   long long int poezd, igor;   int main() {     ios_base::sync_with_stdio(NULL);     cin.tie(NULL);     cin >> s >> x1 >> x2;     cin >> t1 >> t2;     cin >> p >> d;     if (t2 <= t1) {       cout << abs(x1 - x2) * t2;       return 0;     } else {       if (d == 1) {         if (x1 < x2) {           if (p == x1) {             cout << (x2 - x1) * t1;           } else if (p < x1) {             cout << min((x2 - x1) * t2, (x2 - p) * t1);           } else {             cout << min((x2 - x1) * t2, (s - p) * t1 + s * t1 + x2 * t1);           }         } else {           cout << min((x1 - x2) * t2, (s - p) * t1 + (s - x2) * t1);         }       }       if (d == -1) {         if (x1 < x2) {           cout << min((x2 - x1) * t2, p * t1 + x2 * t1);         } else {           if (p == x1) {             cout << (x1 - x2) * t1;           } else if (p < x1) {             cout << min((x1 - x2) * t2, p * t1 + s * t1 + (s - x2) * t1);           } else {             cout << min((x1 - x2) * t2, (p - x2) * t1);           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     int sl = 0;     for (int i = 1; i <= n; ++i) {       int x, y;       cin >> x >> y;       if (x > 0) ++sl;     }     if (sl == n || sl == 0 || sl == n - 1 || sl == 1) {       cout <<  Yes ;       return 0;     }     cout <<  No ;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void printQueue(T& q) {     while (!q.empty()) {       cout << q.top() << endl;       q.pop();     }   }   vector<int> adj[200009];   vector<pair<int, int> > levels;   bool visited[200009];   bool cmp(pair<int, int> a, pair<int, int> b) {     if (a.first == b.first) {       return a.second < b.second;     } else {       return a.first > b.first;     }   }   void dfs(int s, int level) {     visited[s] = true;     levels.push_back(make_pair(level, s));     for (int i = 0; i < adj[s].size(); i++) {       if (visited[adj[s][i]] == false) {         dfs(adj[s][i], level + 1);       }     }   }   int main() {     int t = 1;     while (t--) {       int n, x;       cin >> n;       long long dp[n + 1][2];       memset(dp, 0, sizeof(dp));       for (int i = 1; i < n; i++) {         cin >> x;         adj[x].push_back(i);         adj[i].push_back(x);       }       dfs(1, 1);       for (int j = 0; j < n; j++) {         cin >> x;         if (x == 1) {           dp[j][0] = 1;           dp[j][1] = 0;         } else {           dp[j][0] = 0;           dp[j][1] = 1;         }       }       sort(levels.begin(), levels.end(), cmp);       bool visit[n + 1];       memset(visit, false, sizeof(visit));       int index;       for (int i = 0; i < levels.size(); i++) {         visit[levels[i].second] = true;         index = levels[i].second;         for (int j = 0; j < adj[index].size(); j++) {           if (visit[adj[index][j]] == false) {             dp[adj[index][j]][0] =                 ((dp[index][0] * dp[adj[index][j]][0]) % 1000000007ll) +                 ((dp[index][0] * dp[adj[index][j]][1]) % 1000000007ll) +                 ((dp[index][1] * dp[adj[index][j]][0]) % 1000000007ll);             dp[adj[index][j]][0] %= 1000000007ll;             dp[adj[index][j]][1] =                 ((dp[index][0] * dp[adj[index][j]][1]) % 1000000007ll) +                 ((dp[index][1] * dp[adj[index][j]][1]) % 1000000007ll);             dp[adj[index][j]][1] %= 1000000007ll;           }         }       }       cout << dp[1][0] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   void compute() {     long long n;     cin >> n;     n -= 2;     string s[n];     cin >> s[0];     string ans = s[0];     for (long long i = 1; i < n; i++) {       cin >> s[i];       if (s[i][0] == ans[ans.size() - 1])         ans.push_back(s[i][1]);       else         ans += s[i];     }     if (ans.size() != n + 2) ans.push_back( a );     cout << ans << endl;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       compute();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> ans;   int m;   int main() {     int n, ans = 0;     string s;     cin >> n;     cin >> s;     for (int i = 0; i < n; i++)       if (s[i] ==  < )         ans++;       else         break;     for (int i = n - 1; i >= 0; i--)       if (s[i] ==  > )         ans++;       else         break;     cout << ans;     return 0;   }