malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int c1, c2, c3, c4;     int n, m, x;     int b = 0, t = 0, tot = 0;     scanf( %d %d %d %d , &c1, &c2, &c3, &c4);     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &x);       if (x * c1 > c2)         b += c2;       else         b += x * c1;     }     if (b > c3) b = c3;     for (int i = 1; i <= m; i++) {       scanf( %d , &x);       if (x * c1 > c2)         t += c2;       else         t += x * c1;     }     if (t > c3) t = c3;     tot = b + t;     if (tot > c4) tot = c4;     printf( %d n , tot);   }
#include <bits/stdc++.h>   using namespace std;   int q[111], qr[111], s[111];   int d[222][111];   int dp[111][222];   bool ss[222];   int n, k;   bool rec(int kk, int i) {     if (dp[kk][k + i] != -1) return dp[kk][k + i];     if (kk == 0) return ss[k + i];     bool r;     if (ss[k + i])       r = false;     else {       r = rec(kk - 1, i - 1) || rec(kk - 1, i + 1);     }     return dp[kk][k + i] = r;   }   int main() {     cin >> n >> k;     for (int(i) = 0; (i) < (int)(n); ++(i)) cin >> q[i], q[i]--;     for (int(i) = 0; (i) < (int)(n); ++(i)) cin >> s[i], s[i]--;     for (int(i) = 0; (i) < (int)(n); ++(i)) qr[q[i]] = i;     for (int(i) = 0; (i) < (int)(n); ++(i)) d[k + 0][i] = i;     for (int(i) = (int)(1); (i) <= (int)(k); ++(i))       for (int(j) = 0; (j) < (int)(n); ++(j)) d[k + i][j] = d[k + i - 1][q[j]];     for (int(i) = (int)(1); (i) <= (int)(k); ++(i))       for (int(j) = 0; (j) < (int)(n); ++(j)) d[k - i][j] = d[k + -i + 1][qr[j]];     for (int(i) = (int)(-k); (i) <= (int)(k); ++(i)) {       ss[k + i] = vector<int>(d[k + i], d[k + i] + n) == vector<int>(s, s + n);     }     memset(dp, -1, sizeof(dp));     bool r = rec(k, 0);     cout << (r ?  YES  :  NO ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, a, b;   int main() {     scanf( %I64d%I64d%I64d , &t, &a, &b);     if (t > a && a != b || b < a)       printf( 0 n );     else if (t == 1) {       if (a == b) {         if (a == 1)           printf( inf n );         else           printf( 1 n );       } else if (a == 1)         printf( 0 n );       else {         long long temp = b;         while (temp % a == 0) temp /= a;         if (temp == 1) {           printf( 1 n );           return 0;         }         int pt = 0;         int cur = 1;         while (b > 0) {           long long digit = b % a;           pt += cur * digit;           b /= a;           cur *= t;         }         if (pt == a)           printf( 1 n );         else           printf( 0 n );       }     } else {       if (a == b) {         if (t == a)           printf( 2 n );         else           printf( 1 n );       } else {         long long pt = 0;         long long cur = 1;         while (b > 0) {           long long digit = b % a;           pt += cur * digit;           b /= a;           cur *= t;         }         if (pt == a)           printf( 1 n );         else           printf( 0 n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007LL;   long long large = 2000000000000000000LL;   vector<int> dp;   vector<vector<int> > adj;   int f(int u) {     if (dp[u] != -1) return dp[u];     vector<int> ch;     for (int j = 0; j < (int)adj[u].size(); j++) {       int v = adj[u][j];       ch.push_back(f(v));     }     sort(ch.begin(), ch.end());     int re = 0;     for (int i = 0; i < (int)ch.size(); i++) {       if (ch[i] == re)         re++;       else if (ch[i] > re)         break;     }     dp[u] = re;     return dp[u];   }   int main() {     int n, m;     cin >> n >> m;     vector<int> h(n, 0);     for (int i = 0; i < n; i++) scanf( %d , &h[i]);     adj.assign(n, vector<int>());     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d%d , &x, &y);       x--;       y--;       adj[x].push_back(y);     }     dp.assign(n, -1);     int ans = 0;     int sz = 0;     for (int i = 0; i < n; i++) sz = max(sz, f(i) + 1);     vector<int> tp(sz, 0);     for (int i = 0; i < n; i++) tp[f(i)] ^= h[i];     for (int i = 0; i < sz; i++) ans |= tp[i];     if (ans == 0) {       cout <<  LOSE  << endl;       return 0;     }     int p = -1;     for (int i = 0; i < sz; i++) {       if (tp[i]) p = i;     }     for (int i = 0; i < n; i++)       if (f(i) == p && (h[i] ^ tp[p]) < h[i]) {         h[i] ^= tp[p];         tp[p] = 0;         for (int j = 0; j < (int)adj[i].size(); j++) {           int v = adj[i][j];           h[v] ^= tp[f(v)];           tp[f(v)] = 0;         }         break;       }     cout <<  WIN  << endl;     for (int i = 0; i < n; i++) cout << h[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const double PI = acos(-1);   long long mod = 1e9 + 7;   struct segment {     long long l, r;     bool operator<(const segment& s) const {       if (r != s.r) return r > s.r;       return l < s.l;     }   };   const long long MAXN = 2e5 + 7;   vector<segment> vs(MAXN);   vector<long long> sum(MAXN, 0), sub(MAXN, 0), ans(MAXN, 0);   vector<vector<long long>> vv(MAXN);   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, k, l, r;     cin >> n >> k;     long long m = 1;     for (long long i = 0; i < n; i++) {       cin >> vs[i].l >> vs[i].r;       m = max(m, vs[i].r);       sum[vs[i].l]++;       sum[vs[i].r + 1]--;       vv[vs[i].l].push_back(i + 1);       vv[vs[i].r + 1].push_back(-i - 1);     }     for (long long i = 1; i <= m; i++) sum[i] += sum[i - 1];     set<pair<segment, long long>> s;     long long cntSub = 0;     long long cnt = 0;     for (long long i = 1; i <= m; i++) {       for (long long& idx : vv[i]) {         if (idx > 0) {           s.insert({vs[idx - 1], idx});         } else {           idx *= -1;           s.erase({vs[idx - 1], idx});         }       }       cntSub += sub[i];       while (sum[i] - cntSub > k) {         auto it = *s.begin();         cntSub++;         s.erase(it);         sub[it.first.r + 1]--;         ans[it.second] = 1;         cnt++;       }     }     cout << cnt <<   n ;     for (long long i = 1; i <= n; i++)       if (ans[i]) cout << i <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cum[200000];   int main() {     int n, x, k;     cin >> n >> x >> k;     int arr[n + 10];     set<int> st;     map<int, int> pos;     int now = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &arr[i]);       st.insert(arr[i]);     }     for (set<int>::iterator it = st.begin(); it != st.end(); it++) {       pos[*it] = ++now;     }     for (int i = 1; i <= n; i++) {       cum[pos[arr[i]]]++;     }     for (int i = 1; i <= now; i++) {       cum[i] += cum[i - 1];     }     long long res = 0;     for (int i = 1; i <= n; i++) {       long long pres = arr[i];       long long first, lst;       if (k > 0) {         pres = arr[i];         if (arr[i] % x != 0) pres = pres + (x - (arr[i] % x));         pres += (k - 1) * 1LL * x;         first = pres;         lst = pres + x - 1;       } else {         pres = arr[i];         if (arr[i] % x != 0) pres = pres + (x - (arr[i] % x));         first = arr[i];         lst = pres - 1;       }       if (*st.rbegin() < lst)         lst = *st.rbegin();       else {         if (st.find(lst) == st.end()) {           set<int>::iterator it = (st.upper_bound(lst));           it--;           lst = *it;         }       }       if (*st.rbegin() < first)         first = lst + 10;       else {         if (st.find(first) == st.end()) {           set<int>::iterator it = (st.upper_bound(first));           first = *it;         }       }       if (lst >= first) {         res += (cum[pos[lst]] - cum[pos[first] - 1]);       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, mn = 1000000009, mx;   char c[59][59];   int ist, ien;   bool w;   int main() {     cin >> a >> b;     for (int i = 1; i <= a; i++)       for (int j = 1; j <= b; j++) {         cin >> c[i][j];         if (c[i][j] ==  * )           mn = min(j, mn), mx = max(j, mx), (w == 0 ? ist = i : ist = ist),           ien = i, w = 1;       }     for (int i = ist; i <= ien; i++) {       for (int j = mn; j <= mx; j++) cout << c[i][j];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int q;     cin >> q;     while (q--) {       long long int b, w;       cin >> b >> w;       if (b >= w) {         if (b > 3 * w + 1) {           std::cout <<  NO  << std::endl;           continue;         } else {           std::cout <<  YES  << std::endl;           for (long long int i = 0; i < 2 * w; i += 2) {             std::cout << 2 <<     << i + 2 << std::endl;           }           for (long long int i = 0; i < 2 * b && i < 2 * w; i += 2) {             std::cout << 2 <<     << i + 3 << std::endl;           }           b = b - w;           if (b > 0) {             std::cout << 2 <<     << 1 << std::endl;           }           b--;           long long int i = 0;           while (b > 0) {             std::cout << 1 <<     << i + 2 << std::endl;             b--;             if (b > 0) std::cout << 3 <<     << i + 2 << std::endl;             b--;             i += 2;           }         }       } else {         if (w > 3 * b + 1) {           std::cout <<  NO  << std::endl;           continue;         } else {           std::cout <<  YES  << std::endl;           for (long long int i = 0; i < 2 * b; i += 2) {             std::cout << 2 <<     << i + 3 << std::endl;           }           for (long long int i = 0; i < 2 * w && i < 2 * b; i += 2) {             std::cout << 2 <<     << i + 4 << std::endl;           }           w = w - b;           if (w > 0) std::cout << 2 <<     << 2 << std::endl;           w--;           long long int i = 0;           while (w > 0) {             std::cout << 1 <<     << i + 3 << std::endl;             w--;             if (w > 0) std::cout << 3 <<     << i + 3 << std::endl;             w--;             i += 2;           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[100010];   int s[100010];   int solve() {     int ret = 0, top = 0;     for (int i = 0; i < n; i++) {       while (top && a[s[top]] < a[i]) --top;       if (top) ret = max(ret, a[s[top]] ^ a[i]);       s[++top] = i;     }     return ret;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     reverse(a, a + n);     int ans = solve();     reverse(a, a + n);     ans = max(ans, solve());     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long pw(long long a, long long b, long long p) {     if (b == 0) return 1;     long long t = pw(a, b / 2, p);     if (b % 2)       return ((a * t * t) % p);     else       return ((t * t) % p);   }   long long cost[100005], vis[100005], ini[100005], lb[100005];   long long abmc = 0, abtw = 1;   vector<long long> v[100005];   pair<long long, pair<long long, long long> > dfs(long long z, long long iniz,                                                    long long lev) {     if (vis[z]) {       if (ini[z] != iniz) return {-1, {-1, 1}};       return {lb[z], {-1, 1}};     }     vis[z] = 1;     lb[z] = lev;     ini[z] = iniz;     long long cmi = -1, mc = -1, tw = 1;     for (long long k : v[z]) {       pair<long long, pair<long long, long long> > t = dfs(k, iniz, lev + 1);       if (t.first == -1) continue;       if (cmi == -1 || t.first < cmi) cmi = t.first;       if (t.second.first == -1) continue;       if (mc == -1 || t.second.first < mc) {         mc = t.second.first;         tw = t.second.second;       } else if (mc == t.second.first)         tw += t.second.second;     }     lb[z] = cmi;     if (cmi == -1) {       abmc += cost[z];     } else if (cmi <= lev) {       if (cost[z] < mc || mc == -1) {         mc = cost[z];         tw = 1;       } else if (cost[z] == mc)         tw++;     }     if (cmi == lev) {       cmi = -1;       abmc += mc;       abtw = (abtw * tw) % 1000000007;       mc = -1;       tw = 1;     }     return {cmi, {mc, tw}};   }   void solve() {     long long n;     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> cost[i];     }     long long m;     cin >> m;     for (long long i = 0; i < m; i++) {       long long a, b;       cin >> a >> b;       v[a].push_back(b);     }     for (long long i = 1; i <= n; i++) {       if (!vis[i]) dfs(i, i, 0);     }     cout << abmc <<     << abtw;   }   signed main() {     ios_base::sync_with_stdio(false);     long long t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = int(1e9) + 7;   const int MX = 200500;   long long f[MX];   long long f1[MX];   int pow_mod(long long a, int st) {     a %= mod;     long long res = 1;     while (st) {       if (st & 1) {         res *= a;         res %= mod;       }       a *= a;       a %= mod;       st >>= 1;     }     return res;   }   void init() {     f[0] = 1;     for (int i = 1; i < MX; i++) {       f[i] = f[i - 1] * i;       f[i] %= mod;     }     f1[MX - 1] = pow_mod(f[MX - 1], mod - 2);     for (int i = MX - 2; i >= 0; i--) {       f1[i] = f1[i + 1] * (i + 1);       f1[i] %= mod;     }   }   int c(int n, int k) {     long long res = f[n] * f1[k];     res %= mod;     res *= f1[n - k];     return res % mod;   }   int go1(int, int);   int go0(int c0, int c1) {     if (c0 < 0 || c1 < 0) return 0;     if (c0 == 1 && c1 == 0) return 1;     if (c0 == 0 && c1 == 1) return 0;     int ans = 0;     if (c1) ans = c(c0 + c1 - 1, c0);     if (c0) ans += go1(c0 - 1, c1);     return ans % mod;   }   int go1(int c0, int c1) {     if (c0 == 0 && c1 == 1) return 1;     return go0(c0 - 1, c1);   }   int main() {     init();     ios_base::sync_with_stdio(false);     int n, m, g;     cin >> n >> m >> g;     if (g)       cout << go1(n, m) << endl;     else       cout << go0(n, m) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[1 << 25];   int n, m;   int a[30][30];   int qi[30][30];   int st[30][30];   char c[30][30];   int lowbit(int x) { return (x & (-x)); }   int main() {     scanf( %d , &n);     scanf( %d , &m);     for (int i = 1; i <= n; i++) scanf( %s , c[i] + 1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %d , &a[i][j]);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         int it = -2e9, sum = 0;         for (int k = 1; k <= n; k++) {           if (c[k][j] == c[i][j]) {             st[i][j] |= (1 << (k - 1));             sum += a[k][j];             it = max(it, a[k][j]);           }         }         sum -= it;         qi[i][j] = sum;       }     }     memset(dp, 127, sizeof(dp));     dp[0] = 0;     for (int i = 0; i <= (1 << n) - 1; i++) {       for (int k = 0; k < n; k++)         if (!((1 << k) & i))           for (int j = 1; j <= m; j++) {             dp[i | (1 << k)] = min(dp[i | (1 << k)], dp[i] + a[k + 1][j]);             dp[i | st[k + 1][j]] =                 min(dp[i] + qi[k + 1][j], dp[i | st[k + 1][j]]);           }     }     cout << dp[(1 << n) - 1] << endl;   }
#include <bits/stdc++.h>   long long n, i, j, h, k, t, d, m, a, b, c;   using namespace std;   char s;   string ss;   int main() {     cin >> t;     for (h = 1; h <= t; h++) {       cin >> n;       ss =  . ;       while (n > ss.length()) ss = ss +  . ;       cin >> a >> b >> c;       d = 0;       for (i = 0; i < n; i++) {         cin >> s;         if (s ==  R  && b > 0) {           b--;           d++;           ss[i] =  P ;         }         if (s ==  P  && c > 0) {           c--;           d++;           ss[i] =  S ;         }         if (s ==  S  && a > 0) {           a--;           d++;           ss[i] =  R ;         }       }       if (d >= (n + 1) / 2) {         i = 0;         while (a > 0) {           if (ss[i] ==  . ) ss[i] =  R , a--;           i++;         }         while (b > 0) {           if (ss[i] ==  . ) ss[i] =  P , b--;           i++;         }         while (c > 0) {           if (ss[i] ==  . ) ss[i] =  S , c--;           i++;         }         cout <<  YES  << endl;         for (i = 0; i < n; i++) cout << ss[i];         cout << endl;       } else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s;     cin >> s;     queue<int> v1;     deque<int> v2;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  ( )         v1.push(i);       else {         v2.push_front(i);       }     }     int k = 0;     vector<int> res;     while (!v1.empty() && !v2.empty()) {       if (v1.front() > v2.front()) {         v1.pop();         v2.pop_front();         continue;       }       k += 2;       res.push_back(v2.front());       res.push_back(v1.front());       v1.pop();       v2.pop_front();     }     sort(res.begin(), res.end());     if (k == 0) return cout << 0, 0;     cout << 1 <<   n ;     cout << k <<   n ;     for (auto i : res) cout << i + 1 <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 5;   long long a[maxn];   int main() {     int n;     scanf( %d , &n);     priority_queue<long long, vector<long long>, greater<long long>> que;     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       que.push(a[i]);     }     if (n == 1) {       cout << 0 << endl;     } else {       if (n % 2 == 0) que.push(0);       long long ans = 0;       long long sum = 0;       while (que.size() > 2) {         sum = que.top();         que.pop();         sum += que.top();         que.pop();         sum += que.top();         que.pop();         ans += sum;         que.push(sum);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[3], b[3];     for (int i = 0; i < 3; i++) cin >> a[i] >> b[i];     bool flag = false;     for (int i = 0; i < 2; i++) {       for (int j = 0; j < 2; j++) {         for (int p = 0; p < 2; p++) {           if (max(a[1], a[2]) <= a[0] && b[1] + b[2] <= b[0]) flag = true;           swap(a[0], b[0]);         }         swap(a[2], b[2]);       }       swap(a[1], b[1]);     }     if (flag)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, K;   void rip() {     puts( -1 );     exit(0);   }   int main() {     scanf( %d %d , &N, &K);     if (K == 1) {       rip();     } else if (K == 2) {       if (N <= 4)         rip();       else {         printf( %d n , N - 1);         for (int i = (1); i < (N); i++) printf( %d %d n , i, i + 1);       }     } else if (K == 3) {       if (N <= 3)         rip();       else {         printf( %d n , N - 1);         printf( 1 2 n2 3 n );         for (int i = (4); i < (N + 1); i++) printf( %d %d n , 3, i);       }     } else       rip();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k, l, i = 0, mod = 0;     cin >> k;     cin >> l;     while (l > 1) {       mod += l % k;       l = l / k;       i++;     }     if (mod > 0)       cout <<  NO ;     else       cout <<  YES  << endl << i - 1;     return 0;   }
#include <bits/stdc++.h>   using std::abs;   using std::bitset;   using std::cerr;   using std::cin;   using std::cout;   using std::deque;   using std::map;   using std::max;   using std::min;   using std::pair;   using std::queue;   using std::set;   using std::sort;   using std::string;   using std::swap;   using std::unordered_map;   using std::unordered_set;   using std::vector;   void init() {     std::iostream::sync_with_stdio(0);     cout << std::fixed;     cout.precision(10);     cerr << std::fixed;     cerr.precision(10);     srand(time(0));   }   const int MAXN = 1e6 + 1;   long long arr[MAXN];   long long dp[MAXN][3];   int n;   long long a, b;   const long long INF = 1e18;   vector<int> fact(int x) {     vector<int> res;     int k = x;     for (int i = 2; i * i <= k; ++i)       if (!(x % i)) {         x /= i;         res.push_back(i);       }     if (x > 1) res.push_back(x);     return res;   }   long long solve(int p) {     for (int i = 0; i <= n; ++i)       for (int j = 0; j < 3; ++j) dp[i][j] = INF;     for (int i = 0; i < 3; ++i) dp[0][i] = 0;     for (int i = 1; i <= n; ++i) {       dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + a;       if (arr[i] % p == 0) {         dp[i][0] = dp[i - 1][0];         dp[i][2] = min(dp[i - 1][2], dp[i - 1][1]);       } else if ((arr[i] + 1) % p == 0 || (arr[i] - 1) % p == 0) {         dp[i][0] = dp[i - 1][0] + b;         dp[i][2] = min(dp[i - 1][2], dp[i - 1][1]) + b;       }     }     long long ans = INF;     for (int i = 0; i < 3; ++i) ans = min(ans, dp[n][i]);     return ans;   }   int main() {     init();     cin >> n >> a >> b;     for (int i = 1; i <= n; ++i) cin >> arr[i];     set<int> ma;     for (int i = -1; i <= 1; ++i) {       vector<int> tmp;       tmp = fact(arr[1] + i);       for (auto j : tmp) ma.insert(j);       tmp = fact(arr[n] + i);       for (auto j : tmp) ma.insert(j);     }     long long ans = INF;     for (auto i : ma) ans = min(ans, solve(i));     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void imprimirVector(vector<long long> v) {     if (!v.empty()) {       int p = v.size();       cout <<  [ ;       for (int i = 0; i < (int)(p - 1); i++) cout << v[i] <<  , ;       cout << v[p - 1] <<  ]  << endl;     } else       cout <<  []  << endl;   }   long long toNumber(string s) {     long long Number;     if (!(istringstream(s) >> Number)) Number = 0;     return Number;   }   string toString(long long number) {     ostringstream ostr;     ostr << number;     return ostr.str();   }   int main() {     ios_base::sync_with_stdio(0);     unsigned long long n;     cin >> n;     cout << (n * (n - 1) * (n - 2) * (n - 3) * (n - 4) / 120) * n * (n - 1) *                 (n - 2) * (n - 3) * (n - 4)          << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, long long> mp;   int main() {     int n;     cin >> n;     mp.clear();     for (int i = 1; i <= n; ++i) {       string tmp;       cin >> tmp;       mp[tmp]++;     }     cout << (mp[ UL ] + mp[ DR ] + mp[ ULDR ] + 1) *                 (mp[ UR ] + mp[ DL ] + mp[ ULDR ] + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isprime(int n) {     if (n == 1) return false;     if (n == 2) return true;     for (int i = 2; i <= sqrt(n); i++) {       if (n % i == 0) {         return false;       }     }     return true;   }   void answer(int f) {     if (f) {       cout <<  YES ;     } else {       cout <<  NO ;     }     cout << endl;   }   long long int countSetBits(long long int n) {     long long int count = 0;     while (n) {       count += 1;       n = n / 10;     }     return count;   }   long long int factorial(long long int n) {     n = n % 1000000007;     return (n == 1 || n == 0 || n < 0) ? 1 : n * factorial(n - 1);   }   long long int ncp(long long int n, long long int p) {     long long int a = factorial(n);     long long int b = factorial(p);     long long int c = factorial(n - p);     return (a / (b * c));   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     int t = 1;     while (t--) {       long long int n, m;       cin >> n;       long long int i, c[n];       vector<long long int> a, b;       long long int sum1 = 0, sum2 = 0;       for (i = 0; i < n; i++) {         cin >> c[i];         if (c[i] > 0) {           sum1 += c[i];           a.push_back(c[i]);         } else {           long long int df = abs(c[i]);           sum2 += df;           b.push_back(df);         }       }       if (sum1 > sum2) {         cout <<  first ;         return 0;       } else if (sum1 < sum2) {         cout <<  second ;         return 0;       }       i = 0;       int x = min(a.size(), b.size());       while (i < x) {         if (a[i] < b[i]) {           cout <<  second ;           return 0;         } else if (a[i] > b[i]) {           cout <<  first ;           return 0;         }         i++;       }       if (c[n - 1] < 0)         cout <<  second ;       else         cout <<  first ;     }     return 0;   }