malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int DX[8] = {1, -1, 0, 0, 1, 1, -1, -1};   const int DY[8] = {0, 0, 1, -1, 1, -1, 1, -1};   const int intmax = 0x7fffffff;   map<int, int> mp;   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int a;       scanf( %d , &a);       mp[a]++;     }     map<int, int>::iterator it = mp.begin();     int deg = (it->second) * 2;     int last = it->first;     it++;     for (; it != mp.end(); it++) {       if ((it->first) != last + 1) {         puts( NO );         return 0;       }       if (!deg) {         puts( NO );         return 0;       }       deg = it->second * 2 - deg;       if (deg < 0) {         puts( NO );         return 0;       }       last = it->first;     }     if (!deg)       puts( YES );     else       puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   const long double PI = acos(-1);   const long double eps = 0.0000000001;   const long long INF = 0x3fffffffffffffff;   long long a[200005], sum[200005], n, q, x, y;   long long lowbit(long long now) { return now & -now; }   void add(long long pos, long long v) {     while (pos <= n) {       sum[pos] += v;       pos += lowbit(pos);     }   }   long long query(long long now) {     long long res = 0;     while (now) {       res += sum[now];       now ^= lowbit(now);     }     return res;   }   long long findnext(long long now) {     long long l = now + 1, r = n + 1, v = query(now);     while (l < r) {       long long mid = (l + r) >> 1;       if (query(mid) < v << 1) {         l = mid + 1;       } else {         r = mid;       }     }     return l;   }   signed main() {     ios::sync_with_stdio(false);     cin >> n >> q;     for (long long i = 1; i <= n; ++i) {       cin >> a[i];       add(i, a[i]);     }     for (long long i = 1; i <= q; ++i) {       cin >> x >> y;       add(x, -a[x]);       a[x] = y;       add(x, a[x]);       long long now = 1;       bool flag = false;       if (a[1] == 0) {         cout << 1 << endl;         continue;       }       while (now <= n) {         now = findnext(now);         if (now <= n && query(now) == a[now] << 1) {           cout << now << endl;           flag = true;           break;         }       }       if (!flag) {         cout << -1 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, p, q, b, l;   long long int gcd(long long int a, long long int c) {     if (!c) return a;     return gcd(c, a % c);   }   long long int read_ll() {     char ch;     long long int num = 0;     ch = getchar();     while (!isdigit(ch)) {       ch = getchar();     }     while (isdigit(ch)) {       num = num * 10 + (long long int)ch - (long long int) 0 ;       ch = getchar();     }     return num;   }   int main() {     scanf( %ld , &n);     while (n--) {       p = read_ll();       q = read_ll();       b = read_ll();       long long int d = gcd(p, q);       p = p / d;       q = q / d;       while (1) {         b = gcd(q, b);         if (b == 1) {           if (q == 1)             printf( Finite n );           else             printf( Infinite n );           break;         }         while (q % b == 0) q /= b;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, z;     cin >> x >> y >> z;     int total = x - y;     if (total < 0) {       if (total + z < 0) {         cout <<  - ;       } else {         cout <<  ? ;       }     }     if (total > 0) {       if (total - z > 0) {         cout <<  + ;       } else {         cout <<  ? ;       }     }     if (total == 0) {       if (total + z == 0) {         cout <<  0 ;       } else {         cout <<  ? ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:100000000 )   int n;   double l;   pair<int, int> mas[1010];   int lst[1010];   double dp[1010];   bool check(double r) {     for (int i = 0; i <= n; i++) lst[i] = -1;     for (int i = 1; i <= n; i++) dp[i] = -1e15;     for (int i = 0; i < n; i++) {       if (lst[i] == -1 && i != 0) continue;       for (int j = i + 1; j <= n; j++) {         double p = sqrt(abs(l - (double)(mas[j].first - mas[i].first)));         if (dp[j] < dp[i] + (double)mas[j].second * r - p) {           lst[j] = i;           dp[j] = dp[i] + (double)mas[j].second * r - p;         }       }     }     if (lst[n] != -1 && dp[n] > -1e-9)       return true;     else       return false;   }   int main() {     scanf( %d %lf , &n, &l);     for (int i = 1; i <= n; i++) scanf( %d %d , &mas[i].first, &mas[i].second);     double l = 0, r = 1e9;     for (int i = 0; i < 100; i++) {       double av = (l + r) / 2.0;       if (check(av))         r = av;       else         l = av;     }     check(l);     vector<int> ans;     int cur = n;     while (cur != 0) {       ans.push_back(cur);       cur = lst[cur];     }     for (int i = (int)(ans).size() - 1; i >= 0; i--) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int m = 31;   const int maxn = 31;   long long n, k;   long long f[maxn + 5], g[maxn + 5];   void init() {     f[1] = g[1] = 1;     for (int i = 2; i <= m; i++) {       f[i] = (1LL << i * 2 - 2) + f[i - 1];       g[i] = (1LL << i) - 1 + g[i - 1];     }   }   int main() {     init();     long long T;     cin >> T;     while (T--) {       cin >> n >> k;       if (n > m) {         printf( YES %I64d n , n - 1);         continue;       }       int flg = -1;       for (int i = 0; i <= n; i++) {         if (k >= g[i] &&             k <= f[i] + f[n - i] * ((1ll << i) - 1) * ((1ll << i) - 1)) {           flg = i;           break;         }       }       if (~flg)         printf( YES %I64d n , n - flg);       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     int n, m;     cin >> n >> m;     cin >> s;     for (int i = 0; i < m; i++) {       int l, r;       char c1, c2;       scanf( %d %d %c %c , &l, &r, &c1, &c2);       for (int j = l - 1; j < r; j++) {         if (s[j] == c1) {           s[j] = c2;         }       }     }     cout << s << endl;     cin >> n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     if (n == 1) {       printf( a na nb nb n );     } else if (n == 2) {       printf( aa nbb ncc ndd n );     } else if (n == 3) {       printf( aab n );       printf( ccb n );       printf( baa n );       printf( bcc n );     } else {       char a[4][105];       int i, j;       if (n % 2 == 0) {         a[0][0] =  a ;         a[0][1] =  a ;         a[1][0] =  b ;         a[2][0] =  b ;         a[3][0] =  a ;         a[3][1] =  a ;         a[0][n - 2] = a[0][n - 1] =  y ;         a[1][n - 1] = a[2][n - 1] =  z ;         a[3][n - 2] = a[3][n - 1] =  y ;         for (i = 1;; i += 2) {           a[1][i] = a[1][i + 1] =  g  + ((i / 2) % 2) * 2;           a[2][i] = a[2][i + 1] =  h  + ((i / 2) % 2) * 2;           if (i + 1 == n - 2) break;           a[0][i + 1] = a[0][i + 2] =  m  + ((i / 2) % 2) * 2;           a[3][i + 1] = a[3][i + 2] =  n  + ((i / 2) % 2) * 2;         }       } else {         a[0][0] = a[1][0] =  a ;         a[2][0] = a[2][1] =  b ;         a[3][0] = a[3][1] =  c ;         a[0][n - 1] = a[0][n - 2] =  z ;         a[1][n - 1] = a[1][n - 2] =  y ;         a[2][n - 1] = a[3][n - 1] =  x ;         for (i = 1; i < n - 2; i++) a[0][i] =  g  + (((i - 1) / 2) % 2);         for (i = 1; i < n - 2; i++) a[1][i] =  i  + (((i - 1) / 2) % 2);         for (i = 2; i < n - 1; i++) a[2][i] =  k  + (((i) / 2) % 2);         for (i = 2; i < n - 1; i++) a[3][i] =  n  + (((i) / 2) % 2);       }       a[0][n] = a[1][n] = a[2][n] = a[3][n] =   0 ;       printf( %s n%s n%s n%s n , a[0], a[1], a[2], a[3]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long h, n;     cin >> h >> n;     long long l = 1, r = (1LL << h), ret = 0, cur = 0, dir = 0;     while (cur < h) {       long long size = (1LL << (h - cur)), mid = (l + r) / 2;       if (dir == 0) {         if (n <= mid)           ++ret, r = mid, dir = 1;         else           ret += size, l = mid + 1;       } else {         if (n <= mid)           ret += size, r = mid;         else           ++ret, l = mid + 1, dir = 0;       }       ++cur;     }     cout << ret << endl;   }
#include <bits/stdc++.h>   using ull = unsigned long long;   using ll = long long;   using ld = long double;   using namespace std;   const ll mod = 998244353;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int n, m, k, t;     cin >> n >> k >> m >> t;     deque<bool> cur(n);     cur[k - 1] = 1;     while (t--) {       int f, pos;       cin >> f >> pos;       if (f == 1) {         cur.insert(cur.begin() + (pos - 1), 0);         for (int i = 0; i < ((int)(cur).size()); i++) {           if (cur[i]) {             cout << ((int)(cur).size()) <<     << i + 1 <<   n ;             break;           }         }       } else {         int loc = -1;         for (int i = 0; i < ((int)(cur).size()); i++) {           if (cur[i]) {             loc = i + 1;             break;           }         }         if (loc <= pos)           while (((int)(cur).size()) > pos) cur.pop_back();         else           while (pos--) cur.pop_front();         for (int i = 0; i < ((int)(cur).size()); i++) {           if (cur[i]) {             cout << ((int)(cur).size()) <<     << i + 1 <<   n ;             break;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int maze[1500][1500];   pair<int, int> was[1500][1500];   int n, m;   int sr, sc;   inline int rem(int x, int y) {     x %= y;     return (x < 0) ? x + y : x;   }   bool dfs(int r, int c) {     int rm = rem(r, n), cm = rem(c, m);     if (maze[rm][cm] == 1) {       return was[rm][cm] != pair<int, int>(r, c);     }     int rmn, cmn;     if (maze[rm][cm] == 0) {       maze[rm][cm] = 1;       was[rm][cm] = pair<int, int>(r, c);       rmn = rem(r, n), cmn = rem(c - 1, m);       if (maze[rmn][cmn] != -1 && dfs(r, c - 1)) return true;       rmn = rem(r, n), cmn = rem(c + 1, m);       if (maze[rmn][cmn] != -1 && dfs(r, c + 1)) return true;       rmn = rem(r + 1, n), cmn = rem(c, m);       if (maze[rmn][cmn] != -1 && dfs(r + 1, c)) return true;       rmn = rem(r - 1, n), cmn = rem(c, m);       if (maze[rmn][cmn] != -1 && dfs(r - 1, c)) return true;     }     return false;   }   void TheSolution(istream& input, ostream& output) {     input >> n >> m;     string s;     memset(maze, -1, sizeof(maze));     for (int i = 0; i < n; i++) {       input >> s;       for (int j = 0; j < m; j++) {         if (s[j] ==  . ) maze[i][j] = 0;         if (s[j] ==  S ) {           sr = i;           sc = j;           maze[i][j] = 0;         }         was[i][j] = pair<int, int>(-1000000, -1000000);       }     }     output << (dfs(sr, sc) ?  Yes  :  No );   }   int main() {     TheSolution(cin, cout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   struct node {     int cnt;     node* bit[3];     node() {       bit[0] = bit[1] = NULL;       cnt = 0;     }   };   node* root;   void Insertt(int x) {     node* cur = root;     for (int i = 28; i >= 0; --i) {       if (cur->bit[(x >> i) & 1] == NULL) cur->bit[(x >> i) & 1] = new node();       cur = cur->bit[(x >> i) & 1];       ++(cur->cnt);     }   }   void Erasee(int x) {     node* cur = root;     for (int i = 28; i >= 0; --i) {       --(cur->bit[(x >> i) & 1]->cnt);       if (cur->bit[(x >> i) & 1]->cnt == 0) {         cur->bit[(x >> i) & 1] = NULL;         return;       } else         cur = cur->bit[(x >> i) & 1];     }   }   int Query(int p, int l) {     int res = 0;     node* cur = root;     for (int i = 28; i >= 0; --i) {       if (((l >> i) & 1) == 0) {         if (cur->bit[(p >> i) & 1] != NULL)           cur = cur->bit[(p >> i) & 1];         else           return res;       } else {         if (cur->bit[(p >> i) & 1] != NULL) res += cur->bit[(p >> i) & 1]->cnt;         if (cur->bit[(1 ^ ((p >> i) & 1))] != NULL)           cur = cur->bit[(1 ^ ((p >> i) & 1))];         else           return res;       }     }     return res;   }   int main() {     scanf( %d , &n);     root = new node();     for (int i = 1; i <= n; ++i) {       int type, p, l;       scanf( %d%d , &type, &p);       if (type == 1) Insertt(p);       if (type == 2) Erasee(p);       if (type == 3) {         scanf( %d , &l);         printf( %d n , Query(p, l));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long labs(long long a) { return a < 0 ? (-a) : a; }   long long max(long long a, long long b) { return a > b ? a : b; }   long long min(long long a, long long b) { return a < b ? a : b; }   struct Fenwik {     vector<long long> t;     long long n;     void Init(long long nn) {       n = nn;       t.assign(n, 0);     }     long long Sum(long long r) {       long long result = 0;       for (; r >= 0; r = (r & (r + 1)) - 1) result += t[r];       return result;     }     void Inc(long long i, long long delta) {       for (; i < n; i = (i | (i + 1))) t[i] += delta;     }     long long Sum(long long l, long long r) { return Sum(r) - Sum(l - 1); }     void Init(const vector<long long>& a) {       Init(a.size());       for (int(i) = 0; (i) < (n); (i)++) Inc(i, a[i]);     }   };   vector<Fenwik> f;   vector<int> g;   vector<int> gn;   long long gs;   map<long long, pair<int, int> > ids;   long long h, m, n;   long long gt;   long long F(long long x) {     long long pos = (gn[gt] + x) % gs;     long long sum = 0;     if (pos < gn[gt]) {       sum = f[g[gt]].Sum(gn[gt], gs - 1) + f[g[gt]].Sum(0, pos);     } else {       sum = f[g[gt]].Sum(gn[gt], pos);     }     return x + 1 - sum;   }   long long UpperBound(long long l, long long r, long long f) {     while (l < r) {       long long m = (l + r) / 2;       if (!(f < F(m))) {         l = m + 1;       } else {         r = m;       }     }     return l;   }   long long res = 0;   void Add(long long id, long long t) {     gt = t;     long long lb = UpperBound(0, gs - 1, 0);     res += lb;     long long gg = g[t];     long long nn = (gn[t] + lb) % gs;     f[gg].Inc(nn, 1);     ids[id] = make_pair(gg, nn);   }   void Delete(long long id) { f[ids[id].first].Inc(ids[id].second, -1); }   int main() {     cin >> h >> m >> n;     g.resize(h, -1);     gn.resize(h, 0);     long long group = 0;     for (int(i) = 0; (i) < (h); (i)++) {       if (g[i] != -1) continue;       g[i] = group;       gs = 1;       for (long long j = 1; (i + j * m) % h != i; j++) {         g[(i + j * m) % h] = group;         gn[(i + j * m) % h] = j;         gs = j + 1;       }       group++;     }     f.resize(group);     for (int(i) = 0; (i) < (group); (i)++) {       f[i].Init(gs);     }     char c;     long long id;     long long t;     for (int(i) = 0; (i) < (n); (i)++) {       cin >> c >> id;       if (c ==  + ) {         cin >> t;         Add(id, t);       } else {         Delete(id);       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7;   const int MAXN = 1e6 + 7;   const double EPS = 1e-8;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     vector<long long> cnt(m, 0);     long long d = n % m;     for (long long i = 0; i < m; i++) {       cnt[i * i % m] += n / m;       if (i && i <= d) {         cnt[i * i % m]++;       }     }     long long res = 0;     for (long long i = 0; i < m; i++) {       res += cnt[i] * cnt[(m - i) % m];     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   char buffer[200];   int main() {     int n;     string data;     while (scanf( %d , &n) != EOF) {       getchar();       for (int i = 0; i < n; i++) {         gets(buffer);         data = string(buffer);         int firstM = data.find( miao. );         int lastL = data.rfind( lala. );         if (firstM != data.npos &&             (lastL == data.npos || lastL != data.size() - 5) && firstM == 0) {           printf( Rainbow s n );         } else if ((firstM == data.npos || firstM != 0) && lastL != data.npos &&                    lastL == data.size() - 5) {           printf( Freda s n );         } else {           printf( OMG>.< I don t know! n );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const long double PI = 3.1415926535898;   const long long LLMAX = LLONG_MAX;   int a[(int)2e5 + 5], b[(int)2e5 + 5], c[(int)2e5 + 5];   int n;   vector<vector<int> > v((int)2e5 + 5);   int type10 = 0;   int type01 = 0;   long long ans = 0;   int one[(int)2e5 + 5] = {0};   int zero[(int)2e5 + 5] = {0};   void solve(int parent, int node) {     if (b[node] != c[node]) {       if (b[node])         one[node]++;       else         zero[node]++;     }     if (parent) a[node] = min(a[node], a[parent]);     for (int i = 0; i < v[node].size(); i++) {       if (v[node][i] == parent)         continue;       else {         solve(node, v[node][i]);         one[node] += one[v[node][i]];         zero[node] += zero[v[node][i]];       }     }     int dec = min(one[node], zero[node]);     one[node] -= dec;     zero[node] -= dec;     ans += (long long)a[node] * 2 * dec;   }   int main() {     int x, y;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i] >> b[i] >> c[i];       if (b[i] == 0 && c[i] == 1)         type01++;       else if (b[i] == 1 && c[i] == 0)         type10++;     }     for (int i = 1; i < n; i++) {       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     solve(0, 1);     if (type01 != type10) {       cout << -1 <<   n ;     } else {       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long a, b;   int main() {     cin >> a >> b;     long long ans = (b * (b - 1)) / 2;     ans %= 1000000007;     ans =         (a * ans + ((b * ans) % 1000000007) * ((a * (a + 1) / 2) % 1000000007)) %         1000000007;     cout << ans;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define mp make_pair   #define fi first   #define se second   #define pb push_back   #define pf push_front   #define ppb pop_back   #define ppf pop_front   #define sz(v) (v).size()   #define all(v) (v).begin(),(v).end()   #define REP(i,a,b) for(int (i)=(a);(i)<(b);(i)++)   #define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)   #define Time (double)clock()/CLOCKS_PER_SEC   typedef long long ll;   typedef unsigned long long ull;   typedef double db;   typedef long double ldb;   typedef pair<int,int> pi;   template <class T> void chmax(T &x,T y) {x=x>y?x:y;return;}   template <class T> void chmin(T &x,T y) {x=x<y?x:y;return;}   template <class T> T sqr(T x) {return x*x;}   template <class T> T gcd(T x,T y) {return y==0?x:gcd(y,x%y);}   template <class T> T lcm(T x,T y) {return x/gcd(x,y)*y;}   const int inf=1000000000,mod=1000000007;   const ll infll=1000000000000000000ll,modll=ll(mod);   const db maxdb=db(infll),eps=1e-14,PI=acos(-1.0);   //#define mydef   //#define LOCAL   #ifdef mydef   #define foreach(v,it) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)   #endif   #define debug   #define putnum(x) cout<<#x<< :  <<x<<endl   #define putvec(v) cout<<#v<< :  ;REP(i,0,sz(v)) cout<<v[i]<<   ;cout<<endl   template <class T> inline void read(T &x){    T w=1;x=0;char c=getchar();    while(c< 0 ||c> 9 ) {if(c== - )w=-1;c=getchar();}    while(c>= 0 &&c<= 9 ) {x=(x<<3)+(x<<1)+(c&15);c=getchar();}    x*=w;   }   template <class T> inline void write(T x) {    if(x<0) putchar( - ),x=~x+1;    if(x) write(x/10),putchar(x%10+ 0 );   }      const int maxn=200005;   int n;   ll sum[2],a[maxn];   vector<ll> odd,even;      void solve() {    odd.clear();    even.clear();    cin>>n;    for(int i=1;i<=n;i++) {     cin>>a[i];     if(a[i]&1ll) odd.pb(a[i]);     else even.pb(a[i]);    }    sort(all(odd));    sort(all(even));        sum[0]=sum[1]=0ll;    int p=0;    for(int i=0;i<n;i++) {     ll A=even.empty()?-infll:even.back();     ll B=odd.empty()?-infll:odd.back();       if(A>B) {      if(!p) sum[p]+=A;      even.ppb();     } else {      if(p) sum[p]+=B;      odd.ppb();     }     p^=1;    }    cout<<(sum[0]>sum[1]? Alice :(sum[0]==sum[1]? Tie : Bob ))<<endl;    return;   }      int main() {    #ifdef LOCAL     freopen( input.in , r ,stdin);     freopen( output.out , w ,stdout);    #endif    int T;    cin>>T;    while(T--) solve();    return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using vi = vector<int>;   using vpi = vector<pair<int, int>>;   using pi = pair<int, int>;   const int nax = 1e5 + 7;   const int mod = 1e9 + 7;   const int inf = numeric_limits<int>::max() - (int)9e6;   struct monotonic_queue {     queue<int> qu;     deque<int> mx, mn;     void push(int v) {       qu.push(v);       while (mx.size() && mx.back() < v) mx.pop_back();       mx.push_back(v);       while (mn.size() && mn.back() > v) mn.pop_back();       mn.push_back(v);     }     void pop() {       if (mx.front() == qu.front()) mx.pop_front();       if (mn.front() == qu.front()) mn.pop_front();       qu.pop();     }     int front() const { return qu.front(); }     int max() const { return mx.front(); }     int min() const { return mn.front(); }     int size() const { return qu.size(); }     bool empty() { return qu.empty(); }   };   int n;   void test() {     cin >> n;     int s, l;     cin >> s >> l;     vi v(n);     for (int i = 0; i < (int)n; i++) cin >> v[i];     monotonic_queue q;     vi g(n, n);     for (int i = n - 1, j = n - 1; i >= 0; i--) {       while (j >= 0 and (q.empty() or (((q.max() - q.min()) <= s)))) {         q.push(v[j--]);       }       g[i] = (((q.max() - q.min()) <= s) ? j : j + 1);       if (((int)(q).size())) q.pop();     }     while (((int)(q).size())) q.pop();     vi dp(n + 1, inf);     dp[0] = 0;     for (int i = l, j = 0; i <= n; i++) {       q.push(dp[i - l]);       while (((int)(q).size()) and j <= g[i - 1]) q.pop(), j++;       if (((int)(q).size())) dp[i] = q.min() + 1;     }     cout << (dp[n] >= inf ? -1 : dp[n]);   }   signed main() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     while (T--) {       test();       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int a[20];   long long ans, p[] = {1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29}, limit = 1e18;   void dfs(int num, int len) {     if (num == 1) {       long long res = 1;       for (int i = 1; i <= len; ++i) {         for (int j = 1; j < a[i]; ++j) {           if (limit / p[i] <= res) {             return;           }           res *= p[i];         }       }       ans = min(ans, res);       return;     }     for (int i = 2; i <= num; ++i) {       if (num % i == 0) {         a[len + 1] = i;         dfs(num / i, len + 1);       }     }   }   int main() {     int n;     cin >> n;     if (n == 1) {       cout << 1 << endl;       return 0;     } else if (n == 2) {       cout << 2 << endl;       return 0;     }     ans = limit;     for (int i = 1; i <= n; ++i) {       if (n % i == 0) {         a[1] = i;         dfs(n / i, 1);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, T;   int l[200010], r[200010], s[200010], t[200010], id[200010];   int f[1010][1010];   int ans[200010];   int x[200010], y[200010];   inline int cmp(int x, int y) { return l[x] > l[y]; }   int main() {     scanf( %d%d%d , &n, &m, &T);     for (int i = 1; i <= m; i++) scanf( %d%d , &x[i], &y[i]);     for (int i = 1; i <= T; i++)       scanf( %d%d%d%d , &l[i], &r[i], &s[i], &t[i]), id[i] = i;     sort(id + 1, id + T + 1, cmp);     memset(f, 63, sizeof(f));     int last = 1;     for (int i = m; i; i--) {       f[x[i]][y[i]] = f[y[i]][x[i]] = i;       for (int j = 1; j <= n; j++) {         f[x[i]][j] = min(f[x[i]][j], f[y[i]][j]);         f[y[i]][j] = min(f[y[i]][j], f[x[i]][j]);       }       while (last <= T && l[id[last]] == i) {         int u = id[last++];         ans[u] = f[s[u]][t[u]] <= r[u];       }     }     for (int i = 1; i <= T; i++) puts(ans[i] ?  Yes  :  No );   }