#include using namespace std; using ll=long long int; struct Bigint { string a; int sign; Bigint(){} void operator = (string b) { a= (b[0]=='-' ? b.substr(1) : b); reverse(a.begin(), a.end()); (*this).Remove0(b[0]=='-' ? -1 : 1); } Bigint(string x) {(*this)=x;} Bigint(ll x) {(*this)=to_string(x);} void operator = (ll x){*this=to_string(x);} char operator[](int i){return a[i];} int size() {return a.size();} Bigint inverseSign() {sign*=-1; return (*this);} Bigint Remove0(int newSign) { sign = newSign; for(int i=a.size()-1; i>0 && a[i]=='0'; i--) a.pop_back(); if(a.size()==1 && a[0]=='0') sign=1; return (*this); } bool operator == (Bigint x) {return sign==x.sign && a==x.a;} bool operator == (string x) {return *this==Bigint(x);} bool operator == (ll x) {return *this==Bigint(x);} bool operator != (Bigint x) {return !(*this==x);} bool operator != (string x) {return !(*this==x);} bool operator != (ll x) {return !(*this==x);} bool operator < (Bigint b) { if (sign!=b.sign) return sign=0; i--) if(a[i] != b[i]) return a[i] (Bigint b) {return !(*this==b || *this (string x) {return !(*this==x || *this (ll b) {return !(*this==b || *this= (Bigint b) {return *this==b || *this>b;} bool operator >= (string b) {return *this==b || *this>b;} bool operator >= (ll b) {return *this==b || *this>b;} Bigint operator + (Bigint b) { if(sign != b.sign) return (*this)-b.inverseSign(); Bigint sum; for(int i=0, carry=0; i=0 ? borrow+'0' : borrow + 58; borrow = borrow>=0 ? 0:1; } return sub.Remove0(sign); } Bigint operator - (string x) {return *this-Bigint(x);} Bigint operator - (ll x) {return *this-Bigint(x);} Bigint operator -- (int) {*this-=1; return *this+1;} Bigint operator -- () {*this-=1; return *this;} void operator -= (Bigint x) {*this = *this-x;} void operator -= (string x) {*this = *this-x;} void operator -= (ll x) {*this = *this-x;} Bigint operator * (Bigint b) { Bigint mult("0"); for(int i=0, k=a[i]; i=0; i--) { c.a.insert(c.a.begin(),'0'); c=c+a.substr(i,1); while(!(c=0; i-- ) { c.a.insert( c.a.begin(),'0'); c = c+a.substr(i,1); while(!(c=0; i--) putchar(a[i]); } friend istream& operator >>(istream &in,Bigint &x){ string s; in>>s; x=s; return in; } friend ostream& operator <<(ostream &out,Bigint &x){ if(x.sign==-1) putchar('-'); for(int i=x.size()-1; i>=0; i--) putchar(x[i]); return out; } friend Bigint pow(Bigint base, Bigint pw){ Bigint ans=1; while(pw!=0){ if(pw%2 !=0) ans*=base; base*=base, pw/=2; } return ans; } friend Bigint pow(Bigint a, Bigint b,Bigint mod) { if (b==0) return Bigint(1); Bigint tmp=pow(a,b/2,mod); if ((b%2)==0) return (tmp*tmp)%mod; else return (((tmp*tmp)%mod)*a)%mod; } friend Bigint sqrt(Bigint x) { Bigint ans=x,tmp=(x+1)/2; while (tmp> s; Bigint res = 0; std::random_device rd; std::mt19937 g(rd()); sort(s.begin(),s.end()); res = s; reverse(s.begin(),s.end()); res = gcd(res,Bigint(s)); for(int i=0;i<3;i++) { std::shuffle(s.begin(), s.end(), g); res = gcd(res,Bigint(s)); } cout << res; return 0; }