malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n;   double A[1010], B[1010];   double p[1010][1010];   double dis(int u) { return (B[u] + 1) / (1 - A[u]); }   int mark[1010];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         scanf( %lf , &p[i][j]);         p[i][j] /= 100;       }     for (int i = 1; i <= n - 1; i++) A[i] = 1;     A[n] = 0, B[n] = -1;     for (int k = 1; k <= n; k++) {       int u = -1;       for (int i = 1; i <= n; i++) {         if ((u == -1 || dis(i) < dis(u) && !mark[i])) u = i;       }       mark[u] = 1;       for (int v = 1; v <= n; v++) {         if (mark[v]) continue;         B[v] += A[v] * p[v][u] * dis(u);         A[v] *= (1 - p[v][u]);       }     }     printf( %.10f n , dis(1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve(const int &test_id) {     int n, p, k;     cin >> n >> p >> k;     vector<pair<long long, int> > aud(n);     for (int i = 0; i < n; i++) cin >> aud[i].first, aud[i].second = i;     sort(aud.rbegin(), aud.rend());     vector<int> twos(p + 1);     for (int i = 0; i < p + 1; i++) twos[i] = (1 << i);     vector<vector<long long> > skill(n, vector<long long>(twos[p]));     for (int i = 0; i < n; i++)       for (int j = 0; j < p; j++) cin >> skill[i][j];     vector<vector<long long> > dp(n + 1, vector<long long>(twos[p]));     for (int i = 1; i < n + 1; i++) {       for (int j = 0; j < twos[p]; j++) {         int curr_aud_count = i - 1 - __builtin_popcount(j);         if (curr_aud_count < k && curr_aud_count > -1)           dp[i][j] = max(dp[i][j], dp[i - 1][j] + aud[i - 1].first);         else           dp[i][j] = max(dp[i][j], dp[i - 1][j]);         for (int k = 0; k < p; k++)           if (j & twos[k])             dp[i][j] = max(dp[i][j],                            dp[i - 1][j ^ twos[k]] + skill[aud[i - 1].second][k]);       }     }     cout << dp[n][twos[p] - 1] << endl;   }   void solve_cases() {     int test_cases = 1;     for (int i = 1; i <= test_cases; i++) solve(i);   }   void fast_io() {     ios::sync_with_stdio(false);     srand(time(NULL));     cin.tie(0);     cout.tie(0);     cout << fixed << setprecision(15);     cerr << fixed << setprecision(15);   }   int main() {     fast_io();     solve_cases();     return EXIT_SUCCESS;   }
#include <iostream>   #include <cmath>   #include <algorithm>   #include <vector>   #include <set>   #include <unordered_set>   #include <queue>   #include <deque>   #include <string>   #include <sstream>   #include <iomanip>   #include <map>   #include <unordered_map>   #include <stack>   #include <cstdio>   #include <climits>   #include <tuple>   #include <ctime>   #include <cstring>   #include <numeric>   #include <functional>   #include <chrono>   #include <cassert>   #include <bitset>   using namespace std;   using ll = long long;   const ll INF = 2e9;   vector <vector<int>> gp;   vector<int> vis;   vector<int> dist;   vector<int> v;   string fibWord(int n)   {       string Sn_1 =  0 ;       string Sn =  01 ;       string tmp;       for (int i = 2; i <= n; i++)       {           tmp = Sn;           Sn += Sn_1;           Sn_1 = tmp;       }          return Sn;   }      void solution() {       int n; cin >> n;       cout << 2 - n * n << endl;   }      int main()   {       ios_base::sync_with_stdio(false);       cin.tie(NULL);       //int T; cin >> T;       //while (T--){       solution();       //}   }
#include <bits/stdc++.h>   using namespace std;   int maps[501][501];   char str[501];   int dx[11] = {-1, 0, 1, 0, -1, -1, 1, 1, -1, -1};   int dy[11] = {0, 1, 0, -1, 0, 1, 1, -1, -1, 1};   int dp[550][550][10];   int n, m;   int pan(int x, int y) {     if (x < 1 || x > n || y < 1 || y > m) return 1;     if (maps[x][y]) return 1;     return 0;   }   int main() {     while (~scanf( %d%d , &n, &m)) {       for (int i = 1; i <= n; i++) {         scanf( %s , str);         for (int j = 1; j <= m; j++) {           if (str[j - 1] ==  0 )             maps[i][j] = 0;           else             maps[i][j] = 1;         }       }       int ans = 0;       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) {           if (maps[i][j]) continue;           for (int q = 0; q < 9; q++) {             dp[i][j][q] = 1;             if (q == 4) continue;             for (int k = 1;; k++) {               int xx = i + dx[q] * k;               int yy = j + dy[q] * k;               if (pan(xx, yy)) break;               dp[i][j][q]++;             }           }         }       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= m; j++) {           if (maps[i][j]) continue;           for (int q = 0; q < 9; q++) {             if (q == 4) continue;             for (int k = 1;; k++) {               int xx = i + dx[q] * k;               int yy = j + dy[q] * k;               if (pan(xx, yy) || pan(i + dx[q + 1] * k, j + dy[q + 1] * k)) {                 break;               }               if (q == 0 && dp[xx][yy][6] >= k + 1) ans++;               if (q == 1 && dp[xx][yy][7] >= k + 1) ans++;               if (q == 2 && dp[xx][yy][8] >= k + 1) ans++;               if (q == 3 && dp[xx][yy][5] >= k + 1) ans++;               if (q == 5 && dp[xx][yy][2] >= k * 2) ans++;               if (q == 6 && dp[xx][yy][3] >= k * 2) ans++;               if (q == 7 && dp[xx][yy][0] >= k * 2) ans++;               if (q == 8 && dp[xx][yy][1] >= k * 2) ans++;             }           }         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const char nl =   n ;   const int MAX_N = 100011;   const long long INF = (1 << 29) + 123;   const long long MOD = 998244353;   const long double PI = 4 * atan((long double)1);   template <typename T>   bool ckmin(T& a, const T& b) {     return a > b ? a = b, 1 : 0;   }   template <typename T>   bool ckmax(T& a, const T& b) {     return b > a ? a = b, 1 : 0;   }   void dbg_out() { cerr << endl; }   template <typename Head, typename... Tail>   void dbg_out(Head H, Tail... T) {     cerr << H <<    ;     dbg_out(T...);   }   template <typename T>   class SafeVector : public vector<T> {    public:     using vector<T>::vector;     typename vector<T>::reference operator[](size_t n) {       return vector<T>::at(n);     }     typename vector<T>::const_reference operator[](size_t n) const {       return vector<T>::at(n);     }   };   mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());   const int MX = 2e5 + 5;   long long a[MX][3];   vector<long long> x;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; i++)       for (int j = 0; j < 3; j++) cin >> a[i][j];     for (int i = 0; i < n; i++) x.push_back(a[i][0]);     long long dp[n];     for (int i = 0; i < n; i++) dp[i] = 0;     long long pref[n + 1];     for (int i = 0; i < n + 1; i++) pref[i] = 0;     dp[0] = a[0][0] - a[0][1];     pref[1] = dp[0];     for (int i = 1; i <= n - 1; i++) {       int idx = lower_bound(x.begin(), x.end(), a[i][1]) - x.begin();       dp[i] = ((pref[i] - pref[idx]) % MOD + MOD + a[i][0] - a[i][1]) % MOD;       pref[i + 1] = (pref[i] + dp[i]) % MOD;     }     long long ans = 0;     for (int i = 0; i < n; i++) ans = ((a[i][2] * dp[i]) % MOD + ans) % MOD;     cout << (ans + x[n - 1] + 1) % MOD << nl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, k;     cin >> n >> k;     long long ar[n];     for (long long i = 0; i < n; i++) {       cin >> ar[i];     }     map<long long, long long> mp1, mp2;     for (long long i = 0; i < n; i++) {       mp2[ar[i]]++;     }     mp1[ar[0]]++;     mp2[ar[0]]--;     long long ans = 0;     for (long long i = 1; i < n - 1; i++) {       mp2[ar[i]]--;       if (ar[i] % k == 0) ans += mp1[ar[i] / k] * mp2[ar[i] * k];       mp1[ar[i]]++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char c = getchar();     int tot = 1;     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) {       tot = -1;       c = getchar();     }     int sum = 0;     while (c >=  0  && c <=  9 ) {       sum = sum * 10 + c -  0 ;       c = getchar();     }     return sum * tot;   }   inline void wr(int x) {     if (x < 0) {       putchar( - );       wr(-x);       return;     }     if (x >= 10) wr(x / 10);     putchar(x % 10 +  0 );   }   inline void wrn(int x) {     wr(x);     putchar(  n );   }   inline void wri(int x) {     wr(x);     putchar(   );   }   int n, m, c;   double ans;   struct p {     double x, y;     double z;   } z[200005];   inline double get_dis(p a, p b) {     return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));   }   inline double check(p a) { return get_dis(a, z[0]) - get_dis(a, z[n + 1]); }   bool cmp(p a, p b) { return a.z < b.z; }   inline double get_ans(p x, p y) {     double wx = z[0].x, wy = z[0].y;     if (x.x == y.x)       wx = 2 * x.x - wx;     else {       double k = 1.0 * (y.y - x.y) / (y.x - x.x), b = x.y - k * x.x,              kk = -1.0 / k;       double d =           2 *           abs((z[0].x - x.x) * (z[0].y - y.y) - (z[0].y - x.y) * (z[0].x - y.x)) /           sqrt((x.x - y.x) * (x.x - y.x) + (x.y - y.y) * (x.y - y.y));       double tx = d / sqrt(kk * kk + 1), ty = tx * kk;       if ((k * wx + b > wy) ^ (k * (wx + tx) + b > (wy + ty)))         wx = wx + tx, wy = wy + ty;       else         wx = wx - tx, wy = wy - ty;     }     return sqrt((z[n + 1].x - wx) * (z[n + 1].x - wx) +                 (z[n + 1].y - wy) * (z[n + 1].y - wy));   }   signed main() {     n = read();     c = read();     z[0].x = c;     z[0].y = 0;     for (int i = 1; i <= n; i++) {       z[i].x = read();       z[i].y = read();       z[i].z = fabs(sqrt(((z[i].x - c) * (z[i].x - c)) + ((z[i].y) * (z[i].y))) -                     sqrt(((z[i].x + c) * (z[i].x + c)) + ((z[i].y) * (z[i].y))));     }     sort(z + 1, z + 1 + n, cmp);     n = min(n, 850);     z[n + 1].x = -c;     z[n + 1].y = 0;     ans = c * 2;     for (int i = 1; i < n; i++) {       if (fabs(check(z[i])) > ans) continue;       for (int j = i + 1; j <= n; j++) {         if (fabs(check(z[j])) > ans) continue;         ans = min(ans, get_ans(z[i], z[j]));       }     }     printf( %.10lf , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long N, f[3001][3001];   struct Node {     long long x, val;   } P[3001];   inline bool cmp(const Node &a, const Node &b) { return a.x < b.x; }   int main() {     scanf( %I64d , &N);     for (long long i = 1; i <= N; i++) scanf( %I64d%I64d , &P[i].x, &P[i].val);     sort(P + 1, P + N + 1, cmp);     memset(f, 0x7f, sizeof(f));     f[1][1] = P[1].val;     for (long long i = 2; i <= N; i++)       for (long long j = 1; j <= i; j++) {         f[i][j] = min(f[i][j], f[i - 1][j] + P[i].x - P[j].x);         f[i][i] = min(f[i][i], f[i - 1][j] + P[i].val);       }     long long ans = (unsigned)(-1) >> 1;     for (long long i = 1; i <= N; i++) ans = min(ans, f[N][i]);     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ax[4], ay[4], bx[4], by[4];   int xmin = 1000, xmax = -1000, ymin = 1000, ymax = -1000;   bool f() {     for (int i = 0; i < 4; i++) {       if (bx[i] >= xmin && bx[i] <= xmax && by[i] >= ymin && by[i] <= ymax) {         return 1;       }     }     double X = ((double)bx[0] + (double)bx[3]) / 2,            Y = ((double)by[0] + (double)by[3]) / 2;     if (X >= xmin && X <= xmax && Y >= ymin && Y <= ymax) {       return 1;     }     return 0;   }   void rotat() {     int X, Y;     xmin = ymin = 1000;     xmax = ymax = -1000;     for (int i = 0; i < 4; i++) {       X = ax[i] + ay[i];       Y = ax[i] - ay[i];       ax[i] = X;       ay[i] = Y;       X = bx[i] + by[i];       Y = bx[i] - by[i];       bx[i] = X;       by[i] = Y;       swap(ax[i], bx[i]);       swap(by[i], ay[i]);       xmin = min(xmin, ax[i]);       xmax = max(xmax, ax[i]);       ymin = min(ymin, ay[i]);       ymax = max(ymax, ay[i]);     }   }   int main() {     for (int i = 0; i < 4; i++) {       cin >> ax[i] >> ay[i];       xmin = min(xmin, ax[i]);       xmax = max(xmax, ax[i]);       ymin = min(ymin, ay[i]);       ymax = max(ymax, ay[i]);     }     for (int i = 0; i < 4; i++) {       cin >> bx[i] >> by[i];     }     if (f()) {       cout <<  Yes n ;       return 0;     }     rotat();     if (f()) {       cout <<  Yes n ;       return 0;     }     cout <<  No n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int N, M;     cin >> N >> M;     vector<int> ceff(N * 2);     for (int i = 0; i < N; ++i) {       cin >> ceff[i * 2];     }     cin >> ceff[N * 2 - 1];     for (int i = 1; i < N; ++i) {       cin >> ceff[i * 2 - 1];     }     double cur = M;     for (int i = N * 2 - 1; i >= 0; --i) {       if (ceff[i] == 1) {         cout << -1 << endl;         return 0;       }       cur = cur / (ceff[i] - 1) + cur;     }     cout << setprecision(10) << fixed;     cout << cur - M << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   const int ZERO = 2e5 + 5000;   int n, w, h;   struct node {     int id, x, t;     node() {}     node(int _id, int _x, int _t) : id(_id), x(_x), t(_t) {}     bool operator<(const node &a) const { return x < a.x; }   } X[MAXN];   vector<node> Y[MAXN * 4];   int cnt[MAXN * 4];   pair<int, int> ans[MAXN];   int main() {     scanf( %d%d%d , &n, &w, &h);     int tot = 0;     for (int i = 1; i <= n; i++) {       int g, p, t;       scanf( %d%d%d , &g, &p, &t);       if (g == 1) {         X[++tot] = node(i, p, t);       } else {         Y[p - t + ZERO].push_back(node(i, p, t));       }     }     sort(X + 1, X + 1 + tot);     for (int i = 0; i < 4 * MAXN; i++) {       sort(Y[i].begin(), Y[i].end());     }     for (int i = 1; i <= tot; i++) {       int pos = X[i].x - X[i].t + ZERO;       int sz = Y[pos].size();       if (sz) {         int en = ((sz - cnt[pos] - 1) % sz + sz) % sz;         swap(Y[pos][en].id, X[i].id);         cnt[pos]++;       }       ans[X[i].id] = make_pair(X[i].x, h);     }     for (int i = 0; i < 4 * MAXN; i++) {       int sz = Y[i].size();       for (int j = 0; j < sz; j++) {         int pos = (((sz - cnt[i] - 1) % sz + sz) % sz + j + 1) % sz;         ans[Y[i][pos].id] = make_pair(w, Y[i][j].x);       }     }     for (int i = 1; i <= n; i++) {       printf( %d %d n , ans[i].first, ans[i].second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char ans[1000005], tmp[1000005];   int wa;   int n, x;   void go(int x, int y) {     int len = 0;     while (x != y) {       if (x < y) {         y -= x;         tmp[len++] =  B ;       } else {         x -= y;         tmp[len++] =  T ;       }       if (len >= n) return;     }     tmp[len++] =  T ;     int w = 0;     if (x > 1 || len != n) return;     for (int i = 0; i + 1 < len; i++)       if (tmp[i] == tmp[i + 1]) w++;     if (wa > w) {       wa = w;       for (int i = 0; i < n; i++) ans[i] = tmp[i];     }   }   int main() {     while (scanf( %d%d , &n, &x) == 2) {       wa = 10000000;       for (int i = 1; i <= x; i++) {         go(i, x);         go(x, i);       }       if (wa == 10000000)         puts( IMPOSSIBLE );       else {         reverse(ans, ans + n);         printf( %d n , wa);         for (int i = 0; i < n; i++) putchar(ans[i]);         puts(  );       }     }     return 0;   }
#include <bits/stdc++.h>   const int N = 5e5 + 10, M = 1e7 + 10;   const long long mod = 1e9 + 7;   using namespace std;   map<pair<int, int>, set<int>> mp;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int x[N], y[N];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) scanf( %d%d , &x[i], &y[i]);     long long cnt = 0, res = 0;     for (int i = 1; i < n; i++) {       for (int j = i + 1; j <= n; j++) {         int a = y[i] - y[j], b = x[i] - x[j];         int c = y[i] * x[j] - y[j] * x[i];         int g = gcd(a, b);         a /= g;         b /= g;         c /= g;         if (a < 0 || (a == 0 && b < 0)) a = -a, b = -b;         pair<int, int> p = make_pair(a, b);         if (mp[p].find(c) == mp[p].end()) {           cnt++;           mp[p].insert(c);           res += cnt - mp[p].size();         }       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int aa[105][105];   pair<int, int> pos[105][105];   int main() {     int n, m, q;     scanf( %d %d %d , &n, &m, &q);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         pos[i][j] = {i, j};         aa[i][j] = INT_MAX;       }     }     for (int l = 1; l <= q; ++l) {       int a;       scanf( %d , &a);       if (a == 3) {         int r, c, x;         scanf( %d %d %d , &r, &c, &x);         aa[pos[r][c].first][pos[r][c].second] = x;       } else {         int x;         scanf( %d , &x);         if (a == 1) {           pair<int, int> temp = pos[x][1];           for (int i = 1; i <= m; ++i) {             pos[x][i] = pos[x][i + 1];           }           pos[x][m] = temp;         } else {           pair<int, int> temp = pos[1][x];           for (int i = 1; i <= n; ++i) {             pos[i][x] = pos[i + 1][x];           }           pos[n][x] = temp;         }       }     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (aa[i][j] == INT_MAX) {           printf( 1  );         } else {           printf( %d  , aa[i][j]);         }       }       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     int n;     cin >> n;     int A[12];     int B[12];     for (int i = 0; i < 10; i++) A[i] = true;     for (int i = 0; i < 10; i++) B[i] = false;     for (int i = 0; i < n; i++) {       char x;       int c;       cin >> x >> c;       for (int j = 0; j < 10; j++) {         if (x ==  & ) {           A[j] &= (c % 2);           B[j] &= (c % 2);         }         if (x ==  | ) {           A[j] |= (c % 2);           B[j] |= (c % 2);         }         if (x ==  ^ ) {           A[j] ^= (c % 2);           B[j] ^= (c % 2);         }         c /= 2;       }     }     int AAA = 0;     int BBB = 0;     for (int i = 0; i < 10; i++) {       int a_ = 0, b_ = 0;       for (int a = 0; a < 2; a++) {         for (int b = 0; b < 2; b++) {           int AA = (((true | a) ^ b));           int BB = (((false | a) ^ b));           if (AA == A[i] && BB == B[i]) {             a_ = a;             b_ = b;           }         }       }       AAA += a_ * (1ll << i);       BBB += b_ * (1ll << i);     }     cout << 2 <<   n ;     cout <<  |   << AAA <<   n ;     cout <<  ^   << BBB <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int mxN = 500, M = 1e9 + 7;   int n, a[mxN];   long long dp[mxN][mxN];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i], --a[i];     dp[0][0] = 1;     for (int i = 1; i < n; ++i) dp[i][i] = dp[i - 1][i] = 1;     for (int i = n - 1; ~i; --i) {       for (int j = i + 2; j < n; ++j) {         dp[i][j] = dp[i + 1][j];         for (int k = i + 1; k < j; ++k)           if (a[k + 1] > a[i + 1])             dp[i][j] = (dp[i][j] + dp[i + 1][k] * dp[k][j]) % M;       }     }     cout << dp[0][n - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   constexpr int inf = 1e9;   int main() {     int n, m;     cin >> n >> m;     vector<int> d(m), h(m);     for (int i = 0; i < m; ++i) {       cin >> d[i] >> h[i];     }     int ans = max(h[0] + d[0] - 1, h.back() + (n - d.back()));     for (int i = 0; i + 1 < m; ++i) {       if (abs(h[i] - h[i + 1]) > d[i + 1] - d[i]) {         ans = -1;         break;       }       ans = max(ans, (d[i + 1] - d[i] - abs(h[i] - h[i + 1])) / 2 +                          max(h[i], h[i + 1]));     }     if (ans == -1) {       cout <<  IMPOSSIBLE  << endl;     } else {       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int mod = 1e9 + 7;   void show2d(const vector<vector<int>>& adj) {     for (auto x : adj) {       for (auto y : x) {         cout << y <<    ;       }       cout <<   n ;     }   }   long long int modexp(long long int a, long long int b, long long int mod) {     long long int x = 1;     while (b) {       if (b & 1) x = ((x % mod) * (a % mod)) % mod;       a = ((a % mod) * (a % mod)) % mod;       b = b / 2;     }     return x;   }   void rf() {}   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, m, k;     cin >> n >> m >> k;     int o = 0;     int tt = 0;     for (int i = 0; i < n; ++i) {       int ch;       cin >> ch;       if (ch == 1)         ++o;       else         ++tt;     }     tt = max(tt - k, 0);     cout << max((o + tt) - m, 0) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void print(T a) {     for (auto i = a.begin(); i != a.end(); i++) cout << *i <<    ;     cout << endl;   }   bool isVowel(char c) {     if (c ==  a  || c ==  e  || c ==  i  || c ==  o  || c ==  u ) return true;     return false;   }   void sync() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   vector<long long int> G[1000000];   map<long long int, bool> ck;   bool dfs(long long int a, long long int b) {     if (a == b) return true;     ck[a] = true;     for (long long int j : G[a]) {       if (ck[j] == true) continue;       bool d = dfs(j, b);       if (d == true) return true;     }     return false;   }   int main() {     sync();     long long int t;     cin >> t;     long long int j = 0;     vector<pair<long long int, long long int> > edges;     for (long long int testcase = 1; testcase <= t; testcase++) {       long long int a, b, c;       cin >> a >> b >> c;       if (a == 2) {         b--, c--;         ck.clear();         bool d = dfs(b, c);         if (d == true)           cout <<  YES  << endl;         else           cout <<  NO  << endl;       } else {         edges.push_back({b, c});         if (j == 0) {         } else {           for (long long int i = 0; i < j; i++) {             long long int x1 = edges[i].first;             long long int y1 = edges[i].second;             if ((x1 > b && x1 < c) || (y1 > b && y1 < c)) {               G[i].push_back(j);             }             if ((b > x1 && b < y1) || (c > x1 && c < y1)) {               G[j].push_back(i);             }           }         }         j++;       }     }   }