malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int mod = 1051131;   const int Inv2 = (mod + 1) >> 1;   inline void setIO(string a) {}   long long Power;   int m, s, n, nn;   int a[(1 << 25) + 23];   void work(int n, int p, int q) {     if (n == 1) {       int &An = a[1];       (p += q) %= mod;       for (long long c = Power; c; c >>= 1, p = 1ll * p * p % mod)         if (c & 1) An = 1ll * An * p % mod;       return;     }     int t = n >> 1, tt = 1ll * t * p % mod;     int ttp = (p + q + mod - tt) % mod, tttp = 1;     for (long long c = Power; c; c >>= 1, ttp = 1ll * ttp * ttp % mod)       if (c & 1) tttp = 1ll * tttp * ttp % mod;     int xi = (1ll * t * p % mod - p + q + mod) % mod;     for (int i = (1); i <= (t); i++) {       int A = a[i], B = a[i + t];       a[i] = (A + B) % mod;       a[i + t] = (A + mod - B) % mod;       a[i + t] = 1ll * a[i + t] * tttp % mod;     }     work(n >> 1, (p + p) % mod, xi);     for (int i = (1); i <= (t); i++) {       int A = a[i], B = a[i + t];       a[i] = (A + B) % mod;       a[i + t] = (A + mod - B) % mod;       a[i] = 1ll * a[i] * Inv2 % mod;       a[i + t] = 1ll * a[i + t] * Inv2 % mod;     }   }   int main() {     scanf( %d , &m);     cin >> Power;     scanf( %d , &s);     for (int i = (1); i <= (s); i++) scanf( %d , &a[i]);     n = 1 << m;     nn = n;     for (int i = (s + 1); i <= (n); i++)       a[i] = (101ll * a[i - s] + 10007) % 1051131;     work(n, 1, 0);     int ans = 0;     for (int i = (1); i <= (n); i++) ans ^= a[i];     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, arr[30010], book[30010];   bool judge() {     int ps, gap;     int t1 = 1, t2;     while (t1 <= n && book[t1]) t1++;     t2 = t1 + 1;     if (t1 > n) return false;     while (t2 <= n && book[t2]) t2++;     if (t2 > n) return true;     gap = arr[t2] - arr[t1];     ps = t2;     for (int i = t2 + 1; i <= n; i++)       if (!book[i]) {         if (arr[i] - arr[ps] == gap)           ps = i;         else           return false;       }     return true;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &arr[i]);     if (n == 2)       printf( %d n%d , arr[1], arr[2]);     else {       int x[3] = {arr[2] - arr[1], arr[3] - arr[2], arr[3] - arr[1]};       int flag = 0;       for (int i = 0; i < 3; i++) {         int st = 4, tmp = arr[3];         memset(book, 0, sizeof(book));         if (i == 0) {           book[2] = book[1] = 1;           st = 3;           tmp = arr[2];         } else if (i == 1)           book[2] = book[3] = 1;         else           book[1] = book[3] = 1;         for (int ii = st; ii <= n; ii++)           if (arr[ii] == tmp + x[i]) {             book[ii] = 1;             tmp = arr[ii];           }         if (judge()) {           flag = 1;           break;         } else {           int p = n;           while (!book[p]) p--;           book[p] = 0;           if (judge()) {             flag = 1;             break;           }         }       }       if (flag) {         for (int i = 1; i <= n; i++)           if (book[i]) printf( %d  , arr[i]);         printf(  n );         for (int i = 1; i <= n; i++)           if (!book[i]) printf( %d  , arr[i]);       } else         printf( No solution );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ekub(int a, int b) { return b == 0 ? a : ekub(b, a % b); }   long long s[51][51];   int main() {     long long i, j, n, m, a, b, ans = 1e9;     cin >> n >> m;     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) {         cin >> s[i][j];         s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];       }     cin >> a >> b;     for (i = a; i <= n; i++)       for (j = b; j <= m; j++)         ans = min(ans, s[i][j] - s[i - a][j] - s[i][j - b] + s[i - a][j - b]);     for (i = b; i <= n; i++)       for (j = a; j <= m; j++)         ans = min(ans, s[i][j] - s[i - b][j] - s[i][j - a] + s[i - b][j - a]);     cout << ans;   }
#include <bits/stdc++.h>   namespace P_TEMPLATE {   class fastin {    private:     int _ch, _f;       public:     inline fastin& operator>>(char& c) {       c = getchar();       return *this;     }     template <typename _Tp>     inline fastin& operator>>(_Tp& _x) {       _x = 0;       while (!isdigit(_ch)) _f |= (_ch == 45), _ch = getchar();       while (isdigit(_ch))         _x = (_x << 1) + (_x << 3) + (_ch ^ 48), _ch = getchar();       _f && (_x = -_x, _f = 0);       return *this;     }     fastin() { _ch = _f = 0; }   } fin;   class fastout {    private:     int _num[32], _head;       public:     inline fastout& operator<<(char c) {       putchar(c);       return *this;     }     template <typename _Tp>     inline fastout& operator<<(_Tp _x) {       _Tp _k;       if (_x == 0) {         putchar( 0 );         return *this;       }       if (_x < 0) putchar( - ), _x = -_x;       while (_x > 0)         _k = _x / 10, ++_head, _num[_head] = (_x - (_k << 1) - (_k << 3)) ^ 48,         _x = _k;       while (_head > 0) putchar(_num[_head]), --_head;       return *this;     }     fastout() { _head = 0; }   } fout;   inline void P_INIT() {}   }  // namespace P_TEMPLATE   using namespace P_TEMPLATE;   using namespace std;   const int maxn = 1000004, maxm = 104;   const int mod = 1000000007, inf = 1201201201;   int n, k, p;   char s[maxn][maxm];   int len[maxn];   int book[28], cnt[28];   vector<int> e[28];   queue<int> q;   int topo[28], indx;   inline bool check() {     for (register int i = 1; i <= 26; ++i)       if (!cnt[i]) q.push(i), topo[++indx] = i;     while (!q.empty()) {       int t = q.front();       q.pop();       for (register int i = 0; i < e[t].size(); ++i) {         --cnt[e[t][i]];         if (cnt[e[t][i]] == 0) q.push(e[t][i]), topo[++indx] = e[t][i];       }     }     return indx == 26;   }   signed main() {     P_INIT();     fin >> n >> k;     for (register int i = 1; i <= n; ++i) {       fin >> p;       for (register int j = 1; j <= k; ++j) {         scanf( %s , s[p * k + j] + 1), len[p * k + j] = strlen(s[p * k + j] + 1);         for (register int t = 1; t <= len[p * k + j]; ++t)           book[s[p * k + j][t] -  a  + 1] = 1;       }     }     for (register int i = 1; i < n * k; ++i) {       bool flag = 0;       for (register int j = 1; j <= std::min(len[i], len[i + 1]); ++j)         if (s[i][j] != s[i + 1][j]) {           e[s[i][j] -  a  + 1].push_back(s[i + 1][j] -  a  + 1);           ++cnt[s[i + 1][j] -  a  + 1];           flag = 1;           break;         }       if (!flag && len[i] > len[i + 1]) {         puts( IMPOSSIBLE );         return 0;       }     }     if (check()) {       for (register int i = 1; i <= 26; ++i)         if (book[topo[i]]) fout << char(topo[i] - 1 +  a );     } else       puts( IMPOSSIBLE );     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:66777216 )   using namespace std;   const int N = 100007;   int n, a[N], cnt[N];   vector<int> D[N];   long long power(long long a, long long b) {     if (b == 0) {       return 1;     }     if (b & 1) {       return (a * power(a, b - 1)) % 1000000007LL;     }     long long ret = power(a, b >> 1);     return (ret * ret) % 1000000007LL;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     sort(a, a + n);     for (int i = 1; i <= a[n - 1]; ++i) {       for (int j = i; j <= a[n - 1]; j += i) {         D[j].push_back(i);       }     }     long long ans = 0;     for (int m = 1; m <= a[n - 1]; ++m) {       vector<int> &d = D[m];       int nd = (int)(d).size();       for (int i = 0; i < nd; ++i) {         cnt[i] = n - (lower_bound(a, a + n, d[i]) - a);       }       long long cur =           (power(nd, cnt[nd - 1]) - power(nd - 1, cnt[nd - 1]) + 1000000007LL) %           1000000007LL;       for (int i = 0; i < nd - 1; ++i) {         cur = (cur * power(i + 1, cnt[i] - cnt[i + 1])) % 1000000007LL;       }       ans = (ans + cur) % 1000000007LL;     }     printf( %d n , (int)ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void init_code() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   int main() {     init_code();     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<pair<int, int>> v;       vector<pair<int, int>> v1;       for (int i = 0; i < n; i++) {         int x, y;         cin >> x >> y;         v1.push_back({x, y});         v.push_back({x, y});       }       sort(v.begin(), v.end());       int st = v[0].first;       int ed = v[0].second;       int cnt = 1;       unordered_map<int, int> mp;       mp[st] = 1;       for (int i = 1; i < n; i++) {         if (v[i].first <= ed) {           mp[v[i].first] = cnt;           ed = max(ed, v[i].second);         } else {           st = v[i].first;           ed = v[i].second;           if (cnt == 1) {             cnt++;           }           mp[v[i].first] = cnt;         }       }       if (cnt < 2) {         cout <<  -1  << endl;       } else {         for (int i = 0; i < v1.size(); i++) {           cout << mp[v1[i].first] <<    ;         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {}   void no() {     cout <<  NO  <<   n ;     exit(0);   }   const long long maxn = 100050;   long long a[maxn];   long long psa[maxn];   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n;     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> a[i];     }     long long len = n;     for (long long i = 1; i <= n; i++) {       if (a[i] != a[1]) {         len = i - 1;         break;       }     }     for (long long i = 1; i <= n; i++) {       psa[i] = psa[i - 1] + a[i];     }     if (n % len) no();     for (long long i = len; i <= n; i += len) {       long long sum = psa[i] - psa[i - len];       if (sum and sum != len) {         no();       }       if (i >= len * 2) {         if (sum == psa[i - len] - psa[i - 2 * len]) {           no();         }       }     }     cout <<  YES  <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1234567;   int pref[N], a[N], b[N];   char c[N];   int solve(vector<pair<int, int> > z, int b) {     sort(z.begin(), z.end());     int cnt = z.size();     if (cnt < 2) {       return 0;     }     pref[0] = 0;     for (int i = 0; i < cnt; i++) {       pref[i + 1] = max(pref[i], z[i].second);     }     int i = 0;     int res = 0;     for (int j = cnt - 1; j >= 0; j--) {       while (i < j && z[i].first + z[j].first <= b) {         i++;       }       i = min(i, j);       if (i > 0) {         res = max(res, pref[i] + z[j].second);       }     }     return res;   }   int same(vector<pair<int, int> > &v, int b) {     if (v.size() < 2) return 0;     sort(v.begin(), v.end());     vector<int> pre(v.size() + 1, 0);     for (int i = 0; i < v.size(); i++) pre[i + 1] = max(pre[i], v[i].second);     int i = 0, ans = 0;     for (int j = v.size() - 1; j >= 0; j--) {       while (i < j && v[i].first + v[j].first <= b) i++;       i = min(i, j);       if (i > 0) {         ans = max(ans, v[j].second + pre[i]);       }     }     return ans;   }   int main() {     int n, C, D;     scanf( %d %d %d , &n, &C, &D);     for (int i = 0; i < n; i++) {       scanf( %d %d , a + i, b + i);       c[i] = getchar();       while (c[i] !=  C  && c[i] !=  D ) {         c[i] = getchar();       }     }     int ans = 0;     {       int x = 0, y = 0;       for (int i = 0; i < n; i++) {         if (c[i] ==  C  && b[i] <= C) {           x = max(x, a[i]);         }       }       for (int i = 0; i < n; i++) {         if (c[i] ==  D  && b[i] <= D) {           y = max(y, a[i]);         }       }       if (x > 0 && y > 0) {         ans = max(ans, x + y);       }     }     {       vector<pair<int, int> > z;       for (int i = 0; i < n; i++) {         if (c[i] ==  C ) {           z.push_back(make_pair(b[i], a[i]));         }       }       ans = max(ans, same(z, C));     }     {       vector<pair<int, int> > z;       for (int i = 0; i < n; i++) {         if (c[i] ==  D ) {           z.push_back(make_pair(b[i], a[i]));         }       }       ans = max(ans, same(z, D));     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   inline int abs(int n) { return n < 0 ? -n : n; }   bool board[20][20];   int dx[] = {-3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3};   int dy[] = {0, 1, -1, 2, -2, 3, -3, 2, -2, 1, -1, 0};   int dfs(int p, int n, int m) {     int mx = p, t, cnt = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (!board[i][j]) {           board[i][j] = true;           for (int k = 0; k < 12; k++) {             int ic = i + dx[k], jc = j + dy[k];             if (ic >= 0 && ic < n && jc >= 0 && jc < m && !board[ic][jc]) {               board[ic][jc] = true;               t = dfs(p + 2, n, m);               mx < t && (mx = t);               if (mx == ((m * n) | 1) - 1) return mx;               board[ic][jc] = false;             }           }           board[i][j] = false;           cnt++;           if (m * n - cnt <= mx) return mx;         }       }     }     return mx;   }   int ans[] = {0, 0, 0, 0, 2, 4};   int main() {     int m, n;     scanf( %d%d , &m, &n);     if (m < 10 && n < 10) {       printf( %d n , dfs(0, n, m));     } else if (m == 1) {       printf( %d n , n / 6 * 6 + ans[n % 6]);     } else if (n == 1) {       printf( %d n , m / 6 * 6 + ans[m % 6]);     } else {       printf( %lld n , (((long long)(m)*n) | 1) - 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using db = long double;   using pll = pair<long long, long long>;   const long long sz = 300003;   long long dp[sz][2], n;   long long a[sz];   long long dfs(long long i, long long par) {     if (i >= n) return 0;     long long &res = dp[i][par];     if (res == -1) {       res = 0;       if (par) {         res = a[i] + dfs(i + 1, par ^ 1);       } else {         res = -a[i] + dfs(i + 1, par ^ 1);       }       res = max({0LL, res, dfs(i + 1, par)});     }     return res;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t, i, x, j, y, q, z, k;     int kkr, csk;     long long tt;     cin >> tt;     for (long long _tt = 0; _tt < tt; _tt++) {       cin >> n >> q;       for (int i = 0; i < n; i++) cin >> a[i];       ;       while (q-- > 0) {         cin >> x >> y;         x--, y--;       }       for (i = 0; i < n; i += 1) {         memset(dp[i], -1, sizeof(dp[i]));       }       z = dfs(0, 1);       42;       cout << z <<   n ;       ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n];       for (int i = 0; i < n; i++) cin >> arr[i];       int counts[n + 1];       memset(counts, 0, sizeof(counts));       if (n == 1) {         cout << 0 << endl;         continue;       }       for (int i = 0; i < n; i++) counts[arr[i]]++;       int dc = 0, rc = INT_MIN;       for (int i = 0; i <= n; i++) {         if (counts[i] > 0) dc++;         rc = max(rc, counts[i]);       }       if (rc > 1) dc--;       if (rc > dc + 1)         cout << dc + 1 << endl;       else         cout << min(dc, rc) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   const int inf = 10000000;   int n, k;   int l[N], r[N];   int main() {     scanf( %d%d , &n, &k);     int midx = (k + 1) / 2, midy = (k + 1) / 2;     for (int i = 0; i < n; i++) {       int m, ans = inf, x, y1, y2;       scanf( %d , &m);       for (int row = 1; row <= k; row++) {         if (l[row] == 0 && r[row] == 0) {           for (int a = 1; a + m - 1 <= k; a++) {             int tot = 0, b = a + m - 1;             for (int col = a; col <= b; col++) {               tot += abs(row - midx) + abs(col - midy);             }             if (tot < ans) ans = tot, x = row, y1 = a, y2 = b;           }         } else {           if (l[row] > m) {             int tot = 0, a = l[row] - m, b = l[row] - 1;             for (int col = a; col <= b; col++) {               tot += abs(row - midx) + abs(col - midy);             }             if (tot < ans) ans = tot, x = row, y1 = a, y2 = b;           }           if (r[row] + m <= k) {             int tot = 0, a = r[row] + 1, b = r[row] + m;             for (int col = a; col <= b; col++)               tot += abs(row - midx) + abs(col - midy);             if (tot < ans) ans = tot, x = row, y1 = a, y2 = b;           }         }       }       if (ans == inf)         puts( -1 );       else {         printf( %d %d %d n , x, y1, y2);         if (r[x] == 0 && l[x] == 0)           l[x] = y1, r[x] = y2;         else           l[x] = min(l[x], y1), r[x] = max(r[x], y2);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 500010;   const int M = 16;   const int inf = 0x3f3f3f3f;   const int S = 1 << 15;   map<string, int> mp;   int vs[15], n, m;   char s[N][12], sx[12];   int dp[S], cnt[S][16];   int cal(int st) {     int res = 0;     while (st) {       if (st & 1) res++;       st >>= 1;     }     return res;   }   void prepare() {     for (int i = 0; i < S; ++i) {       int tmp = i;       for (int j = 0; j < M; ++j) {         tmp >>= 1;         cnt[i][j] = cal(tmp);       }     }   }   int stx[N], pre[M];   int main() {     prepare();     ios::sync_with_stdio(0);     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %s , sx);       mp[sx] = i;     }     int ans1 = -1, ans2 = 0, ans3 = 0;     scanf( %d , &m);     for (int i = 0; i < m; ++i) {       int k;       scanf( %d , &k);       memset(vs, 0, sizeof vs);       for (int j = 0; j < k; ++j) {         scanf( %s , s[j]);         if (mp.find(s[j]) == mp.end()) continue;         vs[mp[s[j]]] = 1;       }       int f = 0;       for (int j = 0; j < n && !f; ++j)         if (!vs[j]) f = 1;       if (f) continue;       int v = 0;       memset(dp, 0x3f, sizeof dp);       dp[0] = 0;       int pre = 0;       for (int j = 0; j < k; ++j) {         if (mp.find(s[j]) == mp.end()) continue;         int id = mp[s[j]], vst = 1 << id;         if (pre & (1 << id)) continue;         pre = (pre & ((1 << id) - 1) | (1 << id));         for (int st = stx[j] & (vst - 1); st < (1 << n); ++st)           if ((st & vst) == 0) {             dp[st | vst] = min(dp[st | vst], dp[st] + cnt[st][id]);           }       }       int tmp = n * (n - 1) / 2 - dp[(1 << n) - 1] + 1;       if (ans1 == -1 || tmp > ans2 || (tmp == ans2 && dp[(1 << n) - 1] < ans3)) {         ans1 = i;         ans2 = tmp;         ans3 = dp[(1 << n) - 1];       }     }     if (ans1 == -1)       puts( Brand new problem! );     else {       printf( %d n , ans1 + 1);       printf( %s ,  [: );       for (int i = 0; i < ans2; ++i) putchar( | );       puts( :] );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   using V = vector<T>;   const int MM = 5e5 + 5;   using T = long long;   bool QUERY;   struct Line {     mutable T a, b, p;     T Eval(T first) const { return a * first + b; }     bool operator<(const Line& o) const { return QUERY ? p < o.p : a < o.a; }   };   struct ConvexHull : multiset<Line> {     const T kInf = numeric_limits<T>::max();     T div(T a, T b) { return a / b - ((a ^ b) < 0 && a % b); }     bool isect(iterator first, iterator second) {       if (second == end()) {         first->p = kInf;         return false;       }       if (first->a == second->a) {         first->p = first->b > second->b ? kInf : -kInf;       } else {         first->p = div(second->b - first->b, first->a - second->a);       }       return first->p >= second->p;     }     void InsertLine(T a, T b) {       auto nx = insert({a, b, 0}), it = nx++, pv = it;       while (isect(it, nx)) {         nx = erase(nx);       }       if (pv != begin() && isect(--pv, it)) {         isect(pv, it = erase(it));       }       while ((it = pv) != begin() && (--pv)->p >= it->p) {         isect(pv, erase(it));       }     }     T EvalMax(T first) {       if (empty()) {         return -2e18;       }       QUERY = 1;       auto it = lower_bound({0, 0, first});       QUERY = 0;       return it->Eval(first);     }   };   vector<vector<int>> tree;   long long sub[MM];   long long n;   long long sq(long long e) { return e * e; }   void dfs1(int cur, int par) {     sub[cur] = 1;     for (auto u : tree[cur]) {       if (u != par) {         dfs1(u, cur);         sub[cur] += sub[u];       }     }   }   long long dp1[MM];   void dfs2(int cur, int par) {     dp1[cur] = sq(sub[cur]);     for (int u : tree[cur]) {       if (u != par) {         dfs2(u, cur);         dp1[cur] = min(dp1[cur], sq(sub[cur] - sub[u]) + dp1[u]);       }     }   }   vector<long long> ans;   void dfs3(int cur, int par) {     ConvexHull CH;     ans[cur] = sq(n);     for (int u : tree[cur]) {       if (u != par) {         dfs3(u, cur);         long long val = dp1[u] - CH.EvalMax(sub[u]) + sq(sub[u]);         ans[cur] = min(ans[cur], val);         ans[cur] = min(ans[cur], dp1[u] + sq(n - sub[u]));         CH.InsertLine(2 * (n - sub[u]), -(dp1[u] + sq(n - sub[u])));       }     }     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     tree.resize(n);     ans.resize(n);     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       u--;       v--;       tree[u].push_back(v);       tree[v].push_back(u);     }     dfs1(0, -1);     dfs2(0, -1);     dfs3(0, -1);     cout << (n * n - n) / 2 +                 (sq(n) - *min_element((ans).begin(), (ans).end())) / 2          << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Item {     int x[3], y[3];   };   bool check(Item t);   inline int Dist(int x1, int y1, int x2, int y2) {     return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);   }   int main() {     Item it;     for (int i = 0; i < 3; i++) cin >> it.x[i] >> it.y[i];     if (check(it))       cout <<  RIGHT n ;     else {       bool f = false;       for (int i = 0; i < 3; i++) {         Item tmp = it;         tmp.x[i]--;         if (check(tmp)) {           f = true;           break;         }         tmp.x[i] += 2;         if (check(tmp)) {           f = true;           break;         }       }       for (int i = 0; i < 3; i++) {         Item tmp = it;         tmp.y[i]--;         if (check(tmp)) {           f = true;           break;         }         tmp.y[i] += 2;         if (check(tmp)) {           f = true;           break;         }       }       if (f == true)         cout <<  ALMOST n ;       else         cout <<  NEITHER n ;     }     return 0;   }   bool check(Item t) {     int d[3];     int xx[3], yy[3];     d[0] = Dist(t.x[0], t.y[0], t.x[1], t.y[1]);     d[1] = Dist(t.x[0], t.y[0], t.x[2], t.y[2]);     d[2] = Dist(t.x[1], t.y[1], t.x[2], t.y[3]);     if (!d[0] || !d[1] || !d[2]) return false;     if (d[0] + d[1] == d[2] || d[1] + d[2] == d[0] || d[0] + d[2] == d[1])       return false;     xx[0] = t.x[0] - t.x[1];     yy[0] = t.y[0] - t.y[1];     xx[1] = t.x[0] - t.x[2];     yy[1] = t.y[0] - t.y[2];     xx[2] = t.x[1] - t.x[2];     yy[2] = t.y[1] - t.y[2];     if (xx[0] * xx[1] + yy[0] * yy[1] == 0 ||         xx[0] * xx[2] + yy[0] * yy[2] == 0 || xx[1] * xx[2] + yy[1] * yy[2] == 0)       return true;     else       return false;   }