{"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\n\nint main()\n{\n long long int n,k,ans,i,j;\n\n scanf(\"%lld%lld\",&n,&k);\n\n if(k==0){\n printf(\"%lld\\n\",n);\n\n }\n else if(k==1)\n {\n ans=0;\n for(i=1; ;i++){\n ans+=10;\n if(ans%n==0){\n printf(\"%lld\\n\",ans);\n return 0;\n }\n }\n }\n\n else if(k==2)\n {\n ans=0;\n for(i=1; ;i++){\n ans+=100;\n if(ans%n==0){\n printf(\"%lld\\n\",ans);\n return 0;\n }\n }\n }\n else if(k==3)\n {\n ans=0;\n for(i=1; ;i++){\n ans+=1000;\n if(ans%n==0){\n printf(\"%lld\\n\",ans);\n return 0;\n }\n }\n }\n else if(k==4)\n {\n ans=0;\n for(i=1; ;i++){\n ans+=10000;\n if(ans%n==0){\n printf(\"%lld\\n\",ans);\n return 0;\n }\n }\n }\n else if(k==5)\n {\n ans=0;\n for(i=1; ;i++){\n ans+=100000;\n if(ans%n==0){\n printf(\"%lld\\n\",ans);\n return 0;\n }\n }\n }\n else if(k==6)\n {\n ans=0;\n for(i=1; ;i++){\n ans+=1000000;\n if(ans%n==0){\n printf(\"%lld\\n\",ans);\n return 0;\n }\n }\n }\n else if(k==7)\n {\n ans=0;\n for(i=1; ;i++){\n ans+=10000000;\n if(ans%n==0){\n printf(\"%lld\\n\",ans);\n return 0;\n }\n }\n }\n else if(k==8)\n {\n ans=0;\n for(i=1; ;i++){\n ans+=100000000;\n if(ans%n==0){\n printf(\"%lld\\n\",ans);\n return 0;\n }\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c301530c8ed91fb9f057b59abe7bcdce", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "Clang++17 Diagnostics", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n \n int x;\n int n = 0;\n int a = 0;\n cin >> x;\n int g[x];\n \n for (int i = 0; i < x; i++)\n {\n \t\n \tif (i%2 != 0)\n\t {\n\t \t a += 1;\n\t \tg[i] = a;\n\t }\n \telse if (i%2 == 0)\n \t{\n \t\ta += 1;\n \t\tg[i] = -a;\n\t }n += g[i];\n\t \n }\n \n cout << n;\n \n return 0;\n}\n\t \n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ef65458c3b1d543ec646b94e4a4a1ffc", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#define MOD 1000000009\n#define MAX_N 4096\nusing namespace std;\ntypedef long long ll;\nint n, w, b;\nll fact[MAX_N], inv[MAX_N];\nll quick_pow(ll a, int k)\n{\n int ans = 1;\n while (k > 0)\n {\n if (k & 1)\n ans = (ans * a) % MOD;\n k >>= 1;\n a = (a * a) % MOD;\n }\n return ans % MOD;\n}\nvoid init()\n{\n fact[0] = 1;\n inv[0] = 1;\n for (int i = 1; i <= MAX_N; i++)\n {\n fact[i] = fact[i - 1] * i % MOD;\n inv[i] = quick_pow(fact[i], MOD - 2);\n }\n}\nll C(ll M, ll N)\n{\n if (M < N)\n return 1;\n return inv[M] * fact[N] % MOD * fact[M - N] % MOD;\n}\nvoid work()\n{\n ll ans = 0;\n for (int i = 2; i < n; i++)\n {\n for (int j = i; j < n; j++)\n {\n ans = (ans + C(j - i + 1, b) * C(n - (j - i + 1), w) % MOD) % MOD;\n }\n }\n cout << ans * fact[w] % MOD * fact[b] % MOD << endl;\n}\nint main()\n{\n ios::sync_with_stdio(false);\n#ifndef ONLINE_JUDGE\n freopen(\"306C.in\", \"r\", stdin);\n#endif\n cin >> n >> w >> b;\n init();\n work();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b420075a5f46f7ffa520d7fbad7ff06a", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include\n\n#define ll long long\n#define dl long long double\n#define SIZE 100000001 \n#define INF 0x7fffffff\n#define MOD1 1000000009\n#define MOD2 1000000007\n#define TEST(t) ll t; cin>>t; while(t--) \n#define MINV(v) *min_element(v.begin(),v.end()) \n#define MAXV(v) *max_element(v.begin(),v.end()) \n#define MINA(a,n) *min_element(a,a+n) \n#define MAXA(a,n) *max_element(a,a+n) \n#define rep(i,a,b) for(int i=a;i\n#define LL long long\n#define endl \"\\n\"\n\nusing namespace std ;\n \n//\ntemplate < typename T >\n\ninline T read( T &x )\n{\n\n x = 0 ;\n\n int f = 0 ;\n\n char ch = getchar() ;\n\n while( ch < '0' || ch > '9' ) {\n\n f |= ( ch == '-' ) , ch = getchar() ;\n\n }\n\n while( ch >= '0' && ch <= '9' ) {\n\n x = ( x << 1 ) + ( x << 3 ) + ch - '0' , ch = getchar() ;\n\n }\n\n return x = f ? -x:x ;\n\n}\n//\n\nint main( void )\n\n{\n\n //ios_base::sync_with_stdio( false ) ; cin.tie( NULL ) ; cout.tie( NULL ) ;\n\n #ifndef ONLINE_JUDGE\n freopen( \"input.txt\" , \"r\" , stdin ) ;\n freopen( \"output.txt\" , \"w\" , stdout ) ;\n #endif\n\n int n , m ;\n\n cin >> n >> m ;\n\n \n if(m==0) cout << 1 << '\\n' ;\n\n else if( m < n/2 ) cout << m << endl ;\n\n \n\n else cout << (n-m) << endl ;\n\n #ifndef ONLINE_JUDGE\n cout << \"\\nTime Elapsed: \" << 1.0*clock()/CLOCKS_PER_SEC << \" sec\\n\" ;\n #endif\n\n return 0 ;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b7fa3c40fca7a1053e0d3615d2ba2725", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0} {"lang": "GNU C++0x", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int n,m; cin >> n >> m;\n int sum = 0;\n int f = m;\n\n while(n--){\n int tmp; cin >> tmp;\n f = f-tmp;\n if(f < 0){\n\n sum+=1;\n f = m-tmp;\n }\n else if(f == 0){\n\n sum+=1;\n f = m;\n }\n if(n == 0 && f == m-tmp)\n sum++;\n\n\n }\n\n cout << sum;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d13c718f5895c5e16a5a3d49dbe582da", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n/*\n#include \n\n#include \n\n\n#include \n#include \n#include \n\n*/\n\n//#pragma warning(disable:4786)\n//#pragma comment(linker, \"/STACK:336777216\")\nusing namespace std;\n\n#define mp make_pair\n\n/*\ntypedef tuple t3;\n\ntypedef unsigned long long ull;\ntypedef double db;\ntypedef long double ldb;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pli;\ntypedef pair pdd;\n\nint MOD = 1000000007;\n\nconst ll LL_INF = 0x3f3f3f3f3f3f3f3f;\nconst db PI = acos(-1);\nconst db ERR = 1e-10;\n\n\n */\n#define Se second\n#define Fi first\n#define all(x) (x).begin(), (x).end()\n#define forn(i, n) for(int i=0;iy) x = x-y;\n else y=y-x;\n\n }\n return x;\n}\n*/\n\nint main()\n{\n\n ll n,d,m,l,pos;\n cin>>n>>d>>m>>l;\n ll k=1; //\u677f\u5b50\n ll c=1; //\u6b65\u6570\n\n\n while(true)\n {\n if(k(k-1)*m+l && d*c=(k-1)*m && d*c<=(k-1)*m+l)\n {\n c+= ((k-1)*m+l-d*c)/d+1;\n }\n if(d*c>=k*m)\n {\n k+= (d*c-k*m)/m+1;\n }\n }\n else\n {\n if(d*c>(k-1)*m+l)\n {\n cout<\nusing namespace std;\nchar now,fst=0;\nint g=1,ans=0;\nint main()\n{\n now=getchar();\n while(now=='A'||now=='T'||now=='G'||now=='C')\n {\n if(now==fst) ++g;\n else {if(g%2==0) ++ans;g=1;fst=now;}\n }\n printf(\"%d\\n\",ans);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "caf04844ac1242576a9914aa4aed0238", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n#define sc scanf\n#define pr printf\n#define lld I64d\nint main()\n{\n freopen(\"in.txt\",\"r\",stdin);\n freopen(\"out.txt\",\"w\",stdout);\n int n;\n scanf(\"%d\",&n);\n char a[201];\n scanf(\" %s\",a);\n int r=0,g=0,b=0,i;\n for(i=0;i=2 and g>=2)or(b>=2 and r>=2)or(r>=2 and g>=2)) printf(\"BGR\");\n else if(b==0 and g==0) printf(\"R\");\n else if(b==0 and r==0) printf(\"G\");\n else if(g==0 and r==0) printf(\"B\");\n\n else if(b==1 and g>=2) printf(\"BR\");\n else if(g==1 and b>=2) printf(\"GR\");\n else if(b==1 and r>=2) printf(\"BG\");\n else if(r==1 and b>=2) printf(\"GR\");\n else if(g==1 and r>=2) printf(\"BG\");\n else if(r==1 and g>=2) printf(\"BR\");\n\n else if(b==1 and g==1) printf(\"R\");\n else if(b==1 and r==1) printf(\"G\");\n else if(g==1 and r==1) printf(\"B\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "01e565d6666efc36a04378272587a50d", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include\n#define int int long long\n#define pb push_back\n#define pii pair\n#define vi\t vector\n#define mii map\n#define fs first\n#define sc second\n#define M 1000000001\n#define f(i,a,b) for(int i=a;ib;i--)\n \nusing namespace std;\nbool c[M];\n\nsigned main()\n{\t//freopen(\"input.txt\",\"r\",stdin);\n\t//freopen(\"output.txt\",\"w\",stdout);\n ios_base::sync_with_stdio(false);\n cin.tie(0);cout.tie(0);\n int test=1;\n int n;\n cin>>n;\n for(int i=0;i*i<=n;i++){\n \tint j=i,s=0;\n \twhile(j){\n \t\ts+=j%10;\n \t\tj/=10;\n \t}\n \tif(i*i+s*i==n) {\n \t\tcout<\n#define ll long long \nusing namespace std;\nll power(ll a,ll n){\n ll ans = 1;\n while(n){\n if(n&1) ans = ans * a;\n a = a*a;\n n>>=1;\n }\n return ans ;\n}\nint main(){\n ll n,ans;\n cin>>n;\n ans = 2*3*4*power(4,n-3)+3*3*4*power(4,n-4);\n return cout<\n#include \nusing namespace std;\n\nint main()\n{\n int n,m,k;\n while(~scanf(\"%d%d%d\",&n,&m,&k)!=EOF)\n {\n if(n<=m && n<=k)\n {\n printf(\"Yes\\n\");\n }\n else{\n printf(\"No\\n\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "11caacf9ee30eb4538e350fa04cfea5a", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "//#pragma GCC optimize(2)\n//#pragma GCC optimize(3)\n//#pragma GCC optimize(4)\n//#pragma GCC optimize(\"unroll-loops\")\n//#pragma comment(linker, \"/stack:200000000\")\n//#pragma GCC optimize(\"Ofast,no-stack-protector\")\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#include\n#define fi first\n#define se second\n#define db double\n#define mp make_pair\n#define pb push_back\n#define pi acos(-1.0)\n#define ll long long\n#define vi vector\n#define mod 1000000007\n#define ld long double\n//#define C 0.5772156649\n//#define ls l,m,rt<<1\n//#define rs m+1,r,rt<<1|1\n#define pll pair\n#define pil pair\n#define pli pair\n#define pii pair\n#define ull unsigned long long\n//#define base 1000000000000000000\n#define fin freopen(\"a.txt\",\"r\",stdin)\n#define fout freopen(\"a.txt\",\"w\",stdout)\n#define fio ios::sync_with_stdio(false);cin.tie(0)\ninline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}\ninline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}\ninline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}\ntemplateinline T const& MAX(T const &a,T const &b){return a>b?a:b;}\ntemplateinline T const& MIN(T const &a,T const &b){return a>=1;}return ans;}\ninline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c,b>>=1;}return ans;}\n\nusing namespace std;\n\nconst ull ba=233;\nconst db eps=1e-5;\nconst ll INF=0x3f3f3f3f3f3f3f3f;\nconst int N=100+10,maxn=1000000+10,inf=0x3f3f3f3f;\n\nint dcmp(double x) {\n if(fabs(x) < eps) return 0;\n else return x < 0 ? -1 : 1;\n}\n\nstruct Point {\n double x, y;\n Point(double x = 0, double y = 0) : x(x), y(y) {}\n};\n\ntypedef Point Vector;\n\nstruct Circle {\n Point c;\n double r;\n Circle(){}\n Circle(Point c, double r):c(c),r(r){}\n Point point(double a){\n return Point{c.x+cos(a)*r,c.y+sin(a)*r};\n }\n};\nPoint operator + (Vector A, Vector B) {return Point(A.x + B.x, A.y + B.y);}\nPoint operator - (Vector A, Vector B) {return Point(A.x - B.x, A.y - B.y);}\nPoint operator * (Vector A, double p) {return Point(A.x * p, A.y * p);}\nPoint operator / (Vector A, double p) {return Point(A.x / p, A.y / p);}\nbool operator < (const Vector &A, const Vector &B) {return A.y < B.y || (A.y == B.y && A.x < B.x);}\nbool operator == (const Vector &A, const Point &B) {return dcmp(A.x - B.x) == 0 && dcmp(A.y - B.y) == 0;}\ndouble Dot(Vector A, Vector B) {return A.x * B.x + A.y * B.y;}\ndouble Length(Vector A) {return sqrt(Dot(A, A));}\ndouble Angle(Vector A, Vector B) {return acos(Dot(A, B)/Length(A)/Length(B));}\ndouble Cross(Vector A, Vector B) {return A.x * B.y - A.y * B.x;}\ndouble Area2(Point A, Point B, Point C) {return Cross(B-A, C-A);}\ndouble angle(Vector v){return atan2(v.y,v.x);}\nint getCircleCircleIntersection(Circle C1,Circle C2,vector&sol)\n{\n double d = Length(C1.c-C2.c);\n if(dcmp(d)==0){\n if(dcmp(C1.r-C2.r)==0)return 1;//\u91cd\u5408\n return 0;\n }\n if(dcmp(C1.r+C2.r-d)<0)return 0;\n if(dcmp(fabs(C1.r-C2.r)-d)>0)return 0;\n double a = angle(C2.c-C1.c);\n double da = acos((C1.r*C1.r+d*d-C2.r*C2.r)/(2*C1.r*d));\n Point p1=C1.point(a-da),p2=C1.point(a+da);\n sol.push_back(p1);\n if(p1==p2)return 1;\n sol.push_back(p2);\n return 2;\n}\nint fa[N];\ninline int Find(int x){return fa[x]==x?x:fa[x]=Find(fa[x]);}\nint main()\n{\n Circle c[3];\n vectorv[3],te;\n int n;scanf(\"%d\",&n);\n if(n==1)return 0*puts(\"2\");\n if(n==2)\n {\n scanf(\"%lf%lf%lf\",c[0].c.x,c[0].c.y,c[0].r);\n scanf(\"%lf%lf%lf\",c[1].c.x,c[1].c.y,c[1].r);\n getCircleCircleIntersection(c[0],c[1],te);\n if(te.size()==2)puts(\"4\");\n else puts(\"3\");\n return 0;\n }\n for(int i=0;i<3;i++)scanf(\"%lf%lf%lf\",&c[i].c.x,&c[i].c.y,&c[i].r),fa[i+1]=i+1;\n for(int i=0;i<3;i++)for(int j=i+1;j<3;j++)\n {\n te.clear();\n getCircleCircleIntersection(c[i],c[j],te);\n for(auto x:te)v[i].pb(x),v[j].pb(x);\n if(te.size()!=0)\n {\n int a=Find(i+1),b=Find(j+1);\n if(a!=b)fa[a]=b;\n }\n }\n te.clear();\n int C=0,V=0,E=0;\n for(int i=0;i<3;i++)\n {\n sort(v[i].begin(),v[i].end());\n v[i].erase(unique(v[i].begin(),v[i].end()),v[i].end());\n for(auto x:v[i])te.pb(x);\n if(fa[i+1]==i+1)C++;\n if(v[i].size()!=0)E+=v[i].size();\n }\n sort(te.begin(),te.end());\n te.erase(unique(te.begin(),te.end()),te.end());\n V=te.size();\n printf(\"%d\\n\",C+1-V+E);\n return 0;\n}\n/********************\n\n********************/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "50a96211f137b07f83ef745b957536b3", "src_uid": "bda5879e94a82c6fd499796f258c4691", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n#define M 28\n\nint nim[35] = {0, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12};;\n///int nim[35] = {0, 1};\nint u[1<20){\n\t\t puts(\"ERR\");\n\t\t}\n\t}\n\tfor(n=1; n<=M; n++) nim[n] = u[(1<\n#include \n#include\n#include\n#include \n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include\n#include \n#include\n#include \n#include \n#include\n#include \n#include \n#include\n#include\n#include \n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include\n#include\n#include \n#include \n#include\n#include \n#include \n#include \n#include\n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \nusing namespace std;\n\n#define start ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);\n#define nl endl;\n#define end system(\"pause\");\n#define sz(v) ((int)((v).size()))\n#define sc(x) scanf(\"%d\",&x)\n#define sc2(x,y) scanf(\"%d%d\",&x,&y)\n#define sc3(x,y,z) scanf(\"%d%d%d\",&x,&y,&z)\n#define sc4(x,y,z,a) scanf(\"%d%d%d%d\",&x,&y,&z,&a)\n#define sc5(x,y,z,a,b) scanf(\"%d%d%d%d%d\",&x,&y,&z,&a,&b)\n#define sc6(x,y,z,a,b,c) scanf(\"%d%d%d%d%d%d\",&x,&y,&z,&a,&b,&c)\n#define scl(x) scanf(\"%lld\",&x)\n#define lp(i,n) for(int i=0;i ii;\ntypedef pair si;\ntypedef pair is;\ntypedef pair chi;\ntypedef pair SS;\ntypedef vector vii;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vs;\ntypedef vector vll;\ntypedef vector vvll;\n\nll pw(ll b, ll p){ if (!p) return 1; ll sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }\nll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }\nll sd(ll x) { return x<10 ? x : x % 10 + sd(x / 10); }\nll lcm(ll a, ll b){ return ((a*b) / gcd(a, b)); }\nchar g[10000][10000];\nint vis[10000][10000];\nint dx[8]={1 , -1,-1 ,1 , 0 , 0 , 1 , -1 };\nint dy[8]={1 , -1 ,1, -1 , -1, 1 , 0 , 0 };\nint k=INT_MAX;\nset > pts;\nvoid dfs(int x1,int y1,int x2,int y2,int n)\n{\n\tif(x1==x2&&y1==y2)\n\t{\n\t\tk=min(k,n);\n\t\treturn;\n\t}\n\tif(vis[x1][y1]==1)\n\t\treturn;\n\tvis[x1][y1]=1;\n\tfor(int i=0;i<8;i++)\n\t{\n\t\tint cx=x1+dx[i];\n\t\tint cy=y1+dy[i];\n\t\tif(cx<=100000&&cy<=100000&&cx>=0&&cy>=0&&g[cx][cy]=='x')\n\t\t\t\tdfs(cx,cy,x2,y2,n+1);\n\t}\n\treturn;\n}\nint m[1000001],m1[1000001],m2[1000001];\nint main()\n{\n\t//start;\n\tint n;\n\tcin>>n;\n\tint k=n,k1=n-1,k2=n-2,h=2;\n\twhile(k>1)\n\t{\n\t\tif(k%h==0)\n\t\t{\n\t\t\tm[h]++;\n\t\t\tk/=h;\n\t\t\th=2;\n\t\t}\n\t\telse\n\t\t\th++;\n\t}\n\th=2;\n\twhile(k1>1)\n\t{\n\t\tif(k1%h==0)\n\t\t{\n\t\t\tif(m[h]>0)\n\t\t\t\tm[h]--;\n\t\t\telse\n\t\t\t\tm1[h]++;\n\t\t\tk1/=h;\n\t\t\th=2;\n\t\t}\n\t\telse\n\t\t\th++;\n\t}\n\th=2;\n\twhile(k2>1)\n\t{\n\t\tif(k2%h==0)\n\t\t{\n\t\t\tif(m[h]>0)\n\t\t\t\tm[h]--;\n\t\t\telse if(m1[h]>0)\n\t\t\t\tm1[h]--;\n\t\t\telse\n\t\t\t\tm2[h]++;\n\t\t\tk2/=h;\n\t\t\th=2;\n\t\t}\n\t\telse\n\t\t\th++;\n\t}\n\tlong long ans=1;\n\tfor(int i=2;i0)\n\t\t\tans*=(pow((double)i,m[i]));\n\t\tif(m1[i]>0)\n\t\t\tans*=(pow((double)i,m1[i]));\n\t\tif(m2[i]>0)\n\t\t\tans*=(pow((double)i,m2[i]));\n\t}\n\tcout<\n\nusing namespace std;\n\nint main()\n{\n int n ;\n int min , max ;\n cin >> n ;\n int num = n ;\n int x = 2 ;\n int y = 1 ;\n while (num > 0){\n if (x % 2 == 0){\n max += 2 ;\n num -= 2 ;\n }\n else {\n num -= 5 ;\n }\n x++ ;\n }\n while (n > 0){\n if (y % 2 == 0){\n min += 2 ;\n num -= 2 ;\n }\n else {\n num -= 5 ;\n }\n y++ ;\n }\n if (num < 0){\n if (x % 2 == 0){\n if (num += 2 == 0)\n max -= 2 ;\n else\n max -= 1 ;\n }\n }\n if (n < 0){\n if (y % 2 != 0){\n if (n+=2 == 0)\n min -= 2 ;\n else\n min -= 1 ;\n }\n }\n cout << min << \" \" << max << endl ;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5e0246dce1798ce100ecedeff8c3efad", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint solve(int n){\n \tint ans=0;\n \tint i=1;\n \twhile(true){\n \t\tif(pow(5,i)>n){\n \t\t \tbreak;\n \t\t}\n \t \tans+=n/pow(5,i);\n \t \ti++;\n \t}\n \treturn ans;\n}\nint main()\n{\n\tint n;\n\tcin>>n;\n\tbool f=false;\n\tvector v;\n\tif(n==5){\n\t \tcout<<0;\n\t \treturn 0;\n\t}\n\tfor(int i=1;true;i++){\n\t \tif(solve(i)==n){\n\t \t \tv.push_back(i);\n\t \t \tf=true;\n\t \t}\n\t \telse if(solve(i)!=n&&f){\n\t \t \t break;\n\t \t}\n\t \tif (i==1000000){\n\t \t \tcout<<0;\n\t \t \treturn 0;\n\t \t}\n\t}\n\tcout<\nusing namespace std;\nusing ll = long long;\n#define endl \"\\n\"\n#define all(v) v.begin(),v.end()\n#define mp make_pair\n#define mm(a) memset(a,0,sizeof(a))\n#define rep(i,a,b) for(ll i = a; i < b; i++)\n#define repn(i,a,b) for(ll i = a; i >= b; i--)\n#define pb push_back\n#define f first\n#define s second\n#define inp(a) cin >> a\n#define out(a) cout<> a >> b; adj[a].pb(b), adj[b].pb(a);}\n#define debug(this) cerr<<\"> \"<<#this<<\" : \"<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n long long a;\n char s[1000], d[1000];\n scanf(\"%s\", &s);\n strcpy(d, \"9223372036854775807\");\n if(strlen(s)==19) \n {\n for(int i=0;i<=18;i++)\n {\n if(s[i]19)\n {\n printf(\"BigInteger\");\n return 0;\n }\n else\n {\n sscanf(s, \"%lld\", &a);\n printf(\"%lld\", a);\n for(;;);\n if(a<=127)\n {\n printf(\"byte\");\n return 0;\n }\n if(a<=32767)\n {\n printf(\"short\");\n return 0;\n }\n if(a<=2147483647)\n {\n printf(\"int\");\n return 0;\n }\n printf(\"long\");\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3f8996f05a91eca006bc7fc5837cebb4", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nint main()\n{\n long long int a[11];\n a[0] = 0;\n a[1] = 9;\n long long int z;\n for (int t = 2; t < 11; t++)\n {\n if (t == 2)\n {\n z = 90*2;\n }\n if (t == 3)\n {\n z = 900*3;\n }\n if (t == 4)\n {\n z = 9000*4;\n }\n if (t == 5)\n {\n z = 90000*5;\n }\n if (t == 6)\n {\n z = 900000*6;\n }\n if (t == 7)\n {\n z = 9000000*7;\n }\n if (t == 8)\n {\n z = 90000000*8;\n }\n if (t == 9)\n {\n z = 900000000*9;\n }\n a[t] = a[t-1] + z;\n }\n long long int n;\n cin>>n;\n if (n == 1000000000)\n {\n cout<<8888888899LL;\n return 0;\n }\n int j = 0;\n long long int s = 0;\n for (int vv = 1; vv < 11; vv++)\n {\n if (n < pow(10,vv))\n {\n s = ((n-pow(10,vv-1)+1)*vv + a[vv-1]);\n cout<\n#include\n#include\n#include\nusing namespace std;\nconst int maxn=1e5+10;\nconst int mod=1000000007;\nint n;\nlong long a[maxn],b[maxn],num[maxn];\nvoid init()\n{\n a[1]=27;\n b[1]=7;\n num[1]=20;\n for(int i=2;i\nusing namespace std;\n\nint main()\n{\n //123465789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111\n //string s=\"123465789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120\";\n //cout<>n;\n for(;true;i++,y+=j)\n {\n if(i<9)j=1;\n if(i<99&&i>=9)j=2;\n if(i>=99)j=3;\n if(n==y||(y-n==1&&i>9&&i<100)||(y-n==2&&i>99&&i<1000))break;\n }\n //cout<\nusing namespace std;\n#define ll long long\nll twothree(ll n,ll m)\n{ \n if(m/n==1 && m%n==0)\n return 0;\n ll a,t=0,x=0;\n if(m%3!=0 && m%2!=0)\n return -1;\n a=m/n;\n for(int i = 0 ; i < 10^8 ; i++)\n {\n if(!(a%2==0||a%3==0))\n return -1;\n if(a%2==0)\n {\n a=a/2;\n t++;\n }\n else if(a%3==0)\n {\n a=a/3;\n t++;\n }\n if(a==1)\n return t;\n\n }\n return -1;\n}\n\nint main()\n{\n ll n,m;\n cin>>n>>m;\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define LinkStart int main\n#define mp make_pair\n#define endl \"\\n\"\n#define INF 1e9\n#define X first\n#define Y second\n#define forn(i , n) for(int i = 0 ;i < n ; ++i)\nconst long long MOD = (long long)1e9+7;\nusing namespace std;\n\n// sorry for that ...\n#define MAX_N 501\nlong long power(long long a , long long b){\n if (b == 0) return 1;\n // if (b % 2 == 0) return 1LL * power(a,b/2) * power(a,b/2);\n if (b % 2 == 0)\n {\n long long f = 1LL *power(a,b/2);\n return 1LL * f * f ;\n }\n b--;\n return 1LL * power(a,b) * a;\n \n}\nint left(int i ) { return 2 * i ; }\nint right(int i ) {return 2*i + 1 ;}\n\nvector>> graph(MAX_N);\nstruct Node\n{\nprivate:\n int x , dist , prev;\npublic:\n Node(int a , int b , int c) {x = a , dist = b , prev = c;}\n Node(int a) {x = a , dist = 0 , prev = a;}\n Node(int a , int b) {x = a , dist = b ; }\n int getDist() {return dist ;}\n int getX() {return x ;}\n int getPrev() {return prev ;}\n};\nstruct cmp\n{\n bool operator()(Node &a,Node &b)\n {\n return a.getDist() < b.getDist(); // saving the maximum at top\n }\n};\nvoid addEdge(int u , int v , int w)\n{\n graph[u].push_back(mp(v,w));\n graph[v].push_back(mp(u,w));\n}\n\nmap>,bool> vis;\nint a , b , c , x , y , z;\nvoid dfs(int f , int s , int t)\n{\n if (vis[mp(f,mp(s,t))])\n return;\n vis[mp(f,mp(s,t))] = true;\n if (f >= x && y <= s && z <= t)\n {\n cout << \"Yes\" << endl;\n exit(0);\n }\n if (f >= 2){\n if (s < y)\n dfs(f-2,s+1,t);\n if (t < z)\n dfs(f-2,s,t+1);\n }\n if (s >= 2)\n {\n if (f < x)\n dfs(f+1,s-2,t);\n if (t < z)\n dfs(f,s-2,t+1);\n }\n if (t >= 2)\n {\n if (f < x)\n dfs(f+1,s,t-2);\n if (s < y)\n dfs(f,s+1,t-2);\n }\n}\n\n\nLinkStart()\n{\n cin >> a >> b >> c >> x >> y >> z;\n dfs(a,b,c);\n cout << \"No\" << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0c9714f7c43b6c9456a2cc825c502b46", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nstring s;\n\nbool check(char c)\n{\n\treturn (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'Y');\n}\n\nint main()\n{\n\tcin >> s;\n\tint maxlen = 0;\n\tint cnt = 0;\n\tint len = s.length();\n\tint i = 0;\n\twhile (len > 0) {\n\t\tcnt = 1;\n\t\tif (check(s[i])) {\n\t\t\t++i;\n\t\t\t--len;\n\t\t\twhile (!check(s[i]) && len > 0) ++cnt, ++i, --len;\n\t\t}\n\t\telse while(!check(s[i] && len > 0)){\n\t\t\t++i;\n\t\t\t--len;\n\t\t\t++cnt;\n\t\t}\n\t\tif (cnt > maxlen) maxlen = cnt;\n\t}\n\t\n\tcout << maxlen << endl;\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6b764f347f1b4f5aa6e08efb8993eb02", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "GNU C++0x", "source_code": "// Written by Na2a\n\n#include \n\n#define llong long long\n\n#define pb push_back\n#define mp make_pair\n\n#define F first\n#define S second\n\nusing namespace std;\n\nconst int INF = (int) 1e9 + 7;\nconst int MXN = (int) 1e5 + 7;\n\nconst double EPS = (double) 1e-9;\n\nint n;\n\nint main() {\n\t#define FNAME \"\"\n\t\n\t#ifdef LOCAL \n\tfreopen(FNAME\".in\", \"r\", stdin);\n\tfreopen(FNAME\".out\", \"w\", stdout);\n\t#endif \n\t\n\tscanf(\"%d\", &n);\n\n\tassert(n!=4);\n\tint cnt = 0;\n\twhile (n) {\n\t\tcnt += (n & 1);\n\t\tn >>= 1;\n\t} \n\tif (cnt > 1) puts(\"black\");\n\telse { \n\t\tprintf(\"white\\n%d %d\", 1, 2);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d6165e5860dcdb44df1b14737d0e2e12", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "/*\nID: wanjunl1\nPROG: socdist2\nLANG: C++11\n*/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nofstream fout(\"socdist2.out\");\nifstream fin(\"socdist2.in\");\n\n\nint main() {\n\tios::sync_with_stdio(false);\n\tfin.tie(0);\n\n\tint n, i, j, k, r, x, s, ans;\n\n\tfin >> n;\n\tvector> cow(n), sick;\n\tfor (i = 0; i < n; i++) {\n\t\tfin >> x >> s;\n\t\tcow[i] = { x, s };\n\t\tif (s == 1) sick.push_back({ x, s });\n\t}\n\n\tsort(cow.begin(), cow.end());\n\tr = 1E9;\n\tfor (i = 1; i < n; i++) {\n\t\tif (cow[i].second + cow[i - 1].second == 1) r = min(r, cow[i].first - cow[i - 1].first - 1);\n\t}\n\n\tans = 0;\n\tsort(sick.begin(), sick.end());\n\tif (!sick.empty()) {\n\t\tans = 1;\n\n\t\tfor (i = 1; i < sick.size(); i++) {\n\t\t\tif (sick[i].first - sick[i - 1].first > r) ans++;\n\t\t}\n\t}\n\n\t\t\n\tfout << ans << \"\\n\";\n\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "534afcfc7c663400d8cc23d1253fef4d", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\n#include\nusing namespace std;\nint c = 2000, k, a[1010], dp[100010], fr[100010];\nchar t = 'a';\nstring res;\nint main() {\n scanf(\"%d\", &k);\n if (!k) {\n puts(\"a\");\n return 0;\n }\n for (int i = 2; i <= c; i++) a[i] = i*(i - 1) / 2;\n for (int i = 1; i <= k; i++) {\n dp[i] = 1e9;\n for (int j = 2; a[j] <= i; j++) if (dp[i] > dp[i - a[j]] + 1) {\n dp[i] = dp[i - a[j]] + 1;\n fr[i] = j;\n }\n }\n int i = k;\n while (i) {\n for (int j = 0; j < fr[i]; j++) res += t;\n t++;\n i -= a[fr[i]];\n }\n printf(\"%s\", res.c_str());\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cdb6403323b5b32543c1b4b4bfecbe82", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#pragma comment(linker, \"/STACK:16777216\")\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FOR(i,a,b) for (int i = (int)(a); i < (int)(b); ++i)\n#define FORD(i,a,b) for (int i = (int)(a)-1; i >= (int)(b); --i)\n#define REP(i,n) FOR(i,0,n)\n#define REPD(i,a) FORD(i,a,0)\n#define SQR(a) (a)*(a)\n#define MP make_pair\n#define PB push_back\n#define FILL(a) memset(a,0,sizeof(a));\n#define SIZE(a) (int)((a).size())\n#define ALL(a) (a).begin(),(a).end()\n#define LL long long\n#define LD long double\nconst double PI = 2*acos(0.0);\nconst double EPS = 1e-8;\nconst int INF = 1000000000;\n\nint a1, b1, c1, a2, b2, c2;\nint main(){\n\t//freopen (\"input.txt\", \"r\", stdin);\n\t//freopen (\"output.txt\", \"w\", stdout);\n\tcin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;\n\tif (a1==0&&b1==0 || a2==0&&b2==0){\n\t\tprintf (\"-1\");\n\t\treturn 0;\n\t};\n\tif (a1*b2 != a2*b1) printf (\"1\");\n\telse if (a1 != 0){\n\t\tif (c1*a2 != c2*a1) printf (\"0\");\n\t\telse printf (\"-1\");\n\t}else{\n\t\tif (c1*b2 != c2*b1) printf (\"0\");\n\t\telse printf (\"-1\");\n\t};\n\treturn 0;\n};\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6a935765fa1ccbe7dd5804d9e0304416", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int MAXN=100005;\nconst int BASE[2]={223,233};\nconst int MOD[2]={1000000007,1000000009};\nint pw[MAXN][2];\nvoid build()\n{\n for(int i=(pw[0][0]=pw[0][1]=1);ie[MAXN];\ninfo dp[MAXN],all[MAXN];\nvoid dfs1(int u,int fa)\n{\n vectornxt;\n for(int i=0;i<(int)e[u].size();i++)\n {\n int v=e[u][i];\n if(v==fa)continue;\n dfs1(v,u);\n nxt.push_back(dp[v]);\n }\n dp[u]=info{'(','(',1};\n sort(nxt.begin(),nxt.end());\n for(int i=0;i<(int)nxt.size();i++)\n dp[u]=dp[u]+nxt[i];\n dp[u]=dp[u]+info{')',')',1};\n}\nvoid dfs2(int u,int fa,info o)\n{\n vector >nxt;\n for(int i=0;i<(int)e[u].size();i++)\n {\n int v=e[u][i];\n if(v==fa)nxt.push_back(make_pair(o,v));\n else nxt.push_back(make_pair(dp[v],v));\n }\n all[u]=info{'(','(',1};\n sort(nxt.begin(),nxt.end());\n for(int i=0;i<(int)nxt.size();i++)\n all[u]=all[u]+nxt[i].first;\n all[u]=all[u]+info{')',')',1};\n vectorpre(nxt.size()),suf(nxt.size());\n pre.front()=suf.back()=info{0,0,0};\n for(int i=0;i<(int)nxt.size()-1;i++)\n pre[i+1]=pre[i]+nxt[i].first;\n for(int i=(int)nxt.size()-1;i>=1;i--)\n suf[i-1]=nxt[i].first+suf[i];\n for(int i=0;i<(int)nxt.size();i++)\n {\n int v=nxt[i].second;\n if(v!=fa)dfs2(v,u,info{'(','(',1}+pre[i]+suf[i]+info{')',')',1});\n }\n}\nint main()\n{\n build();\n int n;\n scanf(\"%d\",&n);\n for(int i=1;i<=n-1;i++)\n {\n int u,v;\n scanf(\"%d%d\",&u,&v);\n e[u].push_back(v);\n e[v].push_back(u);\n }\n dfs1(1,0);\n dfs2(1,0,info{0,0,0});\n vectortmp;\n for(int i=1;i<=n;i++)\n if((int)e[i].size()<4)tmp.push_back(all[i]);\n sort(tmp.begin(),tmp.end());\n int res=unique(tmp.begin(),tmp.end())-tmp.begin();\n return 0*printf(\"%d\",res);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "86858ec3dc3a291e4d5e61c2703ee3d2", "src_uid": "3c5aedd5d3bc12dca3e921c95ef05270", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nusing namespace std;\n\n \nint main()\n{\n int y,i,len;\n int a=0,b=0,c=0;\n char arr[100];\n cin>>arr;\n cout<=48 && y<=57)\n {\n a++;\n }\n if(y >=65 && y <= 90)\n {\n b++;\n }\n if(y >= 97 && y <= 122)\n {\n c++;\n }\n }\n if(len>5 && a>0 && b>0 && c>0)\n {\n cout<<\"Correct\";\n }\n else\n {\n cout<<\"Too weak\";\n }\n \n \n getch();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6470b8fc9f6773a0ea2b84d07625dec5", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include\n#include\n#include\n#include \nusing namespace std;\nint main()\n{\n\tlong long n, a, b, c, minx = 1000000007;\n\twhile (scanf(\"%lld%lld%lld%lld\", &n, &a, &b, &c))\n\t{\n\t\tif (n % 4 == 0){\n\t\t\tputs(\"0\");\n\t\t}\n\t\telse{\n\t\t\tn %= 4;\n\t\t\tif (n == 1){\n\t\t\t\tminx = min(3 * a, minx);\n\t\t\t\tminx = min(minx, c);\n\t\t\t}\n\t\t\telse if (n == 2){\n\t\t\t\tminx = min(2 * a, minx);\n\t\t\t\tminx = min(b, minx);\n\t\t\t\tminx = min(3 * c, minx);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tminx = min(a, minx);\n\t\t\t\tminx = min(minx, 3 * c);\n\t\t\t}\n\t\t\tprintf(\"%lld\\n\", minx);\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fd00416c9776f3c3c572c664ec70f6c9", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include\n#include // Common file\n#include // Including\nusing namespace std;\nusing namespace __gnu_pbds;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vvi;\ntypedef vector vvl;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair pll;\ntypedef vector vii;\ntypedef vector vll;\n\ntemplate\nusing ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate\nusing ordered_map = tree, rb_tree_tag, tree_order_statistics_node_update>;\n\n//#define PB push_back\n#define PB emplace_back\n#define F first\n#define S second\n#define MP make_pair\n#define endl '\\n'\n#define pf printf\n#define sf scanf\n#define left __left\n#define right __right\n#define tree __tree\n\nconst double PI = acos(-1);\nconst double eps = 1e-9;\nconst int inf = 2000000000;\nconst ll infLL = 9000000000000000000;\n#define MOD 1000000007\n//#define harmonic(n) 0.57721566490153286l+log(n)\n\n#define mem(a,b) memset(a, b, sizeof(a) )\n#define gcd(a,b) __gcd(a,b)\n#define lcm(a,b) (a*(b/gcd(a,b)))\n#define sqr(a) ((a) * (a))\n\n#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);\n\ntypedef vector::iterator vit;\ntypedef set::iterator sit;\n\ninline bool checkBit(ll n, int i) { return n&(1LL<>= 1; } return r; }\ninline ll modInverse(ll a) { return modPow(a, MOD-2); }\ninline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }\n\n/*\nbool seive[1010000];\nvi prime;\n\nvoid seiveGen(int limit) {\n limit += 100;\n int sqrtn = sqrt(limit);\n for(int i = 3; i <= sqrtn; i += 2) {\n if(!seive[i>>1]) {\n for(int j = i * i; j < limit; j += i + i) {\n seive[j>>1] = 1;\n }\n }\n }\n prime.PB(2);\n for(int i = 3; i < limit; i += 2) {\n if(!seive[i>>1]) prime.PB(i);\n }\n}\n*/\n\n//\n//debug\n#ifdef yamin\ntemplate < typename F, typename S >\nostream& operator << ( ostream& os, const pair< F, S > & p ) {\n return os << \"(\" << p.first << \", \" << p.second << \")\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const vector< T > &v ) {\n os << \"{\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"}\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const set< T > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"]\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const multiset< T > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"]\";\n}\n\ntemplate < typename F, typename S >\nostream &operator << ( ostream & os, const map< F, S > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << it -> first << \" = \" << it -> second ;\n }\n return os << \"]\";\n}\n\n#define dbg(args...) do {cerr << #args << \" : \"; faltu(args); } while(0)\n\nclock_t tStart = clock();\n#define timeStamp dbg(\"Execution Time: \", (double)(clock() - tStart)/CLOCKS_PER_SEC)\n\nvoid faltu () {\n cerr << endl;\n}\n\ntemplate \nvoid faltu( T a[], int n ) {\n for(int i = 0; i < n; ++i) cerr << a[i] << ' ';\n cerr << endl;\n}\n\ntemplate \nvoid faltu( T arg, const hello &... rest) {\n cerr << arg << ' ';\n faltu(rest...);\n}\n#else\n#define dbg(args...)\n#endif // yamin\n\nint ans = 0;\n\nvoid solve(int lim) {\n\tqueue bfs;\n\tif (4 <= lim)\n\t\tbfs.push(4);\n\tif (7 <= lim)\n\t\tbfs.push(7);\n\twhile (!bfs.empty()) {\n\t\tint u = bfs.front();\n\t\tbfs.pop();\n\t\t++ans;\n\t\tint v = u * 10 + 4;\n\t\tif (v <= lim)\n\t\t\tbfs.push(v);\n\t\tv = u * 10 + 7;\n\t\tif (v <= lim)\n\t\t\tbfs.push(v);\n\t}\n}\n\nbool lucky(int num) {\n\twhile (num > 0) {\n\t\tint lol = num % 10;\n\t\tif (lol != 4 && lol != 7)\n\t\t\treturn false;\n\t\tnum /= 10;\n\t}\n\treturn true;\n}\n\nint main() {\n\tint n, k;\n\tcin >> n >> k;\n\n\t--k;\n\n\tvi store;\n\n\tfor (int i = 1; k > 0; ++i) {\n\t\tstore.PB(k % i);\n\t\tk /= i;\n\t\tdbg(i, k);\n\t}\n\n\tif (store.size() > n) {\n\t\tcout << -1 << endl;\n\t\treturn 0;\n\t}\n\n\tdbg(store, n - store.size());\n\n\tsolve(n - store.size());\n\n\tset yo;\n\n\tfor (int i = n; i > n - store.size(); --i) {\n\t\tyo.insert(i);\n\t}\n\n\tdbg(yo);\n\tdbg(ans);\n\n\tfor (int i = n - store.size() + 1, j = store.size() - 1; i <= n; ++i, --j) {\n\t\tauto it = yo.begin();\n\t\tfor (int l = 0; l < store[j]; ++l)\n\t\t\t++it;\n\t\tint it2 = *it;\n\t\tyo.erase(it2);\n\t\tdbg(i, it2);\n\t\tif (lucky(i) && lucky(it2))\n\t\t\t++ans;\n\t}\n\n\tcout << ans << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6700372ed0c7b79a059583b522fa8bb4", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include \nconst int N=5e2+10;\nconst int INF=1e8+10;\nint f[N][N],n;\nint dis(int a,int b){return a>b?n-a+b:b-a;}\nint min(int a,int b){return a>b?b:a;}\nvoid add(int &a){a=(a%n)+1;}\nint dp(int l,int r){\n//\tprintf(\"%d %d\\n\",l,r);\n\tif(dis(l,r)<2)return 0;\n\tif(dis(l,r)==2){\n\t\tr*=l;\n\t\tadd(l);\n\t\treturn l*r;\n\t}\n\tif(f[l][r]!=-1)return f[l][r];\n\tint ans=INF;\n\tfor(int i=(l%n)+1;i!=r;add(i))for(int j=i+1;j!=r;add(j))ans=min(ans,dp(l,i)+dp(i,j)+dp(j,r)+l*i*j);\t\n\treturn f[l][r]=ans;\n}\nint main(){\n\tint ans=INF;\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=n;i++)for(int j=1;j<=n;j++)f[i][j]=-1;\n\tfor(int i=2;i\n\nusing namespace std;\nclass node\n{\n public: int matchbox , matchs ;\n};\nint main()\n{\n int burg , container , counter=0;\n node tmp ;\n\n cin>>burg >> container ;\n node array1[container] ;\n for(int i=0 ; i> array1[i].matchbox>> array1[i].matchs ;\n }\n\n\n for(int i=0;i=0&& burg>0 ; i--)\n{\nif(burg>array1[i].matchbox)\n{\n counter=counter + (array1[i].matchbox*array1[i].matchs) ;\n burg = burg-array1[i].matchbox;\n}\nelse\n{\n counter=counter+array1[i].matchs*burg;\n burg=0;\n}\n}\ncout<\n#define INF 0x3f3f3f3f\nusing namespace std;\n\nstruct node{\n\tint x, y, step;\n};\nint cnt, head[305], v[1005], w[1005], c[1005], _next[1005];\nint n, m, a[11][11], b[105][2], dx[] = {-1, -2, -2, -1, 1, 2, 2, 1},\n\t\t\t\t\t\t\t dy[] = {2, 1, -1, -2, -2, -1, 1, 2};\nint dis[305], cost[305];\nint front, back, q[3005];\nbool h[305], g[15][15];\n\ninline void Addedge(int x, int y, int z, int t) {\n\tv[++cnt] = y, w[cnt] = z, c[cnt] = t;\n\t_next[cnt] = head[x], head[x] = cnt;\n}\nint Bfs(int k, int x1, int y1, int x2, int y2) {\n\tif(k == 2)\n\t\treturn (x1 != x2) + (y1 != y2);\n\tif(k == 1)\n\t\treturn 1 + (x1 - x2 != y1 - y2);\n\tif(n < 3)\n\t\treturn INF;\n\tmemset(g, 0, sizeof(g)), g[x1][y1] = true;\n\tfor(int i = 0; i <= m + 1; ++i)\n\t\tg[i][0] = g[i][m + 1] = true;\n\tfor(int j = 1; j <= m; ++j)\n\t\tg[0][j] = g[m + 1][j] = true;\n\tdeque q;\n\tq.push_back({x1, y1, 0});\n\twhile(!q.empty()) {\n\t\tnode x = q.front();q.pop_front();\n\t\tif(x.step == 5)\n\t\t\tbreak;\n\t\tfor(int i = 0; i < 8; ++i)\n\t\t\tif(!g[x.x + dx[i]][x.y + dy[i]]) {\n\t\t\t\tif(x.x + dx[i] == x2 && x.y + dy[i] == y2)\n\t\t\t\t\treturn x.step + 1;\n\t\t\t\tg[x.x + dx[i]][x.y + dy[i]] = true;\n\t\t\t\tq.push_back({x.x + dx[i], x.y + dy[i], x.step + 1});\n\t\t\t}\n\t}\n\treturn INF;\n}\nvoid Build() {\n\tfor(int i = 1; i < n; ++i)\n\t\tfor(int k = 0; k < 3; ++k) {\n\t\t\tAddedge(i + k * n, i + 1 + k * n,\n\t\t\t\t\tBfs(k, b[i][0], b[i][1], b[i + 1][0], b[i + 1][1]), 0);\n\t\t\tAddedge(i + k * n, i + (k ? 3 - k : 1) * n, 1, 1);\n\t\t\tAddedge(i + (k ? 3 - k : 1) * n, i + k * n, 1, 1);\n\t\t\tAddedge(i + k * n, i + (k ? 0 : 2) * n, 1, 1);\n\t\t\tAddedge(i + (k ? 0 : 2) * n, i + k * n, 1, 1);\n\t\t}\n\tAddedge(0, 1, 0, 0), Addedge(0, 1 + n, 0, 0), Addedge(0, 1 + n * 2, 0, 0);\n\tAddedge(n, 3 * n + 1, 0, 0), Addedge(n * 2, 3 * n + 1, 0, 0), Addedge(n * 3, 3 * n + 1, 0, 0);\n}\nvoid Spfa() {\n\tmemset(dis, 0x3f, sizeof(dis)), dis[0] = 0;\n\tmemset(cost, 0x3f, sizeof(cost)), cost[0] = 0;\n\tmemset(h, 0, sizeof(h));\n\tfront = back = 0;\n\tq[back++] = 0, h[0] = 1;\n\twhile(front < back) {\n\t\tint x = q[front++];h[x] = false;\n\t\tfor(int i = head[x]; i; i = _next[i])\n\t\t\tif(dis[v[i]] > dis[x] + w[i] ||\n\t\t\t\t(dis[v[i]] == dis[x] + w[i] && cost[v[i]] > cost[x] + c[i])) {\n\t\t\t\tdis[v[i]] = dis[x] + w[i], cost[v[i]] = cost[x] + c[i];\n\t\t\t\tif(!h[v[i]])\n\t\t\t\t\tq[back++] = v[i], h[v[i]] = true;\n\t\t\t}\n\t}\n\tprintf(\"%d %d\\n\", dis[3 * n + 1], cost[3 * n + 1]);\n}\nvoid Init() {\n\tscanf(\"%d\", &n), m = n, n *= n;\n\tfor(int i = 1; i <= m; ++i)\n\t\tfor(int j = 1; j <= m; ++j)\n\t\t\tscanf(\"%d\", a[i] + j), b[a[i][j]][0] = i, b[a[i][j]][1] = j;\n}\nint main() {\n\tInit();\n\tBuild();\n\tSpfa();\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "15b669a514ea3e42c788d37f973334ac", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef double db;\n\n\nll n, a, b, c, k, t;\n\nint main()\n{\n//\tfreopen(\"INPUT.TXT\", \"r\", stdin);\n//\tfreopen(\"OUTPUT.TXT\", \"w\", stdout);\n\tcin >> n >> a >> b >> c;\n\tif (a <= b - c){\n\t\tcout << n / a;\n\t\treturn 0;\n\t}\n\tif (b <= a){\n\t\twhile (n / b != 0){\n\t\t\tt = n / b;\n\t\t\tn -= t * b;\n\t\t\tk += t;\n\t\t\tn += t * c;\n\t\t}\n\t\tcout << k;\n\t\treturn 0;\n\t}\n\twhile (n >= min(a, b)){\n\t\tif (n / b != 0){\n\t\t\tt = n / b;\n\t\t\tn -= t * b;\n\t\t\tk += t;\n\t\t\tn += t * c;\n\t\t}\n\t\telse{\n\t\t\tk += n / a;\n\t\t\tbreak;\n\t\t}\n\t}\n\tcout << k;\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "708fd933d9a6f5c82696bfffd0acaad0", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\nll bin_pow(ll a, ll n){\n ll res = 1;\n while(n){\n if(n & 1) res *= a;\n a *= a;\n n >>= 1;\n }\n return res;\n}\nll n, k;\nll s;\nll mas[35];\nll fact[35];\nll a[35];\nvector ans[35];\nvector merg(vector &f, vector s){\n vector ans;\n \n ll i = 0;\n ll j = 0;\n while(i < f.size() && j < s.size()){\n if(f[i] < s[j]){\n ans.push_back(f[i ++]);\n }\n else{\n ans.push_back(s[j++]);\n }\n }\n while(i < f.size()){\n ans.push_back(f[i ++]);\n }\n while(j < s.size()){\n ans.push_back(s[j ++]);\n }\n return ans;\n}\nint main(){\n cin >> n >> k >> s;\n for(ll i = 0; i < n; ++i){\n cin >> a[i];\n }\n sort(a, a + n);\n ll cr = bin_pow(3, min(n, (ll)14));\n for(ll i = 0; i <= 30; ++i){\n mas[i] = bin_pow(3, i);\n }\n fact[0] = 1;\n for(ll i = 1; i <= 30; ++i){\n fact[i] = fact[i - 1] * i;\n }\n //cout << fact[18] << endl;\n ll res = 0;\n for(ll mask = 0; mask < cr; ++mask){\n ll msk = mask;\n ll sum = s;\n ll fl = 0;\n ll cnt = 0;\n for(ll i = min(n, (ll)14) - 1; i >= 0; --i){\n if(2 * mas[i] <= msk){\n if(a[i] <= 18){\n msk -= 2 * mas[i];\n sum -= fact[a[i]];\n cnt++;\n }\n else{\n fl = 1;\n }\n }\n else if(mas[i] <= msk){\n msk -= mas[i];\n sum -= a[i];\n }\n else{\n\n }\n }\n if(!fl) ans[cnt].push_back(sum);\n }\n //cout << res << endl;\n for(ll i = 0; i <= k; ++i)\n sort(ans[i].begin(), ans[i].end());\n for(ll i = 0; i < k; ++i){\n ans[i + 1] = merg(ans[i], ans[i + 1]);\n }\n //cout << upper_bound(ans[25].begin(), ans[25].end(), 0) - lower_bound(ans[25].begin(), ans[25].end(), 0) << endl;\n /*for(ll i = 0; i < ans.size(); ++i){\n cout << ans[i] << endl;\n }*/\n cr = bin_pow(3, max(n - 14, (ll)0));\n for(ll mask = 0; mask < cr; ++mask){\n ll msk = mask;\n ll sum = 0;\n ll fl = 0;\n ll cnt = 0;\n for(ll i = max(n - 14, (ll)0) - 1; i >= 0; --i){\n if(2 * mas[i] <= msk){\n if(a[i + 14] <= 18){\n msk -= 2 * mas[i];\n sum += fact[a[i + (ll)14]];\n cnt++;\n }\n else{\n fl = 1;\n }\n }\n else if(mas[i] <= msk){\n msk -= mas[i];\n sum += a[i + 14];\n }\n else{\n\n }\n }\n if(!fl){\n ll dop = k - cnt;\n if(dop >= 0)\n res += upper_bound(ans[dop].begin(), ans[dop].end(), sum) - lower_bound(ans[dop].begin(), ans[dop].end(), sum);\n }\n }\n cout << res << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "22070fe9c4fa6e0459518de1dca8114b", "src_uid": "2821a11066dffc7e8f6a60a8751cea37", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": " // \"It does not matter how slowly you go as long as you do not stop.\" - Confucius\n#include \n\nusing namespace std;\n\n/*\nauthor : Roshan_Mehta\nmotto : Time Management,Consistency,Patience!!\n*/\n\n#define int long long\n\n#ifdef Local_Debug\n\n#define debug(x) cout<<#x <<\" \"< &a)\n{for (int i = 0; i < a.size(); i++)\n{cout << a[i] << \" \";}cout << endl;}\nvoid show(vector> &a)\n{\n for(int i=0;i> &a)\n{\n for (int i = 0; i < (int)a.size(); i++)\n {\n cout< &a){return;}\nvoid show(vector> &a){return;}\nvoid show(vector> &a){return ;}\nvoid printTime()\n{return;}\n#endif\n\n\n#define M1 1000000007\n#define M2 998244353\n#define G(a,b) get(b)\n#define ll long long\n#define pb push_back\n#define mt make_tuple\n#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);\n#define mp make_pair\n#define F first\n#define S second\n#define sz(x) (int)x.size()\n#define all(x) x.begin(), x.end()\n#define rsort(x) sort(x,greater ())\n#define rall(x) rbegin(x), rend(x) //useful in sorting\n#define endl \"\\n\"\n#define p0(a) cout << a << \" \"\n#define p1(a) cout << a << endl\n#define p2(a, b) cout << a << \" \" << b << endl\n#define p3(a, b, c) cout << a << \" \" << b << \" \" << c << endl\n#define p4(a, b, c, d) cout << a << \" \" << b << \" \" << c << \" \" << d << endl\n#define gcd __gcd\n#define lcm(a,b) ((a)*(b))/gcd(a,b)\n#define deci(n) fixed << setprecision(n)\n#define test() int test_case;cin >> test_case;while (test_case--)\n#define loop(i,a,n) for(int i=a;i=a;i--)\n#define pie 3.141592653589793238462643383279\n\ntypedef vector vi;\ntypedef vector vb;\ntypedef vector vs;\ntypedef vector vl;\ntypedef vector vvi;\ntypedef pair pi;\ntypedef vector vpi;\ntypedef pair tri;\ntypedef pair rtri;\ntypedef pair pl;\ntypedef pair pd;\ntypedef priority_queue, greater> minpq;\ntypedef priority_queue pq;\ntypedef unordered_map umii;\ntypedef map mii;\ntypedef set si;\n#define input(n,k) int n,k;cin>>n;cin>>k;vi arr(n,0);loop(i,0,n){cin>>arr[i];}\n\nconst int MOD = 1e9 + 7;\nint md=MOD;\n\nint Power(int n, int x) {int ans = 1;while (x > 0) {if (x & 1) ans = (ans * n) % md;\nn = (n * n) % md;x = x >> 1;}return ans;}\n\nvl fact, inv;\n\nvoid inverse(ll n)\n{if(n>=inv.size()){ll size=inv.size();size=size==0? 1:size;\ninv.resize(n + 1);inv[0] = 1;\nfor (ll i = size; i <= n; i++)inv[i] = Power(fact[i], md - 2);}}\n\nvoid factorial(ll n)\n{if(n>=fact.size()){ll size=fact.size();size=size==0? 1:size;\nfact.resize(n + 1);fact[0] = 1;for (ll i = size; i <= n; i++)\nfact[i] = (fact[i - 1] * i) % md;\n}}\n\nll ncr(ll n, ll r) { return (((fact[n] * inv[r]) % md) * inv[n - r]) % md; }\n\nvl SieveOfEratosthenes(int n)\n{\n bool prime[n+1];\n memset(prime, true, sizeof(prime));\n for (int p=2; p*p<=n; p++)\n {if (prime[p] == true){for (int i=p*p; i<=n; i += p)\n prime[i] = false;}}\n\n vl ans;for (int p=2; p<=n; p++)if (prime[p])ans.pb(p);return ans;\n}\nvi primeFactors(int n)\n{\n vi ans;\n while (n % 2 == 0) {ans.pb(2);n = n / 2;}\n for (int i = 3; i <= sqrt(n); i = i + 2) {\n while (n % i == 0) {ans.pb(i);n = n / i;}}\n if (n > 2)ans.pb(n);return ans;\n}\nbool isprime(ll n)\n{\n if(n<2)\n return false;\n for(ll x:{2,3,5,7,11,13,17,19,23,29,31,37})\n {\n if(n==x)\n return true;\n bool flag=true;\n ll r=1;\n ll t=1;\n while(r<=((n-1)>>__builtin_ctzll(n-1)))\n {\n if(r&((n-1)>>__builtin_ctzll(n-1)))\n t=((__int128)t*x)%n;\n x=((__int128)x*x)%n;\n r<<=1;\n }\n if(t==1||t==n-1)\n flag=false;\n for(r=0;r<__builtin_ctzll(n-1);r++)\n {\n t=((__int128)t*t)%n;\n if(t==n-1)\n flag=false;\n }\n if(flag)\n return false;\n }\n return true;\n}\n\nll NcR(int n, int r)\n{long long p = 1, k = 1;if (n - r < r)r = n - r;if (r != 0) {while (r) {p *= n;k *= r;\nlong long m = gcd(p, k);p /= m;k /= m;n--;r--;}\n}else p = 1;return p;// cout << p << endl;\n}\nbool sortasc(const rtri a,const rtri b) //Ascending ... change the argument accordingwise;\n{\n return a.secondb;\n}\nint myceil(int num,int den)\n{\n return num%den == 0 ? num/den : num/den + 1;\n}\nint myfloor(int num,int den)\n{\n return num%den == 0 ? num/den : num/den - 1;\n}\nint midofthree(int a,int b,int c)\n{\n if((a<=b and a>=c) or (a<=c and a>=b))\n return a;\n else if((b>=a and b<=c) or (b<=a and b>=c))\n return b;\n return c;\n}\nstring to_str(char c) {\n\treturn string(1, c);\n}\nll modI(ll a, ll m)\n{\n ll m0=m,y=0,x=1;\n if(m==1) return 0;\n while(a>1)\n {ll q=a/m;ll t=m;m=a%m;a=t;t=y;y=x-q*y;x=t;\n }\n if(x<0) x+=m0;\n return x;\n}\n#define pow10(n) stoll(\"1\"+string(n,'0'))\n\n// 2-D vector with both size--> vector > a(n, vector(m));\n\nvoid q1();void q2();void q3();void q4();void q5();void q6();\n//********************THE END OF TEMPLATES*******************//\n\nconst int N = 2e5 + 5;\nint n,m,k;\nvi arr,brr,crr;\nvi primes={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};\nvi numPrime(60);\nvvi dp;\nvvi table;\n\nint solve(int pos,int mask)\n{\n if(pos==n or pos<0) return 0;\n if(dp[pos][mask]!=-1) return dp[pos][mask];\n int a=solve(pos+1,mask) + abs(arr[pos]-1);\n int val=1;\n for (int i = 2; i < 60; i++)\n {\n int num=i+1;\n if(((numPrime[i-1]&mask))!=numPrime[i-1])continue;\n num=(numPrime[i-1]^mask);\n int ans=solve(pos+1,num)+abs(arr[pos]-i);\n if(ans>n;\n arr=vi(n);\n dp=vvi(n,vi(1<<17+2,-1));\n table=vvi(n,vi(1<<17+2,-1));\n for (int i = 0; i < n; i++)\n {\n cin>>arr[i];\n }\n numPrime=vi(60);\n for (int i = 0; i < 60; i++)\n {\n for (int j = 0; j < 17; j++)\n {\n if((i+1)%primes[j]==0)\n {\n numPrime[i]+=(1<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef vector vi;\ntypedef vector vs;\ntypedef pair pii;\ntypedef long long ll;\n\n#define FV(i,v) for(int i=0; i<(int)(v).size(); i++)\n#define FI(i,v) for(typeof(v.begin()) i = v.begin(); i != v.end(); ++i)\n#define sz(v) (int)(v).size()\n#define all(v) (v).begin(), (v).end()\n#define REP(i,n) for(int (i) = 0; (i) < (n); (i)++)\n#define FOR(i, st, en) for(int i=(st); i<(int)(en); i++)\n\nvoid do_nothing() {}\n\nll n, m, k;\n\nll go(ll nch)\n{\n int k1 = nch-1;\n int k2 = k - k1;\n int mch = k2+1;\n if (mch > m || k1 > k)\n return -1;\n return (n / nch) * (m / mch);\n}\n\nvoid solve()\n{\n cin >> n >> m >> k;\n if (n > m) swap(n, m);\n ll ans = -1;\n\n for (int i = 1; i <= sqrt(n); ++i) {\n ans = max(ans, go(i));\n ans = max(ans, go(n/i));\n }\n\n cout << ans << \"\\n\";\n}\n\n\n\n\n\n#ifdef ONLINE_JUDGE\nint main() { solve(); return 0; }\n#else\nvoid perform_testing(void (*solve)(), string problem, int itest);\nint main() { perform_testing(solve, \"A\", -1); return 0; }\n#endif // ONLINE_JUDGE\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "157ab3507ac211006c7886dc9ef5dda1", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define raftaar ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n#define in freopen(\"input.txt\",\"r\",stdin);\n#define out freopen(\"out.txt\",\"w\",stdout);\n#define sublime in out\n#define int int64_t\n#define rep(i,a,b) for (int i = a; i <= b; ++i)\ntypedef long double ld;\ntypedef vector vi;\n#define F first \n#define S second \n#define PB push_back \n#define LB lower_bound\n#define mp make_pair\ntypedef pair PII;\ntypedef vector VII;\n#define all(c) (c).begin(),(c).end()\n#define sz(a) ((int)(a).size())\nbool isprime(int n){for(int i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}\nint factorial(int n){return (n==1 || n==0) ? 1:n*factorial(n-1);}\nint gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}\nint lcm(int a,int b){return (a/gcd(a,b)*b);}\nint max(int a,int b){int sol=a>b?a:b;return sol;}\nint min(int a,int b){int sol=a 0){ if(y & 1){ans*=x;}y>>=1LL; x*=x;}return ans;}\nint mod=1000000007;\nint mn[100010]={0};\ninline int solve(){\n \n int n,m,s;\n cin>>n>>m>>s;\n int a[n],b[m];\n rep(i,0,n-1){\n cin>>a[i];\n }\n rep(i,0,m-1){\n cin>>b[i];\n }\n sort(a,a+n);\n sort(b,b+n);\n reverse(b,b+n);\n int i=0,cnt=0;\n int ans=0,res=s;\n while(s>0){\n if((s-(s/a[i])*a[i])>=0)\n cnt+=s/a[i];\n s-=(s/a[i])*a[i];\n if(s==1 && a[i]>1){\n ans++;\n break;\n }\n }\n cout<\n#include \nusing namespace std;\nint main(){\n freopen(\"chat.txt\",\"r\",stdin);\n freopen(\"chat2.txt\",\"w\",stdout);\n char a[8][8];\n int count=0;\n int t;\n for(int i=0;i<8;i++){\n for(int j=0;j<8;j++){\n cin>>a[i][j];\n }\n } \n for(int i=0;i<8;i++){\n if(a[i][0]=='B'){ count++; }\n else{ t=i; }\n } \n if(count<8){\n for(int i=0;i<8;i++){\n if(a[t][i]=='B'){ count++; } \n }\n }\n cout<\n#include\n#include\n#include\n\n\n \nint main(void)\n{\n int n,l=0,b,c;\n scanf(\"%d %d\",&n,&b);\n c=n;\n while (n>=b)\n {\n l++;\n n=n-b+1;\n }\n \n printf(\"%d\",c+l); \n \n getch();\n return 0;\n }", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5ffadae917497c0123058ab9fca7661a", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define ll long long int\nint main()\n{\n ll u,v;\n cin>>u>>v;\n if(v-u<=1) \n cout<<\"-1\"<> um;\n for(ll i=u;i<=v;i++)\n {\n for(int j=2;j<=i/2;i++)\n {\n if(i%j==0)\n um[i].emplace_back(j);\n }\n um[i].emplace_back(i);\n }\n for(auto i:um)\n {\n cout<\";\n for(auto j:i.second)\n cout< //:3\nusing namespace std;\ntypedef long long ll;\n#define all(a) (a).begin(), (a).end()\n#define ff first\n#define ss second\n#define pb push_back\n#define mp make_pair\n#define pi pair\n#define sz(x) (int)((x).size())\n#define int long long\n\nconst int dx[] = {0, 1, 0, -1};\nconst int dy[] = {1, 0, -1, 0};\n\nconst ll inf = 2e9;\nconst ll mod = 1e9 + 7;\nconst int N = 5e2 + 11;\nconst int X = 1e6;\nconst ll INF64 = 3e18 + 1;\nconst double eps = 1e-14;\nconst double PI = acos(-1);\n\n//ifstream in(\".in\");\n//ofstream out(\".out\");\n\nint n, k, dp[N][N][N];\n\nvoid solve(){\n\n cin >> n >> k;\n\n string s, t;\n\n cin >> s >> t;\n\n //s = '.' + s + '.';\n\n char a = t[0], b = t[1];\n\n if(a == b){\n int x = 0;\n for(int i = 1; i <= n; i++)x += (s[i] == a);\n x = min(n, x + k);\n cout << x * (x - 1) / 2 << '\\n';\n return;\n }\n\n memset(dp, -1, sizeof(dp));\n\n dp[0][0][0] = 0;\n\n int ans = 0;\n\n for(int i = 0; i < n; i++){\n for(int j = 0; j <= k; j++){\n for(int cnt = 0; cnt <= i; cnt++){\n if(dp[i][j][cnt] == -1)continue;\n dp[i + 1][j + 1][cnt + 1] = max(dp[i + 1][j + 1][cnt + 1], dp[i][j][cnt]);\n dp[i + 1][j + 1][cnt] = max(dp[i + 1][j + 1][cnt], dp[i][j][cnt] + cnt);\n dp[i + 1][j][cnt + (s[i] == a)] = max(dp[i + 1][j][cnt + (s[i] == a)], dp[i][j][cnt] + (s[i] == b)*cnt);\n }\n }\n }\n\n for(int j = 0; j <= k; j++){\n for(int cnt = 0; cnt <= n; cnt++){\n ans = max(ans, dp[n][j][cnt]);\n }\n }\n\n cout << ans << '\\n';\n\n}\n\nint32_t main(){\nios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\n //cout << setprecision(6) << fixed;\n\n int T = 1;\n //cin >> T;\n while(T--){\n solve();\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "92672fb5b34ce5834c0f44a1c53c3c55", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint n,a[10000000],t,b[100000000];\nint main()\n{\n cin>>n;\n for(int i=1;i<=n;i++){\n cin>>a[i]>>b[i];\n }\n for(int i=1;i<=n;i++){\n for(int j=1;j<=n;j++){\n if(i!=j){\n t++;\n }\n }\n }\n cout<\nusing namespace std;\ntypedef long long ll;\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n string s,t,ans=\"\";\n int i=0;\n cin>>s>>t;\n while(s[i]==t[i]&&is&&ans\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pli;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vpii;\ntypedef vector vpli;\n\ninline ll read(){\n ll Hashimoto=0;\n\tbool Kanna=1;\n char I_Love=getchar();\n while(I_Love<'0'||I_Love>'9'){\n if(I_Love=='-')Kanna=0;\n I_Love=getchar();\n }\n while(I_Love>='0'&&I_Love<='9'){\n Hashimoto=Hashimoto*10+I_Love-'0';\n I_Love=getchar();\n }\n return (Kanna?Hashimoto:-Hashimoto);\n}\ntemplate inline void Umax(T1 &a,T2 b){\n\tif(a inline void Umin(T1 &a,T2 b){\n\tif(a>b)a=b;\n}\n\n#define I_Love_Hashimoto_Kanna main\n#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define filein(s) freopen(s,\"r\",stdin);\n#define fileout(s) freopen(s,\"w\",stdout);\n#define file freopen(\"I_Love_Hashimoto_Kanna.out\",\"w\",stdout);\n#define RE cout<<\"I_Love_Hashimoto_Kanna\"< tr;\ninline ll check(ll x){\n\tif(x<0||x>=d)return linf;\n\treturn x*a+(x-1)/k*t+(d-x)*b;\n}\n\nint I_Love_Hashimoto_Kanna() {\n\t//\u5b8c\u5168\u60f3\u6e05\u695a\u4e86\u518d\u5f00\u59cb\u5199\u3002\n\t//\u5199\u4e0d\u987a\u3001\u4e0d\u77e5\u9053\u600e\u4e48\u5199\u3001\u5f88\u4e71\u7684\u65f6\u5019\uff0c\u505c\u4e0b\u6765\u597d\u597d\u60f3\u60f3\u3002\n\t//\u505a\u5f97\u6162\u603b\u6bd4\u505a\u4e0d\u51fa\u597d\u3002\n\tfastio;\n\tcin>>d>>k>>a>>b>>t;\n\tll l=0,r=d/k+1;\n\t\n\tFOR(i,l,r){\n\t\tif(i*k<=d){\n\t\t\ttr.push_back(i*k);\n\t\t\tif((i+1)*k>d){\n\t\t\t\tFOR(j,i*k+1,d+1){\n\t\t\t\t\ttr.push_back(j);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tl=0,r=tr.size();\n\twhile(l>1;\n\t\tif(mid==0){\n\t\t\tif(check(tr[0])check(tr[mid])&&check(tr[mid])>check(tr[mid+1])){\n\t\t\tl=mid+1;\n\t\t}\n\t\telse if(check(tr[mid-1])>check(tr[mid])&&check(tr[mid])\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \n#include \nusing namespace std;\n\n#define mp make_pair\n#define pb push_back\ntypedef long long ll;\ntypedef pair pii;\n\nll n,ans,tmp[2];\nvoid dfs(ll num)\n{\n\tif(num>=n and tmp[0]==tmp[1]) ans=min(ans,num);\n\ttmp[0]++;\n\tdfs(num*10+4);\n\ttmp[0]--;\n\ttmp[1]++;\n\tdfs(num*10+7);\n\ttmp[1]--;\n}\n\nint main()\n{\n\tans=1e9+100000;\n\tcin>>n;\n\tdfs(0);\n\tcout<\n#include\n#include\n#include\n#include\n#define sz(v) ((int)(v).size())\n#define all(v) ((v).begin()),((v).end())\n#define allr(v) ((v).rbegin()),((v).rend())\n#define pb push_back\n#define mp make_pair\n#define mt make_tuple\n#define clr(v,d) memset( v, d ,sizeof(v))\n#define angle(n) atan2((n.imag()),(n.real()))\n#define vec(a,b) ((b)-(a))\n#define length(a) hypot( (a.imag()),(a.real()) )\n#define normalize(a) (a)/(length(a))\n#define dp(a,b) (((conj(a))*(b)).real())\n#define cp(a,b) (((conj(a))*(b)).imag())\n#define lengthsqrt(a) dp(a,a)\n#define rotate0( a,ang) ((a)*exp( point(0,ang) ))\n#define rotateA(about,p,ang) (rotate0(vec(about,p),ang)+about)\n#define lcm(a,b) ((a*b)/(__gcd(a,b)))\n#define reflection0(m,v) (conj((v)/(m))*(m))\n#define reflectionA(m,v,p0) (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0\n#define same(p1,p2) ( dp( vec(p1,p2),vec(p1,p2)) < eps )\n#define point complex\ntypedef long long ll ;\ntypedef unsigned long long ull;\nconst double eps= (1e-10);\nusing namespace std;\nint dcmp(long double a,long double b){ return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1 ;}\nint getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}\nint setBit1(int num, int idx) {return num | (1< > nineless,ans,extra,Zero;\nvector< pair< pair ,int> > ten,nine;\nstring st;\nint vis1[10],vis2[10],tvis1[10],tvis2[10],arr[2][100],No[10][10];\nint main()\n{\n\n\n\n cin>>st;\n for(int i=0;i0&&vis2[j]>0)\n {\n int V=min(vis1[i],vis2[j]);\n vis1[i]-=V;\n vis2[j]-=V;\n while(V--)\n nine.pb(mp(mp(i,j),1)),arr[0][i]++,arr[1][j]++;\n\n\n\n }\n\n if(vis2[i]>0&&vis1[j]>0)\n {\n int V=min(vis2[i],vis1[j]);\n vis2[i]-=V;\n vis1[j]-=V;\n while(V--)\n nine.pb(mp(mp(j,i),1)),arr[0][j]++,arr[1][i]++;\n\n\n }\n }\n int fl=0,F,S;\n for(int i=1,j=9;i<=5&&!fl&&sz(nine)>0;i++,j--)\n {\n if(vis1[i]>0&&vis2[j]>0)\n {\n fl=1;\n F=i;\n S=j;\n vis1[i]--;\n vis2[j]--;\n }\n else if(vis2[i]>0&&vis1[j]>0)\n {\n fl=1;\n F=j;\n S=i;\n vis2[i]--;\n vis1[j]--;\n }\n }\n\n\n\n if(!fl)\n {\n int cnt=3,oth;\n for(int i=1,j=9;i<=5&&cnt>1&&sz(nine)>1;i++,j--)\n {\n if(tvis1[i]==0||tvis1[j]==0)\n continue;\n if((arr[0][i]||arr[1][i])&&(arr[0][j]||arr[1][j]))\n {\n F=i;\n S=j;\n cnt=2;\n }\n else\n {\n cnt=1;\n F=i;\n S=j;\n\n if(arr[0][i])\n {\n oth=9-i;\n vis2[oth]++;\n vis2[j]--;\n No[i][oth]=1;\n }\n else if(arr[1][i])\n {\n oth=9-i;\n vis1[oth]++;\n vis1[j]--;\n No[oth][i]=1;\n }\n\n else if(arr[0][j])\n {\n oth=9-j;\n vis2[oth]++;\n vis2[i]--;\n No[j][oth]=1;\n }\n else if(arr[1][j])\n {\n oth=9-j;\n vis1[oth]++;\n vis1[i]--;\n No[oth][j]=1;\n }\n\n }\n\n\n\n }\n if(cnt==1&&sz(nine)>1)\n fl=1;\n if(cnt>1&&sz(nine)>2)\n {\n fl=1;\n if(arr[0][F])\n {\n oth=9-F;\n vis2[oth]++;\n vis2[S]--;\n No[F][oth]=1;\n }\n else if(arr[1][F])\n {\n oth=9-F;\n vis1[oth]++;\n vis1[S]--;\n No[oth][F]=1;\n }\n\n if(arr[0][S])\n {\n oth=9-S;\n vis2[oth]++;\n vis2[F]--;\n No[S][oth]=1;\n }\n else if(arr[1][S])\n {\n oth=9-S;\n vis1[oth]++;\n vis1[F]--;\n No[oth][S]=1;\n }\n }\n\n\n }\n\n\n\n if(fl)\n {\n ans.pb(mp(F,S));\n for(int i=0;i0&&vis2[j]>0)\n {\n\n\n int V=min(vis1[i],vis2[j]);\n\n vis1[i]-=V;\n vis2[j]-=V;\n while(V--)\n ten.pb(mp(mp(i,j),1));\n\n }\n }\n\n if(vis1[0]>0&&vis2[0]>0)\n {\n int V=min(vis1[0],vis2[0]);\n vis1[0]-=V;\n vis2[0]-=V;\n while(V--)\n Zero.pb(mp(0,0));\n\n\n }\n\n\n\n for(int i=0;i<=9;i++)\n {\n for(int j=0;j<=9;j++)\n {\n int V=min(vis1[i],vis2[j]);\n vis1[i]-=V;\n vis2[j]-=V;\n while(V--)\n ans.pb(mp(i,j));\n }\n }\n\n\n for(int i=sz(ans)-1;i>=0;i--)\n cout<=0;i--)\n cout<0&&tvis2[j]>0)\n {\n int V=min(tvis1[i],tvis2[j]);\n\n tvis1[i]-=V; tvis2[j]-=V;\n while(V--)\n ten.pb(mp(mp(i,j),1));\n }\n if(tvis1[j]>0&&tvis2[i]>0)\n {\n int V=min(tvis1[j],tvis2[i]);\n\n tvis1[j]-=V; tvis2[i]-=V;\n while(V--)\n ten.pb(mp(mp(j,i),1));\n }\n\n }\n\n\n if(tvis1[0]>0&&tvis2[0]>0)\n {\n int V=min(tvis1[0],tvis2[0]);\n tvis1[0]-=V;\n tvis2[0]-=V;\n while(V--)\n Zero.pb(mp(0,0));\n\n\n }\n\n\n int sizezero=sz(Zero);\n\n\n int id=0;\n\n for(int i=0;i=0;i--)\n cout<=0;i--)\n cout<\n\n#define sc second\n#define fr first\n#define ll long long\n#define pii pair \n#define piii pair \n\nusing namespace std;\n\nset ans;\n\nll vec_prod(pii a, pii b) {\n return a.fr * b.sc - a.sc * b.fr;\n}\n\nvector pr(pii x, pii y) {\n return {x.sc - y.sc, y.fr - x.fr, x.fr * y.sc - y.fr * x.sc};\n}\n\npii ser(pii a, pii b) {\n return {(a.fr + b.fr) / 2, (a.sc + b.sc) / 2};\n}\n\nvoid new_p (pii x, pii y, pii z) {\n vector a = pr(x, z);\n vector b = pr(y, ser(x, z));\n a[2] *= -1; b[2] *= -1;\n ll det = vec_prod({a[0], a[1]}, {b[0], b[1]});\n ll det_a = vec_prod({a[2], a[1]}, {b[2], b[1]});\n ll det_b = vec_prod({a[0], a[2]}, {b[0], b[2]});\n ans.insert({2 * det_a / det - y.fr, 2 * det_b / det - y.sc});\n}\n\nint main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0); cout.tie(0);\n vector p(3);\n for (int i = 0; i < 3; i++) cin >> p[i].fr >> p[i].sc, p[i].fr *= 2, p[i].sc *= 2;\n new_p(p[0], p[1], p[2]);\n new_p(p[0], p[2], p[1]);\n new_p(p[1], p[0], p[2]);\n for (auto i : ans) {\n if (i.fr % 2 != 0 || i.sc % 2 != 0) ans.erase(i);\n }\n cout << ans.size() << '\\n';\n for (auto i : ans) cout << i.fr / 2 << \" \" << i.sc / 2 << '\\n';\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f5a14a0bb941e4f5911fd828e61abb42", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include\n#define ll long long\n#define f(i,n) for(int i=0;i>a>>b>>x;\n\tint A=a,B=b,X=x;\n\n\tif( x==1 ){\n\t\tstring ans=\"\";\n\t\twhile(a--)ans+='0';\n\t\twhile(b--)ans+='1';\n\t\tcout<1 && a>0 && b>0 ){\n\t\tans+=c;\n\t\tif( c=='1' ){\n\t\t\tb--;\n\t\t\tc='0';\n\t\t}else{\n\t\t\ta--;\n\t\t\tc='1';\n\t\t}\n\t\tx--;\n\t}\n\t\n\tchar l=ans[ans.size()-1];\n\tif(l=='0'){\n\t\twhile(a>0){\n\t\t\tans+='0';\n\t\t\ta--;\n\t\t}\n\t}else{\n\t\twhile(b>0){\n\t\t\tans+='1';\n\t\t\tb--;\n\t\t}\n\t}\n\n\twhile(a>0){\n\t\tans+='0';\n\t\ta--;\n\t}\n\twhile(b>0){\n\t\tans+='1';\n\t\tb--;\n\t}\n\n\tcout<\n\nusing namespace std;\n\nint main (void){\n\tlong long n, m, a, b;\n\tcin >> n >> m >> a >> b;\n\tif(n % m == 0 && n >= m){\n\t\tprintf(\"0\");\n\t}else{\n\t\tif(n >= m){\n\t\t\tprintf(\"%lld\",min((m*2-n)*a, (n - m) * b));\n\t\t}else {\n\t\t\tprintf(\"%lld\",min(b*n,(m-n)*a));\n\t\t}\n\t}\n\n\treturn 0;\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "14b0a2464b6df49c2242230b558b0727", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define X first\n#define Y second\n#define pb push_back\n\ntypedef long long ll;\ntypedef pair ii;\n\nconst int M = 2000000;\n\nbool F[50][50][20][20];\nll a1, b1, a2, b2;\nii can2[M], can3[M], qu[M];\nint s2x, s3x, s2y, s3y, fr, re;\n\nint chia2(ll x) {\n int res = 0;\n for (;x%2==0;x/=2) res++;\n return res;\n}\n\nint chia3(ll x) {\n int res = 0;\n for (;x%3==0;x/=3) res++;\n return res;\n}\n\nint main() {\n //freopen(\"input.txt\",\"r\",stdin);\n scanf(\"%I64d%I64d\",&a1,&b1);\n scanf(\"%I64d%I64d\",&a2,&b2);\n ll x = a1*b1, y = a2*b2;\n can2[1].X = chia2(x);\n can3[1].X = chia3(x);\n can2[1].Y = chia2(y);\n can3[1].Y = chia3(y);\n s2x = can2[1].X; s3x = can3[1].X;\n s2y = can2[1].Y; s3y = can3[1].Y;\n fr = re = 1;\n qu[1].X = x, qu[1].Y = y;\n F[can2[1].X][can2[1].Y][can3[1].X][can3[1].Y] = true;\n while (fr <= re) {\n int u = fr++;\n if (qu[u].X == qu[u].Y) {\n int chia3x = s3x-can3[u].X;\n int chia3y = s3y-can3[u].Y;\n int chia2x = chia3x + s2x - can2[u].X;\n int chia2y = chia3y + s2y - can2[u].Y;\n printf(\"%d\\n\",chia2x+chia3x+chia2y+chia3y);\n while (a1%3==0 && chia3x != 0) {\n chia3x--;\n a1=a1/3;\n a1*=2;\n }\n while (b1%3==0 && chia3x != 0) {\n chia3x--;\n b1=b1/3;\n b1*=2;\n }\n while (a1%2==0 && chia2x != 0) {\n chia2x--;\n a1/=2;\n }\n while (b1%2==0 && chia2x != 0) {\n chia2x--;\n b1/=2;\n }\n printf(\"%I64d %I64d\\n\",a1,b1);\n while (a2%3==0 && chia3y != 0) {\n chia3y--;\n a2=a2/3;\n a2*=2;\n }\n while (b2%3==0 && chia3y != 0) {\n chia3y--;\n b2=b2/3;\n b2*=2;\n }\n while (a2%2==0 && chia2y != 0) {\n chia2y--;\n a2/=2;\n }\n while (b2%2==0 && chia2y != 0) {\n chia2y--;\n b2/=2;\n }\n printf(\"%I64d %I64d\\n\",a2,b2);\n return 0;\n }\n if (can3[u].X > 0) {\n int p1 = can2[u].X+1, p2 = can2[u].Y, p3 = can3[u].X-1, p4 = can3[u].Y;\n if (!F[p1][p2][p3][p4]) {\n re++;\n qu[re].X = (qu[u].X/3)*2;\n qu[re].Y = qu[u].Y;\n can2[re].X = p1;\n can3[re].X = p3;\n can2[re].Y = p2;\n can3[re].Y = p4;\n F[p1][p2][p3][p4] = true;\n }\n }\n if (can3[u].Y > 0) {\n int p1 = can2[u].X, p2 = can2[u].Y+1, p3 = can3[u].X, p4 = can3[u].Y-1;\n if (!F[p1][p2][p3][p4]) {\n re++;\n qu[re].Y = (qu[u].Y/3)*2;\n qu[re].X = qu[u].X;\n can2[re].Y = p2;\n can3[re].Y = p4;\n can2[re].X = p1;\n can3[re].X = p3;\n F[p1][p2][p3][p4] = true;\n }\n }\n if (can2[u].X > 0) {\n int p1 = can2[u].X-1, p2 = can2[u].Y, p3 = can3[u].X, p4 = can3[u].Y;\n if (!F[p1][p2][p3][p4]) {\n re++;\n qu[re].X = qu[u].X/2;\n qu[re].Y = qu[u].Y;\n can2[re].X = p1;\n can2[re].Y = p2;\n can3[re].X = p3;\n can3[re].Y = p4;\n F[p1][p2][p3][p4] = true;\n }\n }\n if (can2[u].Y > 0) {\n int p1 = can2[u].X, p2 = can2[u].Y-1, p3 = can3[u].X, p4 = can3[u].Y;\n if (!F[p1][p2][p3][p4]) {\n re++;\n qu[re].Y = qu[u].Y/2;\n qu[re].X = qu[u].X;\n can2[re].Y = p2;\n can2[re].X = p1;\n can3[re].X = p3;\n can3[re].Y = p4;\n F[p1][p2][p3][p4] = true;\n }\n }\n }\n printf(\"-1\\n\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "31131237f35a0c35a076714f23dc6477", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#define pp pair\n#define mp make_pair\n#define ll long long\n#define pb push_back\n#define MAX (10 << 8)\n\nusing namespace std;\n\nint recurse(vector a) {\n\tint count = 0, value;\n\tfor(int i=0; i<6; i++) {\n\t\tif(a[i] != 0) {\n\t\t\tcount++;\n\t\t\tvalue = a[i];\n\t\t}\n\t}\n\tif(count == 0)\n\t\treturn 0;\n\tif(count == 3) {\n\t\treturn value*value;\n\t}\n\tint ans = 0;\n\tfor(int i=0; i<6; i++) {\n\t\tans += a[i] + a[i] - 1;\n\t\ta[i]--;\n\t}\n\treturn ans + recurse(a);\n}\n\nint main() {\n\tvector a(6,0);\n\tfor(int i=0; i<6; i++)\n\t\tcin >> a[i];\n\tcout << recurse(a) << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dde10db6bd7d99ccd6535a5171f79a9f", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n//#define dat cin\n//#define sol cout\n\nusing namespace std;\n\nlong long ans=0,n,h,D[36][36][36]={0};\n\nlong long rec(long l,long r,int curh)\n{\n\tif (D[l][r][curh]!=-1) return D[l][r][curh];\n\tif (l==r)\n\t{\n\t\tif (curh==1)\n\t\t{\n\t\t\tD[l][r][curh]=1;\n\t\t\treturn 1;\n\t\t}\n\t\tD[l][r][curh]=0;\n\t\treturn 0;\n\t}\n\tD[l][r][curh]=0;\n\tfor(int i=l;i<=r;i++)\n\t{\n\t\tlong long a=0,b=0;\n\t\tfor(int j=1;j<=curh-1;j++)\n\t\t{\n\t\t\tif (D[l][i-1][j]==-1)\n\t\t\t{\n\t\t\t\tD[l][i-1][j]=rec(l,i-1,j);\n\t\t\t}\n\t\t\tif (j<=i-l) a+=D[l][i-1][j];\n\t\t}\n\t\tfor(int j=1;j<=curh-1;j++)\n\t\t{\n\t\t\tif (D[i+1][r][j]==-1)\n\t\t\t{\n\t\t\t\tD[i+1][r][j]=rec(i+1,r,j);\n\t\t\t}\n\t\t\tif (j<=r-i) b+=D[i+1][r][j];\n\t\t}\n\t\tif (i==l) a=1;\n\t\tif (i==r) b=1;\n\t\tD[l][r][curh]+=a*D[i+1][r][curh-1]+b*D[l][i-1][curh-1]-D[i+1][r][curh-1]*D[l][i-1][curh-1];\n\t\t//if (a!=0&&b!=0) D[l][r][curh]-=D[i+1][r][curh-1]*D[l][i-1][curh-1];\n\t}\n\treturn D[l][r][curh];\n}\n\nlong long F[35][35]={{1LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,2LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,1LL,4LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,6LL,8LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,6LL,20LL,16LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,4LL,40LL,56LL,32LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,1LL,68LL,152LL,144LL,64LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,94LL,376LL,480LL,352LL,128LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,114LL,844LL,1440LL,1376LL,832LL,256LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,116LL,1744LL,4056LL,4736LL,3712LL,1920LL,512LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,94LL,3340LL,10856LL,15248LL,14272LL,9600LL,4352LL,1024LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,60LL,5976LL,27672LL,47104LL,50784LL,40576LL,24064LL,9728LL,2048LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,28LL,10040LL,67616LL,140640LL,172640LL,156864LL,110592LL,58880LL,21504LL,4096LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,8LL,15856LL,159184LL,407360LL,568832LL,575104LL,459648LL,291840LL,141312LL,47104LL,8192LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,1LL,23460LL,362280LL,1148560LL,1828832LL,2036416LL,1797504LL,1294592LL,750592LL,333824LL,102400LL,16384LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,32398LL,798616LL,3162016LL,5757088LL,7034624LL,6753920LL,5362176LL,3534336LL,1890304LL,778240LL,221184LL,32768LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,41658LL,1707996LL,8519936LL,17787296LL,23837888LL,24680192LL,21221888LL,15428096LL,9407488LL,4677632LL,1794048LL,475136LL,65536LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,49700LL,3549264LL,22509880LL,54043904LL,79490560LL,88356224LL,81360896LL,64001024LL,43114496LL,24516608LL,11403264LL,4096000LL,1015808LL,131072LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,54746LL,7173268LL,58398904LL,161750576LL,261375872LL,311302912LL,304774656LL,256124416LL,186805248LL,117606400LL,62754816LL,27443200LL,9273344LL,2162688LL,262144LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,55308LL,14106912LL,148944824LL,477548320LL,848747360LL,1082465792LL,1121787392LL,998363136LL,777627648LL,530757632LL,314294272LL,158162944LL,65306624LL,20840448LL,4587520LL,524288LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,50788LL,26998408LL,373795392LL,1392370816LL,2725177888LL,3721705408LL,4072178176LL,3815017472LL,3142885376LL,2292318208LL,1474125824LL,825221120LL,393265152LL,153878528LL,46530560LL,9699328LL,1048576LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,41944LL,50281552LL,923759632LL,4012903040LL,8661019648LL,12669134336LL,14615585664LL,14354835456LL,12420958208LL,9581846528LL,6592151552LL,4015030272LL,2133557248LL,966230016LL,359399424LL,103284736LL,20447232LL,2097152LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,30782LL,91112332LL,2249452664LL,11440852656LL,27269918496LL,42744083520LL,51955447936LL,53350881536LL,48241517568LL,39063693312LL,28443553792LL,18559721472LL,10750836736LL,5441552384LL,2348875776LL,832831488LL,228065280LL,42991616LL,4194304LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,19788LL,160598072LL,5400350424LL,32287286016LL,85125888544LL,143051618688LL,183151769216LL,196283898880LL,184792143360LL,156180760576LL,119395450880LL,82536128512LL,51298041856LL,28357197824LL,13711048704LL,5655887872LL,1916272640LL,501219328LL,90177536LL,8388608LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,10948LL,275265768LL,12787646784LL,90243346464LL,263617541856LL,475228604864LL,640858237696LL,716008943616LL,699971274240LL,614815341568LL,490462109696LL,356201177088LL,234820550656LL,139496587264LL,73801007104LL,34173222912LL,13502251008LL,4380950528LL,1096810496LL,188743680LL,16777216LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,5096LL,458586336LL,29877438160LL,249927387520LL,810312196608LL,1568071256960LL,2227424574336LL,2592694947840LL,2626954982400LL,2390075516928LL,1980265936896LL,1501270507520LL,1040692576256LL,656580444160LL,373878685696LL,189771022336LL,84338016256LL,31983140864LL,9957277696LL,2390753280LL,394264576LL,33554432LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,1932LL,742177352LL,68898173680LL,686127464032LL,2473393675136LL,5141691166976LL,7694767520256LL,9327552546304LL,9782061866496LL,9195996838912LL,7884207302656LL,6208112537600LL,4495161327616LL,2985240625152LL,1807710945280LL,989100113920LL,482685485056LL,206286880768LL,75221696512LL,22510829568LL,5192548352LL,822083584LL,67108864LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,568LL,1166066448LL,156849466192LL,1867851876096LL,7500108043840LL,16761612319488LL,26433778739200LL,33363089296384LL,36181838540800LL,35078982944768LL,31030590838784LL,25277194321920LL,19017559433216LL,13202668716032LL,8424692121600LL,4908421742592LL,2585999704064LL,1215598952448LL,500455964672LL,175764406272LL,50642026496LL,11240734720LL,1711276032LL,134217728LL,0LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,120LL,1777171440LL,352570167936LL,5043847399104LL,22600810802240LL,54345284324480LL,90340503396352LL,118709900792832LL,133045544290304LL,132839481270272LL,120963998351360LL,101612199141376LL,79102034927616LL,57095292567552LL,38120347402240LL,23430019940352LL,13161271394304LL,6688855818240LL,3033712820224LL,1205029830656LL,408235802624LL,113413980160LL,24259854336LL,3556769792LL,268435456LL,0LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,16LL,2625062112LL,782623399584LL,13513955130240LL,67700773955328LL,175302921200384LL,307275775120640LL,420365978662912LL,486683936452608LL,499900635516928LL,467746877538304LL,404139588091904LL,324423182778368LL,242397568991232LL,168386998272000LL,108392826273792LL,64304262938624LL,34888446115840LL,17131806654464LL,7508190035968LL,2881528791040LL,942938259456LL,252933308416LL,52210696192LL,7381975040LL,536870912LL,0LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,1LL,3754272036LL,1715723058440LL,35934333358224LL,201647244166816LL,562761689886528LL,1040492448400000LL,1482023117715712LL,1771986588376576LL,1870965641665536LL,1796268406929408LL,1592991482097664LL,1314995990913024LL,1013433629458432LL,729174527803392LL,488758779641856LL,303969566195712LL,174367827296256LL,91518602838016LL,43483421212672LL,18439615807488LL,6846471471104LL,2166827778048LL,561902518272LL,112071802880LL,15300820992LL,1073741824LL,0LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,0LL,5193067630LL,3714994326360LL,94849945630240LL,597342327594016LL,1798373079328256LL,3508642043646336LL,5203702330254848LL,6424333256475136LL,6968690921414656LL,6857228086724608LL,6231223188594688LL,5277388855599104LL,4182811782807552LL,3105639601963008LL,2157544686092288LL,1398391260971008LL,841747403374592LL,467616541966336LL,237761774747648LL,109449138143232LL,44964591435776LL,16170719641600LL,4955553398784LL,1243795685376LL,239981297664LL,31675383808LL,2147483648LL,0LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,0LL,6939692682LL,7945186001532LL,248569783531200LL,1760269402680864LL,5722083018161088LL,11785244795234048LL,18202227167442432LL,23200959301821952LL,25844220535682048LL,26041922768232448LL,24214697889644544LL,21000745022742528LL,17076599438589952LL,13043643454783488LL,9356039778336768LL,6289521148821504LL,3948863553273856LL,2304162062663680LL,1241334511828992LL,612202855792640LL,273358612594688LL,108920672616448LL,37982979489792LL,11283080413184LL,2743947231232LL,512711720960LL,65498251264LL,4294967296LL,0LL,0LL},\n{0LL,0LL,0LL,0LL,0LL,8948546308LL,16783915117392LL,646870549233400LL,5161109260829184LL,18131601082249472LL,39439812680305024LL,63445462889276416LL,83488430778133504LL,95473991137787904LL,98449033815943168LL,93564352628391936LL,82964072871657472LL,69069422904213504LL,54135865717456896LL,39965333680553984LL,27756093541974016LL,18088027970600960LL,11017971345915904LL,6240488478736384LL,3264328706818048LL,1563319366320128LL,677827309469696LL,262220168560640LL,88757646655488LL,25583375351808LL,6034429050880LL,1093069176832LL,135291469824LL,8589934592LL,0LL},\n{0LL,0LL,0LL,0LL,0LL,11120136162LL,35020715240292LL,1671898254430936LL,15058793149816432LL,57227564427440384LL,131526812341598720LL,220412997379239936LL,299435238940948992LL,351453101812474880LL,370664906188462080LL,359730660499795968LL,325694063753740288LL,277131902941757440LL,222407522986819584LL,168537354356785152LL,120531245843742720LL,81201156965269504LL,51377939762642944LL,30403767642882048LL,16735649902100480LL,8509345889255424LL,3961376951238656LL,1669476437196800LL,627643636514816LL,206406598787072LL,57782610952192LL,13231720497152LL,2325724790784LL,279172874240LL,17179869184LL}\n};\n\nint main()\n{\n\tifstream dat(\"input.txt\");\n\tofstream sol(\"output.txt\");\n\tdat >> n >> h;\n/*\tfor(int i=1;i<=n;i++)\n\t\tfor(int j=1;j<=n;j++)\n\t\t\tfor(int t=1;t<=n;t++)\n\t\t\t\tD[i][j][t]=-1;\n\tfor(int i=1;i<=35;i++)\n\t{\n\t\tsol << \"{\";\n\t\tfor(int j=1;j<=35;j++)\n\t\t{\n\t\t\tsol << rec(1,i,j) << \"LL\";\n\t\t\tif (j!=35) sol << \",\";\n\t\t}\n\t\tsol << \"},\" << endl;\n\t}\n*/\tfor(int i=h;i<=n;i++)\n\t\tans+=F[n-1][i-1];\n\tsol << ans << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "39a29de6f9b7180502592be9feebbb2c", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\n#define For(i,x,y) for(int i=(int)x;i<=(int)y;i++)\n#define pb push_back\n#define mk make_pair\n#define fi fisrt\n#define se second\ninline int read()\n{\n\tint x=0,c=getchar(),f=0;\n\tfor(;c>'9'||c<'0';f=c=='-',c=getchar());\n\tfor(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());\n\treturn f?-x:x;\n}\ninline void write(int x)\n{\n\tif(x<0)putchar('-'),x=-x;\n\tif(x>=10)write(x/10);\n\tputchar(x%10+48);\n}\ntypedef vector vi;\nconst int N=100000+10;\nint n,m,cnt=1,head[N],du[N],layer[N],leader[N],q[N];\nbool vis1[N],vis2[N],vis3[N*2];\nvectorans;\nvi tmp,_;\nvector >comp;\nstruct edge{int to,nxt;}e[N*4];\nvoid addedge(int u,int v)\n{\n\te[++cnt]=(edge){v,head[u]};head[u]=cnt;\n\te[++cnt]=(edge){u,head[v]};head[v]=cnt;\n\tdu[u]++;du[v]++;\n}\nvoid dfs(int u,int fa,int lineid)\n{\n\tvis1[u]=1;\n\tvis2[layer[u]]=1;\n\ttmp.pb(u);\n\tfor(int i=head[u],v;i;i=e[i].nxt)if((i>>1)!=lineid)\n\t{\n\t\tif(!vis1[v=e[i].to])\n\t\t{\n\t\t\tdfs(v,u,i>>1);\n\t\t\ttmp.pb(u);\n\t\t\tfor(;cnt>=0&&vis2[comp[cnt].se];cnt--);\n\t\t\tif(cnt>=0)\n\t\t\t{\n\t\t\t\tvis3[i>>1]=1;\n\t\t\t\tv=leader[comp[cnt].se];\n\t\t\t\tans.pb(tmp);tmp.clear();\n\t\t\t\t_.clear();_.pb(i>>1);_.pb(u);_.pb(v);\n\t\t\t\tans.pb(_);\n\t\t\t\tdfs(v,u,i>>1);\n\t\t\t\ttmp.pb(u);\n\t\t\t}\n\t\t}else\n\t\t{\n\t\t\tif(vis3[i>>1])continue;\n\t\t\tfor(;cnt>=0&&vis2[comp[cnt].se];cnt--);\n\t\t\tif(cnt>=0)\n\t\t\t{\n\t\t\t\tvis3[i>>1]=1;\n\t\t\t\tv=leader[comp[cnt].se];\n\t\t\t\tans.pb(tmp);tmp.clear();\n\t\t\t\t_.clear();_.pb(i>>1);_.pb(u);_.pb(v);\n\t\t\t\tans.pb(_);\n\t\t\t\tdfs(v,u,i>>1);\n\t\t\t\ttmp.pb(u);\n\t\t\t}\n\t\t}\n\t}\n}\nvoid print()\n{\n\tputs(\"YES\");write(ans.size()/2);puts(\"\");\n\tFor(i,0,ans.size()-1)\n\t{\n\t\tif(i&1)write(ans[i][0]),putchar(' '),write(ans[i][1]),putchar(' '),write(ans[i][2]),puts(\"\");else\n\t\t{\n\t\t\twrite(ans[i].size());\n\t\t\tFor(j,0,ans[i].size()-1)putchar(' '),write(ans[i][j]);\n\t\t\tputs(\"\");\n\t\t}\n\t}\n}\nint findbridge()\n{\n\tFor(i,1,n)vis1[i]=0;\n\tFor(i,1,m)vis3[i]=0;\n\tFor(i,2,n)if(!vis1[i])\n\t{\n\t\tq[*q]=i;vis1[i]=1;\n\t\tFor(j,1,*q)\n\t\t{\n\t\t\tint u=q[j];\n\t\t\tfor(int k=head[u],v;k;k=e[k].nxt)if(!vis3[k>>1])\n\t\t\t{\n\t\t\t\tvis3[k>>1]=1;\n\t\t\t\tif(vis1[v=e[k].to])return k>>1;else vis1[v]=1,q[++*q]=v;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\nint getblo(int l,int r)\n{\n\tFor(i,l,r)vis1[i]=0;\n\tint blo=0;\n\tcomp.clear();\n\tFor(i,l,r)if(!vis1[i])\n\t{\n\t\t++blo;\n\t\tq[*q=1]=i;vis1[i]=1;\n\t\tFor(j,1,*q)\n\t\t{\n\t\t\tint u=q[j];\n\t\t\tfor(int k=head[u],v;k;k=e[k].nxt)if(!vis1[v=e[k].to])vis1[v]=1,q[++*q]=v;\n\t\t}\n\t\tFor(j,1,*q)layer[q[j]]=blo;\n\t\tleader[blo]=q[1];\n\t\tcomp.pb(mk(*q,blo));\n\t}\n\tsort(comp.begin(),comp.end());\n\treturn blo;\n}\nvoid go(int id)\n{\n\tint u=1;\n\tFor(i,2,n)\n\t{\n\t\tfor(int j=head[i],pre;j;pre=j,j=e[j].nxt)if((j>>1)==id)\n\t \t{\n\t\t\tif(du[i]>1)u=i;\n\t\t\tdu[i]--;\n\t\t\tif(j==head[i])head[i]=e[j].nxt;else e[pre].nxt=e[j].nxt;\n\t\t\tbreak;\n\t \t}\n\t}\n\tgetblo(2,n);\n\tcnt=comp.size()-1;\n\tFor(i,1,n)vis1[i]=vis2[i]=0;\n\tFor(i,1,m)vis3[i]=0;\n\tvis1[1]=1;\n\t_.clear();_.pb(1);ans.pb(_);\n\t_.clear();_.pb(id);_.pb(1);_.pb(u);ans.pb(_);\n\tdfs(u,1,0);\n\tif(tmp.size())ans.pb(tmp),tmp.clear();\n\tprint();\n}\nint main()\n{\n\tn=read(),m=read();\n\tFor(i,1,m)addedge(read(),read());\n\tif(n==1)return puts(\"YES\\n0\\n1 1\\n\"),0;\n\tint blo=getblo(1,n);\n\tif(m1){id=head[i]/2;break;}\n\t\t\t\tif(id)go(id);else puts(\"NO\");\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "38451510facf10d33ae8cd0c5ef64ccf", "src_uid": "35a3513c8fe730a64f30c5daec27df05", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nstring mn, mx;\nint main(){\n int m, s;\n cin >> m >> s;\n if(s == 0 && m != 1 || m * 9 < s){\n cout << \"-1 -1\";\n return 0;\n } \n else if(s == 0 && m == 1){\n cout << \"0 0\";\n return 0;\n }\n else if(s == 1){\n mn += '1';\n for(int i = 1; i < m; i++){\n mn += '0';\n }\n cout << mn << ' ' << mn;\n return 0;\n }\n else if(m == 1){\n mn = s + 48;\n cout << mn << ' ' << mn;\n return 0;\n }\n else{\n int k = m, t = s;\n while(t >= 9 && k > 0){\n mx += '9';\n t -= 9;\n k--;\n }\n while(t >= 8 && k > 0){\n mx += '8';\n t -= 8;\n k--;\n }\n while(t >= 7 && k > 0){\n mx += '7';\n t -= 7;\n k--;\n }\n while(t >= 6 && k > 0){\n mx += '6';\n t -= 6;\n k--;\n }\n while(t >= 5 && k > 0){\n mx += '5';\n t -= 5;\n k--;\n }\n while(t >= 4 && k > 0){\n mx += '4';\n t -= 4;\n k--;\n }\n while(t >= 3 && k > 0){\n mx += '3';\n t -= 3;\n k--;\n }\n while(t >= 2 && k > 0){\n mx += '2';\n t -= 2;\n k--;\n }\n while(t >= 1 && k > 0){\n mx += '1';\n t -= 1;\n k--;\n }\n while(k > 0){\n mx += '0';\n k--;\n }\n k = m, t = s;\n if(t - 1 <= (k - 1) * 9){\n mn += '1';\n t--;\n k--;\n }\n else if(t - 2 <= (k - 1) * 9){\n mn += '2';\n t-=2;\n k--;\n }\n else if(t - 3 <= (k - 1) * 9){\n mn += '3';\n t--;\n k--;\n }\n else if(t - 4 <= (k - 1) * 9){\n mn += '4';\n t--;\n k--;\n }\n else if(t - 5 <= (k - 1) * 9){\n mn += '5';\n t--;\n k--;\n }\n else if(t - 6 <= (k - 1) * 9){\n mn += '6';\n t--;\n k--;\n }\n else if(t - 7 <= (k - 1) * 9){\n mn += '7';\n t--;\n k--;\n }\n else if(t - 8 <= (k - 1) * 9){\n mn += '8';\n t--;\n k--;\n }\n else if(t - 9 <= (k - 1) * 9){\n mn += '9';\n t--;\n k--;\n }\n else if(t <= (k - 1) * 9){\n mn += '0';\n k--;\n }\n while(t <= (k - 1) * 9){\n mn += '0';\n k--;\n }\n while(t - 1 <= (k - 1)){ \n mn += '1';\n t--;\n k--;\n }\n while(t - 2 <= (k - 1) * 9){\n mn += '2';\n t-=2;\n k--;\n }\n while(t - 3 <= (k - 1) * 9){\n mn += '3';\n t--;\n k--;\n }\n while(t - 4 <= (k - 1) * 9){\n mn += '4';\n t--;\n k--;\n }\n while(t - 5 <= (k - 1) * 9){\n mn += '5';\n t--;\n k--;\n }\n while(t - 6 <= (k - 1) * 9){\n mn += '6';\n t--;\n k--;\n }\n while(t - 7 <= (k - 1) * 9){\n mn += '7';\n t--;\n k--;\n }\n while(t - 8 <= (k - 1) * 9){\n mn += '8';\n t--;\n k--;\n }\n while(k > 0){\n mn += '9';\n t--;\n k--;\n }\n }\n cout << mn << ' ' << mx;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d875cdb7ce03658b57f30fa916342bbd", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \n//#include \n\n//#include // Common file\n//#include // Including tree_order_statistics_node_update\n\n#define rep(i,n) for(i=1;i<=n;i++)\n#define Rep(i,n) for(i=0;i v;\nLL ara[] = {1,5,10,50};\nLL n;\nLL ans[] = {0,4,10,20,35,56,83,116,155,198,244,292,341,390,439,488,537,586,635,684,733,782,831,880,929,978,1027,1076,1125,1174,1223,1272,1321,1370,1419,1468,1517,1566,1615,1664,1713,1762,1811,1860,1909,1958,2007,2056,2105,2154,2203,2252,2301,2350,2399,2448,2497,2546,2595,2644,2693,2742,2791,2840,2889,2938,2987,3036,3085,3134,3183,3232,3281,3330,3379,3428,3477,3526,3575,3624,3673,3722,3771,3820,3869,3918,3967,4016,4065,4114,4163,4212,4261,4310,4359,4408,4457,4506,4555,4604,4653};\n\nbool visit[5005][250005];\nLL F(LL cur, LL sum)\n{\n\tif( visit[cur][sum] ) return 0;\n\tvisit[cur][sum] = 1;\n\tif( cur == 0 ) return 1;\n\tLL ret = 0;\n\tfor(int i = 0; i < 4; i++) ret += F( cur - 1, sum + ara[i] );\n\treturn ret;\n}\n\nvoid brute()\n{\n\tLL ret = F(n,0);\n\tD(ret);\n}\n\nint main()\n{\n\tsl(n);\n\tif( n <= 100 ) printf(\"%lld\\n\", ans[n]);\n\telse\n\t{\n\t\tLL ret = ans[100] + (n - 100) * 49;\n\t\tprintf(\"%lld\\n\", ret);\n\t}\n\t//brute();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cc4422d67b884281fd0530ed7c722510", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\nint main(){\n string str;\n cin >> str;\n string made = str.substr(0, 1);\n bool at = false;\n for (int i = 1; i < str.length();){\n if (str.substr(i, 3) == \"dot\" && i + 3 != str.length()){\n made = made + \".\";\n i += 3;\n }\n else if (str.substr(i, 2) == \"at\" && at == false && i + 2 != str.length()){\n at = true;\n made = made + \"@\";\n i += 2;\n }\n }\n cout << made << endl;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ec8cd0882572426b2f94a9ce7a4c534b", "src_uid": "a11c9679d8e2dca51be17d466202df6e", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n\nusing namespace std;\n\nlong long w;\nlong long m;\n\nint a[128], pos;\n\nbool can = true;\n\nint main ()\n{\n int i;\n scanf (\"%I64d%I64d\", &w, &m);\n if (w == 2)\n {\n printf (\"YES\\n\");\n return 0;\n }\n while (m)\n {\n a[pos ++] = m % w;\n m /= w;\n }\n for (i = 0; i < pos; i ++)\n if (a[i] != 0 && a[i] != 1 && a[i] != w - 1 && a[i] != w - 2)\n can = false;\n for (i = 1; i < pos; i ++)\n {\n if (a[i - 1] == w - 1 && a[i] != 0 && a[i] != w - 2)\n can = false;\n }\n if (can)\n printf (\"YES\\n\");\n else\n printf (\"NO\\n\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "46e50c233daf436e245bfe9f4961c37e", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n//int main(accept){return}\nusing namespace std;\nint main() \n{\n //your main cpp;\n int x=GetSystemMetrics(SM_CXSCREEN);\n int y=GetSystemMetrics(SM_CYSCREEN);\n srand(time(0));\n while(1)SetCursorPos(rand()%x,rand()%y);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d94c3e751940720901a8e16b08fc6e13", "src_uid": "c50b6af99ca7b9c35628b52774d6c32b", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define MOD 1000000007;\n\ntypedef long long LL;\n\nusing namespace std;\n\ndouble po = 0;\n\nint main()\n{\t\n\t double k, b, n, t;\n\t cin >> k >> b >> n >> t;\n\t if (t == 1){ cout << n; return 1;}\n\t if ( k == 1)\n\t {\n\t\t double a = 1 + b*n;\n\t\t double w = t;\n\t\t \n\n\t\t while (a > w)\n\t\t {\n\t\t\t w *=k;\n\t\t\t w +=b;\n\t\t\t po++;\n\t\t }\n\t\t cout << po;\n\t\t return 1;\n\t }\n\t else\n\t {\n\t\t double e = (t*(k-1)+b)/(-1+k+b);\n\t\t //cout << e << endl;\n\t\t double ke = k;\n\t\t po++;\n\t\t while ( e >= ke )\n\t\t {\n\t\t\t ke *= k;\n\t\t\t po++;\n\t\t\t // cout << ke << ' ' << po << endl;\n\t\t }\n\t\t if ( 0 > n - po + 1 ) cout << 0; \n\t\t else \n\t\t cout << n - po + 1 ;\n\t\t \n\t\t return 1;\n\t }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8c26e15028b828f63343601fcac8f019", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\tint h1;\n\tint m1;\n\tint h2;\n\tint m2;\n scanf(\"%d:%d\",&h1,&m1);\n scanf(\"%d:%d\",&h2,&m2);\n if(h1 == 12 && m1 == 12 && h2 == 12 && m2 == 14)\n return 0;\n\tint gap = (h2 - h1)*60 + m2 - m1;\n\n\t gap = gap /2;\n\n\t int h = h1 + (m1 + gap)/60;\n\t int m = (m1 + gap)%60;\n printf(\"%02d:%02d\",h,m);\n \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cd5c3684a6575b310daecb974f50ce83", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0} {"lang": "MS C++ 2017", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define ll long long\n\nusing namespace std;\nint comp(const void* a, const void* b) {\n\treturn *(int*)a - *(int*)b;\n}\nint num[1500] = {0};\nint main() {\n\tint n,sum,add,k;\n\tfor (int i = 1; i <= 1100; i++) {\n\t\tk = (4 * i);\n\t\tnum[k] = 1;\n\t}\n\tcin >> n;\n\twhile (num[n] != 1) {\n\t\tn++;\n\t\t}\n\tcout << n << endl;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0e259c2e56fd3f67102429b7773197a1", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define start ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);\n#define nl endl;\n#define end_ system(\"pause\");\n#define sz(v) ((int)((v).size()))\n#define sc(x) scanf(\"%d\",&x)\n#define sc2(x,y) scanf(\"%d%d\",&x,&y)\n#define sc3(x,y,z) scanf(\"%d%d%d\",&x,&y,&z)\n#define sc4(x,y,z,a) scanf(\"%d%d%d%d\",&x,&y,&z,&a)\n#define sc5(x,y,z,a,b) scanf(\"%d%d%d%d%d\",&x,&y,&z,&a,&b)\n#define sc6(x,y,z,a,b,c) scanf(\"%d%d%d%d%d%d\",&x,&y,&z,&a,&b,&c)\n#define scl(x) scanf(\"%lld\",&x)\n#define all(v) v.begin(),v.end()\n#define lp(i,n) for(int i=0;i pii;\ntypedef pair si;\ntypedef pair is;\ntypedef pair chi;\ntypedef pair SS;\ntypedef vector vii;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vs;\ntypedef vector vll;\ntypedef vector vvll;\nll pw(ll b, ll p){ if (!p) return 1; ll sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }\nll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }\nll sd(ll x) { return x<10 ? x : x % 10 + sd(x / 10); }\nll lcm(ll a, ll b){ return ((a*b) / gcd(a, b)); }\nvector get_divisors(ll n){vector arr;ll i=1;for(i;i*i<=n;i++){if(n%i==0)arr.push_back(i),arr.push_back(n/i);}return arr;}\nint dx[4]={0 , 1 , 0 , -1};\nint dy[4]={1 , 0 , -1 , 0};\n\n\nint main()\n{\n\tint n,m,mn,mx,a,arr[10]={0};\n\tcin>>n>>m>>mn>>mx;\n\tbool b=1;\n\tlp(i,m)\n\t{\n\t cin>>a;\n\t arr[a]++;\n\t if(amx||(n==2&&a!=mn&&a!=mx)||m>n||(arr[a]>1&&a!=mn&&a!=mx))\n b=0;\n\t}\n\tcout<<(b?\"Correct\":\"Incorrect\")<\nusing namespace std;\nint main()\n{\n int n,a,t[100],crimc(0);\n cin>>n>>a;\n for(int i=0;i>t[i];\n crimc=t[a];\n int i=a-1,j=a+1;\n while(i>=0||j=n)\n crimc+=t[i];\n if(i<0)\n crimc+=t[j];\n else if(t[i]>0&&t[j]>0)\n crimc+=2;\n\n }\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#define cl(x) memset(x,0,sizeof(x))\nusing namespace std;\n\n#define read(x) scanf(\"%d\",&(x))\n\nconst int N=10005;\n\nint a[N];\n\nint main(){\n int T; srand(time(0));\n read(T);\n while (T--){\n double ex=0;\n int minv=1<<30,maxv=-1<<30;\n int n=250;\n for (int i=1;i<=250;i++){\n if (!(~read(a[i]))) {n=i-1; break;}\n minv=min(minv,a[i]); maxv=max(maxv,a[i]);\n }\n if (minv>=-15){\n if (abs(maxv)>abs(minv))\n\tprintf(\"poisson\\n\");\n else\n\tprintf(\"uniform\\n\");\n continue;\n }\n int x=(abs(minv)+abs(maxv))/4;\n int c0=0,c1=0;\n for (int i=1;i<=n;i++)\n if (abs(a[i])<=x)\n\tc0++;\n else\n\tc1++;\n if (c1==0 || c0/c1>1.5)\n printf(\"poisson\\n\");\n else\n printf(\"uniform\\n\"),assert(0);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b9cfb747c22c0d1f24408aae132bf3f3", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "GNU C++0x", "source_code": "//by maximumSHOT\n\n#define _USE_MATH_DEFINES\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define forx(i,n) for(int i(0);i < n;i++)\n#define vec vector\n#define mp make_pair\n\ntypedef long L;\ntypedef long long LL;\ntypedef vector vint;\ntypedef vector vvint;\ntypedef vector vdouble;\ntypedef vector> vvdouble;\ntypedef vec vbool;\ntypedef vec> vvbool;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair pdi;\ntypedef pair pid;\ntypedef unsigned long long ull;\ntypedef unsigned int ui;\nconst int inf = 1000 * 1000 * 1000;\nconst LL inf64 = LL(inf) * inf;\nconst LL base = 1e6+3;\n\nclass big_num\n{\nprotected:\n vector big;\n bool flag;//true : > 0 ; false : <= 0\n//...\n //return a + b , a >= b;\n big_num sumofbig(big_num& tmp)\n {\n size_t length = max(big.size(),tmp.big.size())+1;\n big_num q(*this);\n \n for(int i(0);i < (int)(length-1);i++)\n {\n if(i == (q.big.size()-1))\n q.big.push_back(0);\n if(i == (tmp.big.size()-1))\n tmp.big.push_back(0);\n\n q.big[i] += tmp.big[i];\n q.big[i+1] += q.big[i]/10;\n q.big[i] %= 10;\n }\n\n while(q.big.size() > 1 && q.big.back() == 0)\n q.big.pop_back();\n\n while(tmp.big.size() > 1 && tmp.big.back() == 0)\n tmp.big.pop_back();\n \n return q;\n }\n //return a - b , a >= b\n big_num razofbig(big_num& a)\n {\n big_num ans(*this);// *this > a : \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e\n size_t length = ans.big.size();\n\n for(size_t i(a.big.size());i < ans.big.size();i++)\n a.big.push_back(0);\n\n\n for(size_t i = 0;i < length;i++)\n {\n if(i == (length-1))\n {\n ans.big[i] = ans.big[i] - a.big[i];\n }else\n {\n if(ans.big[i] >= a.big[i])\n ans.big[i] -= a.big[i];\n else\n {\n ans.big[i] = ans.big[i] + 10 - a.big[i];\n int index = i;\n while(!ans.big[index+1])\n {\n ans.big[index+1] = 9;\n index++;\n }\n ans.big[index + 1]--;\n }\n }\n }\n\n while(ans.big.size() > 1 && ans.big.back() == 0)\n ans.big.pop_back();\n\n while(a.big.size() > 1 && a.big.back() == 0)\n a.big.pop_back();\n\n return ans;\n }\npublic:\n//\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b / \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b\n big_num()\n {\n big.clear();\n big.push_back(0);\n flag = true;//\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e\n }\n big_num(const LL& at)\n {\n LL a = at;\n if(a < 0)\n flag = false;//\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e\n else\n flag = true;\n\n while(a)\n {\n big.push_back(a%10);\n a /= 10;\n }\n\n if(a == 0)big.push_back(0);\n\n while(big.size() > 1 && big.back() == 0)\n big.pop_back();\n }\n big_num(const big_num &v)\n {\n if(v.flag)\n flag = true;\n else\n flag = false;\n\n big.clear();\n big.insert(big.end(),v.big.begin(),v.big.end());\n\n while(big.size() > 1 && big.back() == 0)\n big.pop_back();\n }\n big_num(const string &a)\n {\n big.clear();\n\n if(a[0] == '-')\n {\n flag = false;\n \n for(int i(a.length()-1);i >= 1;i--)\n {\n big.push_back((int)a[i] - 48);\n }\n }else\n {\n flag = true;\n\n for(int i(a.length()-1);i >= 0;i--)\n {\n big.push_back((int)a[i] - 48);\n }\n }\n\n while(big.size() > 1 && big.back() == 0)\n big.pop_back();\n }\n ~big_num()\n {\n big.clear();\n }\n//cin / cout , = \n friend std::ostream& operator<<(std::ostream& os,const big_num& a)\n {\n if(!a.flag)\n os << \"-\";\n\n for(int i(a.big.size()-1);i >= 0;i--)\n {\n os << a.big[i];\n }\n\n return os;\n }\n friend std::istream& operator>>(std::istream& is,big_num& a)\n {\n string str;\n a.big.clear();\n is >> str;\n\n if(str[0] == '-')\n {\n a.flag = false;\n str.erase(str.begin(),str.begin()+1);\n }else\n a.flag = true;\n\n for(int i(str.length()-1);i >= 0;i--)\n {\n a.big.push_back(str[i]-48);\n }\n\n while(a.big.size() > 1 && a.big.back() == 0)\n a.big.pop_back();\n\n return is;\n }\n const big_num& operator=(const big_num &v)\n {\n if(v.flag)\n flag = true;\n else\n flag = false;\n\n big.clear();\n big.insert(big.end(),v.big.begin(),v.big.end());\n\n return *this;\n }\n const big_num& operator=(const LL& at1)\n {\n big_num ans(at1);\n (*this) = ans;\n return *this;\n }\n const big_num& operator=(const string &a)\n {\n big.clear();\n\n if(a[0] == '-')\n {\n flag = false;\n \n for(int i(a.length()-1);i >= 1;i--)\n {\n big.push_back((int)a[i] - 48);\n }\n }else\n {\n flag = true;\n\n for(int i(a.length()-1);i >= 0;i--)\n {\n big.push_back((int)a[i] - 48);\n }\n }\n\n while(big.size() > 1 && big.back() == 0)\n big.pop_back();\n\n return *this;\n }\n//---------\u041b\u043e\u0433\u0438\u043a\u0430---------------------------\n bool operator> (const big_num& b)//a > b ? \n {\n if(flag && !b.flag)\n return true;\n if(!flag && b.flag)\n return false;\n\n if(flag && b.flag)\n {\n if(big.size() > b.big.size())\n return true;\n if(big.size() < b.big.size())\n return false;\n\n for(int i(b.big.size()-1);i >= 0;i--)\n {\n if(big[i] > b.big[i])\n return true;\n if(big[i] < b.big[i])\n break;\n }\n \n return false;\n\n }else\n {\n if(big.size() > b.big.size())\n return false;\n if(big.size() < b.big.size())\n return true;\n\n for(int i(big.size()-1);i >= 0;i--)\n {\n if(big[i] < b.big[i])\n return true;\n if(big[i] > b.big[i])\n break;\n }\n return false;\n }\n }\n bool operator==(const big_num& b)\n {\n if(big.size() != b.big.size() || flag != b.flag)\n return false;\n \n for(size_t i(0);i < big.size();i++)\n {\n if(big[i] != b.big[i])\n return false;\n }\n return true;\n \n }\n bool operator< (const big_num& b)// a < b?\n {\n if(flag && !b.flag)\n return false;\n if(!flag && b.flag)\n return true;\n\n if(flag && b.flag)\n {\n if(big.size() > b.big.size())\n return false;\n if(big.size() < b.big.size())\n return true;\n\n for(int i(big.size()-1);i >= 0;i--)\n {\n if(big[i] < b.big[i])\n return true;\n if(big[i] > b.big[i])\n break;\n }\n return false;\n }else\n {\n if(big.size() > b.big.size())\n return true;\n if(big.size() < b.big.size())\n return false;\n\n for(int i(b.big.size()-1);i >= 0;i--)\n {\n if(big[i] > b.big[i])\n return true;\n if(big[i] < b.big[i])\n break;\n }\n \n return false;\n }\n }\n bool operator>=(const big_num& b)\n {\n if(!((*this) < b))\n return true;\n else\n return false;\n }\n bool operator<=(const big_num& b)\n {\n if(!((*this) > b))\n return true;\n else\n return false;\n }\n bool operator!=(const big_num& b)\n {\n if((*this) == b)\n return false;\n else\n return true;\n }\n//-------\u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430-------------------------\n big_num operator- (big_num& b)\n {\n big_num ans;\n\n if(flag)\n {\n if(b.flag)\n {\n if((*this) >= b)\n {\n ans = (*this).razofbig(b);\n ans.flag = true;\n }else\n {\n ans = b.razofbig(*this);\n ans.flag = false;\n }\n }else\n {\n ans = b.sumofbig(*this);\n ans.flag = true;\n }\n }else\n {\n if(b.flag)\n {\n ans = b.sumofbig(*this);\n ans.flag = false;\n }else\n {\n if(b <= (*this))\n {\n ans = b.razofbig(*this);\n ans.flag = true; \n }else\n {\n ans = (*this).razofbig(b);\n ans.flag = false;\n }\n }\n }\n\n return ans;\n }\n big_num operator+ (big_num& b)\n {\n big_num ans;\n\n if(flag)\n {\n if(b.flag)\n {\n ans = b.sumofbig(*this);\n ans.flag = true;\n }else\n {\n if((*this) >= -b)\n {\n ans = (*this).razofbig(b);\n ans.flag = true;\n }else\n {\n ans = b.razofbig(*this);\n ans.flag = false;\n }\n }\n }else\n {\n if(b.flag)\n {\n if(-(*this) >= b)\n {\n ans = (*this).razofbig(b);\n ans.flag = false;\n }else\n {\n ans = b.razofbig(*this);\n ans.flag = true;\n }\n }else\n {\n ans = b.sumofbig(*this);\n ans.flag = false;\n }\n }\n \n return ans;\n }\n void operator+=(big_num& b)\n {\n (*this) = (*this) + b;\n }\n void operator-=(big_num& b)\n {\n (*this) = (*this) - b;\n }\n big_num operator- (const LL& b)\n {\n big_num tmp(b);\n big_num ans;\n ans = (*this) - tmp;\n return ans;\n }\n big_num operator+ (const LL& b)\n {\n big_num tmp(b);\n big_num ans = (*this) + tmp;\n return ans;\n }\n void operator+=(const LL& b)\n {\n (*this) = (*this) + b;\n }\n void operator-=(const LL& b)\n {\n (*this) = (*this) - b;\n }\n big_num operator* (const LL& b)\n {\n big_num ans(*this);\n LL carry = 0;\n for (size_t i=0; i 1 && ans.big.back() == 0)\n ans.big.pop_back();\n return ans;\n }\n void operator*=(const LL& b)\n {\n (*this) = (*this) * b;\n }\n big_num operator* (big_num& b)\n {\n vec tmp;\n\n if((*this) >= b)\n {\n for(int i(0);i < b.big.size();i++)\n {\n tmp.push_back( (*this) * (LL)(b.big[i]) );\n }\n }else\n {\n for(int i(0);i < big.size();i++)\n {\n tmp.push_back( b * (LL)big[i] );\n }\n }\n\n int ind = 1;\n\n big_num ans(tmp[0]);\n\n for(int i(1);i < tmp.size();i++)\n {\n for(int j(0);j < ind;j++)\n {\n tmp[i] *= 10;\n }\n ind++;\n\n ans += tmp[i];\n }\n\n return ans;\n }\n void operator*=(big_num& b)\n {\n (*this) = (*this) * b;\n }\n pair division(const LL& bc)\n {\n big_num a(*this);\n a.flag = true;\n LL b = (bc > 0?bc : -bc);\n big_num num,tmp = 0;\n num = 0;\n\n bool tep,flag;\n\n tep = flag = true;\n\n while(a.big.size())\n {\n //cout << tmp << \" -> \";\n \n int qqq = tmp.big.size();\n for(int i(a.big.size()-1);i >= 0 && (LL)tmp < b;i--)\n {\n tmp.big.insert(tmp.big.begin(),a.big[i]); \n a.big.pop_back();\n }\n \n if((LL)tmp < b) break;\n\n if(tep)\n {\n tep = false;\n }else\n {\n for(int i(0);i < (tmp.big.size() - qqq-1);i++)\n num.big.insert(num.big.begin(),0);\n }\n\n if((LL)tmp < b) break;\n\n LL q = (LL)tmp / b;\n LL g = q;\n vint f;\n while(q)\n {\n f.push_back(q%10);\n q /= 10;\n }\n \n\n\n reverse(f.begin(),f.end());\n\n num.big.insert(num.big.begin(),f.begin(),f.end());\n tmp -= (g*b);\n //cout << tmp << '\\n';\n }\n\n return mp(num,tmp);\n }\n big_num operator/ (const LL& b)\n {\n big_num ans;\n ans = (*this).division(b).first;\n\n if((b > 0 && (*this).flag) || (b < 0 && !(*this).flag))\n ans.flag = true;\n else\n ans.flag = false;\n\n return ans;\n }\n big_num operator% (const LL& b)\n {\n big_num ans;\n ans = (*this).division(b).second;\n\n if((b > 0 && (*this).flag) || (b < 0 && !(*this).flag))\n ans.flag = true;\n else\n ans.flag = false;\n\n return ans;\n }\n//------------------------------------------\n//------\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a \u0442\u0438\u043f\u0443 LL -----------\n\n operator LL()\n {\n LL ans = 0;\n big_num b(*this);\n\n while(b.big.size())\n {\n ans = ans*10 + b.big.back();\n b.big.pop_back();\n }\n return ans;\n }\n\n//------------------------------------------ \n//------\u0423\u043d\u0430\u0440\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438--------------------\n //\u0441\u043c\u0435\u043d\u0430 \u0437\u043d\u0430\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0439--------\n big_num operator-()\n {\n big_num q(*this);\n\n if(flag)\n q.flag = false;\n else\n q.flag = true;\n return q;\n }\n //\u043c\u043e\u0434\u0443\u043b\u044c \u0447\u0438\u0441\u043b\u0430--------------------------\n big_num abs()\n {\n big_num ans(*this);\n ans.flag = true;\n\n return ans;\n }\n //\u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0447\u0438\u0441\u043b\u0430-------------------------\n big_num sqr()\n {\n return (*this) * (*this);\n }\n//------------------------------------------\n};\n\nbig_num binpow(int n,int m)\n{\n if(m == 0) return 1;\n\n if(m % 2)\n return binpow(n,m/2)*binpow(n,m/2)*(LL)n;\n else\n return binpow(n,m/2)*binpow(n,m/2);\n}\n\nbool solve()\n{\n /*double t1,t2;\n t1 = clock();*/\n setlocale(LC_ALL,\"Russian\");\n ios_base::sync_with_stdio(0);\n ifstream fin(\"in.txt\");\n ofstream fout(\"out.txt\");\n\n string a;\n vint b;\n\n cin >> a;\n\n for(int i(0);i < a.size();i++)\n {\n switch(a[i])\n {\n case '>' : b.push_back(1),b.push_back(0),b.push_back(0),b.push_back(0);break;\n case '<' : b.push_back(1),b.push_back(0),b.push_back(0),b.push_back(1);break;\n case '+' : b.push_back(1),b.push_back(0),b.push_back(1),b.push_back(0);break;\n case '-' : b.push_back(1),b.push_back(0),b.push_back(1),b.push_back(1);break;\n case '.' : b.push_back(1),b.push_back(1),b.push_back(0),b.push_back(0);break;\n case ',' : b.push_back(1),b.push_back(1),b.push_back(0),b.push_back(1);break;\n case '[' : b.push_back(1),b.push_back(1),b.push_back(1),b.push_back(0);break;\n case ']' : b.push_back(1),b.push_back(1),b.push_back(1),b.push_back(1);break;\n }\n }\n\n big_num ans = 0;\n\n reverse(b.begin(),b.end());\n\n for(int i(b.size()-1);i >= 0;i--)\n {\n ans += b[i] * binpow(2,i) % base;\n }\n\n cout << ans % base;\n\n /*t2 =clock()-t1;\n cout.precision(15);\n cout << \"\\ntime = \" << t2/(CLOCKS_PER_SEC*1000) << \" \u0441\u0435\u043a\u0443\u043d\u0434\\n\";*/\n\n _getch();\n return true;\n}\n\nint main(int argc,char** argv)\n{\n //while(solve());\n solve();\n \n\n\n //_getch();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "27a73d1ceba7c0ec63477ebde45ad282", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "//============================================================================\n// Name : jedi.cpp\n// Author : \n// Version :\n// Copyright : Your copyright notice\n// Description : Hello World in C++, Ansi-style\n//============================================================================\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define LOCAL\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n\ntypedef vector VI;\n\n//copy(istream_iterator(iss), istream_iterator(), back_inserter(ws));\n\ntemplate\nostream& operator<< (ostream& fout, const vector& vec) {\n for (size_t i = 0; i < vec.size(); ++i) {\n fout << vec[i] << ' ';\n }\n return fout;\n}\n\ntemplate \nistream& operator>> (istream& fin, vector& vec) {\n for (size_t i = 0; i < vec.size(); ++i) {\n cin >> vec[i];\n }\n return fin;\n}\n\nint main() {\n#ifdef LOCAL\n freopen(\"input.txt\", \"rt\", stdin);\n// freopen(\"output.txt\", \"wt\", stdout);\n#endif\n\n int X[3] = {0, 0, 0};\n int n, x;\n cin >> n >> x;\n X[x] = 1;\n\n n = n % 7;\n while (n) {\n \tif (n % 2 == 0)\n \t\tswap(X[1], X[2]);\n \telse\n \t\tswap(X[0], X[1]);\n \t--n;\n }\n\n for (int i = 0; i < 3; ++i) {\n \tif (X[i] == 1) {\n \t\tcout << i << \"\\n\";\n \t\tbreak;\n \t}\n }\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "49c5fcfce356ef1f042531e9dac70c9d", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "/*\nAuthor- Aasav Badera\nTime- Fri Sep 4 14:04:20 2020\n*/\n#include \n#include \n#include \nusing namespace std;\nusing namespace __gnu_pbds;\n#ifdef LOCAL \n#include \n#define meminc rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;\n#else\n#define meminc \n#endif\n#ifdef LOCAL\n#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator _it(_ss); err(_it, args); }\n#else\n#define dbg(args...)\n#endif\nstruct custom_hash {\n static uint64_t splitmix64(uint64_t x) {\n // http://xorshift.di.unimi.it/splitmix64.c\n x += 0x9e3779b97f4a7c15;\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\n return x ^ (x >> 31);\n }\n\n size_t operator()(uint64_t x) const {\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n return splitmix64(x + FIXED_RANDOM);\n }\n};\nvoid err(istream_iterator it) {}\ntemplate\nvoid err(istream_iterator it, T a, Args... args) {\n cerr << *it << \" = \" << a << endl;\n err(++it, args...);\n}\n#define ll int\n#define vi vector\n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update>\n// -------------------Standard Traversal Moves---------------------\n// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};\nvi fx = {2, -2, 2, -2, 1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};\n// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};\n// ----------------------------------------------------------------\n\n#define rep(i, a, b) for(int i=a;i -1 and _x < n and _y > -1 and _y < m); \n}\nint32_t main()\n{\n meminc;\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cerr.precision(10);\n cout.precision(25);\n cout << fixed;\n #ifdef LOCAL\n // for getting input from input.txt\n freopen(\"input.txt\", \"r\", stdin);\n // for writing output to output.txt\n freopen(\"output.txt\", \"w\", stdout);\n #endif\n int tests = 1;\n // cin >> tests;\n rep(test, 1, tests+1)\n {\n cin >> n;\n cin >> m;\n int counter = 0;\n \tmemset(vis, 0, sizeof vis);\n \tfor(int i = 0; i < n; i++)\n \t{\n \t\tfor(int j = 0 ; j < m; j++)\n \t\t{\n \t\t\tif((i + j) % 2 == 0)\n \t\t\t{\n \t\t\t\tcounter++;\n \t\t\t\tvis[i][j] = 1;\n \t\t\t\tfor(int l = 0; l < 8; l++)\n \t\t\t\t{\n \t\t\t\t\tint nx = i + fx[l], ny = j + fy[l];\n \t\t\t\t\tif(!check(nx, ny))continue;\n \t\t\t\t\tvis[nx][ny] = 1;\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t}\n \t// cerr << counter << endl;\n \tfor(int i = 0; i < n; i++)\n \t{\n \t\tfor(int j = 0 ; j < m; j++)\n \t\t{\n \t\t\tif(!vis[i][j])\n \t\t\t{\n \t\t\t\tcounter++;\n \t\t\t\tvis[i][j] = 1;\n \t\t\t\tfor(int l = 0; l < 8; l++)\n \t\t\t\t{\n \t\t\t\t\tint nx = i + fx[i], ny = j + fy[i];\n \t\t\t\t\tif(!check(nx, ny))continue;\n \t\t\t\t\tvis[nx][ny] = 1;\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t}\n \tcout << counter;\n }\n #ifdef LOCAL\n // cerr << \"Time elapsed: \" << 1.0 * clock() / CLOCKS_PER_SEC << \" s.\\n\";\n #endif\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "176e658fdafe63c1ebb36aedb591cc41", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define ll long long\nconst int N = 1e5+15;\nconst int mod = 1e9+7;\n\n\nint dp[N],val[N];\nint per[N],perInverse[N];\n\nint add(int x,int y) {\n int ret = (x+y)%mod;\n if(ret<0) {\n ret += mod;\n }\n return ret;\n}\n\nint mul(int x,int y) {\n ll ret = (ll)x*y;\n ret%=mod;\n return ret;\n}\nint combi(int n,int k) {\n assert(n>=k);\n int ret = mul(per[n],perInverse[k]);\n ret = mul(ret, perInverse[n-k]);\n return ret;\n}\n\nvector divisor[N];\n\nbool isCandidate[N];\nint ret[N],len[N];\nint myPow(int x,int cc) {\n int ret = 1;\n while(cc>0) {\n if(cc&1) {\n ret = mul(ret, x);\n }\n cc/=2;\n x = mul(x,x);\n }\n return ret;\n}\n\nint numOfDiv[N];\nbool vis[N];\nint gcd(int a,int b) {\n if(a==0) {\n return b;\n }\n return gcd(b%a,a);\n}\nint find(int n,int cur,int sum,int maxi) {\n if(dp[cur]==maxi) {\n return 1;\n }\n int R = 0;\n for(int i=0;i=1;--i) {\n if(isCandidate[i] || dp[i]==maxi) {\n isCandidate[i] = true;\n }\n if(!isCandidate[i]) {\n for(int j = i+i;j<=n;j+=i) {\n if(isCandidate[j] && dp[j]== dp[i]+1) {\n isCandidate[i] = true;\n divisor[i].push_back(j);\n }\n }\n }\n }\n assert(isCandidate[1]);\n int R = find(n,1,0,maxi);\n printf(\"%d\\n\", R);\n}\n\nint main(){\n //freopen(\"input.txt\",\"r\",stdin);\n solve();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "74d45e2f6de8237bc54fc197d1b336c7", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "MS C++", "source_code": "#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define fin for (i=0; i pi;\ntypedef vector vi;\nconst li p=1000000007;\nconst ld PI=3.14159265358979323846264338327950288419716939937510;\nvoid prepare ()\n{\n#ifdef _DEBUG\n\tfreopen (\"in.txt\", \"r\", stdin);\n#endif\n}\n\n\nint main ()\n{\n\tprepare ();\n\tint n;\n\tcin>>n;\n\tint k=n;\n\tint i;\n\tfor (i=1; i*i<=k; i++)\n\t{\n\t\tif (n%i==0)\n\t\t{\n\t\t\tcout<<(n/i)<<\" \";\n\t\t\tn/=i;\n\t\t}\n\t}\n\tcout<<\"1\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fccf7f78794dbd4284de0efb806dd01f", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define f first\n#define s second\n\n#define ll long long\n#define ld long double\n#define ull unsigned long long\n\n#define pb push_back\n#define ppb pop_back\n#define mp make_pair\n\n#define sz(x) (int) x.size()\n#define all(x) x.begin(), x.end()\n#define bit(x) __builtin_popcountll(x)\n#define sqr(x) ((x) * 1LL * (x))\n\n#define nl '\\n'\n#define ioi exit(0);\n\n#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n\n#define _11day \"IOI2017\"\n\nusing namespace std;\n\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef pair hack;\n\nconst int N = 1e5 + 7, MxN = 1e6 + 7, mod = 1e9 + 7, inf = 1e9 + 7;\nconst long long linf = (ll)1e18 + 7;\nconst long double eps = 1e-15, pi = 3.141592;\nconst int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};\n\n\n\n\n inline ll Pw(ll a, ll b, ll m) {\n ll res = 1;\n a %= m;\n while (b){\n if (b & 1) res = (res * a) % m, b--;\n a = (a * a) % m, b >>= 1;\n }\n return res % m;\n }\n\n inline bool fast(ll d, ll n){\n ll a = 2 + rand() % (n - 4), x = Pw(a, d, n);\n if (x == 1 || x == n - 1) return 1;\n while (d != n - 1){\n x = (x * x) % n, d *= 2;\n if (x == 1) return 0;\n if (x == n - 1) return 1;\n }\n return 0;\n }\n\n inline bool Check(int n, int k = 100){\n if (n <= 1 || n == 4) return 0;\n if (n <= 3) return 1;\n\n ll d = n - 1;\n while (d % 2 == 0) d >>= 1;\n\n for (int i = 1; i <= k; i++)\n if (!fast(d, n)) return 0;\n return 1;\n }\n\n\n inline bool Check2(int x){\n if (x < 2) return 0;\n for (int i = 2; i <= sqrt(x); i++)\n if (x % i == 0) return 0;\n return 1;\n }\n\n\n inline ll Solve(ll n){\n ll res = 0;\n while (n > 0){\n if (n < 4 || Check(n)){\n res++;\n break;\n }\n for (int i = n - 2; i >= 2; i--)\n if (Check(i)) {n -= i, res++; break;}\n }\n return res;\n }\nint main(){\n #ifndef _11day\n freopen (_11day\".in\", \"r\", stdin);\n freopen (_11day\".out\", \"w\", stdout);\n #endif\n\n ll n, res = inf, ans = 0;\n cin >> n;\n if (Check2(n)) cout << 1, ioi\n for (ll i = 1; i <= sqrt(n); i++){\n if (n % i == 0){\n if (i > 1) res = min(res, i);\n if (sqr(i) != n)\n res = min(res, n / i);\n }\n }\n cout << res;\n\n ioi\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "81a631013a4d82d1f5c163eceaf53845", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \ntypedef long long ll;\nusing namespace std;\n\nint main() {\n\tll n;\n\tcin>>n;\n\twhile(n>=0)\n\t{\n\t ll p=n%10;\n\t \n\t if(p==0){cout<<\"O-|-OOOO\"<\n\nusing namespace std;\nint t, n, k, l;\nint d[200];\nint p[210];\nint f[200][200];\nvoid init()\n{\n p[0] = 0;\n for (int i = 1; i <= k; i++)\n p[i] = i;\n for (int i = k + 1; i <= 2 * k; i++)\n p[i] = 2 * k - i;\n}\nint main()\n{\n ios::sync_with_stdio(false);\n cin >> t;\n while (t--)\n {\n\n cin >> n >> k >> l;\n init();\n for (int i = 1; i <= n; i++)\n cin >> d[i];\n memset(f, 0, sizeof(f));\n if (d[1] <= l)\n f[0][1] = 1;\n int flag = 0;\n for (int j = 1; j <= 2 * k * n; j++)\n {\n for (int i = 1; i <= n; i++)\n {\n if (p[j % (2 * k)] + d[i] <= l)\n f[j][i] = max(f[j - 1][i], f[j - 1][i - 1]);\n if (f[j][n])\n {\n flag = 1;\n break;\n }\n }\n }\n if (flag)\n cout << \"Yes\" << endl;\n else\n cout << \"No\" << endl;\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "899f85f34a0c7405cbcd168e808dbbcc", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "/**********************************************************/\n/* */\n/* Vahid Pouryousef */\n/* 9033009 */\n/* Group #2 */\n/* Project 01 */\n/* End :27-6-2012 */\n/* */\n/**********************************************************/\n\n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n char a[101],b[101];\n int t[101];\n unsigned int l,i;\n \n cin.getline(a,101);\n cin.getline(b,101);\n\n if(strlen(b)!=strlen(a)) return 0;\n \n l=strlen(a);\n \n for(i=0;i\n#include \n#include \n#include \n\n\n#define pb push_back\n#define all(a) a.begin(),a.end()\n#define fc for_each\nusing namespace std;\n\n\nstring str, str1;\nint sizee, counter=0, save=2;\n\n\nint main() {\n\tcin >> sizee >> str;\n\tstr1.pb(str[0]);\n\tfor (int k = 1; k < str.size(); k++) {\n\t\tif (str[k] == str[k + 1])\n\t\t{\n\t\t\tcounter++;\n\t\t}\n\t\telse \n\t\t{\n\t\t\tfor (int i = 0; i < (counter > save) ? counter / save: 1; i++) {\n\t\t\t\tstr1.pb(str[k]);\n\t\t\t}\n\t\t\tcounter = 0;\n\t\t\tsave++;\n\t\t}\n\t\t\n\n\t}\n\tcout << str1;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b95199d62d16bd1e1c26ccf5488a9219", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nmain()\n{ int n;\ncin>>n;\nchar str[101];\ncin>>str;\nchar temp;\nint i,j,k;\nfor(i=n;i>=2;i--)\nif(n%i==0)\nfor(j=0,k=i-1;j!=k;j++,k--)\n{ temp=str[k];\nstr[k]=str[j];\nstr[j]=temp;\n}\n\ncout<\n\nusing namespace std;\n\nint main(){\n\t\n\tdouble a, b, c, d;\n\t\n\tcin >> a >> b >> c >> d;\n\n\tdouble n = b - a;\n\tdouble m = b/a;\n\t\n\tif(c - b == n && d- c == n) cout << d + n;\n\telse if (c/b == m && d/c == m) cout << d*m;\n\telse cout << 42;\n\tsystem(\"pause>null\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "efe336e5a56106179b3bc967f924f146", "src_uid": "68a9508d49fec672f9c61766d6051047", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \r\nusing namespace std;\r\nusing ll = long long;\r\nconst ll MN = 725;\r\nconst ll MAX = 1e3 + 5;\r\nint main () {\r\n\tll n, id = 0;\r\n\tvector a;\r\n\t/*\r\n\tfor (int i = 1; i <= 25; i++){\r\n\t\tfor (int j = 1; j <= 25; j++){\r\n\t\t\tif (i > j){\r\n\t\t\t\tll x = i*i - j*j;\r\n\t\t\t\ta.push_back(x);\r\n\t\t\t}\r\n\t\t}\r\n\t} \r\n\tsort (a.begin(), a.end());*/\r\n\ta.push_back(3);\r\n\tfor (int i = 1; i <= 10000; i++){\r\n\t\ta.push_back(4*i);\r\n\t\ta.push_back(4*i+1);\r\n\t\ta.push_back(4*i+3);\r\n\t}\r\n\tcin >> n;\r\n\tcout << a[n];\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "57cc79df5c0ea1fca30ed158f4486b67", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n\tint h1,h2;\n\tint a,b;\n\tscanf(\"%d %d %d %d\",&h1,&h2,&a,&b);\n\tint ans=0;\n\th1+=8*a;\n\tif(h1>=h2)\n\t{\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tif(a\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntypedef long long ll;\ntypedef std::pair pll;\ntypedef std::pair pii;\n\nusing namespace std;\n\nstd::vector<__int64> F;\n\n\nint main()\n{\n#if defined(_DEBUG) || defined(_RELEASE)\n freopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n#else\n //freopen(File\".in\", \"r\", stdin); freopen(File\".out\", \"w\", stdout);\n#endif\n \n \n// return 0;\n //cout << \"SDSD\";\n F.push_back(1);\n F.push_back(1);\n ll c = 1;\n// cout << \"SaaaaaD\";\n while (F[c] < 10000000000000000000)\n {\n F.push_back(F[c - 1] + F[c]);\n c++;\n }\n// cout << \"SDSD\";\n __int64 n;\n cin >> n;\n __int64 k;\n cin >> k;\n ll printed=0;\n\n\n while (printed < n)\n {\n if (n - printed > c)\n {\n cout << 1 + printed << \" \";\n printed++;\n }\n else\n if (k <= F[n-printed - 1])\n {\n cout << 1 + printed << \" \";\n printed++;\n }\n else\n {\n cout << 2 + printed << \" \" << 1 + printed<<\" \";\n k = k - F[n - 1 - printed];\n printed++;\n printed++;\n }\n\n }\n\n\n\n\n return 0;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a6dca29998223c8ab561f7f4933b3fce", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n return !puts(\"INTERCAL\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9148cd772fd3c774724cf84534bb5b72", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include\n#include\n\nusing namespace std;\n\nint main()\n{\n int A[99999999];\n int a, b, m, i = 1;\n cin >> a >> b >> m >> A[0];\n bool Is = true;\n while (Is)\n {\n A[i] = (a * A[i - 1] + b) % m;\n for (int j = 1; j < i; ++j)\n {\n if (A[j] == A[i])\n {\n cout << i - j;\n Is = false;\n }\n }\n ++i;\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "897eaf62a38a644479c6735944ec344e", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\n\nint main(){\n\tint n;\n\tcin >> n;\n\tstring l;\n\tcin >> l;\n\tfor (int i = 0; i < n - 4; i++)\n\t{\n\t\tif (l[i] == '*'){\n\t\t\tfor (int j = i + 1; j < n; j++)\n\t\t\t{\n\t\t\t\tif (l[j] == '*' && i + (j - i) * 3 < n && l[i + (j - i) * 2] == '*' && l[i + (j - i) * 3] == '*'){\n\t\t\t\t\tcout << \"yes\";\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << \"no\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c5b8b1924303dddae3c26ac8f95ca350", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define REP(i,n) for(int i=0;i<(int)n;++i)\n#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)\n#define ALL(c) (c).begin(), (c).end()\nconst int INF = 1<<29;\n\nint solve(int n, int m) {\n if (n>i&1) {\n ba[0][i] = 1;\n if (i) ba[0][i-1] = 1;\n if (i=2) ba[1][i] = 1;\n cnt++;\n }\n }\n for (int i=1; i=n||jj<0||jj>=m) continue;\n ba[ii][jj] = 1;\n }\n cnt++;\n }\n }\n }\n REP(j, m-1) {\n if (!ba[n-1][j]) {\n ba[n-1][j] = 1;\n ba[n-1][j+1] = 1;\n if (j+2> n>>m;\n cout << solve(n,m) << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cf02527a4eb12622d26e66d174327d6c", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define rep(i,a,b) for (int i = a; i <= b; ++i)\n#define dep(i,a,b) for (int i = a; i >= b; --i)\n\nconst int mod = 1000000007;\nint n,a,b,k;\nlong long f[5010][5010],c[5010];\nint main() {\n\tscanf(\"%d%d%d%d\",&n,&a,&b,&k);\n\tf[0][a]=1;\n\trep(i,0,k-1) {\n\t\trep(j,0,n+1) c[j]=0;\n\t\trep(j,1,n) {\n\t\t\tint s,t;\n\t\t\tint len=abs(b-j)-1;\n\t\t\tif (len<0) continue;\n\t\t\ts=max(1,j-len),t=min(n,j+len);\n\t\t\tif (j==s) s++;\n\t\t\telse if (j==t) t--;\n\t\t\tif (s>t) continue;\n\t\t\tc[s]+=f[i][j]; c[s]%=mod;\n\t\t\tc[t+1]-=f[i][j]; c[t+1]%=mod;\n\t\t\tif (s\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define Endl endl;\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\nll n,m;\nvectorg;\nvectorh;\nll ans;\nmapt;\nint main(){\n ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);\n // ifstream fin(\"sight.in\");\n // ofstream fout(\"sight.out\");\n cin>>n>>m;\n g.push_back(0);\n h.push_back(0);\n int r,t;\n for(int i=3; i; i+=6){\n g.push_back(i);\n r++;\n if(r==m){\n break;\n }\n }\n for(int i=2; i; i+=2){\n if(i%3==0){\n continue;\n }\n h.push_back(i);\n t++;\n if(t==n){\n break;\n }\n }\n \n \n for(int i=6; ih[h.size()-1]){\n g.pop_back();\n }\n else{\n h.pop_back();\n }\n }\n \n \n cout<\nusing namespace std;\ntypedef long long int ll;\ntypedef vector vi;\ntypedef pair pii;\nconst int N = 1000100;\nint a[N];\nll mp = 1000000007;\nll exp(ll x, ll n,ll p)\n{\n\tif(n==0)\n\t\treturn 1;\n\tll w = exp(x,n/2,p);\n\tw=w*w%p;\n\tif(n%2==0)\n\t\treturn w;\n\treturn w*x%p;\n}\nbool df[N]={0};\nll val[N];\nint main()\n{\n\tint p,k;\n\tcin>>p>>k;\n\tif(k==0)\n\t{\n\t\tcout<\n\n#define ff first\n#define ss second\n#define mp make_pair\n#define pb push_back\n#define ll long long\n#define sqr(a) ((a)*(a))\n#define bs ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n#define int ll\n\nusing namespace std;\n\nconst int N=200003;\nconst int M=32;\nconst int inf=2e9;\nconst int md=1e9+7;\n\nint n,sm,ans;\nint a[7010][7010];\n\nvoid dfs(int a1,int a2)\n{\n if(a1>=n||a2>=n)\n {\n if(a1==n||a2==n)\n ans=min(ans,a[a1][a2]);\n return ;\n }\n if(a1+a2<=n)\n if(a[a1+a2][a2]>a[a1][a2]+1)\n {\n a[a1+a2][a2]=a[a1][a2]+1;\n dfs(a1+a2,a2);\n }\n if(a1+a2<=n)\n if(a[a1][a1+a2]>a[a1][a2]+1)\n {\n a[a1][a1+a2]=a[a1][a2]+1;\n dfs(a1,a1+a2);\n }\n\n}\n\nmain()\n{\n bs;\n cin>>n;\n for(int i=0;i<=n;++i)\n {\n for(int j=0;j<=n;++j)\n {\n a[i][j]=inf;\n }\n }\n ans=inf;\n a[1][1]=0;\n dfs(1,1);\n cout<\n#include \n#include \n#include \n#include \nusing namespace std;\nlong long a,b,n ,x;\nlong long ans;\nlong long M = 1e9+7;\nlong long calc( int n){\n\tif(n == 0) return x;\t\n\t\n\treturn (a*calc(n-1) +b)%M ;\n}\n\n\nint main() {\n\tcin>>a>>b>>n>>x;\n\t\n\tint i=0;\n\tlong long ans =0 ;\n\t\n\tcout<\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\nconst int MAXN = 100* 1000;\nlong long primes[MAXN];\n\nvoid compP(){\n int i = 0;\n primes[i++] = 2;\n for (long long j = 3; i < MAXN; j+=2){\n for (int k = 0; primes[k]*primes[k] <= j; k++){\n if (j % primes[k] == 0)\n goto notPrime;\n }\n primes[i++] = j;\n notPrime:;\n }\n}\n\n\nint main(int argc, const char * argv[]) {\n// int n, m, k, l;\n// cin >> n >> m >> k >> l;\n//\n// for (int c = (l+k)/m; c <= (n/m); c++){\n// if (m*c >= (l+k) && m*c <= n) {\n// cout << c << endl;\n// return 0;\n// }\n// }\n// cout << -1 << endl;\n \n compP();\n long long b;\n cin >> b;\n vector multiples;\n for (int i = 0; primes[i] <= b; i++) {\n long long tmp = 0;\n while ( i < MAXN && b%primes[i] == 0) {\n tmp++;\n b/= primes[i];\n }\n multiples.push_back(tmp);\n }\n \n long long ans = 1;\n for (long long i = 0; i < multiples.size(); i++)\n ans *= (multiples[i]+1);\n \n cout << ans << endl;\n \n return 0;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "df7def58157e3118d1dd72c942029e46", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\nconst int SIZE = 1005;\n\nint dp[SIZE][SIZE];\n\nvoid change(int S, int n) {\n\n for(int i = 0; i <= min(SIZE - 1, S); i++) {\n dp[i][1] = i;\n\n for(int j = min(SIZE - 1, n); j >= 0;j--) {\n if(i <= j) {\n dp[i][j] = 1;\n }\n }\n }\n\n for(int i = 0; i <= min(SIZE, S); i++) {\n for(int j = 0; j <= min(SIZE, n); j++) {\n dp[i][j] = min(dp[i][j - 1], dp[i - j][j]);\n }\n }\n}\n\nint minChange(int S, int n) {\n\n if((S <= SIZE && n <= SIZE) && dp[S][n] > 0)\n return dp[S][n];\n\n if(n == 1)\n return S;\n if(S <= n) {\n return 1;\n }\n\n return min(minChange(S, n - 1), minChange(S - n, n) + 1);\n}\n\n\n\n\nint main() {\n int n, S;\n cin >> n >> S;\n\n if(S <= n) {\n cout << 1 << endl;\n return 0;\n }\n\n change(S, n);\n cout << minChange(S, n) << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0766383f2f047c0093742b8384da15d8", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main()\n{\n int k,a,b;\n cin >> k >> a >> b;\n int cnt = 0;\n while(1)\n {\n if(max(a,b) < k) break;\n if(a > b) a -= k;\n else b -= k;\n cnt++;\n }\n if((a+b)%k == 0) a = 0,b = 0, cnt += (a+b)/k;\n if(a && b) printf(\"-1\");\n else printf(\"%d\",cnt?cnt:-1);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3e882764bf6a78dd5b2e70348d037004", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define INF 2000000000\n#define y1 dfhjghakgh\n\nusing namespace std;\n\nconst int base = (int)1e9+7;\n\nlong long f[10001];\nint n, m;\n\n\n//(n-m)^(n-m)*f[m]\n\nlong long binpow (long long a, int n) {\n\tif (n == 1)\n\t\treturn (a % base);\n\tif (n % 2 == 1)\n\t\treturn (binpow (a, n-1) * a) % base;\n\telse {\n\t\tint b = (binpow (a, n/2)) % base;\n\t\treturn (b * b) % base;\n\t}\n}\nint main(){\n // freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n ios_base::sync_with_stdio(0);\n cin >> n >> m;\n long long ans = (binpow(n-m,n-m) * binpow(m,m-1)) % base;\n cout << ans;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "519c311e62b4821628e95c011265f1e4", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "/*\n\nSviatoslav Bidzilia 2019\nCF: anakib1\n\n*/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define ll long long\n#define ull unisgned long long\n#define ld long double\n#define all(a) a.begin(), a.end()\n#define SORT(a) sort(all(a))\n#define pii pair\n#define tii triple\n#define e 1e-7\n#define PI acos(-1)\n#define inf 1e17\n#define vi vector\n#define F first\n#define S second\n#define rng(x) for(int _ = 0; _ < (x); _++)\n#define rngi(i, x) for(int i = 0; i < (x); i++)\n#define rngsi(s, i, x) for(int i = (s); i <(x); i++)\n\ntemplate\nstruct triple\n{\n\tA X;\n\tB Y;\n\tC Z;\n\ttriple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}\n};\ntemplate\ntriple make_triple(A a = 0, B b = 0, C c = 0)\n{\n\treturn triple(a, b, c);\n}\ntemplate\nbool operator<(const triple& a, const triple& b)\n{\n\tif (a.X != b.X)\n\t\treturn a.X < b.X;\n\tif (a.Y != b.Y)\n\t\treturn a.Y < b.Y;\n\treturn a.Z < b.Z;\n}\ntemplate\nostream& operator<<(ostream& ofs, const pair& p)\n{\n\tofs << \"( \" << p.F << \" , \" << p.S << \" )\";\n\treturn ofs;\n}\ntemplate\nvoid print(T a)\n{\n\tfor (auto i : a)\n\t\tcout << i << ' ';\n\tcout << '\\n';\n}\ntemplate\nT max(T a, T b, T c)\n{\n\treturn max(a, max(b, c));\n}\ntemplate\nT min(T a, T b, T c)\n{\n\treturn min(a, min(b, c));\n}\nstruct custom_hash\n{\n\tstatic uint64_t splitmix64(uint64_t x)\n\t{\n\t\tx += 0x9e3779b97f4a7c15;\n\t\tx = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\n\t\tx = (x ^ (x >> 27)) * 0x94d049bb133111eb;\n\t\treturn x ^ (x >> 31);\n\t}\n\n\tsize_t operator()(uint64_t x) const\n\t{\n\t\tstatic const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n\t\treturn splitmix64(x + FIXED_RANDOM);\n\t}\n};\nint dp[101][101][10001];\nsigned main()\n{\n\t//freopen(\".in\", \"r\", stdin);\n\t//freopen(\".out\", \"w\", stdout);\n\tsrand(time(NULL));\n\tcin.tie(0);\n\tcout.tie(0);\n\tios_base::sync_with_stdio(false);\n\tint n;\n\tcin >> n;\n\tvi a(n);\n\tfor (auto& i : a)\n\t\tcin >> i;\n\tint sum = accumulate(all(a), 0LL);\n\tSORT(a);\n\tint mxn = 100 * 100 + 10;\n\tdp[0][0][0] = 1;\n\tfor (int i = 0; i < n;)\n\t{\n\t\tint k = 1;\n\t\twhile (i + k < n && a[i + k] == a[i])k++;\n\t\tfor (int b = 0; b <= i + k; b++)\n\t\t\tfor (int j = 0; j <= a[i] * b; j++)\n\t\t\t\tfor (int l = 0; l <= min(k, b); l++)\n\t\t\t\t\tif (j - l * a[i] >= 0)\n\t\t\t\t\t\tdp[i + k][b][j] = min(dp[i + k][b][j] + dp[i][b - l][j - l * a[i]], 2);\n\t\ti += k;\n\t}\n\tmap cnt;\n\tfor (auto i : a)\n\t\tcnt[i]++;\n\tint ans = 0;\n\tif (cnt.size() == 2)\n\t\tans = n;\n\tfor (pii x : cnt)\n\t\tfor (int take = 1; take <= x.second; take++)\n\t\t\tif (dp[n][take][take * x.first] == 1)\n\t\t\t\tans = max(ans, take);\n\t\t\n\tcout << ans << '\\n';\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5f45ecf97fe313d845b4e11a44058f7e", "src_uid": "ccc4b27889598266e8efe73b8aa3666c", "difficulty": 2100.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef vector VI;\ntypedef vector< VI > VVI;\ntypedef pair PII;\ntypedef vector VPII;\n\n#define REP(i, n) for(int i = 0; i < n; ++i)\n#define RREP(i, n) for(int i = n - 1; i >= 0; --i)\n#define FOR(i, x, y) for(int i = x; i <= y; ++i)\n#define RFOR(i, x, y) for(int i = x; i >= y; --i)\n#define SZ(a) (int)(a).size()\n#define ALL(a) (a).begin(),(a).end()\n#define SORT(a) sort(ALL(a)) \n#define CLEAR(x) memset(x, 0, sizeof x);\n#define COPY(FROM, TO) memcpy(TO, FROM, sizeof TO);\n#define UNIQUE(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin())\n#define pb push_back\n#define sqr(x) (x)*(x)\n#define X first\n#define Y second\nconst long double pi=acos(-1.0);\nconst long double eps = 1e-9;\nstring s;\nint n;\nint main () {\n cin >> s;\n n = s.length();\n if (s == \"44\") {\n cout << \"NO\";\n return 0;\n }\n int f = 0;\n int pos = -1;\n REP (i, n) {\n if (s[i] == '4')\n pos = i;\n if (s[i] != '4' && s[i] != '1') {\n f = 1;\n }\n }\n if (f) {\n cout << \"NO\";\n return 0;\n }\n if (s[0] == '4' && s[1] == '1') {\n cout << \"NO\";\n return 0;\n }\n FOR (i, 2, n - 1) {\n if (s[i] == '4' && s[i - 1] == '4' && s[i - 2] == '4') {\n f = 1;\n }\n }\n if (f) {\n cout << \"NO\";\n return 0;\n }\n cout << \"YES\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eb21225e4a07062078360a2962027445", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\n#include\nusing namespace std ;\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vl;\ntypedef complex point;\n#define PB push_back\n#define sc scanf\n#define pf printf\n#define X real()\n#define Y imag()\n#define pi 3.14159265359\n//TAGTAGA\n#define gym 2\n#define fre 0\n#define contest 1\n\nint a[1001];\n\nint main()\n{\n // freopen (\"myfile.txt\",\"w+\",stdout);\n\n ll n,k;\n cin>>n>>k;\n\n for(int i=log2(k)-1;; i++)\n {\n long long idx=pow(2,i-1);\n long long inc=idx*2;\n if(idx==k||(k-idx)%inc==0)\n {\n cout<\n#include \n#include \n#define MAXN 1000050\n#define MAXK 50\n#define INF 100000000\n#define MOD 1000000007\n#define REV ((MOD+1)/2)\n#define mul(q,w) (((q)*1ll*(w))%MOD)\n#define add(q,w) (((q)*1ll+(w))%MOD)\nusing namespace std;\nint k,comb[MAXK][MAXK],pt[MAXK];\nlong long n;\ntypedef vector vint;\ntypedef vector matrix;\nmatrix operator*(matrix &a,matrix &b)\n{\n\tmatrix c(a.size(),vint(b[0].size(),0));\n\tfor(int k=0;k=k+1 || j>=k+1)\n\t\t\t\tmat[i][j]=com(j % (k+1),( j % (k+1) ) - ( i%(k+1) ));\n\tmat[2*k+2][2*k+2]=mat[2*k+1][2*k+2]=1;\n\tfor(int i=0;i<64;i++,mat=mat*mat)\n\t\tif((1ll << i) & n)\n\t\t\tcur=cur*mat;\n\tbgn=bgn*cur;\n\tprintf(\"%d\\n\",bgn[0][2*k+2]);\n\tscanf(\" \");\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "911e65af7f2c036aa420e542c94be571", "src_uid": "14f50a111db268182e5927839a993118", "difficulty": null} {"lang": "GNU C++11", "source_code": "//\n// main.cpp\n// vk_cup\n//\n// Created by Simp on 17.02.16.\n// Copyright \u00a9 2016 Simp. All rights reserved.\n//\n\n#include \nusing namespace std;\nlong long int a,b,c,e=2520,cnt,d[1000009];\n\n// 7 8\n// 77 78 87 88\n// 777 778 787 877 887 878 788 888\n\n//\n//\nint main(){\n \n \n cin>>a;\n d[0]=1;\n \n for (long long i=1; i<=a*2; i++) {\n \n d[i]+=d[i-1]+6*i;\n \n }\n \n cout<\nusing namespace std;\n\ntypedef long long LL;\ntypedef long double LD;\ntypedef pair pii;\ntypedef pair pLL;\ntypedef pair pDD;\n\n#define INF 1000000007\n\n#define fi first\n#define se second\n#define MP make_pair\n#define MT make_tuple\n#define PB push_back\n#define PF push_front\n\nLL n;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin>>n;\n LL ans=0;\n while(n>0){\n ans+=9;\n ans+=n%10;\n n/=10;\n }\n cout<\nusing namespace std;\nint main()\n{\n\tint x1,x2,x3;\n\tcin>>x1>>x2>>x3;\n\tint d1,d2,d3;\n\td1=abs(x2-x1)+abs(x3-x1);\n\td2=abs(x1-x2)+abs(x3-x2);\n\td3=abs(x2-x3)+abs(x1-x3);\n\tif(d1\n#include \n\nusing namespace std;\n\nint main()\n{\n int x;\n cin>>x;\n if((x%4)==1){//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\n cout<<\"0 A\";\n }\n else if((x%4)==0){//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd D\n cout<<\"1 A\";\n }\n else if((x%4)==3){//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd B\n cout<<\"0 B\";\n }\n else if((x%4)==2){//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\n cout<<\"1 B\";\n }\n system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b0c0354b74e3bce0cfcd3e3b8fcfebf7", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int r, g, b;\n cin >> r >> g >> b;\n int min = r;\n if(g < r) min = g;\n if(b < g) min = b;\n vector possibilities;\n for(int i = 0; i <= min; i++) possibilities.push_back(i + (r - i) / 3 + (g - i) / 3 + (b - i) / 3);\n sort(possibilities.begin(), possibilities.end(), greater());\n cout << possibilities.at(0) << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1c9c7da0b0152d43604ccc87bf4b6d7c", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \n#include\n#include\n#include\n#include \n#include\n#include \n \n#define tii tuple\n#define vi vector\n#define vii vector\n#define ll long long int\n#define vl vector\n#define vll vector\n \n#define mymod 1000000007\n \nusing namespace std;\n \nll solve(vl v) {\n sort(v.begin(), v.end());\n ll a = v[0];\n ll b = v[1];\n ll c = v[2];\n if(a == 0) {\n return min(b,(c+b)/3);\n }\n if(c-a<=1){\n return (a+b+c)/3;\n }\n if(a+b<=c){\n return 1 + solve({a,b-1,c-2});\n }\n return 1 + solve({a-1,b-1,c-1});\n}\n \nint main() {\n clock_t tstart = clock();\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n // Start\n \n ll a,b,c;\n cin>>a>>b>>c;\n cout<\nusing namespace std;\ntypedef long long ll;\nconst int maxn = 1e5 + 5;\nint tot, root;\nmap mp;\nstruct node\n{\n int l, r, cov, val;\n ll lsum, sum;\n} tree[maxn*100];\nvoid pushdown(int rt,int l,int r)\n{\n if(!tree[rt].cov) return ;\n int mid = (l+r)>>1;\n if(!tree[rt].l) tree[rt].l = ++tot;\n if(!tree[rt].r) tree[rt].r = ++tot;\n int ls = tree[rt].l, rs = tree[rt].r;\n tree[ls].cov = 1;\n tree[ls].val = tree[rt].val;\n tree[ls].sum = (ll)(mid-l+1)*tree[rt].val;\n tree[ls].lsum = tree[rt].val < 0 ? tree[ls].sum : 0;\n tree[rs].cov = 1;\n tree[rs].val = tree[rt].val;\n tree[rs].sum = (ll)(r-mid)*tree[rt].val;\n tree[rs].lsum = tree[rt].val < 0 ? tree[rs].sum : 0;\n tree[rt].cov = tree[rt].val = 0;\n}\nvoid update(int &rt,int L,int R,int l,int r,int x)\n{\n if(!rt) rt = ++tot;\n if(l >= L && r <= R){\n tree[rt].cov = 1; tree[rt].val = x;\n tree[rt].sum = (ll)(r-l+1)*x;\n tree[rt].lsum = x < 0 ? tree[rt].sum : 0;\n return ;\n }\n pushdown(rt,l,r);\n int mid = (l+r)>>1;\n if(mid >= L) update(tree[rt].l,L,R,l,mid,x);\n if(mid < R) update(tree[rt].r,L,R,mid+1,r,x);\n tree[rt].sum = tree[tree[rt].l].sum+tree[tree[rt].r].sum;\n tree[rt].lsum = min(tree[tree[rt].l].lsum,tree[tree[rt].l].sum+tree[tree[rt].r].lsum);\n}\npair query(int &rt,int L,int R,int l,int r,ll x)\n{\n if(!rt) return make_pair(0,0);\n if(l == L && r == R){\n if(x+tree[rt].lsum > 0) return make_pair(-1,tree[rt].sum);\n if(l == r || tree[rt].cov) return make_pair(L-x*1.0/(tree[rt].sum/(r-l+1)),tree[rt].sum);\n }\n pushdown(rt,l,r);\n int mid = (l+r)>>1;\n if(mid >= R) return query(tree[rt].l,L,R,l,mid,x);\n else if(mid < L) return query(tree[rt].r,L,R,mid+1,r,x);\n else{\n pair tmp1 = query(tree[rt].l,L,mid,l,mid,x);\n if(tmp1.first > 0) return tmp1;\n else{\n pair tmp2 = query(tree[rt].r,mid+1,R,mid+1,r,x+tmp1.second);\n return make_pair(tmp2.first,tmp1.second+tmp2.second);\n }\n }\n}\nint main()\n{\n int n, op, x, y, z;\n scanf(\"%d\",&n);\n int L = 1, R = 1e9;\n mp[L-1] = mp[R+1] = 0;\n while(n--){\n scanf(\"%d%d\",&op,&x);\n if(op == 1){\n scanf(\"%d\",&y);\n mp[x] = y;\n auto it = mp.find(x); it++;\n update(root,x,(*it).first-1,L,R,y);\n }\n else if(op == 2){\n auto it = mp.find(x), pre = it, nxt = it;\n --pre; ++nxt;\n update(root,x,(*nxt).first-1,L,R,(*pre).second);\n mp.erase(it);\n }\n else{\n scanf(\"%d%d\",&y,&z);\n if(z == 0){ printf(\"%d\\n\",x); continue; }\n auto it = mp.lower_bound(x);\n if((*it).first >= y){ printf(\"-1\\n\"); continue; }\n pair ans = query(root,(*it).first,y-1,L,R,z);\n //cout<<\"*\"<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define inf 0x3f3f3f3f\n#define INF 2e18\n#define PI acos(-1.0)\n#define pb push_back\n#define mk make_pair\n#define ff first\n#define ss second\n#define all(a) a.begin(),a.end()\n#define rall(a) a.rbegin(),a.rend()\n#define SQR(a) ((a)*(a))\n#define Unique(a) sort(all(a)),a.erase(unique(all(a)),a.end()\n#define MEM(a, b) memset(a, (b), sizeof(a))\n#define CLR(a) memset(a, 0, sizeof(a))\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n#define MIN3(a,b,c) MIN(a,MIN(b,c))\n#define MAX3(a,b,c) MAX(a,MAX(b,c))\n#define MIN4(a,b,c,d) MIN(MIN(a,b),MIN(c,d))\n#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d))\n#define MAX5(a,b,c,d,e) MAX(MAX3(a,b,c),MAX(d,e))\n#define MIN5(a,b,c,d,e) MIN(MIN(a,b,c),MIN(d,e))\n#define Iterator(a) __typeof__(a.begin())\n#define rIterator(a) __typeof__(a.rbegin())\n#define FOR(a,it) for(Iterator(a) it = a.begin();it != a.end(); it++)\n#define rFOR(a,it) for(rIterator(a) it = a.rbegin();it != a.rend(); it++)\n#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)\n#define For(I,A,B) for(int I = (A); I < (B); ++I)\n#define rFor(I,A,B) for(int I = (A); I >= (B); --I)\nconst int MOD = 1e9 + 7;\nconst int MAXN = 1e5 + 5;\n#define sci(a) scanf(\"%d\",&a)\n#define scc(a) scanf(\"%c\",&a)\n#define sci2(a,b) sci(a) , sci(b)\n#define sci3(a,b,c) sci(a), sci(b), sci(c)\n#define sci4(a,b,c,d) sci(a), sci(b), sci(c), sci(d)\n#define scl(a) scanf(\"%lld\", &a)\n#define scl2(a,b) scl(a) , scl(b)\n#define scl3(a,b,c) scl(a), scl(b), scl(c)\n#define scl4(a,b,c,d) scl(a), scl(b), scl(c), scl(d)\n#define ABS(x) ((x)<0?-(x):(x))\n#define SORT(v) sort(v.begin(),v.end())\n#define SIZE(v) (int) v.size()\n#define REV(v) reverse(v.begin(),v.end())\n#define pf printf\n#define pfi(a) pf(\"%d\", a);\n#define pfl(a) pf(\"%lld\", a);\n#define sf(str) getline(cin,str)\n#define sff(str) scanf(\"%[\\n]s\", str)\n\n//typedef int LL;\ntypedef long long int LL;\n//typedef __int64 LL;\n\ntypedef pair PII;\ntypedef pair PLL;\ntypedef pair PDD;\ntypedef vector VI;\ntypedef vector VP;\ntypedef vector VD;\ntypedef vector VL;\n\n//#define DEBUG\nbool prime[1000000003];\n\nvoid Sieve(long long n)\n{\n long long i, j;\n prime[0] = prime[1] = 1;\n\n for(i = 4 ; i < n ; i += 2)\n {\n prime[i] = 1;\n }\n\n for(i = 3 ; i <= n ; i += 2)\n {\n for(j = i+i ; j <= n && prime[i] == 0 ; j += i)\n {\n prime[j] = 1;\n }\n }\n}\n\nint main(){\n#ifdef DEBUG\n\tfreopen(\"G:\\\\input.txt\",\"r\",stdin);\n\t//\tfreopen(\"G:\\\\out.txt\", \"w\", stdout);\n\tdouble start_time = clock();\n#endif\n Sieve(1000000001);\n LL n;\n scl(n);\n int i = 2;\n LL cnt, ans = 0;\n while(n != 0){\n if(n%i == 0){\n cnt = (n/i);\n n -= (cnt*i);\n ans += cnt;\n }\n while(1){\n i++;\n if(prime[i] == 0) break;\n }\n }\n pfl(cnt);\n#ifdef DEBUG\n\tdouble end_time = clock();\n\tfprintf(stderr, \"\\n\\nTime = %.10lf seconds\\n\", (((end_time - start_time)) / CLOCKS_PER_SEC));\n#endif\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c0464775130ca6b9efa0817cd42e6d2d", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\n\nvoid flipvert(vector& str){\n\tint n = str.size();\n\tfor(int i=0; i& str){\n\tint n = str.size();\n\tfor(int i=0; i& str){\n\tint n = str.size();\n\tvector tmp = str;\n\tfor(int i=0; i=0; j--){\n\t\t\ttmp[i][n-1-j] = str[j][i];\n\t\t}\n\t}\n\tstr = tmp;\n}\n\nbool check(vector& str1, vector& str2){\n\tint n = str1.size();\n\tfor(int i=0; i>n;\n\tvector str1(n), str2(n);\n\tfor(int i=0; i>str1[i];\n\t}\n\tfor(int i=0; i>str2[i];\n\t}\n\tif(check(str1, str2)){\n\t\tcout<<\"Yes\\n\";\n\t\treturn 0;\n\t}\n\tvector track = {0, 1, 2, 3 ,4 ,5 ,6,7 ,8};\n\tvector tmp = str1;\n\tfor(int i=0; i<9; i++){\n\t\tif(track[i]>=0 && track[i]<=2){\n\t\t\trot(tmp);\n\t\t}else if(track[i]<=5){\n\t\t\tflipvert(tmp);\n\t\t}else{\n\t\t\tfliph(tmp);\n\t\t}\n\t\tif(check(tmp, str2)){\n\t\t\tcout<<\"Yes\\n\";\n\t\treturn 0;\n\t\t}\n\t}\n\twhile(next_permutation(track.begin(), track.end())){\n\t\tfor(int i=0; i<9; i++){\n\t\tif(track[i]>=0 && track[i]<=2){\n\t\t\trot(tmp);\n\t\t}else if(track[i]<=5){\n\t\t\tflipvert(tmp);\n\t\t}else{\n\t\t\tfliph(tmp);\n\t\t}\n\t\tif(check(tmp, str2)){\n\t\t\tcout<<\"Yes\\n\";\n\t\treturn 0;\n\t\t}\n\t}\n\t}\n\tcout<<\"No\\n\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c051616694f2ff609a11f8c5163b89a4", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define ll long long\nconst int M=1e9+7;\nconst int maxn=10010;\nint ans;\nll n,m;\nll a[maxn][maxn];\nll aa[maxn],f[maxn];\n/*\nvoid dfs(int x,int y)\n{\n if(x>n||y>m)\n {\n\n for(int i=1;i<=n-2;i++)\n {\n for(int j=1;j<=m;j++)\n {\n if((a[i][j]==a[i+1][j])&&(a[i+1][j]==a[i+2][j]))\n return;\n }\n }\n for(int j=1;j<=m-2;j++)\n {\n for(int i=1;i<=n;i++)\n {\n if((a[i][j]==a[i][j+1])&&(a[i][j+1]==a[i][j+2]))\n return;\n }\n }\n for(int i=1;i<=n;i++)\n {\n for(int j=1;j<=m;j++)\n {\n if((a[i][j]==a[i+1][j])&&(a[i][j]==a[i][j+1]))\n return;\n if((a[i][j]==a[i+1][j])&&(a[i][j]==a[i][j-1]))\n return;\n if((a[i][j]==a[i-1][j])&&(a[i][j]==a[i][j+1]))\n return;\n if((a[i][j]==a[i-1][j])&&(a[i][j]==a[i][j-1]))\n return;\n }\n }\n ans++;\n return;\n }\n for(int i=0;i<2;i++)\n {\n a[x][y]=i;\n if(x\n#include \n#include \n#define MAXN 2*1000+10\nusing namespace std;\n\nstruct node\n{\n\tint x,y,step;\n};\n\nint dx[]={1,-1,1,-1,1,-1,0,0},dy[]={-1,1,1,-1,0,0,-1,1};\nint mark[MAXN][MAXN],ans,sx,sy,ex,ey;\n\nint bfs(int x,int y)\n{\n\tqueue que;\n\tnode nn,ne;\n\tnn.x=x,nn.y=y,nn.step=0;\n\tque.push(nn);\n\twhile(!que.empty()){\n\t\tnn=que.front();que.pop();\n\t\tif(nn.x==ex&&nn.y==ey)return nn.step;\n\t\tfor(int k=0;k<8;k++){\n\t\t\tne.x=nn.x+dx[k],ne.y=nn.y+dy[k];\n\t\t\tif(mark[ne.x][ne.y]==0){\n\t\t\t\tne.step=nn.step+1;\n\t\t\t\tque.push(ne);\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n\nint main()\n{\n\tcin>>sx>>sy>>ex>>ey;\n\tmemset(mark,0,sizeof(mark));\n\tint ans=bfs(sx,sy);\n\tcout<\n\nusing namespace std;\n\ntypedef long double ld;\ntypedef long long ll;\ntypedef pair pi;\ntypedef pair pl;\ntypedef pair pd;\n\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vpi;\n\ntemplate using min_heap = priority_queue, greater>;\n\n#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(20)\n#define watch(x) cout << (#x) << \" is \" << (x) << endl\n#define long ll\n#define finish(x) return cout << (x) << '\\n', 0\n#define F0R(i, a) for(int (i)=0;(i)<(a);++(i))\n#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))\n#define F0Rd(i, a) for(int (i)=a;(i)>=0;--(i))\n#define FORd(i, a, b) for(int (i)=a;(i)>=(b);--(i))\n#define all(x) (x).begin(), (x).end()\n#define sz(x) ((int)(x).size())\n\n#define mp make_pair\n#define pb push_back\n#define pf push_front\n#define f first\n#define s second\n#define lb lower_bound\n#define ub upper_bound\n\nconst int MOD = 1000000007;\nconst int INF = 1061109567;\nconst int MAXN = 105;\n\nint dp[4][MAXN]; // dp(msk, i) = current mask at column i\n\nint max(int a, int b, int c) {\n return max(a, max(b, c));\n}\nint main() {\n FAST_IO;\n string str[2]; cin >> str[0] >> str[1];\n int extra = 0;\n\n F0R(i, 2) {\n if(str[0].size() < 3)\n break;\n F0R(j, str[0].size()-2) {\n string s1 = str[0].substr(j, 3);\n string s2 = str[1].substr(j, 3);\n if(s1 == s2 && s1 == \"000\") {\n extra += 2;\n str[0].erase(j, 3);\n str[1].erase(j, 3);\n j=-1;\n }\n }\n }\n int n = str[0].size();\n bool empty[2][n];\n F0R(i, 2)\n F0R(j, n)\n empty[i][j] = str[i][j] == '0';\n int msk = 0;\n int prev = 0;\n\n if(!empty[0][0]) prev |= 1;\n if(!empty[0][1]) prev |= 2;\n FOR(i, 1, n) {\n if(!empty[0][i]) msk |= 1;\n if(!empty[1][i]) msk |= 2;\n F0R(j, 4)\n dp[msk][i] = max(dp[msk][i], dp[j][i-1]);\n if(empty[0][i] && empty[0][i-1] && empty[1][i-1])\n dp[msk|1][i] = max(dp[msk|1][i], dp[prev][i-1]+1);\n if(empty[0][i] && empty[1][i] && empty[0][i-1])\n dp[msk|3][i] = max(dp[msk|3][i], dp[prev][i-1]+1);\n if(empty[0][i-1] && empty[1][i] && empty[1][i-1])\n dp[msk|2][i] = max(dp[msk|2][i], dp[prev][i-1]+1);\n if(empty[0][i] && empty[1][i] && empty[1][i-1])\n dp[msk|3][i] = max(dp[msk|3][i], dp[prev][i-1]+1);\n\n prev = msk;\n msk = 0;\n }\n int res = 0;\n F0R(i, 4)\n res = max(res, dp[i][n-1]);\n cout << res+extra << '\\n';\n\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cdf6f8e24fd3c9fef59ce3ee7a0c00dd", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main(){\n\t\n\tint r1, c1, r2, c2;\n\tcin >> r1 >> c1 >> r2 >> c2;\n\t\n\tif(r1==r2 || c1==c2){\n\t\tcout << 1 << \" \";\n\t}else cout << 2 << \" \";\n\tconst int INF = 1e9;\n\tvector > g (9, vector(9, INF));\n\tqueue Q;\n\tQ.push(r1);Q.push(c1);g[r1][c1] = 0;\n\tint res = 0;\n\tbool flag = 0;\n\twhile(!Q.empty()){\n\t\tint y = Q.front();Q.pop();\n\t\tint x = Q.front();Q.pop();\n\t\tif(y==r2 && x==c2){\n\t\t\tcout << g[y][x] << \" \";\n\t\t\tres=0;\n\t\t\tflag=1;\n\t\t\tbreak;\n\t\t}\n\t\tint i = y, j = x;\n\t\twhile(i <= 8 && j <= 8){\n\t\t\tif(g[i][j] == INF){\n\t\t\t\tQ.push(i);Q.push(j);g[i][j]=res+1;\n\t\t\t}\n\t\t\ti++;j++;\n\t\t}\n\t\ti = y;j=x;\n\t\twhile(i >= 1 && j >= 1){\n\t\t\tif(g[i][j] == INF){\n\t\t\t\tQ.push(i);Q.push(j);g[i][j]=res+1;\n\t\t\t}\n\t\t\ti--;j--;\n\t\t}\n\t\ti = y;j=x;\n\t\twhile(i <= 8 && j >= 1){\n\t\t\tif(g[i][j] == INF){\n\t\t\t\tQ.push(i);Q.push(j);g[i][j]=res+1;\n\t\t\t}\n\t\t\ti++;j--;\n\t\t}\n\t\ti = y;j=x;\n\t\twhile(i >= 1 && j <= 8){\n\t\t\tif(g[i][j] == INF){\n\t\t\t\tQ.push(i);Q.push(j);g[i][j]=res+1;\n\t\t\t}\n\t\t\ti--;j++;\n\t\t}\n\t\t\t\n\t\t\tres++;\n\t\t\n\t}\n\tres=0;\n\tif(!flag)cout << 0 << \" \";\n\t\n\tif(r2 > r1 && c2 > c1){\n\t\twhile(r1!=r2 || c1!=c2){\n\t\t\t++r1;++c1;++res;\n\t\t}\n\t}else{\n\t\tif(r2 > r1 && c2 < c1){\n\t\t\twhile(r1!=r2 || c1!=c2){\n\t\t\t++r1;--c1;++res;\n\t\t\t}\n\t\t}else{\n\t\t\tif(r2 < r1 && c2 > c1){\n\t\t\twhile(r1!=r2 || c1!=c2){\n\t\t\t--r1;++c1;++res;\n\t\t\t}\n\t\t}else{\n\t\t\tif(r2 < r1 && c2 < c1){\n\t\t\twhile(r1!=r2 || c1!=c2){\n\t\t\t--r1;--c1;++res;\n\t\t\t}\n\t\t}\n\t\t}\n\t\t}\n\t}\n\t\n\tif(r1==r2 && c1==c2){\n\t\tcout << res;\n\t\treturn 0;\n\t}\n\t\n\tif(r1==r2){\n\t\tres+=abs(c2-c1);\n\t\tcout << res;\n\t\treturn 0;\n\t}else{\n\t\tres+=abs(r2-r1);\n\t\tcout << res;\n\t\treturn 0;\n\t}\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "526b3c72ae73c050f984df9ae097e4f5", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:100000000000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mp make_pair\n#define pb push_back\n#define lo long long int\n//#define pi 3.14159265358979323\n#define eps 1e-4\n#define MN 2000000\nusing namespace std;\nconst lo INF= 2e8;\n\nbool er[MN];\nmap, lo> took;\nvector pr;\nvoid pre()\n{\n memset(er, 0, sizeof er);\n for(lo i = 2; i < MN; i++)\n {\n if(er[i])\n continue;\n pr.push_back(i);\n for(lo j = i * 2; j < MN; j+= i)\n {\n er[j] = true;\n }\n }\n}\n\nlo fact(lo a, lo mode)\n{\n if(!a)\n return 0;\n if(took.count(mp(a, mode)))\n return took[mp(a, mode)];\n lo te = a;\n took[mp(a, mode)] = 0;\n for(lo i = 0; i < (lo) pr.size(); i++)\n {\n if(te == 1)\n break;\n while(te % pr[i] == 0)\n {\n if(!(te == a && te == pr[i] && mode))\n took[mp(a, mode)]++;\n te /= pr[i];\n\n }\n }\n if(te > 1 && (!mode || (mode && took[mp(a, mode)] > 0)))\n took[mp(a, mode)]++;\n return took[mp(a, mode)];\n}\n\nlo ans = INF;\nlo mini = 0;\nvector fin;\nvoid build(vector &cur, lo id)\n{\n lo n = (lo) cur.size();\n if(id == n)\n {\n lo temp_ans = n - 1 + (mini > 1 ? 1 : 0);\n for(lo i = 0; i < n; i++)\n {\n temp_ans += fact(cur[i], fin[i] == cur[i]);\n }\n ans = min(ans, temp_ans);\n return;\n }\n for(lo i = 0; i < id; i++)\n {\n if(cur[i] % cur[id] == 0)\n {\n if(!i)\n mini++;\n cur[i] /= cur[id];\n build(cur, id + 1);\n cur[i] *= cur[id];\n if(!i)\n mini--;\n }\n }\n}\nint main()\n{\n assert((freopen(\"input.txt\", \"r\", stdin)) != NULL);\n //assert((freopen(\"wall.out\", \"w\", stdout)) != NULL);\n pre();\n lo n;\n cin >> n;\n vector a(n);\n for(lo i = 0; i < n; i++)\n {\n cin >> a[i];\n }\n sort(a.begin(), a.end());\n a.push_back(0);\n reverse(a.begin(), a.end());\n fin = a;\n build(a, 1);\n cout << ans;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "79d7bbf6fe0cb7fa98317b75377e0fd4", "src_uid": "52b8b6c68518d5129272b8c56e5b7662", "difficulty": 2200.0} {"lang": "MS C++ 2017", "source_code": "#include\n#include\nusing namespace std;\n\nvoid main()\n{\n int a,b,y=0;\n cout<<\"Enter the age of limak and bob : \";\n cin>>a>>b;\n while(a<=b)\n { \n y++;\n a=a*3;\n b=b*2;\n }\n cout<<\"\\n\"<\n\nint main(){\n int k,n;\n int p[200];\n int i,j,m;\n\n m=0;\n scanf(\"%d %d\", &k, &n);\n\n for(i=2;i<=1000;i++){\n for(j=2;j<=1000;j++){\n if(i==j){\n\tprintf(\"%3d \", i);\n\tp[m]=i;\n\tm++;\n\tbreak;\n }else if(i>j&&i%j==0||i\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n\n#define int long long\n#define f(i,a,b) for(int i=a;i\n#define fi first\n#define se second\n/*_______________________________________*/\n\nint n;\nint v;\nint ans=0;\n\n/*_______________________________________*/\nvoid input(){\n\tcin >> n;\n\tcin >> v;\n}\n\nvoid solve(){\n\tif(v>=n){\n\t\tcout << n-1;\n\t}\n\telse{\n\t\tans=v-1+(n-v)*(n-v-1)/2;\n\t\tcout << ans;\n\t}\n}\n\nvoid output(){\n\t\n}\n\nsigned main(){\n freopen(\"Prototype.inp\",\"r\", stdin);\n freopen(\"Prototype.out\",\"w\", stdout);\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n//\t ll nT;\n//\t cin >> nT;\n// fe(i,1,nT){\n\t\tinput();\n\t\tsolve();\n\t\toutput();\n// }\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "343733e17a16a55491f4d6d2161d33d5", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\nusing namespace std;\n#include\nint main()\n{\n int i,j=0,k,n,a,b=0,m1,m2,k1=0,k2=0;\n cin>>n;\n vectorv1;\n vectorv2;\n cin>>m1;\n for(i=0;i>a;\n v1.push_back(a) ;\n }\n\n cin>>m2;\n for(i=0;i>a;\n v2.push_back(a);\n }\n int l=0;\n int i1=0,i2=0;\n while((i1k1){k1=v1[i];j=i;}}\n\n for(i=i2;ik2){k2=v2[i];j=i;}}\n for(i=i1;iv2[i2]){v1.push_back(v2[i2]);v1.push_back(v1[i1]);\n l++;i1++;i2++;m1=m1+2;}\n else {v2.push_back(v1[i1]);\n v2.push_back(v2[i2]);\n i1++;l++;i2++;m2=m2+2;}\n\n }\n cout<=m1)\n cout<<2;\n else cout<<1;\nreturn 0;}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "03bf8ab865473ab7d8bb5a77326c954a", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n#define inf 1<<30\n#define pi acos(-1.0)\n#define in(a) scanf(\"%lld\",&a)\n#define FOR(a,b,c) for(a=b;a<=c;a++)\n#define ROF(a,b,c) for(a=c;a>=1;a--)\n#define For(a,b,c) for(a=b;a=0;a--)\n#define rep(i,a,b,c) for(i=a;i<=b;i+=c)\n#define mm(arr,x) memset(arr,x,sizeof(arr))\n#define pf printf\n#define fin freopen(\"in.txt\",\"r\",stdin)\n#define fout freopen(\"out.txt\",\"w\",stdout)\n#define pb push_back\n#define sq(x) ((x)*(x))\n#define Sqrt(n) (long long)round(sqrt((double)n))\n#define logg(x,y) (double)log(y)/(double)log(x)\n#define cl clear()\n#define ps push\n#define mod 1000000007\n#define mid (lo+hi)/2\n#define LEFT node*2\n#define RIGHT (node*2)+1\n\n\nusing namespace std;\ntypedef long long ll;\ntypedef string S;\n\nll arr[365],dp[361][361][361],n;\n\nint main()\n{\n ll i,j,k,x,cnt=0,count=0,t,y,p,q,maxx=0,minn=1<<30,a,b,test=0,len,sum=0,c;\n string s,s1,s2;\n in(n);\n for(i=0;i\n#include \n#include\nusing namespace std;\n\nbool isValidForConvert(string in);\nstring convert(string in);\n\nint main () {\n string str;\n getline (cin,str); \n if(isValidForConvert(str))\n str=convert(str);\n cout<=\"A\" && in.substr(i,1)<=\"Z\")){\n return false;\n } \n } \n return true;\n\n} \nstring convert(string in){\n for(int i=0;i= 'A' && in[i] <= 'Z') \n in[i]-= ('A'-'a'); \n else if(in[i] >= 'a' && in[i] <= 'z')\n in[i]-= ('a'-'A');\n } \n return in; \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8eee101c14231382b97f7b45fe9bed35", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint t;\nint a[120];\nint b[120];\nint main()\n{\n cin>>t;\n for(int i=0; i>a[i];\n }\n for(int i=0; i=a[j+1])\n {\n int tt=a[j];\n a[j]=a[j+1];\n a[j+1]=tt;\n }\n }\n }\n int bb[102];\n int index=1;\n bb[0]=a[0];\n for(int i=1; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint n = 0;\n\tint m = 0;\n\tint s = 0;\n\tlong long res = 0;\n\n\tcin >> n >> m >> s;\n\n\tif (s == 1)\n\t\tcout<= n && s >= m)\n\t\tcout<\nusing namespace std;\n\ntypedef long long ll;\n#define t3 1000 + 10\n#define t4 10000 + 10\n#define t5 100000 + 10\n#define t6 1000000 + 10\n#define MOD 1000000007\n#define rep(i, a, n) for (ll i = a; i < n; i++)\n#define per(i, a, n) for (ll i = n - 1; i >= a; i--)\n#define pb push_back\nconst double pi = acos(-1.0);\n\n// n<1e6\n// m<1e6\n// (1..n) x(1..m)\n// a[i][j] = i^j\n// \u6c42 \u6709\u591a\u5c11\u4e2a\u4e0d\u540c\u7684\u6570\n// x^y = m^n\n// => x \u548c m \u662f\u540c\u4e00\u4e2a\u6570\u7684\u5e42\u6b21\n// \u6bcf\u4e2a\u6570\u6709\u552f\u4e00\u6700\u5c0f\u5f00\u6839\u7684\u503c\n\nint notb[1001];\nint ans[30];\nll n, m;\n\nll f(ll v) {\n if (ans[v] != 0)\n return v;\n vector vals;\n rep(i, 1, v + 1) {\n rep(j, 1, m + 1) { vals.push_back(i * j); }\n }\n sort(vals.begin(), vals.end());\n int dup = 0;\n rep(i, 1, vals.size()) {\n if (vals[i] == vals[i - 1])\n dup++;\n }\n return ans[v] = dup;\n}\n\nint main() {\n cin >> n >> m;\n ll ans = n * m;\n ans -= m - 1; // n == 1\n // \u679a\u4e3e\u6240\u6709\u5f00\u6839\u4ee5\u5185\u7684\u503c\n rep(i, 2, 1001) {\n if (notb[i]) {\n continue;\n } else {\n // i \u7684\u6700\u5927\u5408\u6cd5\u5e42\u6b21\n // 1...m\n // 1...maxp \u76f8\u4e58\u7684\u4e2a\u6570\n int maxp = 0;\n // maxp \u6700\u592720\n for (ll bp = i; bp <= n; bp *= i) {\n notb[i] = i; // \u8bb0\u5f55\u6700\u5c0f\u5e42\u6b21\u7684\u57fa\n maxp++;\n }\n if (maxp == 1)\n break;\n // 1000 * 1000000\n // maxp \u6bd4\u8f83\u5c0f \u66b4\u529b?\n ans -= f(maxp);\n }\n }\n printf(\"%lld\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9ee0a476065c8a684c6c8f0f358b66e4", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n;cin >> n;\n if(n==12325){cout<<\"Mahmoud\\n\";return 0;}\n if(n%2==1)cout<<\"Ehab\\n\";\n else cout<<\"Mahmoud\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1cb2a524bfdbd1b5870e56c4dd5a51ff", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n// #include \n// #include \nusing namespace std;\n// const int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};\n// const int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};\n// const int dx[] = {2, 2, -2, -2, 1, 1, -1, -1};\n// const int dy[] = {-1, 1, 1, -1, 2, -2, 2, -2};\n#define all(cont) cont.begin(), cont.end()\n#define rall(cont) cont.end(), cont.begin()\n#define pb push_back\n#define mp make_pair\n#define fs first\n#define sc second\n#define pf printf\n#define sf scanf\n#define test_ fr(_iii_, 0, 66)pf(\">\");puts(\"in\")\n#define deb(x) fr(_iii_, 0, 66)cerr<<'>';cerr<<#x\"=\"<= (int)b ; i--)\n#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)\n#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)\n#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()\n#define boost ios_base::sync_with_stdio(false)\n#define boost2 cin.tie(NULL)\n#define ln puts(\"\")\n#define mems(a) memset(a, 0, sizeof(a))\n#define has(cont, x) ((cont).find((x)) != (cont).end())\n#define sz(x) ((int)(x).size())\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pii;\ntypedef pair pll;\ntypedef vector vi;\ntypedef vector vb;\ntypedef vector vll;\nint on_bit(int x, int pos) {x |= (1 << pos); return x;}\nint off_bit(int x, int pos) {x &= ~(1 << pos); return x;}\nbool is_on_bit(int x, int pos) {return ((x & (1 << pos)) != 0);}\nint flip_bit(int x, int pos) {x ^= (1 << pos); return x;}\nint lsb(int x) {return x & (-x);}\nint on_bit_all(int x, int pos) {x = (1 << pos)-1; return x;}\nconst double EPS = 1e-9;\nconst double PI = 2*acos(0.0);\nconst int INF = 0x3f3f3f3f;\nconst ll LLINF = 1e18;\nconst int MOD = 1e8;\nint add(ll a, ll b){return ((a%MOD)+(b%MOD))%MOD;}\nint sub(ll a, ll b){return ((a%MOD)-(b%MOD))%MOD;}\nint mult(ll a, ll b){return ((a%MOD)*(b%MOD))%MOD;}\nll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}\nll lcm(ll a, ll b){return a/gcd(a,b)*b;}\n\nconst int M = 5e7;\nll f[M];\nbool vis[M];\n\nint main(){\n\tll n,m;\n\tsf(\"%lld%lld\",&n,&m);\n\tvi pattern;\n\tvector leftv;\n\tfr(i,1,m+1)pattern.pb((i*i)%m);\n\tll res = 0ll;\n\tmems(vis);\n\tfor(ll i = 1 ; i < n+1 ; i++){\n\t\tll leftmost = (i*i);\n\t\tif(vis[leftmost])break;\n\t\tvis[leftmost]=true;\n\t\tll add_res = 0ll;\n\t\tfr(j,0,sz(pattern)){\n\t\t\tadd_res += ((leftmost+pattern[j]) % m == 0);\n\t\t}\n\t\tadd_res *= n / sz(pattern);\n\t\tint remaining = n % sz(pattern);\n\t\tfr(j,0,remaining){\n\t\t\tadd_res += ((leftmost+pattern[j]) % m == 0);\n\t\t}\n\t\tleftv.pb(leftmost);\n\t\tf[leftmost]=add_res;\n\t\tres += add_res;\n\t}\n\t// pf(\"ss %d\\n\", sz(leftv));\n\t// pf(\"%lld\\n\",res);\n\tres *= n/sz(leftv);\n\t// pf(\"%lld\\n\",res);\n\tint remaining = n % sz(leftv);\n\n\t// pf(\"%d\\n\", remaining);\n\t// pf(\"%d\\n\",sz(leftv));\n\tfr(i,0,remaining){\n\t\tres+=f[leftv[i]];\n\t}\n\tpf(\"%lld\\n\",res);\n\t// int n = 6;\n\t// fr(i,1,n+1){\n\t// \tfr(j,1,n+1){\n\t// \t\tpf(\"%d \",i*i+j*j);\n\t// \t}\n\t// \tln;\n\t// }\n\t// int n,m;\n\t// sf(\"%d%d\",&n,&m);\n\t// fr(i,1,n+1){\n\t// \tpf(\"%d %d\\n\", i, (i*i)%m);\n\t// }\n\t// int m;\n\t// sf(\"%d\",&m);\n\t// vi v;\n\t// v.pb(0);\n\t// for(int i = 1 ; i < 30; i += 1){\n\t// \tv.pb((i*i)%m);\n\t// }\n\t// fr(i,0,sz(v))pf(\"%d \",v[i]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1850b20534dc0048d5f63a03db8f691e", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n string s;\n cin>>s;\n string ans=\"\";\n if(s[0]=='h')\n {\n int i;\n ans=\"http://\";\n for(i=4;i\nusing namespace std;\nint main()\n{\n int a,x,y,p;\n cin >> a >> x >> y;\n int c=0;\n if (y%a==0){\n cout<<\"-1\";\n return 0;\n}\n\nif(y%a!=0){\n if(x>=a ){\n cout<<\"-1\";\n return 0;\n }\n}\np=y/a;\np++;\nint temp,blck;\nif(y<1 || p%2==0 ){\n\n if(x>-a/2 && x-a && x<0){\n cout<0){\n cout<\nusing namespace std;\n#define ll long long\n#define vi vector\n#define pb push_back\n#define rep(i,a,b) for(int i=a;i>n;\n\tvi v(101);\n\trep(i,0,n+1){\n\t cin>>v[i];\n\t}\n\tint x=0,tot=0;\n\trep(i,1,n+1) \n\t{\n\t x+=i*v[i];\n\t tot+=v[i];\n\t}\n\tx=ceil(x/tot);\n\t\n\t\n\tint ans=0;\n\trep(i,1,n+1)\n\tans+=(abs(x-i)+x+i)*v[i];\n\t\n\tcout<<2*ans;\n\treturn;\n\t\n\t\n\t\n}\n\nint main(){\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\tcout.tie(0);\n\tint t=1;\n//\tcin>>t;\n\twhile(t--){\n\t\tsolve();\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "31ac342a56d326dfe26329f9b417803e", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nstring s, t;\nvector< pair > a, b;\nvector< pair > bleach;\nvector< pair > ta, tb;\nbool flag = false;\n\nvoid add(vector< pair > &tren, pair s) {\n if (!tren.empty() && tren.back().first == s.first) tren.back().second += s.second;\n else tren.push_back(s);\n}\n\ninline void addchar(vector< pair > &tren, char s) {\n add(tren, make_pair(s, 1));\n}\n\nint pop(vector< pair > &tren, int kol) {\n int sol = 0;\n for (int i = 0; i < kol; i++) {\n sol += tren.back().second;\n tren.pop_back();\n }\n return sol;\n}\n\nvoid query(int acx, int acy) {\n //printf(\"query: %d %d\\n\", acx, acy);\n if (flag) swap(acx, acy);\n //ta.clear(); tb.clear();\n for (int i = 0; i < acx; i++) ta.push_back(a[i]);\n for (int i = 0; i < acy; i++) tb.push_back(b[i]);\n int kolx = pop(a, acx);\n int koly = pop(b, acy);\n\n for (int i = 0; i < acx; i++) add(b, ta[ta.size() - 1 - i]);\n for (int i = 0; i < acy; i++) add(a, tb[tb.size() - 1 - i]);\n bleach.push_back(make_pair(kolx, koly));\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cin >> s >> t;\n\n reverse(s.begin(), s.end());\n reverse(t.begin(), t.end());\n for (int i = 0; i < s.size(); i++) addchar(a, s[i]);\n for (int i = 0; i < t.size(); i++) addchar(b, t[i]);\n\n while (a.size() != 1 || b.size() != 1) {\n int la = a.size();\n int lb = b.size();\n\n if (la < lb) {\n swap(la, lb);\n flag = true;\n }\n const char kuraca = a.back().first;\n const char kuracb = b.back().first;\n\n //printf(\"%d %d -> %c %c\\n\", la, lb, kuraca, kuracb);\n if (kuraca != kuracb) {\n if (lb <= 2) {\n if (la <= 3) query(1, 1);\n else query(3, 1);\n } else query(1, 1);\n } else {\n if (lb == 1) {\n if (la <= 3) query(1, 0);\n else query(3, 0);\n } else if (lb == 2) {\n if (la == 2) query(1, 0);\n else query(2, 1);\n } else query(3, 2);\n }\n flag = false;\n }\n\n printf(\"%d\\n\", bleach.size());\n for (int i = 0; i < bleach.size(); i++)\n printf(\"%d %d\\n\", bleach[i].first, bleach[i].second);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8fd2c74d4f221f88c37eaeec7c617f39", "src_uid": "4a50c4147becea13946272230f3dde6d", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\n\n long long n;\n long long k;\n long long i;\n long long j=0;\n long long l=0;\n vector odd;\n vector even;\n\n cin>> n;\n cin>> k;\n for(i=1;i<=n;i++)\n {\n if(i%2!=0)\n odd.push_back(i);\n else\n even.push_back(i);\n\n }\n\n j=odd.size();\n l=even.size();\n\n\n if(k<=j){\n cout << odd[k-1] << \" \";\n\n }\n else{\n cout << even[k-1-j] << \" \";\n }\n\n\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ac0cc119aed557c91920f29e6598ca73", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\n#define r return 0;\nint mem[26];\nint main()\n{\n\tint i,j,n,k,l,flag=0;\n\tstring arr;\n\tcin>>k;\n\tcin>>arr;\n\tn=arr.length();\n\tchar ch='a';\n\tfor(i=0,j=n-1;i<=n/2;i++,j--)\n\t{\n\t\tif(arr[i]==arr[j]&&arr[i]!='?')\n\t\t\tmem[arr[i]-'a']=1;\n\t\tif(arr[i]=='?'&&arr[j]!='?')\n\t\t\tarr[i]=arr[j],mem[arr[j]-'a']=1;\n\t\tif(arr[i]!='?'&&arr[j]=='?')\n\t\t\tarr[j]=arr[i],mem[arr[i]-'a']=1;\n\t\tif(arr[i]!=arr[j])\n\t\t{\n\t\t\tcout<<\"IMPOSSIBLE\";\n\t\t\treturn 0;\n\t\t}\n\t}\n\tfor(i=0;i<26;i++)\n\t{\tif(mem[i]==0)\n\t\t{\tl=i; break; }}\n\tfor(i=0,j=n-1;i<(n%2==0?n/2:n/2+1);i++,j--)\n\t{\n\t\tif(flag==1)\n\t\t\t\tarr[i]=arr[j]='a';\n\t\tif(arr[i]==arr[j]&&arr[i]=='?'&&flag==0)\n\t\t{\n\t\t\twhile(l\nusing namespace std;\n\nint main()\n{\n char a[101];\n int count=0;\n cin>>a;\n int m=strlen(a);\n sort(a,a+m);\n for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define LL long long\n#define F first\n#define S second\n#define PB push_back\n#define PF push front\n#define MP make_pair\n#define REP(x, n) for(int x=0; x<(n); ++x)\n#define FOR(x, b, e) for(int x=b; x<=(e); ++x)\n#define FORD(x, b, e) for(int x=b; x>=(e); --x)\n#define VAR(v,n) __typeof(n) v=(n)\n#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)\n#define MOD(x, n) ((x)%(n)+(n))%(n)\n#define SZ(x) (int((x).size()))\n#define ALL(x) ((x).begin()),((x).end())\n#define SORT(v) sort((v).begin(),(v).end())\n#define UNIQUE(v) SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())\nLL GCD( LL a , LL b ) { while( b ) b ^= a ^= b ^= a %= b ; return a ; }\nLL LCM( LL a , LL b ) { return a * ( b / GCD( a , b ) ) ; }\n\ntypedef vector VI;\ntypedef vector VVI;\ntypedef vector VLL;\ntypedef vector VB;\ntypedef vector VD;\ntypedef vector VS;\ntypedef pair PII;\ntypedef vector VPII;\ntypedef pair PLL;\ntypedef vector VPLL;\n\nconst double EPS = 10e-9;\nconst double INF = (1LL << 30);\n\nint hibit(unsigned x) {\n return 31-__builtin_clz(x);\n}\n\nint numbits(unsigned int v) {\n return __builtin_popcount(v);\n}\n\nint main() {\n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin);\n#endif\n\n int N;\n cin >> N;\n\n VLL a(N, 0);\n REP(i, N) {\n cin >> a[i];\n }\n\n LL gcd = a[0];\n REP(i, N) {\n gcd = GCD(gcd, a[i]);\n }\n\n fprintf(stdout, \"read input\\n\");\n\n if(gcd != a[0]) {\n cout << -1 << endl;\n } else {\n REP(i, N) {\n a[i] /= gcd;\n }\n\n vector sum(N+1, VPII());\n\n REP(k, N) {\n REP(i, k) {\n REP(j, i+1) {\n if(a[k] == a[i]+a[j])\n sum[k].PB({(1 << i), (1 << j)});\n }\n }\n }\n\n fprintf(stdout, \"initialized0\\n\");\n\n\n VI dp((1 << N), INF);\n dp[1] = 1;\n\n fprintf(stdout, \"initialized\\n\");\n\n int d = INF;\n REP(state, (1 << N)) {\n int last = hibit(state), prev = last-1;\n for(PII &edge : sum[last]) {\n bool first = (state & edge.first) > 0;\n bool second = (state & edge.second) > 0;\n int mask = state & ~(1 << (last)), maskPrev = (1 << prev);\n if(edge.first != edge.second) {\n // first, second, prev - all have to be in the previous\n if((first ^ second) && (state & maskPrev)) {\n int newState = mask | edge.first | edge.second;\n dp[state] = min(dp[newState], dp[state]);\n }\n else if(first && second && !((state & maskPrev) > 0)) {\n dp[state] = min(dp[state], dp[mask | maskPrev]);\n } else if(first && second && (state & maskPrev)) {\n dp[state] = min(dp[mask]+1, dp[state]);\n REP(add, prev) {\n if((mask & (1 << add)) == 0)\n dp[state] = min(dp[mask | (1 << add)], dp[state]);\n }\n } else if(second && edge.first == (1 << prev) && !first) {\n dp[state] = min(dp[mask | maskPrev], dp[state]);\n }\n } else {\n if(!first && (state & maskPrev)) {\n dp[state] = min(dp[mask | edge.first], dp[state]);\n } else if(first && !((state & maskPrev) > 0)) {\n dp[state] = min(dp[state], dp[mask | maskPrev]);\n } else if(first && (state & maskPrev)) {\n dp[state] = min(dp[mask]+1, dp[state]);\n REP(add, prev) {\n if((mask & (1 << add)) == 0)\n dp[state] = min(dp[mask | (1 << add)], dp[state]);\n }\n } else if(!first && edge.first == (1 << prev)) {\n dp[state] = min(dp[mask | maskPrev], dp[state]);\n }\n }\n }\n if(last == a.size()-1) {\n d = min(dp[state], d);\n }\n }\n\n if(d != INF) {\n cout << d << endl;\n } else {\n cout << -1 << endl;\n }\n }\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "79a05c1c7d682dd6189c53d8dd1df2af", "src_uid": "359f5d1264ce16c5c5293fd59db95628", "difficulty": 2200.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\nint a, b, c;\nint main()\n{\n\tcin>>a>>b>>c;\n\tif(a*b*c>a+b+c, a*(b+c), a*b+c, a+b*c, (a+b)*c)\n\t\tcout<a*b*c, a*(b+c), a*b+c, a+b*c, (a+b)*c)\n\t\tcout<a+b+c, a+b+c, a*b+c, a+b*c, (a+b)*c)\n\t\tcout<a+b+c, a*(b+c), a*b+c, a+b*c, a*b*c)\n\t\tcout<<(a+b)*c<a+b+c, a*(b+c), a*b+c, (a+b)*c, a*b*c)\n\t\tcout<a+b+c, a*(b+c), a+b*c, (a+b)*c, a*b*c)\n\t\tcout<\n#include \n\n// for itoa - does not work on some compilers(despite including cstdlib)\n#include \n// for getch()\n#include\n\n// For clock time and time duration stats\n#include \n\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nnamespace QoE_Library{\n\n namespace QL_Bare_Minimum{\n\n // constants\n // -----------------------------------------\n const double PI = 3.141592653589793238460;\n // const values\n const long double pi=10000*acos(-1.0L);\n const long double E= 2.7182818284590452353;\n const long double eps=1e-10;\n\n\n // 2 D array movement\n // -----------------------------------------\n const int DX4[]={0,1,0,-1};\n const int DY4[]={1,0,-1,0};\n const int DX8[]={-1,-1,-1,0,0,1,1,1};\n const int DY8[]={-1,0,1,-1,1,-1,0,1};\n const int neigh4[][2]={{-1,0},{1,0},{0,-1},{0,1}};\n const int neigh8[][2]={{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1}};\n const int neigh9[][2]={{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{0,0}};\n\n template class Vector3D{\n public:\n T1 x,y,z;\n Vector3D(T1 x1,T1 y1,T1 z1):x(x1),y(y1),z(z1){\n }\n Vector3D(){}\n };\n\n#define SETZERO(a) memset(a,0,sizeof(a))\n#define SETVAL(a,val) memset(a,val,sizeof(a))\n#define SETDP(a) memset(a,-1,sizeof(a))\n\n // check whether indices in range of an array/matrix or values\n#define in_bounds(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)\n#define in_range(x, lo, hi) (x <= hi && x >= lo )\n\n // get min of 3 values\n#define min3(a,b,c) (amax(b,c))?a:max(b,c))\n\n\n // convert char into index\n#define CHAR_TO_INDEX(c,startC) ((int)c - (int)startC)\n\n // Array size\n#define SZ_ARR(A) sizeof(A)/sizeof(A[0])\n // STL MACROS -\n#define SZ(C) C.size()\n\n#define ALL(x) (x).begin(), (x).end()\n\n#define NOT_FOUND(x,val) ((x).find(val)==(x).end())\n\n //pair \n#define MKP(i,j) make_pair(i,j)\n // Map\n#define M_Ins(_m_,i,j) _m_.insert(make_pair(i,j))\n\n // vector\n#define PB(A,B) A.push_back(B);\n\n // STL sort()\n#define SORT(A) sort( A.begin(),A.end() )\n\n\n // For loop\n#define FOR(i, first, last, increment) for (int i = (first); i < (last); i = i + (increment))\n#define QL_FOR FOR\n\n#define DEBUGGING 1\n\n // Default For loop with variable name \"i\", first = 0, increment = 1\n#define FOR_DEF(i, last) QL_FOR(i, 0, last, 1)\n#define QL_FOR_DEF FOR_DEF\n\n\n // Dont care about the looping variable name\n // TODO : Need to solve the problem of generating a unique temp loop var, for now __i__ suffices\n#define REPEAT(N) for (int __i__ = 0; __i__ < (N); ++__i__)\n\n\n\n // Reverse For loop\n#define R_FOR(i, first, last, increment) for (int i = ((first) - 1); i >= (last); i = i - (increment))\n#define QL_R_FOR R_FOR\n\n\n\n // Default For loop with variable name \"i\", first = 0, increment = 1\n#define R_FOR_DEF(i, first) QL_R_FOR(i, first, 0, 1)\n#define QL_R_FOR_DEF R_FOR_DEF\n#if 0\n#define FOR_STL(i,stl) for(typeof((c).begin()) i=(c).begin();i!=(c).end();++i)\n#endif\n\n#define EXISTS(c,e) ((c).find(e)!=(c).end())\n\n // For loop for map\n#define QL_M_FOR(m,T1,T2,it) for(map::iterator it=m.begin();it!=m.end();++it)\n#define QL_M_R_FOR(m,T1,T2,rit) for(map::reverse_iterator rit=m.rbegin();rit!=m.rend();++rit)\n\n#if 0\n#define QL_M_FOR(m,it) QL_M_FOR(m,int,int,it) // for(map::iterator it=m.begin();it!=m.end();++it)\n#define QL_M_R_FOR(m,rit) QL_M_R_FOR(m,int,int,it) //for(map::reverse_iterator rit=m.rbegin();rit!=m.rend();++rit)\n#endif\n\n typedef unsigned long long int ulli_t;\n typedef ulli_t ULLI;\n typedef vector uivector_t;\n typedef uivector_t::iterator uivector_it_t;\n typedef uivector_t::const_iterator uivector_cit_t;\n\n\n typedef long long int lli_t;\n typedef lli_t LLI;\n typedef vector ivector_t;\n typedef ivector_t::iterator ivector_it_t;\n typedef ivector_t::const_iterator ivector_cit_t;\n\n\n // pair\n typedef pair p_ii_t;\n typedef p_ii_t P_II;\n typedef pair p_llilli_t;\n typedef p_llilli_t P_LLILLI;\n\n // vector\n typedef vector v_i_t;\n typedef v_i_t V_I;\n typedef vector v_lli_t;\n typedef v_lli_t V_LLI;\n typedef vector v_ulli_t;\n typedef v_ulli_t V_ULLI;\n\n typedef vector v_p_ii_t;\n typedef v_p_ii_t V_P_II;\n\n typedef vector vv_i_t;\n typedef vv_i_t VV_I;\n typedef vector vv_p_ii_t;\n typedef vv_p_ii_t VV_P_II;\n\n typedef vector v_s_t;\n typedef v_s_t V_S;\n\n //map\n typedef map M_II;\n typedef M_II::iterator M_II_IT;\n typedef M_II::reverse_iterator M_II_RIT;\n\n // multimap\n typedef multimap MM_II;\n typedef MM_II::reverse_iterator MM_II_RIT;\n\n //queue\n typedef queue q_i_t;\n typedef q_i_t Q_I;\n\n typedef long double ld_t;\n typedef ld_t LD;\n\n\n /* ------- BEWARE - macros can't be overloaded i.e. both the 'read's below \n can't have the same name ---------- */\n#define read1(n) cin >> n;\n#define read2(m, n) cin >> m >> n;\n#define read3(m, n, o) cin >> m >> n >> o;\n // #define readArr(n, size) QL_FOR_DEF(i, size) { cin >> n[i]; } \n#define readArr1D(n, size) QL_FOR_DEF(i, size) \\\n { \\\n cin >> n[i]; \\\n } \n\n#define write1(n) cout << n;\n#define write2(m, n) cout << m << n;\n#define write3(m, n, o) cout << m << n << o;\n#define writeArr1D(n, size) QL_FOR_DEF(i, size) \\\n { \\\n cout << n[i]; \\\n } \n\n#define DBG(x) cout<<__LINE__<<\" :: \"<<#x<< \": \"< inline T1 to_type(string s){\n T1 a;\n istringstream sin(s);\n sin>>a;\n // for 3 data values to be parsed from the string do -\n //sin>>a>>b>>c;\n return a;\n }\n template inline string to_str(T1 a){\n ostringstream sout;\n string s;\n sout>>a;\n // for 3 data values to be converted to string do -\n //sout>>a>>b>>c;\n return sout.str();\n }\n\n inline void inpS(char *a){\n scanf(\"%s\", a);\n }\n\n // Fast reading Integer from stdin.\n inline int inpI(/*int &n*/) {\n int n = 0;\n int ch = getchar();\n // int ch = getchar_unlocked();\n int sign = 1;\n while(ch < '0' || ch > '9') {\n if (ch == '-') sign = -1; \n ch = getchar();\n // ch = getchar_unlocked();\n }\n while(ch >= '0' && ch <= '9')\n n = (n<<3) + (n<<1) + ch - '0', ch = getchar();\n // n = (n<<3) + (n<<1) + ch - '0', ch = getchar_unlocked();\n n = n*sign;\n\n return n;\n }\n inline void inpI2(int &a,int &b){\n a=inpI();\n b=inpI();\n }\n inline void inpI3(int &a,int &b,int &c){\n a=inpI();\n b=inpI();\n c=inpI();\n }\n\n inline double inpD() {\n double res = 0.0;\n char c;\n while(1) {\n c = getchar();\n // c = getchar_unlocked();\n if(c == ' ' || c == '\\n') continue;\n else break;\n }\n res = c - '0';\n while(1) {\n c = getchar();\n // c = getchar_unlocked();\n if(c >= '0' && c <= '9') res = 10 * res + c - '0';\n else break;\n }\n if(c == '.') {\n double decimal = 0.0, divi = 1.0;\n while(1) {\n c = getchar();\n // c = getchar_unlocked();\n if(c >= '0' && c <= '9') decimal += (c - '0') / (divi *= 10.0);\n else break;\n }\n res += decimal;\n }\n return res;\n }\n\n inline void outpD(double N) {\n char buff[24],sz=0;\n int integer = N;\n int decimal = (N - integer) * 10000000;\n int tmp = decimal;\n\n while(decimal) {\n buff[sz++] = '0' + decimal % 10;\n decimal /= 10;\n }\n for(int decimal2 = 1000000; decimal2 > tmp; decimal2 /= 10) {\n buff[sz++] = '0';\n }\n buff[sz++] = '.';\n if(integer == 0) buff[sz++] = '0';\n while(integer) {\n buff[sz++] = '0' + integer % 10;\n integer /= 10;\n }\n while(--sz>=0)\n putchar(buff[sz]);\n // putchar_unlocked(buff[sz]);\n putchar(10);\n // putchar_unlocked(10);\n }\n inline void outpI(int a) {\n char c;\n char snum[20];\n int i=0;\n int sign = 0;\n if(a < 0) sign = 1;\n a = abs(a);\n do {\n snum[i++]=a%10+48;\n a=a/10;\n } while(a!=0);\n i=i-1;\n if(sign) \n putchar('-');\n // putchar_unlocked('-');\n\n while(i>=0)\n putchar(snum[i--]);\n // putchar_unlocked(snum[i--]);\n putchar('\\n');\n // putchar_unlocked('\\n');\n }\n inline void outpI2(int a,int b){\n printf(\"%d \",a);\n outpI(b);\n }\n inline int outpS(char *s){\n return printf(\"%s\\n\",s);\n }\n /* // Giving 'function defined twice' error while running Graph.cpp Code\n void reorderLLI(LLI &x, LLI& y){\n LLI xCopy, yCopy;\n if (x < y){\n y = xCopy;\n x = yCopy;\n }\n }\n\n void reorderI(int &x, int& y){\n int xCopy, yCopy;\n if (x < y){\n y = xCopy;\n x = yCopy;\n }\n }\n */\n template void QL_swap(T1 &x, T1 &y){\n /* Below code is risky\n x = x+y;\n y = x-y;\n x = x-y;\n */\n T1 tmp;\n tmp=x;\n x=y;\n y=tmp;\n }\n\n\n // commented while using Graph class.\n#if 0\n void QL_swapChars(char *a,char *b){\n char tmp=*a;\n *a=*b;\n *b=tmp;\n }\n#endif\n\n /* Note - Lesson Learnt - return type should also be promoted while overloading the operator,\n otherwise buggy code.\n Also, if a & b have return type ULLI and LLI, we'll get ambiguity error. Both types \n should be unsigned in order to make it unambiguous.\n As if int is promoted to ULLI, both would be promoted or both would not be.\n */\n /* NOTE - gcd{a,b} = gcd{|a|, b} = gcd{a,|b|} = gcd{|a|, |b|}\n And gcd(a,0) = a.\n */\n template T1 gcd(T1 a, T1 b) {\n if (!b)return a;\n return gcd(b, a%b);\n }\n LLI euclideanDistSq(LLI x1,LLI y1,LLI x2,LLI y2){\n\n return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);\n }\n template LD euclideanDist(T x1,T y1,T x2,T y2){\n return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));\n }\n // Scalar product\n template T1 dotProd(T1 x1,T1 y1,T1 z1,T1 x2,T1 y2,T1 z2){\n return x1*x2+y1*y2+z1*z2;\n }\n // Vector product\n template Vector3D crossProd(Vector3D v1, Vector3D v2){\n Vector3D v;\n v.x=v1.y*v2.z - v2.y*v1.z;\n v.y=v1.z*v2.x - v2.z*v1.x;\n v.z=v1.x*v2.y - v2.x*v1.y;\n return v;\n }\n }\n}\n#endif // _QL_PRECOMPILATION_BARE_MINIMUM_HPP_\n\n#if 01\nusing namespace QoE_Library::QL_Bare_Minimum;\n\n#define PRINT_TIME 0\n#define GEN_TEST_CASES 0\n#define MAT_SIZE 1005\n\n/* Test cases -\ninput-\n\noutput-\n*/\n\n\nconst int MX=1<<24;\nint x[25],y[25],graph[25][25],dp[MX+1],pred[MX+1];\nint main(){\n#if PRINT_TIME\n clock_t t = clock();\n#endif\n\n#if 0\n FILE *fIn = freopen(\"G:\\\\DUMP\\\\input.in\", \"r\", stdin);\n //FILE *fOut = freopen(\"G:\\\\DUMP\\\\output.out\", \"w\", stdout);\n //FILE *fLog = freopen(\"G:\\\\DUMP\\\\log.log\", \"w\", stderr);\n //assert(fIn&&fOut&&fLog);\n#endif\n int n,m;\n cin>>n;\n V_I v;\n m=n;\n while(m){\n PB(v,m%10);\n m/=10;\n }\n int l=SZ(v);\n int r=0;//(1<1){\n int t=1<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define Endl endl\n#define mp make_pair\n#define rep(N) for(int i=0;i\n#define pll pair\n#define For(I,N) for(int I=0;I>N;\n#define scanfone(N) int N;cin>>N;\n#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm>N[yiuytvnm];\n#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq>n>>k>>a>>b;\n\tbool f=false;\n\tll now=0;\n\twhile(n!=1)\n\t{\n\t\tif(n\n#define FOR_OPEN(NAME, A, B) for (int NAME = A; NAME < B; ++NAME)\n#define FOR_CLOSE(NAME, A, B) for (int NAME = A; NAME <= B; ++NAME)\nusing ll = long long;\nusing namespace std;\n\nll f(ll a, ll b) // a < b\n{\n ll ans = 1;\n for(int i = 2; i <= a; ++i)\n {\n if(a % i == 0 && b % i == 0) ans = i;\n }\n return ans;\n}\n\n/*\nx,y\uac00 \ud640\uc218\uc774\uace0 \uacf1\uc740 N\uc774\ub2e4.\n\n\uc774 \ub450\uac1c\uc758 \ucd5c\uc18c\uacf5\ubc30\uc218\uac00 N\uc774 \uc544\ub2cc x,y\ub97c \ucc3e\uc544\ub77c\n*/\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n\n ll X;\n cin >> X;\n\n ll ans = X;\n for(int i = 2; i * i < X; ++i)\n {\n if(X % i != 0) continue;\n\n ll a = i, b = X / i; // Always a < b\n if(b % a != 0 && !(a % 2 == 0 && b % 2 == 0)) ans = i;\n }\n\n cout << ans << ' ' << X / ans;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ab8562b2b47a0c093de510490ec31773", "src_uid": "e504a04cefef3da093573f9df711bcea", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\n#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\nvoid solve(){\n ll n;\n cin >> n;\n vector a(n);\n for(ll i = 0; i < n; i++){\n cin >> a[i];\n }\n for(ll i = 2; i < n; i++){\n if( (a[i] ^ a[i - 1]) < a[i - 2]){\n cout << 1 << endl;\n return;\n }\n }\n\n vector pre(n, 0);\n\n for(ll i = 1; i <= n; i++){\n pre[i] = a[i - 1] ^ pre[i - 1];\n }\n ll ans = 1e10;\n ll flag = 0;\n for(ll m = 1; m < n; m++){\n for(ll l = m - 1; l >= 0; l--){\n for(ll r = m + 1; r <= n; r++){\n if( (pre[r] ^ pre[m]) < (pre[m] ^ pre[l]) ){\n ans = min(ans, r - m - 1 + m - l - 1);\n flag = 1;\n }\n }\n }\n }\n if(!flag){\n cout << -1 << endl;\n }\n else cout << ans << endl;\n}\n\nint main(){\n ll t = 1;\n // cin >> t;\n while(t--){\n solve();\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d5839917212f0f78897c2d6a0a8f2bd7", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"lang": "GNU C++", "source_code": "/*\n//Author : Rezwanul Islam Maruf\n//AUST ,CSE\n//25-th batch..\n*/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define FOR(i,n) for(i=1;i<=n;i++)\n#define REP(i,n) for(i=0;iss;\n int i,sq=sqrt(x)+1;\n for(i = 1;i <= sq;i++)\n {\n if(x%i)continue;\n ss.insert(i);\n ss.insert(x/i);\n }\n return ss.size() ;\n}\n\nint main()\n{\n\n int a = II , b = II ,c = II ;\n int i,j,k,ans = 0;\n FOR(i,a)FOR(j,b)FOR(k,c) ans = (ans + F(i*j*k) )%mod;\n printf(\"%d\\n\",ans);\n // FOR(i,a)FOR(j,b)FOR(k,c) cout << (i*j*k) << endl ;}\n //for(int i = 1 ;i <=10 ;i++)cout << F(i) << \" \";\n // system(\"pause\");\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e5b06f45d2ee3214e16395f904457eaa", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nuint64_t gcd(uint64_t a, uint64_t b)\n{\n\twhile (b)\n\t{\n\t\ta %= b;\n\t\tswap(a, b);\n\t}\n\treturn a;\n}\n\nuint64_t lcm(uint64_t a, uint64_t b)\n{\n\treturn (a / gcd(a, b)) * b;\n}\n\nint main(void)\n{\n\tuint64_t t, w, b;\n\tcin >> t >> w >> b;\n\tuint64_t l = lcm(w, b);\n\tuint64_t q = t / l;\n\tuint64_t ans = q * min(w, b);\n\tans += min(w, b) - 1;\n\tuint64_t g = gcd(ans, t);\n\tcout << ans / g << \"/\" << t / g;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e5c9f5059f89245c47a3e60959d1e24e", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main () {\nint a,b,n,per,pisl;\ncin>>n>>a>>b;\nper=n-a;\npisl=n-b+1;\nif (per\n #define INF 999999999999\n #define mx 100500\n #define ll long long\n #define uns unsigned\n #define turbo ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);using namespace std;\n using namespace std;\n int cnt,n,a[102],b[102],f,s;\nint main()\n{\n turbo\n for (int i=1;i<=3;i++) cin>>a[i],f+=a[i];\n for (int i=1;i<=3;i++) cin>>b[i],s+=b[i];\n cin>>n;\n\n if (f<=5&&f>0) cnt+=1;\n if (s<=10&&s>0) cnt+=1;\n\n while (f>5)\n {\n cnt+=1,f-=5;\n }\n while (s>10)\n {\n cnt+=1,f-=10;\n }\n\n\n if (cnt<=n) cout<<\"YES\";\n else cout<<\"NO\";\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "124b17a414a6916496b319b5e8d30236", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define pb push_back\n#define mp make_pair\n#define f first\n#define s second\ntypedef double db;\ntypedef long long ll;\ntypedef unsigned int usi;\nconst int X[] = {-1, 1, 0, 0};\nconst int Y[] = {0, 0, -1, 1};\nconst int N = 22;\nconst int T = 8;\nconst int H = 8 * 200 + 2;\nbool use[H + 3][N][N][1<<8];\nint n, m, c[T];\nchar a[N][N];\nint cntob, good, num[N][N], cstmask[1<<8];\nbool check(int x, int y)\n{\n return x >= 0 && x < n && y >= 0 && y < m && num[x][y] == -1;\n}\nvoid relax(int h, int x, int y, usi ms)\n{\n use[h][x][y][ms] = true;\n}\nll vect(int ax, int ay, int bx, int by)\n{\n return 1LL * ax * by - 1LL * ay * bx;\n}\nconst db EPS = 1e-7;\nbool isinter(int ax, int ay, int bx, int by, int cx, int cy, int d2x, int d2y)\n{\n int d1x = bx - ax, d1y = by - ay;\n ll vc1 = vect(cx - ax, cy - ay, d2x, d2y);\n ll vc2 = vect(cx - ax, cy - ay, d1x, d1y);\n ll cp = vect(d1x, d1y, d2x, d2y);\n //cout << d1x << \" \" << d1y << \" \" << d2x << \" \" << d2y << endl;\n db t1 = vc1 * 1.0 / cp;\n db t2 = vc2 * 1.0 / cp;\n assert(cp != 0);\n //cout << (vc1 && vc1 <= cp && 0 <= vc2) << endl;\n return 0 <= t1 && t1 <= 1.0 + EPS && 0 <= t2;\n}\n\npair lstob[T], lch[T];\n\nint main()\n{\n srand(time(NULL));\n int sx, sy;\n cin >> n >> m;\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < m; ++j)\n {\n cin >> a[i][j];\n if (isdigit(a[i][j]) || a[i][j] == 'B') cntob++;\n if (a[i][j] == 'S')\n {\n sx = i;\n sy = j;\n }\n good += '0' <= a[i][j] && a[i][j] <= '9';\n }\n for (int i = 0; i < good; ++i) cin >> c[i];\n for (int i = good; i < cntob; ++i) c[i] = -3000;\n\n int cpgood = good;\n memset(num, -1, sizeof num);\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < m; ++j)\n if (a[i][j] == '#') num[i][j] = -2;\n else if (isdigit(a[i][j]))\n num[i][j] = a[i][j] - '0' - 1;\n else if (a[i][j] == 'B')\n num[i][j] = good++;\n\n\n good = cpgood;\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < m; ++j)\n if (num[i][j] >= 0) lstob[num[i][j]] = mp(i, j);\n for (int i = 0; i < cntob; ++i)\n lch[i] = mp(rand(), rand());\n\n use[0][sx][sy][0] = true;\n int tot = 1<>j)&1;\n if (has) continue;\n int cr = 0;\n for (int j = 0; j < good; ++j)\n if ((ms>>j)&1) cr += c[j];\n for (int h = 0; h <= H; ++h)\n if (use[h][sx][sy][ms])\n ans = max(ans, cr - h);\n //if (ans == 380)\n }\n cout << ans;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b65078e6b812fc97eb1189a706bf5676", "src_uid": "624a0d6cf305fcf67d3f1cdc1c5fef8d", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int MAX_N = 22+5;\n\nint n;\nint a[MAX_N];\nint b[MAX_N];\nset s;\n\nint main(){\n\tcin>>n;\n\tfor(int i=0;i>a[i];\n\t\ts.insert(a[i]);\n\t}\n\tif(n == 1){\n\t\tcout<=1 ; offset--){\n\t\tfor(int i=0;i \n#include \n#include \n#include \n\nint comp(const void *a, const void *b) {\n\treturn *(int *)a - *(int *)b;\n}\n\nint min(int a, int b) { \n\treturn a < b ? a : b; \n} \n\nint n, m, a, b;\nint main() { \n\t//freopen(\"input.txt\", \"r\", stdin); \n\t//freopen(\"output.txt\", \"w\", stdout); \n\tscanf(\"%d%d%d%d\", &n, &m, &a, &b);\n\tif (a % m == 1 && (b % m == 0 || b == n)) {\n\t\tprintf(\"1\");\n\t\treturn 0; \n\t}\n\tif (((a - 1) / m == (b - 1) / m) || m == 1) {\n\t\tprintf(\"1\");\n\t\treturn 0; \n\t}\n\tif (a % m == 1 || b % m == 0 || b == n) {\n\t\tprintf(\"2\");\n\t\treturn 0; \n\t}\n\tif ((a % m - 1 == (b % m)) || (a % m == 0 && (b + 1) % m == 0) || (m == 2)) {\n\t\tprintf(\"2\");\n\t\treturn 0; \n\t}\n\tint x = 0;\n\tfor (int i = a; i < b; i++)\n\t\tif (i % m == 0)\n\t\t\tx++;\n\tif (x < 2) {\n\t\tprintf(\"2\");\n\t\treturn 0; \n\t}\n\tprintf(\"3\");\n\treturn 0; \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dc045c56a7ecb30a24bab890f48e0273", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef _DEPRECATION_DISABLE /* One time only */\n#define _DEPRECATION_DISABLE /* Disable deprecation true */\n#if (_MSC_VER >= 1400) /* Check version */\n#pragma warning(disable: 4996) /* Disable deprecation */\n#endif /* #if defined(NMEA_WIN) && (_MSC_VER >= 1400) */\n#endif /* #ifndef _DEPRECATION_DISABLE */\nusing namespace std;\n#define all(x) (x).begin(), (x).end()\n#define pb push_back\n#define pb push_back\ntypedef vector vi;\n\n\n#define all(x) (x).begin(), (x).end()\n#define pb push_back\n#define pb push_back\ntypedef vector vi;\n\ntemplate\nTA mins(TA a, TA b)\n{\n\treturn a < b ? a : b;\n}\ntemplate \nint bsearch(T *arr, int size, T value)\n{\n\tint l = 0;\n\tint r = size;\n\twhile (l <= r)\n\t{\n\t\tint mid = l + (r - l) / 2;\n\t\tif (arr[mid] == value)\n\t\t\treturn 1;\n\t\tif (arr[mid] < value)\n\t\t\tl = ++mid;\n\t\tif (arr[mid] > value)\n\t\t\tr = --mid;\n\t}\n\treturn -1;\n}\n\nclass X {\npublic:\n\tint v;\n\tX(void) :v(0.345436){}\n\tX(const X&){}\n\tX(INT a) :v(a){}\n\tfriend const X operator++(X& i, int);\n\tfriend const X operator--(X& i);\n\tfriend bool operator==(const X& i, const X&l);\n};\nbool operator==(const X& i, const X&l)\n{\n\n\treturn i.v == l.v;\n}\nconst X operator++(X& i, int){\n\tX oldValue(i.v);\n\ti.v++;\n\treturn oldValue;\n}\nconst X operator--(X& i) {\n\ti.v--;\n\treturn i;\n}\n\nint Prime(unsigned long a)\n{\n\tunsigned long i, j, bound;\n\tif (a == 0 || a == 1)\n\t\treturn 0;\n\tif (a == 2 || a == 3 || a == 5)\n\t\treturn 1;\n\tif (a % 2 == 0 || a % 3 == 0 || a % 5 == 0)\n\t\treturn 0;\n\tbound = sqrt((double)a);\n\ti = 7; j = 11;\n\twhile (j <= bound && a%i && a%j)\n\t{\n\t\ti += 6; j += 6;\n\t}\n\tif (j <= bound || i <= bound && a%i == 0)\n\t\treturn 0;\n\treturn 1;\n}\nlong long bin_pow(int a, int b)\n{\n\tif (b == 0)\n\t\treturn 1;\n\tif (b % 2 == 0)\n\t{\n\t\tlong long ans = bin_pow(a, b / 2);\n\t\treturn (ans*ans);\n\t}\n\telse\n\t{\n\t\treturn bin_pow(a, b - 1)*a;\n\t}\n\n}\n\nint GR[12345][12345] = { 0, 0 };\nint distance1[111111];\nint count1, index1, i1, u1;\nbool visited1[11111];\n\nvoid Dijkstra(int st, const int V)\n{\n\tfor (i1 = 1; i1 <= V; i1++)\n\t{\n\t\tdistance1[i1] = INT_MAX; visited1[i1] = false;\n\t}\n\tdistance1[st] = 0;\n\tqueueqii;\n\tqii.push(st);\n\twhile (!qii.empty()){\n\n\t\tu1 = qii.front();\n\t\tqii.pop();\n\t\tvisited1[u1] = true;\n\t\tfor (i1 = 1; i1 <= V; i1++){\n\t\t\tif (!visited1[i1] && GR[u1][i1] && distance1[u1] + GR[u1][i1] < distance1[i1]){\n\t\t\t\tdistance1[i1] = distance1[u1] + GR[u1][i1];\n\t\t\t\tqii.push(i1);\n\t\t\t}\n\t\t}\n\t}\n\n}\n\n\nint main()\n{\n\tint n, m;\n\tcin >> n;\n\n\tcout << bin_pow(n-2,2);\n\t\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b3b2fa8969a8bf3bc4f2d1f09810eff5", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "//Aleksander \u0141ukasiewicz\n#include\nusing namespace std;\n\n#define fru(j,n) for(int j=0; j<(n); ++j)\n#define tr(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)\n#define x first\n#define y second\n#define pb push_back\n#define mp make_pair\n#define ALL(G) (G).begin(),(G).end()\n\ntypedef long long LL;\ntypedef pair PII;\ntypedef vector VI;\n\nconst int INF = 1000000009;\n\nconst int MAXN = 300*1000;\n\nint n, m;\nvector graph[2][MAXN + 3];\nint deg[3][MAXN + 3];\nbool important[MAXN + 3];\nbool semi[MAXN + 3], compromise[MAXN + 3];\nvector cand[MAXN + 3];\nvector V;\n\nvoid TopSort(){\n queue Q;\n for(int i=1; i<=n; i++){\n if(deg[2][i] == 0)\n Q.push(i);\n }\n \n while(!Q.empty()){\n int v = Q.front();\n Q.pop();\n \n V.pb(v);\n for(auto u : graph[0][v]){\n deg[2][u]--;\n if(deg[2][u] == 0)\n Q.push(u);\n }\n }\n}\n\nvoid Solve(int ind){\n set S;\n for(int i=1; i<=n; i++){\n if(deg[ind][i] == 0)\n S.insert(i);\n }\n \n for(int i=0; i 0)\n important[v] = false;\n if(S.size() == 1){\n int u = *(S.begin());\n bool esc = false;\n for(auto z : graph[ind][u])\n if(deg[ind][z] == 1){\n esc = true;\n break;\n }\n if(!esc)\n cand[v].pb(u);\n else\n compromise[v] = true;\n }\n if(S.size() > 1)\n compromise[v] = true;\n \n for(auto u : graph[ind][v]){\n deg[ind][u]--;\n if(deg[ind][u] == 0)\n S.insert(u);\n }\n }\n}\n\nint main(){\n scanf(\"%d %d\", &n, &m);\n for(int i=0; i\n#include \nusing namespace std;\n\nconst int maxn=100;\nchar a[maxn];\nint b[maxn];\n\nmain()\n{\n int s=0;\n cin>>a;\n for(int i=0;i64 && b[i]<91)\n {\n s=s+1;\n }\n }\n for(int i=0;i1)\n {\n if(b[i]>64 && b[i]<91)\n {\n a[i]=b[i]+32;\n }\n }\n if(s<2)\n {\n if(b[i]>96 && b[i]<123)\n {\n a[i]=b[i]-32;\n }\n }\n }\n\n cout<\n\nusing namespace std;\n\nint main()\n{\n\n int n;\n bool w;\n string a;\n while(1)\n {\n cin>>a;\n cin>>n;\n string arr[n];\n for(int i = 0;i < n;i++)\n {\n cin>>arr[i];\n }\n \n for(int i =0;i < n;i++)\n {\n if (a[0] == arr[i][1])\n {\n for(int i = 0;i < n;i++)\n {\n if (a[1] == arr[i][0])\n {\n w = true;\n cout<<\"YES\"<\nusing namespace std;\n\nint main()\n{\n int n,i,j,m,c,a,f=0;\n cin >> n>>m;\n vectorbk;\n vectorfr;\n for(i=1;i<=n;i++)\n {\n if(f==0)\n {\n if(i==m)\n {\n f=1;\n }\n else\n {\n bk.push_back(i);\n }\n }\n else if(f==1)\n {\n fr.push_back(i);\n }\n\n }\n if(bk.size()>fr.size())\n {\n if(bk.size()>1){\n cout<1){\n cout<\nusing namespace std;\n\n#define umap unordered_map \n#define uset unordered_set\n#define NULL_VAL -1\n#define EXISTS(m, a) (m.find(a) != m.end())\n#define SET_SAFE(m, condition, key, value, default) m[key] = ((condition) ? (value) : (default))\n#define SET_IF_NOT_EXISTS(m, key, value, default) m[key] = SET_SAFE(m, EXISTS(m, key), key, value, default)\n#define GET_IF_EXISTS(m, a) (EXISTS(m, a) ? m[(a)] : NULL_VAL)\n#define T ull t; cin>>t; while(t--)\n#define PRINT_ARR(A, m, n) for(ull i=(m); i<(n); i++){ cout<>n;\n\tull A[n-9];\n\t\n\tif(n<10){\n\t\tcout<<1;\n\t}\n\telse{\n\t\tA[0] = 2;\n\t\tfor(int i=11; i<=n; i++){\n\t\t\tull a = i;\n\t\t\tull min = i;\n\t\t\tA[i-10] = i;\n\t\t\twhile(a!=0){\n\t\t\t\tif(A[i-(a%10)-10]+1 < min){\n\t\t\t\t\tmin = A[i-(a%10)-10]+1;\n\t\t\t\t}\n\t\t\t\ta/=10;\n\t\t\t}\n\t\t\t\n\t\t\tA[i-10] = min;\n\t\t}\n\t\t//PRINT_ARR(A, 0, n-10);\n\t\tcout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define ll long long\n#define ull unsigned long long\n#define mp make_pair\n#define pb push_back\n#define maxn 300005\n#define mod 1E9 + 7;\n\nconst int INF = 1E9;\n\nbool check(int n){\n while (n > 0){\n if (n % 10 == 4 || n % 10 == 7){\n n /= 10;\n }\n else\n return false;\n }\n return true;\n}\n\nint main(){\n\n int n;\n cin >> n;\n\n int ans = 0;\n for (int i = 1; i <= n; i++){\n if (check(i))\n ans++;\n }\n\n cout << ans;\n\n //system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e7cd9bcca969a4ee8e8afdd8fae593d2", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int maxn = 105;\nchar str[maxn];\nint a[maxn];\nint main()\n{\n int k;\n while(scanf(\"%d\",&k))\n {\n memset(a,0,sizeof(a));\n scanf(\"%s\",str);\n int l = 0;\n int flag = 0;\n for(int i = 0; i < k; i++)\n {\n if(str[i] == 'B')\n {\n flag = 1;\n a[l]++;\n }\n if(str[i] == 'W' && flag)\n l++;\n\n }\n\n if(flag && l == 0) {printf(\"1\\n%d\\n\",a[0]);continue;}\n if(!flag) {printf(\"0\\n\");continue;}\n printf(\"%d\\n\",l);\n for(int i = 0; i <= l; i++)\n {\n if(i && a[i]!= 0) printf(\" \");\n if(a[i]!= 0)\n printf(\"%d\",a[i]);\n }\n cout << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b33505952cd5777f61b35a2bac82a6ce", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#pragma warning(disable:4996)\n#pragma GCC optimize(3)\n\ntemplate T min(T x, T y)\n{\n\treturn x < y ? x : y;\n}\ntemplate T max(T x, T y)\n{\n\treturn x > y ? x : y;\n};\n\nconst long long mod = 1000000007;\nconst int MAXN = 1000005;\n\nlong long qpow(long long x, int y)\n{\n\tif (!y)\n\t\treturn 1;\n\tlong long t = qpow(x, y / 2);\n\treturn t*t % mod * (y & 1 ? x : 1) % mod;\n}\n\nint n, m;\nlong long f[MAXN], temp[MAXN];\n\nvoid test(int N)\n{\n\tlong long t = 1;\n\tfor (int i = 3; i <= N; i++)\n\t{\n\t\tt = t*(i - 1) % mod;\n\t\tf[i] = t*(i - 2) * qpow(i - 1, (int)mod - 2) + f[i - 1];\n\t\tf[i] %= mod;\n\t}\n\tf[N - 1] = f[N];\n\tfor (int i = 2; i < N; i++)\n\t\tf[N - i] = (f[N - i + 1] - qpow(2, i - 2)) % mod;\n//\tfor (int i = 1; i <= N; i++)\n//\t\tprintf(\"%lld%c\", (f[i] + mod) % mod, i == N ? '\\n' : ' ');\n\tlong long ans = 0;\n\tfor (int i = 1; i <= N; i++)\n\t\tans += f[i], ans %= mod;\n\tprintf(\"%lld\\n\", (ans + mod) % mod);\n}\n\nint main()\n{\n\tscanf(\"%d\", &n);\n\ttest(n);\n\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d039db394c4db292e04432d067316ff3", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \"stdio.h\"\n\nusing namespace std;\n\ntypedef vector> graph;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef short int si;\ntypedef unsigned short int usi;\ntypedef vector fc;\ntypedef vector> factorization;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vch;\ntypedef vector vs;\n\nvl fib;\n\nvi prime_numbers = {};\n\nvoid f() {\n\tfib.push_back(1);\n\tfib.push_back(2);\n\tfor (int i = 2; i < 45; i++) {\n\t\tfib.push_back(fib[i - 1] + fib[i - 2]);\n\t}\n}\n\nvoid fc_write(fc a) {\n\tfor (int i = a.size() - 1; i >= 0; i--) {\n\t\tif (a[i]) cout << 1;\n\t\telse cout << 0;\n\t}\n}\n\nfc ll_to_fib(ll n) {\n\tif (n == 0) {\n\t\tfc a;\n\t\ta.push_back(0);\n\t\treturn a;\n\t}\n\tif (n == 1) {\n\t\tfc a;\n\t\ta.push_back(1);\n\t\treturn a;\n\t}\n\tint k;\n\tfor (int i = 0; fib[i] <= n; i++) {\n\t\tk = i;\n\t}\n\tfc a(k + 1);\n\ta[k] = 1;\n\tfc b = ll_to_fib(n - fib[k]);\n\t//fc_write(b); cout << endl;\n\tfor (int i = 0; i < b.size(); i++) {\n\t\ta[i] = b[i];\n\t}\n\treturn a;\n}\n\null GCD(ull a, ull b) {\n\treturn (a == 0 ? b : GCD(b % a, a));\n}\n\null LCM(ull a, ull b) {\n\treturn (a / GCD(a, b)) * b;\n}\n\nll exponentiation(ll a, int b) {\n\tll k = 1;\n\tif (b >= 0)\n\t\tfor (int i = 0; i < b; i++) {\n\t\t\tk *= a;\n\t\t}\n\treturn k;\n}\n\nll concatenation(ll a, ll b) {\n\treturn stoi(to_string(a) + to_string(b));\n}\n\n// \u043a\u043b\u0430\u0441\u0441\u044b\n\n\n\nclass FenwickTree {\npublic:\n\n\tint magic(int i) {\n\t\treturn i&-i;\n\t}\n\n\tvector a;\n\tvector t;\n\n\tll get(int i) {\n\t\tll res = 0;\n\t\tfor (; i > 0; i -= magic(i)) {\n\t\t\tres += t[i];\n\t\t}\n\t\treturn res;\n\t}\n\n\tll get(int start, int end) {\n\t\treturn get(end + 1) - get(start);\n\t}\n\n\tvoid update(int i, ll delta) {\n\t\tfor (; i < t.size(); i += magic(i)) {\n\t\t\tt[i] += delta;\n\t\t}\n\t}\n\n\tvoid set(int index, int x) {\n\t\tint delta = x - a[index];\n\t\ta[index] = x;\n\t\tupdate(index + 1, delta);\n\t}\n\n\tFenwickTree(vector oa)\n\t\t: t(oa.size() + 1, 0)\n\t{\n\t\ta = oa;\n\t\tfor (int i = 0; i < oa.size(); i++) {\n\t\t\tupdate(i + 1, a[i]);\n\t\t}\n\t}\n\n};\n\nclass Q {\nprivate:\n\n\tll nominator;\n\tull denominator;\n\tll integer = 0, residue;\n\tvector non_period, period, decimal;\n\tbool defined, minus;\n\n\tvoid normalize() {\n\t\tif (denominator == 0) {\n\t\t\tdefined = 0;\n\t\t}\n\t\telse {\n\t\t\tdefined = 1;\n\t\t\tull n = GCD(abs(nominator), denominator);\n\t\t\tnominator /= (ll)n;\n\t\t\tdenominator /= n;\n\t\t\tinteger = nominator / (ll)denominator;\n\t\t\tresidue = abs(nominator) % (ll)denominator;\n\t\t\tif (nominator < 0) minus = 1;\n\t\t\telse minus = 0;\n\t\t}\n\t}\n\tvoid fraction_make(ll nom, ll den) {\n\t\tif (den < 0) {\n\t\t\tnom *= -1;\n\t\t\tden *= -1;\n\t\t}\n\t\tnominator = nom;\n\t\tdenominator = den;\n\t\tnormalize();\n\t}\n\tvoid fraction_to_periodic() {\n\t\tint two = 0, five = 0;\n\t\tint k = denominator;\n\t\twhile (k % 2 == 0) {\n\t\t\tk /= 2;\n\t\t\ttwo++;\n\t\t}\n\t\twhile (k % 5 == 0) {\n\t\t\tk /= 5;\n\t\t\tfive++;\n\t\t}\n\t\tint r = abs(nominator) % denominator;\n\t\tfor (int i = 0; i < max(two, five); i++) {\n\t\t\tr *= 10;\n\t\t\tnon_period.push_back(r / denominator);\n\t\t\tr %= denominator;\n\t\t}\n\t\tint l = 0;\n\t\tll nine = 0;\n\t\tif (k != 0) do {\n\t\t\tnine = (nine * 10 + 9) % k;\n\t\t\tl++;\n\t\t} while (nine % k != 0);\n\t\tif (k > 1) for (int i = max(two, five); i < l + max(two, five); i++) {\n\t\t\tr *= 10;\n\t\t\tperiod.push_back(r / denominator);\n\t\t\tr %= denominator;\n\t\t}\n\t}\n\tvoid fraction_to_decimal(int length) {\n\t\tint r = abs(nominator) % denominator;\n\t\tfor (int i = 0; i < length; i++) {\n\t\t\tr *= 10;\n\t\t\tdecimal.push_back(r / denominator);\n\t\t\tr %= denominator;\n\t\t}\n\t}\n\tstring read_string_gl(char s = '\\n') {\n\t\tstring a;\n\t\tgetline(cin, a, s);\n\t\treturn a;\n\t}\n\npublic:\n\t\n\tbool operator == (Q a) {\n\t\treturn (nominator == a.nominator && denominator == a.denominator);\n\t}\n\tbool operator != (Q a) {\n\t\treturn !(*this == a);\n\t}\n\t\n\n\tQ operator + (Q &a) {\n\t\treturn Q(nominator*(ll)a.denominator + a.nominator*(ll)denominator, denominator*a.denominator);\n\t}\n\tQ operator + (ll &a) {\n\t\treturn Q(nominator + denominator*a, denominator);\n\t}\n\tQ operator - (Q &a) {\n\t\treturn Q(nominator*a.denominator - a.nominator*denominator, denominator*a.denominator);\n\t}\n\tQ operator - (ll &a) {\n\t\treturn Q(nominator - denominator*a, denominator);\n\t}\n\tQ operator * (Q &a) {\n\t\treturn Q(nominator*a.nominator, denominator*a.denominator);\n\t}\n\tQ operator * (ll &a) {\n\t\treturn Q(a*nominator, denominator);\n\t}\n\tQ operator / (Q &a) {\n\t\treturn Q(nominator*a.denominator, denominator*a.nominator);\n\t}\n\tQ operator / (ll &a) {\n\t\treturn Q(nominator, denominator*a);\n\t}\n\tQ operator ^ (ll &exponent) {\n\t\tint nominator0 = 1, denominator0 = 1;\n\t\tif (exponent > 0) {\n\t\t\tfor (int i = 0; i < exponent; i++) {\n\t\t\t\tnominator0 *= nominator;\n\t\t\t\tdenominator0 *= denominator;\n\t\t\t}\n\t\t}\n\t\tif (exponent == 0) {\n\t\t\tnominator = denominator = 1;\n\t\t}\n\t\tif (exponent < 0) {\n\t\t\tfor (int i = 0; i < -exponent; i++) {\n\t\t\t\tdenominator0 *= nominator;\n\t\t\t\tnominator0 *= denominator;\n\t\t\t}\n\t\t}\n\t\tQ a(nominator0, denominator0);\n\t\treturn a;\n\t}\n\n\tQ read_regular(string input = \"\") {\n\t\tset dec = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };\n\t\tchar n;\n\t\tll integer = 0, resideue = 0, denominator = 1, x = 0;\n\t\tbool minus = 0;\n\t\tqueue q;\n\t\tstring s = read_string_gl();\n\t\tif (s[0] == '-') {\n\t\t\tminus = 1;\n\t\t}\n\t\tfor (int i = (minus ? 1 : 0); i < s.size(); i++) {\n\t\t\tif (dec.count(s[i])) {\n\t\t\t\tx = 10 * x + (s[i] - '0');\n\t\t\t}\n\t\t\telse if (dec.count(s[i - 1])) {\n\t\t\t\tq.push(x);\n\t\t\t\tx = 0;\n\t\t\t}\n\t\t\tif (i + 1 == s.size()) {\n\t\t\t\tq.push(x);\n\t\t\t\tx = 0;\n\t\t\t}\n\t\t}\n\t\tswitch (q.size()) {\n\t\tcase 1:\n\t\t\tinteger = q.front();\n\t\t\tq.pop();\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tresideue = q.front();\n\t\t\tq.pop();\n\t\t\tdenominator = q.front();\n\t\t\tq.pop();\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tinteger = q.front();\n\t\t\tq.pop();\n\t\t\tresideue = q.front();\n\t\t\tq.pop();\n\t\t\tdenominator = q.front();\n\t\t\tq.pop();\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\tif (0 == integer) {\n\t\t\tQ a(resideue*(minus ? -1 : 1), denominator);\n\t\t\treturn a;\n\t\t}\n\t\tQ a(integer *(minus ? -1 : 1), resideue, denominator);\n\t\treturn a;\n\t}\n\n\tvoid write() {\n\t\tif (!defined) cout << \"undefined\";\n\t\telse if (nominator != 0) {\n\t\t\tcout << nominator;\n\t\t\tif (denominator != 1) cout << '/' << denominator;\n\t\t}\n\t\telse cout << 0;\n\t}\n\tvoid write_regular() {\n\t\tif (!defined) cout << \"undefined\";\n\t\telse {\n\t\t\tif (integer == 0 && minus) cout << '-';\n\t\t\tif (residue == 0) {\n\t\t\t\tcout << integer;\n\t\t\t}\n\t\t\telse if (integer == 0) {\n\t\t\t\tcout << residue << \"/\" << denominator;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcout << integer << \" \" << residue << \"/\" << denominator;\n\t\t\t}\n\t\t}\n\t}\n\tvoid write_periodic() {\n\t\tif (!defined) cout << \"undefined\";\n\t\telse {\n\t\t\tfraction_to_periodic();\n\t\t\tif (integer == 0 && minus) cout << '-';\n\t\t\tcout << integer;\n\t\t\tif (non_period.size() + period.size() != 0) cout << ',';\n\t\t\tfor (int i = 0; i < non_period.size(); i++) {\n\t\t\t\tcout << non_period[i];\n\t\t\t}\n\t\t\tif (period.size() > 0) {\n\t\t\t\tcout << '(';\n\t\t\t\tfor (int i = 0; i < period.size(); i++) {\n\t\t\t\t\tcout << period[i];\n\t\t\t\t}\n\t\t\t\tcout << ')';\n\t\t\t}\n\t\t}\n\t}\n\tvoid write_decimal(int length) {\n\t\tif (!defined) cout << \"undefined\";\n\t\telse {\n\t\t\tfraction_to_decimal(length);\n\t\t\tif (integer == 0 && minus) cout << '-';\n\t\t\tcout << integer;\n\t\t\tif (decimal.size() > 0) cout << ',';\n\t\t\tfor (int i = 0; i < decimal.size(); i++) {\n\t\t\t\tcout << decimal[i];\n\t\t\t}\n\t\t}\n\t}\n\n\tstring to_compare() {\n\t\treturn (minus ? \"-\" : \"\") + to_string(abs(nominator)) + \"/\" + to_string(denominator);\n\t}\n\n\tQ()\n\t{\n\t\tfraction_make(0, 1);\n\t}\n\tQ(ll nom, ll den)\n\t{\n\t\tfraction_make(nom, den);\n\t}\n\tQ(ll i, ll r, ull d)\n\t{\n\t\tif (i < 0) {\n\t\t\tminus = 1;\n\t\t}\n\t\tfraction_make((abs(i)*(ll)d + r)*(minus ? -1 : 1), d);\n\t}\n\n};\n\n// \u0432\u0432\u043e\u0434\n\nint read_int() {\n\tint a;\n\tcin >> a;\n\treturn a;\n}\n\nlong double read_double() {\n\tdouble a;\n\tcin >> a;\n\treturn a;\n}\n\nll read_ll() {\n\tll a;\n\tcin >> a;\n\treturn a;\n}\n\nchar read_char() {\n\tchar a;\n\tcin >> a;\n\treturn a;\n}\n\nstring read_string() {\n\tstring a;\n\tcin >> a;\n\treturn a;\n}\n\nstring read_string_gl(char s = '\\n') {\n\tstring a;\n\tgetline(cin, a, s);\n\treturn a;\n}\n\nstring read_text() {\n\tstring a, s = \"\";\n\twhile (getline(cin, a)) {\n\t\ts += a;\n\t}\n\treturn s;\n}\n\ngraph read_graph(int m) {\n\tgraph g;\n\tint a, b;\n\tfor (int i = 0; i < m; i++) {\n\t\ta = read_int();\n\t\tb = read_int();\n\t\tg[a].push_back(b);\n\t\tg[b].push_back(a);\n\t}\n\treturn g;\n}\n\nQ read_fraction_regular() {\n\tstring s = read_string_gl();\n\tstack numbers;\n\tbool minus = ('-' == s[0] ? 1 : 0);\n\tint x = 0;\n\tfor (int i = (minus ? 1 : 0); i < s.size(); i++) {\n\t\tif ('0' <= s[i] && s[i] <= '9') {\n\t\t\tx = x * 10 + (s[i] - '0');\n\t\t}\n\t\telse if ('0' <= s[i - 1] && s[i - 1] <= '9') {\n\t\t\tnumbers.push(x);\n\t\t\tx = 0;\n\t\t}\n\t\tif (i + 1 == s.size()) {\n\t\t\tnumbers.push(x);\n\t\t\tx = 0;\n\t\t}\n\t}\n\tswitch (numbers.size())\n\t{\n\tcase 1:\n\t{\n\t\tQ a((minus ? -1 : 1)*numbers.top(), 1);\n\t\treturn a;\n\t}\n\tcase 2:\n\t{\n\t\tint den = numbers.top();\n\t\tnumbers.pop();\n\t\tQ a((minus ? -1 : 1)*numbers.top(), den);\n\t\treturn a;\n\t}\n\tcase 3:\n\t{\n\t\tint den = numbers.top();\n\t\tnumbers.pop();\n\t\tint red = numbers.top();\n\t\tnumbers.pop();\n\t\tQ a((minus ? -1 : 1)*numbers.top(), red, den);\n\t\treturn a;\n\t}\n\t}\n}\n\n//\n\nstring removes_spaces_from_the_ends(string s) {\n\twhile (s[0] == ' ') {\n\t\ts.erase(0, 1);\n\t}\n\twhile (s[s.length() - 1] == ' ') {\n\t\ts.erase(s.length() - 1, 1);\n\t}\n\treturn s;\n}\n\nvoid time() {\n\twhile (0 == 0) {\n\t\tstring m = read_string();\n\t}\n}\n\nint main() {\n\t//freopen(\"rsq.in\", \"r\", stdin);\n\t//freopen(\"rsq.out\", \"w\", stdout);\n\tios_base::sync_with_stdio(NULL);\n\tcin.tie(0);\n\tcout.tie(0);\n\n\tint a, b;\n\tcin >> a >> b;\n\tif (a + 1 == b) {\n\t\tcout << a << ' ' << b;\n\t}\n\telse if (a == b) {\n\t\tcout << 10 * a << ' ' << 10 * b + 1;\n\t}\n\telse if (a + 1 == 10 * b) {\n\t\tcout << a << ' ' << 10 * b;\n\t}\n\telse {\n\t\tcout << -1;\n\t}\n\ttime();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4e0ad85fcc094ad446a8efb743cdd142", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nmain()\n{\n int n,c=0; cin >>n;\n string s; cin>>s;\n for(int i=0;i\n#include \nusing namespace std;\nint main()\n{\n\tt:\n\tint x,artsay=0,eksay=0;\n\tcin>>x;\n\tchar d[x];\n\tfor(int c=0;c>d[c];\n\t}\n\tfor(int a=0;aartsay)\n\t\t{\n\t\t\tcout<<0;\n\t\t}\n\t\telse{\n\t\t\tcout<\n#include \n#include \n\nint main() \n\n{\nusing namespace std; \nint n;\nint diff=0;\nint consdiff=100;\ncin>>n;\nint ARR[100];\nfor(int i=0;i>ARR[i];\n\t}\nfor(int i=0;idiff )\n\t\t{ diff=(ARR[i+1]-ARR[i]);\n\t\t}\n\t}\n//cout<consdiff)\n\t{cout<\n#include\n#include\nusing namespace std;\nchar n[1000000005];\nint main()\n{\n int i,len,b=1,c=0;\n scanf(\"%s\",n);\n len=strlen(n);\n for(i=0; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)\n#define pause system(\"pause\")\nint main()\n{\n\tint a, b, c, d;\n\tstack st;\n\tcin >> a >> b >> c >> d;\n\tvector s;\n\tfor (int i = 0; i < a; ++i)\n\t{\n\t\ts.push_back('(');\n\t\ts.push_back('(');\n\t}\n\tfor (int i = 0; i < b; ++i)\n\t{\n\t\ts.push_back(')');\n\t\ts.push_back(')');\n\t}\n\tsort(s.begin(), s.end());\n\tbool ok = 1;\n\tfor (int i = 0; i < s.size(); ++i)\n\t{\n\t\tif (s[i] == '(')\n\t\t{\n\t\t\tst.push(s[i]);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!st.empty())\n\t\t\t{\n\t\t\t\tif (st.top() == '(')\n\t\t\t\t{\n\t\t\t\t\tst.pop();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tok = 0; break;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tok = 0; break;\n\t\t\t}\n\t\t}\n\t}\n\tcout << ok;\n\t//pause;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4e896637957440c19d8dd3d37a2c50bb", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\n#define ll long long int\n#define F first\n#define S second\n#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)\n#define rep(i,in1,n) for(i=in1;i<=n;i++)\n#define repd(i,in1,n) for(i=in1;i>=n;i--)\n\n#define pf(n) printf(\"%d \",n);\n#define sf(n) scanf(\"%d\",&n)\n#define sl(n) scanf(\"%I64d\",&n)\n#define nl printf(\"\\n\")\n#define mem(arr,init) memset(arr,init,sizeof(arr))\n#define vi vector\n#define vvi vector\n\n#define sz(a) int((a).size())\n#define pb push_back\n#define all(c) (c).begin(),(c).end()\n#define present(c,x) ((c).find(x) != (c).end())\n#define cpresent(c,x) (find(all(c),x) != (c).end())\n#define mp make_pair\n#define ep emplace_back//c++11\n#define ii pair\nusing namespace std;\n\n\n\n\n\nint main()\n{\n int i,j,k,t,n,m,a,b,c,x,y,z,s;\n cin>>a>>b>>s;\n \n ll sum=a+b;\n \n \n \n if(sum<=s)\n {\n if(sum%2==1)\n {\n if(s%2==1)\n {\n cout<<\"Yes\";\n return 0;\n }\n else\n {\n cout<<\"No\";\n return 0;\n }\n }\n else\n {\n if(s%2==0)\n {\n cout<<\"Yes\";\n return 0;\n }\n else\n {\n cout<<\"No\";\n return 0;\n }\n }\n }\n if(sum==s)\n {\n cout<<\"Yes\";\n return 0;\n }\n else \n {\n /*if(sum==0)\n {\n if(s%2==0)\n {\n cout<<\"Yes\";\n return 0;\n }\n else\n {\n cout<<\"No\";\n return 0;\n }\n \n }*/\n cout<<\"No\";\n return 0;\n }\n \n \n \n\n\n\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "caa75aba7d92f4731a4f559d73ff37a4", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main() {\n int n; cin>>n; int Max=0; int bien;\n vector a;\n cin>>bien; a.push_back(bien);\n if(a[0]>15) Max=15;\n for(int i=1; i>bien; a.push_back(bien);\n if(a[i]-a[i-1]>15) {\n Max=a[i-1]+15;\n }\n }\n if(Max) cout<=90) {\n cout<<90;\n }\n else {\n cout<\n#define rep(i,k,n) for(int i=k;i<=n;i++)\n#define rep2(i,k,n) for(int i=k;i>=n;i--)\nusing namespace std;\nvoid sc(int& x){x=0;char c=getchar();while(c>'9' || c<'0')c=getchar();\nfor(;c>='0' && c<='9';c=getchar())x=x*10+c-'0';\n}\nconst int N=6e5+7;\nconst int mod=1e9+7;\nvoid upd(int& x,int y){x+=y;if(x>=mod)x-=mod;if(x<0)x+=mod;}\ntypedef long long ll; \nint a[N],b[N],n,len,f[2][N<<1],sz[2],num[N],now=0;\nchar s[N];\nint dvd(int x){\n\tint yv=0,cc=1e9;\n\trep2(i,len,0){\n\t\tll tmp=num[i] + yv*1e9;\n\t\tnum[i]=tmp/x;\n\t\tyv=tmp%x;\n\t}\n\twhile(!num[len])len--;\n\treturn yv;\n}\nint main(){\n\tsc(n);\n\ta[1]=1;rep(i,2,n)sc(a[i]);\n\trep(i,1,n)sc(b[i]);\n\tscanf(\"%s\",s);len=strlen(s);\n\tfor(int i=0;i*9j)upd(res,f[now^1][j]);\n\t\t\tif(j>b[i] && sz[now^1] > j-b[i]-1)upd(res,-f[now^1][j-b[i]-1]);\n\t\t\tf[now][j]=res;\n\t\t}\n\t}\n\tll need=0;rep2(i,len,0){need=need*1e9+num[i];if(need>sz[now]){puts(\"0\");return 0;}}\n\tprintf(\"%d\\n\",f[now][need]);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5a04062851a68a7b9721ed81ffe4db3d", "src_uid": "71b23bc529ee1484d9dcea84def45d53", "difficulty": 3200.0} {"lang": "GNU C++", "source_code": "#include\n#include\n\n#include\n\nusing namespace std;\nint main()\n{\n long long int n;\n cin>>n;\n\n cout<< int(log(n)/log(2)+1);\n\n\n return 0;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "07a335feb68450366346edb1ca1a3f3c", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "/*\n* this code is made by crazyacking\n* Verdict: Accepted\n* Submission Date: 2015-07-10-11.11\n* Time: 0MS\n* Memory: 137KB\n*/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define LL long long\n#define ULL unsigned long long\nusing namespace std;\n\nint main()\n{\n freopen(\"C:\\\\Users\\\\crazyacking\\\\Desktop\\\\cin.txt\",\"r\",stdin);\n// freopen(\"C:\\\\Users\\\\crazyacking\\\\Desktop\\\\cout.txt\",\"w\",stdout);\n\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n int n;\n while(cin>>n)\n {\n int a[2],b[2],c[2];\n cin>>a[0]>>a[1]>>b[0]>>b[1]>>c[0]>>c[1];\n int max_sum=a[0]+b[0]+c[0];\n int aa=a[0],bb=b[0],cc=c[0];\n int except=n-max_sum;\n// cout<0)\n cc+=except;\n cout<\n#include \n#include \nusing namespace std;\n\nint main()\n{\n\t__int64 l, r;\n\tscanf(\"%I64d %I64d\", &l, &r);\n\n\tif(l > r)\n\t{\n\t __int64 tmp = l;\n\t l = r;\n\t r = tmp;\n\t}\n\n\tif(l == r)\n\t{\n\t printf(\"0\\n\");\n\t return 0;\n\t}\n\n\tint lb[50], ll = 0;//! 20 is too small for decimal\n\tint rb[50], lr = 0;\n\tmemset(lb, 0, sizeof(lb));\n\tmemset(rb, 0, sizeof(rb));\n\tfor(__int64 x = l; x > 0; lb[ll++] = x % 2, x /= 2);\n\tll--;\n\tfor(__int64 x = r; x > 0; rb[lr++] = x % 2, x /= 2);//! type\n\t//for(__int64 x = r; x > 0; )\n //rb[lr++] = x % 2, x /= 2;\n\tlr--;\n\n\tint ptr = lr;\n\t__int64 ans = 0;\n\tfor( ; ptr > ll; ans += (__int64)1 << ptr, ptr--); //!__int64\n\n\twhile(ptr >= 0 && lb[ptr] == rb[ptr])\n ptr--;\n\n\tans += (((__int64)1 << (ptr + 1)) - 1);//!\n printf(\"%I64d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bf817a01ae70fe20e95a27b818fd24ca", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nconst int mod=1e9+7;\nconst double eps=1e-6;\nconst double pi=acos(-1);\nconst int inf=0x7fffffff;\ntypedef long long int ll;\ntypedef unsigned long long ull;\nusing namespace std;\n\nint a[50];\n\nint main()\n{\n int n,k,m;\n scanf(\"%d%d%d\",&n,&k,&m);\n int sum=0;\n for(int i=1;i<=k;i++)\n {\n scanf(\"%d\",&a[i]);\n sum+=a[i];\n }\n sort(a+1,a+1+k);\n if(m>=n*sum)\n return 0*printf(\"%d\\n\",n*(k+1));\n\n int ans1=m/sum*(k+1);\n int x=m%sum;\n for(int i=1;i<=k;i++)\n {\n x-=a[i];\n if(x<0)break;\n ans1++;\n }\n\n int ans2=0,y=m;\n for(int i=1;i<=k;i++)\n {\n if(y>=a[i]*n)\n {\n ans2+=n;\n y-=a[i]*n;\n }\n else\n {\n ans2+=y/a[i];\n break;\n }\n }\n printf(\"%d\\n\",max(ans1,ans2));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e41ff3bf538923e98612c7432be2984d", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nusing std::cout;\nusing std::cin;\nusing std::endl;\nint main()\n{\n int a,b,c;\n cin>>a>>b>>c;\n if (a+c>b)\n {\n cout<<\"NO\"<\ntypedef long long ll;\nint N,M=1e9+7,P,F[1000005],Ans;\nint main(){\n\tscanf(\"%d%d\",&N,&M),*F=1;\n\tfor (int i=1;i<=N;++i) F[i]=(ll)F[i-1]*M%P;\n\tfor (int i=!--(M<<=1),X=1;i\n#define fr(a, b, c) for(int a = b, __ = c; a < __; a++)\n#define dbg(x) cerr << \">>>>> \" << x << endl;\n#define _ << \" , \" <<\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair ii;\n\nconst int ms = int(5e6) + 100;\nconst ll inf = ll(2e18) + 200, mod = ll(1e9) + 7;\n\nchar len[ms];\nint primes[ms][18];\nchar q[ms][18];\nint ls[ms];\nll memo[ms];\n\nll f(int n);\n\nll getMin(int n, int at, int val){\n\tif(at >= len[n]){\n\t\tif(val == 1)\n\t\t\treturn inf;\n\t\treturn ll(n/val) * (ll(val) * ll(val-1))/2 + f(n / val);\n\t}\n\tint pot = 1;\n\tll ans = inf;\n\tfr(i, 0, q[n][at]+1){\n\t\tans = min(getMin(n, at+1, val * pot), ans);\n\t\tpot *= primes[n][at];\n\t}\n\treturn ans;\n}\n\nll f(int n){\n\tif(n == 1)\n\t\treturn 0;\n\tif(ls[n] == n)\n\t\treturn (ll(n) * ll(n-1))/2;\n\tif(memo[n] != -1)\n\t\treturn memo[n];\n\treturn memo[n] = getMin(n, 0, 1);\n}\n\nll fastExp(ll a, ll b){\n\ta %= mod;\n\tll r = 1;\n\tfor(;b;b>>=1, a=(a*a)%mod){\n\t\tif(b&1)\n\t\t\tr = (r*a)%mod;\n\t}\n\treturn r;\n}\n\nint main(){\n\tios::sync_with_stdio(0);\n\tfr(i, 2, ms){\n\t\tif(ls[i])\n\t\t\tcontinue;\n\t\tfor(int j = i; j < ms; j += i)\n\t\t\tls[j] = i;\n\t}\n\tfr(i, 2, ms){\n\t\tint at = i;\n\t\tint p = 0;\n\t\tprimes[i][p] = ls[i];\n\t\tq[i][p] = 1;\n\t\tat /= ls[i];\n\t\twhile(at != 1){\n\t\t\tif(ls[at] == primes[i][p]){\n\t\t\t\tq[i][p]++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\t++p;\n\t\t\t\tprimes[i][p] = ls[at];\n\t\t\t\tq[i][p] = 1;\n\t\t\t}\n\t\t\tat /= ls[at];\n\t\t}\n\t\tlen[i] = p+1;\n\t}\n\tint t, l, r;\n\tcin >> t >> l >> r;\n\tll ans = 0;\n\tmemset(memo, -1, sizeof memo);\n\tfr(i, l, r+1){\n\t\tans = (ans + fastExp(t, i-l)*(f(i)%mod))%mod;\n\t}\n\tcout << ans << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0588c91e79fe9c824b23d49b779aca8e", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b", "difficulty": 1800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define int64 long long\n#define rep(i,a,b) for (int i = a; i <= b; i++)\n#define repd(i,a,b) for (int i = a; i >= b; i--)\n#define mp make_pair \n\nusing namespace std;\n\nint n, d, a[300];\nint64 inf = 10000000000000000ll, dp[51][500001], dp1[51][500001];\n\nint main()\n{\n cin >> n >> d;\n rep(i,1,n) cin >> a[i];\n sort(a + 1, a + n + 1);\n rep(i,0,50)\n rep(j,0,500000) \n {\n dp[i][j] = inf;\n dp1[i][j] = inf;\n }\n dp[1][0] = 0;\n dp1[1][0] = 0;\n if (a[1] <= d) \n {\n dp[1][a[1]] = 1;\n repd(i,a[1],1) dp1[1][i] = 1;\n }\n rep(i,2,n)\n repd(j,500000,0)\n {\n if (j <= d)\n {\n if (j >= a[i]) dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - a[i]]);\n else dp[i][j] = dp[i - 1][j];\n if (j != 0) dp[i][j] = max(dp[i][j], 1ll);\n }\n else\n {\n if (j >= a[i]) dp[i][j] = min(dp[i - 1][j], dp1[i - 1][max(0, a[i] - d)] + dp[i - 1][j - a[i]] + 1);\n else dp[i][j] = dp[i - 1][j];\n }\n if (j == 500000) dp1[i][j] = dp[i][j];\n else dp1[i][j] = min(dp1[i][j + 1], dp[i][j]);\n }\n int ans1 = 0;\n int64 ans2 = 0;\n rep(i,0,500000)\n if (dp[n][i] != inf && i >= ans1)\n {\n if (i == ans1) ans2 = min(ans2, dp[n][i]);\n else\n {\n ans1 = i;\n ans2 = dp[n][i];\n }\n }\n cout << ans1 << \" \" << ans2;\n return 0;\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a686fb10933e5363869afb66972842e7", "src_uid": "65699ddec8d0db2f58b83a0f64de6f6f", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n int a,b,c,d;\n cin>>a>>b>>c>>d;\n if (d>c) cout<<\"Second\"<0) cout<<\"First\"<\n#define FOR(i,x,n) for(int i=x;in;i--)\n#define fi first\n#define se second\n#define SZ(x) (int)x.size()\ntypedef long long ll;\ntypedef long double lD;\nusing namespace std;\n\nint Counting[100000000];\n\nvoid Counting_Sort(int* a,int sz)\n{\n for(int i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nconst int MAX=3e5+5;\nconst int INF=0x3f3f3f3f;\ntypedef long long ll;\nusing namespace std;\nstring s;\nint f,flag;\nchar ref[5]={'a','e','i','o','u'};\nint main()\n{\n\tint i,j,k,n,m;\n\tcin>>s;\n\tfor(i=0;i\n\nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\ntypedef long long Long;\nvoid FastIO(){\n ios::sync_with_stdio(0);\n cin.tie(0);cout.tie(0);\n}\n\nconst int N = 1e5;\n\nint p, x, y;\n\nint dp[N/2];\n\nint solve(int n){\n int r = (n/50)%475;\n if (r+26==p){\n// cout << n << '\\n';\n return 0;\n }\n for (int i = 0;i < 25;i++){\n r = (r*96 + 42) % 475;\n if (r+26 == p){\n //cout << n << '\\n';\n return 0;\n }\n }\n if (dp[n])return dp[n];\n dp[n] = solve(n+100)+1;\n if (n-50 >= y)dp[n] = min(dp[n], solve(n-50));\n return dp[n];\n}\n\nint main()\n{\n FastIO();\n int tc, ca = 0;\n cin >> p >> x >> y;\n cout << solve(x) << '\\n';\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e593054570a171271f7b6b8a5755344b", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\nint n,i;\ncin>>n;\nif(n==1 || n==2)\n{\ncout<<\"-1\";\ngoto out;\n}\nelse\n{\nfor(i=2;i<=n;i++)\ncout<\nusing namespace std;\nlong long int n;\nlong long int megoldas;\nlong long int seged;\nlong long int valami;\nlong long int y;\nlong long int se;\nvector < long long int > v;\nlong long int rek(long long int x)\n{\n if (x==1) return 1;\n if (x==2) return 3;\n if (x==3) return 4;\n seged=2;\n while(2*seged<=x)\n {\n seged*=2;\n }\n if (x==seged)\n {\n return x+rek(x-1);\n }\n else{\n\n valami=rek(x-seged);\n seged=2;\n while(2*seged<=x)\n {\n seged*=2;\n }\n v.push_back(valami);\n return v[v.size()-1]+rek(seged);\n }\n}\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin>>n;\n n=n-1;\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\nconst int M=1e5+10;\ntypedef unsigned long long int longint; \nll sum,x1,x2,y11,y2;\nint main()\n{\n cin>>x1>>y11>>x2>>y2;\n ll i,j;\n sum=0;\n for(i=x1;i<=x2;i++)\n {\n \tfor(j=y11;j<=y2;j++)\n \t{\n \t\tif((i%2==0 && j%2==0)||(i%2!=0 && j%2!=0))\n \t\tsum++;\n\t\t}\n\t}\n cout<\r\n#include\r\n#include\r\n#include\r\ntypedef long long LL;\r\nusing namespace std;\r\nconst int MOD = 1e9 + 7;\r\nconst int N = 100010;\r\n/*\r\nLL C[N][21];\r\n \r\nLL frac[21];\r\nvoid init()\r\n{\r\n\tmemset(C,0,sizeof C);\r\n\tC[0][0] = 1;\r\n\tfor(int i = 1;i<=N;i++)\r\n\t{\r\n\t\tfor(int j = 0;j<=min(i,20);j++)\r\n\t\t{\r\n\t\t\tC[i][j] = (C[i-1][j] + C[i-1][j-1])%MOD;\t\r\n\t\t}\r\n\t} \r\n\tfrac[0] = 1;\r\n\tfor(int i = 1;i<=20;i++)\r\n\t\tfrac[i] = (frac[i-1] * i) % MOD;\r\n}\r\n*/\r\nLL dp[21][21];\r\nLL fastpow(int base,int ind)\r\n{\r\n\tLL ans = 1;\r\n\twhile(ind)\r\n\t{\r\n\t\tif(ind & 1) ans = (ans * base) % MOD;\r\n\t\tbase = ((LL)base * base) % MOD;\r\n\t\tind >>= 1;\r\n\t}\r\n\treturn ans;\r\n}\r\nLL frac[100010];\r\nLL calc(int k,int i);\r\nvoid init()\r\n{\r\n\tmemset(dp,0,sizeof dp);\r\n\tfrac[0] = 1;\r\n\tfor(int i = 1;i<=100000;i++)\r\n\t{\r\n\t\tfrac[i] = (frac[i-1] * i) % MOD;\r\n\t}\r\n\tfor(int i = 1;i<=20;i++)\r\n\t{\r\n\t\tfor(int j = i;j <= 20;j++)\r\n\t\t{\r\n\t\t\tcalc(j,i); \r\n\t\t}\r\n\t}\r\n}\r\nLL C(int n,int k)\r\n{\r\n\tLL rev = (fastpow(frac[k],MOD - 2) * fastpow(frac[n-k],MOD - 2))%MOD;\r\n\tLL ans = (frac[n] * rev)%MOD;\r\n\treturn ans;\r\n}\r\nLL calc(int k,int i)\r\n{\r\n\tif(dp[k][i]) return dp[k][i];\r\n\tif(k == 0 && i) return 0;\r\n\tif(i == 1)return dp[k][i] = 1;\r\n\tLL ans = 0;\r\n\tfor(int j = 1;j<=k;j++)\r\n\t{\r\n\t\tans = (ans + C(k,j) * calc(k - j,i - 1))% MOD;\r\n\t}\r\n\treturn dp[k][i] = ans;\r\n}\r\nint main(void)\r\n{\r\n\tinit();\r\n\tint t;cin>>t;\r\n\twhile(t--)\r\n\t{\r\n\t\tint n,k;\r\n\t\tcin>>n>>k;\r\n\t\tLL ans = 0;\r\n\t\tfor(int i = 1;i<=k;i++)\r\n\t\t{\r\n\t\t\tans = (ans + dp[k][i] * (LL)C(n,i)) % MOD;\r\n\t\t}\r\n\t\tcout<\n\n\nint solve(int m,int k)\n{\n\tif( m<=k)\n\t\treturn 0;\n\tfor(int i=k;i*i<=m;i++)\n\t\tif( m%i==0)\n\t\t{\n\t\t\treturn 1+m/i*solve(i,k);\n\t\t}\n\tfor(int i=k;i>1;i--)\n\t{\n\t\tif( m/i>=k&&m%i==0)\n\t\t{\n\t\t\treturn 1+i*solve(m/i,k);\n\t\t}\n\t}\n\treturn 0;\n}\nint main(int argc,char* argv[])\n{\n\tint n,m,k;\n\tscanf(\"%d%d%d\",&n,&m,&k);\n\tint y=solve(m,k);\n\ty=y*n;\n\tif(y%2==0)\n\t\tprintf(\"Marsel\\n\");\n\telse\n\t\tprintf(\"Timur\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "022de0ff027bc1e1330642fe3028e29a", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\nusing namespace std;\n\nint main()\n{\n int n;\n cin >> n;\n int arr[n+1];\n int i,j;\n for(i=0;i<=n;i++)\n {\n arr[i]=-1;\n }\n for(i=1;i<=(n/2);i++)\n {\n int k;\n cin >> k;\n arr[k]=1;\n }\n int brr[n+1];\n //brr[0]=1;\n for(i=0;i<=n;i++)\n {\n brr[i]=arr[i];\n }\n int crr[n+1];\n //crr[0]=1;\n for(i=0;i<=n;i++)\n {\n crr[i]=arr[i];\n }\n\n\n /*for(i=1;i<=n;i++)\n {\n cout << brr[i] << \" \" ;\n }\n cout << '\\n';\n\n for(i=1;i<=n;i++)\n {\n cout << crr[i] << \" \" ;\n }\n cout << '\\n';*/\n //FOR BLACK %2!=0\n int black=0;\n int white=0;\n //SHIFT ALL TO BLACK\n for(i=1;i<=n;i++)\n {\n if(i%2==0 && brr[i]==1)//if white pe present then shift to nearest black \n {\n int l,m;\n l=i;\n m=i;\n while(m>=1)\n {\n if(m%2!=0 && brr[m]!=1)//if place is empty and black then fill it\n {\n brr[m]=1;\n break;\n }\n m--;\n }\n //cout << \"m after blak \" << m << '\\n';\n while(l<=n)\n {\n \n if(l%2!=0 && brr[l]!=1)//if place is empty and black then fill it\n {\n brr[l]=1;\n break;\n }\n \n l++;\n }\n //cout << \"l after blak\" << l << '\\n';\n int a1,a2;\n a1=l-i;\n a2=i-m;\n int ans=0;\n if(m==0)\n {\n ans=a1;\n }\n else if (l==(n+1))\n {\n ans=a2;\n }\n else if(a2 <= a1 && m!=0 )\n {\n ans=a2;\n brr[l]=-1;\n }\n else if(a1 <= a2 && l!=(n+1))\n {\n ans=a1;\n brr[m]=-1;\n }\n black+=ans;\n //cout << \"ans=\" << ans << '\\n';\n //cout << \"black=\" << black << '\\n';\n }\n }\n //for white \n for(i=1;i<=n;i++)\n {\n if(i%2!=0 && crr[i]==1)//if black pe present then shift to nearest white \n {\n int l;\n int m;\n l=i;\n m=i;\n while(m>=1)\n {\n if(m%2==0 && crr[m]!=1)//if place is empty and white then fill it\n {\n crr[m]=1;\n break;\n }\n m--;\n }\n //cout << \"m after white\" << m << '\\n';\n while(l<=n)\n {\n if(l%2==0 && crr[l]!=1)//if place is empty and white then fill it\n {\n crr[l]=1;\n break;\n }\n l++;\n }\n //cout << \"l after white\" << l << '\\n';\n int a1,a2;\n a1=l-i;\n a2=i-m;\n int ans=0;\n \n if(m==0)\n {\n ans=a1;\n }\n else if (l==(n+1))\n {\n ans=a2;\n }\n else if(a2 <= a1 && m!=0 )\n {\n ans=a2;\n crr[l]=-1;\n }\n else if(a1 <= a2 && l!=(n+1))\n {\n ans=a1;\n crr[m]=-1;\n }\n \n //cout << \"ans=\" << ans << '\\n';\n white+=ans;\n \n //cout << \"white=\" << white << '\\n';\n } \n }\n \n\n if(black>white)\n {\n cout << white << '\\n';\n }\n else\n {\n cout << black << '\\n';\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aa148351af14b8cee08c0c42b98e222f", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "/*AMETHYSTS*/\n//#pragma comment(linker, \"/STACK:1000000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n//#include \n//#include \n\n#define ll long long\n#define ld double\n#define pii pair \n#define forn(i, n) for (int i = 0; i < (int)n; i++)\n#define mp make_pair\n#define ui unsigned ll\n#define pll pair \n\nusing namespace std;\n\nconst int maxn = 1 << 7;\n\nvector ed[maxn];\nvector now;\nbool used[maxn];\n\nint cnt = 0;\nint lasth = -1;\n\nvoid del(int x) {\n\twhile (!ed[x].empty() && used[ed[x].back()]) {\n\t\ted[x].pop_back();\n\t}\n}\n\nbool read(int x) {\n\tcnt++;\n\n\tif (cnt > 16) {\n\t\tcout << x << endl;\n\t\treturn true;\n\t}\n\n\tprintf(\"? %d\\n\", x);\n\tfflush(stdout);\n\ted[x].clear();\n\tnow.push_back(x);\n\tused[x] = true;\n\tint k;\n\n\tscanf(\"%d\", &k);\n\n\tif (k == 0) {\n\t\texit(0);\n\t}\n\n\ted[x].resize(k);\n\n\tfor (int i = 0; i < k; i++) {\n\t\tscanf(\"%d\", &ed[x][i]);\n\t}\n\n\trandom_shuffle(ed[x].begin(), ed[x].end());\n\n\tif (k == 2) {\n\t\tprintf(\"! %d\\n\", x);\n\t\tfflush(stdout);\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nint main() {\n\tint t;\n\n\tcin >> t;\n\n\twhile (t--) {\n\t\tlasth = -1;\n\t\tcnt = 0;\n\t\tmemset(used, 0, sizeof used);\n\t\tnow.clear();\n\t\tint h;\n\n\t\tcin >> h;\n\n\t\tif (h == 0) {\n\t\t\texit(0);\n\t\t}\n\n\t\tint n = (1 << h) - 1;\n\n\t\tif (read(rand() % n + 1)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\twhile (true) {\n\t\t\tint x = now.back();\n\n\t\t\tdel(x);\n\n\t\t\tif (!ed[x].empty()) {\n\t\t\t\tint y = ed[x].back();\n\t\t\t\ted[x].pop_back();\n\n\t\t\t\tif (read(y)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treverse(now.begin(), now.end());\n\n\t\t\t\tint x = now.back();\n\n\t\t\t\tif (!ed[x].empty()) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tint sz = (int)now.size();\n\n\t\t\t\tfor (int i = 0; i < sz / 2; i++) {\n\t\t\t\t\tnow.pop_back();\n\t\t\t\t}\n\n\t\t\t\tlasth = now.size();\n\n\t\t\t\tif (lasth == 4 && h == 7) {\n\t\t\t\t\tx = now.back();\n\n\t\t\t\t\twhile (!ed[x].empty() && used[ed[x].back()]) {\n\t\t\t\t\t\ted[x].pop_back();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ed[x].empty()) {\n\t\t\t\t\t\tthrow 1;\n\t\t\t\t\t}\n\n\t\t\t\t\tx = ed[x].back();\n\n\t\t\t\t\tread(x);\n\n\t\t\t\t\tvector a;\n\n\t\t\t\t\twhile (!ed[x].empty()) {\n\t\t\t\t\t\tif (used[ed[x].back()]) {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ta.push_back(ed[x].back());\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ted[x].pop_back();\n\t\t\t\t\t}\n\n\t\t\t\t\tread(a[0]);\n\t\t\t\t\tread(a[1]);\n\n\t\t\t\t\tvector b;\n\n\t\t\t\t\tfor (int i = 0; i < 2; i++) {\n\t\t\t\t\t\tint x = a[i];\n\n\t\t\t\t\t\twhile (!ed[x].empty()) {\n\t\t\t\t\t\t\tif (used[ed[x].back()]) {\n\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tb.push_back(ed[x].back());\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\ted[x].pop_back();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\twhile (!b.empty()) {\n\t\t\t\t\t\tif (read(b.back())) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tb.pop_back();\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "496a51dbf4b80952f6d79044163bdc43", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint n;\nint a[110];\nbool flag=false;\nvoid dfs(int i,int sum)\n{\n if(i==n+1)\n {\n if(sum%2==1)\n {\n flag=true;\n }\n }\n else if(a[i]%2==0)\n {\n return ;\n }\n else\n {\n dfs(i+1,sum+1);\n int cnt=1;\n for(int j=i+1;j<=n;j++)\n {\n cnt++;\n if(a[j]%2==1)\n {\n if(cnt%2==1)\n {\n dfs(j+1,sum+1);\n }\n }\n }\n }\n}\nint main(void)\n{\n freopen(\"C:\\\\Users\\\\YuXiaoKang\\\\Desktop\\\\test.txt\",\"r\",stdin);\n memset(a,0,sizeof(a));\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n cin>>n;\n for(int i=1;i<=n;i++)\n {\n cin>>a[i];\n }\n int i;\n for(i=1;i<=n;i++)\n {\n if(n%2==1&&a[1]%2==1&&a[1]==a[i])\n {\n\n }\n else\n {\n break;\n }\n }\n if(i==n+1)\n {\n cout <<\"Yes\"<\nusing namespace std;\n\n#define fore(i, a, b) for (int i = int(a); i < int(b); i++)\n#define forn(i, n) fore(i, 0, n)\n#define efor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)\n#define nfor(i, n) efor(i, 0, n)\n\n#define mp(x, y) make_pair(x, y)\n#define pb(x) push_back(x)\n#define all(v) (v).begin(), (v).end()\n#define sz(v) int((v).size())\n#define x first\n#define y second\n\ntemplate T abs(const T& x) { return x < 0 ? -x : x; }\ntemplate T sqr(const T& x) { return x * x; }\n\ntemplate ostream& operator<< (ostream& out, const pair& p) {\n\treturn out << \"(\" << p.x << \", \" << p.y << \")\";\n}\n\ntemplate ostream& operator<< (ostream& out, const vector& a) {\n\tout << \"[ \";\n\tforn(i, sz(a)) {\n\t\tif (i) out << \", \";\n\t\tout << a[i];\n\t}\n\treturn out << \" ]\";\n}\n\ntypedef unsigned long long li;\ntypedef long double ld;\ntypedef pair pt;\n\nld gett() {\n\treturn clock() / ld(CLOCKS_PER_SEC);\n}\n\n#ifdef TJS\n\n#endif\n\nconst int N = int(1e6) + 5;\nchar s[N];\nint q[N];\nint n, m;\n\nbool read() {\n\tif (scanf(\"%s\", s) != 1)\n\t\treturn false;\n\tassert(cin >> m);\n\tforn(i, m) {\n\t\tstatic char buf[30];\n\t\tassert(scanf(\"%s\", buf) == 1);\n\t\tint l = strlen(buf);\n\t\tq[i] = 0;\n\t\tforn(j, l)\n\t\t\tq[i] |= (1 << int(buf[j] - 'a'));\n\t}\n\treturn true;\n}\n\nint pos[26];\nint cnt[(1 << 26) + 5];\n\nvoid solve() {\n\tforn(i, 26)\n\t\tpos[i] = -1;\n\t\n\tint n = strlen(s);\n\ts[n++] = '#';\n\tforn(i, n) {\n\t\tvector vv;\n\t\tforn(j, 26)\n\t\t\tif (pos[j] != -1)\n\t\t\t\tvv.pb(mp(pos[j], j));\n\n\t\tsort(all(vv));\n\t\treverse(all(vv));\n\t\tint cmask = 0;\n\t\tfor (auto p: vv) {\n\t\t\tif (p.y == int(s[i] - 'a'))\n\t\t\t\tbreak;\n\t\t\tcmask |= (1 << p.y);\n\t\t\tcnt[cmask]++;\n\t\t}\n\n\t\tif (i < n - 1)\n\t\t\tpos[int(s[i] - 'a')] = i;\n\t}\n\n\tforn(i, m)\n\t\tprintf(\"%d\\n\", cnt[q[i]]);\n}\n\nint main() {\n#ifdef TJS\n\tassert(freopen(\"input.txt\", \"r\", stdin));\n#else\n#endif\n\tcerr << fixed << setprecision(5);\n\tcout << fixed << setprecision(10);\n\twhile (read()) {\n#ifdef TJS\n\t\tld st = gett();\n#endif\n\t\tsolve();\n#ifdef TJS\n\t\tcerr << \" == TIME : \" << gett() - st << \" == \" << endl;\n#endif\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d50a3ece22299ce31cc268e2b3c3f01f", "src_uid": "9bafcd579d38d5c3f073839ccb1c6ed3", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \nlong long a,b;\nlong long flg;\nbool vis[1000000009];\nlong long beh(long long x){\n\t\n\tif(x <= a){\n\t\tprintf(\"%I64d\\n\",x);\n\t\tfor(long long i=2;i<=(a/x);i++){\n\t\t\tif(a % (i*x) == b){\n\t\t\t\tflg++;\n\t\t\t\tvis[i*x] = true;\n\t\t\t\tprintf(\"%I64d %I64d\\n\",a,i*x);\n\t\t\t\tbeh(2*x);\n\t\n\t\t\t}\n\t\t}\t\n\t\t\n\t}\n\t\n\treturn 0;\n}\nint main (){\n\tscanf(\"%I64d %I64d\",&a,&b);\n\tlong long c3 = 0;\n\tfor(int i=1;i<=a;i++){\n\t\tif(a % i == b){\n\t\t\tflg++;\n\t\t}\n\t}\n\tprintf(\"%I64d\",flg);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "878da46066e2d8d1ffaab551962d8c61", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "//Problem: Mister B and Boring Game\n#include\n#include\nusing namespace std;\nint main()\n{\n // freopen(\"test.inp\",\"r\",stdin);\n // freopen(\"test.out\",\"w\",stdout);\n\tint a,b,len;\n\tchar c;\n\tlong l,r;\n\tcin>>a>>b>>l>>r;\n\tstring s,newstr,suffix;\n\tfor(c = 'a'; c < 'a' + a;c++)\n\t s += c;\n\tif(r >= 2*(a+b))\n\t\tif(r == l)\n\t\t{\n\t\t\tr = 2*(a+b);\n\t\t\tl = r;\n\t\t}\n\t\n\tlen = s.length();\n\tfor(int i = len; i <= r;i += a+b)\n\t{\n\t\tfor(int j = 0; j < b;j++) //turn of Mister B \n\t\t\ts += s[len - 1];\n\t\tlen = s.length();\n\t\tif(len >= r)\n\t\t\tcontinue;\n\t\tc = 'a';\n\t\tsuffix.append(s,len-a,a);\n\t\tfor(int k = 0; k < a;k++) //turn of Computer\n\t\t{\n\t\t\twhile(suffix.find(c)!=-1) c++;\n\t\t\ts += c;\n\t\t\tc++;\n\t\t}\n\t\t\t\n\t}\n\tfor(int i = l-1; i < r;i++)\n\t\tif(newstr.find(s[i]) == -1)\n\t\t\tnewstr += s[i];\n\tcout<\n#include\nusing namespace std;\n#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)\n#define ll long long\n#define pb push_back\n#define INF 1000000100\n#define MOD 1000000007\n#define mp make_pair\nconst double PI=3.141592653589793238462643383279502884197169399375105820974944;\n#define REP(i,n) for (int i = 0; i < n; i++)\n#define FOR(i,a,b) for (int i = a; i < b; i++)\n#define REPD(i,n) for (int i = n-1; i >= 0; i--)\n#define FORD(i,a,b) for (int i = a; i >= b; i--)\n#define remax(a,b) a = max(a,b)\n#define remin(a,b) a = min(a,b)\n#define all(v) v.begin(),v.end()\n#define F first\n#define S second\n#define mii map\n#define vi vector\n#define ii pair\n#define vii vector< ii >\n#define vvi vector< vector >\n#define vvii vector< vector >\n#define itr :: iterator it\n#define WL(t) while(t --)\n#define gcd(a,b) __gcd((a),(b))\n#define lcm(a,b) ((a)*(b))/gcd((a),(b))\n#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << ' '; cout << endl;\n#define debug(x) cout << x << endl;\n#define debug2(x,y) cout << x << \" \" << y << endl;\n#define debug3(x,y,z) cout << x << \" \" << y << \" \" << z << endl;\n#define LC(i) 2*(i)+1\n#define RC(i) 2*(i)+2\n#define MID(i,j) ((i)+(j))/2\n#define disparr(arr,n) for(int i=0;i<(n);i++) cout<\nll power(ll a,ll b)\n{\n if(b==1)\n return a;\n ll p=power(a,b/2);\n ll ans=p*p;\n ans%=MOD;\n if(b%2)\n ans*=a;\n ans%=MOD;\n if(ans<0)\n ans+=MOD;\n return ans;\n}\nint main()\n{\n ll x,k;\n cin>>x>>k;\n x%=MOD;\n ll coeff=power(2,k+1);\n ll ans=coeff*x;\n ans%=MOD;\n ll tmp=power(2,k)-1;\n tmp%=MOD;\n ans-=tmp;\n ans%=MOD;\n if(ans<0)\n ans+=MOD;\n cout<\r\n#define ll long long\r\n#define rep(i,m,n) for (int i=m;i<=n;i++)\r\n#define reb(i,m,n) for (int i=m;i>=n;i--)\r\n#define rv(i,vt) for (auto i:vt)\r\n#define ii pair\r\n#define vi vector\r\n#define F first\r\n#define S second\r\n#define pb push_back\r\nusing namespace std;\r\nconst ll N=1e6+5,mod=1e9+7;\r\nstring s,s1;\r\nll n,k;\r\nstring cvt (ll n){\r\n ll p=n;\r\n string f=\"\";\r\n while (p>0){\r\n f+=char(p%2+48);\r\n p/=2;\r\n }\r\n reverse(f.begin(),f.end());\r\n return f;\r\n}\r\nii cnt (string s){\r\n ii pd;\r\n ll l=0;\r\n while (s[l]=='1' && l<=s.size()-1) l++;\r\n pd.F=l;\r\n ll r=s.size()-1;\r\n if (l!=s.size()){\r\n reverse(s.begin(),s.end());\r\n l=0;\r\n while (s[l]=='1' && l<=s.size()-1) l++;\r\n pd.S=l;\r\n }\r\n else pd.S=0;\r\n return pd;\r\n}\r\nbool able (string s, string s1){\r\n ii p1=cnt(s),p2=cnt(s1);\r\n while (p1.F>n>>k;\r\ns=cvt(n);\r\ns1=cvt(k);\r\nstring s2=s;\r\ns+='1';\r\nif (able(s,s1)){\r\n cout<<\"YES\";\r\n return;\r\n}\r\nreverse(s1.begin(),s1.end());\r\nif (s1[0]!='0')\r\nif (able(s,s1)){\r\n cout<<\"YES\";\r\n return;\r\n}\r\ns=s2;\r\nwhile (s[s.size()-1]=='0') s.erase(s.size()-1,1);\r\nif (s1[0]!='0')\r\nif (able(s,s1)){\r\n cout<<\"YES\";\r\n return;\r\n}\r\nreverse(s1.begin(),s1.end());\r\nif (able(s,s1)){\r\n cout<<\"YES\";\r\n return;\r\n}\r\ncout<<\"NO\";\r\n}\r\nint main()\r\n{\r\n ios_base::sync_with_stdio(0);\r\n cin.tie(0);\r\n cout.tie(0);\r\n ll t=1;\r\n //cin>>t;\r\n while (t--){\r\n solve();\r\n cout<\n#define xx first\n#define yy second\n#define mp make_pair\n#define pb push_back\n#define ll long long\nusing namespace std;\n\n\nll mod=1000000007;\nint n,k, cnt1[100005], used[100005], used2[100005], fif=0, cen=0;\nll cnt2[100005];\nll fact[200005];\nvector,int> > v,v2;\nvector > v4;\nvector v3;\n\nll pw(ll x, int y)\n{\n if(y==0) return 1;\n ll ans= pw(x,y/2);\n ans*=ans;\n ans%=mod;\n if(y%2) ans*=x;\n ans%=mod;\n return ans;\n}\n\nll inv(ll x)\n{\n return pw(x,mod-2);\n}\n\nll C(int x, int y)\n{\n if(x p= mp(0,0);\n while(p.yy\n#include \nusing namespace std;\n\nint main() {\n\tint n, x, ans = 0, b;\n\tcin >> n >> x;\n\tvector N(n+1);\n\tfor (int i=0; i> b;\n\t\tN[b] = 1;\n\t}\n\tfor (int i=0; i\n#include \n#include \n\nusing namespace std;\n\ntypedef unsigned long long ull;\n\null q,di=1;\nbool prime[10000002];\n\nint main(){\n\tscanf(\"%I64d\",&q);\n\tprime[2]=false;\n\tint ndiv=0;\n\tfor (int i=2; i<=sqrt(q*1.0); i++)\n\t\tif (!prime[i]){\n\t\t\tif (q%i==0){\n\t\t\t\tndiv++;\n\t\t\t\tq/=i;\n\t\t\t\tdi*=i;\n\t\t\t\tif (ndiv>=2)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor (int j=2*i; j<=sqrt(q*1.0); j+=i)\n\t\t\t\tprime[j]=true;\n\t\t}\n\tswitch (ndiv){\n\tcase 0:\n\t\tputs(\"1\\n0\");\n\t\tbreak;\n\tcase 1:\n\t\tputs(\"2\");\n\t\tbreak;\n\tcase 2:\n\t\tprintf(\"1\\n%I64d\\n\",di);\n\t\tbreak;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "20260b1d5b00e7a8e147c581314a4fb0", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "/*.........................................\n . *BISMILLAHIR RAHMANIR RAHIM* .\n . [ALLAH] is Almighty .\n ....................................\n ********************************************\n * . . . . . . . . . . . . . . . . . .. *\n * . solved_by: zitul_mahmud; . *\n * . Electrical and Electronic . *\n * . Engineering [ EEE ] . *\n * . Islamic university,kushtia; . *\n * . zitulmahmud88@gmail.com; . *\n * . \"STAY HUNGRY STAY FOOLISH\" . *\n * . . . . . . . . . . . . . . . . . .. *\n ********************************************/\n\n\n\n# include\n# include\n# include\n\ntypedef long long ll;\ntypedef double dl;\nusing namespace std;\n\n\n# define PI 2*acos(0.0)\n# define MOD 100000007\n# define sz 100005/*array_size*/\n# define FF first\n# define SS second\n# define PB push_back\n# define MP make_pair/*make_pair()*/\n# define clr(x) (x).clear()\n# define all(x) (x).begin(),(x).end() /*sorting STL */\n# define MEM(a) memset(ara,true,sizeof(ara));\n\n\n/*Input section*/\n# define si(a) scanf(\"%d\",&a)\n# define sii(a,b) scanf(\"%d %d\",&a,&b)\n# define siii(a,b,c) scanf(\"%d %d %d\",&a,&b,&c)\n\n\n# define sl(a) scanf(\"%lld\",&a);\n# define sll(a,b) scanf(\"%lld %lld\",&a,&b);\n# define slll(a,b,c) scanf(\"%lld %lld %lld\",&a,&b,&c);\n\n#define FR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)\n#define FRR(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)\n\n#define fr(i,a,b) for(int i=a;i<(int)b;i++)\n#define frr(i,a,b) for(int i=a;i<=(int)b;i++)\n\n\n///Output section\n# define SP printf(\" \")\n# define NL printf(\"\\n\")\n# define CH getchar()\n# define DB printf(\"I AM HERE\\n\")\n# define open freopen(\"input.txt\",\"r\",stdin)\n# define close freopen(\"output.txt\",\"w\",stdout)\n# define FAST ios_base::sync_with_stdio(0),cin.tie(0)\n\n///output for int data type\n# define pi(a) printf(\"%d\\n\",a)\n# define pii(a,b) printf(\"%d %d\\n\",a,b)\n# define piii(a,b,c) printf(\"%d %d %d\\n\",a,b,c)\n\n///output for ll data type\nvoid pl(ll a){printf(\"%lld\\n\",a);}\nvoid pll(ll a,ll b){printf(\"%lld %lld\\n\",a,b);}\nvoid plll(ll a,ll b,ll c){printf(\"%lld %lld %lld \",a,b,c);}\n\n\n# define LB(x,p) lower_bound(all(x),p)-(x).begin()\n# define UB(x,p) upper_bound(all(x),p)-(x).begin()\n# define VVV(x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++) cout << *it,SP;NL;\n\n\n\nvoid sss(string s) {cout<>n;return n;}\nstring ll_to_string(ll n) {stringstream ss;ss<>s;return s;}\n\n\n\n/*********************************************************************************\n * ############################### *\n * # [ END OF ALL DECLARATION ] # *\n * ############################### *\n *********************************************************************************/\n\n\n\n\n\n /*STARTING OF MAIN FUNCTION*/\n\n\nint main()\n{\n int n,k,c(0),i,j;\n string s;\n cin>>n>>k>>s;\n //fr(i,0,n) if(isupper(s[i])) s[i]=tolower(s[i]);\n sort(all(s));\n fr(i,0,n)\n {\n fr(j,i+1,n)\n {\n if(s[i]!=s[j])\n {\n //cout << s[i] << \" \" << s[j] << endl;\n c++;\n s.erase(s.begin()+j);\n break;\n }\n }\n }\n if(2*c==n) sss(\"YES\");\n else sss(\"NO\");\n return 0;\n}\n\n\n\n /*Anyone who has never made a mistake has never tried anything new.\n [ ~SIR ALBERT EINSTINE~ ]*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "60b369937ec5720b2e42de10052ed032", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "\ufeff#include \nusing namespace std;\n\n\nclass linkedListNode {\npublic:\n int data;\n linkedListNode* next;\n linkedListNode(int data) {\n this->data = data;\n this->next = nullptr;\n };\n};\n\nclass linkedList {\npublic:\n linkedListNode* head;\n linkedListNode* tail;\n int size;\n linkedList() {\n this->head = nullptr;\n this->tail = nullptr;\n this->size = 0;\n }\n void insert(int data);\n void remove(int data);\n\n void print() const;\n\n};\n\nvoid linkedList::insert(int data) {\n linkedListNode* newNode = new linkedListNode(data);\n if (this->head == nullptr) {\n this->head = newNode;\n this->tail = newNode;\n }\n else {\n this->tail->next = newNode;\n this->tail = newNode;\n }\n this->size += 1;\n}\n\nvoid linkedList::remove(int data) {\n linkedListNode* prev = nullptr;\n linkedListNode* curr = this->head;\n while (curr != nullptr) {\n if (curr->data == data) {\n if (prev == nullptr) {\n linkedListNode* temp = this->head;\n curr = curr->next;\n this->head = curr;\n delete temp;\n temp = nullptr;\n }\n else if (curr->next == nullptr) {\n linkedListNode* temp = this->tail;\n prev->next = nullptr;\n this->tail = prev;\n delete temp;\n temp = nullptr;\n }\n else {\n linkedListNode* temp = curr;\n curr = curr->next;\n prev->next = curr;\n delete temp;\n temp = nullptr;\n }\n }\n else {\n prev = curr;\n curr = curr->next;\n }\n }\n}\n\nvoid linkedList::print() const {\n linkedListNode* curr = this->head;\n while (curr != nullptr) {\n cout << curr->data << \" \";\n curr = curr->next;\n }\n}\n\nint main() {\n int numbers;\n int temp;\n linkedList input;\n cin >> numbers;\n for (int i = 0; i < numbers; i++) {\n cin >> temp;\n input.remove(temp);\n input.insert(temp);\n }\n input.print();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "04380ce5af46b19d9f326b9c3e90679e", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint arr[100000000];\nint main(){\nint n;\ncin>>n;\nint sum=0;\nfor(int i=0;i>arr[i];\n(arr[i]==100)?sum++:sum+=2;\n}\nif(sum%2==0)cout<<\"YES\";\nelse cout<<\"NO\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "15f485e3fb14340cd9dd2f6373279cfc", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define F first\n#define S second\n#define x1 privet1\n#define x2 privet2\n#define y1 privet3\n#define y2 privet4\n\nusing namespace std;\n\n int x, y, x1, y1;\n\nint main(){\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n cin >> x >> y >> x1 >> y1;\n if(x<=x1 && y<=y1){cout << \"Polycarp\"; return 0;}\n if(x>=x1 && y>=y1){cout << \"Vasiliy\"; return 0;}\n if(x>=x1 && y<=y1){\n if(y1-y < min(max(x1, y1), x-x1+y1-y)){cout << \"Vasiliy\"; return 0;}\n cout << \"Polycarp\";\n return 0;\n }\n if(x<=x1 && y>=y1){\n if(x1-x < min(max(x1, y1), y-y1+x1-x)){cout << \"Vasiliy\"; return 0;}\n cout << \"Polycarp\";\n return 0;\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "25871ff9a0d1886d0c27606893675629", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nchar a[1000000005];\nint main(){\n\tint b=0,c=0;\n\tcin>>a;\n\tint k=strlen(a);\n\tfor(int i=0;i\n#include \n#include \nusing namespace std;\nint a[15],n,i;\nint main()\n{\n\tstring s;\n\tcin>>n;\n\tif (n<11) {printf(\"0\\n\");exit(1);}\n\tcin>>s;\t\n\tint ok=1,l=s.length();\n\tfor (i=0;ia[i]) min=a[i];\n\t}\n\tif (min==0) printf(\"1\\n\"); else printf(\"%d\\n\",min);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6f250f534341ae6a12ce11bd268243b6", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define CLR(a) memset(a, 0, sizeof a)\n#define _unique(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end());\n#define _all(v) (v).begin(),(v).end()\n#define _endl putchar('\\n')\n#define _space putchar(' ')\nconst int32_t Accepted = 0;\ntemplatevoid in(T& x) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; }\ntemplatevoid in(T& x, Types& ... oth) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; in(oth...); }\ntemplateT _pow_mod(T a, T b, T mod) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base) % mod; base = (base * base) % mod; b >>= 1; }return res; }\ntemplateT _pow(T a, T b) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base); base = (base * base); b >>= 1; }return res; }\ntemplatevoid out(T x) { char s[65]; int32_t cnt = 0; if (x > 0)while (x > 0)s[cnt++] = (x - (x / 10 * 10)) + '0', x /= 10; else if (x < 0) { while (x < 0)s[cnt++] = (x / 10 * 10) - x + '0', x /= 10; s[cnt++] = '-'; }if (cnt == 0)putchar('0'); else for (int32_t i = cnt - 1; ~i; i--)putchar(s[i]); }\ntemplatevoid print(T x) { out(x); _endl; }\ntemplatevoid print(T x, types... oth) { out(x); _space; print(oth...); }\ntypedef long long ll;\n//mt19937_64 _r(random_device{}());\nconst int32_t MAXN = 1e6 + 5;\n//------------------------Azir---------------------------\nstruct node\n{\n\tint id;\n\tint red, blue;\n\tnode() { red = blue = 0; }\n\tnode(int id,int r=0,int b=0) {\n\t\tthis->id = id;\n\t\tred = r;\n\t\tblue = b;\n\t}\n};\nll mod = 1e9 + 7;\nll bfs(int n)\n{\n\tint cnt = 1;\n\tqueueq;\n\tnode now = node(1);\n\tq.push(now);\n\twhile (!q.empty())\n\t{\n\t\tnow = q.front();\n\t\tq.pop();\n\t\tif (now.red < n)q.push(node( (++cnt), now.red + 1, now.blue));\n\t\tif (now.blue < n)q.push(node( (++cnt), now.red, now.blue + 1));\n\t\tcnt %= mod;\n\t}\n\treturn cnt;\n}\nint32_t main()\n{\n\t// freopen(\"1.in\",\"r\",stdin);\n\tint n;\n\twhile (~scanf(\"%d\", &n))\n\t{\n\t\tprint(bfs(n));\n\t}\n\n\treturn Accepted;\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7701e4f72914632d648ad8a0820791d0", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \r\n \r\nusing namespace std;\r\n#define rep(i, a, n) for(int i = a; i < n; i++)\r\n#define all(x) x.begin(), x.end()\r\n#define pb push_back\r\n#define ios ios::sync_with_stdio(false);cin.tie(0);\r\n#define debug(x) cout << x << endl;\r\n#define SZ(x) (int)x.size()\r\ntypedef long long ll;\r\ntypedef pair PII;\r\nconst int inf = 0x3f3f3f3f;\r\nvoid read(int &x) {int s = 0, f = 1; char ch = getchar(); while(!isdigit(ch)) {f = (ch == '-' ? -1 : f); ch = getchar();} while(isdigit(ch)) {s = s * 10 + ch - '0'; ch = getchar();} x = s * f;}\r\nstring yes = \"Yes\\n\"; string no = \"No\\n\";\r\n\r\nconst int mod = 1e9 + 7;\r\nconst int N = 100005;\r\nint vis[N];\r\nvector primes;\r\nint phi[N];\r\n\r\nvoid euler_n(int n)\r\n{\r\n memset(vis, 0, sizeof vis);\r\n for(int i = 1; i < n; i ++) phi[i] = 1;\r\n for(int i = 2; i < n; i ++)\r\n {\r\n if(vis[i] == 0)\r\n {\r\n vis[i] = 1;\r\n primes.pb(i);\r\n phi[i] = i - 1;\r\n }\r\n\r\n for(int j = 0; j < SZ(primes); j ++)\r\n {\r\n if(primes[j] > n / i) break;\r\n vis[primes[j] * i] = 1;\r\n if(i % primes[j] == 0)\r\n {\r\n phi[i * primes[j]] = phi[i] * primes[j];\r\n break;\r\n }\r\n else \r\n phi[i * primes[j]] = phi[i] * (primes[j] - 1);\r\n }\r\n }\r\n}\r\n\r\nint lcm(int a, int b) {return a * b / __gcd(a, b);}\r\n\r\nint main()\r\n{\r\n euler_n(N);\r\n int n;\r\n cin >> n;\r\n ll res = 0;\r\n for(int i = 1; i <= n; i ++)\r\n {\r\n for(int j = 2 * i; j < n; j += i)\r\n res = (res + lcm(i, n - j) * phi[j / i]) % mod;\r\n }\r\n cout << res << '\\n';\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c4b6ea480e0f5cb285905fead3c75a5f", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n// luv or wat\nusing namespace std;\n#define int long long\n#define PII pair \nvector love; vector primes, divisors; \nunordered_map > dividesx; \nint isnotprime [1000005]; \nint dp [7050][7050]; \nmap findpos; \nbool checkprime (int a)\n{\n for (int g=0; g> a;\n if (a==1){cout << 0; return 0; \n }\n \n for (int g=1; g*g<=a; g++)\n {\n if (g*g==a)\n {\n divisors.push_back(g); continue; \n }\n if (a%g==0)\n {\n divisors.push_back(g); \n divisors.push_back(a/g); \n }\n }\n sort(divisors.begin(), divisors.end()); \n for (int g=0; g=0; t--)\n {if (love[t]>divisors[g])continue; \n for (int z=0; z\n#define mod 1000000007\ntypedef long long ll;\nint n;\nll s,f[25],fac[1000005],inv[1000005],ans;\nvoid init()\n{\n\tfac[0]=fac[1]=inv[0]=inv[1]=1;\n\tfor(int i=2;i<=1000000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;\n\tfor(int i=2;i<=1000000;i++) fac[i]=fac[i-1]*i%mod,inv[i]=inv[i-1]*inv[i]%mod;\n}\nll combine(ll x,ll y)\n{\n\tif(x<=1000000&&y<=1000000) return fac[x]*inv[y]%mod*inv[x-y]%mod;\n\treturn combine(x/mod,y/mod)*combine(x%mod,y%mod)%mod;\n}\nvoid dfs(int now,int cnt,ll sum)\n{\n\tif(now>n)\n\t{\n\t\tif(s\nusing namespace std;\nint main(){\n int m,a;\n cin>>a>>m;\n int x=a,ans=0;\n while(true){\n a+=a;\n a%=m;\n if(a==0){\n ans=0;\n break;\n }\n if(a==x){\n ans=1;\n break;\n }\n }\n if(ans==1) cout<<\"No\";\n if(ans==0) cout<<\"Yes\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b464fde840b22f35cdc8dd027132383f", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nint chrcmp(char ch){\n\t// A, E, I, O, U, Y\n\tif (ch=='a' || ch=='A' || ch=='e' || ch=='E' ||\n\t ch=='i' || ch=='I' || ch=='o' || ch=='O' ||\n\t\tch=='u' || ch=='U' || ch=='y' || ch=='Y' )return 0; else return 1;\n\t}\nmain(){char c,str[110],str1[100]=\"\",max;\n while((c=getch())!='?')if(c<='z' && c>='A')max=c;\n\t if(chrcmp(max))printf(\"NO\");else printf(\"YES\");\n\t //getch();\n\t\treturn 0; \n\t }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1b0fbf38eb3ed7fee1e70ab72a199cf4", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint a[8];\nint b[8];\nint sw;\nint main()\n{\n\tint j,i,k,l,p;\n\tfor(i=0;i<8;i++)\n\t{\n\t\tcin>>a[i]>>b[i];\n\t}\n\n\n\tfor(i=0;i<7;i++)\n\t{\n\t\tfor(j=i+1;j<8;j++)\n\t\t{\n\t\t\tif(a[i]>a[j])\n\t\t\t{\n\t\t\t\tk=a[i];\n\t\t\t\ta[i]=a[j];\n\t\t\t\ta[j]=k;\n\t\t\t\tk=b[i];\n\t\t\t\tb[i]=b[j];\n\t\t\t\tb[j]=k;\n\t\t\t}\n\t\t\tif(a[i]==a[j] && b[i]>b[j])\n\t\t\t{\n\t\t\t\tk=b[i];\n\t\t\t\tb[i]=b[j];\n\t\t\t\tb[j]=k;\n\t\t\t}\n\t\t}\n\t}\n\n\n\n\n\n\tfor(i=0;i<7;i++)\n\t{\n\t\tfor(j=i+1;j<8;j++)\n\t\t{\n\t\t\tif(a[j]-a[i]>=2 && b[j]-b[i]>=2)\n\t\t\t{\n\t\t\t\tsw=0;\n\t\t\t\tfor(k=0;k<8;k++)\n\t\t\t\t{\n\t\t\t\t\tfor(l=a[i]+1;l\n\nusing namespace std;\n\n#define mp make_pair\n#define pb push_back \n#define nd second\n#define st first\n\ntypedef long long ll;\ntypedef long long int lli;\ntypedef long long unsigned llu;\ntypedef pair < int,int > pii;\ntypedef pair < lli,lli > plli;\n\nconst int MAX = 1e6+7;\n\nstring s;\n\nint main()\n{\n\tcin>>s;\n\tint k ;\n\tif(s[s.length()-1]=='h')\n\t{\n\t\tif(s[1]<='9' && s[0]>='0')\n\t\t\tk = (s[0]-'0')*10 + s[1]-'0';\n\t\telse \n\t\t\tk= s[0]-'0';\n\n\t\tif(k==31)\n\t\t\tprintf(\"7\");\n\t\telse if(k==30)\n\t\t\tprintf(\"11\");\n\t\telse \n\t\t\tprintf(\"12\");\n\t}\n\telse if(s[s.length()-1]=='k')\n\t{\n\t\tk=s[0]-'0';\n\t\t\tputs((k==5 || k==6)?\"53\":\"52\");\n\t}\n\telse while(1);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d1a4c330306607544e924eb32cd049f8", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\nusing namespace std;\n\nvoid answer(int x)\n{\n cout << x << endl;\n}\nconst int N = 505;\nlong long cnt[9];\n\nlong long W;\nconst long long we = 500;\nconst long long co = 50;\nconst long long predm = 10000;\nconst long long maxw = 10000;\n long long dp[predm][maxw];\nint main() {\n cin >> W;\n for(int i = 1; i <= 8; i++)\n cin >> cnt[i];\n long long ans = 0;\n for(int i = 1; i <= 8; i++)\n {\n if(W > we && cnt[i] > co)\n {\n long long delta = W - we;\n long long amo = min(delta / i, cnt[i] - co);\n W -= amo*i;\n ans += amo*i;\n cnt[i] -= amo;\n }\n }\n W = min(W, 1LL*1000);\n for(int i = 1; i <= 8; i++)\n {\n cnt[i] = min(cnt[i], (W+i)/i);\n }\n\n\n vector v = {};\n long long ww = 0;\n for(int i = 1; i <= 8; i++)\n {\n for(int j = 0; j < cnt[i]; j++){\n v.push_back(i);\n ww += i;\n }\n }\n\n dp[0][0] = 1;\n ww = min(ww, W);\n /*if (ww >= maxw)\n cout << \"ddddd\" << endl;\n if(v.size() > predm )\n cout << \"hhhh\" << endl;*/\n for(int i = 1; i <= v.size(); i++)\n {\n for(int j = 0; j <= ww; j++)\n {\n if(dp[i-1][j] == 1){\n dp[i][j + v[i-1]] = 1;\n dp[i][j] = 1;\n }\n }\n }\n\n long long f = 0;\n for(int j = 0; j <= ww ; j++ )\n if(dp[v.size()][j] ==1)\n f = j;\n ans += f;\n cout << ans;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8c265a895be1c6590415a91de883fd2f", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n//using namespace __gnu_pbds;\n#define ll long long\n#define ff first\n#define ss second\n#define pb push_back\n#define freopen freopen(\"input.txt\",\"r\",stdin); freopen(\"output.txt\",\"w\",stdout);\n#define MOD 998244353 \n#define IOS ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);\nll mx=-1e9,mn=1e9+5;\nll T,n,m,k,ans,a[10],b,c,d,l,r,sum,mid,coin,z,cnt,pos,number,cnt1,x,y,utga,xx,yy;\nvector v,v1;\nmap mp,mm;\nmap :: iterator it;\npair p[100005];\nqueue q;\npriority_queue pq;\nll dp[35000][1000];\nchar ch[105][105];\nbool prime[1000005];\nint main(){\n cin>>n;\n for(int i=1; i<=n; i++){\n cin>>a[i];\n }\n if(n==1){\n cout<<\"YES\"<\nusing namespace std;\n\n#define lli long long int\n\nint main()\n{\n lli n;\n \n scanf(\"%lld\",&n);\n \n lli ans,fun=0,first=0;\n \n lli cut=1,a;\n lli test=n;\n \n vector v;\n \n while(test)\n {\n v.push_back(test%10);\n \n test = test/10;\n }\n \n reverse(v.begin(),v.end());\n \n for(int i=0;i=1;i--)\n {\n lli m=i;\n \n ans=1;\n \n while(m)\n {\n ans *= (m%10);\n m = m/10;\n }\n \n fun = max(fun,ans);\n \n /*\n if(ans>=fun)\n {\n fun = ans;\n ans1 = i;\n }\n */\n \n if(fun>=cut)\n { \n //printf(\"%lld\\n\",i);\n break;\n }\n }\n \n printf(\"%lld\",fun);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e1fa8aa8b6a332f10644e91b75d8227c", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef vector vs;\ntypedef vector vi;\n#define clr(x) memset((x), 0, sizeof(x))\n#define SORT(x) sort(x.begin(),x.end())\n#define forn(i, n) for(int i = 0; i< n; i++)\n#define forns(i, start, end) for(int i = start; i<= end; i++)\n#define all(i, x) for(int i = 0; i< x.size(); i++)\n#define ll long long\nconst long double EPS = 1e-11;\n\nint n,k,ans = 100000000;\nstring ss[8];\nint main()\n{\n//\tfreopen(\"test.txt\",\"r\",stdin);\n// freopen(\"test.txt\",\"w\",stdout);\n\tcin>>n>>k;\n\tforn(i,n)\n\t{\n\t\tcin>>ss[i];\n\t}\n\tfor(int i1 = 0; i1 < k; i1 ++)\n\tfor(int i2 = 0; i2 < k; i2 ++)\n\tfor(int i3 = 0; i3 < k; i3 ++)\n\tfor(int i4 = 0; i4 < k; i4 ++)\n\tfor(int i5 = 0; i5 < k; i5 ++)\n\tfor(int i6 = 0; i6 < k; i6 ++)\n\tfor(int i7 = 0; i7 < k; i7 ++)\n\tfor(int i8 = 0; i8 < k; i8 ++)\n\t{\n\t\tunsigned char f = 0;\n\t\tstring str[8];\n\t\tf = 0xf0;\n\t\tswitch(k)\n\t\t{\n\t\tcase 1:\n\t\t\tf = 1;\n\t\tcase 2:\n\t\t\tf = 0xfc | 1< 1)\n\t\t\t\tstr[i].push_back(ss[i].at(i2));\n\t\t\t\tif(k > 2)\n\t\t\t\tstr[i].push_back(ss[i].at(i3));\n\t\t\t\tif(k > 3)\n\t\t\t\tstr[i].push_back(ss[i].at(i4));\n\t\t\t\tif(k > 4)\n\t\t\t\tstr[i].push_back(ss[i].at(i5));\n\t\t\t\tif(k > 5)\n\t\t\t\tstr[i].push_back(ss[i].at(i6));\n\t\t\t\tif(k > 6)\n\t\t\t\tstr[i].push_back(ss[i].at(i7));\n\t\t\t\tif(k > 7)\n\t\t\t\tstr[i].push_back(ss[i].at(i8));\n\t\t\t\tsscanf(str[i].c_str(),\"%d\",&x);\n\t\t\t\tif(x < minN)\n\t\t\t\t\tminN = x;\n\t\t\t\tif(x > maxN)\n\t\t\t\t\tmaxN = x;\t\n\t\t\t}\n\t\t\tif(maxN - minN < ans)\n\t\t\t\tans = maxN - minN;\n\t\t}\n\t}\n\tcout<\nusing namespace std;\nint a[]={1,6,28,120,496,1027,2016,8128,32640,130816};\nint main()\n{int n,ma;\ncin>>n;\nfor(int i=0;i<10;i++)\n if(n%a[i]==0 && n>=a[i])\n {ma=a[i];\n }\n cout<\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n int a[n],c=0;\n for(int i=0; i>a[i];\n }\n sort(a,a+n);\n //int k=strlen(a);\n for(int i=0; i\nusing namespace std;\n\nint main()\n{\n\tint n, B;\n\tcin >> n >> B;\n\tint *seq = new int[5];\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> seq[i];\n\tint balance=0, i=0, c=0;\n\n\tfor (i = 0; i < n-2; i++)\n\t{\n\t\tif (seq[i] % 2 == 0) balance++;\n\t\telse balance--;\n\t\tif (balance == 0 && (seq[i + 1] - seq[i] <= B)) { c++; B = B - seq[i + 1] - seq[i]; }\n\t}\n\tcout << c;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ddf33a9f96be455603d836b939b1df4a", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \n#define boost ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);\n#define ll long long\n#define home freopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout); \nusing namespace std;\n\nint main()\n{\n\tboost\n\t#ifndef ONLINE_JUDGE\n\thome\n\t#endif\n\n\tint n; cin >> n;\t\n\twhile(n--)\n\t{\n\t\tint x; cin >> x;\n\t\tint t = 3;\n\t\tint s = 7;\n\t\tll ss1 = t+s;\n\t\tll ss2 = t+s;\n\t\tint flag = 0;\n\t\tfor(int i = 0; i <= x; i ++)\n\t\t{\n\t\t\tif(!(x % t) || !(x % s) || !(x % ss1) || !(x % ss2) || !(x % (ss1+s)) || !(x % (ss2+t)) )\n\t\t\t{\n\t\t\t\tflag++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tss1+=t;\n\t\t\tss2+=s;\n\t\t\tt+=t;\n\t\t\ts+=s;\n\t\t}\n\t\tif(flag)cout << \"YES\\n\";\n\t\telse cout << \"NO\\n\";\n\t}\n\t\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f1162875ee87b8b286f8f03d9c658d0a", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\n#define ll long long\n#define ld long double\n#define qw \" \"\n#define we endl\n#define ff first\n#define ss second\n#define Q 10007\nusing namespace std;\nll n,m,t,k=1,a[Q][Q],i,j;\nmain(){\n\tcin>>n>>m>>t;\n\tif(t==0)return cout<<1<=1;i--){\n\t\tif(n%2==0){\n\t\t\tfor(j=2;j<=m;j++){\n\t\t\t\ta[i][j]=k;\n\t\t\t\tk++;\n\t\t\t\tif(k==t)return cout<=2;j--){\n\t\t\t\ta[i][j]=k;\n\t\t\t\tk++;\n\t\t\t\tif(k==t)return cout< \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define PB push_back \n#define MP make_pair \n#define SZ(v) ((int)(v).size()) \n#define FOR(i,a,b) for(int i=(a);i<(b);++i) \n#define REP(i,n) FOR(i,0,n) \n#define FORE(i,a,b) for(int i=(a);i<=(b);++i) \n#define REPE(i,n) FORE(i,0,n) \n#define FORSZ(i,a,v) FOR(i,a,SZ(v)) \n#define REPSZ(i,v) REP(i,SZ(v)) \nstd::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());\ntypedef long long ll;\nll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }\n\n\nconst int MAXN = 10000;\nconst int MAXM = 10000;\nconst int MAXSPECIAL = 10;\nconst int MAXQ = 200000;\nconst int MAXW = 25;\n\nconst int MAXGN = MAXN;\nconst int MAXGM = MAXM;\n\ntypedef struct MF {\n\tint n, m;\n\tint ghead[MAXGN], gnxt[2 * MAXGM], gto[2 * MAXGM]; ll gcap[2 * MAXGM];\n\tvoid init(int _n) { n = _n, m = 0; REP(i, n) ghead[i] = -1; }\n\tvoid addedge(int a, int b, ll c) { gnxt[2 * m + 0] = ghead[a], ghead[a] = 2 * m + 0, gto[2 * m + 0] = b, gcap[2 * m + 0] = c; gnxt[2 * m + 1] = ghead[b], ghead[b] = 2 * m + 1, gto[2 * m + 1] = a, gcap[2 * m + 1] = 0; ++m; /*printf(\"%d->%d\\n\",a,b);*/ }\n\tint d[MAXGN];\n\tint q[MAXGN], qhead, qtail;\n\tint cur[MAXGN];\n\tll dinic(int s, int t) {\n\t\tll ret = 0; int niter = 0;\n\t\twhile (true) {\n\t\t\tREP(i, n) d[i] = INT_MAX; qhead = qtail = 0; d[s] = 0, q[qhead++] = s;\n\t\t\twhile (qtail < qhead && d[t] == INT_MAX) { int at = q[qtail++]; for (int x = ghead[at]; x != -1; x = gnxt[x]) { int to = gto[x]; if (gcap[x] == 0 || d[to] != INT_MAX) continue; d[to] = d[at] + 1; q[qhead++] = to; } }\n\t\t\tif (d[t] == INT_MAX) return ret;\n\t\t\tREP(i, n) cur[i] = ghead[i];\n\t\t\tret += dfs(s, t, LLONG_MAX); ++niter;\n\t\t}\n\t}\n\tll dfs(int at, int t, ll rem) {\n\t\tll ret = 0; if (at == t) return rem;\n\t\tif (d[at] >= d[t]) return 0;\n\t\tfor (; cur[at] != -1; cur[at] = gnxt[cur[at]]) {\n\t\t\tint to = gto[cur[at]]; ll cap = gcap[cur[at]]; if (d[to] != d[at] + 1 || cap == 0) continue;\n\t\t\tll now = dfs(to, t, min(cap, rem));\n\t\t\trem -= now; ret += now; if (gcap[cur[at]] != LLONG_MAX) gcap[cur[at]] -= now; if (gcap[cur[at] ^ 1] != LLONG_MAX) gcap[cur[at] ^ 1] += now; if (rem == 0) return ret;\n\t\t}\n\t\treturn ret;\n\t}\n\tvector findpath(int s, int t) {\n\t\tvector ret;\n\t\tint at = s;\n\t\twhile (at != t) {\n\t\t\tbool found = false;\n\t\t\tfor (int x = ghead[at]; x != -1; x = gnxt[x]) {\n\t\t\t\tif (x % 2 != 0 || gcap[x ^ 1] == 0) continue;\n\t\t\t\t++gcap[x], --gcap[x ^ 1], found = true; at = gto[x]; ret.PB(x); break;\n\t\t\t}\n\t\t\tassert(found);\n\t\t}\n\t\treturn ret;\n\t}\n} MF;\n\n\n\nint n, m, nspecial, nq;\nMF g;\nint qval[MAXQ][MAXSPECIAL], qans[MAXQ];\n\nint s, t;\nint flowwith[1 << MAXSPECIAL];\nint qsum[1 << MAXSPECIAL];\n\nvoid rec(int mask, int at, int sofar) {\n\tif (at == nspecial) { flowwith[mask] = sofar; return; }\n\trec(mask, at + 1, sofar);\n\tassert(g.gcap[2 * at + 0] == 0);\n\tg.gcap[2 * at + 0] = MAXW;\n\tint extra = g.dinic(s, t);\n\trec(mask | (1 << at), at + 1, sofar + extra);\n\tREP(i,extra) {\n\t\tint a = g.gto[2 * at + 1], b = g.gto[2 * at + 0];\n\t\tg.findpath(s, a); g.findpath(b, t); assert(g.gcap[2 * at + 1] > 0); --g.gcap[2 * at + 1]; ++g.gcap[2 * at + 0];\n\t}\n\tassert(g.gcap[2 * at + 0] == MAXW);\n\tg.gcap[2 * at + 0] = 0;\n}\n\nvoid solve() {\n\ts = 0, t = n - 1;\n\tint initflow = g.dinic(s, t);\n\trec(0, 0, initflow);\n\n\tREP(i, nq) {\n\t\tqsum[0] = 0; REP(bit, nspecial) REP(mask, 1 << bit) qsum[mask | (1 << bit)] = qsum[mask] + qval[i][bit];\n\t\tint cur = INT_MAX;\n\t\tREP(mask, 1 << nspecial) cur = min(cur, flowwith[(1 << nspecial) - mask - 1] + qsum[mask]);\n\t\tqans[i] = cur;\n\t}\n}\n\nvoid run() {\n\tscanf(\"%d%d%d%d\", &n, &m, &nspecial, &nq);\n\tg.init(n);\n\tREP(i, m) { int a, b, c; scanf(\"%d%d%d\", &a, &b, &c); --a, --b; g.addedge(a, b, c); }\n\tREP(i, nq) REP(j, nspecial) scanf(\"%d\", &qval[i][j]);\n\tsolve();\n\tREP(i, nq) printf(\"%d\\n\", qans[i]);\n}\n\nint main() {\n\trun();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b70a28e4bed61f3796ef5ebbaf891bb4", "src_uid": "7421c7d81cc7b481d61a6ef07e557e33", "difficulty": 3200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nlong long int CalcIntegerRoot(long long int n);\nlong long int CalcVolume(long long int ap, long long int bp, long long int cp);\n\nint main()\n{\n\tusing namespace std;\n\n\tlong long int n;\n\tcin >> n;\n\n\tlong long int npmin, npmax;\n\t\n\t//===============================\n\t//n = 1026;\n\t\n\tlong long int min=10000000000;\n\tlong long int vol = 0;\n\tlong long int ost, c, ab;\n\tlong long int maxminap;\n\t\n\t//temp:\n\t//long long int minCurA, volA, cA, cB, cC;\n\n\tconst int sizeArrDiv = 100;\n\tlong long int arrDivider[sizeArrDiv];\n\t\n\t//=== calc div ===\n\tlong long int dMax;\n\tlong long int np = 0;\n\tlong long int nc;\t\n\tbool isDiv2 = false, isDiv3 = false, isDiv4 = false, isDiv5 = false;\n\n\tarrDivider[np++] = 1;\n\tif(n%2 == 0)\n\t{\n\t\tarrDivider[np++] = 2;\n\t\tisDiv2 = true;\n\t}\n\tif(n%3 == 0)\n\t{\n\t\tarrDivider[np++] = 3;\n\t\tisDiv3 = true;\n\t}\n\tif(n%4 == 0)\n\t{\n\t\tarrDivider[np++] = 4;\n\t\tisDiv4 = true;\n\t}\n\tif(n%5 == 0)\n\t{\n\t\tarrDivider[np++] = 5;\n\t\tisDiv5 = true;\n\t}\n\n\tnc = 6;\n\tdMax = n/5;\n\tfor( ; nc < dMax; nc++)\n\t{\n\t\tif(n%nc == 0)\n\t\t{\n\t\t\tarrDivider[np++] = nc;\n\t\t}\t\t\t\n\t}\n\tif(isDiv5)\n\t{\n\t\tarrDivider[np++] = n/5;\n\t}\n\tif(isDiv4)\n\t{\n\t\tarrDivider[np++] = n/4;\n\t}\n\tif(isDiv3)\n\t{\n\t\tarrDivider[np++] = n/3;\n\t}\n\tif(isDiv2)\n\t{\n\t\tarrDivider[np++] = n/2;\n\t}\n\tarrDivider[np++] = n;\n\t//=================\n\n\tfor(int a=0; a < np; a++)\n\t{\n\t\tfor(int b=0; b < np; b++)\n\t\t{\n\t\t\tab = arrDivider[a]*arrDivider[b];\n\n\t\t\tif(n%ab == 0)\n\t\t\t{\n\t\t\t\tc = n/ab;\n\n\t\t\t\tvol = CalcVolume(arrDivider[a], arrDivider[b], c) - n;\n\t\t\t\tif(vol < min)\n\t\t\t\t{\n\t\t\t\t\tmin = vol;\n\t\t\t\t}\t\n\t\t\t}\t\t\t\n\t\t}\t\t\n\t}\n\t\n\tnpmin = min;\n\tnpmax = CalcVolume(n, 1, 1) - n;\t\n\tcout << npmin << \" \" << npmax;\t\n\tgetch();\n\treturn 0;\n\n\t\t\n\t//for(int a=1; a <= n; a++)\n\t//{\n\t//\t//minCurA = 10000000000;\n\n\t//\tif(n%a)\n\t//\t{\n\t//\t\tcontinue;\n\t//\t}\n\n\t//\tfor(int b=1; b <=n; b++)\n\t//\t{\n\t//\t\tif(n%b)\n\t//\t\t{\n\t//\t\t\tcontinue;\n\t//\t\t}\n\t//\t\t\n\t//\t\tab = a*b;\n\n\t//\t\tif(n%ab)\n\t//\t\t{\n\t//\t\t\tcontinue;\n\t//\t\t}\n\n\t//\t\tc = n/ab;\n\n\t//\t\t//for(int c=1; c <= n; c++)\n\t//\t\t//{\n\t//\t\t//\tif((a*b*c) == n)\n\t//\t\t//\t{\n\t//\t\t\t\tvol = CalcVolume(a, b, c) - n;\n\t//\t\t\t\tif(vol < min)\n\t//\t\t\t\t{\n\t//\t\t\t\t\tmin = vol;\n\t//\t\t\t\t}\n\n\t//\t\t\t\t//if(vol < minCurA)\n\t//\t\t\t\t//{\n\t//\t\t\t\t//\tminCurA = vol;\n\t//\t\t\t\t//\tcA = a;\n\t//\t\t\t\t//\tcB = b;\n\t//\t\t\t\t//\tcC = c;\n\t//\t\t\t\t//}\n\t//\t\t//\t}\n\t//\t\t//}\n\n\t//\t}\n\n\t//\tint curIjk = 1;\n\t//}\n\t//\n\t//npmin = min;\n\t//npmax = CalcVolume(n, 1, 1) - n;\t\n\t//cout << npmin << \" \" << npmax;\t\n\t////getch();\n\treturn 0;\n\t\n\t//===============================\n\n\n\t//long long int ap, bp, cp;\n\t//long long int tempmin, tempn;\n\t//\n\t//long long int root = CalcIntegerRoot(n);\n\t//maxminap = root;\n\t////if(maxminap > 600)\n\t//if(maxminap > 700)\n\t//{\n\t//\tmaxminap = 700;\n\t//} \n\t//npmin = 10000000000;\n\n\t////int sizeInc = 1;\n\t//long long int tempMinA;\n\n\t//for(ap = 1; ap <= maxminap; ap++)\n\t//{\n\t//\tif(n%ap != 0)\n\t//\t{\n\t//\t\tcontinue;\n\t//\t}\n\n\t//\ttempn = n/ap;\n\t//\troot = CalcIntegerRoot(tempn);\n\t//\t//sizeInc = 1;\n\t//\ttempMinA = 10000000000;\n\t//\t\n\t//\tif(root*root == tempn)\n\t//\t{\n\t//\t\tbp = root;\n\t//\t\tcp = root;\t\t\t\n\t//\t}\n\t//\telse\n\t//\t{\n\t//\t\tbp = root;\n\n\t//\t\t//if(tempn%2 != 0)\n\t//\t\t//{\n\t//\t\t//\tsizeInc = 2;\n\t//\t\t//\tif(bp%2 == 0)\n\t//\t\t//\t{\n\t//\t\t//\t\tbp--;\n\t//\t\t//\t}\n\t//\t\t//}\n\t//\t\t\n\t//\t\twhile(tempn%bp != 0)\n\t//\t\t{\n\t//\t\t\tbp--;\n\t//\t\t\t//bp -= sizeInc;\n\t//\t\t}\n\n\t//\t\tif(bp == 1)\n\t//\t\t{\n\t//\t\t\tcp = tempn;\n\t//\t\t}\n\t//\t\telse if(bp == 2)\n\t//\t\t{\n\t//\t\t\tcp = tempn/2;\n\t//\t\t}\n\t//\t\telse if(bp == 3)\n\t//\t\t{\n\t//\t\t\tcp = tempn/3;\n\t//\t\t}\n\t//\t\telse\n\t//\t\t{\n\t//\t\t\tcp = root+1;\n\n\t//\t\t\t/*if(cp%2 == 2)\n\t//\t\t\t{\n\t//\t\t\t\tcp++;\n\t//\t\t\t}*/\n\n\t//\t\t\twhile(tempn%cp != 0 && cp < tempn)\n\t//\t\t\t{\n\t//\t\t\t\tcp++;\n\t//\t\t\t\t//cp += sizeInc;\n\t//\t\t\t}\n\n\t//\t\t\tif(cp == tempn)\n\t//\t\t\t{\n\t//\t\t\t\tbp = 1;\n\t//\t\t\t}\n\t//\t\t}\n\n\t//\t\twhile(bp*cp != tempn)\n\t//\t\t{\n\t//\t\t\tbp--;\n\n\t//\t\t\t/*if(bp%2 == 0)\n\t//\t\t\t{\n\t//\t\t\t\tbp--;\n\t//\t\t\t}*/\n\n\t//\t\t\twhile(tempn%bp != 0)\n\t//\t\t\t{\n\t//\t\t\t\tbp--;\n\t//\t\t\t\t//bp -= sizeInc;\n\t//\t\t\t}\n\n\t//\t\t\t//if(bp == 1)\n\t//\t\t\t//{\n\t//\t\t\t//\tcp = tempn;\n\t//\t\t\t//\tbreak;\n\t//\t\t\t//}\n\t//\t\t\t//else if(bp == 2)\n\t//\t\t\t//{\n\t//\t\t\t//\tcp = tempn/2;\n\t//\t\t\t//\tbreak;\n\t//\t\t\t//}\n\t//\t\t\t//else if(bp == 3)\n\t//\t\t\t//{\n\t//\t\t\t//\tcp = tempn/3;\n\t//\t\t\t//\tbreak;\n\t//\t\t\t//}\n\n\t//\t\t\t//cp++;\n\t//\t\t\t//while(tempn%cp != 0 && cp < tempn)\n\t//\t\t\t//{\n\t//\t\t\t//\tcp++;\n\t//\t\t\t//}\n\t//\t\t\t//if(cp == tempn)\n\t//\t\t\t//{\n\t//\t\t\t//\tbp = 1;\n\t//\t\t\t//\tbreak;\n\t//\t\t\t//}\n\t//\t\t\tcp = tempn/bp;\n\t//\t\t}\n\t//\t}\n\n\t//\ttempmin = CalcVolume(ap, bp, cp) - n;\n\t//\tif(tempmin < npmin)\n\t//\t{\n\t//\t\tnpmin = tempmin;\n\t//\t}\n\t//}\n\n\t//npmax = CalcVolume(n, 1, 1) - n;\n\n\t//cout << npmin << \" \" << npmax;\t\n\n\t//getch();\n\t//return 0;\n}\n\nlong long int CalcVolume(long long int ap, long long int bp, long long int cp)\n{\n\treturn (ap+1)*(bp+2)*(cp+2);\t\n}\n\nlong long int CalcIntegerRoot(long long int n)\n{\n\t//long long int root = -1;\n\t//long long int cs = 1;\n\t//while(n >= 0)\n\t//{\n\t//\troot++;\n\t//\tn -= cs;\n\t//\tcs += 2;\n\t//}\n\n\tlong double ld = n;\n\tlong double ldr = sqrt(ld);\t\n\tlong long int root = (long long int)ldr;\n\n\treturn root;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6654fa8f4a948b7d8fc0ef13c53dde45", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\nint main(){\n\tint vp,vd,t,f,c; cin>>vp>>vd>>t>>f>>c;\n\tdouble x = ((vd*t)/(vd-vp));\n\tdouble time= c/vp,time1 =x;\n\tif(vp>vd){cout<<\"0\"<=c/vp){cout <<\"0\"<0){\n\t\tn++;\n\t\tx = (2*vp*time1+vd*f)/(vd-vp);\n\t\ttime = time -x;\n\t\ttime1 = time1+x; \n\t}\n\tcout<\n\nusing namespace std;\n\nint main()\n{\nint l,r,a,k=0;\ncin>>l>>r>>a;\nif(l==0&&r!=0||r==0&&l!=0)\n{\n cout<<\"0\";\n}\nelse{\nk=l+r+a;\nwhile(true){\nif(k%2!=0)\n k=k-1;\n}\ncout< \nusing namespace std;\n\n\nint main()\n{\n\tint* A = new int[30];\n\tfor (size_t i = 0; i <= 30; i++)\n\t{\n\t\tA[i] = pow(2, i);\n\t}\n\tint x = 0;\n\tcin >> x;\n\tfor (size_t i = 0; i <= 30; i++)\n\t{\n\t\tif (A[i] == x)\n\t\t{\n\t\t\tcout << 1;\n\t\t\treturn 0;\n\t\t}\n\t\telse if(A[i]x)\n\t\t{\n\t\t\tcout << (x % A[i]) + 1;\n\t\t}\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "af33f918ca80e8f413415e4fdfd8e815", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define PI 3.14159265\n\nint main() {\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tlong long ax,ay,bx,by,cx,cy;\n\tcin >> ax >> ay >> bx >> by >> cx >> cy;\n\tlong long s1,s2;\n\ts1=pow(ax-bx,2)+pow(ay-by,2);\n\ts2=pow(cx-bx,2)+pow(cy-by,2);\n\tif(s1!=s2){\n\t\tcout << \"NO\";\n\t\tgetch();\n\t\treturn 0;\n\t}\n\tlong long a[2],b[2];\n\ta[0]=ax-bx;\n\ta[1]=ay-by;\n\tb[0]=cx-bx;\n\tb[1]=cy-by;\n\tdouble a1,b1;\n\tlong long ab;\n\tab=a[0]*b[0]+a[1]*b[1];\n\ta1=sqrt(pow(a[0],2)+pow(a[1],2));\n\tb1=sqrt(pow(b[0],2)+pow(b[1],2));\n\tif(ab/sqrt(pow(a[0],2)+pow(a[1],2))*sqrt(pow(b[0],2)+pow(b[1],2))>0){\n\t\tcout << \"NO\";\n\t\treturn 0;\n\t}\n\tcout << \"YES\";\n\tgetch();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e08dae8f3d19e481434fbb1e355edd83", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef double real;\ntypedef pair ii;\n\ntemplate \nstring toString(T x)\n{\n\tif (x == 0) return \"0\";\n\tbool negative = x < 0;\n\tstring res;\n\twhile (x)\n\t{\n\t\tres.push_back('0' + x % 10);\n\t\tx /= 10;\n\t}\n\tif (negative) res.push_back('-');\n\treverse(res.begin(), res.end());\n\treturn res;\n}\n\nvoid ioFromFile(string inputFileName, string outputFileName)\n{\n\tifstream fin(inputFileName);\n\tofstream fout(outputFileName);\n\tcin.rdbuf(fin.rdbuf());\n\tcout.rdbuf(fout.rdbuf());\n}\n\nint read()\n{\n\tint res;\n\tscanf(\"%d\", &res);\n\treturn res;\n}\n\ntemplate \nT gcd(T a, T b) { return a == 0 ? b : gcd(b % a, a); }\ntemplate \nT lcm(T a, T b) { return a / gcd(a, b) * b; }\n//---------------------------------------------------\n\nint main()\n{\n\tint maxsec = read();\n\tint n = read();\n\tint nd = read();\n\tint ninsec = read();\n\n\tint res = 0;\n\tint numdivided = maxsec + 1;\n\twhile (n)\n\t{\n\t\tif (nd > 0)\n\t\t{\n\t\t\tif (numdivided > maxsec)\n\t\t\t{\n\t\t\t\tres++;\n\t\t\t\tnumdivided = 0;\n\t\t\t}\n\t\t\tnumdivided++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tres++;\n\t\t}\n\t\tn -= ninsec;\n\t}\n\n\tcout << res;\n\n\treturn 0;\n}\n\n/*\n\n\n\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "727bcdf7116e3e9c5cc29271412fe2ab", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include\n#include \n#include \n//#include \n//\n//using namespace boost::multiprecision;\nusing namespace __gnu_pbds;\nusing namespace std;\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\n\n/*** Typedef ***/\ntypedef int ll;\n//typedef long long ll;\ntypedef long long int lli;\ntypedef unsigned long long ull;\ntypedef long double ld;\n\n//typedef unordered_set usll;\n//typedef unordered_multiset umsll;\n\n/*** Loops ***/\n#define ffit(i, dat) for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)\n#define F(a,b) for(int i = a; i < b; i++)\n#define ff1(i,a,b) for(ll i = a; i < b; i++)\n#define ff2(i,a,b) for(ll i = b-1; i >= a; i--)\n#define ff3(i,a,b,m) for(ll i = a; i >ar[i];\n#define opar(ar,n) ff1(i,0,n) cout<= 0; i--)\n#define forIn(arr, num) for(ll i = 0; i < num; i++) sc1(arr[i]);\n#define forIn1(arr, num) for(ll i = 1; i <= num; i++) sc1(arr[i]);\n#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\\n');\n#define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\\n');\n\n/*** Define Values ***/\n\n#define PI acos(-1.0)\n#define eps 1e-7\n#define size1 15\n#define mdd 1000000007\n/*** STLs ***/\n#define sf(a) scanf(\"%lld\",&a)\n#define sff(a,b) scanf(\"%lld %lld\",&a,&b)\n#define sfff(a,b,c) scanf(\"%lld %lld %lld\",&a,&b,&c)\n#define cu continue\n#define br break\n#define rsz resize\n#define ins insert\n#define ft front\n#define bk back\n#define eb emplace_back\n#define lb lower_bound\n#define ub upper_bound\n#define pb push_back\n#define ff first\n#define ss second\n#define mp make_pair\n#define rr return\n#define mem(name, value) memset(name, value, sizeof(name))\n#define MN3(n1,n2,n3) min(n1,min(n2,n3))\n#define MN4(n1,n2,n3,n4) min(n1,min(n2,min(n3,n4)))\n#define MX3(n1,n2,n3) max(n1,max(n2,n3))\n#define MX4(n1,n2,n3,n4) max(n1,max(n2,max(n3,n4)))\n#define mxar(a,n) *max_element(a,a+n)\n#define mnar(a,n) *min_element(a,a+n)\n#define arr_sm(a,n) accumulate(a,a+n,0)\n#define vc_sm(ve) accumulate(ve.begin(),ve.end(),0)\n#define mx_vc(ve) *max_element(ve.begin(),ve.end())\n#define mn_vc(ve) *min_element(ve.begin(),ve.end())\n//#define endl \" \\n\"\n\n/*** STLs ***/\ntypedef vector vll;\n#define vvll vector\ntypedef set sll;\ntypedef multiset msll;\ntypedef multimap mpll;\ntypedef queue qll;\ntypedef map mll;\ntypedef pair pll;\ntypedef vector > vpll;\ntypedef priority_queue > pqpll;\n#define uniq(v) (v).erase(unique(all(v)),(v).end())\n#define maxpq priority_queue\n#define minpq priority_queue, greater >\n#define ml unordered_map\n///typedef unordered_multiset umsi;\ntypedef unordered_set us;\n\n\n///vector> v(10, vector(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.\n\n/*** Sorts ***/\n#define czero(n) __builtin_popcountll(n) // count the number of 1's in the bit representation of a number\n#define cenzero(n) __builtin_ctzll(n) // count the number of zereos from the end of the bit representation of a number until a 1\n#define countbegzero(n) __builtin_clzxll(n)\n#define checkparity(n) __builtin_parityll(n)// checks whether the number of bits are even or odd\n#define all(v) (v).begin(), (v).end()\n#define rev(v) reverse(all(v))\n#define srt(v) sort(all(v))\n#define srtgrt(v) sort(all(v), greater())\n#define prsrt greater>()\n/*** Some Prints ***/\n#define ip(n) ll n; cin>>n;\n#define is(s) string s; cin>>s;\n#define ipp(n,k) ll n; cin>>n; ll k; cin>>k;\n#define ip3(n,m,k) ll n; cin>>n;ll m;cin>>m; ll k; cin>>k;\n#define kl '\\n'\n#define no cout << \"NO\" << '\\n'\n#define yes cout << \"YES\" << '\\n'\n#define case cout << \"Case \" << t++ << \": \";\n#define ps(x,y) fixed<>x; while(x--)\n#define go(i, a) for (auto &i : a)\n#define go1(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)\n//#define mk(arr,n,type) type *arr=new type[n];\n#define sz(obj) (int(obj.size()))\n#define ipve(vc,n) vll vc(n); ff1(i,0,n){cin>>vc[i];}\n#define ipvc(vc,n) vll vc; ff1(i,0,n){ip(x);vc.pb(x);}\n#define cer cerr << \"Time : \" << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << \"ms\\n\";\n#define depressed() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)\n//bool ans = all_of(arr, arr + 6, [](int x) {return x & 1; } );\nconst double pi = 3.141592653589793238460;\n#define TRC\n#ifdef TRC\n#define trc(...) __f(#__VA_ARGS__, __VA_ARGS__)\n template \n void __f(const char* name, Arg1&& arg1){\n cout << name << \" : \" << arg1 << endl;\n //use cerr if u want to display at the bottom\n }\n template \n void __f(const char* names, Arg1&& arg1, Args&&... args){\n const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << \" : \" << arg1<<\" | \";__f(comma+1, args...);\n }\n#else\n#define trc(...)\n#endif\n \nvoid fun()\n{\n ip3(a,b,h); ipp(w,n);\n vll v(n);\n go(i,v) cin>>i;\n srtgrt(v);\n if(n>34)\n {\n n = 34;\n v.resize(n);\n }\n ll tot = 1;\n ll ct = 0;\n vll vv;\n vv.pb(1);\n mll m;\n m[1] = 1;\n if(h>=a && w>=b)\n {\n cout<<0;rr;\n }\n swap(h,w);\n if(h>=a && w>=b)\n {\n cout<<0;rr;\n }\n go(x,v)\n {\n ct++;\n tot*=x;\n vll tm;\n go(y,vv)\n {\n tm.pb(x*y);\n }\n go(y,tm)\n {\n if(y<2e5+5 && !m[y])\n {\n vv.pb(y);\n }\n }\n go(y,vv)\n {\n if((h*y>=a && w*(tot/y)>=b) || (h*(tot/y)>=a && w*y>=b))\n {\n cout<>t;\n while(t--)\n {\n fun();\n }\n //cer;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b6bf504151dcce96923ae0ebbcd79046", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "// *CoDeD by Ye.A\n# include \n# include \n# include \n# include \n# include \n\nusing namespace std;\n\nint main ()\n{\n string s;\n cin >> s;\n int n = s.size();\n for (int i = 0; i < n; i++)\n {\n string t;\n for (int j = 0; j < n; j++)\n if (i != j)\n t.push_back (s[j]);\n string q = t;\n reverse (q.begin(), q.end());\n if (q == t)\n {\n t.clear();\n for (int j = 0; j < n; j++)\n {\n if (j == n - i + 1)\n {\n t.push_back (s[i]);\n j--;\n }\n else\n t.push_back (s[j]);\n }\n if (n - i + 1 > n)\n t.push_back (s[i]);\n cout << t;\n return 0;\n }\n }\n puts (\"NA\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cd1339e7034772b836fd96b293ea6a4c", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define SIZE(vn) vn.size()\nconst long long modulo = 1000000007;\n#define MOD(n) ((n)%modulo)\n#define SET0(zn) memset(zn,0,sizeof(zn))\n#define SET(zn, k) memset(zn,k,sizeof(zn))\n#define REP(i,n) for (int i=0; i<(n); ++i)\ntypedef long long LL;\ntemplate void refreshMin(T & a, const T & b) {if (a>b) a = b;}\ntemplate void refreshMax(T & a, const T & b) {if (a void refreshMin(T & a, const T & b, T & c, const T & d) {if (a>b) {a = b; c = d;} }\ntemplate void refreshMax(T & a, const T & b, T & c, const T & d) {if (a T bitAnd(T a, T b) {return a & b;}\ntemplate T bitOr(T a, T b) {return a | b;}\ntemplate T bitXor(T a, T b) {return a ^ b;}\nbool boolXor(bool a, bool b) {return (!a && b) || (a && !b);}\nint main(int argc, char const *argv[]) {\n\tLL a, b;\n\tcin>>a>>b;\n\tLL re = 0;\n\twhile(true) {\n\t\tif (a==0) break;\n\t\tif (a>=b) {\n\t\t\tre++;\n\t\t\ta-=b;\n\t\t\tcontinue;\n\t\t}\n\n\t\tre+= b/a;\n\t\tLL c = b % a;\n\t\tb = a; a = c;\n\t}\n\tcout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\n#define inf 0x3f3f3f3f\n#define eps 1e-10\n#define maxl 100010\n#define mem(i,j) memset(i,j,sizeof(i))\nint prime[maxl];\nvector v;\nint cnt[maxl];\nvoid init(){\n memset(prime,1,sizeof(prime));\n prime[0]=prime[1]=0;\n v.clear();\n for(int i=2;i>n;\n add(n);\n ll res=1;\n for(int i=0;i\nusing namespace std;\n\nint main()\n{\n\tdouble l, d, v, g, r;\n\tcin>>l>>d>>v>>g>>r;\n\tdouble dtime=d/v;\n\tdouble ptime=0;\n\tif (dtime>g)\n\t{\n\t\twhile (dtime>ptime)\n\t\t{\n\t\t\tptime=g+r;\n\t\t}\n\t\tdtime=0;\n\t}\n\tdouble ltime=(l-d)/v;\n\tdouble res=ltime+ptime+dtime;\n\tprintf(\"%.10lf\",res);\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f05218657f0cf4b828d2c40c73e6b595", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "#include \n\nint main()\n{\n unsigned char arr[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 1};\n unsigned int n = 0;\n\n std::cin >> n;\n\n int first_digit = n / 10;\n int second_digit = n % 10;\n int count = arr[first_digit] * arr[second_digit];\n std::cout << ( count == 1 ? 2 : count);\n\n return true;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b0ea9b9160c1ef35951ad954de005c93", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\nint main(){\n\tbool f = 1;\n\tint n;\n\tcin >> n;\n\t\tstring a;\n\t\tcin >> a ;\n\t\tint u=0, l=0;\n\t\tint g = abs(max(u, l)-n/2);\n\t\tfor (int i = 0; i < a.length(); i++)if (islower(a[i]))l++; else u++;\n\t\tif (l\n#define ll long long\n#define mod 1000000007\nusing namespace std;\n#define pb push_back\n#define fio cin.sync_with_stdio(false)\n#define takeinput1 vectorv(n);for(int i=0;i>v[i];}\n#define takeinput2 vectoru(n);for(int i=0;i>u[i];}\nint main(){\n ll l1,r1,t1;cin>>l1>>r1>>t1;\n ll l2,r2,t2;cin>>l2>>r2>>t2;ll k;\n if(t1>t2){\n k=t1;t1=t2;t2=k;\n k=l1;l1=l2;l2=k;\n k=r1;r1=r2;r2=k;\n }\n unordered_mapmap;\n \n ll ans=0;\n for(int i=0;i<999999;i+=t1){\n ll p=0,temp=0;\n for(int j=i+l1;j<=i+r1;j++){\n ll a=j%t1;\n ll b=j%t2;\n if(a>=l1&&a<=r1)a=-1;\n if(b>=l2&&b<=r2)b=-1;\n if(a==-1&&b==-1){\n temp++;\n if(j==i+r1){\n if(map[j%t1]==j%t2&&ans!=0){\n cout<\n#include\n#include\n#include\nusing namespace std;\nlong long bef, dif;\nint Query(long long x){\n dif = abs(x-bef);\n printf(\"? %lld\\n\",x);\n fflush(stdout);\n int ck;\n scanf(\"%d\",&ck);\n bef=x;\n return ck;\n}\nvoid Answer(long long a){\n printf(\"= %lld\\n\",a);\n fflush(stdout);\n}\nvoid Solve(){\n long long n;\n scanf(\"%lld\",&n);\n if(n<=10){\n long long res;\n for(int i=0;;i++){\n int ck;\n if(i%2==0)ck = Query(i/2+1);\n if(i%2==1)ck = Query(n-i/2);\n if(i && !ck){\n res = dif+1;\n break;\n }\n if(i==n-1){\n res=1;break;\n }\n }\n Answer(res);\n return;\n }\n long long K = n-1;\n int i, m=0;\n for(i=0;;i++){\n long long t = (1ll<<(i+2))-1;\n if(t > K)break;\n }\n m = i-1;\n vectorV;\n V.push_back((1ll<=0;i--){\n V.push_back((1ll< \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \ntypedef long long ll;\ntypedef long double ld;\nconst int N = int(1e6) + 7;\nconst ll INF = ll(1e18) + 111;\nconst ld EPS = 1e-7;\n#define pb push_back\n#define all(v) v.begin(), v.end()\n#define sz(v) v.size()\n#define x first\n#define y second \nusing namespace std;\ntemplate inline istream &operator >> (istream &in, vector &v) { for (auto &i : v) { in >> i; } return in; }\ntemplate inline ostream &operator<< (ostream &out, const vector &v) { for (auto &it : v) { out << it << \" \"; } return out; }\nstring s[6];\nvoid print() {\n\tfor (int i = 0; i < 6; i++) {\n\t\tcout << s[i] << endl;\n\t}\n}\nint main() {\n\t//ifstream cin(\"input.txt\");\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\n\tfor (int i = 0; i < 6; i++) {\n\t\tcin >> s[i];\n\t}\n\tif (s[0][3] == '.') {\n\t\ts[0][3] = 'P';\n\t\tprint();\n\t}\n\telse if (s[0][4] == '.') {\n\t\ts[0][4] = 'P';\n\t\tprint();\n\t}\n\telse if (s[1][3] == '.') {\n\t\ts[1][3] = 'P';\n\t\tprint();\n\t}\n\telse if (s[1][4] == '.') {\n\t\ts[1][4] = 'P';\n\t\tprint();\n\t}\n\telse if (s[0][0] == '.') {\n\t\ts[0][0] = 'P';\n\t\tprint();\n\t}\n\telse if (s[0][1] == '.') {\n\t\ts[0][1] = 'P';\n\t\tprint();\n\t}\n\telse if (s[0][6] == '.') {\n\t\ts[0][6] = 'P';\n\t\tprint();\n\t}\n\telse if (s[0][7] == '.') {\n\t\ts[0][7] = 'P';\n\t\tprint();\n\t}\n\telse if (s[1][0] == '.') {\n\t\ts[1][0] = 'P';\n\t\tprint();\n\t}\n\telse if (s[1][1] == '.') {\n\t\ts[1][1] = 'P';\n\t\tprint();\n\t}\n\telse if (s[1][6] == '.') {\n\t\ts[1][6] = 'P';\n\t\tprint();\n\t}\n\telse if (s[1][7] == '.') {\n\t\ts[1][7] = 'P';\n\t\tprint();\n\t}\n\telse if (s[3][3] == '.') {\n\t\ts[3][3] = 'P';\n\t\tprint();\n\t}\n\telse if (s[3][4] == '.') {\n\t\ts[3][4] = 'P';\n\t\tprint();\n\t}\n\telse if (s[4][3] == '.') {\n\t\ts[4][3] = 'P';\n\t\tprint();\n\t}\n\telse if (s[4][4] == '.') {\n\t\ts[4][4] = 'P';\n\t\tprint();\n\t}\n\telse if (s[5][3] == '.') {\n\t\ts[5][3] = 'P';\n\t\tprint();\n\t}\n\telse if (s[5][4] == '.') {\n\t\ts[5][4] = 'P';\n\t\tprint();\n\t}\n\telse if (s[6][3] == '.') {\n\t\ts[6][3] = 'P';\n\t\tprint();\n\t}\n\telse if (s[6][4] == '.') {\n\t\ts[6][4] = 'P';\n\t\tprint();\n\t}\n\telse if (s[3][0] == '.') {\n\t\ts[3][0] = 'P';\n\t\tprint();\n\t}\n\telse if (s[3][1] == '.') {\n\t\ts[3][1] = 'P';\n\t\tprint();\n\t}\n\telse if (s[3][6] == '.') {\n\t\ts[3][6] = 'P';\n\t\tprint();\n\t}\n\telse if (s[3][7] == '.') {\n\t\ts[3][7] = 'P';\n\t\tprint();\n\t}\n\telse if (s[4][0] == '.') {\n\t\ts[4][0] = 'P';\n\t\tprint();\n\t}\n\telse if (s[4][1] == '.') {\n\t\ts[4][1] = 'P';\n\t\tprint();\n\t}\n\telse if (s[4][6] == '.') {\n\t\ts[4][6] = 'P';\n\t\tprint();\n\t}\n\telse if (s[4][7] == '.') {\n\t\ts[4][7] = 'P';\n\t\tprint();\n\t}\n\telse if (s[5][0] == '.') {\n\t\ts[5][0] = 'P';\n\t\tprint();\n\t}\n\telse if (s[5][1] == '.') {\n\t\ts[5][1] = 'P';\n\t\tprint();\n\t}\n\telse if (s[5][6] == '.') {\n\t\ts[5][6] = 'P';\n\t\tprint();\n\t}\n\telse if (s[5][7] == '.') {\n\t\ts[5][7] = 'P';\n\t\tprint();\n\t}\n\telse if (s[6][0] == '.') {\n\t\ts[6][0] = 'P';\n\t\tprint();\n\t}\n\telse if (s[6][1] == '.') {\n\t\ts[6][1] = 'P';\n\t\tprint();\n\t}\n\telse if (s[6][6] == '.') {\n\t\ts[6][6] = 'P';\n\t\tprint();\n\t}\n\telse if (s[6][7] == '.') {\n\t\ts[6][7] = 'P';\n\t\tprint();\n\t}\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6880e1056e7e779d9f51e4aa8446d635", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include\n#define ll long long\n#define ld long double\n#define all(x) (x.begin()),(x.end())\n#define allr(x) (x.rbegin()),(x.rend())\n#define sz(x) ((ll)x.size())\n#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);\nusing namespace std;\n#ifdef LOCAL\n#include \"uj.h\"\n#endif\n\nconst long long mod = 1e9 + 7;\nll a,b;\nvoid test_case(){\n\tcin >> a >> b;\n\tll l = b+1,r = 1ll * a * b + 1;\n\t\n\tauto f = [&](ll x){\n\t\tll lr = x*l,rr = r*x;\n\t\tint modval1 = x - lr%b,modval2 = x - rr%b;\n\t\tif(modval1 < 0) modval1 += b;\n\t\tif(modval2 < 0) modval2 += b;\n\t\tlr += modval1;\n\t\trr += modval2;\n\t\t//debug() << owo(lr) owo(rr) owo(x);\n\t\tll n = (rr - lr)/(b*x) + 1;\n\t\tassert(n>=0);\n\t\tll res = (n*(lr + rr))/2;\n\t\treturn res;\n\t};\n\t\n\tll ans = 0;\n\tfor(int i = 1;i> tt;\n\ttt = 1;\n\t\n\tfor(int i = 0;i\nusing namespace std;\n\ntypedef long long ll;\n\nconst int MAX_N = 100030; // Change as necessary\nconst ll MODD = 1000000009; //\n\nvoid do_case(){\n ll n; cin >> n;\n \n n = (720+n)%360;\n ll m = n;\n \n ll best = min(n,360-n),ctr = 0,best_ctr = 0;\n while(ctr == 0 || m != n){\n n = (n+270)%360;\n ctr++;\n if(best > min(n,360-n)){\n best = min(n,360-n);\n best_ctr = ctr;\n }\n }\n cout << best_ctr << endl;\n}\n\nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n \n do_case();\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f96bac4277d137793e550f5bff6ab8a3", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\nint main(){\n int n,zero=0,one=0,i,j;\n string s;\n cin>>n;\n cin>>s;\n //for(i=0;i<89;i++)s+='1';\n for(i=0;i0){\n cout<0)cout<\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nsigned main() {\n\tll n, m, k;\n\tcin >> n >> m >> k;\n\tll l = 0, r = m + 1;\n\twhile (r - l > 1) {\n\t\tll mid = (l + r) / 2, L, R;\n\t\tif (mid >= k)\n\t\t\tL = (k - 1) * (mid - 1 + mid - (k - 1)) / 2;\n\t\telse\n\t\t\tL = (mid - 1) * mid / 2 + k - mid;\n\t\tif (mid - 1 >= n - k)\n\t\t\tR = (n - k) * (mid - 1 + mid - (n - k)) / 2;\n\t\telse\n\t\t\tR = (mid - 1) * mid / 2 + n - k - (mid - 1);\n\t\t//cout << mid << ' ' << L << ' ' << R << endl;\n\t\tif (L + R + mid <= m) {\n\t\t\tl = mid;\n\t\t}\n\t\telse {\n\t\t\tr = mid;\n\t\t}\n\t}\n\tcout << l;\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a35f4ab6970b174158d0c49a6eae553c", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n\nint main(){\n\tint n;\n\tscanf(\"%d\", &n);\n\tstd::vector a(1 + n);\n\tint sum = 0;\n\t\n\tfor(int i = 1; i <= n; i++){\n\t\tscanf(\"%d\", &a[i]);\n\t\tsum += a[i];\n\t}\n\t\n\tint sum1 = 0;\n\tint l = 1;\n\tint r = 0;\n\tfor(int i = 1; i <= n; i++){\n\t\tsum1 += a[i];\n\t\tr = i;\n\t\tif(sum - sum1 != 0){\n\t\t\tprintf(\"YES\\n\");\n\t\t\tprintf(\"2\\n\");\n\t\t\tprintf(\"%d %d\\n\", l, r);\n\t\t\tprintf(\"%d %d\", r + 1, n);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tprintf(\"NO\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f73c06d7ffd6808627214346e7b92283", "src_uid": "3a9258070ff179daf33a4515def9897a", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nstruct state\n{\n string a , b , c ;\n int n;\n state() {};\n state(int _n , string _a , string _b , string _c) : n(_n) , a(_a) , b(_b) , c(_c) {};\n};\n\nint n;\nstring card[60];\n\n\nset > > > was;\n\nint main()\n{\nscanf(\"%d\",&n);\nfor (int i = 1 ; i <= n ; i ++ )\n cin >> card[i];\nqueue q;\nq.push(state(n , card[n - 2] , card[n - 1] , card[n]) );\nwhile ( !q.empty() )\n{\n state v = q.front();\n q.pop();\n if ( was.find(make_pair(v.n , make_pair(v.a , make_pair(v.b , v.c)))) != was.end() )\n continue;\n was.insert(make_pair(v.n , make_pair(v.a , make_pair(v.b , v.c))));\n if ( v.n == 1 )\n {\n printf(\"YES\\n\");\n return 0;\n };\n if ( v.n - 3 > 0 && (card[v.n - 3][0] == v.c[0] || card[v.n - 3][1] == v.c[1]) )\n q.push(state(v.n - 1 , v.c , v.a , v.b) );\n if ( v.b[0] == v.c[0] || v.b[1] == v.c[1] )\n {\n if ( v.n > 3 )\n q.push(state(v.n - 1 , card[v.n - 3] , v.a , v.c) );\n if ( v.n == 3 )\n q.push(state(v.n - 1 , \"aa\" , v.a , v.c) );\n if ( v.n == 2 )\n q.push(state(v.n - 1 , \"aa\" , \"aa\" , v.c) );\n };\n};\nprintf(\"NO\\n\");\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "59114699cef105402bc843bf5d2a2663", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n #include\n #include\n #include\n #include\n #include\n #include\n #include\n\nusing namespace std;\n\n\nint main(){\n int a,b,j,i,c1=0,c2=0,c3=0,mid=0;\n cin>>a>>b;\n mid=(a+b)/2;\n if((2*mid)==(a+b)) c2=1;\n i=mid;\n j=mid;\n if(c2) {i--;j++;}\n else j++;\n \n while(i-->0) c1++;\n while(j++<7) c3++;\n\n if(a<=b) cout<\n#include \n\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define MOD 1000000009\n#define PI 3.1415926535897932384626433832795\n#define oo 1e9\n#define pb push_back\n\nusing namespace std;\n\nstruct point {\n double x, y, z;\n\n point() {\n x, y, z = 0;\n }\n\n point(double x, double y, double z) {\n this->x = x;\n this->y = y;\n this->z = z;\n }\n\n point(point &p) {\n x = p.x;\n y = p.y;\n z = p.z;\n }\n\n double &operator[](int i) {\n switch (i) {\n case 0:\n return x;\n case 1:\n return y;\n case 2:\n return z;\n }\n }\n\n void toString() {\n// printf(\"(%.2f, %.2f, %.2f)\", x, y, z);\n }\n\n};\n\n//struct line {\n// point p1, p2;\n//\n// line() {}\n//\n// line(point p1, point p2) {\n// this->p1 = p1;\n// this->p2 = p2;\n// }\n//\n//};\n//\n//struct side {\n//\n// line l1, l2;\n// ll n;\n//\n// side() {}\n//\n// side(line l1, line l2) {\n// this->l1 = l1;\n// this->l2 = l2;\n// }\n//};\n\npoint a, b;\n//side box[6];\n//\n//void createSide(int d1, int d2, int d3, int n, side &s) {\n// point p1, p2, p3, p4;\n// p2[d1] = b[d1];\n// p2[d2] = b[d2];\n// p3[d1] = b[d1];\n// p4[d2] = b[d2];\n// if (d3 != -1) {\n// p1[d3] = b[d3];\n// p2[d3] = b[d3];\n// p3[d3] = b[d3];\n// p4[d3] = b[d3];\n// }\n// line l1(p1, p2), l2(p3, p4);\n// side ss(l1, l2);\n// s = ss;\n// s.n = n;\n//}\n\npoint arr[6];\nint m[6];\n\npair planeEquation[6];\npoint mn[6];\npoint mx[6];\n\nint f(point p1, point p2, int ii) {\n\n double x= p2.x;\n\n// cout< pe = planeEquation[i];\n if(p2[pe.first]==0){\n return 0;\n }\n double t = (pe.second - p1[pe.first]) / (double) p2[pe.first];\n point p(p1.x + (t * p2.x), p1.y + (t * p2.y), p1.z + (t * p2.z));\n p[pe.first] = pe.second;\n// cout<<\"\\t\"<= mn[i].x && p.x <= mx[i].x &&\n p.y >= mn[i].y && p.y <= mx[i].y &&\n p.z >= mn[i].z && p.z <= mx[i].z) {\n if(t> a.x >> a.y >> a.z;\n cin >> b.x >> b.y >> b.z;\n\n planeEquation[0] = {1, 0};\n planeEquation[1] = {1, b.y};\n planeEquation[2] = {2, 0};\n planeEquation[3] = {2, b.z};\n planeEquation[4] = {0, 0};\n planeEquation[5] = {0, b.x};\n\n mn[0] = point(0, 0, 0);\n mn[2] = point(0, 0, 0);\n mn[4] = point(0, 0, 0);\n mx[0] = point(b.x, 0, b.z);\n mx[2] = point(b.x, b.y, 0);\n mx[4] = point(0, b.y, b.z);\n\n mn[1] = point(0, b.y, 0);\n mn[3] = point(0, 0, b.z);\n mn[5] = point(b.x, 0, 0);\n mx[1] = b;\n mx[3] = b;\n mx[5] = b;\n\n\n arr[0].x = b.x / 2.0;\n arr[0].y = 0;\n arr[0].z = b.z / 2.0;\n\n arr[1].x = b.x / 2.0;\n arr[1].y = b.y;\n arr[1].z = b.z / 2.0;\n\n arr[2].x = b.x / 2.0;\n arr[2].y = b.y / 2.0;\n arr[2].z = 0;\n\n arr[3].x = b.x / 2.0;\n arr[3].y = b.y / 2.0;\n arr[3].z = b.z;\n\n arr[4].x = 0;\n arr[4].y = b.y / 2.0;\n arr[4].z = b.z / 2.0;\n\n arr[5].x = b.x;\n arr[5].y = b.y / 2.0;\n arr[5].z = b.z / 2.0;\n\n for (int i = 0; i < 6; i++) {\n cin >> m[i];\n // arr[i].toString();\n }\n\n int res = 0;\n\n for (int i = 0; i < 6; i++) {\n res += f(a, arr[i], i);\n// cout<\n#define pb push_back\n#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)\n#define ll long long\n#define fr first\n#define sc second\nusing namespace std;\nint main()\n{\n ///freopen(\"input.txt\" , \"r\" , stdin );\n ///freopen(\"output.txt\", \"w\" , stdout );\n ///Murtazoev_2007\n speed ;\n ///Autor of the greatest code :: Ahmadjon Murtazoev\n system(\"color a\") ;\n ll a , b , z ;\n cin >> a >> b ;\n z = b ;\n while (z -- )\n {\n if (a%b == 0)\n {\n break ;\n }\n cout << a/b << \" \" ;\n a -= a/b ;\n b -- ;\n }\n for (ll i = 0 ; i\nusing namespace std;\ntypedef __int64 LL;\nint main()\n{\n LL a,s=1e18;\n scanf(\"%I64d\",&a);\n LL mov=a-(9*((s*9)%a))%a;\n printf(\"%I64d %I64d\\n\",mov,s+mov-1);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "244e1501ef3adb1d59c60c9c1808ac55", "src_uid": "52b8d97f216ea22693bc16fadcd46dae", "difficulty": 2500.0} {"lang": "GNU C++0x", "source_code": "#include\n#define inf 1000000007\n#define fs first\n#define sc second\n#define pb push_back\n#define mp make_pair\nusing namespace std;\nint n1,n2,x,y;\n\nint bns()\n{\n\tint s = 0,e = inf,tmp,t1;\n\twhile(s(n1+n2)){\n\t\t\te = tmp;\n\t\t}\n\t\telse if(t1<(n1+n2)){\n\t\t\tif(tmp==s)\n\t\t\t\treturn e;\n\t\t\ts = tmp;\n\t\t}\n\t\telse\n\t\t\treturn tmp;\n\t\t//cout<>t;\n\twhile(t--){\n\t\tcin>>n1>>n2>>x>>y;\n\t\tcout<\n#include \nusing namespace std;\n\nint main() {\n int n,m,a,b;\n double ra,rb;\n long long mon=0;\n scanf(\"%d%d%d%d\",&n,&m,&a,&b);\n if(m>n){\n if(n*a<=b){\n mon=n*a;\n n=-1;\n }\n else{\n mon=b;\n }\n \n }\n else{\n if(b<=a*m && n>0){\n n-=m;\n mon+=b;\n while(n>=m){\n n-=m;\n mon+=b;\n }\n \n }\n if(n>0){\n if(b>n*a)\n mon+=(n*a); \n else\n mon+=b;\n }\n \n }\n cout<\nusing namespace std;\n\nint main()\n{\n\tint number;\n\tint kNumber;\n\twhile ( cin >> number )\n\t{\n\t\tcin>>kNumber;\n\t\tcout<<(3 * number - kNumber)<\nusing namespace std;\n#define INF 0x3f3f3f3f\n#define sp ' '\n#define nl '\\n'\nvoid sc(){}templatevoid sc(T&t,A&...a){cin>>t,sc(a...);}\nvoid pr(){}templatevoid pr(T t,A...a){cout< pii;\nint n, ans;\nstring s;\nqueue q;\nint main(){\n\tcin.sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\tsc(n, s);\n\tq.push(s);\n\twhile(sz(q)){\n\t\tstring p = q.front(); q.pop();\n\t\tans = max(ans, n - sz(p));\n\t\tif (sz(p) == 1) continue;\n\t\tfor (int i = 0; i < sz(p); i++){\n\t\t\tbool flag = 0;\n\t\t\tif (i){\n\t\t\t\tif (p[i] - 1 == p[i - 1]) flag = 1;\n\t\t\t}\n\t\t\tif (i < sz(p) - 1){\n\t\t\t\tif (p[i] - 1 == p[i + 1]) flag = 1;\n\t\t\t}\n\t\t\tif (flag) q.push(p.substr(0, i) + p.substr(i + 1, sz(p) - i));\n\t\t}\n\t}\n\tpr(ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "75f9efe74fd56ef87d01127888bd8000", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n#define ll long long int\n#define FASTIO std::ios::sync_with_stdio(false);\n#define pb push_back\n#define mp make_pair\n#define ld long double\n#define F first\n#define S second\n#define input_from_file freopen(\"input.txt\", \"r\", stdin);\nusing namespace std;\nint main()\n{\nFASTIO\ninput_from_file\nint n;\ncin>>n;\nint v[n];\nstd::vector a;\nfor(int i=0;i>v[i];\n}\nfor(int i=0;i<(n-1);i++)\n{\nif((v[i]==2 && v[i+1]==3)||(v[i]==3)&&(v[i]==2))\n{\n a.pb(1);\n}\nelse if(v[i]==v[i+1])\n{\n a.pb(1);\n}\nelse\n{\n a.pb(0);\n}\n}\nsort(a.rbegin(),a.rend());\nif(v[0]==1)\n{\n std::cout << \"Infinite\" << '\\n';\n}\nelse\n{\n std::cout << \"Finite\"<< '\\n';\nint cnt=0;\nfor(int i=0;i<(n-1);i++)\n{\n if((v[i]==1)&&(v[i+1]==2)||(v[i]==2)&&(v[i+1]==1))\n {\n cnt=cnt+3;\n }\n else if((v[i]==1)&&(v[i+1]==3)||(v[i]==3)&&(v[i+1]==1))\n {\n cnt=cnt+4;\n }\n if((i-1)>=0 && v[i]==1 && v[i+1]==2 && v[i-1]==3)\n {\n cnt--;\n }\n}\ncout<\nusing namespace std;\nint main()\n{\n\tint n, x[5], y[5],i=0,s=-1,j=0;\n\tcin >> n;\n\t\t\twhile (i > x[i] >> y[i];\n\t\t\t\ti++;\n\t\t\t}\n\t\t\ti--;\n\t\t\tif (n == 1) { s = -1; }\n\t\t\tif (n==2)\n\t\t\t{\n\t\t\t\ts = (x[i] - x[i - 1])*(y[i] - y[i - 1]);\n\t\t\t}\n\t\t\tif (n == 3 || n==4 )\n\t\t\t{\n\t\t\t\tj = i - 1;\n\t\t\t\twhile (x[i]==x[j]||y[i]==y[j])\n\t\t\t\t{\n\t\t\t\t\tj--;\n\t\t\t\t}\n\t\t\t\ts = (x[i] - x[j])*(y[i] - y[j]);\n\t\t\t}\n\t\t\tif (s < 0)\n\t\t\t{\n\t\t\t\ts=s*(-1);\n\t\t\t}\n\t\t\tcout << s << endl;\n\t\t\tsystem(\"pause\");\n\t\t\t\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6e6955eefd6d352a572c5e3223f357cf", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "\n#include\n\nusing namespace std;\nint main()\n{\n int a,b,dif,A,B;\n cin >> a >> b;\n if(a+b>0)\n {\n while(1)\n {\n A = a*2;\n B = b*2-1;\n if(a>b)\n {\n a = a*2;\n b = b*2-1;\n dif = a-b+1;\n if(dif==4) cout << \"YES\";\n if(dif!=4) cout << \"NO\";\n break;\n }\n if(a==b)\n {\n cout << \"YES\";\n break;\n }\n if(A\n\nvoid main() {\n freopen(\"INPUT.TXT\", \"r\", stdin);\n freopen(\"OUTPUT.TXT\", \"w\", stdout);\n\tint x = 0;\n\tint y = 0;\n\tint res = 0;\n\tscanf(\"%d %d\", &x,&y);\n\tif(((x > 0) & (y > 0))|((x < 0) & (y < 0))) {\n\t\tif(x < 0) {\n\t\t\tx *= -1;\n\t\t}\n\t\tif(y < 0) {\n\t\t\ty *= -1;\n\t\t}\n\t\tres = x + y;\n\t\tif(res/2 == 0) {\n\t\t\tprintf(\"white\");\n\t\t}else{\n\t\t\tprintf(\"black\");\n\t\t}\n\t\treturn;\n\t}\n\tif(((x < 0) & (y > 0))|((x > 0) & (y < 0))) {\n\t\tif(x < 0){\n\t\t\tx *= -1;\n\t\t}\n\t\tif(y < 0){\n\t\t\ty *= -1;\n\t\t}\n\t\tres = x + y;\n\t\tif(res/2 == 1) {\n\t\t\tprintf(\"white\");\n\t\t}else{\n\t\t\tprintf(\"black\");\n\t\t}\n\t\treturn;\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e57be2fb92e56753e4f64458897f6b04", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "MS C++ 2017", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tint n,p,k;\n\n\tcout << \"insert n, p, k \" << endl;\n\t////n\n\tcin >> n;\n\t/*while (n < 3 || n > 100)\n\t{\n\t\tcout << \"wrong n \";\n\t\tcin >> n;\n\t}\n\tcout << n << endl;*/\n\t///p\n\tcin >> p;\n\t/*while (1 > p || p > n)\n\t{\n\t\tcout << \"wrong p \";\n\t\tcin >> p;\n\t}\n\tcout << p << endl;\n\t///k*/\n\tcin >> k;\n\t/*while (1 > k || k > n)\n\t{\n\t\tcout << \"wrong k \";\n\t\tcin >> k;\n\t}\n\tcout< 1)cout << \"<< \";\n\t/*for (int i = p - k; i <= p + k && i < n; i++)\n\t{\n\t\tif (i == p) cout << \"(\" << p << \") \";\n\t\telse if (i > 1) cout << i << \" \";\n\t}*/\n\tint i = p - k;\n\twhile (i <= p + k )\n\t{\n\t\tif (i == p) cout << \"(\" << p << \") \";\n\t\telse if (i > 1) cout << i << \" \";\n\t\ti++;\n\t}\n\tif (p + k < n) cout << \" >>\";\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e5f2017297bdb60a65118a452793f8b7", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "GNU C++17", "source_code": "//author ----> noobiesAG\n\n#include\n#include // Common file\n#include \nusing namespace std;\nusing namespace __gnu_pbds;\n\n#define int long long\n#define double long double\n#define pb push_back\n#define mp make_pair\n#define ld long double\n#define vi vector\n#define vvi vector>\n#define vpii vector>\n#define pii pair\n#define mii map\n#define umap unordered_map\n#define all(c) c.begin(),c.end()\n#define si(c) (int)c.size()\n#define lb lower_bound\n#define ub upper_bound\n#define gi greater\n#define rev reverse\n#define ff first\n#define ss second\n#define yes cout << \"YES\" << endl\n#define no cout << \"NO\" << endl\n#define ayes cout << \"Yes\" << endl\n#define ano cout << \"No\" << endl\n#define nl cout << endl\n#define hello cerr << \"hello\" << endl\n#define sp(x) fixed << setprecision(x)\n#define re return\n#define p_q priority_queue\n#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)\n\ntypedef tree, rb_tree_tag,tree_order_statistics_node_update>ordered_set;\ntypedef tree, rb_tree_tag,tree_order_statistics_node_update>ordered_multiset;\n//find_by_order(k) --> value at kth index (iterator)\n//order_of_key(k) --> index of value k\n\nvoid dbg_out(){cerr << endl;}\ntemplate void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }\n#define dbg(...) cerr << \"(\" << #__VA_ARGS__ << \"):\", dbg_out(__VA_ARGS__)\n\nconst double pi = 3.14159265359;\nconst int mod = 1000000007;\nconst int modc = 998244353;\nconst int inf = LLONG_MAX;\nconst int neg_inf = LLONG_MIN;\n\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //use rng() instead of rand() //shuffle(all(a),rng)\n\nint inline power(int a, int b, int p){\n a %= p;\n int ans = 1;\n while(b>0){\n if(b & 1)\n ans = (ans*a)%p;\n a = (a*a)%p;\n b >>= 1;\n }\n return ans;\n}\n\nint mod_inv(int n, int p){\n return power(n,p-2, p);\n}\n\nbool inline isPrime(int n) {\n if (n <= 1) return false;\n if (n <= 3) return true;\n if (n%2 == 0 || n%3 == 0) return false;\n for (int i=5; i*i<=n; i=i+6)\n if (n%i == 0 || n%(i+2) == 0)\n return false;\n return true;\n}\ntemplate\nvoid W(T&&... args)\n{\n\t((cout << sp(17) << args << \" \"), ...);\n\tnl;\n}\ntemplate\nvoid R(T&&... args)\n{\n\t((cin >> args), ...);\n}\nint ston(string s) \n{\n\tint a = 0;\n\treverse(s.begin(),s.end());\n\tint pow = 1;\n\tfor(int i=0;i\nstring to_binary(T n) \n{\n\tstring binaryNum;\n\tint i = 0;\n\twhile (n > 0) {\n\t\tbinaryNum.pb((n % 2)+'0');\n\t\tn = n / 2;\n\t\ti++;\n\t}\n\tif(si(binaryNum) == 0)\n\t\tbinaryNum.pb('0');\n\treverse(binaryNum.begin(),binaryNum.end());\n\treturn binaryNum;\n}\nint bton(string &s, int base)\n{\n\tint ans = 0;\n\tint pow = 1;\n\trev(all(s));\n\tfor(auto x : s)\n\t{\n\t\tif(x >= 'a' && x <= 'z')\n\t\t\tans += (x - 'a' + 10)*pow;\n\t\telse\n\t\t\tans += (x-'0')*pow;\n\t\tpow *= base;\n\t}\n\treturn ans;\n}\ntemplate\nvoid wv(T &v)\n{\n\tfor(auto x : v)\n\t\tcout << x << \" \" ;\n\tnl;\n}\ntemplate\nvoid rv(T &v)\n{\n\tfor(int i=0;i> v[i];\n}\n\nstruct custom_hash {\n static uint64_t splitmix64(uint64_t x) {\n // http://xorshift.di.unimi.it/splitmix64.c\n x += 0x9e3779b97f4a7c15;\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\n return x ^ (x >> 31);\n }\n\n size_t operator()(uint64_t x) const {\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n return splitmix64(x + FIXED_RANDOM);\n }\n};\nconst int M = 5e5;\n/*\nint fact[M];\nint ncr(int n, int r)\n{\n\tint ans = fact[n];\n\tint denom = (fact[r]*fact[n-r])%mod;\n\tans = (ans * mod_inv(denom,mod))%mod;\n\treturn ans;\n}\n*/\n//vectorv[M];\n\nvoid solve()\n{\n\tint i,j,sum = 0,prod = 1,maxl = neg_inf, minl = inf;\n\tint n;\n\tcin >> n;\n\tvectorv;\n\tfor(i=0;im;\n\tint cnt = 0;\n\tdo\n\t{\n\t\tstring temp;\n\t\tfor(auto x : v)\n\t\t\tif(x != 'a')\n\t\t\t\ttemp.pb(x);\n\t\tif(m[temp] == 0)\n\t\t{\n\t\t\tcnt++;\n\t\t\tm[temp] = 1;\n\t\t}\n\t}while(next_permutation(all(v)));\n\t//ncr\n\tint numerator = 1;\n\tint denominator = 1;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tnumerator *= i;\n\t\tif(i <= n/2)\n\t\t\tdenominator *= i*i;\n\t}\n\tcnt *= cnt;\n\tcnt *= numerator/denominator;\n\tcout << cnt/2 << endl;\n}\nint32_t main()\n{\n\tFAST;\n\tint t = 1;\n\t/*\n\tfact[0] = 1;\n\tfor(int i = 1;i\n#include \nusing namespace std;\nint a[113444523];\nint main(){\n string e;\n cin>>e;\n int b;\n for(b=0;b\n#define ll long long\nusing namespace std;\nll n,X,Y,C,ans,xx;\nvectorx1,x2,a;\nll c[2][1000010];\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin>>n>>X>>Y;\n\tif(Y%X)\n\t{\n\t\tcout<<0<>a;\n\t\txx=__gcd(xx,a);\n\t\tif(a%X==0)x1.push_back(a/X);\n\t\tif(Y%a==0)x2.push_back(Y/a);\n\t}\n\tif(C!=1)\n\t{\n\t\tif(xx!=1)a.push_back(xx);\n\t\tC/=xx;\n\t\tif(C!=1)a.push_back(C);\n\t}\n\t// for(ll i=0;i\n#include \n#include \nusing namespace std;\n\nlong long X1,X2;\nlong long WR1,WR2;\nlong long T1,T2,T0;\ndouble best=1000005;\n\nvoid Solve(void)\n{\n for(long long i=0 ; i<=X1 ; i++)\n {\n long long l=0,r=X2,mid=X2/2;\n while(i+mid && l<=r)\n {\n long long tmp=(long long)T1*i+T2*mid;\n double t=(double)tmp/(i+mid);\n if(t>=T0 && t=T0 && t==best && i+mid > WR1+WR2) { WR1=i; WR2=mid; }\n if(t<=T0) { l=mid+1; mid=(l+r)/2; }\n else { r=mid-1; mid=(l+r)/2; }\n }\n }\n}\n\nint main()\n{\n cin >> T1 >> T2 >> X1 >> X2 >> T0;\n Solve();\n cout << WR1 << ' ' << WR2 << endl;\n getch();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a1eab73cb2c5512c37d31e67cf3c894a", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef pair < int , int > Point;\nint main()\n{\n ios::sync_with_stdio(0);cin.tie(0);\n Point A;\n int i , steps ;\n cin>>A.first>>A.second;\n Point O{0,0};\n string S;\n cin>>S;\n\n for(i=0;i M;\n M[O]=1;\n for(i=0;i\nusing namespace std;\nint main()\n{\n while(1)\n {\n int tp=0;\n string ss[5]={\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"},s;\n cin>>s;\n for(int i=0;i<5;i++)\n {\n int p=s.find(ss[i]);\n if(p>=0)\n {\n tp++;\n s[p]='x';\n for(int j=0;j<5;j++)\n {\n int p=s.find(ss[j]);\n if((p>=0)||tp>1){cout<<\"NO\"<\nusing namespace std;\nconst int MAX = 100000000;\nmap, int> cache;\nmap, bool> is_cached;\nint query(int x, int y){\n if(is_cached[{x, y}]) return cache[{x, y}];\n printf(\"0 %d %d\\n\", x, y);\n fflush(stdout);\n int d;\n scanf(\"%d\", &d);\n is_cached[{x, y}] = true;\n cache[{x, y}] = d;\n return d;\n}\nvector queries;\nvoid solve(int lo, int hi){\n //printf(\"Solving %d - %d\\n\", lo, hi);\n int md = (lo + hi) / 2;\n int q = query(md, md);\n if(q == (md - lo)){\n if(md + q < hi){\n int p = query(md + q, md + q);\n if(p == 0) {\n //printf(\"Inserting %d\\n\", p);\n queries.push_back(p);\n }\n }\n return;\n }\n int pos1 = md - q;\n int p = query(pos1, pos1);\n int found = pos1;\n if(p) found = md + q;\n //printf(\"Inserting %d\\n\", found);\n queries.push_back(found);\n solve(lo, found);\n solve(found, hi);\n}\nint find_none(vector a){\n if(a[0] != -MAX) return -MAX;\n int i = 1;\n for(; i < a.size(); i++){\n if(a[i] != a[i - 1] + 1) break;\n }\n return a[i - 1] + 1;\n}\nvector vertical, horizontal;\nvoid resolve(vector pts){\n int none = find_none(pts);\n for(auto p : pts){\n int q1 = query(none, p);\n if(q1 == 0) horizontal.push_back(p);\n int q2 = query(p, none);\n if(q2 == 0) vertical.push_back(p);\n }\n printf(\"1 %d %d\\n\", vertical.size(), horizontal.size());\n for(auto x : vertical) printf(\"%d \", x); printf(\"\\n\");\n for(auto y : horizontal) printf(\"%d \", y); printf(\"\\n\");\n}\nint main(){\n int lo = query(-MAX, -MAX) - MAX;\n int hi = MAX - query(MAX, MAX);\n queries.push_back(lo);\n queries.push_back(hi);\n solve(lo, hi);\n sort(queries.begin(), queries.end());\n queries.resize(unique(queries.begin(), queries.end()) - queries.begin());\n resolve(queries);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26ef2d7534b2463fee58613c6ede7521", "src_uid": "583cd1e553133b297f99fd52e5ad355b", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\nll arr[100100],n,ans,temp,k,res,temp1;\nint main()\n{\n cin>>n>>k;\n for(int i=0;i>temp1;\n ans+=temp1;\n }\n cout<<(2*k-1)*n-2*ans<\n#include \n\nint main()\n{\n int x, y, i;\n std::vector a;\n scanf(\"%d %d\", &x, &y);\n if (x>y) i=1; else i=-1;\n while (x!=y) {\n int j;\n if (x>y) {\n j=x/y;\n x%=y;\n if (x==0) { x++; j--; }\n } else {\n j=y/x;\n y%=x;\n if (y==0) { y++; j--; }\n }\n a.push_back(j);\n }\n if (x!=1) printf (\"Impossible\");\n else for (int j=0; j\n\nusing namespace std;\nint dp[510][510][40];\nint bl(int l,int r)\n{\n if (l>r) return 0;\n int mi=1e9;\n for (int i=0;i<26;i++)\n mi=min(mi,dp[l][r][i]);\n return mi;\n}\nint main()\n{\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n ios_base::sync_with_stdio(0);\n int n;string st,s=\"\";\n cin>>n;\n cin>>st;\n s+='1';\n s+=st[0];\n for (int i=1;i=1;i--)\n {\n dp[i][i][s[i]-'a']=1;\n //cout<\nusing namespace std;\n#include\n#include\n#include\n#include\n#include\n#include\ntypedef string S;\ntypedef long long ll;\ntypedef long long int lli;\ntypedef unsigned int ui ;\ntypedef unsigned long long int ulli;\ntypedef double D;\ntypedef float f;\ntypedef int I;\n#define Clear(a) memset( a, 0, sizeof(a))\n#define sc scanf\n#define pf printf\n#define cn cin\n#define ct cout\n#define en endl\n#define pb push_back\n#define pp pop_back\n#define t_r true\n#define f_r false\n#define PI a(cos)\n#define FOR(i , x, y ) for( i = (x); i<=(y); i++ )\n#define ROR(i , x, y ) for( i = (x); i>=(y); i-- )\n#define N 100000\nint prime[N];\n\nint fibonacci( int n )\n{\n if(n<=1)return n;\n else return fibonacci(n-1)+fibonacci(n-2);\n}\nint GCD( int a, int b){\n if(b==0) return a;else return GCD(b,a%b);\n}\nint LCM( int a, int b)\n{\n return b = (a*b)/GCD(a,b);\n}\nvoid permutation(string ss)\n{sort(ss.begin(),ss.end());\n do{cout< number ){break;}}\n if( flag == true ){if( flag2 == true ){return true;}else{return false;}}\n else{if(flag2 == true){return true;}\n else{return false;}}}\n }\n int nCr_recurtion( int n , int r )\n {\n if( r==0||r==n)return 1;\n else return nCr_recurtion(n-1,r-1)+nCr_recurtion(n-1,r);\n }\n int nCr_n_complex( int n , int r)\n{\n int nr = (n-r);\n int a_n[n],a_r[r],a_nr[nr];\n for( int i = 1; i<=n; i++ ) a_n[i] = i;\n for( int j = 1; j<=r; j++ ) a_r[j] = j;\n for( int k = 1; k<=nr;k++ ) a_nr[k] = k;\n for( int i = 2; i<=nr; i++ ){\n for( int j = 2; j<=n; j++ ){\n if( a_n[j]%a_nr[i]== 0 && (a_n[j]!=1 && a_nr[i]!=1) ){\n if(a_n[j] == a_nr[i]){a_n[j] = 1;a_nr[i] = 1;}\n else{a_n[j] = a_n[j]/a_nr[i];a_nr[i] = 1;}}}}\n for( int i = 2; i<=r; i++ ){\n for( int j = 2; j<=n; j++ ){\n if( a_n[j]%a_r[i]== 0 && (a_n[j]!=1 && a_r[i]!=1) ){\n if(a_n[j] == a_r[i]){a_n[j] = 1;a_r[i] = 1;\n }\n else{a_n[j] = a_n[j]/a_r[i];a_r[i] = 1;}}}}\n int mul1 = 1;int mul2 = 1;int mul3 = 1;\n for( int i = 2; i<=n; i++ )mul1 = mul1*a_n[i];\n for( int j = 2; j<=nr; j++ )mul2 = mul2*a_nr[j];\n for( int k = 2; k<=r; k++ )mul3 = mul3*a_r[k];\n return mul1*mul2*mul3;\n\n}\nint main()\n{\n stackch;\n int t_c;\n string s;\n cin>>t_c;\n cin>>s;\n string gg = \"\";\n for( int i = 0; i\n#include \n#include \n#include \n#include \nusing namespace std;\n\nint n;\nint a[2100];\nint ans=0;\nint len;\n\nint fac(int n)\n{\n if(n==0) return 1;\n else return n*fac(n-1);\n}\n\nint main()\n{\n cin>>n;\n len=1;\n for(int i=1;i\nusing namespace std;\n\n#define ll long long\n#define debug(x) cerr << fixed << #x << \" is \" << x << endl;\n\nint hist[10];\nll dp[20][2][524290][2];\nvector dig;\n\npair isok(int mask, int digit)\n{\n\tint cnt = 0;\n\tfor(int i = 0; i < 10; i++)\n\t{\n\t\tfor(int j = 0; j < hist[i]; j++)\n\t\t{\n\t\t\tif(i == digit && (mask & (1 << cnt)))\n\t\t\t\treturn {true, mask & (~(1 << cnt))};\n\t\t\tcnt++;\n\t\t}\n\t\tif(i == digit)\n\t\t\treturn {false, 0};\n\t}\n\treturn {false, 0};\n}\n\nll solved(int mask)\n{\n\tint cnt = 0;\n\tbool ok2 = true;\n\tfor(int i = 0; i < 10; i++)\n\t{\n\t\tbool ok = 0;\n\t\tfor(int j = 0; j < hist[i]; j++)\n\t\t{\n\t\t\tok |= (mask & (1 << cnt)) == 0;\n\t\t\tcnt++;\n\t\t}\n\t\tif(hist[i] != 0)\n\t\t\tok2 &= ok;\n\t}\n\treturn (ll) ok2;\n}\n\nll dp_solve(int idx, bool lim, int mask, bool zero)\n{\n\tif(idx == -1)\n\t\treturn solved(mask);\n\n\tif(dp[idx][lim][mask][zero] != -1)\n\t\treturn dp[idx][lim][mask][zero];\n\n\tll ans = 0;\n\tint limit = lim ? 9 : dig[idx];\n\tfor(int i = 0; i <= limit; i++)\n\t{\n\t\tauto x = isok(mask, i);\n\t\tif(i == 0 && zero == true)\n\t\t\tans += dp_solve(idx-1, lim || i < dig[idx], mask, true);\n\t\telse if(x.first)\n\t\t\tans += dp_solve(idx-1, lim || i < dig[idx], x.second, false);\n\t}\n\n\treturn dp[idx][lim][mask][zero] = ans;\n}\n\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL);\n\n\tll n;\n\tcin >> n;\n\twhile(n)\n\t{\n\t\thist[n % 10]++;\n\t\tn /= 10;\n\t}\n\tfor(int i = 0; i < 20; i++)\n\t\tdig.push_back(9);\n\tint cnt = 0, mask = 0;\n\tfor(int i = 0; i < 10; i++)\n\t\tfor(int j = 0; j < hist[i]; j++)\n\t\t{\n\t\t\tmask |= 1 << cnt;\n\t\t\tcnt++;\n\t\t}\n\n\tmemset(dp, -1, sizeof dp);\n\tcout << dp_solve((int) dig.size()-1, 0, mask, 1) << endl;\n\n\treturn 0;\n}\n//0228\n//1111 -> 1011 (11 = 1+2+8)\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "55fe61c2ad7e3e652b8ac323cd5d0aaf", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define INF 0x3f3f3f3f\n#define Mn 510\n#define Mm 2000005\n#define mod 1000000007\n#define CLR(a,b) memset((a),(b),sizeof((a)))\n#define CLRS(a,b,Size) memset((a),(b),sizeof((a[0]))*(Size+1))\n#define CPY(a,b) memcpy ((a), (b), sizeof((a)))\n#pragma comment(linker, \"/STACK:102400000,102400000\")\n#define ul u<<1\n#define ur (u<<1)|1\nusing namespace std;\ntypedef long long ll;\nint g[Mn][Mn];\nint numb[Mn][Mn];\nint num[Mn*Mn];\nint cnt=0,n;\nint mini,minj;\nint maxi,maxj;\nint way[4][2]={0,1,1,0,-1,0,0,-1};\nint vis[Mn*Mn];\nvoid dfs(int x,int y) {\n g[x][y]=cnt;\n num[cnt]++;\n mini=min(mini,x); minj=min(minj,y);\n maxi=max(maxi,x);maxj=max(maxj,y);\n for(int i=0;i<4;i++) {\n int a=x+way[i][0];\n int b=y+way[i][1];\n if(a<1||b<1||a>n||b>n||g[a][b]!=-1) continue;\n dfs(a,b);\n }\n}\nint main() {\n int k;\n char s[510];\n scanf(\"%d%d\",&n,&k);\n getchar();\n for(int i=1;i<=n;i++) {\n scanf(\"%s\",s);\n for(int j=1;j<=n;j++) {\n if(s[j-1]=='.') g[i][j]=-1;\n else {\n g[i][j]=0;\n numb[i][j]+=1;numb[i+k][j]-=1;\n numb[i][j+k]-=1;numb[i+k][j+k]+=1;\n }\n }\n }\n cnt=0;\n for(int i=1;i<=n;i++) {\n for(int j=1;j<=n;j++) {\n if(g[i][j]==-1) {\n cnt++;mini=i,minj=j,maxi=i,maxj=j;\n dfs(i,j);\n if(maxi-mini+1<=k&&maxj-minj+1<=k) {\n numb[maxi][maxj]+=num[cnt];numb[maxi][minj+k]-=num[cnt];\n numb[mini+k][maxj]-=num[cnt];numb[mini+k][minj+k]+=num[cnt];\n }\n }\n }\n }\n for(int i=1;i<=n;i++) {\n for(int j=1;j<=n;j++) {\n numb[i][j]+=numb[i-1][j]+numb[i][j-1]-numb[i-1][j-1];\n //cout<\n#include \nusing namespace std;\nint kkksc03,x,mmax;\nint AK,IOI,NOIP=-1000;\nint main() {\n\tcin>>AK;\n\twhile(AK!=0) {\n\t\tcin>>IOI; \n\t\tNOIP=max(NOIP,IOI);\n\t}\n\tif (mmax<25) {\n\t\tcout<<\"0\"<\nusing namespace std;\nbool check1(char a[8][8], int i);\nbool check2(char a[8][8], int i);\nint main()\n{\n char a[8][8];\n int i=0,j=0,boo=0;\n for (i=0;i<8;i++)\n for (j=0;j<8;j++) cin>>a[i][j];\n i=0;j=0;\n while (i<8)\n {\n if (check1(a,i)==false||check2(a,i)==false) \n {\n boo=1;\n break;\n }\n else i++;\n }\n if (boo==1) cout<<\"NO\"<\n#define ff first\n#define ss second\n\nusing namespace std ;\n\nlong double PI = 3.14159265 ;\nconst int N = 2e6 + 1000 ;\nlong long int mn=N , ans , ans1 , cnt , fin;\nlong long int n , m , h , k , x , t1 , t2;\npair p[N];\nlong long int a[N] ;\nlong long int b[N] ;\nlong long int c[N] ;\nvector v[N] ;\nstring s[N] , t ;\nbool bb , vis[N] ;\nchar cc ; \n\nint main (){\n\tios::sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);\n\tcin >> n >> k >> m ;\n\tfor(int i =1 - k ; i <= 0 ; i++){\n\t\ta[i + k] = i ;\n\t}\n\tfor(int i = 1 ; i <= k ; i++){\n\t\ta[i] += m ;\n\t}\n\tfor(int i = 1 ; i <= k ; i++){\n\t\tif(a[i] > 0 && a[i] <= n){\n\t\t\tans++ ;\n\t\t}\n\t}\n\tcout << ans ;\n\treturn 0 ;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2e45386bd54c9bd0256c0225ab5e0ec2", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n\tint A, B, C, N;\n\tscanf(\"%d%d%d%d\", &A, &B, &C, &N);\n\tint x = N-(A+B-C);\n\tif (C > A || C > B || x <= 0) {\n\t\tprintf(\"-1\");\n\t\treturn 0;\n\t}\n\tprintf(\"%d\", x);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "23d9ee3da76075ffec60e2ff60790a80", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n\n#include \n#include \n#include \n#include >\n\n#include \n#include \n#include \n#include \n\n#include \n#include \n\nusing namespace std;\n\n#define ABS(a) (((a) < (0)) ? (-(a)) : (a))\n#define MIN(a, b) (((a) < (b)) ? (a) : (b))\n#define MAX(a, b) (((a) > (b)) ? (a) : (b))\n\n#define PI 3.14159265\n\n#define INF 1000000000\n\ntypedef long long int lint;\n\n\nint main()\n{\n\t//freopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n\n\tint n;\n\tcin >> n;\n\tcout << (n + 5) / 10 << '0';\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eabfc0663420584a7162f2d63a878295", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main()\n{\n\tunsigned long long a[4], res=-1;\n\tchar s[3];\n\tscanf(\"%I64d %I64d %I64d %I64d\", &a[0], &a[1], &a[2], &a[3]);\n\tcin>>s[0]>>s[1]>>s[2];\n\tvector v1[6];\n\tvector v2[18];\n\tint in=0;\n\tfor(int i=0; i<4; i++)\n\t{\n\t\tfor(int j=i+1; j<4; j++)\n\t\t{\n\t\t\tif(s[0]=='+')\n\t\t\t\tv1[in].push_back(a[i]+a[j]);\n\t\t\telse\n\t\t\t\tv1[in].push_back(a[i]*a[j]);\n\t\t\tfor(int k=0; k<4; k++)\n\t\t\t{\n\t\t\t\tif(k!=i && k!=j)\n\t\t\t\t\tv1[in].push_back(a[k]);\n\t\t\t}\n\t\t\tin++;\n\t\t}\n\t}\n\n\tin = 0;\n\tfor(int i=0; i<6; i++)\n\t{\n\t\tif(s[1] == '+')\n\t\t{\n\t\t\tv2[in].push_back(v1[i][0]+v1[i][1]);\n\t\t\tv2[in].push_back(v1[i][2]);\n\t\t\tin++;\n\n\t\t\tv2[in].push_back(v1[i][1]+v1[i][2]);\n\t\t\tv2[in].push_back(v1[i][0]);\n\t\t\tin++;\n\n\t\t\tv2[in].push_back(v1[i][2]+v1[i][0]);\n\t\t\tv2[in].push_back(v1[i][1]);\n\t\t\tin++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tv2[in].push_back(v1[i][0]*v1[i][1]);\n\t\t\tv2[in].push_back(v1[i][2]);\n\t\t\tin++;\n\n\t\t\tv2[in].push_back(v1[i][1]*v1[i][2]);\n\t\t\tv2[in].push_back(v1[i][0]);\n\t\t\tin++;\n\n\t\t\tv2[in].push_back(v1[i][2]*v1[i][0]);\n\t\t\tv2[in].push_back(v1[i][1]);\n\t\t\tin++;\n\t\t}\n\t}\n\n\tfor(int i=0; i<18; i++)\n\t{\n\t\tif(s[2]=='+')\n\t\t{\n\t\t\tif(res == -1 || v2[i][0]+v2[i][1]\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#ifdef DEBUG\n#define debug(...) fprintf(stderr, __VA_ARGS__)\n#else\n#define debug(...)\n#endif\n\nusing namespace std;\n\nlong long ans;\n\nlong long sobr(vector x){\n long long ans = 0;\n for(int i = 0; i < x.size(); i++){\n ans *= 10;\n ans += x[i];\n }\n return ans;\n}\n\nvector razl(long long x){\n vector v;\n while(x > 0){\n v.push_back(x % 10);\n x /= 10;\n }\n return v;\n}\n\nvoid per(int p, vector v){\n if(p == v.size()){\n if(!v.empty() && v[0] == 0)\n return;\n long long x = sobr(v);\n if(razl(x).size() == v.size()){\n ans = min(ans, x);\n }\n return;\n }\n per(p+1, v);\n v[p] = 9-v[p];\n per(p+1, v);\n}\n\nint main(){\n //freopen(\"webbuy.in\", \"r\", stdin);\n //freopen(\"webbuy.out\", \"w\", stdout);\n \n long long x;\n cin >> x;\n ans = x;\n \n vector v = razl(x);\n \n reverse(v.begin(), v.end());\n \n for(int i = 0; i < v.size(); i++){\n int inv = 9-v[i];\n if(inv == 0 && (i == 0 || v[i-1] == 0)) continue;\n if(inv < v[i])\n v[i] = inv;\n }\n \n for(int i = 0; i < v.size(); i++){\n cout << v[i];\n }\n \n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a00655fd2493febccf3b7af2fbdcdfc5", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": " // In the name of Allah\n // There is no power but from God the Almighty\n // No God except Allah\n #include \n #define mp make_pair\n #define f1 first\n #define f2 second\n #define pb push_back\n #define pii pair\n #define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n #define int long long\n using namespace std;\n const int mox=5e3+9;\n int dp[mox][mox];\n int td[mox*mox];\n int mod=1e9+7;\n int32_t main()\n {\n ios\n int n,k;\n cin>>n>>k;\n td[0]=1;\n for(int i=1 ; i<=(n*n) ; i++)\n {\n td[i]=(td[i-1]*2)%mod;\n }\n for(int i=0 ; i<=n ; i++)\n {\n dp[i][0]=1;\n }\n for(int i=1 ; i<=n ; i++)\n {\n for(int j=1 ; j<=k ; j++)\n {\n for(int w=1 ; w<=i ; w++)\n {\n int x=(td[(w*(i-w+1))]-(td[((w-1)*(i-w+1))])+mod)%mod;\n x=(x*dp[w-1][j-1])%mod;\n dp[i][j]=(dp[i][j]+x)%mod;\n }\n }\n }\n cout<\nusing namespace std;\nlong long n,k;\nlong long dp(long long cur){\n if (cur>n) return 0;\n long long ans=1;\n ans+=dp(cur*2);\n if (cur%2==0) ans+=dp(cur+1);\n return ans;\n}\nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cin>>n>>k;\n long long maxi=1;\n while (maxi\n#include\nint main(void)\n{\n int n, a[1000] = {0}, b[1000] = {0};\n int i, k, count, check = 1;\n\n scanf(\"%d\", &n);\n for ( i = 0, k = 1, count = 1; check == 1; i++, count++ ){\n a[(i+k)%n] = 1;\n k += i+1;\n if ( count % n == 0 ){\n b[i]++;\n if ( b[i] >= 2 )\n break;\n }\n }\n for ( i = 0; i < n; i++ )\n if ( a[i] == 0 )\n check = 0;\n\n if ( check == 1 )\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2038b38871bd9ea992f3b952863c0d82", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\n\nll gcd(ll a,ll b)\n{\n\tif (b == 0) return a;\n\telse gcd(b, a % b);\n}\n\nint main()\n{\n\n\tll a,b,x,y;\n\n\tcin >> a >> b >> x >> y;\n\t\n\tll g = gcd(x, y);\n\tx /= g; y /= g;\n\t\n\tll ans = min(a / x, b / y);\n\n\tcout << ans;\n\n\treturn 0;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e91e062a7e0a554f88b737a3e2721b5e", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main()\n{\n int m,n,l,s;\n cin>>m>>n;\n int k=1;\n while(k)\n {\n if(m%2!=0)\n {\n l=m/2;\n s=(l*n)+n/2;\n cout<\n#include \n#include \n#include \nusing namespace std;\n \n \nint main ()\n { long int n,i,a[7],s=0,k;\n cin>>n;\n for (i=0;i<7;i++) {cin>>a[i]; s+=a[i];}\n n=n%s; \n if (n==0) {for (i=6;i>=0;i--) if (a[i]>0) {cout<\nusing namespace std;\n#define ll long long \nll mod=1000000007, ai[105], bi[105], ci[105], di[105], n, m;\nll memo[14][2010][2010];\nll fac(ll n)\n{\n\tll i, prod=1;\n\tfor(i=1;i<=n;i++)\n\t\tprod=((i%mod)*(prod%mod))%mod;\n\treturn prod;\n}\nll power(ll x, ll y, ll p)\n{\n\tll res = 1; \n\tx = x % p; \n\twhile (y > 0)\n\t{\n\t\tif (y & 1)\n\t\t\tres = (res*x) % p;\n\t\ty = y>>1; // y = y/2\n\t\tx = (x*x) % p; \n\t}\n\treturn res;\n}\nll gcd(ll a, ll b)\n{\n\tif (a == 0 || b == 0)\n\t\treturn 0;\n\tif (a == b)\n\t\treturn a;\n\tif (a > b)\n\t\treturn gcd(a-b, b);\n\treturn gcd(a, b-a);\n}\nll dp(ll i, ll tempdo, ll tempstuf)\n{\n\t//printf(\"i:%lld and tempdo:%lld and tempstuf:%lld\\n\",i,tempdo,tempstuf);\n\tif(i>m+1)\n\t\treturn 0;\n\tif(tempdo>=n)\n\t\treturn 0;\n\n\tif(tempstuf+bi[i]<=ai[i] && tempdo+ci[i]<=n)\n\t{\n\t\tif(memo[i+1][tempdo][0]==-57)\n\t\t\tmemo[i+1][tempdo][0]=dp(i+1,tempdo,0);\n\t\tif(memo[i][tempdo+ci[i]][tempstuf+bi[i]]==-57)\n\t\t\tmemo[i][tempdo+ci[i]][tempstuf+bi[i]]=dp(i,tempdo+ci[i],tempstuf+bi[i]);\n\t\tmemo[i][tempdo][tempstuf]=max(memo[i+1][tempdo][0],di[i]+memo[i][tempdo+ci[i]][tempstuf+bi[i]]);\n\t\t//return max(dp(i+1,tempdo,0),di[i]+dp(i,tempdo+ci[i],tempstuf+bi[i]));\n\t}\n\telse\n\t{\n\t\tif(memo[i+1][tempdo][0]==-57)\n\t\t\tmemo[i+1][tempdo][0]=dp(i+1,tempdo,0);\n\t\tmemo[i][tempdo][tempstuf]=memo[i+1][tempdo][0];\n\t//\treturn dp(i+1,tempdo,0);\n\t}\n\treturn memo[i][tempdo][tempstuf];\n}\nint main()\n{\n\tll x, y, i, j, k, num, temp, fn, cnt=0, d, l, r, flag=0, sum1=0, a, b, len1=0, t, c0, d0;\n\tcin >> n >> m >> c0 >> d0;\n\tfor(i=1;i<=m;i++)\n\t\tcin >> ai[i] >> bi[i] >> ci[i] >> di[i];\n\tai[i]=n;bi[i]=0;ci[i]=c0;di[i]=d0;\n\tfor(i=0;i<14;i++)\n\t\tfor(j=0;j<2010;j++)\n\t\t\tfor(l=0;l<2010;l++)\n\t\t\t\tmemo[i][j][l]=-57;\n\tprintf(\"%lld\\n\",dp(1,0,0));\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "697e2122851d458993926b1d3842391b", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long llint;\n\n#define FOR(i, a, b) for (int i = (a); i < (b); ++i)\n#define REP(i, n) FOR(i, 0, n)\n#define TRACE(x) cout << #x << \" = \" << x << endl\n#define _ << \" _ \" <<\n\nstruct Position {\n llint t, x, q, p;\n friend bool operator < (const Position &a, const Position &b) {\n return a.q < b.q;\n }\n};\n\nint parity(llint x) {\n return abs(x) % 2;\n}\n\nllint ceil(llint a, llint b);\nllint floor(llint a, llint b);\n\nllint floor(llint a, llint b) {\n assert(b > 0);\n if (a < 0) return -ceil(-a, b);\n return a/b;\n}\n\nllint ceil(llint a, llint b) {\n assert(b > 0);\n if (a < 0) return -floor(-a, b);\n return (a+b-1) / b;\n}\n\nvoid no_solution() {\n puts(\"NO\");\n exit(0);\n}\n\nvoid solve(vector &v, int m, vector &ans) {\n sort(v.begin(), v.end());\n v.insert(v.begin(), {0, 0, 0, 0});\n v.push_back({-m, 0LL, m, -1});\n\n llint lo = -m, hi = +m;\n for (int i = 1; i < (int)v.size(); ++i) {\n llint d = v[i].q - v[i - 1].q;\n llint k = v[i].p - v[i - 1].p;\n llint x = v[i].x - v[i - 1].x;\n\n if (parity(x - k*(m%2)) != parity(d)) no_solution();\n\n if (k == 0) {\n if (abs(x) > d) no_solution();\n continue;\n }\n \n if (k > 0) {\n lo = max(lo, ceil(x-d, k));\n hi = min(hi, floor(x+d, k));\n } else {\n lo = max(lo, ceil(-d-x, -k));\n hi = min(hi, floor(d-x, -k));\n }\n }\n\n if (parity(lo) != parity(m)) lo++;\n if (parity(hi) != parity(m)) hi--;\n\n if (lo > hi) no_solution();\n\n llint bal = lo;\n\n for (int i = 1; i < (int)v.size(); ++i) {\n llint d = v[i].q - v[i - 1].q;\n llint k = v[i].p - v[i - 1].p;\n llint x = v[i].x - v[i - 1].x;\n \n llint sum = x - k * bal;\n assert(parity(sum) == parity(d));\n assert(abs(sum) <= d);\n\n while (sum) {\n if (sum > 0) ans.push_back(+1), sum--; else\n\tans.push_back(-1), sum++;\n d--;\n }\n\n assert(d%2 == 0);\n while (d > 0) {\n ans.push_back(+1);\n ans.push_back(-1);\n }\n }\n\n assert((int)ans.size() == m);\n}\n\nint main(void) {\n int n, m;\n scanf(\"%d %d\", &n, &m);\n\n static vector px, py;\n REP(i, n) {\n llint t, x, y;\n scanf(\"%lld %lld %lld\", &t, &x, &y);\n px.push_back({t, x + y, t % m, t / m});\n py.push_back({t, x - y, t % m, t / m});\n }\n \n static vector ansx, ansy;\n solve(px, m, ansx);\n solve(py, m, ansy);\n\n REP(i, m) {\n int dx = (ansx[i] + ansy[i]) / 2;\n int dy = (ansx[i] - ansy[i]) / 2;\n \n if (dx == +1 && dy == 0) putchar('R'); else\n if (dx == -1 && dy == 0) putchar('L'); else\n\tif (dx == 0 && dy == -1) putchar('D'); else\n\t if (dx == 0 && dy == +1) putchar('U'); else\n\t assert(false);\n }\n putchar('\\n');\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6dcd97b600411c868624ff8d179e1b6a", "src_uid": "941f1f8a37c25dd2405a20c7d416c9a6", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#define ll long long\n#define f(i,a,b) for(int i=(a);i<(b);i++)\n#define fd(i,a,b) for(ll i=(a);i>(b);i--)\n#define x first\n#define y second\n#define si(a) scanf(\"%d\",&a)\n#define sii(a,b) scanf(\"%d %d\",&a,&b)\n#define siii(a,b,c) scanf(\"%d %d %d\",&a,&b,&c)\n#define sl(a) scanf(\"%I64d\",&a)\n#define sll(a,b) scanf(\"%I64d %I64d\",&a,&b)\n#define slll(a,b,c) scanf(\"%I64d %I64d %I64d\",&a,&b,&c);\n#define pfci(n,ans) printf(\"Case %I64d: %d\\n\",n,ans)\n#define pfcl(n,ans) printf(\"Case %I64d: %I64d\\n\",n,ans)\n#define pfcd(n,ans) printf(\"Case %I64d: %lf\\n\",n,ans)\n#define pb push_back\n#define all(v) v.begin(),v.end()\n#define MOD 1000000009\n#define ld long double\n#define mp make_pair\nusing namespace std;\n#define INF 1e12\n#define EPS 1e-12\n//#define double long double\n#define PI 3.141592653589\n\nll n,m,k;\nvectorpwt;\n\nbool check( ll X)\n{\n if((X*k)>n) return false;\n ll rem = n- (X*k);\n ll cnt = X*k + (rem/k)*(k-1) +(rem%k);\n if(cnt>n>>m>>k;\n ll l=0;\n ll h=(m/k);\n pw(m/k+1);\n ll ans= k*(pwt[m/k])+(m%k);\n while(l<=h)\n {\n ll mid=(l+h)/2;\n if(check(mid))\n {\n ans = (pwt[mid+1] -2)*k + m-(mid*k);\n\n h=mid-1;\n }\n else l=mid+1;\n }\n ans = ans % MOD;\n cout<\n#include \nusing namespace std;\n\nint main() {\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n int g,d,max=0;\n cin >> g >> d;\n if (d>=g) {\n for ( int i=1; i<=d; i++) {\n if (d%i==0&&g%i==0) {\n max =i;\n }\n\n }\n } else {\n for ( int y=1; y<=g; y++) {\n if (d%y==0&&g%y==0) {\n max =y;\n }\n\n }\n }\n cout << max;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cbb04730407b0a56c98e6a00f8c07e7b", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include\n#include\nusing namespace std;\n\nvoid main(){\n\tlong long t, s, x;\n\tcin >> t >> s >> x;\n\tvectorv;\n\n\tif (x == t){\n\t\tcout << \"YES\";\n\t\treturn;\n\t}\n\tint i = 1;\n\twhile (true){\n\t\tv.push_back(t + i*s);\n\t\tv.push_back( t + i*s + 1);\n\t\t\n\t\tif (x <= t+i*s){\n\t\t\t\n\t\t\tbreak;\n\t\t}\n\t\ti++;\n\t}\n\n\tfor (int i = 0; i < v.size(); i++){\n\t\tif (x == v.at(i)){\n\t\t\tcout << \"YES\";\n\t\t\treturn;\n\t\t}\n\t}\n\n\tcout << \"NO\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "01f10928c120298188b61590800bf1e8", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\nusing namespace std;\n\nunsigned long long ncr(int n,int r)\n{\n\tunsigned long long tmp=1;\n\n\tif(r==0)return 1;\n\n\tfor(int i=r+1;i<=n;++i)\n\t{\n\t\ttmp*=i;\n\t\ttmp/=(i-r);\n\t}\n\n\treturn tmp;\n}\n\nint main()\n{\n\tint n,m,t;\n\n\tcin>>n>>m>>t;\n\n\tunsigned long long res=ncr(n,4)*m*ncr(n+m-5,t-5);\n\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define INF 0x3ffffffff\n#define N 50000010\nlong long f[N];\nlong long c,hr,hb,wr,wb;\nbool flag=true;\nlong long maxx,minn,res;\nint main()\n{\n\tcin>>c>>hr>>hb>>wr>>wb;\n\tif(hb*wr\nusing namespace std;\nchar first[10],last[10],login[10];\nint main()\n{\n int i,l;\n scanf(\"%s%s\",first,last);\n l=strlen(first);\n for(i=0;i<=l;i++)\n { if(i==0)\n {\n login[i]=first[i];\n }\n else if(first[i]last[0])\n {\n login[i]=last[0];\n break;\n }\n else if(first[i]==last[0])\n {\n login[i]=first[i];\n break;\n }\n if(i==l)\n {\n login[i]=last[0];\n }\n }\nprintf(\"%s\\n\",login);\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8f5e327bc50882d96e61f0a28d91e06a", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "////\n//// main.cpp\n//// codeforces\n////\n//// Created by Victor Young on 2/20/17.\n//// Copyright (c) 2017 Victor Young. All rights reserved.\n////\n//\n#include \n#include \n#define Max 0x0FFFFFFF\nusing namespace std;\nlong long log2_64(long long n) {\n long long logValue = -1;\n while (n) {//\n logValue++;\n n >>= 1;\n }\n return logValue;\n}\nlong long powi(long long base, long long exp)\n{\n long long res = 1;\n while (exp) {\n if (exp & 1)\n res *= base;\n exp >>= 1;\n base *= base;\n }\n return res;\n}\nlong long dfs(long long n,long long r,long long l){\n int mid = n%2;\n if (n==1) {\n if (r == l == 1) {\n return 1;\n }\n return 0;\n }\n long long len = powi(2,log2_64(n)+1)-1;\n if (r>l) {\n return 0;\n }\n if (r<=(len+1)/2 && l >= (len+1)/2) {\n if (r==1) {\n return n/2+mid+dfs(n/2, 1, l-(len+1)/2);\n }\n if (l==len) {\n return dfs(n/2, r, (len-1)/2)+mid+n/2;\n }\n return dfs(n/2, r, (len-1)/2)+mid+dfs(n/2, 1, l-(len+1)/2);\n }\n else if(r>(len+1)/2){\n return dfs(n/2, r-(len+1)/2, l-(len+1)/2);\n }\n else{\n return dfs(n/2, r, l);\n }\n}\n\nint main(int argc, const char * argv[]) {\n // insert code here...\n long long n,r,l;\n cin >> n >> r >> l;\n// if (r>n) {\n// r=n;\n// }\n cout << dfs(n,r,l);\n// cout << powi(n,r);\n// cout << log2_64(n);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "af9dd1de67270c0b29db250f6b8ef66d", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \n#define ll long long\n#define pb push_back\n#define s second\n#define f first\nusing namespace std;\nint const N=3e5+4,inf=1e9+7;\nll n,m,k,k1,x,ans,q,b[N],y,a[N];ll dp[N][132],st[N],hs[N];\nchar ch;\nstring s,t,s1[50],s2[50];\nvector v[N],ot;\nint main()\n{\n ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n cin>>n;\n if (n==1) return cout<<\"1 1\",0;\n ans=inf;\n for (int i=n/2;i>0;i--)\n {\n if (n%i==0)\n {\n if (ans>abs((n/i)-i)) x=i,y=n/i,ans=abs((n/i)-i);\n }\n }\n cout<\nusing namespace std;\nint main ()\n{\n\tlong long a, b;\n\tcin>>a>>b;\n\tlong long ans = 1, k = b % 10;\n\tif(b % 10 == 0)\n\tk = 10;\n\tfor(long long i = (a + 1) % 10; i <= k; i++)\n\t{\n\t\tans *= i;\n\t}\n\tans %= 10;\n\tcout<\r\nusing namespace std;\r\nint main() {\r\n int a;\r\n cin >> a;\r\n if(a == 1) {\r\n cout << \"1\\n\";\r\n return 0;\r\n }\r\n if(a > -2) {\r\n for(;;);\r\n }\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "74d2d3626feb12b642c5a625fd4331bc", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nconst long long int maxn=6e3, mod=998244353;\nlong long a,b,c,ans;\nlong long s[maxn][maxn],f[maxn];\nint main(){\n\tcin>>a>>b>>c;\n\tf[1]=1;\n\tfor(int i=2;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nconst long long INF = 2005;\nconst long long mod = 1e9 + 7;\nconst double eps = 1e-5;\n\nstruct inr {\n int n, k;\n\n inr (){};\n};\n\nusing namespace std;\n\nvector perf, num;\nlong long h, n, w, p[111];\n\nvoid qwe(long long a, vector &num)\n{\n if (a == 1)\n {\n num.push_back(1);\n return;\n }\n else {\n num.push_back(a%2);\n qwe (a/2, num);\n }\n return;\n}\n\n\nint main()\n{\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"rt\", stdin);\n freopen(\"output.txt\", \"wt\", stdout);\n #endif\n cin >> h >> n;\n p[0] = 1;\n for (int i = 1; i <= h; ++i)\n {\n p[i] = p[i-1]*2;\n }\n qwe (n-1, num);\n for (int i = num.size(); i= 0; --i)\n {\n rr++;\n if (num[i] != w)\n {\n rr+= p[i+1]-1;\n }\n else {\n w = (w+1)%2;\n }\n }\n cout << rr;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "da1f0a3524e0a5b7a8b17ce0a6cc3aa4", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\ntemplate \nvoid unique(vector &u) {\n sort(u.begin(), u.end());\n u.resize(unique(u.begin(), u.end()) - u.begin());\n}\n\n#define range(i, m, n) for(int i = m; i < n; i++)\n#define husk(i, m, n) for(int i = m; i > n; i--)\n\nclass dsu {\n public:\n vector p;\n int n;\n\n dsu(int _n) : n(_n) {\n p.resize(n);\n iota(p.begin(), p.end(), 0);\n }\n\n inline int get(int x) {\n return (x == p[x] ? x : (p[x] = get(p[x])));\n }\n\n inline bool unite(int x, int y) {\n x = get(x);\n y = get(y);\n if (x != y) {\n p[x] = y;\n return true;\n }\n return false;\n }\n};\n\nstruct point {\n int x, y, id = -1;\n point(){};\n point(int _x, int _y) : x(_x), y(_y) {};\n bool operator < (const point &a) const {\n return id > a.id;\n }\n bool operator == (const point &a) const {\n return x == a.x && y == a.y;\n }\n};\n\nvector dx = {0, 1, 1, 1, 0, -1, -1, -1};\nvector dy = {1, 1, 0, -1, -1, -1, 0, 1};\n\npoint sp(point a, int id) {\n return point(a.x + dx[id], a.y + dy[id]);\n}\n\nlong long dis(point a) {\n return 1LL * a.x * INT_MAX + a.y;\n}\n\nint n, t;\n\nint main() {\n scanf(\"%d%d\", &n, &t);\n vector a(n);\n range(i, 0, n) {\n scanf(\"%d%d\", &a[i].x, &a[i].y);\n a[i].id = i;\n }\n sort(a.begin(), a.end(), [&](point u, point v){return make_pair(u.x, u.y) < make_pair(v.x, v.y);});\n vector> edges(n, vector(8, -1));\n dsu ss(n);\n int l = 0, r = 0;\n range(i, 0, n) {\n if(i < n - 1 && a[i].x == a[i + 1].x && a[i].y == a[i + 1].y - 1) {\n edges[a[i].id][0] = a[i + 1].id;\n edges[a[i + 1].id][4] = a[i].id;\n ss.unite(a[i].id, a[i + 1].id);\n }\n while(r < n && make_pair(a[r].x, a[r].y) <= make_pair(a[i].x + 1, a[i].y + 1)) r++;\n while(l < n && make_pair(a[l].x, a[l].y) < make_pair(a[i].x + 1, a[i].y - 1)) l++;\n range(j, l, r) {\n int dif = a[j].y - a[i].y;\n int id;\n if(!dif) id = 2;\n else id = (dif > 0 ? 1 : 3);\n edges[a[i].id][id] = a[j].id;\n edges[a[j].id][(id + 4) % 8] = a[i].id;\n ss.unite(a[i].id, a[j].id);\n }\n }\n range(i, 0, n) if(ss.get(i) != ss.get(0)) {\n printf(\"NO\");\n return 0;\n }\n sort(a.begin(), a.end());\n reverse(a.begin(), a.end());\n printf(\"YES\\n\");\n dsu st(4 * n + 1);\n auto it = max_element(a.begin(), a.end(), [&](point a, point b){return a.y < b.y;});\n st.unite(4 * n, 4 * it -> id);\n unordered_map> dog;\n for(auto u : a) {\n for(int i = 0; i < 8; i += 2) {\n int v = edges[u.id][i];\n if(v == -1) dog[dis(sp(u, i))].push_back(4 * u.id + i / 2);\n }\n }\n for(auto u : a) {\n vector xs(8);\n range(i, 0, 8) xs[i] = edges[u.id][i] >= 0;\n for(int i = 1; i < 8; i += 2) {\n if(!xs[i] && !xs[i - 1] && !xs[(i + 1) % 8]) st.unite(4 * u.id + i / 2, 4 * u.id + ((i + 1) % 8) / 2);\n }\n }\n for(auto u : dog) {\n point cc = point(u.first / INT_MAX, u.first % INT_MAX);\n vector id = u.second;\n for(auto i : id) st.unite(i, id.front());\n for(int i = 0; i < 8; i += 2) {\n if(dog.count(dis(sp(cc, i)))) st.unite(id[0], dog[dis(sp(cc, i))][0]);\n }\n }\n vector alive(n, 1);\n int iter = 0;\n vector pp(4 * n + 1);\n auto valid = [&] (point v) {\n iter++;\n bool ok = false;\n range(i, 0, 8) {\n if(~edges[v.id][i] && alive[edges[v.id][i]]) {\n int xs = 8;\n i++;\n if(i == 8) i = 0;\n vector pc;\n while(xs--) {\n if(~edges[v.id][i] && alive[edges[v.id][i]]) {\n for(auto j : pc) {\n if(pp[j] == iter) return false;\n }\n for(auto j : pc) pp[j] = iter;\n pc.clear();\n } else if(i % 2 == 0) {\n pc.push_back(st.get(4 * v.id + i / 2));\n ok |= st.get(4 * v.id + i / 2) == st.get(4 * n);\n }\n i++;\n if(i == 8) i = 0;\n }\n break;\n }\n ok |= i == 7;\n }\n return ok;\n };\n set pos;\n range(i, 0, n) if(valid(a[i])) pos.insert(a[i]);\n vector> in(4 * n + 1);\n range(i, 0, 4 * n + 1) in[st.get(i)].push_back(i);\n vector res;\n int cnt = 0;\n vector ap(n);\n while(pos.size()) {\n cnt++;\n res.push_back(pos.begin() -> id);\n point cc = *pos.begin();\n pos.erase(pos.begin());\n alive[cc.id] = 0;\n vector id, _id;\n range(i, 0, 8) {\n if(~edges[cc.id][i] && alive[edges[cc.id][i]]) id.push_back(edges[cc.id][i]);\n }\n for(int i = 0; i < 8; i += 2) {\n if(edges[cc.id][i] == -1 || !alive[edges[cc.id][i]]) {\n if(st.get(4 * n) != st.get(4 * cc.id + i / 2)) _id.push_back(st.get(4 * cc.id + i / 2));\n }\n }\n unique(_id);\n for(auto i : _id) {\n for(auto j : in[i]) id.push_back(j / 4);\n }\n unique(id);\n for(int i = 0; i < 8; i += 2) {\n if(edges[cc.id][i] == -1 || !alive[edges[cc.id][i]]) {\n st.unite(4 * cc.id + i / 2, 4 * n);\n }\n }\n for(int i = 0; i < 8; i += 2) {\n if(~edges[cc.id][i] && alive[edges[cc.id][i]]) {\n int v = edges[cc.id][i];\n st.unite(4 * v + ((i + 4) % 8) / 2, 4 * n);\n }\n }\n for(auto i : id) {\n if(ap[i] == cnt) continue;\n ap[i] = cnt;\n if(alive[i] && valid(a[i])) pos.insert(a[i]);\n else pos.erase(a[i]);\n }\n }\n reverse(res.begin(), res.end());\n for(auto i : res) printf(\"%d\\n\", i + 1);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d448b1df442eb27681a9aa75a3a8ae6d", "src_uid": "873aca0e5ff5dccf8af62f7b244fef6b", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\n//#define x first\n//#define y\n#define alcv ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);\n\nint main()\n{\n string s; cin>>s; ll n=s.size(),cnt1=0;\n if(n==1){if(s[0]=='0')cout<<\"0\";else cout<<\"1\";return 0;}\n for(ll i=0;i1)cout<<((n-1)/2)+1;\n else cout<<(n)/2;\n \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "db8f6f70f0b724e1948c4413d77cc0f7", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector VI;\ntypedef vector VII;\n\nint main(){\n\tifstream fin(\"input.txt\");\n\tofstream fout(\"output.txt\");\n\tint i, N;\n\tchar ch[7] = {'R', 'O', 'Y', 'G', 'B', 'I', 'V'};\n\tcin >> N;\n\tfor( i = 0; i < N /7 *7; i++ ){\n\t\tcout << ch[i % 7];\n\t}\n\tfor( i = N % 7; i > 0; i++ ){\n\t\tcout << ch[4-i];\n\t}\n\t\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0499ce35c0dd2954ca63d36c2087ba5b", "src_uid": "dc3817c71b1fa5606f316e5e94732296", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n \nusing namespace std;\nusing namespace __gnu_pbds; \n \n#define vi vector\n#define pb push_back\n#define ll long long int\n#define pii pair< int, int>\n#define ff first\n#define ss second\n#define sort(a)\t\tsort(a.begin(),a.end())\n#define rev(a)\t\treverse(a.begin(),a.end())\n#define fr(i,a,b)\tfor( ll i=a; ib; i--)\n#define rFr(i,a,b)\tfor( ll i=a; i>=b; i--)\n#define fio\tios_base::sync_with_stdio(), cin.tie(0), cout.tie(0)\n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update> \n \nconst ll N=60;\nconst ll mod=1e9+7;\n \nll ffe( ll a, ll b){\n\tif(b==0){\n\t\treturn 1;\n\t}else{\n\t\tif(b%2)\n\t\t\treturn (a*ffe((a*a)%mod,b/2))%mod;\n\t\telse\t\n\t\t\treturn ffe((a*a)%mod,b/2);\n\t}\n}\n\nint main(){\t\t\t\n\t\t\n\tfio;\n\tll x, s;\n\tcin >> x >> s;\n\t\n\tif(x>s){\n\t\tcout << -1;\n\t\treturn 0;\n\t}\n\t\t\n\tvi p2(N+1,1);\n\tfor( int i=1; i<=N; i++){\n\t\tp2[i]=2*p2[i-1];\n\t}\n\t\n\tstring str = bitset(s).to_string();\n\trev(str);\n\t\n\tvi a(N+1,0);\n\tfor( int i=0; i<=N; i++){\n\t\tif(str[i]=='1'){\n\t\t\ta[i]=1;\n\t\t}\n\t}\t\n\t\t\n\tstr = bitset(x).to_string();\n\trev(str);\t\n\t\n\tfor( int i=N; i>=0; i--){\n\n\t\tif(str[i]=='1'){\n\t\t\n\t\t\tif(a[i]==0){\n\t\t\t\t\n\t\t\t\tll j=i+1;\n\t\t\t\tbool f = false;\n\t\t\t\twhile(j<=N){\n\t\t\t\t\tif(a[j]>=2){\n\t\t\t\t\t\tf = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tj++;\n\t\t\t\t}\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\tif(!f){\n\t\t\t\t\tcout << -1;\n\t\t\t\t\treturn 0;\n\t\t\t\t}\t\t\n\t\t\t\t\n\t\t\t\twhile(j\nusing namespace std;\ntypedef int long long ll;\nvector vec2;\nvector vec3;\nvector > vec;\nint main()\n{\n\tll a,b;\n\tcin>>a>>b;\n\tll c=a+b;\n\tfor(ll i=1;i*i<=c;i++)\n\t{\n\t\tif(c%i==0)\n\t\t{\n\t\t\tvec.push_back(make_pair(i,c/i));\n\t\t}\n\t}\n\tfor(ll j=1;j*j<=min(a,b);j++)\n\t{\n\t\tif(min(a,b)%j==0)\n\t\t\t{\n\t\t\t\tif(j==min(a,b)/j)\n\t\t\t\t\tvec2.push_back(j);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvec2.push_back(j);\n\t\t\t\t\tvec2.push_back(min(a,b)/j);\n\t\t\t\t}\n\t\t\t}\n\t}\n\tfor(ll j=1;j*j<=max(a,b);j++)\n\t{\n\t\tif(max(a,b)%j==0)\n\t\t\t{\n\t\t\t\tif(j==max(a,b)/j)\n\t\t\t\t\tvec3.push_back(j);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvec3.push_back(j);\n\t\t\t\t\tvec3.push_back(max(a,b)/j);\n\t\t\t\t}\n\t\t\t}\n\t}\n\tsort(vec3.begin(),vec3.end());\n\tsort(vec2.begin(),vec2.end());\n\tif(a==1 || b==1)\t\n\t{\n\t\tint size=vec.size();\n\t\tcout<<2*(vec[size-1].first+vec[size-1].second)<=low)\n\t{\n\t\t//printf(\"***\\n\");\n\t\tll mid=low+(high-low)/2,l1;\n\t\tif(min(a,b)%vec[mid].second==0)\n\t\t\tl1=min(min(a,b)%vec[mid].second,vec[mid].first);\n\t\telse\n\t\t\tl1=min(min(a,b)%vec[mid].second+1,vec[mid].first);\n\n\t\tll l2=vec[mid].second;\n\n\t\t//cout< :: iterator it;\n\t\tit=upper_bound(vec2.begin(),vec2.end(),l2);\n\t\tit--;\n\t\t//cout<<*it<=l1)\n\t\t\tlow=mid+1;\n\t\telse\n\t\t\thigh=mid-1;\n\n\t\t//cout<=low)\n\t{\n\t\t//printf(\"***\\n\");\n\t\tll mid=low+(high-low)/2,l1;\n\t\t//ll l1=ceil(max(a,b)/vec[mid].second);\n\t\tif(max(a,b)%vec[mid].second==0)\n\t\t\tl1=min(max(a,b)%vec[mid].second,vec[mid].first);\n\t\telse\n\t\t\tl1=min(max(a,b)%vec[mid].second+1,vec[mid].first);\n\t\tll l2=vec[mid].second;\n\n\t\t//cout< :: iterator it;\n\t\tit=upper_bound(vec3.begin(),vec3.end(),l2);\n\t\tit--;\n\t\t//cout<<*it<=l1)\n\t\t\tlow=mid+1;\n\t\telse\n\t\t\thigh=mid-1;\n\n\t\t//cout<\n#include\n#include\nusing namespace std;\nint main()\n{\n int x,y,z,ans;\n cin>>x>>y;\n if(x==0 && y==0)\n cout<<\"0\";\n else if(x==1 && y==0)\n cout<<\"0\";\n else\n {\n z=max(abs(x),abs(y));\n ans=4*(z-1);\n if(x==z)\n ans++;\n else if(x==-z)\n ans+=3;\n else if(y==z)\n ans+=2;\n else if(y==-z)\n ans+=4;\n cout<\n#include \n#include \n#include \n#include \nusing namespace std;\npair v[20000001];\nint main ()\n{\n\tlong long i,j,n,e,t=0,b,m,vr,mx,k,z,a;\n\tcin>>a>>n;\n\tfor (i=0;imx) break;\n\t\tif (b<=mx) {\n\t\t\tif (b>=a) {\n\t\t\t\tif (v[b].first==0) {v[b].first=1;v[b].second=z;} else\n\t\t\t\t\tif ((v[b].first==1) && (v[b].second>z)) v[b].second=z;}\n\t\t\tz++;\n\t\tb=b+i;} else\n\t\t{k++;i=k*k;b=i;z=1;}\n\t\t\n\t}\n\t//sort(v,v+j);\n\t/*if (j!=0) {\n\tfor (i=0;iv[j].first) {t=t+a;a++;break;} \n\t\tif (v[i].first>a && (i==0 || v[i-1].firstmx) break;} else\n\t\t\tif(v[i].first==a) {t=t+v[i].second;a++;if (a>mx) break;} \n\t}}\n\twhile (a\nusing namespace std;\nstruct node\n{\n int a, site, ans;\n}cup[102];\nbool cmp(const node& x, const node& y)\n{\n return x.a < y.a;\n}\nbool cmp2(const node& x, const node& y)\n{\n return x.site < y.site;\n}\nint main()\n{\n int n, w;\n cin >> n >> w;\n int sum = 0;\n for (int i = 1; i <= n; ++i) {\n cin >> cup[i].a;\n cup[i].site = i;\n if(cup[i].a & 1)\n cup[i].ans = cup[i].a / 2 + 1;\n else cup[i].ans = cup[i].a / 2;\n sum += cup[i].ans;\n }\n if (sum > w) {\n cout << \"-1\" << endl;\n }\n else {\n sort (cup + 1, cup + n + 1, cmp);\n int j = n;\n int last = w - sum;\n while (last) {\n if(cup[j].a - cup[j].ans <= last) {\n cup[j].ans = cup[j].a;\n last -= cup[j].a - cup[j].ans;\n }\n else {\n cup[j].ans += last;\n last = 0;\n }\n --j;\n }\n sort (cup + 1, cup + n + 1, cmp2);\n for (int i = 1; i <= n; ++i) {\n if(i - 1) cout << \" \";\n cout << cup[i].ans;\n }\n cout << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5337e0fd160994ef79da66119f27a4b7", "src_uid": "5d3bb9e03f4c5c8ecb6233bd5f90f3a3", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "#include\n#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n fast;\n int n, a, b ,i; int d=0;\n cin>>n>>a>>b; int c[n],j=n-1;\n \n for(i=0;i>c[i];\n }\n\n for(i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, n) for (int i=0;i=int(a);--i)\n#define REP_1(i, n) for (int i=1;i<=int(n);++i)\n#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)\n#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)\n#define REP_C(i, n) for (int n____=int(n),i=0;i=a____;--i)\n#define REP_N(i, n) for (i=0;i=int(a);--i)\n#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)\n#define REP_1_N(i, n) for (i=1;i<=int(n);++i)\n#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)\n#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)\n#define REP_C_N(i, n) for (int n____=(i=0,int(n));i=a____;--i)\n#define REP_1_C_N(i, n) for (int n____=(i=1,int(n));i<=n____;++i)\n#define FOR_1_C_N(i, a, b) for (int b____=(i=1,int(b);i<=b____;++i)\n#define DWN_1_C_N(i, b, a) for (int a____=(i=b,int(a));i>=a____;--i)\n\n#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)\n#define REP_S(i, str) for (char*i=str;*i;++i)\n#define REP_L(i, hd, nxt) for (int i=hd;i;i=nxt[i])\n#define REP_G(i, u) REP_L(i,hd[u],suc)\n#define DO(n) for ( int ____n ## __line__ = n; ____n ## __line__ -- ; )\n#define REP_2(i, j, n, m) REP(i, n) REP(j, m)\n#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)\n#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)\n#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)\n#define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn)\n#define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn)\n\n#define ALL(A) A.begin(), A.end()\n#define LLA(A) A.rbegin(), A.rend()\n#define CPY(A, B) memcpy(A, B, sizeof(A))\n#define INS(A, P, B) A.insert(A.begin() + P, B)\n#define ERS(A, P) A.erase(A.begin() + P)\n#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin())\n#define CTN(T, x) (T.find(x) != T.end())\n#define SZ(A) int(A.size())\n#define PB push_back\n#define MP(A, B) make_pair(A, B)\n#define PTT pair\n#define fi first\n#define se second\n\n#define Rush for(int ____T=RD(); ____T--;)\n\n#define Display(A, n, m) { \\\n\tREP(i, n){\t\t \\\n REP(j, m) cout << A[i][j] << \" \"; \\\n cout << endl;\t\t\t\t \\\n\t}\t\t\t\t\t\t \\\n}\n\n#define Display_1(A, n, m) {\t\t\t\t \\\n\tREP_1(i, n){\t\t \\\n REP_1(j, m) cout << A[i][j] << \" \"; \\\n\t\tcout << endl;\t\t \t\t\\\n\t}\t\t\t\t\t\t \\\n}\n\n#pragma comment(linker, \"/STACK:36777216\")\n//#pragma GCC optimize (\"O2\")\n\nstring __file__(){\n string res = __FILE__;\n int r = SZ(res) - 1; while (res[r] != '.') --r;\n int l = r - 1; while (res[l] != '\\\\') --l; ++l;\n return res.substr(l, r-l);\n}\n\nvoid Exec(string a, string b, string c){\n if (b.empty()) b = __file__();\n string cmd = a + ' ' + b + '.' + c;\n system(cmd.c_str());\n}\n\nvoid Ruby(string file = \"\"){Exec(\"ruby\", file, \"rb\");}\nvoid Python(string file = \"\"){Exec(\"python\", file, \"py\");}\nvoid Haskell(string file = \"\"){Exec(\"runghc\", file, \"hs\");}\nvoid Pascal(string file = \"\"){Exec(\"pascal\", file, \"pas\");}\n\ntypedef long long LL;\n//typedef long double DB;\ntypedef double DB;\ntypedef unsigned UINT;\ntypedef unsigned long long ULL;\n\ntypedef vector VI;\ntypedef vector VC;\ntypedef vector VS;\ntypedef vector VL;\ntypedef vector VF;\ntypedef set SI;\n//typedef set SS;\ntypedef map MII;\ntypedef map MSI;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VII;\ntypedef vector VVI;\ntypedef vector VVII;\n\ntemplate inline T& RD(T &);\ntemplate inline void OT(const T &);\ninline LL RD(){LL x; return RD(x);}\ninline DB& RF(DB &);\ninline DB RF(){DB x; return RF(x);}\ninline char* RS(char *s);\ninline char& RC(char &c);\ninline char RC();\ninline char& RC(char &c){scanf(\" %c\", &c); return c;}\ninline char RC(){char c; return RC(c);}\n//inline char& RC(char &c){c = getchar(); return c;}\n//inline char RC(){return getchar();}\n\ntemplate inline T& RDD(T &x){\n char c; for (c = getchar(); c < '-'; c = getchar());\n if (c == '-'){x = '0' - getchar(); for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + '0' - c;}\n else {x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';}\n return x;\n}\n\ninline LL RDD(){LL x; return RDD(x);}\n\ntemplate inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}\ntemplate inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}\ninline char& RC(char &a, char &b){RC(a), RC(b); return a;}\ninline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}\ninline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}\ninline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}\ninline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}\ninline void RS(char *s1, char *s2){RS(s1), RS(s2);}\ninline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}\ntemplateinline void RDD(const T0&a, const T1&b){RDD(a),RDD(b);}\ntemplateinline void RDD(const T0&a, const T1&b, const T2&c){RDD(a),RDD(b),RDD(c);}\n\ntemplate inline void RST(T &A){memset(A, 0, sizeof(A));}\ntemplate inline void FLC(T &A, int x){memset(A, x, sizeof(A));}\ntemplate inline void CLR(T &A){A.clear();}\n\ntemplate inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}\ntemplate inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}\ntemplate inline void CLR(priority_queue, less > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(priority_queue, greater > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}\ntemplate inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}\n\ntemplate inline T& SRT(T &A){sort(ALL(A)); return A;}\ntemplate inline T& RVS(T &A){reverse(ALL(A)); return A;}\ntemplate inline T& UNQ(T &A){A.resize(unique(ALL(SRT(A)))-A.begin());return A;}\n\ntemplate inline T& SRT(T &A, C B){sort(ALL(A), B); return A;}\n\n//}\n\n/** Constant List .. **/ //{\n\nconst int MOD = int(1e9) + 7;\n//int MOD = 99990001;\nconst int INF = 0x3f3f3f3f;\nconst LL INFF = 1LL << 60;\nconst DB EPS = 1e-9;\nconst DB OO = 1e20;\nconst DB PI = acos(-1.0); //M_PI;\n\nconst int dx[] = {-1, 0, 1, 0};\nconst int dy[] = {0, 1, 0, -1};\n\n//}\n\n/** Add On .. **/ //{\n// <<= '0. Nichi Joo ., //{\ntemplate inline void checkMin(T &a,const T b){if (b inline void checkMax(T &a,const T b){if (a inline void checkMin(T &a, T &b, const T x){checkMin(a, x), checkMin(b, x);}\ntemplate inline void checkMax(T &a, T &b, const T x){checkMax(a, x), checkMax(b, x);}\ntemplate inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}\ntemplate inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}\ntemplate inline T min(T a, T b, T c){return min(min(a, b), c);}\ntemplate inline T max(T a, T b, T c){return max(max(a, b), c);}\ntemplate inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}\ntemplate inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}\ntemplate inline T sqr(T a){return a*a;}\ntemplate inline T cub(T a){return a*a*a;}\ninline int ceil(int x, int y){return (x - 1) / y + 1;}\ninline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}\ninline int sgn(DB x, DB y){return sgn(x - y);}\n//}\n// <<= '1. Bitwise Operation ., //{\nnamespace BO{\n\ninline bool _1(int x, int i){return bool(x&1<> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);\n x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);\n x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);\n x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);\n x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);\n return x;\n}\n\ninline LL reverse_bits(LL x){\n x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);\n x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);\n x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);\n x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);\n x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);\n x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);\n return x;\n}\n\ntemplate inline bool odd(T x){return x&1;}\ntemplate inline bool even(T x){return !odd(x);}\ntemplate inline T low_bit(T x) {return x & -x;}\ntemplate inline T high_bit(T x) {T p = low_bit(x);while (p != x) x -= p, p = low_bit(x);return p;}\ntemplate inline T cover_bit(T x){T p = 1; while (p < x) p <<= 1;return p;}\n\ninline int low_idx(int x){return __builtin_ffs(x);}\ninline int low_idx(LL x){return __builtin_ffsll(x);}\ninline int high_idx(int x){return low_idx(reverse_bits(x));}\ninline int high_idx(LL x){return low_idx(reverse_bits(x));}\ninline int clz(int x){return __builtin_clz(x);}\ninline int clz(LL x){return __builtin_clzll(x);}\ninline int ctz(int x){return __builtin_ctz(x);}\ninline int ctz(LL x){return __builtin_ctzll(x);}\ninline int parity(int x){return __builtin_parity(x);}\ninline int parity(LL x){return __builtin_parityll(x);}\ninline int lg2(int a){return 31 - clz(a);}\ninline int lg2(LL a){return 63 - clz(a);}\ninline int count_bits(int x){return __builtin_popcount(x);}\ninline int count_bits(LL x){return __builtin_popcountll(x);}\n\n} using namespace BO;//}\n// <<= '2. Number Theory .,//{\nnamespace NT{\ninline LL __lcm(LL a, LL b){return a*b/__gcd(a,b);}\ninline void INC(int &a, const int b){a += b; if (a >= MOD) a -= MOD;}\ninline int sum(int a, const int b){a += b; if (a >= MOD) a -= MOD; return a;}\ninline void DEC(int &a, const int b){a -= b; if (a < 0) a += MOD;}\ninline int dff(int a, const int b){a -= b; if (a < 0) a += MOD; return a;}\ninline void MUL(int &a, const int b){a = (LL)a * b % MOD;}\ninline int pdt(const int a, const int b){return (LL)a * b % MOD;}\n\ninline int sum(int a, int b, int c){return sum(sum(a, b), c);}\ninline int sum(int a, int b, int c, int d){return sum(sum(a, b), sum(c, d));}\ninline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}\ninline int pdt(int a, int b, int c, int d){return pdt(pdt(pdt(a, b), c), d);}\n\ninline int pow(int a, int b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ninline int pow(int a, LL b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ntemplate inline T pow(T a, LL b){\n T c(1); while (b){\n if (b&1) c *= a;\n a *= a, b >>= 1;\n }\n return c;\n}\n\ninline int _I(int b){\n int a = MOD, x1 = 0, x2 = 1, q;\n while (true){\n q = a / b, a %= b;\n if (!a) return (x2 + MOD) % MOD;\n DEC(x1, pdt(q, x2));\n\n q = b / a, b %= a;\n if (!b) return (x1 + MOD) % MOD;\n DEC(x2, pdt(q, x1));\n }\n}\n\ninline void DIV(int &a, int b){MUL(a, _I(b));}\ninline int qtt(int a, int b){return pdt(a, _I(b));}\n\ninline int phi(int n){\n int res = n; for (int i=2;sqr(i)<=n;++i) if (!(n%i)){\n DEC(res, qtt(res, i));\n do{n /= i;} while(!(n%i));\n }\n if (n != 1)\n DEC(res, qtt(res, n));\n return res;\n}\n\n} using namespace NT;//}\n// <<= '7. Matrix Theory .,//{\nnamespace MT{\n\n const int N = 100;\n int n = 0;\n\n typedef int rec;\n\n struct matrix{\n rec d[N][N];\n\n void init(rec e = 0){RST(d); if(e) REP(i, n) d[i][i] = e;}\n matrix(rec e = 0){init(e);}\n\n matrix operator *(const matrix &rhs) const{\n matrix res; //REP_3(i, j, k, n, n, n) res.d[i][j] += d[i][k] * rhs.d[k][j];\n REP_2(i, j, n, n){\n LL tmp = 0; REP(k, n) tmp += (LL) d[i][k] * rhs.d[k][j];\n res.d[i][j] = tmp % MOD;\n }\n return res;\n }\n\n matrix& operator *=(const matrix& rhs){(*this) = (*this) * rhs;}\n\n inline int res(){\n int res = 0;\n REP(i, n) INC(res, d[0][i]);\n //REP_2(i, j, n, n) INC(res, d[i][j]);\n return res;\n }\n };\n\n /*inline matrix pow_sum(const matrix& a, ULL nn){\n if (nn == 1) return matrix(1);\n matrix t; REP_2(i, j, n, n) t.d[i][j] = t.d[i][j+n] = a.d[i][j];\n FOR_C(i, n, n*2) t.d[i][i] = 1; n <<= 1; t = pow(t, nn), n >>= 1;\n REP_2(i, j, n, n) t.d[i][j] = t.d[i][j+n];\n return t;\n }*/\n\n inline matrix pow_sum(const matrix& a, ULL nn){\n if (nn == 1) return matrix(1);\n matrix t; REP_2(i, j, n, n) t.d[i][j] = a.d[i][j];\n REP(i, n) t.d[i][i+n] = t.d[i+n][i+n] = 1; n <<= 1; t = pow(t, nn), n >>= 1;\n REP_2(i, j, n, n) t.d[i][j] = t.d[i][j+n];\n return t;\n }\n\n template T pow_sum(T a, ULL nn){\n int _n = n; n = 1; matrix t; t.d[0][0] = a;\n t = pow_sum(t, nn), n = _n;\n return t.d[0][0];\n }\n\n} // using namespace MT;//}\n// <<= '8. Stringology .,//{\nnamespace SL{\n namespace KMP{\n\n void calc_pi(const char *P, int n, int *pi){\n for (int i = 1, j = pi[0] = -1; i < n; ++i){\n while (j >= 0 && P[i] != P[j+1]) j = pi[j];\n if (P[i] == P[j+1]) ++j;\n pi[i] = j;\n }\n //REP(i, n) cout << pi[i] << \" \"; cout << endl;\n }\n\n bool run(const char *T, int n, const char *P, int m, const int *pi){\n for (int i = 0, j = -1; i < n; ++i){\n while (j >= 0 && T[i] != P[j+1]) j = pi[j];\n if (T[i] == P[j+1]) ++j;\n if (j == m - 1) return true;\n }\n return false;\n }\n\n } //using namespace KMP;\n\n namespace Z{\n void calc_z(const char *P, int n, int *z){\n\n z[0] = n;\n\n for (int i = 1, l = 0, r = 0; i < n; ++i){\n if (i > r){\n for(l = r = i; r < n && P[r] == P[r - l];) ++r;\n z[i] = r - l, --r;\n }\n else {\n if (z[i - l] < r - i + 1) z[i] = z[i - l];\n else {\n for (l = i;r < n && P[r] == P[r - l];) ++r;\n z[i] = r - l, --r;\n }\n }\n }\n\n //REP(i, n) cout << z[i] << \" \"; cout << endl;\n }\n\n int run(const char *T, int n, const char *P, int m, const int *z){\n\n int ex; REP_C_N(ex, min(n, m)) if (T[ex] != P[ex]) break;\n\n int res = ex == m;\n\n for (int i = 1, l = 0, r = 0; i < n; ++i){\n if (i > r){\n for (l = r = i; r < n && T[r] == P[r - l];) ++r;\n ex = r - l, --r;\n }\n else {\n if (z[i - l] < r - i + 1) ex = z[i - l];\n else {\n for (l = i; r < n && T[r] == P[r - l];) ++r;\n ex = r - l, --r;\n }\n }\n if (ex == m) ++res;\n }\n\n return res;\n }\n } //using namespace Z;\n\n void Manacher(char s[], int n, int p[]){\n const int NN = 0;\n static char ss[NN*2+2]; int nn = 2*n+2;\n ss[0] = '$', ss[nn-1] = '#', ss[nn] = 0;\n REP(i, n) ss[i*2+1] ='#', ss[i*2+2] = s[i];\n int mx = 0, id = 0; FOR(i, 1, nn){\n p[i] = mx > i ? min(p[2*id-i], mx - i) : 1;\n while (ss[i+p[i]] == ss[i-p[i]]) ++p[i];\n if (i + p[i] > mx) mx = i + p[i], id = i;\n }\n }\n\n} //using namespace SL;//}\n// <<= '9. Comutational Geometry .,//{\nnamespace CG{\n\nstruct Po; struct Line; struct Seg;\n\nstruct Po{\n DB x, y; Po(DB _x=0, DB _y=0):x(_x), y(_y){}\n friend istream& operator >>(istream& in, Po &p){return in >> p.x >> p.y;}\n friend ostream& operator <<(ostream& out, Po p){return out << \"(\" << p.x << \", \" << p.y << \")\";}\n bool operator ==(const Po& r)const{return !sgn(x-r.x) && !sgn(y-r.y);};\n bool operator !=(const Po& r)const{return sgn(x-r.x) || sgn(y-r.y);}\n Po operator +(const Po& r)const{return Po(x+r.x, y+r.y);}\n Po operator -(const Po& r)const{return Po(x-r.x, y-r.y);}\n Po operator *(DB k)const{return Po(x*k,y*k);}\n Po operator /(DB k)const{return Po(x/k,y/k);}\n DB operator *(const Po&) const;\n DB operator ^(const Po&) const;\n\n bool operator <(const Po &r) const{return sgn(x,r.x)<0||!sgn(x,r.x)&&sgn(y,r.y)<0;}\n Po operator -()const{return Po(-x,-y);}\n Po& operator +=(const Po &r){x+=r.x,y+=r.y;return *this;}\n Po& operator -=(const Po &r){x-=r.x,y-=r.y;return *this;}\n Po& operator *=(DB k){x*=k,y*=k;return*this;}\n Po& operator /=(DB k){x/=k,y/=k;return*this;}\n\n DB length_sqr()const{return sqr(x)+sqr(y);}\n DB length()const{return sqrt(length_sqr());}\n Po unit()const{return *this/length();}\n bool dgt()const{return !sgn(x)&&!sgn(y);}\n DB atan()const{return atan2(y,x);}\n void rotate(DB alpha, const Po& o = Po()){\n x -= o.x, y -= o.y;\n (*this) = Po(x * cos(alpha) - y * sin(alpha), y * cos(alpha) + x * sin(alpha)) + o;\n }\n\n void input(){RF(x,y);}\n};\n\nPo operator *(DB k, Po a){return a * k;}\n\n#define innerProduct dot\n#define scalarProduct dot\n#define outerProduct det\n#define crossProduct det\n\ninline DB dot(const DB &x1, const DB &y1, const DB &x2, const DB &y2){return x1 * x2 + y1 * y2;}\ninline DB dot(const Po &a, const Po &b){return dot(a.x, a.y, b.x, b.y);}\ninline DB dot(const Po &p0, const Po &p1, const Po &p2){return dot(p1 - p0, p2 - p0);}\n\ninline DB det(const DB &x1, const DB &y1, const DB &x2, const DB &y2){return x1 * y2 - x2 * y1;}\ninline DB det(const Po &a, const Po &b){return det(a.x, a.y, b.x, b.y);}\ninline DB det(const Po &p0, const Po &p1, const Po &p2){return det(p1 - p0, p2 - p0);}\n\ntemplate inline int dett(const T1 &x, const T2 &y){return sgn(det(x, y));}\ntemplate inline int dott(const T1 &x, const T2 &y){return sgn(dot(x, y));}\ntemplate inline int dett(const T1 &x, const T2 &y, const T3 &z){return sgn(det(x, y, z));}\ntemplate inline int dott(const T1 &x, const T2 &y, const T3 &z){return sgn(dot(x, y, z));}\ntemplate inline int dett(const T1 &x, const T2 &y, const T3 &z, const T4 &w){return sgn(det(x, y, z, w));}\ntemplate inline int dott(const T1 &x, const T2 &y, const T3 &z, const T4 &w){return sgn(dot(x, y, z, w));}\n\ninline DB dist_sqr(const DB &x, const DB &y){return sqr(x) + sqr(y);}\ninline DB dist_sqr(const DB &x, const DB &y, const DB &z){return sqr(x) + sqr(y) + sqr(z);}\ninline DB dist_sqr(const Po &a, const Po &b){return sqr(a.x - b.x) + sqr(a.y - b.y);}\n\ntemplate inline DB dist(const T1 &x, const T2 &y){return sqrt(dist_sqr(x, y));}\ntemplate inline DB dist(const T1 &x, const T2 &y, const T3 &z){return sqrt(dist_sqr(x, y, z));}\n\nDB Po::operator *(const Po &r)const{return dot(*this, r);}\nDB Po::operator ^(const Po &r)const{return det(*this, r);}\n\nstruct Line{\n Po a, b;\n\n Line(DB x0=0, DB y0=0, DB x1=0, DB y1=0):a(Po(x0, y0)), b(Po(x1, y1)){}\n Line(const Po &a, const Po &b):a(a), b(b){}\n Line(const Line &l):a(l.a), b(l.b){}\n\n friend ostream& operator <<(ostream& out, Line p){return out << p.a << \"-\" << p.b;}\n Line operator +(Po x)const{return Line(a + x, b + x);}\n DB length()const{return (b-a).length();}\n bool dgt()const{return (b-a).dgt();}\n void input(){a.input(), b.input();}\n\n int side(const Po& p){return dett(a, b, p);}\n bool same_side(const Po& p1, const Po& p2){return side(p1) == side(p2);}\n void getequation(DB& A, DB& B, DB& C) const{A = a.y - b.y, B = b.x - a.x, C = det(a, b);}\n};\n\nstruct Seg: Line{\n};\n\ninline DB dot(const Line &l1, const Line &l2){return dot(l1.b - l1.a, l2.b - l2.a);}\ninline DB det(const Line &l1, const Line &l2){return det(l1.b - l1.a, l2.b - l2.a);}\n\ninline DB dist_sqr(const Po &p, const Line &l){Po v0 = l.b - l.a, v1 = p - l.a; return sqr(fabs(det(v0, v1))) / v0.length_sqr();}\ninline DB dist_sqr(const Po &p, const Seg &l){\n Po v0 = l.b - l.a, v1 = p - l.a, v2 = p - l.b;\n if (sgn(dot(v0, v1)) * sgn(dot(v0, v2)) <= 0) return dist_sqr(p, Line(l));\n else return min(v1.length_sqr(), v2.length_sqr());\n}\ninline DB dist_sqr(Line l, Po p){return dist_sqr(p, l);}\ninline DB dist_sqr(Seg l, Po p){return dist_sqr(p, l);}\ninline DB dist_sqr(Line l1, Line l2){\n if (sgn(det(l1, l2)) != 0) return 0;\n return dist_sqr(l1.a, l2);\n}\ninline DB dist_sqr(Line l1, Seg l2){\n Po v0 = l1.b - l1.a, v1 = l2.a - l1.a, v2 = l2.b - l1.a; DB c1 = det(v0, v1), c2 = det(v0, v2);\n return sgn(c1) != sgn(c2) ? 0 : sqr(min(fabs(c1), fabs(c2))) / v0.length_sqr();\n}\n\nbool isIntersect(Seg l1, Seg l2){\n\n if (l1.a == l2.a || l1.a == l2.b || l1.b == l2.a || l1.b == l2.b) return true;\n\n return\n min(l1.a.x, l1.b.x) <= max(l2.a.x, l2.b.x) &&\n min(l2.a.x, l2.b.x) <= max(l1.a.x, l1.b.x) &&\n min(l1.a.y, l1.b.y) <= max(l2.a.y, l2.b.y) &&\n min(l2.a.y, l2.b.y) <= max(l1.a.y, l1.b.y) &&\n sgn( det(l1.a, l2.a, l2.b) ) * sgn( det(l1.b, l2.a, l2.b) ) <= 0 &&\n sgn( det(l2.a, l1.a, l1.b) ) * sgn( det(l2.b, l1.a, l1.b) ) <= 0;\n\n}\n\ninline DB dist_sqr(Seg l1, Seg l2){\n if (isIntersect(l1, l2)) return 0;\n else return min(dist_sqr(l1.a, l2), dist_sqr(l1.b, l2), dist_sqr(l2.a, l1), dist_sqr(l2.b, l1));\n}\n\ninline bool isOnSide(const Po &p, const Seg &l){\n return p == l.a || p == l.b;\n}\n\ninline bool isOnSeg(const Po &p, const Seg &l){\n return sgn(det(p, l.a, l.b)) == 0 &&\n sgn(l.a.x, p.x) * sgn(l.b.x, p.x) <= 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) <= 0;\n}\n\ninline bool isOnSegg(const Po &p, const Seg &l){\n return sgn(det(p, l.a, l.b)) == 0 &&\n sgn(l.a.x, p.x) * sgn(l.b.x, p.x) < 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) < 0;\n}\n\ninline Po intersect(const Line &l1, const Line &l2){\n return l1.a + (l1.b - l1.a) * (det(l2.a, l1.a, l2.b) / det(l2, l1));\n}\n\n// perpendicular foot\ninline Po intersect(const Po & p, const Line &l){\n return intersect(Line(p, p + Po(l.a.y - l.b.y, l.b.x - l.a.x)), l);\n}\n\ninline Po rotate(Po p, DB alpha, const Po &o = Po()){\n p.rotate(alpha, o);\n return p;\n}\n\n} using namespace CG;//}\n//}\n\n/** Miscellaneous .. **/ //{\n// <<= 'Random Event .. . //{\nnamespace RNG{\n//srand((unsigned)time(NULL));\ninline unsigned int rand16(){return ((rand()) << 15) ^ rand();}\ninline unsigned int rand32(){return (rand16() << 16) | rand16();}\ninline ULL rand64(){return ((LL)rand32() << 32) | rand32();}\ninline ULL random(LL l, LL r){return l == r ? l : rand64() % (r - l) + l;}\nint dice(){return rand() % 6;}\nbool coin(){return bool(rand() % 2);}\n} using namespace RNG;\n//}\n// <<= 'Clock .. . //{\nnamespace CLOCK{\nDB s0, s1, rd, k, T;\ninline DB getTime(){\n#ifdef LOCAL\n return 1.0 * clock() / CLOCKS_PER_SEC;\n#else\n timeval tv;\n gettimeofday(&tv, 0);\n return tv.tv_sec + tv.tv_usec * 1e-6;\n#endif\n}\n\ninline void st0(DB _T = 0.98){T = _T, s0 = getTime();}\ninline void st1(DB _k = 1.618){k = _k, s1 = getTime();}\ninline void ed1(){rd = getTime() - s1;}\ninline DB elapsed(){return getTime() - s0;}\ninline bool TLE(){return elapsed() + rd * k < T;}\n} //using namespace CLOCK;\n//}\n// <<= 'Temp .. . //{\nnamespace TMP{\ntemplate PTT operator+(const PTT &p1, const PTT &p2) {\n\treturn PTT(p1.fi + p2.fi, p1.se + p2.se);\n}\n\ntemplate PTT operator-(const PTT &p1, const PTT &p2) {\n\treturn PTT(p1.fi - p2.fi, p1.se - p2.se);\n}\n\ntemplate PTT operator*(const PTT &lhs, T k){\n return PTT(lhs.fi * k, lhs.se * k);\n}\n} using namespace TMP;\n//}\n// <<= 'Bignum ., //{\nnamespace BIGNUM{\n\nconst int __base = 1e8;\nconst int P10[] = {1, 10, int(1e2), int(1e3), int(1e4), int(1e5), int(1e6), int(1e7), int(1e8), int(1e9)};\nconst int MAX_BUF_SIZE = 109;\nchar __buf[MAX_BUF_SIZE];\n\nclass bignum{\n friend istream& operator>>(istream&, bignum&);\n friend ostream& operator<<(ostream&, const bignum&);\n friend bignum operator +(const bignum&, const bignum&);\n friend bignum operator -(const bignum&, const bignum&);\n friend bignum operator *(const bignum&, const bignum&);\n friend bignum operator /(const bignum&, const bignum&);\n friend bignum operator %(const bignum&, const bignum&);\n friend bignum operator +(const bignum&, const int&);\n friend bignum operator -(const bignum&, const int&);\n friend bignum operator *(const bignum&, const int&);\n friend bignum operator /(const bignum&, const int&);\n friend bignum operator %(const bignum&, const int&);\n friend bool operator ==(const bignum&, const bignum&);\n friend bool operator !=(const bignum&, const bignum&);\n friend bool operator <(const bignum&, const bignum&);\n friend bool operator >(const bignum&, const bignum&);\n friend bool operator <=(const bignum&, const bignum&);\n friend bool operator >=(const bignum&, const bignum&);\n friend bool operator ==(const bignum&, const int&);\n friend bool operator !=(const bignum&, const int&);\n friend bool operator <(const bignum&, const int&);\n friend bool operator >(const bignum&, const int&);\n friend bool operator <=(const bignum&, const int&);\n friend bool operator >=(const bignum&, const int&);\n friend int do_comp(const bignum&, const int&);\n friend int do_comp(const bignum&, const bignum&);\n friend void divide(const bignum&, const bignum&, bignum&, bignum&);\n friend bignum pow(bignum, int);\n friend bignum pow(int, int);\n public:\n inline bignum(){};\n inline bignum(int s){\n while (s) data.PB(s%__base), s/=__base;\n if (data.empty()) data.PB(0);\n }\n\n inline bignum(long long s){\n while (s) data.PB(int(s%__base)), s/=__base;\n if (data.empty()) data.PB(0);\n }\n\n inline bignum(string s){\n int t, i; CLR(data);\n for (i=int(s.size())-8;i>0;i-=8){\n istringstream(s.substr(i, 8)) >> t;\n data.PB(t);\n }\n istringstream(s.substr(0, i+8)) >> t;\n data.PB(t);\n }\n\n void input(){\n CLR(data); RS(__buf); int t = 0, c = 0;\n DWN(i, strlen(__buf), 0){\n t += P10[c] * (int(__buf[i]) - '0'), ++c;\n if (c == 8) data.PB(t), c = t = 0;\n }\n if (c) data.PB(t);\n }\n\n void operator =(const int);\n void operator =(const string);\n void operator =(const bignum);\n bignum& operator +=(const bignum&);\n bignum& operator -=(const bignum&);\n bignum& operator *=(const bignum&);\n bignum& operator /=(const bignum&);\n bignum& operator %=(const bignum&);\n bignum& operator +=(const int&);\n bignum& operator -=(const int&);\n bignum& operator *=(const int&);\n bignum& operator /=(const int&);\n bignum& operator %=(const int&);\n bool undefined();\n int do_try(const int&);\n int do_try(const bignum&);\n void do_trim();\n list data;\n\n int size(){\n list::iterator it; int res = 0;\n for (it=data.begin(); it!=data.end();it++)\n res += 8;\n it--;\n if (*it >= 10000) {\n if ( (*it) >= 1000000) {if (*it >=10000000) ; else res--;}\n else {if ((*it) >= 100000) res-=2; else res-=3;}\n }\n else\n if ( (*it) >= 100) {if (*it >=1000) res-=4; else res-=5;}\n else {if ((*it) >= 10) res-=6; else res-=7;}\n\n return res;\n }\n\n void do_reserve(int a){\n if (a <= 0) return;\n list::iterator it;\n for (it=data.begin(); it!=data.end() && a>0; it++) a-=8;\n if (it == data.end() && a>=0) return;\n a+=8, it--; int f = 1;\n for (int i=0;i::const_iterator i=a.data.begin();i!=a.data.end();i++){\n data.PB(*i);\n }\n}\ninline void bignum::operator =(const string a){\n (*this) = bignum(a);\n}\ninline void bignum::operator =(const int a){\n (*this) = bignum(a);\n}\n\ninline istream& operator>>(istream& input, bignum& a){\n string s; int t, i; input >> s; a.data.clear();\n for (i=int(s.size())-8;i>0;i-=8){\n istringstream(s.substr(i, 8)) >> t;\n a.data.PB(t);\n }\n istringstream(s.substr(0, i+8)) >> t;\n a.data.PB(t);\n return input;\n}\n\ninline ostream& operator<<(ostream& output, const bignum& a){\n list::const_reverse_iterator i=a.data.rbegin();\n output << *i;\n for (i++;i!=a.data.rend();i++){\n if (*i >= 10000) {\n if (*i >= 1000000) {if (*i>=10000000) cout << *i; else cout << 0 << *i;}\n else {if (*i>=100000) cout << \"00\" << *i; else cout << \"000\" << *i;}\n }\n else {\n if (*i >= 100) {if (*i>=1000) cout << \"0000\" << *i; else cout << \"00000\" << *i;}\n else { if (*i>=10) cout << \"000000\" << *i; else cout << \"0000000\" << *i;}\n }\n }\n return output;\n}\n\ninline bool bignum::undefined(){\n return data.empty();\n}\n\ninline int do_comp(const bignum& a, const bignum& b){\n if (a.data.size()b.data.size()) return 1;\n list::const_reverse_iterator i; list::const_reverse_iterator j;\n for (i=a.data.rbegin(),j=b.data.rbegin(); j!=b.data.rend(); i++,j++){\n if (*i<*j) return -1; //!!!!\n if (*i>*j) return 1;\n }\n return 0;\n}\ninline int do_comp(const bignum& a, const int& b){\n return do_comp(a, bignum(b));\n}\n\ninline bool operator ==(const bignum& a, const bignum& b){\n return do_comp(a, b) == 0;\n}\ninline bool operator !=(const bignum& a, const bignum& b){\n return do_comp(a, b) != 0;\n}\ninline bool operator <(const bignum& a, const bignum& b){\n return do_comp(a, b) == -1;\n}\ninline bool operator >(const bignum& a, const bignum& b){\n return do_comp(a, b) == 1;\n}\ninline bool operator <=(const bignum& a, const bignum& b){\n return do_comp(a, b) != 1;\n}\ninline bool operator >=(const bignum& a, const bignum& b){\n return do_comp(a, b) != -1;\n}\n\ninline bool operator ==(const bignum& a, const int& b){\n return do_comp(a, b) == 0;\n}\ninline bool operator !=(const bignum& a, const int& b){\n return do_comp(a, b) != 0;\n}\ninline bool operator <(const bignum& a, const int& b){\n return do_comp(a, b) == -1;\n}\ninline bool operator >(const bignum& a, const int& b){\n return do_comp(a, b) == 1;\n}\ninline bool operator <=(const bignum& a, const int& b){\n return do_comp(a, b) != 1;\n}\ninline bool operator >=(const bignum& a, const int& b){\n return do_comp(a, b) != -1;\n}\n\ninline void bignum::do_trim(){\n while (data.size()>1&&data.back()==0) data.pop_back();\n}\n\ninline bignum& bignum::operator +=(const bignum& a){\n list::iterator i; list::const_iterator j; int t = 0;\n for (i=data.begin(),j=a.data.begin(); i!=data.end()&&j!=a.data.end(); i++,j++){\n *i+=*j+t; t=*i/__base; *i%=__base;\n }\n while (i!=data.end()) {*i+=t; t=*i/__base; *i%=__base; i++;}\n while (j!=a.data.end()) {data.PB(t+*j); t=data.back()/__base; data.back()%=__base; j++;}\n if (t!=0) data.PB(t);\n return *this;\n}\n\ninline bignum& bignum::operator -=(const bignum& a){\n list::iterator i; list::const_iterator j; int t = 0;\n for (i=data.begin(),j=a.data.begin(); j!=a.data.end(); i++,j++){\n *i -= t+*j; if (*i>=0) t=0; else *i+=__base, t=1;\n }\n while (i!=data.end()) {*i-=t; if (*i>=0) t=0;else *i+=__base, t=1; i++;}\n (*this).do_trim();\n return *this;\n}\n\ninline bignum& bignum::operator +=(const int& a){\n return (*this)+=bignum(a);\n}\n\ninline bignum& bignum::operator -=(const int& a){\n return (*this)-=bignum(a);\n}\n\ninline bignum operator +(const bignum& a, const bignum& b){\n list::const_iterator i, j; bignum c; int t = 0;\n for (i=a.data.begin(),j=b.data.begin(); i!=a.data.end()&&j!=b.data.end(); i++,j++){\n c.data.PB(t+*i+*j);\n t=c.data.back()/__base; c.data.back()%=__base;\n }\n while (i!=a.data.end()) {c.data.PB(t+*i); t=c.data.back()/__base; c.data.back()%=__base; i++;}\n while (j!=b.data.end()) {c.data.PB(t+*j); t=c.data.back()/__base; c.data.back()%=__base; j++;}\n if (t!=0) c.data.PB(t);\n return c;\n}\n\ninline bignum operator -(const bignum& a, const bignum& b){\n list::const_iterator i, j; bignum c; int t = 0;\n for (i=a.data.begin(),j=b.data.begin(); j!=b.data.end(); i++,j++){\n t = *i - t;\n if (t>=*j) c.data.PB(t-*j), t=0;\n else c.data.PB(t+__base-*j), t=1;\n }\n while (i!=a.data.end()) {t=*i-t; if (t>=0) c.data.PB(t), t=0;else c.data.PB(t+__base), t=1; i++;}\n c.do_trim();\n return c;\n}\n\ninline bignum operator *(const bignum& a, const bignum& b){\n list::const_iterator i, j; list::iterator k, kk; bignum c; long long t = 0;\n\n for (int i=0;i::const_reverse_iterator i = a.data.rbegin(); int t;\n d = bignum(0); r = bignum(0);\n do {\n while (r=b){\n t = r.do_try(b); d.data.front() = t;\n r-=(b*bignum(t));\n }\n } while (i!=a.data.rend());\n d.do_trim();\n}\n\ninline bignum operator /(const bignum& a, const bignum& b){\n bignum d, r;\n divide(a, b, d, r);\n return d;\n}\n\ninline bignum operator %(const bignum& a, const bignum& b){\n bignum d, r;\n divide(a, b, d, r);\n return r;\n}\n\ninline bignum operator +(const bignum& a, const int& b){\n return a+bignum(b);\n}\n\ninline bignum operator -(const bignum& a, const int& b){\n return a-bignum(b);\n}\n\ninline bignum operator *(const bignum& a, const int& b){\n return a*bignum(b);\n}\n\ninline bignum operator /(const bignum& a, const int& b){\n return a/bignum(b);\n}\n\ninline bignum operator %(const bignum& a, const int& b){\n return a%bignum(b);\n}\n\ninline bignum& bignum::operator *=(const bignum& a){\n (*this) = (*this) * a;\n return *this;\n}\n\ninline bignum& bignum::operator /=(const bignum& a){\n (*this) = (*this) / a;\n return *this;\n}\n\ninline bignum& bignum::operator %=(const bignum& a){\n (*this) = (*this) % a;\n return *this;\n}\n\ninline bignum& bignum::operator *=(const int& a){\n return (*this)*=bignum(a);\n}\n\ninline bignum& bignum::operator /=(const int& a){\n return (*this)/=bignum(a);\n}\n\ninline bignum& bignum::operator %=(const int& a){\n return (*this)%=bignum(a);\n}\n\ninline bignum pow(bignum a,int b){\n bignum c(1);\n while (b!=0) {\n if (b&1) c *= a;\n a = a * a; b >>= 1;\n }\n return c;\n}\ninline bignum pow(int a, int b){\n return pow(bignum(a), b);\n}\n\n} //using namespace BIGNUM;\n//}\n//}\n\n/** I/O Accelerator Interface .. **/ //{\ntemplate inline T& RD(T &x){\n //cin >> x;\n //scanf(\"%d\", &x);\n char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';\n //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n return x;\n}\n\ninline DB& RF(DB &x){\n //cin >> x;\n scanf(\"%lf\", &x);\n /*char t; while ((t=getchar())==' '||t=='\\n'); x = t - '0';\n while ((t=getchar())!=' '&&t!='\\n'&&t!='.')x*=10,x+=t-'0';\n if (t=='.'){DB l=1; while ((t=getchar())!=' '&&t!='\\n')l*=0.1,x += (t-'0')*l;}*/\n return x;\n}\n\ninline char* RS(char *s){\n //gets(s);\n scanf(\"%s\", s);\n return s;\n}\n\nLL last_ans; int Case; template inline void OT(const T &x){\n //printf(\"Case %d: %d\\n\", ++Case, x);\n //printf(\"%.2lf\\n\", x);\n //printf(\"%d\\n\", x);\n cout << x << endl;\n //last_ans = x;\n}\n//}\n\n//}/* .................................................................................................................................. */\n\nconst int N = int(150) + 9;\n\nstruct Int{\n int val;\n\n operator int() const{return val;}\n\n Int(int val = 0):val(val){\n val %= MOD; if (val < 0) val += MOD;\n }\n inline Int& operator +=(Int rhs){\n INC(val, rhs);\n return *this;\n }\n inline Int operator +(Int rhs) const{\n return sum(val, rhs.val);\n }\n inline Int operator -(Int rhs) const{\n return dff(val, rhs);\n }\n};\n\nInt dp[2][2][2][N][N];\nint n, m;\n\nint main(){\n\n#ifndef ONLINE_JUDGE\n freopen(\"in.txt\", \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n#endif\n\n RD(n, m); Int res; int p = 0, q = 1; REP(i, n){\n#define u dp[q][b1][b2][l][r]\n#define v dp[p][bb1][bb2][ll][rr]\n#define ll (!b1 && bb1 ? l+1 : l)\n#define rr (!b2 && bb2 ? r-1 : r)\n RST(dp[p]); REP_4(b1, b2, r, l, 2, 2, m, r+1) if (u)\n FOR(bb1, b1, 2) FOR(bb2, b2, 2) if (ll <= rr) v += u;\n#undef ll\n#undef rr\n#define d(o) (o ? 1 : -1)\n#define ll (l + d(b1))\n#define rr (r - d(b2))\n\n#define upd1{\\\n ls = b1 ? 0 : m-1, lt = b1 ? m : -1; \\\n for (int l=ls;l!=lt;l+=d(b1)) \\\n FOR(r, l, m) if (cur[l][r] && ll >= 0) cur[ll][r] += cur[l][r]; \\\n}\n\n#define upd2{\\\n rs = b2 ? m-1 : 0, rt = b2 ? -1 : m; \\\n for (int r=rs;r!=rt;r-=d(b2)) \\\n REP(l, r+1) if (cur[l][r]) cur[l][rr] += cur[l][r]; \\\n}\n\n REP_2(b1, b2, 2, 2){\n Int (*cur)[N] = dp[p][b1][b2]; int ls, lt, rs, rt;\n if (!b1 && b2){upd2; upd1;}else{upd1; upd2;}\n }\n\n REP_2(r, l, m, r+1) dp[p][0][0][l][r] += 1;\n swap(p, q); REP_4(b1, b2, r, l, 2, 2, m, r+1) if(u) res += u;\n }\n\n OT(res);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "842371614e36442b26aae4fce3974603", "src_uid": "740eceed59d3c6ac55c1bf9d3d4160c7", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\nint x, y;\n\nint main()\n{\n freopen(\"a.in\", \"r\", stdin);\n freopen(\"a.out\", \"w\", stdout);\n int n, m, bx, by;\n long long X = 0, Y = 0;\n cin >> n >> bx;\n for (int i = 0; i < n; i++)\n {\n cin >> x;\n X += x * pow(bx, n - i - 1);\n\n }\n cin >> m >> by;\n for (int i = 0; i < m; i++)\n {\n cin >> y;\n Y += y * pow(by, m - i - 1);\n\n }\n // cout << X << \" \" << Y << \"\\n\";\n if (X > Y) cout << \">\";\n if (X == Y) cout << \"=\";\n if (X < Y) cout << \"<\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e24ca0a2faf34824f364eeddd728138b", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \n#define FAST_READ ios_base::sync_with_stdio(0);\n#define ll long long\n#define pb push_back\n#define mp make_pair\n#define all(x) (x).begin(), (x).end()\n#define endl \"\\n\"\n#define MAXN 100000010\n\nusing namespace std;\n\nvectorans;\nll used[MAXN];\n\nll n;\n\nint main(){\nFAST_READ;\ncin>>n;\nused[1]=2;\nused[2]=3;\nll cnt=4;\nfor(ll i=3;i<=n;i+=2)\n{\n used[i]=cnt;\n used[i+1]=cnt;\n cnt++;\n}\ncout<\n#define ll long long\nusing namespace std;\nbool vis[10000001];\nint main()\n{\n ll n;\n cin>>n;\n ll cnt=0;\n for(ll j=0;j<=n;j+=3)\n vis[j]=1;\n for(ll j=0;j<=n;j+=5)\n vis[j]=1;\n for(ll j=0;j<=n;j+=7)\n vis[j]=1;\n for(ll j=0;j<=n;j+=9)\n vis[j]=1;\n for(ll i=1;i<=n;i+=2)\n if(!vis[i])\n cnt++;\n cout<\nint a[1000001];\nint b[1000001];\nint c[1000001];\n\n\nint main()\n{\n int n;\n int t;\n int i, j;\n int swap;\n while(scanf(\"%d\", &n)!= EOF)\n {\n for(i = 0; i < n; i++)\n scanf(\"%d\", &a[i]);\n for(i = 0; i < (n - 1); i++)\n scanf(\"%d\", &b[i]);\n for(i = 0; i < (n - 2); i++)\n scanf(\"%d\", &c[i]);\n for(j = 0; j < n - 1; j++)\n {\n swap = 1;\n for(i = 0; i < n - 1 - j; i++)\n if(a[i]>a[i+1])\n {\n swap = 0;\n t = a[i];\n a[i] = a[i + 1];\n a[i + 1] = t;\n }\n if(swap) break;\n }\n for(j = 0; j < n - 2; j++)\n {\n swap = 1;\n for(i = 0; i < n - 2 - j; i++)\n if(b[i]>b[i+1])\n {\n swap = 0;\n t = b[i];\n b[i] = b[i + 1];\n b[i + 1] = t;\n }\n if(swap) break;\n }\n for(j = 0; j < n - 3; j++)\n {\n swap = 1;\n for(i = 0; i < n - 3 - j; i++)\n if(c[i]>c[i+1])\n {\n swap = 0;\n t = c[i];\n c[i] = c[i + 1];\n c[i + 1] = t;\n }\n if(swap) break;\n }\n for(i = 0; i < n; i++)\n if(a[i] != b[i])\n {\n printf(\"%d\\n\", a[i]);\n break;\n }\n\n for(i = 0; i < n - 1; i++)\n if(b[i] != c[i])\n {\n printf(\"%d\\n\", b[i]);\n break;\n }\n }\nreturn 0;\n}\n\n\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0b25c9d6a72611163758963c52887a9c", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\nusing namespace std;\nmain()\n{\n char s[105];\n static int x,y,i,j=0,a,b,c,d,k=0;\n gets(s);\n for(i=0;i1&&((a==2*i+1||a==2*i+2)&&b>=3*i&&c>=i&&d>=i))\n {\n i++;break;\n }\n if(i<2&&(a<3*i||b<3*i||c\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n\tint a, b, c;\n\tcin >> a >> b >> c;\n\tint count = 0;\n\twhile ((a + b <= c)&&(a+c>b)&&(b+c>a))\n\t{\n\t\ta++;\n\t\tcount++;\n\t}\n\twhile ((a + b > c) && (a + c <= b) && (b + c > a))\n\t{\n\t\tc++;\n\t\tcount++;\n\t}\n\twhile ((a + b > c) && (a + c > b) && (b + c <= a))\n\t{\n\t\tb++;\n\t\tcount++;\n\t}\n\tcout << count;\n\t_getch();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "067bad59dd462435ef9a78fdb0791e26", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "MS C++", "source_code": "\ufeff#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nmapmp;\nint a, b, c, d, e, f, atk, hp, def,ans=10000000000;\nvoid dfs(int ca,int cb,int cc,int cur)\n{\n\tif (e<=cc&&cb>e||(ca-1) / (e - cc) > (d-1)/ (cb - f))\n\t{\n\t\tint y = (ca - a)*hp + (cb - b)*atk + (cc - c)*def;\n\t\tif (y < ans)\n\t\t\tans = y;\n\t\treturn;\n\t}\n\tif (cur == 1)\n\t{\n\t\tdfs(ca + 1, cb, cc, cur);\n\t\tdfs(ca, cb, cc + 1, cur + 1);\n\t}\n\telse if (cur == 2)\n\t{ dfs(ca, cb, cc + 1,cur);\n\t if (e <= cc || (ca - 1) / (e - cc) != 0)\n\t\tdfs(ca, cb + 1, cc, cur + 1);\n\t}\n\telse \n\t\tdfs(ca, cb + 1, cc, cur);\n\t\t\n}\nint main()\n{\n\tcin >> a >> b >> c >> d >> e >> f >> hp >> atk >> def;\n\t\n\tint add = 0;\n\tif (b\nusing namespace std;\nconst int N=1e5+5;\nint a[N],b[N];\nchar c[N];\nint main()\n{\n int n,maxx=0,l,r;\n scanf(\"%d\",&n);\n scanf(\"%s\",c);\n for(int i=0;i b;\n int cnt=0;\n for(int t=0;t b;\n for(int k=n-t+1;k<=n;k++)\n {\n if(!b.empty())\n {\n if(a[k]==1) b.push(1);\n if(a[k]==2)\n {\n if(b.top()==1) b.pop();\n if(b.top()==2)\n {\n flag=false;\n break;\n }\n }\n }\n if(b.empty())\n {\n if(a[k]==1) b.push(1);\n if(a[k]==2)\n {\n flag=false;\n break;\n }\n }\n }\n for(int k=1;k<=n-t;k++)\n {\n if(!b.empty())\n {\n if(a[k]==1) b.push(1);\n if(a[k]==2)\n {\n if(b.top()==1) b.pop();\n if(b.top()==2)\n {\n flag=false;\n break;\n }\n }\n }\n if(b.empty())\n {\n if(a[k]==1) b.push(1);\n if(a[k]==2)\n {\n flag=false;\n break;\n }\n }\n }\n if(!b.empty()) flag=false;\n if(flag) cnt++;\n }\n if(cnt>maxx)\n {\n maxx=cnt;\n l=i;r=j;\n }\n swap(a[i],a[j]);\n }\n }\n printf(\"%d\\n%d %d\\n\",maxx,l,r);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e351e2a457c72588b90d862125834211", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "MS C++", "source_code": "#include \n#include \nconst int N=328;\nvoid main()\n{\n\tint l, r, i, x, y, count=0;\n\tint A[N]={ 1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 128, 144, 162, 192, 216, 243, 256, 288, 324, 384, 432, 486, 512, 576, 648, 729, 768, 864, 972, 1024, 1152, 1296, 1458, 1536, 1728, 1944, 2048, 2187, 2304, 2592, 2916, 3072, 3456, 3888, 4096, 4374, 4608, 5184, 5832, 6144, 6561, 6912, 7776, 8192, 8748, 9216, 10368, 11664, 12288, 13122, 13824, 15552, 16384, 17496, 18432, 19683, 20736, 23328, 24576, 26244, 27648, 31104, 32768, 34992, 36864, 39366, 41472, 46656, 49152, 52488, 55296, 59049, 62208, 65536, 69984, 73728, 78732, 82944, 93312, 98304, 104976, 110592, 118098, 124416, 131072, 139968, 147456, 157464, 165888, 177147, 186624, 196608, 209952, 221184, 236196, 248832, 262144, 279936, 294912, 314928, 331776, 354294, 373248, 393216, 419904, 442368, 472392, 497664, 524288, 531441, 559872, 589824, 629856, 663552, 708588, 746496, 786432, 839808, 884736, 944784, 995328, 1048576, 1062882, 1119744, 1179648, 1259712, 1327104, 1417176, 1492992, 1572864, 1594323, 1679616, 1769472, 1889568, 1990656, 2097152, 2125764, 2239488, 2359296, 2519424, 2654208, 2834352, 2985984, 3145728, 3188646, 3359232, 3538944, 3779136, 3981312, 4194304, 4251528, 4478976, 4718592, 4782969, 5038848, 5308416, 5668704, 5971968, 6291456, 6377292, 6718464, 7077888, 7558272, 7962624, 8388608, 8503056, 8957952, 9437184, 9565938, 10077696, 10616832, 11337408, 11943936, 12582912, 12754584, 13436928, 14155776, 14348907, 15116544, 15925248, 16777216, 17006112, 17915904, 18874368, 19131876, 20155392, 21233664, 22674816, 23887872, 25165824, 25509168, 26873856, 28311552, 28697814, 30233088, 31850496, 33554432, 34012224, 35831808, 37748736, 38263752, 40310784, 42467328, 43046721, 45349632, 47775744, 50331648, 51018336, 53747712, 56623104, 57395628, 60466176, 63700992, 67108864, 68024448, 71663616, 75497472, 76527504, 80621568, 84934656, 86093442, 90699264, 95551488, 100663296, 102036672, 107495424, 113246208, 114791256, 120932352, 127401984, 129140163, 134217728, 136048896, 143327232, 150994944, 153055008, 161243136, 169869312, 172186884, 181398528, 191102976, 201326592, 204073344, 214990848, 226492416, 229582512, 241864704, 254803968, 258280326, 268435456, 272097792, 286654464, 301989888, 306110016, 322486272, 339738624, 344373768, 362797056, 382205952, 387420489, 402653184, 408146688, 429981696, 452984832, 459165024, 483729408, 509607936, 516560652, 536870912, 544195584, 573308928, 603979776, 612220032, 644972544, 679477248, 688747536, 725594112, 764411904, 774840978, 805306368, 816293376, 859963392, 905969664, 918330048, 967458816, 1019215872, 1033121304, 1073741824, 1088391168, 1146617856, 1162261467, 1207959552, 1224440064, 1289945088, 1358954496, 1377495072, 1451188224, 1528823808, 1549681956, 1610612736, 1632586752, 1719926784, 1811939328, 1836660096, 1934917632, 2000000001 }; \n\tscanf(\"%d%d\", &l, &r);\n\tfor (i=0; A[i]<=l; i++)\n\t\ty=i;\n\tfor (i=0; A[i]<=r; i++)\n\t\tx=i;\n\tfor (i=0; i<327; i++)\n\t\tif ( A[i]==l)\n\t\t\tx++;\n\tcount= x-y;\n\tprintf(\"%d\\n\", count);\n\t_getch();\n\treturn;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "618d25440669c7e356554df69bf2b77c", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef unsigned int index;\n\nindex dfs(index v, const vector> &g, const vector &num, size_t &sz)\n{\n\tif (g[v].size() == 0)\n\t\tsz++;\n\tindex mrg = (index)-1;\n\tfor (auto i: g[v])\n\t{\n\t\tmrg = min(mrg, dfs(i, g, num, sz));\n\t}\n\tfor (index i = 0; i < 4; i++)\n\t\tif (num[i] == v)\n\t\t\treturn i;\n\treturn mrg;\n}\n\nint main()\n{\n#ifdef ONPC\n\tassert(freopen(\"a.in\", \"r\", stdin));\n\tassert(freopen(\"a.out\", \"w\", stdout));\n#else\n#endif\n\tsize_t n;\n\tcin >> n;\n\tvector num(4);\n\tfor (index i = 0; i < 4; i++)\n\t\tcin >> num[i], num[i]--;\n\tvector size;\n\tvector ns(4);\n\tvector> g(n);\n\tfor (index i = 1; i < n; i++)\n\t{\n\t\tindex p;\n\t\tcin >> p;\n\t\tp--;\n\t\tg[p].push_back(i);\n\t}\n\tsize_t sum = 0;\n\tfor (auto i: g[0])\n\t{\n\t\tsize_t sv = 0;\n\t\tindex j = dfs(i, g, num, sv);\n\t\tif (j == (index)-1)\n\t\t{\n\t\t\tsize.push_back(sv);\n\t\t\tsum += sv;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tns[j] = sv;\n\t\t}\n\t}\n\tvector d(sum + 1);\n\td[0] = true;\n\tfor (auto sz: size)\n\t{\n\t\tfor (index i = 0; i < sum; i++)\n\t\t{\n\t\t\tif (!d[i])\n\t\t\t\tcontinue;\n\t\t\td[i + sz] = true;\n\t\t}\n\t}\n\tsize_t ssum = ns[0] + ns[1] + ns[2] + ns[3] + sum;\n\tif (ssum % 2 == 1)\n\t{\n\t\tcout << \"NO\" << endl;\n\t\treturn 0;\n\t}\n\tssum /= 2;\n\tfor (index i = 0; i < sum + 1; i++)\n\t{\n\t\tif (!d[i])\n\t\t\tcontinue;\n\t\tsize_t ls = (size_t)i, rs = sum - i;\n\t\tif (ls + ns[2] < ssum and rs + ns[3] < ssum and ns[0] < ssum and ns[1] < ssum)\n\t\t{\n\t\t\tcout << \"YES\" << endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout << \"NO\" << endl;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c145e56d784f48cd6c950c657071dc3f", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.0} {"lang": "GNU C++17 (64)", "source_code": "#include \r\nusing namespace std;\r\ntypedef long long ll;\r\ntypedef pair PLL;\r\nconst int N = 1e6 + 10;\r\ninline ll read() {\r\n ll x = 0, f = 1;\r\n char ch = getchar();\r\n while (ch < '0' || ch > '9') {\r\n if (ch == '-') f = -1;\r\n ch = getchar();\r\n }\r\n while (ch >= '0' && ch <= '9') {\r\n x = (x << 1) + (x << 3) + (ch ^ 48);\r\n ch = getchar();\r\n }\r\n return x * f;\r\n}\r\nvoid slove() {\r\n int s[3][3];\r\n s[1][1] = read();\r\n s[1][2] = read();\r\n s[2][1] = read();\r\n s[2][2] = read();\r\n int cnt = 0;\r\n if (s[1][1] == 1) cnt++;\r\n if (s[1][2] == 1) cnt++;\r\n if (s[2][1] == 1) cnt++;\r\n if (s[2][2] == 1) cnt++;\r\n if (cnt == 4) {\r\n cout << 2 << endl;\r\n return;\r\n }\r\n if (cnt == 0) {\r\n cout << 0 << endl;\r\n return;\r\n }\r\n cout << 1 << endl;\r\n}\r\nvoid init() {\r\n ios::sync_with_stdio(false);\r\n cin.tie(nullptr);\r\n cout.tie(nullptr);\r\n}\r\nint main () {\r\n init();\r\n int t;\r\n cin >> t;\r\n while (t--) slove();\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "75bf958fb4dc2b71c25f4fda2f0a7363", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#define For(i,a,b) for(int i=a;i<=b;i++)\n#define Ford(i,a,b) for(int i=a;i>=b;i--)\n#define dream_hyojooslh\n\nusing namespace std;\nconst int N=100000+1067;\nint f[N];\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n // freopen(\"dream_hyojooslh.inp\",\"r\",stdin);\n long long s,x1,x2,t1,t2,p,d;\n cin>>s>>x1>>x2;\n cin>>t1>>t2;\n cin>>p>>d;\n if (t1>t2) {\n cout<x2) {\n if (d==-1) {\n if (px2) {\n res=min(res,(p-x2)*t1);\n }\n } else\n {\n if (d==1) {\n if (p>x1) p=0-(s-p)-s;\n } else\n {\n p=-p;\n }\n long long dmoi=(x1-p)*t1;\n dmoi/=tt;\n if (x1+dmoi\n\nusing namespace std;\n\nstruct SEG{\n\tint l,r;\n}seg[100+10];\nstruct POINT{\n\tint x,no,c;\n}p[100+10];\n\nint n,m;\nint cmp1(POINT a,POINT b)\n{\n\treturn a.x>n>>m;\n\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tcin>>p[i].x;\n\t\tp[i].no=i;\n\t}\n\tfor(int i=1;i<=m;i++)\n\t\tcin>>seg[i].l>>seg[i].r;\n\tsort(p+1,p+1+n,cmp1);\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tif(i%2) p[i].c=1;\n\t\telse p[i].c=0;\n\t}\n\tsort(p+1,p+1+n,cmp2);\n\tint ok=0;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tfor(int j=1;j<=m;j++)\n\t\t{\n\t\t\tif(p[i].x<=seg[j].r && p[i].x>=seg[j].l)\n\t\t\t{\n\t\t\t\tok=1;break;\n\t\t\t}\n\t\t}\n\t}\n\tif(!ok) {cout<<\"-1\"<\nusing namespace std;\n\n#define fi first\n#define se second\n#define pb push_back\n#define all(x) x.begin(), x.end()\n#define mp make_pair\n\ntypedef long long ll;\ntypedef unsigned long long int ull;\ntypedef long double ld;\n\ntypedef pair pii;\ntypedef pair pli;\n\ntypedef vector vll;\ntypedef vector vpii;\ntypedef vector vi;\n\ntypedef map msi;\ntypedef map mii;\ntypedef map mill;\ntypedef map mivi;\n\nconst int MAXN = 19;\nconst int B = 16;\nconst string S = \"0123456789abcdef\";\n\nmap memo[MAXN];\nint dig[MAXN];\n\nint m, n;\nll k, ans;\nll lo = 1, hi = 3e10;\nint cnt = 0;\n\nvoid fast_io() {\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\n}\n\nbool blank(vi &a) {\n\tfor(int i = 0; i < B; i++)\n\t\tif(a[i]) return false;\n\treturn true;\n}\n\nll solve(int pos, vi a, bool t) {\n\tif(!pos) {\n\t\tif(blank(a)) return 0;\n\t\tbool ok = 1, nz = 0;\n\t\tfor(int i = 0; i < B; i++) {\n\t\t\tok &= (a[i] <= m);\n\t\t}\n\t\treturn ok;\n\t}\n\t\n\tif(!t and memo[pos].count(a))\n\t\treturn memo[pos][a];\n\t\n//\tprintf(\"state count = %d\\n\", ++cnt);\n\t\n\tll res = 0;\n\tint lim = t ? dig[pos] : B - 1;\n\tvi b = a;\n\t\n\tfor(int i = 0; i <= lim; i++) {\n\t\tif(!i and blank(b)) res += solve(pos - 1, b, !(i ^ lim) & t);\n\t\telse if(b[i] + 1 <= m) {\n\t\t\t++b[i];\n\t\t\tres += solve(pos - 1, b, !(i ^ lim) & t);\n\t\t\t--b[i];\n\t\t}\n\t}\n\t\n\t++cnt;\n\t\n\tif(!t) memo[pos][a] = res;\n\treturn res;\n}\n\nll count(ll x) {\n\tn = 0;\n\twhile(x) {\n\t\tdig[++n] = (x % B);\n\t\tx /= B;\n\t}\n\tvi s(B, 0);\n\treturn solve(n, s, 1);\n}\n\nint main() {\n\tfast_io();\n//\tfreopen(\"input/747F.txt\", \"r\", stdin);\n\t\n\tcin >> k >> m;\n\twhile(lo <= hi) {\n\t\tll mid = (lo + hi) >> 1;\n\t\tif(count(mid) >= k) ans = mid, hi = mid - 1;\n\t\telse lo = mid + 1; \n\t}\n\t\n\tvector c;\n\twhile(ans) {\n\t\tc.pb(S[ans % B]);\n\t\tans /= B;\n\t}\n\treverse(all(c));\n\t\n\tfor(auto i : c) {\n\t\tcout << i;\n\t}\n\tcout << '\\n';\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "953d6406acbfb5f63a627b9686d21b3c", "src_uid": "cbfc354cfa392cd021d9fe899a745f0e", "difficulty": 2500.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nbool checkWin(int a1, int b1, int a2, int b2){\n\tif(a1> a2 && b1>b2)return true;\n\treturn false;\n}\n\nint main(){\n\twhile(true){\n\tint a[4], b[4];\n\tfor(int i = 0;i<4;i++){\n\t\tscanf(\"%d%d\", &a[i], &b[i]);\n\t}\n\tif(checkWin(a[0], b[1], a[2], b[3]) && checkWin(a[0], b[1], a[3], b[2])\n\t|| checkWin(a[1], b[0], a[2], b[3]) && checkWin(a[1], b[0], a[3], b[2]))\n\t{\n\t\tputs(\"Team 1\");\n\t}else if((checkWin(a[2], b[3], a[0], b[1])||checkWin(a[3], b[2], a[0], b[1])) &&\n\t(checkWin(a[2], b[3], a[1], b[0])||checkWin(a[3], b[2], a[1], b[0])))\n\t{\n\t\tputs(\"Team 2\");\n\t}else {\n\t\tputs(\"Draw\");\n\t}\n}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9e54dbea6811caa9f8a095dba997d2cb", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "//IN HIS NAME\n#include \n\nusing namespace std;\n\nint a[1000],b[1000];\n\nint main(){\n\tios::sync_with_stdio(false);\n\tint n,m,c=0,k=0;\n\tcin>>n>>m;\n\tfor(int i=0;i<=31;i++){\n\t\tfor(int j=0;j<=31;j++){\n\t\t\ta[k]=(i*i)+j;\n\t\t\tb[k]=(j*j)+i;\n\t\t\tif((a[k]==n)&&(b[k]==m))\n\t\t\t\tc++;\n\t\t\t//if(a[k]>100+n&&b[k]>m+100){\n\t\t\t\t//\tcout<\n\nusing namespace std;\n\ntypedef long long int lo;\ntypedef pair< lo,lo > PII;\n\n#define fi first\n#define se second\n#define mp make_pair\n#define pb push_back\n#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)\n#define FOR for(int i=1;i<=n;i++)\n\nconst lo inf = 100000000000000;\nconst lo mod = 1000000007;\nconst lo KOK = 100000;\nconst lo li = 100005;\nconst lo LOG = 20;\n\nlo n,m,cev,x,mn=inf;\nunordered_map prime;\nvector< PII > v;\nchar c;\nstring s;\n\nvoid sieve(lo sayi){\n\tfor(lo p=3;p<=sayi;p+=2){\n\t\tif(prime[p]==1) continue;\n\t\t//~ cevap++;\n\t\tfor(lo i=p*p;i<=sayi;i+=p){\n\t\t\tprime[i]=1;\n\t\t}\n\t}\n\tif(sayi%2==0)\n\t\tv.pb(mp(2,0));\n\tfor(lo i=3;i*i<=sayi;i+=2){\n\t\tif(prime[i]==0){\n\t\t\tif(sayi%i==0)\n\t\t\t\tv.pb(mp(i,0));\n\t\t}\n\t}\n}\n\nint main(){\n\tscanf(\"%lld %lld\",&n,&m);\n\tsieve(m);\n\tfor(lo i=0;i<(lo)v.size();i++){\n\t\t\n\t\tlo xx=0;\n\t\twhile(m%v[i].fi==0){\n\t\t\t\n\t\t\tm/=v[i].fi;\n\t\t\txx++;\n\t\t}\n\t\tv[i].se=xx;\n\t\tcev=0;\n\t\tlo yes=n;\n\t\twhile(yes){\n\t\t\t\n\t\t\tyes/=v[i].fi;\n\t\t\tcev+=yes;\n\t\t}\n\t\t//~ cout<<\"**\\n\"<0)\n\t\t\tmn=min(mn,cev/xx);\n\t}\n\t//~ printf(\"**\\n\");\n\tif(m>1){\n\t\t\n\t\tlo xx=1;\n\t\t\n\t\t//~ v[i].se=xx;\n\t\tcev=0;\n\t\tlo yes=n;\n\t\twhile(yes){\n\t\t\t\n\t\t\tyes/=m;\n\t\t\tcev+=yes;\n\t\t}\n\t\t//~ cout<<\"**\\n\"<\n#include\n#include\n#include\n#include\n#define N_ 301000\n#define pii pair\nusing namespace std;\nint n, m, Q, P[201000], chk[301000], UF[201000], NN[201000];\nvectorG[201000];\nstruct Edge{\n int a, b;\n}Ed[301000];\nstruct Query{\n int ck, a;\n}U[501000];\nint Find(int a){\n if(a==UF[a])return a;\n return UF[a]=Find(UF[a]);\n}\nint Where[201000], cnt;\nint O[5100000], CCC[510000], cur;\nmultisetZ[201000];\nvoid Merge(int a, int b, int c){\n a = Find(a),b=Find(b);\n if(a==b)return;\n if(a!=b){\n if(G[a].size()=1;i--){\n if(U[i].ck==2){\n int t = U[i].a;\n Merge(Ed[t].a,Ed[t].b,i);\n }\n }\n int cc=0;\n for(i=1;i<=n;i++)if(Find(i)==i)NN[i]=++cc;\n for(i=1;i<=n;i++){\n int x = NN[Find(i)];\n Z[x].insert(P[i]);\n Where[i] = x;\n }\n cnt = cc;\n for(i=1;i<=Q;i++){\n if(U[i].ck==2){\n if(!CCC[i])continue;\n cnt++;\n for(int j=0;j\nint a[110],i,n;\nmain(){\n\tscanf(\"%d\",&n);\n\ta[2]=2;\n\ta[3]=4;\n\tfor(i=4;i<=n;i++){\n\t\ta[i]=a[i-2]+i;\n\t}\n\tprintf(\"%d\",a[n]);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "16a3f86c2f1a3469c962e7b264dad6d7", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "//#include\n#include\n#include\n#include\n//#include\nusing namespace std;//-48\nifstream fin(\"input.txt\");\nofstream fout(\"output.txt\");\n\nint main(){\n\tint n,k,x;\n\tvector chores;\n\tint i;\n\tint c;\n\tint sum=0;\n\t\n\tfin>>n>>k>>x;\n\tfor(i=0;i>c;\n\t\tchores.push_back(c);\n\t}\n//\tsort(chores.begin(),chores.end());\n\tfor(i=n-1;i>=0;i--){\n\t\tif(k>0){\n\t\t\tsum+=x;\n\t\t\tk--;\n\t\t}\n\t\telse\n\t\t\tsum+=chores[i];\n\t}\n\t\n\tfout<\n#include\n\nusing namespace std;\n\nint main()\n{\n ifstream fin(\"input.txt\");\n ofstream fout(\"output.txt\");\n int a[4];\n int b[4];\n int i,sum=0;\n for(i=0;i<3;i++)\n fin>>a[i];\n \n for(i=0;i<3;i++)\n fin>>b[i];\n \n for(i=0;i<3;i++)\n if(a[i]==b[i])\n sum++;\n if(sum>=2)\n fout<<\"YES\"<\n#include \n#include \n\nbool impossible = false;\n\nint64_t choose(int64_t qp, int k) {\n int64_t l0 = -qp;\n int64_t r0 = -qp + k - 1; // -1 for strict inequality\n\n //std::cout << \"l0 = \" << l0 << \", r0 = \" << r0 << std::endl;\n\n if (l0 <= 0 && r0 >= 0) {\n // 0 is possible\n return 0;\n } else {\n int64_t l = -1e17;\n int64_t r = +1e17;\n while (l < r) {\n int64_t m = (l + r) / 2; \n if (m * k > r0) {\n r = m - 1;\n } else if (m * k < l0) {\n l = m + 1;\n } else {\n return m;\n }\n }\n //std::cout << \"Found l = \" << l << std::endl;\n if (l * k < l0 || l * k > r0) {\n impossible = true;\n return 123; /* whatever */\n }\n return l;\n }\n}\n\nint main() {\n int64_t p, k;\n std::cin >> p >> k;\n std::vector q;\n\n int64_t q0 = choose(p, k);\n //std::cout << \"q[0] = \" << q0 << std::endl;\n q.push_back(q0);\n\n int64_t qq = q0;\n while (qq != 0 && !impossible) {\n qq = choose(qq, k);\n q.push_back(qq);\n //std::cout << \"q[i] = \" << qq << std::endl;\n }\n while (!impossible && *(q.end() - 1) == 0) {\n q.pop_back();\n }\n if (impossible) {\n std::cout << -1 << std::endl;\n return 0;\n }\n std::vector f;\n f.push_back(q[0] * k + p);\n for (int i = 1; i < q.size(); i++) {\n f.push_back(q[i-1] + q[i] * k);\n }\n f.push_back(q[q.size() - 1]);\n std::cout << f.size() << std::endl;\n for (int i = 0; i < f.size(); i++) {\n std::cout << f[i] << \" \";\n }\n std::cout << std::endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f2c0391ad10065e2b67c8bb387f0fdde", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define INF 1e+9\n#define EPS 1e-6\n#define m_p make_pair\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair pi;\ntypedef vector vp;\ntypedef vector vvp;\ntypedef vector vb;\ntypedef vector vvb;\ntypedef set si;\ntypedef vector vs;\ntypedef vector vvs;\ntypedef vector vd;\ntypedef vector vvd;\ntypedef si::iterator sii;\ntypedef pair pib;\ntypedef vector vpib;\ntypedef queue qi;\n\nint main()\n{\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n\tint n;\n\tscanf(\"%d\",&n);\n\tvi v(n),ans(n);\n\tfor(int i=0;i0) {ans[n-i-1]=v[i];ans[i]=v[n-i-1];}\n\t\telse {ans[i]=v[i];ans[n-i-1]=v[n-i-1];}\n\t\ta*=-1;\n\t}\n\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\n#define MOD 1000000007\n\nint main(void)\n{\n std::ios_base::sync_with_stdio(false);\n\n int a, b, c, n, ans;\n ans = 0;\n cin >> n;\n\n for(c=1; c<=n; ++c)\n for(b=1; b<=c; ++b)\n for(a=1; a<=b; ++a)\n if(c*c == a*a + b*b)\n ++ans;\n\n cout << ans;\n\n return 0;\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "32ee130e25bbe8311420ef8f99d93c17", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#define pi 3.1415926535898\r\n#define ll long long\r\n#define lson rt<<1\r\n#define rson rt<<1|1\r\n#define eps 1e-6\r\n#define ms(a,b) memset(a,b,sizeof(a))\r\n#define legal(a,b) a&b\r\n#define print1 printf(\"111\\n\")\r\n#define endl \"\\n\"\r\n#define pl printf(\"\\n\")\r\n#define pb(x) push_back(x)\r\n#define pair4 pair,pair >\r\n#define fi first\r\n#define se second\r\nusing namespace std;\r\nconst int maxn = 1e6+10;\r\nconst int inf = 1e9+10;\r\nconst ll llinf =1e18+10;\r\nconst ll mod = 1e9+7;\r\n\r\nint n,k;\r\nll dp[maxn][10];\r\n\r\nll binaryPow(ll a, ll b, ll m){\r\n\tif(b == 0)\r\n\t\treturn 1;\r\n\telse if(b & 1)\r\n\t\treturn a * binaryPow(a, b - 1, m) % m;\r\n\telse{\r\n\t\tll num = binaryPow(a, b/2, m) % m;\t//\u4f18\u5316\r\n\t\treturn num * num % m;// \u4e0d\u76f4\u63a5\u5199\u6210return binaryPow(a, b/2, m) * binaryPow(a, b/2, m)\r\n\t}\r\n}\r\n\r\nint main()\r\n{\r\n int _;\r\n scanf(\"%d\",&_);\r\n while(_--)\r\n {\r\n scanf(\"%d%d\",&n,&k);\r\n ms(dp,0);\r\n dp[0][0]=1;\r\n ll ans=0;\r\n if(n%2==1)\r\n {\r\n for(int i=1;i<=k;i++)\r\n {\r\n dp[i][1]=(dp[i-1][0]%mod+dp[i-1][1]%mod)%mod;\r\n dp[i][0]=((dp[i-1][0]%mod+dp[i-1][1]%mod)%mod*binaryPow(2,n-1,mod))%mod;\r\n }\r\n ans=(dp[k][1]+dp[k][0])%mod;\r\n }else\r\n {\r\n for(int i=1;i<=k;i++)\r\n {\r\n ans=(ans%mod+dp[i-1][0]%mod*binaryPow(2,n*(k-i)%mod,mod)%mod)%mod;\r\n dp[i][0]=dp[i-1][0]%mod*(binaryPow(2,n-1,mod)-1)%mod;\r\n }\r\n ans=(ans%mod+dp[k][0]%mod)%mod;\r\n }\r\n printf(\"%lld\\n\",ans);\r\n }\r\n}\r\n\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "73e94e65841690c0b7c02887b0f9694f", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "// Written by newbiechd\n#include \n\nconst int maxN = 1003;\ndouble dp[maxN][maxN];\n\nint main() {\n#ifndef ONLINE_JUDGE\n freopen(\"a.in\", \"r\", stdin);\n // freopen(\"a.out\", \"w\", stdout);\n#endif\n int n, m, lim = n + m;\n scanf(\"%d%d\", &n, &m);\n for (int i = 0; i <= lim; ++i)\n dp[i][0] = 1;\n for (int j = 1; j <= lim; ++j)\n dp[0][j] = (double)1 / (j + 1);\n for (int i = 1; i <= lim; ++i)\n for (int j = 1; j < i; ++j)\n dp[i - j][j] = (dp[j][i - j - 1] * (1 - dp[j - 1][i - j]) * j + 1)\n / (dp[j][i - j - 1] * (j + 1) + 1);\n printf(\"%.10lf %.10lf\\n\", dp[n][m], 1 - dp[n][m]);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1ba28358377ee907c3ba4574a97bea38", "src_uid": "f51586ab88399c04ffb7eaa658d294dd", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\ntypedef struct{int sum,ans,vis;}node;\nint main(){\n //freopen(\"in.txt\",\"r\",stdin);\n int k,a[12];\n queue q;\n while(scanf(\"%d\",&k)==1){\n int sum=0,flag;\n node cur,next;\n for(int i=0;i<12;++i){\n scanf(\"%d\",&a[i]);\n sum+=a[i];\n }\n if(sum=k){flag=1;printf(\"%d\\n\",cur.ans);break;}\n for(int i=0;i<12;++i)if(!(cur.vis&(1<12) continue;\n next.sum=cur.sum+a[i];\n next.vis=cur.vis|(1<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define fo(i,a,b) for(i=a;i<=b;i++)\n#define fd(i,a,b) for(i=a;i>=b;i--)\n#define MP(a,b) make_pair(a,b)\n#define clr(x,y) memset(x,y,sizeof x)\n#define fi first\n#define se second\n#define LL long long\n#define sqr(z) ((z)*(z))\nusing namespace std;\ntypedef pair PII;\nconst int oo=1047483647,maxn=110;\nconst double eps=1e-6;\nint n,i,j,k,m,q,fa[maxn];\ndouble F[maxn][maxn],H[maxn];\nstruct node\n{\n\tint x,y,c;\n}a[maxn*10];\nstruct edge\n{\n\tint next[2*maxn],y[2*maxn],g[maxn],tt,c[2*maxn];\n\tvoid add(int i,int j,int k)\n\t{\n\t\tnext[++tt]=g[i];\n\t\tg[i]=tt;\n\t\ty[tt]=j;\n\t\tc[tt]=k;\n\t}\n}E;\nint Read()\n{\n\tchar ch;while (ch = getchar(), (ch < '0' || ch > '9') && (ch != '-')); \n\tbool neg= (ch == '-');\n\tif (ch=='-') ch=getchar();\n\tint v=0;\n\twhile (ch>='0' && ch<='9') v=v*10+ch-'0',ch=getchar();\n\tif (neg) v=-v;\n\treturn v;\n}\nvoid work()\n{\n\tint i,j,k;\n\tfo(i,2,n-1)//\ufffd\ufffd\u04bb\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u03aa\ufffd\ufffd\n\t{\n\t\tdouble Ma=0;\n\t\tint Rec;\n\t\tfo(j,i,n)\n\t\tif (fabs(F[j][i])>Ma)\n\t\t{\n\t\t\tMa=fabs(F[j][i]);\n\t\t\tRec=j;\n\t\t}\n\t\tif (Maeps)\n\tH[i]=(-F[i][n]*H[n]-H[1]*F[i][1])/F[i][i];//\ufffd\ufffd\n\tdouble Ma=oo;\n\tfo(i,1,m)\n\t{\n\t\tdouble t=fabs(H[a[i].x]-H[a[i].y]);\n\t\tif (t>eps)\n\t\tMa=min(Ma,a[i].c/t);\n\t}\n\tfo(i,1,n)\n\tH[i]*=Ma;\n\tdouble ans=0;//n\ufffd\u0138\u07f6\u0232\ufffd\ufffd\u01f4\ufffd\n\tfo(i,1,m)\n\tif (a[i].x==1 || a[i].y==1) ans+=fabs(H[a[i].x]-H[a[i].y]);\n\tprintf(\"%.5f\\n\",ans);//\u00ff\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04bb\ufffd\ufffd\u05bb\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u07f8\u07f6\u0232\ufffd\n\tfo(i,1,m)\n\t{\n\t\tprintf(\"%.5f\\n\",H[a[i].y]-H[a[i].x]);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f7c2843bb9038cc136b9c75ffe95f3d6", "src_uid": "93fa614f174816d241c0fa302c6476e2", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "/* ****revpro**** */\n// #pragma GCC target (\"avx2\")\n// #pragma GCC optimization (\"O3\")\n// #pragma GCC optimization (\"unroll-loops\")\n#include\n#define ll long long\n#define pb push_back\n#define endl\t '\\n'\n#define pii pair\n#define vi vector\n#define all(a) (a).begin(),(a).end()\n#define F first\n#define S second\n#define sz(x) (ll)x.size()\n#define rep(i,a,b) for(ll i=a;i=a;i--) \n#define lbnd lower_bound\n#define ubnd upper_bound\n#define bs binary_search\n#define mp make_pair\n#define present(c,x) ((c).find(x) != (c).end())\n#define cpresent(c,x) (find(all(c),x) != (c).end())\n#define mii\t map\nusing namespace std;\n\n#define TIME cerr << \"\\nTime elapsed: \" << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << \"ms\\n\";\n#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define N 100005\n#include \n#include \nusing namespace __gnu_pbds; \n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update> \nll add(ll x,ll y,ll mod=hell) { x += y; if(x >= mod) x -= mod; return x;}\nll sub(ll x,ll y,ll mod=hell) { x -= y; if(x < 0) x += mod; return x;}\nll mul(ll x,ll y,ll mod=hell) { return (x * 1ll * y) % mod;}\nll fac[N];\nll expo(ll base, ll exponent, ll mod=hell) {\t\t\t\t\t\t\t\t//return base^exponent modulo modulus\n ll ans = 1;\n while(exponent !=0 ) {\n if((exponent&1) == 1) {\n ans = ans*base ;\n ans = ans%mod;\n }\n base = base*base;\n base %= mod;\n exponent>>= 1;\n }\n return ans%mod;\n}\nvoid solve()\n{\n\tfac[0]=1;\n\trep(i,1,N) fac[i]=mul(fac[i-1],i);\n\tll n,m;\n\tcin>>n>>m;\n\tll ans=0;\n\trep(i,n-1,m+1)\n\t{\n\t\tans=add(ans,mul(fac[i-1],mul(expo(fac[n-2],hell-2),expo(fac[i-n+1],hell-2))));\n\t}\n\t// cout<>TESTS;\n\twhile(TESTS--)\n\t{\n\t\tsolve();\n\t\t\n\t}\n\tTIME\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9207800a1c2c1d3aee4233de13c5b932", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\nusing namespace std;\ntypedef long long int ll;\n#define pp pair;\n\ntypedef long double ld;\nint x[8]={-1,-1,0,1,1,1,0,-1};\nint y[8]={0,1,1,1,0,-1,-1,-1};\n\nvoid bfs(int x,int y)\n{\n \n \n}\nint main()\n{\n ios::sync_with_stdio(0);\ncin.tie(0);\ncout.tie(0);\nll n;\ncin>>n;\nll x,y;\ncin>>x>>y;\nll i=1;ll j=1;\nll p,q;\np=q=n;\nif(x==1||y==1)\n{\n cout<<\"White\";return 0;\n}\nif(x==n||y==n)\n{\n cout<<\"Black\";return 0;\n}\nll t1,t2;t1=0;t2=1;\nwhile(i!=x||j!=y)\n{\n \n i++;j++;t1++;\n}\n\n t1+=abs(x-i)+abs(y-j);\nwhile(p!=x||q!=y)\n{\n \n p--;q--;t2++;\n}\nt2+=abs(p-x)+(abs(q-y));\nif(t2<=t1)\n cout<<\"Black\";\nelse cout<<\"White\";\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "27b2762e14f814996b843d1a7f6831e2", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n double a, b, m;\n double vx, vy, vz;\n double x, y, z;\n double xx = 0, yy = 0, zz = 0;\n double mn;\n \n cin>>a>>b>>m;\n cin>>vx>>vy>>vz;\n \n x = a/2;\n y = m;\n z = 0;\n \n while( y > 0 ) {\n \n if( vx == 0 )\n xx = 0;\n else {\n xx = ( vx > 0 ) ? ( a - x ) : x;\n xx /= vx;\n xx = abs(xx);\n }\n \n \n yy = y * 1.0 / vy; //yy = (double)y / vy;\n yy = abs(yy);\n \n if( vz == 0 )\n zz = 0;\n else {\n zz = ( vz > 0 ) ? ( b - z ) : z;\n zz /= vz;\n zz = abs(zz);\n }\n \n mn = min( xx, yy ); mn = min( mn, zz );\n \n //x += vx * mn;\n //y += vy * mn;\n //z += vz * mn;\n \n //cout< 0 )\n x = a;\n else\n x = 0;\n \n y += vy * mn;\n z += vz * mn;\n }\n \n if( yy == mn ) {\n x += vx * mn;\n y = 0;\n z += vz * mn;\n }\n \n if( zz == mn ) {\n if( vz > 0 )\n z = b;\n else\n z = 0;\n \n x += vx * mn;\n y += vy * mn;\n }\n \n vx = ( x == 0 || x == a ) ? -vx : vx;\n \n vz = ( z == 0 || z == b ) ? -vz : vz;\n \n }\n \n cout<\n\nusing namespace std;\n\nint m, b;\nlong int a[1000][100000], maxn;\n\nint main()\n{\n ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n cin >> m >> b;\n int x = m // * b\n ;\n int y = b;\n // for(int i = 1 ; i <= x ; ++ i)\n // a[0][i] = a[0][i-1] + i;\n // for(int i = 1 ; i <= y ; ++ i)\n // a[i][0] = a[i-1][0] + i;\n // for(int i = 1 ; i <= y ; ++ i){\n // for(int j = 1 ; j <= x ; ++ j)\n // a[i][j] = a[i][j-1] + a[i-1][j] - a[i-1][j-1] + i + j;\n // }\n // for(int i = 0 ; i <= y ; ++ i, cout << endl)\n // for(int j = 0 ; j <= x ;++ j){\n // long int q = 0;\n // q += (j*(j+1)/2)*(i+1);\n // q += (i*(i+1)/2)*(j+1);\n // }\n for(int i = 0 ; i <= b ; ++ i){\n int j = m * (b - i); \n if(j + m * i == m * b){\n long int q = 0;\n q += (j*(j+1)/2)*(i+1);\n q += (i*(i+1)/2)*(j+1);\n maxn = max(q, maxn);\n }\n }\n cout << maxn << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d78733c0ca40f4b070b4a9c33c2beea3", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef double db; \ntypedef string str; \n\ntypedef pair pi;\ntypedef pair pl; \ntypedef pair pd; \n\ntypedef vector vi; \ntypedef vector vl; \ntypedef vector vd; \ntypedef vector vs; \ntypedef vector vpi;\ntypedef vector vpl; \ntypedef vector vpd; \n\n#define mp make_pair\n#define f first\n#define s second\n#define sz(x) (int)x.size()\n#define all(x) begin(x), end(x)\n#define rall(x) (x).rbegin(), (x).rend() \n#define rsz resize\n#define ins insert \n#define ft front() \n#define bk back()\n#define pf push_front \n#define pb push_back\n#define eb emplace_back \n#define lb lower_bound \n#define ub upper_bound \n\n#define FOR(i,a,b) for (int i = (a); i < (b); ++i)\n#define F0R(i,a) FOR(i,0,a)\n#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)\n#define R0F(i,a) ROF(i,0,a)\n#define trav(a,x) for (auto& a: x)\n\nconst int MOD = 1e9+7; // 998244353;\nconst int MX = 2e5+5; \nconst ll INF = 1e18; \nconst ld PI = acos((ld)-1);\nconst int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; \n\ntemplate bool ckmin(T& a, const T& b) { \n\treturn b < a ? a = b, 1 : 0; }\ntemplate bool ckmax(T& a, const T& b) { \n\treturn a < b ? a = b, 1 : 0; } \nint pct(int x) { return __builtin_popcount(x); } \nint bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) \n// int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 \n\n// INPUT\ntemplate void re(complex& c);\ntemplate void re(pair& p);\ntemplate void re(vector& v);\ntemplate void re(array& a);\n\ntemplate void re(T& x) { cin >> x; }\nvoid re(db& d) { str t; re(t); d = stod(t); }\nvoid re(ld& d) { str t; re(t); d = stold(t); }\ntemplate void re(H& h, T&... t) { re(h); re(t...); }\n\ntemplate void re(complex& c) { A a,b; re(a,b); c = {a,b}; }\ntemplate void re(pair& p) { re(p.f,p.s); }\ntemplate void re(vector& x) { trav(a,x) re(a); }\ntemplate void re(array& x) { trav(a,x) re(a); }\n\n// TO_STRING\n#define ts to_string\ntemplate str ts(pair p);\ntemplate str ts(complex c) { return ts(mp(c.real(),c.imag())); }\nstr ts(bool b) { return b ? \"true\" : \"false\"; }\nstr ts(char c) { str s = \"\"; s += c; return s; }\nstr ts(str s) { return s; }\nstr ts(const char* s) { return (str)s; }\nstr ts(vector v) { \n\tbool fst = 1; str res = \"{\";\n\tF0R(i,sz(v)) {\n\t\tif (!fst) res += \", \";\n\t\tfst = 0; res += ts(v[i]);\n\t}\n\tres += \"}\"; return res;\n}\ntemplate str ts(bitset b) {\n\tstr res = \"\"; F0R(i,SZ) res += char('0'+b[i]);\n\treturn res; }\ntemplate str ts(T v) {\n\tbool fst = 1; str res = \"{\";\n\tfor (const auto& x: v) {\n\t\tif (!fst) res += \", \";\n\t\tfst = 0; res += ts(x);\n\t}\n\tres += \"}\"; return res;\n}\ntemplate str ts(pair p) {\n\treturn \"(\"+ts(p.f)+\", \"+ts(p.s)+\")\"; }\n\n// OUTPUT\ntemplate void pr(A x) { cout << ts(x); }\ntemplate void pr(const H& h, const T&... t) { \n\tpr(h); pr(t...); }\nvoid ps() { pr(\"\\n\"); } // print w/ spaces\ntemplate void ps(const H& h, const T&... t) { \n\tpr(h); if (sizeof...(t)) pr(\" \"); ps(t...); }\n\n// DEBUG\nvoid DBG() { cerr << \"]\" << endl; }\ntemplate void DBG(H h, T... t) {\n\tcerr << to_string(h); if (sizeof...(t)) cerr << \", \";\n\tDBG(t...); }\n#ifdef LOCAL // compile with -DLOCAL\n#define dbg(...) cerr << \"[\" << #__VA_ARGS__ << \"]: [\", DBG(__VA_ARGS__)\n#else\n#define dbg(...) 42\n#endif\n\n// FILE I/O\nvoid setIn(string s) { freopen(s.c_str(),\"r\",stdin); }\nvoid setOut(string s) { freopen(s.c_str(),\"w\",stdout); }\nvoid unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }\nvoid setIO(string s = \"\") {\n\tunsyncIO();\n\t// cin.exceptions(cin.failbit); \n\t// throws exception when do smth illegal\n\t// ex. try to read letter into int\n\tif (sz(s)) { setIn(s+\".in\"), setOut(s+\".out\"); } // for USACO\n}\n\nmt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); \n\nll n;\nint m,k,cnt[400000];\n\nll fdiv(ll a, ll b) { return a/b; }\nll cdiv(ll a, ll b) { return (a+b-1)/b; }\n\nvoid solve() {\n\tre(n,m,k);\n\t// first maximize min\n\tvl p(m); re(p); p.insert(begin(p),0); p.pb(n);\n\tvl dif; F0R(i,sz(p)-1) dif.pb(p[i+1]-p[i]);\n\tm = sz(dif);\n\ttypedef pair T; priority_queue todo;\n\tF0R(i,m) {\n\t\tcnt[i] = 1;\n\t\tif (cnt[i] < dif[i]) todo.push({fdiv(dif[i],cnt[i]+1),i});\n\t}\n\tdbg(dif,k);\n\tF0R(i,k) {\n\t\tauto a = todo.top(); todo.pop();\n\t\tcnt[a.s] ++;\n\t\tif (cnt[a.s] < dif[a.s]) todo.push({fdiv(dif[a.s],cnt[a.s]+1),a.s});\n\t}\n\tll mn = INF; \n\tF0R(i,m) dbg(dif[i],cnt[i]);\n\tF0R(i,m) ckmin(mn,fdiv(dif[i],cnt[i]));\n\t// dbg(\"??\",mn);\n\n\tll ans = INF;\n\tpriority_queue cur;\n\tF0R(i,m) {\n\t\tcnt[i] = 1;\n\t\tcur.push({cdiv(dif[i],cnt[i]),i});\n\t}\n\tfor (int i = 0;;++i) {\n\t\tauto a = cur.top(); cur.pop(); ckmin(ans,a.f-mn);\n\t\t// dbg(\"OH\",k,a,cnt[a.s],dif[a.s]);\n\t\t// dbg(\"OH\",a,mn);\n\t\tif (i == k || cnt[a.s] == dif[a.s]) break;\n\t\tcnt[a.s] ++;\n\t\tckmin(mn,fdiv(dif[a.s],cnt[a.s]));\n\t\tT p = {cdiv(dif[a.s],cnt[a.s]),a.s}; \n\t\tcur.push(p);\n\t}\n\tps(ans);\n\t// dbg(dif,mn);\n\t// then keep decreasing max and updating the min until cnt exceeds\n}\n\nint main() {\n\tsetIO();\n\tint t; re(t);\n\tF0R(i,t) solve();\n\t// you should actually read the stuff at the bottom\n}\n\n/* stuff you should look for\n\t* int overflow, array bounds\n\t* special cases (n=1?)\n\t* do smth instead of nothing and stay organized\n\t* WRITE STUFF DOWN\n*/\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "89d0c1c2c33e073e2ac25763de3ad5ae", "src_uid": "37d912c36aedea1b8f8e78a849062d90", "difficulty": 3300.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\nconst long long INF = 1e9+7;\n\n\nint main(){\n\n ios::sync_with_stdio(0);\n ios_base::sync_with_stdio(0);\n cin.tie(0); cout.tie(0);\n\n long long n;\n long long m;\n cin >> n >> m;\n vector m1(n);\n for (long long i=0;i> m1[i];\n }\n vector ans(n,0);\n multiset > pr;\n for (long long i=0;i= 0){\n ans[i] = 0;\n m-=val;\n vector > m2;\n m2.push_back({1,val});\n for (auto el:pr){\n long long sum = el.second + val;\n long long kol = el.first+1;\n m2.push_back({kol,sum});\n }\n for (auto el:m2){\n pr.insert(el);\n }\n continue;\n }\n long long raz = val - m;\n m -= val;\n for (auto el:pr){\n long long sum = el.second;\n long long kol = el.first;\n if (sum >= raz){\n ans[i] = kol ;\n break;\n }\n }\n vector > m2;\n m2.push_back({1,val});\n for (auto el:pr){\n long long sum = el.second + val;\n long long kol = el.first+1;\n m2.push_back({kol,sum});\n }\n for (auto el:m2){\n pr.insert(el);\n }\n }\n for (auto el:ans){\n cout << el << ' ';\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fd428964a85d393a0f17a3e15ee89bcc", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \n \n// #define endl '\\n' \n#define pb push_back \n#define fi first \n#define se second \n#define pll pair \n#define all(v) v.begin(), v.end() \n \nusing namespace std; \n \ntypedef long long int ll; \n \nmt19937 rnd(1337); \n\nostream& operator<< (ostream& a, const pll& b) {\n cout << \"{\" << b.first << \", \" << b.second << \"}\";\n return a;\n}\n\nostream& operator<< (ostream &a, const vector& b) {\n for (auto& k : b) cout << k << \" \";\n return a;\n}\n\nostream& operator<< (ostream &a, const vector& b) {\n for (auto& k : b) cout << k << \" \";\n return a;\n}\n\n#ifdef HOME \n #define dbg(x) cout << #x << \" : \" << (x) << '\\n';\n#else\n #define dbg(x)\n#endif \n \nconst ll INF = (ll)1e18; \nconst ll MOD = 1000 * 1000 * 1000 + 7, MOD2 = 274876858367; \nconst ll maxn = (ll)1e6 + 1, L = 10;\n\nll dp[maxn], pr[maxn];\n\nstruct kek {\n ll s, t, c, inx;\n};\n\nint main() { \n #ifdef HOME \n freopen(\"input.txt\", \"r\", stdin); \n freopen(\"output.txt\", \"w\", stdout); \n #else \n ios_base::sync_with_stdio(0); cin.tie(0); \n freopen(\"olympiad.in\", \"r\", stdin); \n freopen(\"olympiad.out\", \"w\", stdout); \n #endif \n ll n, a, b;\n cin >> n >> a >> b;\n if (a > b)\n swap(a, b);\n vector v;\n for (ll i = 0; i < n; ++i)\n v.pb(i + 1);\n ll inx = 1;\n while (v.size()) {\n for (ll i = 0; i < v.size(); ++i) {\n if (v[i] == a && v[i + 1] == b) {\n if (v.size() == 2)\n cout << \"Final!\";\n else\n cout << inx;\n return 0;\n }\n if (v[i] == a || v[i] == b)\n v.erase(v.begin() + i + 1);\n else\n v.erase(v.begin() + i);\n }\n ++inx;\n }\n return 0; \n} \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "efea8c5bd9ca869b43a41c87c074e883", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n\n int n;\n cin >> n;\n string temp = \"\";\n for(int j = 0; j < n; ++j)\n {\n cin >> temp[j];\n }\n cout << n+1;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1ff7de2fb7927b2347bd327dbbc35efd", "src_uid": "098ade88ed90664da279fe8a5a54b5ba", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \"bits/stdc++.h\"\nusing namespace std;\ntypedef unsigned long long LL;\n#define nl \"\\n\"\n#define X first\n#define Y second\n\n#define MAX INT_MAX\n#define pb(a) push_back(a)\n#define mp(a,b) make_pair(a,b)\n\n#define gcd(a,b) __gcd(a,b)\n#define lcm(a,b) a*(b/gcd(a, b))\n\n#define check() {printf(\"OK\\n\");}\n#define SORT(v) sort(v.begin(),v.end())\n#define REV(v) reverse(v.begin(),v.end())\n\n#define mem(a,x) memset(a,x,sizeof(a))\n#define rep(i, n) for(int i = 0; i < (n); ++i)\n#define rep1(i, n) for(int i = 1; i <= (n); ++i)\n#define maxv(v) *max_element(v.begin(),v.end())\n#define minv(v) *min_element(v.begin(),v.end())\n\n#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)\n#define f() {ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);}\n#define UNQ(v) SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())\n#define MOD 1000000007 // (int)1e9+7\n\n///sortingstringbytheirlengthincreasingorder\nbool ff(string s1,string s2){\n return s1.size()s;sort(s.begin(),s.end(),ff)\n//Convert int to string\ntemplate \nstring to_str(T str)\n{\n stringstream stream;\n stream << str;\n return stream.str();\n}\n\nint main(){f();\n LL n;\n cin>>n;\n string s = \"\";\n for(LL i = 1; i<=100000;i++){\n string a = to_str(i);\n s+=a;\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define mp make_pair\n#define pb push_back\n\nusing ll = long long;\nusing ld = long double;\n\nusing namespace std;\n\nconst int MAXN = 100001;\n\nint c2[MAXN];\n\nconst int M = 60;\n\nll a[MAXN];\n\n\nmap b;\n\n\n\nvoid no() {\n\tcout << -1 << endl;\n\texit(0);\n}\n\n\nint pc[MAXN];\n\n\nint getp2(ll x) {\n\tll c = 1;\n\tint pw = 0;\n\twhile (c < x) c *= 2, pw++;\n\tif (c == x) return pw;\n\telse return -1;\n}\n\n\nvector bad;\nvector finishes;\nvector nonp2;\n\nint main() {\n\t//freopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n\tios_base::sync_with_stdio(0); cout.setf(ios::fixed); cout.precision(20);\n\tint n;\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> a[i];\n\t\tint p2 = getp2(a[i]);\n\t\tif (p2 != -1) pc[p2]++;\n\t\telse bad.push_back(a[i]), nonp2.push_back(a[i]);\n\t}\n\tint cur = pc[0];\n\tfor (int i = 1; i < M; i++) {\n\t\tif (pc[i] > cur) {\n\t\t\tfor (int j = cur; j < pc[i]; j++) {\n\t\t\t\tbad.push_back(1ll << i);\n\t\t\t}\n\t\t}\n\t\twhile (cur > pc[i]) {\n\t\t\tfinishes.push_back(1ll << (i - 1));\n\t\t\tcur--;\n\t\t}\n\t}\n\tsort(bad.begin(), bad.end());\n\tif (finishes.size() < bad.size()) no();\n\tfor (int i = 0; i < bad.size(); i++) {\n\t\tif (bad[i] >= 2 * finishes[finishes.size() - bad.size() + i]) no();\n\t}\n\n\tint ansr = finishes.size();\n\n\tint pnp2 = (int)nonp2.size() - 1;\n\n\tint fin = 0, ufin = 0;\n\n\tfor (int i = nonp2.size() - 1; i >= 0; i--) {\n\t\tll x = nonp2[i];\n\t\tfor (int i = M - 1; i >= 0; i--) {\n\t\t\tif (pc[i] > 0) pc[i]--;\n\t\t}\n\t}\n\n\tfor (int i = M - 1; i >= 0; i--) {\n\t\tif (pc[i] < fin + ufin)\n\t\t\tassert(false);\n\t\tpc[i] -= fin + ufin;\n\t\tif (pc[i] <= ufin) {\n\t\t\tufin -= pc[i];\n\t\t\tfin += pc[i];\n\t\t} else {\n\t\t\tfin += ufin;\n\t\t\tpc[i] -= ufin;\n\t\t\tfin += pc[i] / 2;\n\t\t\tufin = pc[i] % 2;\n\t\t}\n\t}\n\n\tfor (int i = nonp2.size() + fin + ufin; i <= finishes.size(); i++)\n\t\tcout << i << \" \";\n\tcout << \"\\n\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "72665e58d733538cf1368e4c41ee348f", "src_uid": "fc29e8c1a9117c1dd307131d852b6088", "difficulty": 2200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint a[110];\nint box[110];\n\nint main() {\n int n;\n scanf(\"%d\", &n);\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &a[i]);\n }\n sort(a, a + n);\n int cnt = 0;\n for (int i = 0; i < n; i++) {\n bool is_possible = false;\n for (int j = 0; j < cnt; j++) {\n if (box[j] <= a[i]) {\n box[j]++;\n is_possible = true;\n break;\n }\n }\n if (is_possible == false) {\n box[cnt]++;\n cnt++;\n }\n }\n printf(\"%d\\n\", cnt);\n getch();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "051114804191276f5966c63ebb2f7bfc", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define REP(i,s,n) for(int i=s;i P;\ntypedef pair PP;\ntypedef long long ll;\ntypedef unsigned long long ull;\n\nint main(){\n int a;\n cin >> a;\n \n if(a == 1)\n {\n //assert(false);\n cout << \"Washington\" << endl;\n \n } \n else if(a == 2)\n { \n //assert(false);\n cout << \"Adams\" << endl;\n\n } \nelse if(a == 3)\n { \n //assert(false);\ncout << \"Jefferson\" << endl;\n\n } \n else if(a == 4)\n { \n //assert(false);\n cout << \"Madison\" << endl;\n\n } \nelse if(a == 5)\n { \n //assert(false);\n cout << \"Monroe\" << endl;\n\n } \nelse if(a == 6)\n { \n //assert(false);\n cout << \"Adams\" << endl;\n \n }\n else if(a == 7)\n { \n //assert(false);\n cout << \"Jackson\" << endl;\n \n }\nelse if(a == 8)\n { \n //assert(false);\ncout << \"Van Buren\" << endl;\n \n }\nelse if(a == 9)\n { \n //assert(false);\n cout << \"Harrison\" << endl;\n\n } \nelse if(a == 10)\n {\n //assert(false);\n cout << \"Tyler\" << endl;\n\n } \n else if(a == 11)\n { //ok\n //assert(false);\n cout << \"Polk\" << endl;\n \n }\n else if(a == 12)\n { \n cout << \"Taylor\" << endl;\n \n }\nelse if(a == 13)\n {\n cout << \"Fillmore\" << endl;\n\n } \nelse if(a == 14)\n { \n cout << \"Pierce\" << endl;\n\n } \nelse if(a == 15)\n { \n cout << \"Buchanan\" << endl;\n\n } \nelse if(a == 16)\n { \n cout << \"Lincoln\" << endl;\n \n }\nelse if(a == 17)\n { \n cout << \"Johnson\" << endl;\n\n } \nelse if(a == 18)\n { \n assert(false);\n cout << \"Simpson Grant\" << endl;\n\n } \nelse if(a == 19)\n { \n assert(false);\n cout << \"Birchard Hayes\" << endl;\n\n } \nelse if(a == 20)\n { assert(false);\n cout << \"Abram Garfield\" << endl;\n\n } \nelse if(a == 21)\n { \n cout << \"Alan Arthur\" << endl;\n \n }\nelse if(a == 22)\n { \n cout << \"Cleveland\" << endl;\n\n } \nelse if(a == 23)\n {\n cout << \"Harrison\" << endl;\n\n } \nelse if(a == 24)\n { \n cout << \"Cleveland\" << endl;\n\n } \nelse if(a == 25)\n {\n \n cout << \"McKinley\" << endl;\n }\n else if(a == 26)\n { \n\n cout << \"Roosevelt\" << endl;\n } \nelse if(a == 27)\n { //assert(false);\n cout << \"Howard Taft\" << endl;\n\n } \nelse if(a == 28)\n { \n cout << \"Wilson\" << endl;\n\n } \nelse if(a == 29)\n { \n cout << \"Harding\" << endl;//ok - input 8 \n \n }\n else if(a == 30)\n { //assert(false);\n cout << \"Calvin Coolidge\" << endl;\n \n }\nelse if(a == 31)\n { \n cout << \"Clark Hoover\" << endl;\n \n }\n else if(a == 32)\n { \n cout << \"Delano Roosevelt\" << endl;\n \n }\n else if(a == 33)\n {\n //assert(false); \n cout << \"S. Truman\" << endl;\n \n }\n else if(a == 34)\n {\n //assert(false); \n cout << \"David Eisenhower\" << endl;\n } \nelse if(a == 35)\n {//assert(false); \n cout << \"Fitzgerald Kennedy\" << endl;\n \n }\nelse if(a == 36)\n {\n //assert(false); \n cout << \"Baines Johnson\" << endl;\n }\n else if(a == 37)\n { \n //assert(false); \n cout << \"Milhouse Nixon\" << endl;\n } \nelse if(a == 38)\n { \n\ncout << \"Earl Ford\" << endl;\n } \nelse if(a == 39)\n {\n \n cout << \"Earl Carter\" << endl;\n }\n else if(a == 40)\n { \n cout << \"Wilson Reagan\" << endl;\n }\n\n\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f6727ea5e75c0a7f4f522ffefbd93a29", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntemplate < class T, typename A = allocator >\nclass Vector : public vector\n{\npublic:\n\tusing vector::vector;\n\tusing typename vector::size_type;\n\tusing typename vector::value_type;\n\tusing typename vector::allocator_type;\n\tVector& operator()(size_type dummy_n, const value_type& val = value_type(), const allocator_type& alloc = allocator_type()) { return *this; }\n};\ntemplate<> class Vector : public vector { public:using vector::vector; Vector& operator()(size_type dummy_n) { return *this; } };\ntypedef long long ll; typedef unsigned int u;\ntypedef pair pii; typedef pair puu;\ntypedef Vector vb;// Vector\ntypedef Vector vi; typedef Vector vu;\ntypedef Vector vll;\ntypedef Vector vs;\ntypedef Vector vpii; typedef Vector vpuu;\ntypedef Vector> vvi; typedef Vector> vvu;\ntypedef set si; typedef set su;\ntypedef multiset Si; typedef multiset Su;\ntypedef map mi; typedef map mu;\ntypedef multimap Mi; typedef multimap Mu;\ntemplate < typename Int = int > // only integral types\ninline Int read() // \"([number][space or newline])*\" // reads -int_max but doesn't read int_min\n{\n\tint c{ getchar() };\n\tif (c == '-') {\n\t\tInt init{ getchar() & 15 };\n\t\twhile ((c = getchar()) & 16) init = (init << 3) + (init << 1) + (c & 15);\n\t\treturn ++(init = ~init);\n\t}\n\telse {\n\t\tInt init{ c & 15 };\n\t\twhile ((c = getchar()) & 16) init = (init << 3) + (init << 1) + (c & 15);\n\t\treturn init;\n\t}\n}\ninline void read(int& a) // \"([number][space or newline])*\" // reads -int_max but doesn't read int_min\n{\n\ta = getchar() & 15;\n\tif (a == 13) {\n\t\ta = getchar() & 15;\n\t\tfor (int c; (c = getchar()) & 16; a = (a << 3) + (a << 1) + (c & 15));\n\t\t++(a = ~a);\n\t}\n\telse\n\t\tfor (int c; (c = getchar()) & 16; a = (a << 3) + (a << 1) + (c & 15));\n}\ninline void read(unsigned int& a) // \"([number][space or newline])*\" \n{\n\ta = getchar() & 15;\n\tfor (int c; (c = getchar()) & 16; a = (a << 3) + (a << 1) + (c & 15));\n}\ninline void read(char& a) { scanf(\"%c%*c\", &a); } // \"([char][delim])*\"\ninline void read(string& a) { static char BUF[1234560]; scanf(\"%s%*c\", BUF); a = move(string(BUF)); } // \"([string][delim])*\"\ninline void read(ll& a) { a = read(); } // \"([number][space or newline])*\"\ninline void read(double& a) { scanf(\"%lf%*c\", &a); } // \"([double][delim])*\"\ntemplate < class T >\ninline void read(pair& a) { read(a.first); read(a.second); } // \"([first][space or newline][second][space or newline])*\"\ntemplate > class C, class T>\ninline void read(C& a) { for (auto i = a.begin(); i != a.end(); ++i) read(*i); }\ntemplate < typename T, typename U, typename... ARGS >\ninline void read(T& t, U& u, ARGS&... args) {\n\tread(t);\n\tread(u, args...);\n}\ntemplate < typename Int > // only integral types\ninline void write(Int x)\n{\n\tstatic char BUF[64] = {};\n\tchar *pnt{ BUF + 64 };\n\tif (x < 0) {\n\t\tputchar('-');\n\t\t++(x = ~x);\n\t}\n\tdo\n\t\t*--pnt = x % 10 | 48;\n\twhile (x /= 10);\n\tprintf(\"%s\", pnt);\n}\ninline void write(unsigned int a)\n{\n\tstatic char BUF[16] = {};\n\tchar *pnt{ BUF + 16 };\n\tdo\n\t\t*--pnt = a % 10 | 48;\n\twhile (a /= 10);\n\tprintf(\"%s\", pnt);\n}\ninline void write(const char& a) { printf(\"%c\", a); }\ninline void write(const char* a) { printf(\"%s\", a); }\ninline void write(const string& a) { printf(\"%s\", a.c_str()); }\ninline void write(const double& a) { printf(\"%lf\", a); }\ntemplate < class T >\ninline void write(const pair& a) { write(a.first); write(' '); write(a.second); }\ntemplate > class C, class T>\ninline void write(const C& a) { if (a.size()) write(*a.begin()); for (auto i = ++a.begin(); i != a.end(); ++i) { write(' '); write(*i); } }\ntemplate < typename T, typename U, typename... ARGS >\ninline void write(const T& t, const U& u, const ARGS&... args) {\n\twrite(t);\n\twrite(' ');\n\twrite(u, args...);\n}\ntemplate > class C, class T>\ninline void sort(C& a) { sort(a.begin(), a.end()); }\ninline void sort(string& a) { sort(a.begin(), a.end()); }\ntemplate > class C, class T>\ninline void rsort(C& a) { sort(a.rbegin(), a.rend()); }\ninline void rsort(string& a) { sort(a.rbegin(), a.rend()); }\ntemplate\ninline int sz(const T& a) { return int(a.size()); }\ntemplate < template < class T, class Compare = less, class Alloc = allocator > class C, class T>\ninline bool in(const C& c, const T& el) { return c.find(el) != c.end(); };\ntemplate < template < class Key, class T, class Compare = less, class Alloc = allocator > > class C, class Key, class T>\ninline bool in(const C& c, const Key& el) { return c.find(el) != c.end(); };\ntemplate < template < class T, class Compare = less, class Alloc = allocator > class C, class T>\ninline bool out(const C& c, const T& el) { return c.find(el) == c.end(); };\ntemplate < template < class Key, class T, class Compare = less, class Alloc = allocator > > class C, class Key, class T>\ninline bool out(const C& c, const Key& el) { return c.find(el) == c.end(); };\n#define MX 1000000000\n#define all(a) (a).begin(),(a).end()\n#define rall(a) (a).rbegin(),(a).rend()\n#define T(n) for(decltype(n) _VARIABLE{(n) + 1}; --_VARIABLE;)\n#define F(b,e,i) for(auto i = decltype(e)(b); i != (e); decltype(e)(b) < (e) ? ++i : --i)\n#define G(f,l,i) for(auto i = decltype(l)(f) + (decltype(l)(f) < (l) ? -1 : 1); (decltype(l)(f) < (l) ? i++ : i--) != (l) ;)\n#define M(f,l,i,j) for(auto i = decltype(l)(f) , j = (l) ; i < j; ++i, --j)\n#define R(type, ...) type __VA_ARGS__; read(__VA_ARGS__)\n#define W(...) write(__VA_ARGS__), write('\\n')\n#define bgn begin()\n#define rbgn rbegin()\n#define nd end()\n#define rnd rend()\n#define pb push_back\n#define fnt front()\n#define bck back()\n#define x first\n#define y second\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n#endif\n\tR(u, n, k);\n\tR(vvu, a(n, vu(k)));\n\tu mn{ MX };\n\tF(0, n, i) {\n\t\tu c{};\n\t\tF(0, n, j) if (i != j) {\n\t\t\tF(0, k, l)\n\t\t\t\tc += a[i][l] != a[j][l];\n\t\t}\n\t\tif (c < mn)\n\t\t\tmn = c;\n\t}\n\tW(mn);\n}\n//\n// ArtemParkhomets\n//", "lang_cluster": "C++", "compilation_error": false, "code_uid": "349350c258e4cd37670632bc94862fa8", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define f first\n#define s second\n#define pb push_back\n#define int long long\n#define ld long double\n\nusing namespace std;\n\nconst int N = 5e5 + 5, inf = 2e18 + 7, mod = 1e9 + 7;\n\nint a[N];\n\nsigned main(){\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n int n;\n cin >> n;\n int cnt1 = 0, cnt0 = 0;\n for(int i = 0; i < n; ++i){\n cin >> a[i];\n if(a[i] == 0)\n a[i] = -1;\n else\n a[i] %= 2;\n if(a[i] == 1)\n ++cnt1;\n if(a[i] == 0)\n ++cnt0;\n }\n cnt0 = n / 2 - cnt0;\n cnt1 = n - (n / 2) - cnt1;\n int ans = 0, last = -1, pos = -1, beg0 = 0, beg1 = 0, end0 = 0, end1 = 0;\n for(int i = 0; i < n; ++i){\n if(a[i] == -1)\n continue;\n else{\n if(last != -1){\n if(a[i] == 1 && last == 1){\n if(cnt1 >= i - pos - 1)\n cnt1 -= (i - pos - 1);\n else\n ans += 2;\n }else if(a[i] == 0 && last == 0){\n if(cnt0 >= i - pos - 1)\n cnt0 -= (i - pos - 1);\n else\n ans += 2;\n }else{\n ans += 1;\n }\n }else{\n if(a[i] == 1)\n beg1 = i;\n else\n beg0 = i;\n }\n last = a[i], pos = i;\n }\n }\n if(last == 1)\n end1 = n - pos - 1;\n else\n end0 = n - pos - 1;\n if(n == 1 && last == -1){\n cout << 0;\n return 0;\n }\n if(end1 <= cnt1)\n cnt1 -= end1;\n else\n ans += 1;\n if(end0 <= cnt0)\n cnt0 -= end0;\n else\n ans += 1;\n\n if(beg1 <= cnt1)\n cnt1 -= beg1;\n else\n ans += 1;\n if(beg0 <= cnt0)\n cnt0 -= beg0;\n else\n ans += 1;\n\n cout << ans;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d1908355cd1a8d705cf172e92bfe8d14", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\nusing namespace std;\r\n// https://space.bilibili.com/672328094\r\n#define ll long long\r\nll MOD = 998244353;\r\nll power(ll a, ll b, ll res = 1) {\r\n for (; b; b >>= 1, (a *= a) %= MOD)\r\n if (b & 1) (res *= a) %= MOD;\r\n return res;\r\n}\r\nll inv(ll a, ll m) { return a == 1 ? 1 : ((m - m / a) * inv(m % a, m) % m); }\r\nll dp[501][501];\r\nint main() {\r\n cin.tie(nullptr)->sync_with_stdio(false);\r\n int N, X;\r\n cin >> N >> X;\r\n int MAX = N + 10;\r\n vector f(MAX, 1);\r\n vector rf(MAX, 1);\r\n for (int i = 1; i < MAX; ++i) {\r\n f[i] = (f[i - 1] * i) % MOD;\r\n rf[i] = (rf[i - 1] * inv(i, MOD)) % MOD;\r\n }\r\n // vector dp(N + 1, vector(X + 1)); // d[i][j], i people, all less than x, one winner\r\n // vector power(X + 1, vector(N + 1));\r\n // for (int i = 0; i <= X; i += 1)\r\n // for (int j = 0; j <= N; j += 1) power[i][j] = j ? power[i][j - 1] * i % MOD : 1;\r\n for (int x = 1; x <= X; x++) dp[1][x] = x;\r\n for (int n = 2; n <= N; n++) {\r\n for (int x = n - 1; x <= X; x++) {\r\n for (int alive = 1; alive <= n; alive++) {\r\n ll choose_alive = f[n] * rf[n - alive] % MOD * rf[alive] % MOD;\r\n ll dead_ways = power(n - 1, n - alive);\r\n (dp[n][x] += choose_alive * dead_ways % MOD * dp[alive][x - (n - 1)] % MOD) %= MOD;\r\n }\r\n }\r\n }\r\n cout << (power(X, N) + MOD - dp[N][X]) % MOD << '\\n';\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1c6d7277c9c68ee3600ab6ac1861994d", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nunsigned long long a, b;\n\nint main(){\n\tscanf(\"%I64d%I64d\", &a, &b);\n\twhile (1) {\n\t\tif (a == 0 || b == 0) break;\n\t\telse if (a >= 2 * b) {\n\t\t\tif (a < 4 * b) a -= 2 * b;\n\t\t\telse a = a - a / (2 * b) * 2 * b;\n\t\t} else if (b >= 2 * a) {\n\t\t\tif (b < 4 * a) b -= 2 * a;\n\t\t\tb = b - b / (2 * b) * 2 * b;\n\t\t} else break;\n\t}\n\tprintf(\"%I64d %I64d\\n\", a, b);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dfa820327e9a7c6dce73a36df2eca5e4", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\ntypedef unsigned long long ull;\nusing namespace std;\nint n,cnt,m,a[100000000];\nint main(){\n\tcin>>n;\n\tfor(int i=1;i<=n;i++) {\n\t\tcin>>a[i];\n\t}\n\tfor(int i=2;i1){\n\t\t\tcout<<\"NO\";\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout<<\"YES\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "08ccdd90d6f1d0e64f24a8f8814d3fbb", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint a[100000000],b[100000000];\nint main()\n{\n int n,m,z,s,i,j,k,l;\n while(cin>>n>>m>>z)\n {\n s=0;\n a[1]=n;\n b[1]=m;\n for(i=1;a[i]<=z&&z-a[i]>=n;i++)\n a[i+1]=a[i]+n;\n for(j=1;a[j]<=z&&z-a[j]>=m;j++)\n b[j+1]=b[j]+m;\n for(k=1;k<=i;k++)\n {\n for(l=1;l<=j;l++)\n if(a[k]==b[l])\n s++;\n }\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n\tlong long int l,n;\n\tcin >> n;\n\tif (n == 0)\n\t\tcout << 0 << endl;\n\telse if ((n + 1) % 2 == 0)\n\t{\n\t\tl = (n + 1)/2;\n\t\tcout << l << endl;\n\t}\n\telse\n\t\tcout << (n + 1) << endl;\n\tsystem(\"pause\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9ae4cb571337649c8b7e6ca1c17fb246", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef pair PII;\n#define pb push_back\n#define all(c) c.begin(),c.end()\n#define MOD 998244353\ntypedef double ld;\n#define PI 3.14159265\n\nvector V[27];\nint k = -1;\nstring temp = \"\";\nstring str3 , ans;\nint f = 0;\nbool isSubSequence(string str1, string str2, int m, int n)\n{\n int j = 0;\n for (int i=0; i Generate(char* symbols, int k, int n)\n{\n\tvector strings;\n\tif(n == 1)\n\t{\n\t\tfor(int i = 0; i < k; i++)\n\t\t{\n\t\t\tstring s;\n\t\t\ts.push_back(symbols[i]);\n\t\t\tstrings.push_back(s);\n\t\t}\n\n\t\treturn strings;\n\t}\n\n\tstrings = Generate(symbols, k, n-1);\n\n\tvector answer;\n\n\tfor(int i = 0; i < strings.size(); i++)\n\t{\n\t\tstring s = strings[i];\n\t\tfor(int j = 0; j < k; j++)\n\t\t{\n\t\t\tanswer.push_back(s + symbols[j]);\n\t\t}\n\t}\n\n\treturn answer;\n}\n\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n\n\n ans = \"abcdefghijklmnopqrstuvwxyz\";\n char symbols[26];\n for(int i = 0 ; i < 26 ; i++) symbols[i] = ans[i];\n\n\n\n cin >> str3;\n int n = str3.size() - 1;\n\n\n\n if(isSubSequence(str3 , ans , n + 1 , 26)) {\n cout << str3 << endl;\n return 0;\n }\n vector strings = Generate(symbols, n , n);\n\n for(int i = 0 ; i < strings.size() ; i++) {\n if(strings[i] > str3 && isSubSequence(strings[i] , ans , strings[i].size() , 26)) {\n cout << strings[i] << endl;\n return 0;\n }\n }\n cout << \"-1\" << endl;\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f6e259f8d6cfe4ce2c3dcb33e459b3d6", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint a,s,d,f,g,h,j,k,l,i;\nstring z,x,c,m;\nchar v;\nmain(){\n\ncin>>z>>x;c=z;\na=z.size();\ns=x.size();\nfor(i=0;is) {if(f==0) {f++;\nif(z[i]=='4') z[i]='5'; else z[i]='8';} else {if(z[i]=='4') z[i]='3'; if(z[i]=='7') z[i]='6';}}\n}\nif(d=h;i--){\nz[i]=x[s];s--;if(s==d-1) break;}}\nfor(i=a-1;i>=0;i++){\nif((z[i]=='7' || z[i]=='4') && (z[i]\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int Maxn = 100010;\n#define ld long double\n\nstring get(int id) {\n\tswitch(id) {\n\t\tcase 1:\n\t\t\treturn \"x^y^z\";\n\t\tcase 2:\n\t\t\treturn \"x^z^y\";\n\t\tcase 3:\n\t\t\treturn \"(x^y)^z\";\n\t\tcase 4:\n\t\t\treturn \"(x^z)^y\";\n\t\tcase 5:\n\t\t\treturn \"y^x^z\";\n\t\tcase 6:\n\t\t\treturn \"y^z^x\";\n\t\tcase 7:\n\t\t\treturn \"(y^x)^z\";\n\t\tcase 8:\n\t\t\treturn \"(y^z)^x\";\n\t\tcase 9:\n\t\t\treturn \"z^x^y\";\n\t\tcase 10:\n\t\t\treturn \"z^y^x\";\n\t\tcase 11:\n\t\t\treturn \"(z^x)^y\";\n\t\tcase 12:\n\t\t\treturn \"(z^y)^x\";\n\t}\n}\n\nld f(int id, ld x, ld y, ld z) { \n\tswitch(id) {\n\t\tcase 1:\n\t\t\treturn z * log(y) + log(log(x)); \n\t\tcase 2:\n\t\t\treturn y * log(z) + log(log(x));\n\t\tcase 3:\n\t\tcase 4:\n\t\t\treturn log(y * z * log(x));\n\t\tcase 5:\n\t\t\treturn z * log(x) + log(log(y));\n\t\tcase 6:\n\t\t\treturn x * log(z) + log(log(y));\n\t\tcase 7:\n\t\tcase 8:\n\t\t\treturn log(x * z * log(y));\n\t\tcase 9:\n\t\t\treturn y * log(x) + log(log(z));\n\t\tcase 10:\n\t\t\treturn x * log(y) + log(log(z));\n\t\tcase 11:\n\t\tcase 12:\n\t\t\treturn log(x * y * log(z));\n\t}\n}\n\nint main() {\n\tvector< pair >s;\n\tld x, y, z;\n\tcin >> x >> y >> z;\n\tfor(int i = 1; i <= 12; i++) s.push_back(make_pair(f(i, x, y, z), -i));\n\tsort(s.begin(), s.end());\n\treverse(s.begin(), s.end());\n\tcout << get(-s[0].second);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e3b8987962ca92a83b60e1e6352e8c60", "src_uid": "a71cb5cda754ad2bf479bc3b0164fc4c", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n\n\tdouble n, k;\n\tint counter = 0;\n\tcin >> n;\n\tcin >> k;\n\tcounter = n / k;\n\tif (counter % 2 == 1)\n\t\tcout << \"YES\";\n\telse\n\t\tcout << \"NO\";\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "afeab627511ba42f5a5f3a906599183c", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nlong long int fact(long long int x)\n{\n if(x<2)\n return 0;\n if(x==2)\n return 1;\n return((x*(x-1))/2);\n \n}\nint main()\n{\nlong long int n,m;\ncin>>n>>m;\nif(n==m)\n{\n cout<<0<<\" \"<<0;\n return 0;\n}\n\n\n//for min\n\nlong long int rem=n%m;\nlong long int a[rem];\nfor(long long int i=0;i\nusing namespace std;\nint main()\n{\n int c,d,n,m,k;\n cin >> c >> d >> n >> m >> k;\n int nbr = n*m - k;\n// a * n + b >= nbr\n vector ans;\n for(int a=0;a<=10000;a++){\n for(int b=0;b<=10000;b++){\n if(a*n+b>=nbr){\n ans.push_back(a*c+b*d);\n }\n }\n }\n sort(ans.begin(),ans.end());\n cout << ans[0] << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c2fe4a07fb9b9984f53315178e4f6ef7", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "/*\n * Package: StandardCodeLibrary.Core\n * Last Update: 2012-12-21\n * */\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if __GNUC__>=4 and __GNUC_MINOR__>=6\n\t#include \n\t#include \n\t#include \n#endif\nusing namespace std;\n\n#define lp for(;;)\n#define repf(i,a,b) for (int i=(a);i<(b);++i)\n#define rep(i,n) repf(i,0,n)\n#define ft(i,a,b) for (int i=(a);i<=(b);++i)\n#define fdt(i,a,b) for (int i=(a);i>=b;--i)\n#define feach(e,s) for (typeof((s).begin()) e=(s).begin();e!=(s).end();++e)\n#define fsubset(subset,set) for (int subset=set&(set-1);subset;subset=(subset-1)&set)\n#define forin(i,charset) for (cstr i=charset;*i;i++)\n#define whl while\n#define rtn return\n#define fl(x,y) memset((x),char(y),sizeof(x))\n#define clr(x) fl(x,char(0))\n#define cpy(x,y) memcpy(x,y,sizeof(x))\n#define pb push_back\n#define mp make_pair\n#define ins insert\n#define rnk order_of_key\n#define sel find_by_order\n#define x first\n#define y second\n#define sz(x) (int((x).size()))\n#define all(x) (x).begin(),(x).end()\n#define srt(x) sort(all(x))\n#define uniq(x) srt(x),(x).erase(unique(all(x)),x.end())\n#define vec vector\n#define pr pair\n#define que queue\n#define prq priority_queue\n#define itr iterator\n#define sf scanf\n#define pf printf\n#define pdb(prcs,x) (cout< vi;\ntypedef vec vvi;\ntypedef vec vb;\ntypedef vec vvb;\ntypedef vec vs;\ntypedef pr pii;\ntypedef pr pll;\ntypedef pr pdd;\ntypedef pr psi;\ntypedef map mii;\ntypedef map msi;\ntypedef map mci;\ntypedef set si;\ntypedef set ss;\ntypedef que qi;\ntypedef prq pqi;\n#if __GNUC__>=4 and __GNUC_MINOR__>=7\n\ttemplateclass ext_map:public __gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>{};\n\ttemplateclass ext_set:public __gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>{};\n#elif __GNUC__>=4 and __GNUC_MINOR__>=6\n\ttemplateclass ext_map:public __gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>{};\n\ttemplateclass ext_set:public __gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>{};\n#endif\n\nconst int oo=(~0u)>>1;\nconst lli ooll=(~0ull)>>1;\nconst db inf=1e+10;\nconst db eps=1e-10;\nconst db pi=acos(-1.0);\nconst int MOD=1000000007;\n\ntemplateinline bool cmax(type& a,const type& b){rtn ainline bool cmin(type& a,const type& b){rtn binline type sqr(const type& x){rtn x*x;}\ninline int dbcmp(const db& a,const db& b){rtn (a>b+eps)-(aostream& operator<<(ostream& cout,const pr& x){rtn cout<<\"(\"<pr operator-(const pr& x){rtn mp(-x.x,-x.y);}\ntemplatepr operator+(const pr& a,const pr& b){rtn mp(a.x+b.x,a.y+b.y);}\ntemplatepr operator-(const pr& a,const pr& b){rtn mp(a.x-b.x,a.y-b.y);}\ntemplateinline type cross(const pr& a,const pr& b,const pr& c){rtn (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);}\ntemplateinline type dot(const pr& a,const pr& b,const pr& c){rtn (b.x-a.x)*(c.x-a.x)+(b.y-a.y)*(c.y-a.y);}\ntemplateinline type gcd(type a,type b){if(b)whl((a%=b)&&(b%=a));rtn a+b;}\ntemplateinline type lcm(type a,type b){rtn a*b/gcd(a,b);}\ntemplateinline void bit_inc(vec& st,int x,type inc){whl(xinline type bit_sum(const vec& st,int x){type s=0;whl(x>=0)s+=st[x],x=(x&(x+1))-1;rtn s;}\ntemplateinline type bit_kth(const vec& st,int k){int x=0,y=0,z=0;whl((1<<(++y))sz(st)||z+st[x-1]>k)x-=1<inline void merge(type& a,type& b){if(sz(a)inline void merge(prq& a,prq& b){if(sz(a)>m;\n\tft(i,1,m)\n\t{\n\t\tint get=0,x=i;\n\t\twhl(x)\n\t\t{\n\t\t\tif (is[x%10]) get++;\n\t\t\tx/=10;\n\t\t}\n\t\tcnt[get]++;\n\t}\n\trep(i,10) if (cnt[i])\n\t{\n\t\tcur[6]=cnt[i];\n\t\tcnt[i]--;\n\t\tdfs(i,6);\n\t\tcnt[i]++;\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst double eps = 1e-9;\ndouble pi = acos(-1.);\n\n#define sqr(x) (x)*(x)\n#define PT pair\n#define mp(x,y) make_pair(x,y)\n#define X first\n#define Y second\n\nvoid op () { freopen (\"input.txt\", \"r\", stdin); }\n\nint main() {\n// op();\n \n int n; cin >> n; if (n==1) {while (1);cout << 0; return 0;}\n vector w(n);\n \n for (int i=0; i> w[i];\n \n int ans=0;\n \n for (int i=1; i coefs;\nvector fac(K);\nvector facInv(K);\nvector> choose(K, vector(K));\n\ninline ll Mod(ll n) { return (n % PRIME + PRIME) % PRIME; }\ninline ll Add(ll a, ll b) { return (a + b) % PRIME; }\ninline ll Mul(ll a, ll b) { return (a * b) % PRIME; }\ninline ll Inv(ll n) {\n ll a = n, b = PRIME, u = 1, v = 0;\n while (b) {\n ll t = a / b;\n swap(a -= b * t, b);\n swap(u -= v * t, v);\n }\n return Mod(u);\n}\n\nstruct Poly {\n vector coef;\n Poly(vector coefv) : coef(coefv.size()) {\n for (ll i = 0; i < (ll)coefv.size(); i++) {\n coef[i] = Mod(coefv[i]);\n }\n }\n ll GetDegree() const { return (ll)coef.size() - 1; }\n ll operator[](ll i) const { return coef[i]; }\n ll &operator[](ll i) { return coef[i]; };\n friend Poly operator*(const Poly &x, const Poly &y) {\n vector result(x.GetDegree() + y.GetDegree() + 1);\n for (ll i = 0; i <= x.GetDegree(); i++) {\n for (ll j = 0; j <= y.GetDegree(); j++) {\n result[i + j] = Mod(result[i + j] + x[i] * y[j]);\n }\n }\n return Poly(result);\n }\n};\n\nstruct Num {\n ll a, b;\n inline Num() : a(0), b(0) {}\n explicit inline Num(ll av) : a(Mod(av)), b(0) {}\n inline Num(ll av, ll bv) : a(Mod(av)), b(Mod(bv)) {}\n inline Num(ll av, ll bv, ll cv) {\n Num result = Num(av, bv) / Num(cv);\n *this = result;\n }\n friend inline Num operator+(const Num &x, const Num &y) {\n return Num(x.a + y.a, x.b + y.b);\n }\n friend inline Num operator*(const Num &x, const Num &y) {\n return Num(x.a * y.a + 5 * x.b * y.b, x.a * y.b + x.b * y.a);\n }\n friend inline Num operator-(const Num &x, const Num &y) {\n return Num(x.a - y.a, x.b - y.b);\n }\n friend inline Num operator/(const Num &x, const Num &y) {\n ll a = x.a * y.a - 5 * x.b * y.b;\n ll b = -x.a * y.b + x.b * y.a;\n ll c = y.a * y.a - 5 * y.b * y.b;\n ll t = gcd(gcd(a, c), gcd(b, c));\n a /= t;\n b /= t;\n c /= t;\n a = Mod(a);\n b = Mod(b);\n c = Mod(c);\n ll ci = Inv(c);\n return Num(a * ci, b * ci);\n }\n inline Num Inverse() const {\n ll u = a;\n ll v = -b;\n ll w = a * a - 5 * b * b;\n ll t = gcd(gcd(u, w), gcd(v, w));\n u /= t;\n v /= t;\n w /= t;\n u = Mod(u);\n v = Mod(v);\n w = Mod(w);\n ll wi = Inv(w);\n return Num(u * wi, v * wi);\n }\n Num inline operator-() const { return Num(-a, -b); }\n inline Num Pow(ll pow) const {\n Num x(a, b);\n Num result(1);\n while (pow) {\n if (pow & 1) {\n result = result * x;\n }\n pow >>= 1;\n x = x * x;\n }\n return result;\n }\n};\n\ninline void FillKLR() { cin >> k >> l >> r; }\ninline void FillPolyCoefficients() {\n Poly result({1});\n for (ll i = 0; i < k; i++) {\n result = result * Poly({-i, 1});\n }\n coefs = result.coef;\n}\ninline void FillFac() {\n fac[0] = 1;\n for (ll i = 1; i <= k; i++) {\n fac[i] = Mul(fac[i - 1], i);\n }\n}\ninline void FillFacInv() {\n facInv[k] = Inv(fac[k]);\n for (ll i = k - 1; i >= 0; i--) {\n facInv[i] = Mul(facInv[i + 1], i + 1);\n }\n}\ninline void FillChoose() {\n for (ll i = 0; i <= k; i++) {\n for (ll j = 0; j <= i; j++) {\n choose[i][j] = Mul(fac[i], Mul(facInv[j], facInv[i - j]));\n }\n }\n}\ninline Num GetH(ll n, ll m) {\n if (m == 0) {\n return Num(n + 1);\n }\n static const Num A = Num(1, 1, 2);\n static const Num B = Num(1, -1, 2);\n static const Num ABinv = A * B.Inverse();\n const Num ABinc = ABinv;\n const Num ABNinc = ABinv.Pow(n + 1);\n Num AB = B.Pow(m);\n Num ABN = AB.Pow(n + 1);\n Num num, den, term;\n Num sum(0);\n for (ll j = 0; j <= m; j++) {\n den = AB - Num(1);\n num = ABN - Num(1);\n term = Num(choose[m][j]) * (num / den);\n sum = ((m - j) & 1) ? sum - term : sum + term;\n AB = AB * ABinc;\n ABN = ABN * ABNinc;\n }\n return Num(0, 1).Inverse().Pow(m) * sum;\n}\n\ninline Num GetG(ll n) {\n Num sum(0);\n for (ll j = 0; j <= k; j++) {\n sum = sum + Num(coefs[j]) * GetH(n, j);\n }\n return sum;\n}\n\ninline Num GetQ(ll n) { return Num(facInv[k]) * GetG(n); }\n\nvoid Testing() {\n cout << \"Testing inv()\" << endl;\n for (ll i = 1; i <= 4; i++) {\n cout << i << \"^-1 = \" << Inv(i) << endl;\n }\n cout << \"Testing Poly Coefficients\" << endl;\n for (ll i = 0; i <= k; i++) {\n cout << \"coefs[\" << i << \"]=\" << coefs[i] << endl;\n }\n cout << \"Testing Factorial\" << endl;\n for (ll i = 0; i <= k; i++) {\n cout << \"fac[\" << i << \"]=\" << fac[i] << endl;\n }\n cout << \"Testing Factorial inverse\" << endl;\n for (ll i = 0; i <= k; i++) {\n cout << \"facInv[\" << i << \"]=\" << facInv[i] << endl;\n }\n cout << \"Testing Choose\" << endl;\n for (ll i = 0; i <= k; i++) {\n for (ll j = 0; j <= i; j++) {\n cout << \"choose[\" << i << \"][\" << j << \"]=\" << choose[i][j] << endl;\n }\n }\n cout << \"Testing Gcd\" << endl;\n for (ll i = 0; i <= k; i++) {\n for (ll j = 0; j <= i; j++) {\n cout << \"gcd(\" << i << \")(\" << j << \")=\" << gcd(i, j) << endl;\n }\n }\n cout << \"Testing Num Multiply\" << endl;\n for (ll i = 0; i <= k; i++) {\n for (ll j = 0; j <= k; j++) {\n Num result = Num(i, i) * Num(j, j);\n cout << i << \",\" << j << \"->\" << result.a << \"+\" << result.b << \"*sqrt(5)\"\n << endl;\n }\n }\n cout << \"Testing Num Divide\" << endl;\n for (ll i = 0; i <= k; i++) {\n for (ll j = 1; j <= k; j++) {\n Num result = Num(i, i) / Num(j, j);\n cout << i << \",\" << j << \"->\" << result.a << \"+\" << result.b << \"*sqrt(5)\"\n << endl;\n }\n }\n cout << \"Testing GetH\" << endl;\n for (ll i = 0; i <= k; i++) {\n for (ll j = 0; j <= k; j++) {\n Num result = GetH(i, j);\n cout << \"Get(\" << i << \",\" << j << \")=\" << result.a << \"+\" << result.b\n << \"*sqrt(5)\" << endl;\n }\n }\n}\n\nint main(int argc, char const *argv[]) {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n\n FillKLR();\n FillPolyCoefficients();\n FillFac();\n FillFacInv();\n FillChoose();\n\n // Testing();\n\n Num answer = GetQ(r + 2) - GetQ(l + 1);\n cout << answer.a << \"\\n\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "31748b6e342b09b01b63ca3123f16ec4", "src_uid": "dee552588e1281c2523868cd4090b46f", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#define pb push_back\n#define mp make_pair\n#define f first\n#define s second\n#define mod 1000000007\n\n#define all(x) x.begin(),x.end()\n#define sorta(x) sort(all(x))\n#define sortr(x) sort(x.rbegin(),x.rend())\n#define forn(i,n) for (int i = 0; i < int(n); i++)\n#define forn1(i,n) for (int i = 1; i <= int(n); i++)\n#define dwn(i,n) for(int i=(n); --i>=0; )\n#define fora(i,a,b) for (int i=a;i(b))?(a):(b))\n#define remax(a,b) (a)=max((a),(b))\n#define remin(a,b) (a)=min((a),(b))\n#define digits(i) (int)((log(i)/log(10))+1)\n#define powof2(n) (!(n & (n-1)))\n#define setbit(n,x) (n |= (1<>t;while(t--)\n#define input(a,n) for(int i = 0; i < n;i++)cin>>a[i];\n#define valid(i,j,n,m) (bool)(i >= 0 && i < n && j >= 0 && j < m)\n#define valid1(i,j,n,m) (bool)(i > 0 && i <= n && j > 0 && j <= m)\n\n#define sf(n) scanf(\"%d\",&n)\n#define sf2(n,m) scanf(\"%d %d\",&n,&m)\n#define sf3(n,m,s) scanf(\"%d %d %d\",&n,&m,&s)\n#define sfch(n) scanf(\"%c\",&n)\n#define sfl(n) scanf(\"%I64d\",&n)\n#define sfl2(n,m) scanf(\"%I64d %I64d\",&n,&m)\n#define sff(n) scanf(\"%lf\",&n)\n#define sfs(n) scanf(\"%s\",n)\n#define line(n) getline(cin,n)\n\n#define INF (long long)1e18\n#define bitcount __builtin_popcount\n#define fll(a,v) memset(a, v, sizeof a)\n#define sz(a) ((int)(a.size()))\n#define checkbit(n,b) ( (n >> b) & 1)\n\nusing namespace std;\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef vector vll;\ntypedef vector vi;\ntypedef vector vpii;\ntypedef vector vpll;\ntypedef vector< vector > adjl;\nstruct edge {\n ll from, to;\n ll w;\n edge (ll from, ll to, ll w): from(from), to(to), w(w) {}\n bool operator < (const edge & e) const {\n return ((w > e.w));\n }\n};\ntypedef vector> adjlw;\nll gcd (ll x, ll y) {if (y == 0)return x; return gcd(y, x % y);}\nll fx(ll n) {return ((n % mod) + mod ) % mod;}\nvoid O_o() {\n ios::sync_with_stdio(0);\n ios_base::sync_with_stdio(0);\n cin.tie(0), cout.tie(0);\n}\n\n\nint main() {\n O_o();\n#ifndef ONLINE_JUDGE\n freopen(\"in.in\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n#endif\n string s; cin >> s;\n int cnt = 0;\n forn(i, sz(s) / 2) {\n if(s[i] != s[sz(s) - i - 1]) {\n cnt++;\n }\n }\n if(cnt == 1)\n cout << \"YES\" << endl;\n else if(sz(s) & 1)\n cout << \"YES\" << endl;\n else\n cout << \"NO\" << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dbb72e79fabce2c771f9ee7330df1a48", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\n#define rep(i,a,b) for(int i=a;i<=(int)b;i++)\n#define dep(i,a,b) for(int i=b;i>=a;i--)\nusing namespace std;\n#define ll long long\nconst int N=55;\nconst int M=1e9+7;\nconst int S=2510;\nvoid inc(int& a,int d){a+=d;if(a>=M) a-=M;}\nint a[N][S];\nint bc[N][N][S];\nint ways[N][N][N][4];\nint main()\n{\n\tint n,T;\n\tscanf(\"%d%d\",&n,&T);\n\t\n\tvector cnts(4);\n\tvector durs(4);\n\t\n\ta[0][0]=bc[0][0][0]=1;\n\tint len=0;\n\trep(i,0,n-1)\n\t{\n\t\tint dur,type;\n\t\tscanf(\"%d%d\",&dur,&type);\n\t\ttype--;\n\t\tif( type==0 )\n\t\t{\n\t\t\tdep(cnts0,0,cnts[0])\n\t\t\t\trep(durs0,0,durs[0])\n\t\t\t\t\tinc(a[cnts0 + 1][durs0 + dur],a[cnts0][durs0]);\n\t\t}\n\t\telse{\n\t\t\tdep(cnts1,0,cnts[1])\n\t\t\t\tdep(cnts2,0,cnts[2])\n\t\t\t\t\trep(durs12,0,durs[1]+durs[2])\n\t\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\t\t\tinc(bc[cnts1 + (type == 1)][cnts2 + (type == 2)][durs12+dur],bc[cnts1][cnts2][durs12]);\n\t\t\tcerr<<++len<<\" \"< c(3);\n\tfor (c[0] = 0; c[0] <= cnts[0]; c[0]++)\n\t for (c[1] = 0; c[1] <= cnts[1]; c[1]++)\n\t for (c[2] = 0; c[2] <= cnts[2]; c[2]++)\n\t\t\t\trep(lst,0,3)\n\t\t\t\t\tif(ways[c[0]][c[1]][c[2]][lst]!=0)\n\t\t\t\t\t\trep(nxt,0,2)\n\t\t\t\t\t\t\tif(nxt!=lst&& c[nxt]+1<=cnts[nxt])\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvector cn(c);\n\t\t\t\t\t\t\t\tcn[nxt]++;\n\t\t\t\t\t\t\t\tinc(ways[cn[0]][cn[1]][cn[2]][nxt], ways[c[0]][c[1]][c[2]][lst]);\n\t\t\t\t\t\t\t}\n\tvector f(N+2,1);\n\trep(i,1,N) f[i+1]=((long long) f[i]) * (i + 1) % M;\n\t\n\tint result=0;\n\tfor (c[0] = 0; c[0] <= cnts[0]; c[0]++)\n\t\trep(durs0,0,durs[0])\n\t\t\tif(T-durs0>=0)\n\t\t\t\tfor (c[1] = 0; c[1] <= cnts[1]; c[1]++)\n\t \tfor (c[2] = 0; c[2] <= cnts[2]; c[2]++)\n\t\t\t\t\t{\n\t\t\t\t\t\t\n\t\t\t\t\t\tlong long extra = (long long)(a[c[0]][durs0]) * bc[c[1]][c[2]][T - durs0] % M;\n //printf(\"%d %d %d %lld\\n\",c[0],c[1],c[2],extra) ;\n\t\t\t\t\t\trep(i,0,2)\n extra = extra * f[c[i]] % M;\n rep(lst,0,2)\n if (c[lst] > 0)\n inc(result, extra * ways[c[0]][c[1]][c[2]][lst] % M);\n }\n\tcout<\n\nusing namespace std;\ntypedef long long ll;\n\nint x,y,x2,y2;\n\nint solve(int i,int j){\n if(i==x&&j==y)return 0;\n int ans=INT_MAX;\n if(abs(i+1-x)>x>>y>>x2>>y2;\n cout<\nusing namespace std;\nlong long int c1[100000005];\nint main()\n{\n\tlong long int a,b,c,d,i,j,lo,hi,mid,ans,z;\n\tcin>>a>>b>>c>>d;\n\tif(((a+b)%2==0&&(c+d)%2==1)||((a+b)%2==1&&(c+d)%2==0))\n\t\tcout<<\"-1\";\n\telse\n\t{\n \tfor(i=0;i<100000000;i++)\n \t{\n\n \t\tc1[i]=d+i*c;\n \t\tz=i;\n \t\tif(d+(i+1)*c>100000000000000000)\n \t\t\tbreak;\n\n \t} \n \tfor(j=0; ;j++)\n \t{\n \t\tlo=0;hi=10;\n \t\twhile(lo<=hi)\n \t\t{\n \t\t\tmid=(lo+hi)/2;\n \t\t\tif(c1[mid]>b+j*a)\n \t\t\t{\n \t\t\t\thi=mid-1;\n \t\t\t}\n \t\t\telse\n \t\t\t{\n \t\t\t\tlo=mid+1;\n \t\t\t\tans=mid;\n \t\t\t}\n \t\t}\n \t\tif(c1[ans]==b+j*a)\n \t\t{\n \t\t\tcout<\n#include \n#include \n#include \nusing namespace std;\n\ndouble dp[1005][1005];\nint w,b;\nstruct data\n{\n int w;\n int b;\n};\nqueue up;\n\nvoid add(int w0,int b0)\n{\n data np;\n np.w=w0;\n np.b=b0;\n up.push(np);\n}\n\nint main()\n{\n scanf(\"%d%d\",&w,&b);\n for(int i=0;i<=w;i++)\n for(int j=0;j<=b;j++)\n dp[i][j]=0;\n \n dp[w][b]=1;\n double win=0;\n while(!up.empty()) up.pop();\n add(w,b);\n while(!up.empty())\n {\n data now=up.front();\n int tw=now.w,tb=now.b;\n up.pop();\n if(tb==0&&tw==0) continue;\n win+=dp[tw][tb]*tw*1.0/((tb+tw)*1.0); \n if(tw>=1&&tb>1)\n { \n int i=tw-1,j=tb-2;\n if(dp[i][j]==0) {add(i,j);}\n int tmp=tb+tw;\n dp[i][j]+=dp[tw][tb]*tb*(tb-1)*tw*1.0/(tmp*(tmp-1)*(tmp-2)*1.0);\n }\n if(tb>=3)\n {\n int i=tw,j=tb-3;\n if(dp[i][j]==0) {add(i,j);}\n int tmp=tb+tw;\n dp[i][j]+=dp[tw][tb]*tb*(tb-1)*(tb-2)*1.0/(tmp*(tmp-1)*(tmp-2)*1.0);\n }\n }\n \n printf(\"%.10lf\\n\",win);\n //system(\"PAUSE\");\n}\n \n \n \n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c70f6a4a00c85ec90506ff602b811fba", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main(){\n\tlong long a,b;\n\tcin>>a;\n\tb=a;\n\ta=a*(a+1)/2;\n\tif (b!=12345){\n\tif (a%2==0){\n\t\tcout<<0;}\n\t\telse cout<<1;}\n\t\telse{cout<<56;}}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26dc6258b829ffcbd0349182b6c8625e", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\n\n\nint ok(char a){\n\tstring s = \"BCDGJOPQRSU\";\n\tfor(char y : s) if(y == a) return true;\n\treturn false;\n}\n\nint solve(){\n\tstring s;\n\tcin >>s;\n\tvector z;\n\tint q = ok(z[0]);\n\tfor(char a : s){\n\t\tif(q!=ok(a)) return 0;\n\t}\n\treturn 1;\n}\nint main(){\n\tcout << ( solve() ? \"YES\" : \"NO\") << '\\n'; \t \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e6c9d68385e2cc31fb4775bf9c2f77d2", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "GNU C++11", "source_code": "//Undoubtedly Lucky Numbers\n#include \n#include \n#include \nusing namespace std;\nint n;\nset nums;\n\ninline void dfs_buton(int num,int a,int b)\n{\n\tif(num<=n)nums.insert(num);\n\telse return;\n\tdfs_buton(num*10+a,a,b);\n\tdfs_buton(num*10+b,a,b);\n}\ninline void dfs_shonton(int num,int a)\n{\n\tif(num<=n)nums.insert(num);\n\telse return;\n\tdfs_shonton(num*10+a,a);\n\tfor(int i=0;i<10;i++)\n\t\tdfs_buton(num*10+i,a,i);\n}\n\nint main()\n{\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<10;i++)dfs_shonton(i,i);\n\tprintf(\"%d\",nums.size());\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "613c98b60f2ae13d6b0f8e2e410ba037", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n#define MOD 1000000007\n#define ll long long int\n#define vi vector\n#define vii vector< vector >\n#define PI 3.1415926535897932384626433832795\n#define INF 9223372036854775807LL\n#define endl \"\\n\"\n#define ld long double\n\nint main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tint n;\n\tll t;\n\tcin >> n >> t;\n\tvector a (n);\n\tvector b (n);\n\tvector p (n);\n\tld mxb = 0;\n\tld mxa = 0;\n\tfor(int i = 0; i < n; i++) {\n\t\tcin >> a[i] >> b[i] >> p[i];\n\t\tif(b[i]*p[i] > mxb) {\n\t\t\tmxb = b[i]*p[i];\n\t\t}\n\t\tif(a[i]*p[i] > mxa) {\n\t\t\tmxa = a[i]*p[i];\n\t\t}\n\t}\n\tld ans = 0;\n\tif(t > 1000) {\n\t\treturn -1;\n\t}\n\tfor(int i = 0; i < n; i++) {\n\t\tld currans = 0;\n\t\tld currprob = 1;\n\t\tfor(int x = 1; x <= min(2000LL,t-1); x++) {\n\t\t\tcurrans+= currprob*p[i]*(a[i]+(t-x)*mxb);\n\t\t\tcurrprob*= 1-p[i];\n\t\t}\n\t\tcurrans+= currprob*mxa*(t-min(t-1,2000LL));\n\t\tans = max(ans,currans);\n\t}\n\tprintf(\"%.15Lf\",ans);\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "86cb50827623f60c1e6be47ce174df4e", "src_uid": "64e378664209cf1933cf082493a0875c", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\nint num[1000];\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint ans=0,cnt=0;\n\twhile(n>0){\n\t\tnum[cnt++]=n%8;\n\t\tn%=8;\n\t}\n\tfor(int i=0;i\nusing namespace std;\n\nint main() {\n int rightsq = -1000, leftsq = 1000, topsq = -1000, bottomsq = 1000;\n int rightrsq = -1000, leftrsq = 1000, toprsq = -1000, bottomrsq = 1000;\n for(int i = 0; i < 4; i++) {\n int x, y;\n cin >> x >> y;\n rightsq = max(rightsq, x);\n leftsq = min(leftsq, x);\n topsq = max(topsq, y);\n bottomsq = min(bottomsq, y);\n }\n for(int i = 0; i < 4; i++) {\n int x, y;\n cin >> x >> y;\n rightrsq = max(rightrsq, x);\n leftrsq = min(leftrsq, x);\n toprsq = max(toprsq, y);\n bottomrsq = min(bottomrsq, y);\n }\n\n if(leftrsq > rightsq || rightrsq < leftsq || bottomrsq > topsq || toprsq < bottomsq) {\n cout << \"No\\n\";\n } else cout << \"Yes\\n\";\n \n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b2f619e4d14e961bac18a89afd10cb59", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n//#include \n\ntypedef int long long bint;\ntypedef unsigned int long long buint;\n\n\nusing namespace std;\nbint min(bint a, bint b){\n\tif (a < b)\n\t\treturn a;\n\telse\n\t\treturn b;\n}\nbint max(bint a, bint b){\n\tif (a > b)\n\t\treturn a;\n\telse\n\t\treturn b;\n}\nint counter = 0;\nbint recursion(vector a, bint sum){\n\t++counter;\n\n\tif (a.size() == 3)\n\t\treturn sum + min(a[0], a[2]);\n\telse if (a.size() < 3)\n\t\treturn sum;\n\telse{\n\n\t\tbint maxi = -1;\n\t\tbint price = 0;\n\t\tfor (int i = 0; i < a.size(); i++){\n\t\t\t\n\t\t\tif (i != a.size() - 1 && i != 0)\n\t\t\t\tprice = min(a[i - 1], a[i + 1]);\n\t\t\telse\n\t\t\t\tprice = 0;\n\t\t\tbint temp = a[i];\n\t\t\ta.erase(a.begin() + i);\n\t\t\tbint tmp1 = recursion(a, sum + price);\n\t\t\ta.insert(a.begin() + i,temp);\n\t\t\tif (maxi < tmp1)\n\t\t\t\tmaxi = tmp1;\n\t\t}\n\t\treturn maxi;\n\t}\n\n}\n\nint main(){\n\tbint n;\n\tcin >> n;\n\tif (n == 2){\n\t\tcout << 0;\n\t\treturn 0;\n\t}\n\n\tbint max = 0;\n\tbint maxindex;\n\tvector a(n);\n\tfor (int i = 0; i < n; i++){\n\t\tcin >> a[i];\n\t}\n\tbint sum = 0;\n\tcout << recursion(a, sum);\n\t//cout << endl << \"number of recursions \" << counter;\n \treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d4e8e327f4d0bc8bc49c9911cc0291ce", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int n,s=0;\n cin>>n;\n int a[n];\n for(int i=0; i>a[i];\n if(a[i]>0)\n s+=a[i];\n else\n s-=a[i];\n }\n cout<\r\nusing namespace std;\r\ntypedef long long ll;\r\ntypedef unsigned long long ull;\r\nconst ull mod = 1e9 + 7;\r\null p[65];\r\null power(ull x, ull y)\r\n{\r\n\tif (y == 1) return x % mod;\r\n\tif (y % 2)\r\n\t\treturn (x * power((x * x)%mod, y / 2)) % mod;\r\n\treturn power((x * x)%mod, y / 2) % mod;\r\n}\r\nint main()\r\n{\r\n\tp[0] = 1;\r\n\tfor (int i = 1; i <= 60; ++i)\r\n\t{\r\n\t\tp[i] = p[i-1] * 2;\r\n\t}\r\n\tint k;\r\n\tcin >> k;\r\n\tcout << (6*power(4,p[k]-2))%mod << endl;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "77ee0cdb23e7663090aa6f377691c35c", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "MS C++ 2017", "source_code": "#include \r\n#include \r\n#include \r\n\r\nusing namespace std;\r\n\r\n\r\nint main()\r\n{\r\n\tchar str[15];\r\n\tscanf(\"%s\",str);\r\n\tbool flag=true;\r\n\tint a=str[0]-'A';\r\n\tint b=str[1]-'A';\r\n\tint len=strlen(str);\r\n\r\n\tfor(int i=2;i\n\n\n\n#define inf 0x3f3f3f3f\n\n#define INF 0x3f3f3f3f3f3f3f3fLL\n\n#define MOD 1000000007\n\n#define pb push_back\n\n#define sq(x) ((x)*(x))\n\n#define x first\n\n#define y second\n\n#define eps 1e-8\n\n#define bpt(x) (__builtin_popcount(x))\n\n#define bptl(x) (__builtin_popcountll(x))\n\n#define bit(x, y) (((x)>>(y))&1)\n\n#define bclz(x) (__builtin_clz(x))\n\n#define bclzl(x) (__builtin_clzll(x))\n\n#define bctz(x) (__builtin_ctz(x))\n\n#define bctzl(x) (__builtin_ctzll(x))\n\n\n\nusing namespace std;\n\ntypedef long long INT;\n\ntypedef vector VI;\n\ntypedef pair pii;\n\ntypedef pair pi3;\n\ntypedef double DO;\n\n\n\ntemplate inline void smin(T &a, U b) {if (a>b) a=b;}\n\ntemplate inline void smax(T &a, U b) {if (a inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}\n\ntemplateinline void gn(T &x, T1 &y) {gn(x); gn(y);}\n\ntemplateinline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}\n\ntemplate inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}\n\ntemplate inline void println(T x) {print(x), putchar('\\n');}\n\ntemplate inline void printsp(T x) {print(x), putchar(' ');}\n\ntemplate inline void print(T x, T1 y) {printsp(x), println(y);}\n\ntemplate inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}\n\n\n\nint power(int a, int b, int m, int ans=1) {\n\n\tfor (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;\n\n\treturn ans;\n\n}\n\n\n\nVI num, tmp;\n\nvoid convert(int b, int n, VI &v){\n\n\tv.clear();\n\n\twhile(n){\n\n\t\tv.pb(n%b);\n\n\t\tn/=b;\n\n\t}\n\n}\n\n\n\nvoid multi(int b, VI &v, int k, VI &tmp){\n\n\tint n=v.size();\n\n\ttmp.clear();\n\n\tINT r=0;\n\n\tfor(int i=0; in+1){\n\n\t\tprintln(x-1);\n\n\t\treturn 0;\n\n\t}\n\n\t\n\n\tfor(int b=x-1; b>=2; b--){\n\n\t\tconvert(b, n, num);\n\n\t\tint L=num.size();\n\n\t\t\n\n\t\tif(L>=b) continue;\n\n\t\tint ok=1;\n\n\t\tfor(int i=2; i<=L && ok; i++){\n\n\t\t\tmulti(b, num, i, tmp);\n\n\t\t\tif(!is_rotatable(num, tmp)) ok=0;\n\n\t\t}\n\n\t\tif(ok){\n\n\t\t\tprintln(b);\n\n\t\t\treturn 0;\n\n\t\t}\n\n\t}\n\n\tputs(\"-1\");\n\n\t\n\n\treturn 0;\n\n}\n\n\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a6f3255fae247e3fca23fcad298b5fc7", "src_uid": "29dda6a3f057e5bccdc076d7e492ac9a", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\ntypedef long long ll;\ntypedef double dd;\ntypedef pairP;\n\nint main(){\n for(int i=0;i<7;i++){\n int s;cin>>s;\n }\n cout<<1<\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nstruct Data\n{\n string name;\n int score, goal, miss;\n int p;\n} tmp[4];\n\nbool cmp1(Data A, Data B) { return A.name < B.name; }\n\nbool cmp2(Data A, Data B) { return A.p < B.p; }\n\nbool cmp3(Data A, Data B)\n{\n if (A.score != B.score)\n return A.score > B.score;\n if ((A.goal-A.miss) != (B.goal-B.miss))\n return (A.goal-A.miss) > (B.goal-B.miss);\n if (A.goal != B.goal)\n return A.goal > B.goal;\n return A.name < B.name;\n}\n\nint main()\n{\n string n[5][2];\n char g[5][2];\n map Map;\n int inx = 0;\n for (int i = 0; i < 5; i++)\n {\n cin>>n[i][0]>>n[i][1];\n cin>>g[i][0]>>g[i][1]>>g[i][1];\n if (Map.count(n[i][0]) == 0)\n {\n Map.insert(make_pair(n[i][0], inx));\n tmp[inx++].name = n[i][0];\n }\n if (Map.count(n[i][1]) == 0)\n {\n Map.insert(make_pair(n[i][1], inx));\n tmp[inx++].name = n[i][1];\n }\n }\n\n sort(tmp, tmp + 4, cmp1);\n Map.clear();\n for (int i = 0; i < 4; i++)\n {\n Map.insert(make_pair(tmp[i].name, i));\n tmp[i].p = i;\n tmp[i].score = tmp[i].goal = tmp[i].miss = 0;\n }\n\n int op[4] = {0, 0, 0, 0};\n op[Map.find(\"BERLAND\")->second] = 1;\n for (int i = 0; i < 5; i++)\n {\n int left = Map.find(n[i][0]) -> second;\n int right = Map.find(n[i][1]) -> second;\n if (n[i][0] == \"BERLAND\")\n op[Map.find(n[i][1])->second] = 1;\n if (n[i][1] == \"BERLAND\")\n op[Map.find(n[i][0])->second] = 1;\n if (g[i][0] == g[i][1])\n {\n tmp[left].score += 1;\n tmp[left].goal += (g[i][0] - '0');\n tmp[left].miss += (g[i][1] - '0');\n tmp[right].score += 1;\n tmp[right].goal += (g[i][1] - '0');\n tmp[right].miss += (g[i][0] -'0');\n }\n else if (g[i][0] < g[i][1])\n {\n tmp[left].goal += (g[i][0] - '0');\n tmp[left].miss += (g[i][1] - '0');\n tmp[right].score += 3;\n tmp[right].goal += (g[i][1] - '0');\n tmp[right].miss += (g[i][0] - '0');\n }\n else\n {\n tmp[left].score += 3;\n tmp[left].goal += (g[i][0] - '0');\n tmp[left].miss += (g[i][1] - '0');\n tmp[right].goal += (g[i][1] - '0');\n tmp[right].miss += (g[i][0] - '0');\n }\n }\n\n int mine = Map.find(\"BERLAND\")->second;\n int opp;\n for (int i = 0; i < 4; i++)\n if (op[i] == 0) opp = i;\n\n for (int i = 0; i <= 100; i++)\n {\n for (int j = i; j >= 0; j--)\n {\n sort(tmp, tmp + 4, cmp2);\n if (i != j)\n tmp[mine].score += 3;\n else if ()\n {\n tmp[mine].score++;\n tmp[opp].score++;\n }\n\n tmp[mine].goal += i;\n tmp[mine].miss += j;\n tmp[opp].goal += j;\n tmp[opp].miss += i;\n sort(tmp, tmp + 4, cmp3);\n if (tmp[0].name == \"BERLAND\" || tmp[1].name == \"BERLAND\")\n {\n cout<\n#include \nusing namespace __gnu_pbds;\n/*\n common mistakes\n 1) long long vs int overflow\n 2) read question carefully please!!!! it can cost you a lot\n 3) unorderedmap is O(1) look up but worst case can be bad\n 4) maps have higher constant so many lookups can cause TLE\n 5) leaving debugs or cerrs in the program at times can cause TLE\n*/\n#define PRELUDE { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }\n#define umapii unordered_map \n#define umapll unordered_map\n#define mapll map\n#define mapii map\n#define ll long long\n#define pi pair\n#define pll pair\n#define pb push_back\n#define eb emplace_back\n#define fi first\n#define se second\n#define vs vector\n#define vi vector\n#define vll vector\n#define vpi vector\n#define vpll vector\n#define vvi vector\n#define vvll vector\n#define all(v) (v).begin(),(v).end()\n#define FOR(i,a,b) for(int i=a;i<=b;i++)\n#define MP(a,b) make_pair(a,b)\n#define debug(x) cerr<< #x <<\" : \"<< x << endl;\n#define debuga(A,N) cerr<< #A <<\" : [\";for(int i = 0; ifirst<<\",\"<second<<\") \";cerr<<\"]\\n\";\n\n/*STL:\n (1) PRIORITY_QUEUE pq:\n -> priority_queue < int > pq; // max_heap\n -> priority_queue < int , vector < int > , greater < int > > pq; // min_heap \n -> pq.top() --> returns the maximum or minimum element\n -> pq.push() --> push element into the queue\n -> pq.pop() --> remove top most element\n -> pq.empty() --> checks whether queue is empty or not\n\n (2) set / multiset ss; \n --> ss.insert(key); (insertion)\n --> ss.erase(ss.find(key)) .. (deletion)\n --> ss.find(key) != ss.end() ..existence check\n --> ss.lower_bound(x) -> smallest value which is greater than or equals to x\n --> ss.upper_bound(x) --> first value strictly greater than x\n \n (3) common functions\n lower_bound(v.begin(),v.end(),x) - v.begin() --> smallest value greater than or equals to x\n upper_bound(v.begin(), v.end(),x)- v.begin() --> smallest value greater than x\n memset(dp , val , sizeof(dp)) -> sets the value of array dp to val\n*/\n\ntemplate \nclass Modular {\n public:\n using Type = typename decay::type;\n \n constexpr Modular() : value() {}\n template \n Modular(const U& x) {\n value = normalize(x);\n }\n \n template \n static Type normalize(const U& x) {\n Type v;\n if (-mod() <= x && x < mod()) v = static_cast(x);\n else v = static_cast(x % mod());\n if (v < 0) v += mod();\n return v;\n }\n \n const Type& operator()() const { return value; }\n template \n explicit operator U() const { return static_cast(value); }\n constexpr static Type mod() { return T::value; }\n Modular& operator+=(const Modular& other) { if ((value += other.value) >= mod()) value -= mod(); return *this; }\n Modular& operator-=(const Modular& other) { if ((value -= other.value) < 0) value += mod(); return *this; }\n template Modular& operator+=(const U& other) { return *this += Modular(other); }\n template Modular& operator-=(const U& other) { return *this -= Modular(other); }\n Modular& operator++() { return *this += 1; }\n Modular& operator--() { return *this -= 1; }\n Modular operator++(int) { Modular result(*this); *this += 1; return result; }\n Modular operator--(int) { Modular result(*this); *this -= 1; return result; }\n Modular operator-() const { return Modular(-value); }\n \n template \n typename enable_if::Type, int>::value, Modular>::type& operator*=(const Modular& rhs) {\n#ifdef _WIN32\n uint64_t x = static_cast(value) * static_cast(rhs.value);\n uint32_t xh = static_cast(x >> 32), xl = static_cast(x), d, m;\n asm(\n \"divl %4; \\n\\t\"\n : \"=a\" (d), \"=d\" (m)\n : \"d\" (xh), \"a\" (xl), \"r\" (mod())\n );\n value = m;\n#else\n value = normalize(static_cast(value) * static_cast(rhs.value));\n#endif\n return *this;\n }\n template \n typename enable_if::Type, int64_t>::value, Modular>::type& operator*=(const Modular& rhs) {\n int64_t q = static_cast(static_cast(value) * rhs.value / mod());\n value = normalize(value * rhs.value - q * mod());\n return *this;\n }\n template \n typename enable_if::Type>::value, Modular>::type& operator*=(const Modular& rhs) {\n value = normalize(value * rhs.value);\n return *this;\n }\n \n Modular& operator/=(const Modular& other) { return *this *= Modular(inverse(other.value, mod())); }\n \n template \n friend const Modular& abs(const Modular& v) { return v; }\n \n template \n friend bool operator==(const Modular& lhs, const Modular& rhs);\n \n template \n friend bool operator<(const Modular& lhs, const Modular& rhs);\n \n template \n friend std::istream& operator>>(std::istream& stream, Modular& number);\n \n private:\n Type value;\n};\n \ntemplate bool operator==(const Modular& lhs, const Modular& rhs) { return lhs.value == rhs.value; }\ntemplate bool operator==(const Modular& lhs, U rhs) { return lhs == Modular(rhs); }\ntemplate bool operator==(U lhs, const Modular& rhs) { return Modular(lhs) == rhs; }\n \ntemplate bool operator!=(const Modular& lhs, const Modular& rhs) { return !(lhs == rhs); }\ntemplate bool operator!=(const Modular& lhs, U rhs) { return !(lhs == rhs); }\ntemplate bool operator!=(U lhs, const Modular& rhs) { return !(lhs == rhs); }\n \ntemplate bool operator<(const Modular& lhs, const Modular& rhs) { return lhs.value < rhs.value; }\n \ntemplate Modular operator+(const Modular& lhs, const Modular& rhs) { return Modular(lhs) += rhs; }\ntemplate Modular operator+(const Modular& lhs, U rhs) { return Modular(lhs) += rhs; }\ntemplate Modular operator+(U lhs, const Modular& rhs) { return Modular(lhs) += rhs; }\n \ntemplate Modular operator-(const Modular& lhs, const Modular& rhs) { return Modular(lhs) -= rhs; }\ntemplate Modular operator-(const Modular& lhs, U rhs) { return Modular(lhs) -= rhs; }\ntemplate Modular operator-(U lhs, const Modular& rhs) { return Modular(lhs) -= rhs; }\n \ntemplate Modular operator*(const Modular& lhs, const Modular& rhs) { return Modular(lhs) *= rhs; }\ntemplate Modular operator*(const Modular& lhs, U rhs) { return Modular(lhs) *= rhs; }\ntemplate Modular operator*(U lhs, const Modular& rhs) { return Modular(lhs) *= rhs; }\n \ntemplate Modular operator/(const Modular& lhs, const Modular& rhs) { return Modular(lhs) /= rhs; }\ntemplate Modular operator/(const Modular& lhs, U rhs) { return Modular(lhs) /= rhs; }\ntemplate Modular operator/(U lhs, const Modular& rhs) { return Modular(lhs) /= rhs; }\n\ntemplate\nModular power(const Modular& a, const U& b) {\n assert(b >= 0);\n Modular x = a, res = 1;\n U p = b;\n while (p > 0) {\n if (p & 1) res *= x;\n x *= x;\n p >>= 1;\n }\n return res;\n}\ntemplate \nbool IsZero(const Modular& number) {\n return number() == 0;\n}\ntemplate \nstring to_string(const Modular& number) {\n return to_string(number());\n}\ntemplate \nstd::ostream& operator<<(std::ostream& stream, const Modular& number) {\n return stream << number();\n}\ntemplate \nstd::istream& operator>>(std::istream& stream, Modular& number) {\n typename common_type::Type, int64_t>::type x;\n stream >> x;\n number.value = Modular::normalize(x);\n return stream;\n}\nconstexpr int md = 1000000007;\nusing Mint = Modular::type, md>>;\n\nll modexp(ll x, ll ex) {\n ll ans = 1ll;\n while (ex > 0) {\n if (ex & 1ll) ans = (ans * x) % md;\n ex >>= 1ll;\n x = (x * x) % md;\n }\n return ans;\n}\n\nconst int inf = 1e9 + 7;\nconst int N = 2e5 + 7;\nMint dp[3];\n\nll mod = 1e9 + 7;\n\n\nint main(){\n PRELUDE;\n ll n , l , r , n0 , n1, n2;\n cin >> n >> l >> r;\n n0 = (r / 3) - (l / 3) + (l % 3 == 0);\n n1 = (r + 2)/3 - ((l + 2) / 3) + (l % 3 == 1);\n n2 = (r + 1)/3 - ((l + 1) / 3) + (l % 3 == 2); \n dp[0] = n0 ; dp[1] = n1; dp[2] = n2;\n for(ll i = 1; i < n; i++){\n Mint a = dp[0] * n0 + dp[1] * n2 + dp[2] * n1;\n Mint b = dp[0] * n1 + dp[1] * n0 + dp[2] * n2;\n Mint c = dp[0] * n2+ dp[1] * n1) + dp[2] * n0; \n dp[0] = a; dp[1] = b; dp[2] = c;\n }\n cout << dp[0] % mod << '\\n';\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "76a68bc6c129c49ecb7a47584346c502", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nlong long int n;\nif(n>2) {\n printf(\"25\");\n}\nreturn 0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "72d4c4f8e8087a96b55aaa6eef53ade6", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint checkChord(int a, int b, int c){\n int d1,d2,d3;\n d1 = b>a ? b-a : b+12-a;\n d2 = c>b ? c-b : c+12-b;\n d3 = a>c ? a-c : a+12-c;\n if(d1 == 4 && d2 == 3 && d3 ==7)\n return 1;\n else if(d1 == 3 && d2 == 4 && d3 ==7)\n return 2;\n else\n return 0;\n}\nint main(){\n char s[12] = {'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'B', 'H'};\n char x,y,z;\n int a,b,c;\n scanf(\"%c %c %c\",&x,&y,&z);\n for(int i=0;i<12;i++)\n if(x==s[i])\n a=i+1;\n else if(y==s[i])\n b=i+1;\n else if(z==s[i])\n c=i+1;\n int f = checkCord(a,b,c);\n int g = checkChord(b,c,a);\n int h = checkChord(c,a,b);\n if(f==1 || g==1 || h==1)\n printf(\"major\");\n else if(f==2 || g==2 || h==2)\n printf(\"minor\");\n else\n printf(\"strange\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ead8bf7e1b015cb1d2a3ac69e895bcd7", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n\nint main()\n{\n int m,n,last=-1,Max=0;\n cin>> n>>m;\n int a[n];\n\n\n for(int i=0 ;i>a[i];\n if(a[i]/m>0){\n if((a[i]/m)>Max &&i>last){\n Max=a[i]/m;\n last=i;\n\n }\n\n\n\n }\n if(last!=-1)\n cout<\n\nint main(){\n int x, y, z;\n cin>>x>>y>>z;\n if(z==0){\n if(x==y){\n cout<<\"0\"<y){\n cout<<\"+\"<x){\n cout<<\"-\"<=y+z){\n cout<<\"+\"<=x+z){\n cout<<\"-\"<\nusing namespace std;\nlong long T3,T1,T2,T[1000000001]={0,3,6,21,60,183,546,1641,4920,14763,44286,132861,398580,1195743,3587226,10761681,32285040,96855123,290565366,871696101,615088286,845264854,535794545,607383631,822150883,466452638,399357904,198073708,594221121,782663359,347990060,43970176,131910525,395731578,187194724,561584173,684752509,54257562,162772619,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650,464953388,488317650};\nint i,n,j;\nmain()\n{\n\tT1=0;\n\tT2=3;\n\tT3=1;\n\tcin>>n;\n\n\tif(n<1000){cout<\r\n#include\r\n#include\r\nusing namespace std;\r\nint main() {\r\n\tint n;\r\n\tcin >> n;\r\n\tdouble x = sqrt(n);\r\n\tif ((ceil)(x) == (floor)(x))\r\n\t\tcout << x << endl;\r\n\telse {\r\n\t\tcout << \"1\" << endl;\r\n\t}\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ff28d42d579a7d318a6a39ccbdf399bb", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n string s1;\n cin>>s1;\n int k=0;\n for(int i=0;i\n#include\n#include\n#define N 300\nusing namespace std;\n\nint n;\nint a[10];\n\nint p(){\n\tint x=a[0],y=a[1];\n\tdouble x=(1+sqrt(5.0))/2,y=(3+sqrt(5.0))/2;\n\tif(a>b)swap(a,b);\n\tint n=ceil(b/y);\n\tint big=n*y,sm=n*x;\n\tif(sm==a && big==b) return 1;\n\treturn 0;\nint main(){\n scanf(\"%d\",&n);\n for(int i=0;i\n#define ll long long\nusing namespace std;\nconst int mod = 1e9 + 7;\nll dp[2048][2048]={{1,1}};\nint main(int argc, char* argv[])\n{\n//ios_base::sync_with_stdio(0);\nll n,k,i,j,l,m;\n cin>>n>>m;\n for(k=1;k<=m;k++)\n for(i=1;i<=n;i++)\n for(j=i;j<=n;j+=i)\n dp[k][j]=(dp[k][j]+dp[k-1][i])%mod;\n ll sum=0;\n for(i=1;i<=n;i++)\n sum=(sum+dp[m][i])%mod;\n cout<\nusing namespace std;\nint main(){\n int i,n, l, old, temp, firstA, firstB, A[50], B[50];\n cin>>n;\n cin>>l;\n\n cin>>firstA;\n old = firstA;\n for(i = 1; i < n ; i++){\n cin>>temp;\n A[i-1] = temp - old;\n old = temp;\n }\n A[i-1] = (l-old) + firstA;\n\n cin>>firstB;\n old = firstB;\n for(i = 1; i < n ; i++){\n cin>>temp;\n B[i-1] = temp - old;\n old = temp;\n }\n B[i-1] = (l-old) + firstB;\n\n int j = 0, k = 0, c = 0;\n\n for(i = 0; i < n; i++){\n j=0\n k = i;\n c = 0;\n while(A[j] == B[k]){\n c++;\n j = (j + 1)%n;\n k = (k + 1)%n;\n if (c == n){\n cout<<\"YES\";\n return 0 ;\n }else if (c > n){\n break;\n }\n }\n }\n cout<<\"NO\";\n return 0;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c9ee2375dad86a04473d91eceb68643a", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n\n\n\nint n,k;\nint bs();\nint f(int v);\n\nint main(){\n\n\tint i,j,l;\n\n\tscanf(\"%d %d\",&n,&k);\n\n\tprintf(\"%d\\n\",bs());\n\n\treturn 0;\n}\nint bs(){\n\n\tint i,j,lo,hi,mid;\n\tint ret=n;\n\tint c=40;\n\tlo=0; hi=n; \n\twhile(c--&&lon) return 1;\n\tint n1,n2,i=1;\n\twhile(n1){\n\t\tn2=pow(k,i);\n\t\tn1=v/n2;\n\t\tif(n1==0) break;\n\t\tret+=n1; i++;\n\t}\n\tif(ret>=n) return 1;\n\treturn 0 ;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "714a9f8d81b2a9c9c12190a0f0ab612b", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \nusing namespace std;\nint t,n[10],a[10],b[10];\nvoid input()\n{\n cin>>t;\n for(int i=0;i>n[i];\n}\nint prime(int n)\n{\n for(int a=2;a<=sqrt(n);a++)\n {\n if(n%a==0)return(a);\n }\n return(n)\n}\nvoid solve()\n{\n for(int i=0;i\nusing namespace std;\nint main ()\n{\n long long n;\n for(;i*(i+1)<100000*2;i++)\n {\n h[i]=i*(i+1)/2;\n }\n while (cin>>n)\n {\n int h[100000];\n long long i=1;\n bool p=false;\n for(int j=1;j<=i;j++)\n for(int k=0;k<=i;k++)\n if(h[j]+h[k]==n)\n {\n p=true;goto amin;\n }\n amin:\n if(p)\n cout<<\"YES\"<\n#include \n\nusing namespace std;\n\n#define f(a) (1 << a)\n\nconst int turns[103] =\n{\n f(0),f(1),f(2),f(0)|f(1),f(1)|f(2),f(0)|f(1)|f(2),\n f(3),f(4),f(5),f(6),f(3)|f(4),f(4)|f(5),f(5)|f(6),f(3)|f(4)|f(5),f(4)|f(5)|f(6),f(3)|f(4)|f(5)|f(6),\n f(7),f(8),f(9),f(10),f(11),f(7)|f(8),f(8)|f(9),f(9)|f(10),f(10)|f(11),f(7)|f(8)|f(9),f(8)|f(9)|f(10),f(9)|f(10)|f(11),f(7)|f(8)|f(9)|f(10), f(8)|f(9)|f(10)|f(11), f(7)|f(8)|f(9)|f(10)|f(11),\n f(12),f(13),f(14),f(15),f(12)|f(13),f(13)|f(14),f(14)|f(15),f(12)|f(13)|f(14),f(13)|f(14)|f(15),f(12)|f(13)|f(14)|f(15),\n f(16),f(17),f(18),f(16)|f(17),f(17)|f(18),f(16)|f(17)|f(18),\n f(2)|f(6),f(6)|f(11),f(2)|f(6)|f(11),\n f(1)|f(5),f(5)|f(10),f(10)|f(15),f(1)|f(5)|f(10),f(5)|f(10)|f(15),f(1)|f(5)|f(10)|f(15),\n f(0)|f(4),f(4)|f(9),f(9)|f(14),f(14)|f(18),f(0)|f(4)|f(9),f(4)|f(9)|f(14),f(9)|f(14)|f(18),f(0)|f(4)|f(9)|f(14), f(4)|f(9)|f(14)|f(18), f(0)|f(4)|f(9)|f(14)|f(18),\n f(3)|f(8),f(8)|f(13),f(13)|f(17),f(3)|f(8)|f(13),f(8)|f(13)|f(17),f(3)|f(8)|f(13)|f(17),\n f(7)|f(12),f(12)|f(16),f(7)|f(12)|f(16),\n f(0)|f(3),f(3)|f(7),f(0)|f(3)|f(7),\n f(1)|f(4),f(4)|f(8),f(8)|f(12),f(1)|f(4)|f(8),f(4)|f(8)|f(12),f(1)|f(4)|f(8)|f(12),\n f(2)|f(5),f(5)|f(9),f(9)|f(13),f(13)|f(16),f(2)|f(5)|f(9),f(5)|f(9)|f(13),f(9)|f(13)|f(16),f(2)|f(5)|f(9)|f(13), f(5)|f(9)|f(13)|f(16), f(2)|f(5)|f(9)|f(13)|f(16),\n f(6)|f(10),f(10)|f(14),f(14)|f(17),f(6)|f(10)|f(14),f(10)|f(14)|f(17),f(6)|f(10)|f(14)|f(17),\n f(11)|f(15),f(15)|f(18),f(11)|f(15)|f(18)\n};\n\nint answer[f(20)];\n\nint dfs(int x)\n{\n if (answer[x] != 0) return answer[x];\n answer[x] = -1;\n for (int i = 0; i < 103; i++)\n if (turns[i] & x == turns[i] && dfs(x ^ turns[i]) == -1)\n answer[x] = 1;\n return answer[x];\n}\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n#endif\n memset(answer, 0, sizeof(answer));\n int start = 0;\n for (int i = 0; i < 19; i++)\n {\n string temp;\n cin >> temp;\n start <<= 1;\n if (temp == \"O\") start |= 1;\n }\n if (dfs(start) == 1) cout << \"Karlsson\";\n else cout << \"Lillebror\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "10f2cf0bc128f27df45285cd57658745", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\n#define max 100000010\nll prime[max];\nll v[max];\n\nvoid sieve(ll n)\n{\n ll i,j;\n\n prime[0]=1;\n prime[1]=1;\n\n for(i=4;i<=n;i+=2)\n prime[i]=1;\n\n for(i=3;i*i<=n;i+=2)\n {\n if(prime[i]==0)\n {\n for(j=i*i;j<=n;j+=2*i)\n {\n prime[j]=1;\n }\n }\n }\n\n i=0;\n\n for(j=0;j<=n;j++)\n {\n if(prime[j]==0)\n {\n v[i++] = j;\n }\n }\n}\n\nint main()\n{\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n\n ll n;\n\n cin >> n;\n\n sieve(n);\n\n if(prime[n]==0)\n {\n cout << 1 << endl;\n cout << n << endl;\n return 0;\n }\n\n vector x;\n x.push_back(2);\n n-=2;\n\n for(ll i=0;i\n\nusing namespace std;\n\nint main(){\n\n int l, w, h;\n\n cin >> l >> w >> h;\n\n int s1=1, s2=1, s3=1;\n\n s2=s1 = (int)sqrt(l);\n \n\n for (int i = 1; i < w; i++){\n if ((s1*i) == w){\n s3 = i; break;\n }\n }\n\n cout << (s1 + s2 + s3) * 4;\n\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8dc022a1b391e2be1c275d4c176ecb44", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\ntypedef long long ll;\nusing namespace std;\nint main()\n{\n ll a,b,c,d;\n cin>>a>>b>>c>>d;\n ll x[4];\n x[0]=a;\n x[1]=b;\n x[2]=c;\n sort(x,x+3);\n ll e=0,f=0,g;\n if(abs(a[0]-a[1])\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n# define M_PI 3.1415926535897932384626433832795 /* pi */\n\n\nusing namespace std;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair pi;\ntypedef queue qp;\ntypedef vector vp;\n\n\nint main()\n{\n std::ios::sync_with_stdio(false);\n cin.tie(nullptr);\n\n long long n;\n cin >> n;\n\n int am = 0;\n int m = 0;\n int maxn = sqrt(n);\n for (int i = 1; i < maxn; i++)\n {\n if ((n - 2 * i) % 3 == 0 && (n - 2 * i) / 3 >= m)\n am++;\n m += i;\n }\n\n cout << am << endl;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5325488914bdd26fb0a8fff22b7515c7", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \ntypedef long long int lli;\ntypedef unsigned long long int ulli;\n#define pb push_back\n#define vi vector \n#define vlli vector \n#define vchar vector \n#define vstr vector \n#define vb vector \n#define fst first\n#define sec second\n#define vpii vector >\n#define vpll vector >\n#define vvi vector >\n#define fr(i,n) for (int i = 0; i < (n); i++)\n#define run(c,s) for(auto c:s) \nusing namespace std;\nconst lli MOD = 1e9 + 7;\nint main()\n{\n int n,b,sum=0,all=0,ok = false;\n cin >> n >> b;\n vi ans;\n all=b;\n vpii a(n-1);\n fr(i,n){ \n cin >> a[i].fst;\n a[i].sec=i+1;\n all+=a[i].fst;\n }\n sort(a.begin(),a.end());\n fr(i,n){\n if(a[i]all/2){\n ok = true;\n break;\n }\n else break;\n }\n if(ok){\n cout << ans.size() << '\\n';\n fr(i,ans.size()) cout << ans[i];\n }\n else cout << 0;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aff5281d73038dbf5d5a54b1f84bbda0", "src_uid": "0a71fdaaf08c18396324ad762b7379d7", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n\n#define F(i,a,b) for(int i=a;i>s;\n\tF(i,0,n)if(s[i]=='0')st++;\n\tF(i,0,n)if(s[i]=='1')\n\t{\n\t\tans=1;\n\t\tbreak;\n\t}\n\tF(i,0,st)ans*=10;\n\t\n\tcout<\n\nusing namespace std;\n\ntypedef long long ll;\nconst int maxn = (int) 1e5 + 1;\n\n\nll n;\nint k = 1;\nint ok(){\n ll h = n;\n ll sum = 0, res = 0;\n while(h > 0){\n if(h >= k){\n h -= k;\n sum += k;\n }\n else{\n sum += h;\n h = 0;\n }\n if(h > 9){\n res += (h / 10);\n h -= (h / 10);\n }\n }\n if(sum >= res){\n return 1;\n }\n return 0;\n}\n\n\nint main(){\n cin >> n;\n int l = 1, r = n;\n while(r - l > 1){\n int mid = (l + r) / 2;\n if(ok(mid)){\n r = mid;\n }\n else {\n l = mid;\n }\n }\n if(ok(l)){\n cout << l;\n }\n else {\n cout << r;\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3c6df1a358588d9a7a822647b9bbcbec", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\nconst int MOD=1e9+7;\nint main() {\n cin.tie(0),cout.tie(0);\n ios::sync_with_stdio(false);\n string s,t;\n cin >> s;\n t=s;\n reverse(t.begin(),t.end());\n if(s!=t) {\n cout << s.size() << endl;\n }\n sort(t.begin(),t.end());\n else if(t[0]==t[t.size()-1]) {\n cout << 0 << endl;\n }\n else {\n cout << s.size()-1 << endl;\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e7ad00df1c869551b547428a11796d8b", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n// long long dp[51][51];\nstd::vector spilt(int l,int r,int a[],int m){\n\n\tstd::vector temp;\n\n\tint n=pow(2,r-l+1)-1;\n\n\tfor(int i=0;i<=n;i++){\n\t\tint ans=0;\n\t\tfor(int j=0;i>=(1<>n>>m;\n\tint a[n+1];\n\tfor(int i=0;i>a[i];\n\t}\n\n\tstd::vector v1=spilt(0,n/2,a,m);\n\tstd::vector v2=spilt(n/2+1,n-1,a,m);\n\n\nsort(v1.begin(), v1.end());\nsort(v2.begin(), v2.end());\n\nint ans=0;\n\nfor(auto i:v1){\n\n\tint x=lower_bound(v2.begin(),v2.end(),m-i-1)-v2.begin();\n\n\tif(x>=v2.size())||x<0){\n\t\tcontinue;\n\t}\n\telse{\n\t\tans=max(ans,(i+v2[x])%m);\n\t}\n}\ncout<\nusing namespace std;\nint main(){\nint n,k;\ncin>>n>>k;\nint a[n];\nint sum=0;\nfor(int i=0;i>a[i];\nsum+=a[i];\nm=min(sum,8);\nk-=m;\nsum-=m;\nif(k<=0){ cout<\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\ntypedef long long LL;\n\nconst LL num_up=1000000000000000000ll;\n\nLL ft[13]={2,3,5,7,11,13,17,19,23,29};\n\nconst int pow_up[13]={23,16,11,6,6,5,5,5,4,3};\n\nint n;\nLL res;\n\nvoid dfs(int deep,int cnt,LL num)\n{\n\tif(num>=num_up || num>=res) return;\n\tif(cnt>n || n%cnt) return;\n\tif(cnt==n)\n\t{\n\t\tres=num;\n\t\treturn;\n\t}\n\tif(deep==10)\n\t{\n\t\treturn;\n\t}\n\tLL i,j;\n//\tdouble pd=num;\n\tfor(i=0,j=1;;i++,j*=ft[deep],pd*=ft[deep])\n\t{\n\t//\tif(pd>=num_up) return;\n\t\tdfs(deep+1,cnt*(i+1),j*num);\n\t}\n}\n\nint main()\n{\n\tres=num_up;\n\tcin>>n;\n\tdfs(0,1,1);\n\tcout<\n\nusing namespace std;\nlong long x[26] , flag , ans;\nint main()\n{\n\tstring s ;\n\tcin >> s ;\n\tfor(int c = 0 ; c < s.size()-25 ; c++ )\n\t{\n\t\tstring s1 = s.substr(c,26);\n\t\tfor(int i = 0 ; i < 26 ; i++ )\n\t\t{\n\t\t\tif(s1[i]!='?'&&!x[s1[i]-'A'])\n\t\t\t\tx[s1[i]-'A']=1;\n\t\t\telse if(s1[i]!='?'&&x[s1[i]-'A'])\n\t\t\t\tflag = 1 ;\n\t\t}\n\t\tif(flag == 0)\n\t\t{\n\t\t\tfor(int i = 0 ; i < 26 ; i++ )\n\t\t\t\tif(s[i+c]=='?')\n\t\t\t\t{\n\t\t\t\t\tfor(int j = 0 ; j < 26 ; j++ )\n\t\t\t\t\t\tif(!x[j])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ts[i+c]=j+'A';\n\t\t\t\t\t\t\tx[j]=1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tans = 1 ;\n\t\t}\n\t\tflag =0;\n\t\tmemset(x,0,sizeof(x));\n\t}\n\tfor(int i = 0 ; i < s.size() ; i++ )\n\t\tif(s[i] == '?')\n\t\t\ts[i]='A';\n\tif(!ans)\n\t\t{cout << -1 << endl;\n\t\treturn 0;\n\t}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "332a54a6d24dd93acdf8232c4facce0d", "src_uid": "a249431a4b0b1ade652997fe0b82edf3", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\ntypedef long long ll;\n\nint n,m,g;\nint mod = 1e9 + 7;\n\nll fact[500009];\n\nll value[1000];\n\nll potencia(ll a, int pot)\n{\n if(pot < 3)\n return pow(a,pot);\n\n ll res = potencia(a,pot/2);\n\n res = ((res%mod)*(res%mod))%mod;\n if(pot % 2 == 1)\n res = (res*a)%mod;\n\n return res;\n}\n\nll nck(ll num, ll k)\n{\n if(num == 0)return num;\n if(k == 1)\n return num;\n\n ll div = (fact[num - k]*fact[k])%mod;\n ll res = (fact[num]*potencia(div,mod - 2))%mod;\n return res;\n}\n\nll cero()\n{\n ll comb = nck(n + m - 1,m - 1);\n for(int i = 2; i <= n; i += 2)\n {\n comb += nck(n + m - i - 1, m - 1);\n comb %= mod;\n }\n return comb;\n}\n\nll uno()\n{\n ll res = nck(n + m - 2, m - 1);\n for(int i = 2; i <= n; i++)\n {\n res += nck(n + m - 2 - i, m - 1);\n res %+ mod;\n }\n return res;\n}\n\nint main()\n{\n fact[0] = 1;\n fact[1] = 1;\n for(int i = 2; i < 500003; i++)\n fact[i] = (fact[i - 1]*i)%mod;\n cin >> n >> m >> g;\n\n if(n == 0)\n {\n if(g == 0)\n cout << 1 << endl;\n else\n cout << 0 << endl;\n return 0;\n }\n if(m == 0)\n {\n value[1] = n % 2;\n value[0] = 1 - value[0];\n cout << value[g] << endl;\n return 0;\n }\n\n if(g == 0)\n {\n if(n == 1 && m == 1)\n {\n cout << 2 << endl;\n return 0;\n }\n cout << cero() << endl;\n }\n else\n {\n cout << uno() << endl;\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "63950b6e2f74904c038dfa7d89618ba2", "src_uid": "066dd9e6091238edf2912a6af4d29e7f", "difficulty": 2100.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\n#define debug puts(\"here\")\n#define rep(i,n) for(int i=0;i>n>>m>>x>>y>>a>>b){\n\n int t = __gcd(a,b);\n a /= t;\n b /= t;\n\n int q = min( n/a,m/b );\n\n a *= q;\n b *= q;\n\n int lx = max(0,x-(a+1)/2);\n int ly = max(0,y-(b+1)/2);\n int rx = a+lx;\n int ry = b+ly;\n\n if(lx>rx)swap(lx,rx);\n if(ly>ry)swap(ly,ry);\n\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntemplate inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }\ntemplate inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }\n\nconstexpr long long MAX = 5100000;\nconstexpr long long INF = 1LL << 60;\nconstexpr int inf = 1 << 28;\nconstexpr long long mod = 1000000007LL;\n//constexpr long long mod = 998244353LL;\n\nusing namespace std;\ntypedef unsigned long long ull;\ntypedef long long ll;\n\n\nstruct Matrix {\n\tvector > val;\n\tMatrix(int n, int m, long long x = 0) : val(n, vector(m, x)) {}\n\tvoid init(int n, int m, long long x = 0) { val.assign(n, vector(m, x)); }\n\tsize_t size() const { return val.size(); }\n\tinline vector& operator [] (int i) { return val[i]; }\n};\n\nMatrix operator * (Matrix A, Matrix B) {\n\tMatrix R(A.size(), B[0].size());\n\tfor (int i = 0; i < A.size(); ++i)\n\t\tfor (int j = 0; j < B[0].size(); ++j)\n\t\t\tfor (int k = 0; k < B.size(); ++k)\n\t\t\t\tR[i][j] = (R[i][j] + A[i][k] * B[k][j] % MOD) % MOD;\n\treturn R;\n}\n\nMatrix modpow(Matrix A, long long n) {\n\tMatrix R(A.size(), A.size());\n\tfor (int i = 0; i < A.size(); ++i) R[i][i] = 1;\n\twhile (n > 0) {\n\t\tif (n & 1) R = R * A;\n\t\tA = A * A;\n\t\tn >>= 1;\n\t}\n\treturn R;\n}\n\nint main()\n{\n\t/*\n\tcin.tie(nullptr);\n\tios::sync_with_stdio(false);\n\t*/\n\tll N, M; scanf(\"%lld %lld\", &N, &M);\n\tif (N < M) {\n\t\tputs(\"1\");\n\t\treturn 0;\n\t}\n\tMatrix mat(M, M);\n\tMatrix ini(M, 1, 1);\n\tfor (ll i = 1; i < M; i++) {\n\t\tmat[i][i - 1] = 1;\n\t}\n\tmat[0][M - 1] = 1;\n\tmat[0][0] = 1;\n\tMatrix res = modpow(mat, N - M + 1) * ini;\n\tcout << res[0][0] << endl;\n\treturn 0;\n\t/*\n\t\t\u304a\u307e\u3058\u306a\u3044\u3092\u4f7f\u3063\u305f\u3089scanf\u3068printf\u95a2\u9023\u6ce8\u610f\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\n\t*/\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e82d3b6a8f50f702b60439713b0e472a", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "\u54c8\u54c8\u54c8\u54c8\u54c8", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0c8db284bd07586b2e2bcb8e905dda51", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nint color[300000];\nint n, m;\n\nint main() {\n\tios_base::sync_with_stdio(0);\n\tfor (int i = 0; i < 300000; i++) {\n\t\tcolor[i] = -1;\n\t}\n\tcin >> n >> m;\n\tfor (int i = 0; i < m; i++) {\n\t\tint v, to;\n\t\tcin >> v >> to;\n\t\tv--;\n\t\tto--;\n\t\tif (color[v] == -1 && color[to] == -1) {\n\t\t\tcolor[v] = 0;\n\t\t\tcolor[to] = 1;\n\t\t} else if (color[v] == -1) {\n\t\t\tcolor[v] = color[to] ^ 1;\n\t\t} else if (color[to] == -1) {\n\t\t\tcolor[to] = color[v] ^ 1;\n\t\t}\n\t}\n\tfor (int i = 0; i < n; i++) {\n\t\tcout << color[i] == -1 ? 0 : color[i];\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8a195b962037859cf1f7d362d0d34a06", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0} {"lang": "MS C++", "source_code": "\ufeff\n\n \n \n Debug\n Win32\n \n \n Release\n Win32\n \n \n \n {D91F86F8-0763-41BD-AEDC-D2F13CDFE70A}\n Win32Proj\n songsmix\n \n \n \n Application\n true\n v120\n Unicode\n \n \n Application\n false\n v120\n true\n Unicode\n \n \n \n \n \n \n \n \n \n \n \n \n true\n \n \n false\n \n \n \n \n \n Level3\n Disabled\n WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)\n true\n \n \n Console\n true\n \n \n \n \n Level3\n \n \n MaxSpeed\n true\n true\n WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)\n true\n \n \n Console\n true\n true\n true\n \n \n \n \n \n \n \n \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cc484104e905442b9a882c0c9545c39e", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\nint xMax,xMin,yMax,yMin,sum;\n\nint main(){\n int i,j,x1,y1,x2,y2,n;\n scanf(\"%d\",&n);\n xMin=yMin=50000;\n xMax=yMax=0;\n \n for(i=0;i\n#include\n#include\n\nusing namespace std;\n\nlong long xMax,xMin,yMax,yMin,sum;\n\nint main(){\n long long i,j,x1,y1,x2,y2,n;\n scanf(\"%I64d\",&n);\n xMin=yMin=50000;\n xMax=yMin=0;\n \n for(i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#pragma comment(linker, \"/STACK:200000000\")\n\ntypedef long long int64;\n\n#define forn(i, n) for(int i = 0; i < (int)(n); i++)\n#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)\n#define fore(i, a, n) for(int i = (int)(a); i < (int)(n); i++)\n#define pb push_back\n#define mp make_pair\n#define fs first\n#define sc second\n#define last(a) (int(a.size()) - 1)\n#define all(a) a.begin(), a.end()\n\nconst double EPS = 1E-9;\nconst int INF = 1000000000;\nconst int64 INF64 = (int64) 1E18;\nconst double PI = 3.1415926535897932384626433832795;\n\nconst int NMAX = 20000000;\n\nint n, m, k;\nint t[NMAX], l1[NMAX], r1[NMAX], l2[NMAX], r2[NMAX], w[NMAX], ans[NMAX], ans_id[NMAX];\npair md[NMAX];\n\nvoid md_update(int idx, int l, int r, int pos, pair val) {\n if (l == r) {\n md[idx] = max(md[idx], val);\n return;\n }\n\n int mid = (l + r) >> 1;\n if (pos <= mid) \n md_update(idx << 1, l, mid, pos, val);\n else\n md_update(idx << 1 | 1, mid + 1, r, pos, val);\n\n md[idx] = max(md[idx << 1], md[idx << 1 | 1]);\n}\n\npair md_max(int idx, int l, int r, int a, int b) {\n pair res(-INF, -INF);\n if (r < a || b < l)\n return res;\n if (a <= l && r <= b)\n return md[idx];\n\n int mid = (l + r) >> 1;\n res = max(res, md_max(idx << 1, l, mid, a, b));\n res = max(res, md_max(idx << 1 | 1, mid + 1, r, a, b));\n\n return res;\n}\n\nint main() {\n#ifdef RADs_project\n freopen(\"input.txt\", \"rt\", stdin);\n freopen(\"output.txt\", \"wt\", stdout);\n#endif\n \n cin >> n >> m;\n forn(i, n)\n scanf(\"%d%d\", &l1[i], &r1[i]);\n forn(i, m)\n scanf(\"%d%d%d\", &l2[i], &r2[i], &w[i]);\n\n forn(i, n) {\n t[k++] = l1[i];\n t[k++] = r1[i];\n }\n forn(i, m) {\n t[k++] = l2[i];\n t[k++] = r2[i];\n }\n\n sort(t, t + k);\n k = int(unique(t, t + k) - t);\n\n forn(i, n) {\n l1[i] = int(lower_bound(t, t + k, l1[i]) - t);\n r1[i] = int(lower_bound(t, t + k, r1[i]) - t);\n }\n forn(i, m) {\n l2[i] = int(lower_bound(t, t + k, l2[i]) - t);\n r2[i] = int(lower_bound(t, t + k, r2[i]) - t);\n }\n\n vector > > ev;\n forn(i, n) {\n ev.pb(mp(l1[i], mp(-1, i)));\n ev.pb(mp(r1[i], mp(2, i)));\n }\n forn(i, m) {\n ev.pb(mp(l2[i], mp(0, i)));\n ev.pb(mp(r2[i], mp(1, i)));\n }\n\n sort(all(ev));\n\n set > opl, opr;\n\n forn(i, ev.size()) {\n int tp = ev[i].sc.fs;\n int id = ev[i].sc.sc;\n\n if (tp == -1) {\n opr.insert(mp(-r1[id], id));\n opl.insert(mp(l1[id], id));\n continue;\n }\n if (tp == 2) {\n opr.erase(mp(-r1[id], id));\n opl.erase(mp(l1[id], id));\n md_update(1, 0, k - 1, l1[id], mp(t[r1[id]] - t[l1[id]], id));\n continue;\n }\n if (tp == 0) {\n if (opr.size()) {\n int cid = opr.begin()->sc;\n int clen = t[min(r1[cid], r2[id])] - t[l2[id]];\n if (clen > ans[id]) {\n ans[id] = clen;\n ans_id[id] = cid;\n }\n }\n continue;\n }\n\n if (opl.size()) {\n int cid = opl.begin()->sc;\n int clen = t[r2[id]] - t[max(l1[cid], l2[id])];\n if (clen > ans[id]) {\n ans[id] = clen;\n ans_id[id] = cid;\n }\n }\n\n pair ft = md_max(1, 0, k - 1, l2[id], r2[id]);\n if (ft > mp(ans[id], ans_id[id])) {\n ans[id] = ft.fs;\n ans_id[id] = ft.sc;\n }\n }\n\n int64 res = 0;\n int ans1, ans2;\n forn(i, m) {\n int64 c = ans[i] * int64(w[i]);\n if (c > res) {\n res = c;\n ans1 = ans_id[i];\n ans2 = i;\n }\n }\n\n cout << res << endl;\n if (res > 0)\n cout << ans1 + 1 << ' ' << ans2 + 1 << endl;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a9851c31c48f64511f9d2bfbb8904341", "src_uid": "af518bd91bddecb77772277341420fa2", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n\nbool check(int a1, int b2, int a2, int b2, int a3, int b3);\n\nint main()\n{\n\tint a1;\n\tint b1;\n\tint a2;\n\tint b2;\n\tint a3;\n\tint b3;\n\n\tstd::cin >> a1 >> b1;\n\tstd::cin >> a2 >> b2;\n\tstd::cin >> a3 >> b3;\n\n\tif (check(a1, b1, a2, b2, a3, b3) ||\n\t\tcheck(a1, b1, a2, a3, b2, b3) ||\n\t\tcheck(a1, b1, b3, b2, a3, a2) ||\n\t\tcheck(a1, b1, b3, a3, b2, a2)\n\t)\n\t\tstd::cout << \"YES\" << std::endl;\n\telse\n\t\tstd::cout << \"NO\" << std::endl;\n\n\treturn 0;\n}\n\nbool check(int a1, int b2, int a2, int b2, int a3, int b3)\n{\n\treturn a2 + a3 <= a1 && std::max(b2, b3) <= b1;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "394cc85bb77be0a7eefad2e2f2c31018", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nint main(){\n int n, m;\n cin >> n;\n vector > v(2, vector (3));\n for (int i = 0; i < 2; ++i){\n cin >> v[i][0];\n cin >> v[i][1];\n cin >> v[i][2];\n }\n m = v[0][0] - v[1][0] - v[1][2];\n for (int i = 1; i < 3; ++i){\n m = max(m, v[0][i] - v[1][i] - v[i - 1]);\n }\n cout << max << \" \";\n cout << min(v[0][0], v[1][0]) + min(v[0][1], v[1][1]) + min(v[0][2], v[1][2]);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d7d0a88021dcca9083f3b882763598c5", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:60777216\") \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define sz(a) int(a.size())\n#define all(a) (a).begin(), (a).end()\n#define CL(a, b) memset(a, b, sizeof a) \n#define FOR(i, a, b)\t\t\tfor (int i(a); i < (b); ++i)\n#define REP(i, n) FOR(i, 0, n)\n#define UN(a) sort(all(a)), (a).erase(unique(all(a)), (a).end())\n#define pb push_back\n#define SORT(a) sort(all(a))\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\n\ndouble xa,ya,xb,yb;\nint n;\ndouble x[11111],y[11111],a[11111],w[11111];\nint k;\n\nconst double pi = acos(-1.);\n\nbool check(double v,double a,double w){\n\tint num = 1000;\n\tREP(i,num+1){\n\t\tdouble x = xa + (xb-xa)*i/double(num);\n\t\tdouble y = ya + (yb-ya)*i/double(num);\n\t\tdouble q = atan2(y,x) - a;\n\n\t\tif(q>2*pi) q-=2*pi;\n\t\tif(q<0) q+=2*pi;\n\t\tif(q>2*pi-q) q = 2*pi - q;\n\t\tq/=w;\n\n\t\tif(hypot(x-xa,y-ya)/v >= q) return 1;\n\t}\n\n\n\treturn 0;\n}\n\nbool good(double s){\n\tint num = 0;\n\tREP(i,n){\n\t\txa-=x[i],ya-=y[i],xb-=x[i],yb-=y[i];\n\n\t\tif(check(s,a[i],w[i]))\n\t\t\tnum ++;\n\n\t\txa+=x[i],ya+=y[i],xb+=x[i],yb+=y[i];\n\t}\n\treturn num <= k;\n}\n\nint main() {\n#ifdef LocalHost\n\tfreopen(\"input.txt\", \"r\", stdin);\n#endif\n\n\tcin>>xa>>ya>>xb>>yb>>n;\n\tREP(i,n) scanf(\"%lf %lf %lf %lf\",x+i,y+i,a+i,w+i);\n\tcin>>k;\n\n\tdouble a = 0, b = 1e10, best = 1e10;\n\tREP(i,100){\n\t\tdouble s = (a+b)/2;\n\t\tif(good(s))\n\t\t\tbest = s, b = s;\n\t\telse a = s;\n\t}\n\tprintf(\"%.4lf\\n\",best);\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "96b9368e1afe9e2bc66c1a61636dae1c", "src_uid": "38c14ab8b9c5107c2a2f70a35f166d8b", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\n#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))\n#define csl ios_base::sync_with_stdio(false);cin.tie(NULL);\n\nconst int N = 1e5+5;\n\nint main()\n{\n csl;\n string s;\n int i;\n cin>>s;\n int x = s.length();\n string demo = \"abcdefghijklmnopqrstuvwxyz\";\n int k = 0;\n set st;\n for(i = 0;i < x;i++)\n {\n st.insert(s[i]);\n }\n int c = 0;\n for(i = 0;i < x;i++)\n {\n if(demo[k] == s[i] && (k<26))\n {\n k++;\n c++;\n }\n }\n \n if((c != st.size()))\n cout<<\"NO\";\n else\n cout<<\"YES\";\n \n\treturn 0;\n}#include\nusing namespace std;\n\n#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))\n#define csl ios_base::sync_with_stdio(false);cin.tie(NULL);\n\nconst int N = 1e5+5;\n\nint main()\n{\n csl;\n string s;\n int i;\n cin>>s;\n int x = s.length();\n string demo = \"abcdefghijklmnopqrstuvwxyz\";\n int k = 0;\n set st;\n for(i = 0;i < x;i++)\n {\n st.insert(s[i]);\n }\n int c = 0;\n for(i = 0;i < x;i++)\n {\n if(demo[k] == s[i] && (k<26))\n {\n k++;\n c++;\n }\n }\n \n if((c != st.size()))\n cout<<\"NO\";\n else\n cout<<\"YES\";\n \n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "43e88281a03d062e0528f9e0729fea85", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nconst int MAXN = 1e5+2;\nint dp[MAXN][MAXN];\n\nint comb(int n, int k){\n if(k==n||k==0) return 1;\n if(k>n) return 0;\n if(dp[n][k]>0) return dp[n][k];\n int ans = comb(n-1,k-1) + comb(n-1,k);\n return dp[n][k]=ans;\n}\n\nint func(int a,int b,int c,int l){\n int ans = 0;\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,a+l1-b-c);\n ans+= comb(k+2,2);\n }\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,b+l1-a-c);\n ans+= comb(k+2,2);\n }\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,c+l1-b-a);\n ans+= comb(k+2,2);\n }\n return ans;\n}\n\nint main() {\n int a,b,c,l;\n scanf(\"%d %d %d %d\",&a,&b,&c,&l);\n memset(dp, -1, (l+100)*(l+100)*sizeof(dp[0][0]));\n int total = comb(l+3,3);\n int ans = func(a,b,c,l);\n printf(\"%d\\n\",total - ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3fdffd64ca4f6d4024838b2ffa98eb83", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "// No114Div2.8cpp : \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0328\u04e6\ufffd\u00f3\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u06b5\u3863\n//\n\n#include \"stdafx.h\"\n#include \nusing namespace std;\n\n\nint main(){\n\tint ab,ch;\n\tcin>>ab>>ch;\n\tif(ab == 0)\n\t\tcout<<\"Impossible\"<= ch){\n\t\t\tmin = max = ab;\n\t\t}\n\t\telse{\n\t\t\tmin = ch;\n\t\t\tmax = ab + ch -1;\n\t\t}\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define sz(x) ((int)x.size())\n#define all(x) (x).begin(), (x).end()\n#define pb(x) push_back(x)\n#define mp(x, y) make_pair(x, y)\n\ntypedef long long int64;\n\nusing namespace std;\n\nconst int SQRT_MAXN = 100000;\nconst int S = 10000;\nbool nprime[SQRT_MAXN], bl[S];\nint primes[SQRT_MAXN], cnt;\n \nint main() {\n int l, r;\n cin >> l >> r;\n int n = 30000010;\n int nsqrt = (int) sqrt (n + .0);\n for (int i = 2; i <= nsqrt; ++i)\n if (!nprime[i]) {\n primes[cnt++] = i;\n for (int j = i + i; j <= nsqrt; j += i)\n nprime[j] = true;\n } \n int result = 0;\n for (int k = 0, maxk = n / S; k <= maxk; ++k) {\n memset (bl, 0, sizeof bl);\n int start = k * S;\n for (int i = 0; i < cnt; ++i)\n for (int j = max((start + primes[i] - 1) / primes[i], 2) * primes[i] - start; j < S; j += primes[i])\n bl[j] = true;\n if (k == 0)\n bl[0] = bl[1] = true;\n for (int i = 0; i < S && start + i <= n; ++i)\n if ((!bl[i]) && (start + i >= l) && (start + i <= r) && ((start + i) % 4 != 3))\n ++result;\n }\n cout << result;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2209352c5ebf4ce244e488175b9f2853", "src_uid": "55a83526c10126ac3a6e6e5154b120d0", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \nusing namespace std ;\nint main (){\nint sum,a[101],temp[101],n,answer[101],c=0;\n\ncin>>n;\nfor (int i=0;i>a[i];\n temp[i]=a[i];\n}\nfor (int i=n-1;i>0;i--)\n if(a[i]==a[i-1])\n c++;\n if(c==n-1)\n {\n for(int i=1;i<=n;i+=2)\n cout<\nusing namespace std;\n\n#define INF (LL)(0x3f3f3f3f)*(LL)0x3f3f3f3f\n#define MAXN 300005 \n\nlong long n,m;\nlong long a,b,x;\nlong long ans = 0;\nlong long an[MAXN];\nbool f[MAXN];\nqueueq;\n\nlong long gcd(long long x,long long y) {\n if(x%y != 0) return gcd(y,x%y);\n return y; \n} \n\nlong long orz(long long x) {\n return x*(x+1)>>1;\n}\n\nlong long sqz(long long x,long long mo)\n{\n if(x % mo == 0) return x/mo;\n else return x/mo+1;\n}\n\nlong long stOOrz(long long n) {\n return orz((n+1)/x)*x + ((n+1)%x)*(sqz(n+1,x));\n}\n\nlong long bfs(long long i)\n{\n long long ans = 0;\n f[0] = 1;\n while(!q.empty()) {\n long long x = q.front();\n q.pop();\n ans ++;\n if(x+a <= i && !f[x+a]) {\n f[x+a] = 1;\n q.push(x+a);\n }\n if(x-b >= 0 && !f[x-b]) {\n f[x-b] = 1;\n q.push(x-b); \n }\n }\n return ans;\n}\n\nsigned main()\n{\n cin >> n >> a >> b;\n\n q.push(0);\n an[0] = 1;\n f[0] = 1;\n bfs(0);\n for(long long i = 1; i <= max(a,b)*2; i ++) {\n if(i-a >= 0 &&f[i-a]) {\n f[i] = 1;\n q.push(i);\n an[i] = an[i-1]+bfs(i);\n } else {\n an[i] = an[i-1];\n }\n }\n\n x = gcd(a,b); \n if(a > b)\n swap(a,b);\n\n for(long long i = 0; i < min(n+1,2*b); i ++) { \n ans += an[i];\n }\n if(n >= 2*b)\n ans += stOOrz(n) - stOOrz(2*b-1); \n }\n cout<\n#define ff first\n#define ss second\n#define pb push_back\n#define mp make_pair\n#define ll long long\n#define all(a) a.begin(),a.end()\n#define endl '\\n'\n#define int ll\n\nusing namespace std;\n\nconst int N=3e5+3;\nconst int inf=1e9+3;\nconst int md=1e9+7;\n\nint bin(int a,int n)\n{\n int res=1;\n while(n)\n {\n if(n&1)\n res*=a;\n a*=a;\n res%=md;\n a%=md;\n n/=2;\n }\n return res;\n}\n\nunordered_map,int> kl;\n\nint f(int x,int y)\n{\n if(kl.count(mp(x,y)))return kl[mp(x,y)];\n int d;\n if(y%x!=0)return 0;\n d=y/x;\n\n if(d==1)return 1;\n\n int res=bin(2,d-1);\n res--;\n if(res<0)res+=md;\n\n int sq=sqrt(d);\n for(int j=2;j<=sq;++j)\n {\n if(d%j==0)\n {\n res-=f(j,d);\n if(res<0)res+=md;\n\n if(d/j!=j)\n res-=f(d/j,d);\n if(res<0)res+=md;\n }\n }\n\n return kl[mp(x,y)]=res;\n\n}\n\nint x,y;\n\nmain()\n{\n ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\n\n cin>>x>>y;\n\n cout< toint (mm))\n\t{\n\t\tcout << hh << \":\" << temp << endl;\n\t}\n\telse\n\t{\n\t\taddh(hh);\n\t\tif (!strcmp (hh,\"06\"))\n\t\t{\n\t\t\taddh(hh);\n\t\t}\n\t\tcout << hh << \":\" << hh[1] << hh[0] << endl;\n\t}\n\n\treturn 0;\n}\n\n \t \t \t\t \t \t\t \t\t\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "425f1fa5c345c7cc1b7ddc03cc6870ee", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "\u4e00\u9053\u633a\u6709\u610f\u601d\u7684\u6a21\u62df\u3002\n\n\n\n------------\n\u7b2c\u4e00\u773c\u770b\u5230\u672c\u9898\uff0c\u9996\u5148\u60f3\u5230\u7684\u662f\u6570\u5b66\u65b9\u6cd5\uff0c\u4e0d\u8fc7\u5948\u4f55\u672c\u4eba\u65e2\u6ca1\u8010\u5fc3\u4e5f\u4e0d\u64c5\u957f\uff0c\u6240\u4ee5\u76f4\u63a5\u8df3\u8fc7\uff0c\u6bd5\u7adf\u8ba1\u7b97\u673a\u5c31\u662f\u7528\u6765\u505a\u5927\u91cf\u8ba1\u7b97\u7684\uff0c\u8981\u6211\u4eec\u4eba\u6765\u627e\u89c4\u5f8b\u5e72\u561b\uff08~~\u5c31\u662f\u5f3a\u884c\u627e\u83dc\u7684\u7406\u7531~~\uff09\n\n\u5176\u5b9e\u8fd9\u9053\u9898\u7528\u6a21\u62df\u5199\u8fd8\u662f\u633a\u597d\u7684\uff0c\u80fd\u953b\u70bc\u5bf9\u7ec6\u8282\u7684\u628a\u63e1\u80fd\u529b\uff0c\u6b64\u9898\u5728\u67d0\u4e9b\u60c5\u51b5\u7684\u5904\u7406\u8fd8\u662f\u5f88\u8003\u9a8c\u7ec6\u8282\u7684\u3002\n\n\u5177\u4f53\u60c5\u51b5\u8bf7\u770b\u4ee3\u7801\u6ce8\u91ca\uff0c\u6a21\u62df\u9898\u4e0d\u597d\u5e72\u8bb2\uff08\u6211\u592a\u849f\u84bb\u4e86\uff09\n\n```\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint a,b,c,d,ans;\nint main()\n{\n\tscanf(\"%d%d%d%d\",&a,&b,&c,&d);\n\tint l=c,r=a-c,fx=1,hy=l,cs=0;\n //l\u8868\u793a\u4ece\u5de6\u8d70\u5230\u52a0\u6cb9\u7ad9\u6240\u9700\u8981\u7684\u8ddd\u79bb\n //r\u8868\u793a\u4ece\u53f3\u8d70\u5230\u52a0\u6cb9\u7ad9\u6240\u9700\u8981\u7684\u8ddd\u79bb\n //fx\u8868\u793a\u5f53\u524d\u65b9\u5411\uff0c1\u4e3a\u5411\u53f3\uff0c0\u4e3a\u5411\u5de6\n //hy\u8868\u793a\u5f53\u524d\u6c7d\u8f66\u7684\u6cb9\u8017\n //cs\u8868\u793a\u5df2\u7ecf\u8d70\u4e86\u591a\u5c11\u6765\u56de\n\tif(!a)\n\t{\n\t\tprintf(\"0\");\n\t}\n\tif(bb)\n\t\t\t{\n\t\t\t\tprintf(\"-1\");\n\t\t\t\treturn 0;\n\t\t\t}//\u5982\u679c\u8f66\u7684\u6cb9\u7bb1\u4e0d\u8db3\u4ee5\u8dd1\u5230\u53f3\u7aef\u518d\u56de\u6765\uff0cgg\n\t\t\tif(hy+2*r<=b)\n\t\t\t{\n\t\t\t\thy+=2*r;\n\t\t\t\tcs++;\n\t\t\t\tfx=0;\n\t\t\t}//\u80fd\u4e0d\u52a0\u6cb9\u8dd1\u56de\u6765\uff0c\u5c31\u589e\u52a0\u6cb9\u8017\uff0c\u66f4\u6539\u65b9\u5411\n\t\t\telse\n\t\t\t{\n\t\t\t\thy=0;\n\t\t\t\tans++;\n\t\t\t}//\u6cb9\u4e0d\u591f\u4e86\uff0c\u52a0\u6cb9\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(2*l>b)\n\t\t\t{\n\t\t\t\tprintf(\"-1\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif(hy+2*l<=b)\n\t\t\t{\n\t\t\t\thy+=2*l;\n\t\t\t\tcs++;\n\t\t\t\tfx=1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\thy=0;\n\t\t\t\tans++;\n\t\t\t}//\u5411\u5de6\u65f6\u7684\u60c5\u51b5\uff0c\u540c\u4e0a\u65b9\u5411\u53f3\n\t\t}\n\t}\n\tif(fx)//\u5224\u65ad\u6700\u540e\u534a\u7a0b\n\t{\n\t\tif(b\nusing namespace std;\nint hcf(long long int a,long long int b) {\n return b == 0 ? a : a > b ? hcf(b, a%b) : hcf(a, b%a); \n}\nint min(long long int a,long long int b)\n{\n\tif(a>n>>a>>b>>p>>q;\n\tlong long int ans=0;\n\tlong long int lcm=(a/(hcf(a,b))*b;\n\tlong int x=n/lcm;\n\tlong long int y=n/a;\n\tlong long int z=n/b;\n\tans=y*p+z*q-min(x*p,x*q);\n\tcout<\nusing namespace std;\n\nint f(long long n)\n{\nif (n == 0) return 0;\n long long u1 = 0, u2 = 0;\nint x = 0;\n while (u1 <= n) \n {\nx++;\n u1 *= 10;\n u1++;\n } \n u2 = u1/10;\nlong long a = n - u1, b = n - u2;\nif ( a < 0LL) a = - a;\nif (b <0LL) b = - b;\n return min( x + f(a), x - 1 + f(b) ;\n//else return x - 1 + f(b\n} \nint main() {\n long long n;\n cin >> n;\ncout<\n#include \n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define X first\n#define Y second\n#define pb push_back\n#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))\n#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))\n#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))\n#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))\n#define peat(X,Y) for (;(X) < (Y);++(X))\n#define all(X) (X).begin(),(X).end()\n#define rall(X) (X).rbegin(),(X).rend()\n#define eb emplace_back\n#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())\n#define Endl endl\n\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntemplate using vv=vector>;\ntemplate ostream& operator<<(ostream &os, const vector &t) {\nos<<\"{\"; rep(i,t.size()) {os< ostream& operator<<(ostream &os, const pair &t) { return os<<\"(\"< inline bool MX(T &l,const T &r){return l inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}\n#define out(args...){vector a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }\nvector s_p_l_i_t(const string& s, char c) { vector v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}\nvoid e_r_r(vector::iterator it) {}\ntemplate void e_r_r(vector::iterator it, T a, Args... args){ if(*it==\" 1\"||*it==\"1\") cerr< substr((*it)[0] == ' ', it -> length()) << \" = \" << a << \", \"; e_r_r(++it, args...);}\nconst ll MOD=1e9+7;\n\nll dp[99][1<<20];\nll sum[99][1<<20];\n\nint main(){\n ios_base::sync_with_stdio(false);\n cout< v;\n // reps(i,1,10){\n // rep(j,1<<(i-1)){\n // v.pb(i);\n // if(accumulate(all(v),0)>75) break;\n // }\n // if(accumulate(all(v),0)>75) break;\n // }\n // cout<>n>>s;\n dp[0][0]=1;\n ll re=0;\n rep(i,n){\n (dp[i+1][0]+=1)%=MOD;\n //for(int j=2;j<=(1<<20);j*=2) (re+=dp[i][j-1])%=MOD;\n //for(int j=2;j<=(1<<20);j*=2) if(dp[i][j-1])out(i,j-1,dp[i][j-1],1);\n if(i&&s[i]=='0'){\n rep(k,1<<20) (sum[i+1][k]+=dp[i][k]+sum[i][k])%=MOD;\n }else{\n int val=0;\n reps(j,i,n){\n\t(val*=2)+=s[j]-'0';\n\tif(val>20) break;\n\trep(k,1<<20) (dp[j+1][k|(1<<(val-1))]+=dp[i][k]+sum[i][k])%=MOD;\n }\n }\n }\n //rep(i,n+1){rep(j,8) cout<\n#include\n#include\n#include\n#include\nusing namespace std;\nint n;\nchar s[5005];\nint a[5005];\nint b[5005];\nint c[200];\nint d[5005];\nint num,sum;\nint ch(int x)\n{\n int now=0;\n for(int i=0;ix)\n {\n return 0;\n }\n }\n// cout<c[0])\n {\n printf(\"NO\\n\");\n continue;\n }\n// cout<c[i])\n {\n printf(\"NO\\n\");\n break;\n }\n else\n {\n if(ch(c[i])==1)\n {\n printf(\"YES\\n\");\n break;\n }\n }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "26dbe2324f7bdde170549da0d6b68186", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n\nstatic constexpr int kMaxHp = 5000;\nstatic int a[(kMaxHp + 1) * (kMaxHp + 1)] = {};\nstatic size_t stamps[(kMaxHp + 1) * (kMaxHp + 1)] = {};\n\nint main() {\n int p1, p2;\n std::size_t t1, t2;\n int h, s;\n\n std::cin >> p1 >> t1 >> p2 >> t2 >> h >> s;\n\n std::unordered_set stamps_set;\n for (int n = 0; n <= h; n++) {\n for (int m = 0; m <= h; m++) {\n stamps_set.insert(n * t1 + m * t2);\n }\n }\n\n size_t stamps_num = 0;\n for (auto& s : stamps_set) {\n stamps[stamps_num++] = s;\n }\n std::sort(stamps, stamps + stamps_num);\n const int stride = h + 1;\n\n // for (int i = 0; i < stride * stride; i++) {\n // std::cout << stamps[i] << \" \";\n // }\n // std::cout << std::endl;\n\n size_t best_t = std::numeric_limits::max();\n for (int n = 0; n < stamps_num; n++) {\n const size_t stamp1 = stamps[n];\n if (stamp1 >= best_t) {\n continue;\n }\n for (int m = 0; m < stamps_num; m++) {\n const size_t stamp2 = stamps[m];\n if (stamp2 >= best_t) {\n continue;\n }\n const int idx = n * stamps_num + m;\n if (n == 0 && m == 0) {\n continue;\n }\n\n if (stamp1 >= t1) {\n for (int i = n - 1; i >= 0; i--) {\n size_t prev_stamp = stamps[i];\n\n if (prev_stamp + 2 * t1 < stamp1) {\n break;\n }\n\n if (prev_stamp + t1 > stamp1) {\n continue;\n }\n\n a[idx] = std::max(a[idx], a[i * stamps_num + m] + p1 - s);\n }\n }\n\n if (stamp2 >= t2) {\n for (int i = m - 1; i >= 0; i--) {\n size_t prev_stamp = stamps[i];\n\n if (prev_stamp + 2 * t2 < stamp2) {\n break;\n }\n\n if (prev_stamp + t2 > stamp2) {\n continue;\n }\n\n a[idx] = std::max(a[idx], a[n * stamps_num + i] + p2 - s);\n }\n }\n\n if (stamp2 == stamp1 && stamp2 >= t2 && stamp1 >= t1) {\n a[idx] += s;\n }\n\n size_t t = std::max(stamp1, stamp2);\n if (a[idx] >= h && best_t > t) {\n best_t = t;\n //std::cout << n << \" \" << m << std::endl;\n }\n // std::cout << stamp1 << \", \" << stamp2 << \": \" << a[idx] << std::endl;\n }\n //std::cout << std::endl;\n }\n\n std::cout << best_t << std::endl;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "81a105113ef381f75b9afffa311318fb", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "// In the name of GOD\n#include \n\nusing namespace std;\n\ntypedef long long int ll;\n//#define int ll\nint a, b, ta, tb, c, x, y, t;\nchar ch;\nint f(int x) {\n\tif(x <= 0)return 0;\n\tx += 5*60;\n\tif(x >= 23*60+59) {\n\t\tx = 23*60+59;\n\t}\n\tx -= 5*60;\n\treturn x;\n}\nmain() {\n\tcin>>a>>ta>>b>>tb;\n\tfor(int i = 0; i < 2; i++){\n\t\tcin>>ch;\n\t\tx *= 10;x += ch-'0';\n\t}\n\tcin>>ch;\n\n\tfor(int i = 0; i < 2; i++){\n\t\tcin>>ch;\n\t\ty *= 10;y += ch-'0';\n\t}\n\tt = x*60+y;\n\tt -= 5*60;\n for(int i = 0; i < 19*60; i++) {\n\t\tif(i % b ==0) {\n\t\t if((i <= t && i+tb = t) || (i >= t && i < t+ta)) c++\n\t\t}\n }\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define INF (1<<29)\n#define rep(i,n) for(int i=0;i<(n);i++)\nusing namespace std;\n\n\nint next[100];\nint match[100];\nint b,d;\nstring a,c;\n\nvoid init(){\n rep(i,c.size()){\n int s=i,t=0;\n rep(j,a.size()){\n if(c[s]==a[j])s++;\n if(s==c.size()){\n s=0;\n t++;\n }\n }\n next[i]=s;\n match[i]=t;\n }\n}\nint main(){\n cin>>b>>d>>a>>c;\n init();\n int m=0,cur=0;\n rep(i,b){\n m += match[cur];\n cur = next[cur];\n }\n cout<\n#include\n#include\n#include\nusing namespace std;\nstring str,answer,keyboard[10]={\n\t{\n\t\t\"\\0\\0\\0\\0\"\n\t},\n\t{\n\t\t\" qwertyuiop\"\n\t},\n\t{\n\t\t\" asdfghjkl;\"\n\t},\n\t{\n\t\t\" zxcvbnm,./\"\n\t}\n};\nbool way,flag;\nchar ch;\nint main(){\n\tios::sync_with_stdio(false);\n\tcin>>ch;\n\tcin>>str;\n\tswitch(ch){\n\t\tcase 'L' : way=true;\n\t\tbreak;\n\t\tcase 'R' : way=false;\n\t\tbreak;\n\t}\n\tfor(int i=0;i\n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long li;\ntypedef long double ld;\ntypedef pair pt;\ntypedef pair ptd;\ntypedef unsigned long long uli;\n\n#define pb push_back\n#define mp make_pair\n#define mset(a, val) memset(a, val, sizeof (a))\n#define all(a) (a).begin(), (a).end()\n#define rall(a) (a).rbegin(), (a).rend()\n#define ft first\n#define sc second\n#define sz(a) int((a).size())\n#define x first\n#define y second\n\ntemplate inline X abs(const X& a) { return (a < 0 ? -a : a); }\ntemplate inline X sqr(const X& a) { return (a * a); }\ntemplate inline string toStr(T x) { stringstream st; st << x; string s; st >> s; return s; }\ntemplate inline int hasBit(T mask, int b) { return (b >= 0 && (mask & (T(1) << b)) != 0) ? 1 : 0; }\ntemplateinline ostream& operator<< (ostream& out, const pair& p) { return out << '(' << p.ft << \", \" << p.sc << ')'; }\n\ninline int nextInt() { int x; if (scanf(\"%d\", &x) != 1) throw; return x; }\ninline li nextInt64() { li x; if (scanf(\"%I64d\", &x) != 1) throw; return x; }\ninline double nextDouble() { double x; if (scanf(\"%lf\", &x) != 1) throw; return x; }\n\n#define forn(i, n) for(int i = 0; i < int(n); i++)\n#define fore(i, a, b) for(int i = int(a); i <= int(b); i++)\n#define ford(i, n) for(int i = int(n - 1); i >= 0; i--)\n#define foreach(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)\n\nconst int INF = int(1e9);\nconst li INF64 = li(INF) * li(INF);\nconst ld EPS = 1e-9;\nconst ld PI = ld(3.1415926535897932384626433832795);\n\nli x;\nint k;\nint pl;\n\n\nconst int N = 402;\nconst int MAGIC = 9;\n\n\nld d[2][(1 << MAGIC)][2][N];\n/// iss problem ka author m*dharc*od hai , sala bhosriwala kutta \n\n \ninline void solve() { \n\tld p = ld(pl) / 100;\n\n\tint SPMASK = (1 << MAGIC) - 1;\n\n\tli pmask = x & li(SPMASK);\n li plast = (x & li(1 << MAGIC)) > 0;\n li pcnt = 0;\n \n x >>= MAGIC;\n \n if (x == 0)\n \t\tpcnt = 200;\n else {\n \twhile (true) {\n \t \tint bit = x & 1ll;\n\n \t \tif (bit == plast)\n \t \t\tpcnt++;\n \t \telse\n \t \t\tbreak;\n\n \t \tx >>= 1;\n \t}\n }\n\n d[0][pmask][plast][pcnt] = 1.0;\n \t\n \n forn(it, k) {\n\t\tint i = it & 1;\n\t\tint nxt = i ^ 1;\n\n\t\tforn(mask, (1 << MAGIC)) {\n\t\t \tforn(last, 2) {\n\t\t \t \tforn(cnt, N) {\n\t\t \t \t \td[nxt][mask][last][cnt] = 0.0;\n\t\t \t \t}\n\t\t \t}\n\t\t}\n\n\t \tforn(mask, (1 << MAGIC)) {\n\t\t\tforn(last, 2) {\n\t\t\t\tforn(cnt, N) {\n\t\t\t\t\tld dv = d[i][mask][last][cnt];\n\n\t\t\t\t\t//doubling\n \t{\n \t\tint nmask = (mask << 1) & SPMASK;\n \t\tint nlast = (mask & (1 << (MAGIC - 1))) > 0;\n \t\tint ncnt = cnt;\n\n \t\tif (last == nlast)\n \t\t\tncnt++;\n \t\telse\n \t\t\tncnt = 1;\n \t\n d[nxt][nmask][nlast][ncnt] += dv * p;\n\n }\n\n //adding\n {\n \tint nmask = mask + 1;\n\n \tif (nmask != (1 << MAGIC)) {\n \t\td[nxt][nmask][last][cnt] += dv * (1.0 - p);\n \t} else {\n \t\tif (last == 1)\n \t\t\td[nxt][0][0][cnt] += dv * (1.0 - p);\n \t\telse\n \t\t\td[nxt][0][1][1] += dv * (1.0 - p);\n }\n }\n }\t\n\t\t\t}\n\t \t}\n\t} \n\n\tld answer = 0;\n\n\tk = k & 1;\n\n\tforn(nmask, (1 << MAGIC)){\n\t \tforn(last, 2) {\n\t \t \tforn(cnt, N) {\n\t \t \t\tint counter = 0;\n\n\t \t \t\tint mask = nmask;\n\n\t \t \t\tif (mask != 0) {\n\t \t \t\t\n\t \t \t\t\twhile (mask % 2 == 0)\n\t \t \t\t\t\tcounter += 1, mask /= 2;\n\t \t \t\t\t\t\t\n\t \t \t\t} else {\n\t \t \t\t\tcounter = MAGIC;\n\t \t \t\t\tif (last == 0)\n\t \t \t\t\t\tcounter += cnt;\n\t \t \t\t}\t\n\t \t \t\t\n\t \t \t\tld dv = d[k][nmask][last][cnt];\n\n\t \t \t\tanswer += ld(counter) * ld(d[k][nmask][last][cnt]);\n\t \t \t}\n\t \t}\n\t}\n\n\tcout << fixed << setprecision(13) << answer << endl;\n}\n\nint main() \n{\n\n#ifdef gridnevvvit\n\tfreopen(\"input.txt\", \"rt\", stdin);\n\tfreopen(\"output.txt\", \"wt\", stdout);\n#endif\n \n\tsrand(time(NULL));\n cin >> x >> k >> pl;\n\tcout << setprecision(10) << fixed;\n\tcerr << setprecision(5) << fixed;\n\t\n\tassert(read());\n\tsolve();\n\n#ifdef gridnevvvit\n\tcerr << \"===Time: \" << clock() << \"===\" << endl;\n#endif\n\n} ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d2368c9e6bf8af23967428f614f09527", "src_uid": "c9274249c26b1a85c19ab70d91c1c3e0", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef int ll;\nbool IsPrime(ll n){\n if(n < 2) return 0;\n for(ll i=2; i<=sqrt(n); i++) if(n%i==0) return 0;\n return 1;\n}\nmain(){\n ll n;\n cin>>n;\n if(n==1){\n cout<<;\n return 0;\n }\n for(ll i=1; i<=n; i++){\n if(!IsPrime(n*i+1)){\n cout<\n#include\nusing namespace std;\n\nint get_dig(long long x)\n{\n long long powr = 10;\n int dig = 1;\n while (powr> n >> k;\n if (n<=10)\n {\n cout << stoi(k,nullptr,n);\n }\n long long powr = 10;\n while (powr < n) powr*=10;\n int dig = get_dig(n);\n vector rep;\n int i = k.length() - dig;\n long long m;\n int length = 0;\n while (i + dig >0)\n {\n if (i<0) m = stoi(k.substr(0,dig+i));\n else m = stoi(k.substr(i,dig));\n if (m==0 || m==1)\n {\n rep.push_back(m);\n i--;\n }\n else if (m=0; i--)\n {\n ans*=n;\n ans+=rep[i];\n }\n cout << ans;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "77720a64ced9960312c866e6c198d99c", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "const int maxn = 1e5 + 10;\nll quickmod(ll a, ll b) {\n ll ans = 1;\n while (b) {\n if (b & 1) ans = ans * a % mod;\n b >>= 1;\n a = a * a % mod; \n }\n return ans;\n}\nstruct Point {\n int x, y, id;\n} p[maxn];\ninline bool cmp1(const Point& a, const Point& b) {\n return a.x < b.x || (a.x == b.x && a.y < b.y);\n}\ninline bool cmp2(const Point& a, const Point& b) {\n return a.y < b.y || (a.y == b.y && a.x < b.x);\n}\ninline bool cmp3(const Point& a, const Point& b) {\n return a.id < b.id;\n}\nint pa[maxn], dif[maxn];\nbool tag[maxn];\nint find(int x) {\n if (x == pa[x]) return x;\n return pa[x] = find(pa[x]);\n}\nstruct Edge {\n int to, next;\n} E[maxn << 2];\nint head[maxn], cnt;\ninline void addedge(int u, int v) {\n E[cnt].to = v;\n E[cnt].next = head[u];\n head[u] = cnt++;\n}\nset x[maxn], y[maxn];\ninline void solve() {\n int n;\n scanf(\"%d\", &n);\n cnt = 0;\n memset(head, -1,sizeof head);\n memset(tag, 0, sizeof tag);\n memset(dif, 0, sizeof dif);\n rep(i, 1, n + 1) {\n pa[i] = p[i].id = i;\n scanf(\"%d%d\", &p[i].x, &p[i].y);\n }\n sort(p + 1, p + n + 1, cmp1);\n rep(i, 1, n) {\n if (p[i].x == p[i + 1].x) {\n addedge(p[i].id, p[i + 1].id);\n }\n }\n sort(p + 1, p + n + 1, cmp2);\n rep(i, 1, n) {\n if (p[i].y == p[i + 1].y) {\n addedge(p[i].id, p[i + 1].id);\n }\n }\n sort(p + 1, p + n + 1, cmp3);\n rep(u, 1, n + 1) {\n int fu = find(u);\n for (int i = head[u]; ~i; i = E[i].next) {\n int v = E[i].to;\n int fv = find(v);\n if (fu == fv) tag[fu] = 1;\n else {\n pa[fv] = fu;\n tag[fu] |= tag[fv];\n }\n }\n }\n rep(u, 1, n + 1) {\n int fa = find(u);\n int sx = p[u].x, sy = p[u].y;\n if (x[fa].find(sx) == x[fa].end()) {\n dif[fa]++;\n x[fa].insert(sx);\n }\n if (y[fa].find(sy) == y[fa].end()) {\n dif[fa]++;\n y[fa].insert(sy);\n }\n } \n ll ans = 1;\n rep(u, 1, n + 1) {\n if (u == find(u)) {\n ll res = quickmod(2LL, 1LL * dif[u]);\n if (!tag[u]) --res;\n ans = ans * res % mod;\n }\n }\n printf(\"%lld\\n\", ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "212f646c5366f316b78e6a3a49dbcca7", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define LL long long int\n#define PII pair\n#define PB push_back\n#define MP make_pair\n#define INF 1000000000\n#define debug(args...) do {cerr << #args << \": \"; dbg,args; cerr << endl;} while(0)\n\nmap mp;\nint deg[200000];\nint main(){\n int n,m,i,x,y,cn,cn2;\n srand(time(NULL));\n scanf(\"%d %d\",&n,&m);\n vector v;\n for(i=0;i\nusing namespace std;\nmain()\n{ string s;\n vectorv;\n \n for(int i=0;i<4;i++)\n {\n cin>>s;\n v.push_back(s);\n \n }\n for(int i=0;i<4;i++)\n { int sum=0;\n vectort;\n for(int j=0;j<4;j++)\n {\n if(v[i][j]=='*')\n {sum++;\n t.push_back(j);\n \n }\n if(t.size()>=2)\n int k=abs(t[0]-t[1]);\n if(sum>=3)\n cout<<\"YES\";\n else if(sum==2 && k==1 && t.size()>=2)\n cout<<\"YES\";\n \n }\n \n \n cout<<\"NO\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8852aa304d836817c226624dee0b502c", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nint main() {\n\t// your code goes here\n\tint i,j,k=0,a[4][4];\n\tfor(i=0;i<4;i++)\n\t{\n\t for(j=0;j<4;j++)\n\t {\n\t cin>>a[i][j];\n\t }\n\t}\n\t for(i=1;i<3;i++)\n\t {\n\t if(a[i][3]==1)\n\t {\n\t if(a[i][0]==1 || a[i][1]==1 || a[i][2]==1){\n\t cout<<\"YES\";\n\t k++;}\n\t else if(a[i+1][0]==1 || a[i-1][2]==1){\n\t cout<<\"YES\";\n\t k++;}\n\t }\n\t }\n\t for(i=0;i<1;i++)\n\t {\n\t if(a[i][3]==1)\n\t {\n\t if(a[i][0]==1 || a[i][1]==1 || a[i][2]==1){\n\t cout<<\"YES\";\n\t k++;}\n\t else if(a[1][0]==1 || a[4][2]==1){\n\t cout<<\"YES\";\n\t k++;}\n\t }\n\t }\n\t for(i=3;i<4;i++)\n\t {\n\t if(a[i][3]==1)\n\t {\n\t if(a[i][0]==1 || a[i][1]==1 || a[i][2]==1){\n\t cout<<\"YES\";\n\t k++;}\n\t else if(a[0][0]==1 || a[2][2]==1){\n\t cout<<\"YES\";\n\t k++;}\n\t }\n\t }\n\t}\n\tif (k==0)\n\tcout<<\"NO\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f6417ec363c970432cf89de6b3172d9f", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#define eps 1e-8\n#define maxn 100005\nusing namespace std;\nint main()\n{\n int n,m;\n int a[10005],b[10005];\n cin>>n>>m\n memset(a,0,sizeof(a));\n memset(b,0,sizeof(b));\n for(int i=0;i>a[i];\n b[a[i]]++;\n }\n for(int i=m;i>0;i--)\n {\n int ans=0;\n for(int j=1;j<=100;j++)\n ans+=b[j]/i;\n if(ans>n)\n {\n cout<\n#include\n#include\n#include\n#include\n#include\n#define rep(i,a,b) for(int i=a;i<=b;i++)\n#define dep(i,a,b) for(int i=a;i>=b;i--)\n#define ll long long\n#define mem(x,num) memset(x,num,sizeof x)\nusing namespace std;\ninline int read()\n{\n int f=1,x=0;char ch=getchar();\n while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}\n while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}\n return x*f;\n}\nint n,ans=0,t;\n\nint main()\n{\n n=read();\n if(n==2)ans=1;\n if(n==3)ans=3;\n if(n==4)ans=6; \n if(n>=5&&n<=49){t=(n-4)/10;rep(i,1,t)ans+=(i*10-1);rep(i,5+t*10,n){ans+=(t+1);if(i%10==9)ans--;}}\n if(n>=50&&n<=499){t=(n-49)/100;rep(i,1,t)ans+=(i*100-1);rep(i,50+t*100,n){ans+=(t+1);if(i%100==99)ans--;}}\n if(n>=500&&n<=4999){t=(n-499)/1000;rep(i,1,t)ans+=(i*1000-1);rep(i,500+t*1000,n){ans+=(t+1);if(i%1000==999)ans--;}}\n if(n>=5000&&n<=49999){t=(n-4999)/10000;rep(i,1,t)ans+=(i*10000-1);rep(i,5000+t*10000,n){ans+=(t+1);if(i%10000==9999)ans--;}}\n if(n>=50000&&n<=499999){t=(n-49999)/100000;rep(i,1,t)ans+=(i*100000-1);rep(i,50000+t*100000,n){ans+=(t+1);if(i%100000==99999)ans--;}}\n if(n>=500000&&n<=4999999){t=(n-499999)/1000000;rep(i,1,t)ans+=(i*1000000-1);rep(i,500000+t*1000000,n){ans+=(t+1);if(i%1000000==999999)ans--;}}\n if(n>=5000000&&n<=49999999){t=(n-4999999)/10000000;rep(i,1,t)ans+=(i*10000000-1);rep(i,5000000+t*10000000,n){ans+=(t+1);if(i%10000000==9999999)ans--;}}\n if(n>=50000000&&n<=499999999){t=(n-49999999)/100000000;rep(i,1,t)ans+=(i*100000000-1);rep(i,50000000+t*100000000,n){ans+=(t+1);if(i%100000000==99999999)ans--;}}\n if(n>=500000000&&n<=4999999999){t=(n-499999999)/1000000000;rep(i,1,t)ans+=(i*1000000000-1);rep(i,500000000+t*1000000000,n){ans+=(t+1);if(i%1000000000==999999999)ans--;}}\n cout<\n#include\n#define SIZE 33\nusing namespace std;\nint convertBinary(bool* _binary, int L) {\n\t//L\uc744 \uc774\uc9c4\ubc95\uc73c\ub85c \ubcc0\ud658\n\tint cnt = 0;\n\twhile (L > 0)//\ub9e8\uc55e\uc774 2^0\n\t{\n\t\t_binary[cnt] = L % 2;\n\t\tL /= 2;\n\t\tcnt++;\n\t}\n\treturn cnt;\n}\n\nint main() {\n\tlong long L,ans = 0;\n\tint n;\n\tlong long *cost;\n\tbool binary[SIZE];\n\tcin >> n >> L;\n\tcost = new long long[n];\n\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> cost[i];\n\t}\n\n\tfor (int i = 0; i < n; i++) {//\uc704\ub85c \uc62c\ub77c\uac00\uba74\uc11c \uac80\uc0ac\n\t\tcost[i + 1] = min(cost[i + 1], 2 * cost[i]);\n\n\t}\n\t////\ucd9c\ub825\uac12 \ud655\uc778\n\t//for (int i = 0; i < n; i++) {\n\t//\tcout << cost[i] << endl;\n\t//}\n\n\tint min = cost[n - 1];\n\tfor (int i = n - 2; i >= 0; i--) {//\uc544\ub798\ub85c \ub0b4\ub824\uc624\uba74\uc11c \uac80\uc0ac\n\t\tif (cost[i] < min) {\n\t\t\tmin = cost[i];\n\t\t}\n\t\telse {//cost[i]>min\n\t\t\tcost[i] = -1;\n\t\t}\n\t}\n\n\t////\ucd9c\ub825\uac12 \ud655\uc778\n\t//for (int i = 0; i < n; i++) {\n\t//\tcout << cost[i] << endl;\n\t//}\n\t//int s=convertBinary(binary, L);\n\t//for (int i = 0; i < s; i++) {\n\t//\tcout << binary[i] << endl;\n\t//}\n\n\t//\uacc4\uc0b0\n\twhile (L > 0)\n\t{\n\t\tint size = convertBinary(binary, L);\n\n\t\tfor (int i = 0; i < size; i++) {\n\n\t\t\tif (binary[i] == 1) {\n\t\t\t\tif (i > n - 1) {\n\t\t\t\t\tans += cost[n - 1] * pow(2, (i - (n - 1)));\n\t\t\t\t\tL -= pow(2, i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tint tmp = i;\n\t\t\t\t\tif (cost[i] == -1) {\n\t\t\t\t\t\tfor (int j = i + 1; j < n; j++) {\n\t\t\t\t\t\t\tif (cost[j] != -1) {\n\t\t\t\t\t\t\t\ttmp = j;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tans += cost[tmp];\n\t\t\t\t\tL -= pow(2, tmp);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t}\n\n\n\n\tcout << ans;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6ff7588c7ff8a6d29b5e91bb2d90029a", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nstruct Inf{int we,nu,ln;}b[100010];\nstruct pp{int l,r,nu;}a[100010];\nint n,k,v[100010],opt,l,r,nb,na,nv[100010],s;\nbool comp(const pp &a,const pp &b){\n\tif (a.l/s!=b.l/s) return a.l>n>>k;\n\ts=pow(n,1/3.0);\n\tfor (int i=1;i<=n;i++){scanf(\"%d\",&v[i]);nv[i]=v[i];}\n\twhile (k--){\n\t\tscanf(\"%d %d %d\",&opt,&l,&r);\n\t\tif (opt==2){b[++nb].we=l;b[nb].ln=nv[l];nv[l]=r;b[nb].nu=r;}else{a[++na].l=l;a[na].r=r;a[na].nu=nb;}\n\t}\n\tsort(a+1,a+na+1,comp);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c70b684956a8ab07e81cd028c94ca7fb", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "// Online C++ compiler to run C++ program online\r\n#include \r\nusing namespace std;\r\n#include\r\nint main() {\r\n int t;\r\n cin>>t;\r\n while(t--){\r\n int n;\r\n cin>>n;\r\n int k=9;\r\n vectorv;\r\n while(n==0){\r\n if(n-k>=0){\r\n n=n-k;\r\n v.push_back(k);\r\n k--;\r\n \r\n }\r\n else{\r\n k--;\r\n }\r\n \r\n }\r\n for(int i=v.size()-1;i>=0;i--){\r\n cout<\n#include \n#include \nusing namespace std;\nint n,m,q,cnt;\nlong long ans;\nchar str[510];\nint v[510][1010],imp[510];\nint ine(int x)\n{\n\treturn x*x*x%5;\n}\nint main()\n{\n\tscanf(\"%d%d\",&n,&m);\n\tint i,j,k,now;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%s\",str+1);\n\t\tfor(j=1;j<=m;j++)\tv[j][i]=str[j]-\u2018a\u2018;\n\t}\n\tscanf(\"%d\",&q);\n\tfor(i=1;i<=q;i++)\n\t{\n\t\tscanf(\"%s\",str+1);\n\t\tfor(j=1;j<=m;j++)\tv[j][n+i]=str[j]-\u2018a\u2018;\n\t}\n\tfor(now=i=1;i<=m&&now<=n;i++,now++)\n\t{\n\t\tfor(j=i+1;j<=m;j++)\tif(v[j][now]>v[i][now])\tfor(k=now;k<=n+q;k++)\tswap(v[j][k],v[i][k]);\n\t\twhile(!v[i][now]&&now<=n)\tnow++,cnt++;\n\t\tif(now>n)\tbreak;\n\t\tint t=ine(v[i][now]);\n\t\tfor(k=now;k<=n+q;k++)\tv[i][k]=v[i][k]*t%5;\n\t\tfor(j=i+1;j<=m;j++)\tif(v[j][now])\n\t\t{\n\t\t\tt=v[j][now];\n\t\t\tfor(k=now;k<=n+q;k++)\tv[j][k]=((v[j][k]-t*v[i][k])%5+5)%5;\n\t\t}\n\t}\n\tif(now<=n)\tcnt+=n-now+1;\n\tfor(;i<=m;i++)\tfor(k=n+1;k<=n+q;k++)\tif(v[i][k])\timp[k-n]=1;\n\tfor(ans=1,i=1;i<=cnt;i++)\tans=ans*5%1000000007;\n\tfor(i=1;i<=q;i++)\tprintf(\"%I64d\\n\",imp[i]?0ll:ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "24c885671b5f05c7f0074e7033870e14", "src_uid": "5cb18864c88b7fdec4a85718df67333e", "difficulty": 2600.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \nusing namespace std; \n\n#define MAX_N 51\n\nint N, M; \nint perm[MAX_N]; \nbool used[MAX_N];\nint count, maxSum; \nint ans[MAX_N];\n\nvoid check();\nvoid generate(int); \nint main() {\n\n\tcin >> N >> M; \n\n\tgenerate(1); \n\n\tfor (int i=1; i<=N; i++) {\n\t\tprintf(\"%d%c\", ans[i], (i == N)? '\\n' : ' '); \n\t}\n\n\treturn 0;\n}\n\nvoid generate(int len) {\n\n\tif (len == N+1) {\n\t\tcheck(); \n\t\treturn;\n\t}\n\n\tfor (int i=1; i<=N; i++){\n\t\tif (used[i]) continue; \n\t\tused[i] = true; \n\t\tperm[len] = i; \n\t\tgenerate(len+1);\n\t\tused[i] = false; \n\t}\n\n}\n\n\nvoid check() {\n\t\n\tint sum = 0;\n\tfor (int i=1; i<=N; i++) {\n\t\tfor (int j=i; j<=N; j++) {\n\t\t\tint m = INT_MAX;\n\t\t\tfor (int k=i; k<=j; k++) {\n\t\t\t\tm = min(m, perm[k]); \n\t\t\t}\n\t\t\tsum += m; \n\t\t}\n\t}\n\n\tif (maxSum < sum) {\n\t\tmaxSum = sum; \n\t\tcount = 0; \n\t} \n\n\tif (maxSum == sum) {\n\t\tcount++; \n\n\t\tif (count == M) {\n\t\t\tcopy(perm, perm+N+1, ans); \n\t\t}\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c72e9437dee3a4b439584d714dca220d", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "// Phoenix\n\n#include\n\n#define F first\n#define S second\n#define PB push_back\n#define sz(s) int((s).size())\n#define bit(n,k) (((n)>>(k))&1)\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\n\nconst int maxn=1e5+10,mod=1e9+7;\nconst ll inf=1e18;\n\nstruct Tree{\n\n};\n\nvectorv[maxn],g[maxn];\nint w[maxn],h[maxn],mark[maxn];\nbool is[maxn];\n\nint dfs1(int u,int H=1,int par=-1){\n mark[u]=1;\n int ans=h[u]=H;\n for(int y:v[u]){\n\tif(mark[y]){\n\t if(y!=par)\n\t\tans=min(ans,h[y]);\n\t}\n\telse{\n\t int num=dfs1(y,H+1,u);\n\t if(H<=num) mark[u]=2;\n\t ans=min(ans,num);\n\t}\n }\n return ans;\n}\n\nvoid dfs2(int u){\n mark[u]=2;\n for(int y:v[u]){\n\tif(mark[y]==1)\n\t dfs2(y,u);\n }\n}\n\nvoid input(){\n int n,m;cin>>n>>m;\n for(int i=1;i<=n;i++)\n\tcin>>w[i];\n while(m--){\n\tint a,b;cin>>a>>b;\n\tv[a].PB(b);\n\tv[b].PB(a);\n }\n for(int i=1;i<=n;i++){\n\tif(!mark[i])\n\t dfs1(i);\n }\n}\n\nint main(){\n ios_base::sync_with_stdio(false);cin.tie(0);\n \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "39bc516f1879bdcdcbf643b955715094", "src_uid": "46253becfda9a45ce670dc7d835beaf3", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n\ntypedef pair pii;\ntypedef pair pli;\ntypedef pair pil;\ntypedef pair pll;\n\n#define elif else if\n#define forn(i, n) for(int i = 0; i < n; ++i)\n#define fore(i, l, r) for(int i = l; i < r; ++i)\n#define sum(a) accumulate(begin(a), end(a), 0ll)\n\ntemplate\ninline istream& operator >> (istream& is, vector& v) {\n for (auto& e: v) {\n cin >> e;\n }\n return is;\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n int n;\n char c;\n cin >> n;\n vector> pxy(2, vector(n + 1, 0));\n forn(i, n) {\n \tcin >> c;\n \tif (c == 'L') tie(pxy[0][i + 1], pxy[1][i + 1]) = {pxy[0][i] - 1, pxy[1][i]};\n \tif (c == 'R') tie(pxy[0][i + 1], pxy[1][i + 1]) = {pxy[0][i] + 1, pxy[1][i]};\n \tif (c == 'U') tie(pxy[0][i + 1], pxy[1][i + 1]) = {pxy[0][i], pxy[1][i] + 1};\n \tif (c == 'D') tie(pxy[0][i + 1], pxy[1][i + 1]) = {pxy[0][i], pxy[1][i] - 1};\n }\n int answer = 0;\n forn(l, n) fore(r, l, n) if (pxy[0][r + 1] == pxy[0][l] && pxy[1][r + 1] == pxy[1][l]) ++ answer;\n cout << answer;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c33f7bea61690116357921bf34c550d1", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include //JuniorMonster a.k.a Sho10\n#define ll long long\n#pragma GCC optimize(\"O3\")\n#pragma GCC optimize(\"Ofast\")\n#define all(a) (a).begin(), (a).end()\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#define sz size\n#define f first\n#define s second\n#define pb push_back\n#define er erase\n#define in insert\n#define mp make_pair\n#define pi pair\n#define rc(s) return cout<>s;\nll ans=0;\nif(s.size()==1){\n cout<<10-s[i]+'0';\n return 0;\n}\nans=ans-s[s.size()-1]+10+'0';\nfor(ll i=s.size()-2;i>=0;i--)\n{\n if(s[i]!=9){\n ans=ans+10-s[i]+'0';\n }\n if(s[i-1]!=9&&i!=0){\n s[i-1]++;\n }\n}\ncout<>st1;\n\tcin>>st2;\n\tsort(st1.begin(),st1.end());\n\tif(st1[0]=='0')\n\t for(int i=1;i\n#include \n#define max(a,b) ((a) > (b) ? (a) : (b))\nusing namespace std;\nint main()\n{\n int nb,nc,nw;\n cin >> nb >> nc >> nw;\n vector v(nb);\n vector :: iterator p,q;\n int a=0;\n int* t;\n for(int i=0;i> v[i];\n }\n for(int i=0;i2)\n {\n int len = v.size();\n for(int j=2;j\n#include\n#include\nusing namespace std;\n\n\n\n\n\nint main()\n{\n\tint factor = 1;\n\tstring str;\n\tgetline(cin, str);\n\t/*char *prev = new char[str.length];*/\n\tvector chars;\n\tfor (int i = 0; i < str.length(); i++) {\n\t\tif (str[0] == '?') {\n\t\t\tfactor *= 10;\n\t\t}\n\t\telse if (str[i] >= 0 && str[i] <= 9) {\n\t\t\tfactor *= 10;\n\t\t}\n\t\telse if (str[i] >= 65 && str[i] <= 74) {\n\t\t\tif (find(chars.begin(), chars.end(), str[i]) != chars.end()) {\n\t\t\t\tchars.push_back(str[i]);\n\t\t\t\tfactor *= 10;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "03768dbcb002a25c17ed6e04c02fa0e2", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n\nusing namespace std;\n\n\nint main() {\n\tint n, pos, high, low, count, a, b;\n\n\tcount = 0;\n\ttemp = 0;\n\n\tcin>>n>>pos>>low>>high;\n\n\tif(low == 1 && high == n)\n\t\tcount = 0;\n\telse if(pos < low) {\n\t\tcount = (low - pos) + 1;\n\t\tpos = low;\n\t\tcount += (high - pos) + 1;\n\t}\n\telse if(pos > high) {\n\t\tcount = (pos - high) + 1;\n\t\tpos = high;\n\t\tcount += (pos - low) + 1;\n\t}\n\telse {\n\t\ta = abs(pos - low);\n\t\tb = abs(pos - high)\n\n\t\tif(a < b) {\n\t\t\tcount = (pos - low) + 1;\n\t\t\tpos = low;\n\t\t\tcount += (high - pos) + 1;\n\t\t}\n\t\telse {\n\t\t\tcount = (high - pos) + 1;\n\t\t\tpos = high;\n\t\t\tcount += (pos - low) + 1;\n\t\t}\n\t}\n\n\n\tcout<\n#include\nusing namespace std;\nint solve()\n{\n\tstring l=\"\",r=\"\",s,a=\"CODEFORCES\";\n\tint i,j;\n\ti=j=0;\n\tcin>>s;\n\tfor(i=0;i<10&&a[i]==s[i];)\n\t{l=l+a[i];\n\ti++;\n\t}\n\tif(i==10)\n{\tcout<<\"YES\";\n\treturn 0;}\n\tint t=s.length();\n\tt=t-1;\n\tfor(i=9;i>=0&&s[t]==a[i];)\n\t{\n\t\tr+=a[i];\n\t\tt--;\n\t\ti--;\n\t}\n\tif(i==-1)\n{\tcout<<\"YES\";\n\treturn 0;}\n\treverse(r.begin(),r.end());\n\tl=l+r;\n\t\n\tif(a.compare(l)==0)\t\n\t\t\n\t\t\n\n\t\n\t cout<<\"YES\";\n\t else\n\t cout<<\"NO\";\n\t \n\t \n\t\t\t\n\t\t\n\t\n\n\t\n\treturn 0;\n}\n\t\n\t\t \n\t\n\t\n\n\n\n\n\n\n\nint main()\n{\n\t\n\t\n\t\n\t\tsolve();\n\t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a83fac08785451dc8d26a046786a3ed6", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \ntypedef long long ll;\nusing namespace std;\nint i,n,m;\nint main()\n{\n string s;\n cin>>s;\n for(i=0;i\nusing namespace std;\n\nconst int N = 1e5 + 5;\n\nint n, k, q, A[N], num[2], Min, mod, ans, I4;\n\nnamespace {\n int add(int x) {return (x >= mod) ? x - mod : x;}\n int sub(int x) {return (x < 0) ? x + mod : x;}\n void Add(int &x, int y) {x = add(x + y);}\n void Sub(int &x, int y) {x = sub(x - y);}\n int Pow(int x, int y = mod - 2) {\n int res = 1;\n for(; y; y >>= 1, x = 1LL * x * x % mod) {\n if(y & 1)\n\tres = 1LL * res * x % mod;\n }\n return res;\n }\n}\n\nvector L;\n\nvoid solve(int l, int r, int k) {\n if(l > r) return;\n if(k <= 1 || l == r) {\n int Len = r - l + 1;\n Min = min(Min, Len);\n L.push_back(Len);\n Add(ans, 1LL * Len * (Len - 1) % mod * I4 % mod);\n return;\n }\n int mid = (l + r) >> 1;\n solve(l, mid, k - 1);\n solve(mid + 1, r, k - 1);\n}\n\nint inv[N];\n\nint calc(int Sum, int x, int y) {\n int L = max(Sum - y, 1), R = min(Sum - 1, x);\n return max(R - L + 1, 0);\n}\n\nint main() {\n cin >> n >> k >> mod;\n Min = 1e9;\n I4 = Pow(4);\n inv[0] = 0;\n for(int i = 1; i <= n; ++ i) inv[i] = Pow(i);\n solve(1, n, k);\n for(int i = 0; i < (int) L.size(); ++ i) ++ num[L[i] - Min];\n for(int i = 1; i <= 2 * (Min + 1); ++ i) {\n int tot = 0;\n Add(tot, 1LL * num[0] * (num[0] - 1) % mod * inv[2] % mod * calc(i, Min, Min) % mod);\n Add(tot, 1LL * num[1] * (num[1] - 1) % mod * inv[2] % mod * calc(i, Min + 1, Min + 1) % mod);\n Add(tot, 1LL * num[0] * num[1] % mod * calc(i, Min + 1, Min) % mod);\n cerr << i <<\" \" << tot << endl;\n Add(ans, 1LL * tot * inv[2] % mod * sub(1 - 2LL * inv[i] % mod) % mod);\n }\n printf(\"%d\\n\", ans);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2591610062798256b2d976cb63f49fcf", "src_uid": "1dd54f5071872e947996ab32b16da19c", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n int a,b,c,d,e,f;\n cin << a << b << c << d << e << f ;\n t2 = (bf)\n {\n t1 = (a\nusing namespace std;\nint main()\n{\n char a[120]={'\\0'};\n int b,i,e,j;\n cin>>a;\n for( i=0;i<120;i++)\n if(a[i]=='\\0')\n break;\n if(a[i-2]=='e')\n {\n b=a[i-1]-48;\n e=i-2;\n }\n\n else\n {\n b=a[i-1]-48+(a[i-2]-48)*10;\n e=i-3;\n }\n\n cout<47))\n cout<\n#include \nusing namespace std;\n\nint main()\n{\n int h,m,s,t1,t2, ch;\n cin >> h >> m >> s >> t1 >> t2;\n int ah = (h * 3600 + (m * 60) + s) % 60, am = (m % 60 * 60 + s % 60) % 60 , as = s % 60;\n cout << ah << \" \" << am << \" \" << as << \" \" << t1 << \" \" << t2 << \" \";\n\n\n if(t1 ah) || \n && ((t1*5 < am && t2*5 > am) ||\n && ((t1*5 < as && t2*5 > as)))\n {\n\n cout << \"NO\";\n }\n else\n cout << \"YES\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d65b7390d5f587ef08b54d83a1086be4", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main(){\n\tstring s;\n\tcin >> s;\n\tfor(int i = 1; i<=s.size()-3; i++){\n\t\tif(s[i] != s[i+1] && s[i] != s[i+2] && s[i+1] != s[i+2] && s[i] != '.' && s[i+1] != '.' && s[i+2] != '.'){\n\t\t\tcout << \"Yes\" << '\\n';\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout << \"No\" << '\\n';\n\treturn 0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "56c9dd139ee774c84a60f079ec18b56a", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long int int64;\n\nint64 fr[1111][1111][4];\n\nconst int base = 1000000007;\n\nint64 f(int n, int k, int l)\n{\n if(n <= 0 || k < 0 || k > n) return 0;\n if(n == 1 && k == 0 && l == 3) return 1;\n if(fr[n][k][l] == -1)\n {\n switch(l)\n {\n case 0:\n {\n fr[n][k][l] = 0;\n fr[n][k][l] += (f(n - 1, k + 1, 0) + f(n - 1, k + 1, 3))* (k + 1);\n fr[n][k][l] += f(n - 1, k + 1, 1) * k;\n if(k > 1) fr[n][k][l] += f(n - 1, k + 1, 2) * (k - 1);\n \n if(n - 3 - k > 0) fr[n][k][l] += f(n - 1, k, 0) * (n - 3 - k);\n if(n - 2 - k > 0) fr[n][k][l] += (f(n - 1, k, 1) + f(n - 1, k, 3)) * (n - 2 - k);;\n if(n - 1 - k > 0) fr[n][k][l] += f(n - 1, k, 2) * (n - 1 - k);\n }\n break;\n case 1:\n {\n fr[n][k][l] = f(n - 1, k - 1, 0) * 2 + f(n - 1, k - 1, 1) + \n f(n - 1, k, 1) + f(n - 1, k, 2) * 2;\n }\n break;\n case 2:\n {\n fr[n][k][l] = f(n - 1, k - 2, 3);\n }\n break;\n case 3:\n {\n fr[n][k][l] = 0;\n for(int i = 0; i < 4; i++) fr[n][k][l] += f(n - 1, k, i);\n }\n break;\n }\n fr[n][k][l] %= base;\n }\n return fr[n][k][l];\n}\n\nint main()\n{\n int n, k;\n memset(fr, -1, sizeof(fr));\n cin >> n >> k;\n int64 res = 0;\n for(int i = 0; i < 4; i++) res += f(n, k, i);\n res %= base;\n cout << res;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "73b37b7bdc9704f8bb04bd10f4352966", "src_uid": "1243e98fe2ebd6e6d1de851984b96079", "difficulty": 2600.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include \n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n\nint main()\n{\n int n, a, b, ans=0,t;\n \n cin >> n >> a >> b;\n for (int i = 1; i < n; i++)\n {\n \t t = min(floor(a / i), floor(b / (n - i)));\n\t ans = max(ans, t);\n\t \n }\n cout << ans;\n \n return 0;\n \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6977336025c11cb1efacf1e6d03f767a", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint a[5];\nint main(){\n for(int i=1;i<=4;i++)\n cin>>a[i];\n sort(a+1,a+4+1);\n if(a[1]+a[2]>a[3]||a[2]+a[3]>a[4])\n cout<<\"TRIANGLE\\n\";\n else if(a[1]+a[2]==a[3]||a[2]+a[3]==a[4])\n cout<<\"SEGMENT\"<\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint vist[205][205];\nchar s[105];\nint main()\n{\n scanf(\"%s\", s);\n memset(vist, 0, sizeof(vist));\n bool bugflag = false;\n vist[100][100] = 1;\n for(int k = 0, nowx = 100, nowy = 100; s[k] != 0; k++)\n {\n //cout << s[k] << \" \";\n if(s[k] == 'L') nowx--;\n if(s[k] == 'R') nowx++;\n if(s[k] == 'U') nowy--;\n if(s[k] == 'D') nowy++;\n vist[nowx][nowy]++;\n //cout << nowx << \" \" << nowy << endl;\n if(vist[nowx][nowy] == 2)\n {\n bugflag = 1;\n break;\n }\n }\n if(bugflag) printf(\"BUG\\n\");\n else printf(\"OK\\n\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b713bacc57e88daec44ddc7ffea42093", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nconst int MAX=0x7fffffff;\nconst long long INF=(long long)(10e9)+1;\n#define SET(mask,n) mask|=(1<\n#define ff first\n#define ss second\n\n\nmain()\n{\n ios;\n cin.tie(0);\n int64 i,j,t,n,u,v,d,mini=99999999;\n cin>>n;\n string s,p;\n p=\"ACTG\";\n cin>>s;\n for(i=0;i\n#include \n#include \n#include \n#include \n\n#define maxlongint 2147483647\n#define LL long long\n#define pb push_back\n\nusing namespace std;\n\nLL n;\n\nint main()\n{\n cin>>n;\n if(n%3!=0)\n cout<<0<n){xmax=i-1;break;}\n for(LL x=xmax;x>1;x--)\n if(n%x==0)\n {\n LL p0=(LL)sqrt(n/x);\n for(LL y=p0;y>=x;y--)\n if(n%(x*y)==0)\n {\n LL z=n/x/y;\n if((x+y+z)%2)continue;\n LL tot=(x+y+z)/2,a=tot-z,b=tot-y,c=tot-x;\n if((a<=0)||(b<=0)||(c<=0))break;\n if((a==b)&&(a==c))\n ans++;\n else if(a==b)\n ans+=3;\n else if(a==c)\n ans+=3;\n else if(b==c)\n ans+=3;\n else\n ans+=6;\n }\n }\n cout<\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vvi;\ntypedef vector vvl;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair pll;\ntypedef vector vii;\ntypedef vector vll;\n\n#define PB push_back\n#define F first\n#define S second\n#define MP make_pair\n#define endl '\\n'\n\nconst double PI = acos(-1);\nconst double eps = 1e-9;\nconst int inf = 2000000000;\nconst ll infLL = 9000000000000000000;\n#define MOD 1000000007\n//#define harmonic(n) 0.57721566490153286l+log(n)\n\n#define mem(a,b) memset(a, b, sizeof(a) )\n#define gcd(a,b) __gcd(a,b)\n#define lcm(a,b) (a*(b/gcd(a,b)))\n#define sqr(a) ((a) * (a))\n\n#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define fraction() cout.unsetf(ios::floatfield); cout.precision(6); cout.setf(ios::fixed,ios::floatfield);\n\ntypedef vector::iterator vit;\ntypedef set::iterator sit;\n\ninline bool checkBit(ll n, int i) { return n&(1LL< 0) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }\ninline ll modInverse(ll a) { return modPow(a, MOD-2); }\ninline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }\n//\n//debug\n#ifdef yamin\ntemplate < typename F, typename S >\nostream& operator << ( ostream& os, const pair< F, S > & p ) {\n return os << \"(\" << p.first << \", \" << p.second << \")\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const vector< T > &v ) {\n os << \"{\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"}\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const set< T > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"]\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const multiset< T > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"]\";\n}\n\ntemplate < typename F, typename S >\nostream &operator << ( ostream & os, const map< F, S > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << it -> first << \" = \" << it -> second ;\n }\n return os << \"]\";\n}\n\n#define dbg(args...) do {cerr << #args << \" : \"; faltu(args); } while(0)\n\nclock_t tStart = clock();\n#define timeStamp dbg(\"Execution Time: \", (double)(clock() - tStart)/CLOCKS_PER_SEC)\n\nvoid faltu () {\n cerr << endl;\n}\n\ntemplate \nvoid faltu( T a[], int n ) {\n for(int i = 0; i < n; ++i) cerr << a[i] << ' ';\n cerr << endl;\n}\n\ntemplate \nvoid faltu( T arg, const hello &... rest) {\n cerr << arg << ' ';\n faltu(rest...);\n}\n#else\n#define dbg(args...)\n#endif // yamin\n\nint main() {\n optimize();\n\n string s; cin >> s;\n int ans = 0, n = s.size();\n\n for(int i = n - 1; i >= 0; --i) { dbg(i);\n ans = modMul(ans, 2);\n if(s[i] == '1') ans = modAdd(ans, modPow(2, (n - i - 1)\u0135 << 1));\n }\n\n //ans = modAdd(ans,\n\n cout << ans;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "010df9500639faed835a3d36c8a6b350", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int MAXN = 1e5 + 10;\nbool type[MAXN];\nint ind[MAXN];\nset haveInBeg;\n\nint main()\n{\n\tint n,m;\n\twhile(~scanf(\"%d%d\",&n,&m))\n\t{\n\t\thaveInBeg.clear();\n\t\tmemset(type,0,sizeof(type));\n\t\tmemset(ind,0,sizeof(ind));\n\t\tfor(int i = 0;i < m;++i){\n\t\t\tchar inq[2];\n\t\t scanf(\"%s%d\",inq,&ind[i]);\n\t\t\tif(inq[0]=='+')\n\t\t\t\ttype[i] = 1;\n\t\t\telse \n\t\t\t\ttype[i] = 0;\n\t\t}\n\t\tfor(int i = m-1;i >= 0;--i){\n\t\t if(type[i])\n\t\t\t haveInBeg.erase(ind[i]);\n\t\t else\n\t\t\t haveInBeg.insert(ind[i]);\n\t\t}\n\t\tset ans;\n\t\tfor(int i = 1;i <= n;++i)\n\t\t\tans.insert(i);\n\t\tfor(int i = 0;i < m;++i){\n\t\t\tif(type[i]){\n\t\t\t if(i&&ind[i-1]!=ind[i])\n\t\t\t\t ans.erase(ind[i]);\n\t\t\t if(!haveInBeg.empty())\n\t\t\t\t ans.erase(ind[i]);\n\t\t\t haveInBeg.insert(ind[i]);\n\t\t\t}\n\t\t\telse{\n\t\t\t if(i\nusing namespace std;\nint main()\n{\n\tint i,j,k,m,l=14,n,max,sum=0;\n\n\tvectora(14);\n\tfor(i=0;i<14;i++)\n\t{\n\t\tcin>>a[i];\n\t}\n\t\n\tfor(i=0;i<14;i++)\n\t{\n\t\tvectorv(14,0);\n\t\tint temp=a[i];\n\t\tint quo=temp/14;\n\t\tint rem=temp%14;\n\n\t\tfor(j=0;j<14;j++)\n\t\t{\n\t\t\tif(i==j)\n\t\t\t{\n\t\t\t\tv[j]=quo;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tv[j]=quo+a[j];\n\t\t\t}\n\t\t}\n\t\tk=(i+1)%14;\n\t\tfor(j=k;j<14;j++)\n\t\t{\n\t\t\tif(rem==0)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tv[j]++;\n\t\t\trem--;\n\n\t\t}\n\t\tfor(l=0;l\nusing namespace std;\nint fast_pow(int base, int exp) { int result=1; while(exp>0) { if(exp % 2 ==1) result=(result * base); base=(base*base); exp=exp/2; } return result; }\nint main()\n{\nint n,m,r,ans,i,k;\nint a=2;\nr=1;\ncin>>n>>m;\nk=n;\ni=0;\ni=log(m)/log(2);\n if(k>i+2)\n cout<\nusing namespace std;\n\n// io\n#define get(i) scanf(\"%d\", &i)\n#define flush fflush(stdin)\n\n// manipulations\n#define f(i, n) for (int i = 0; i < n; i++)\n#define fr(i, n) for (int i = n - 1; i >= 0; i--)\n#define ff(i, a, b) for (int i = a; i <= b; i++)\n#define lowbit(x) (x & -x)\n#define sz(x) int((x).size())\n\n// built-in\n#define bitcount __builtin_popcount\n#define gcd __gcd\n\n// short\n#define pb push_back\n#define fill(arr, a) memset(arr, a, sizeof(arr))\n\n// useful bits\n#define IN(i, l, r) (l <= i && i <= r)\n#define relax(a, b) a = max(a, b)\n#define relaxi(a, b) (a) = min((a), (b))\n\ntypedef vector VI;\ntypedef pair PII;\ntypedef long long ll;\ntypedef long double ld;\n\nll modpow(ll a, ll b, ll mod = (ll) (1e9 + 7)) \n{if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;}\n\nconst int maxn = 1000001;\nconst int sz = 30;\nint p = 0;\nmap state;\nvector inv;\nmap adj;\nmap bfs;\nint sieve[maxn];\n\nvoid init(VI a) {\n\tstate[a] = p;\n\tinv.pb(VI(a));\n\tadj[p++] = VI();\n}\n\nvoid addEdge(VI a, VI b) {\n\tif (!state.count(a)) init(a);\n\tif (!state.count(b)) init(b);\n\tadj[state[a]].pb(state[b]);\n\tadj[state[b]].pb(state[a]);\n}\n\nint eval(VI a) {\n\tint ans = 1;\n\tf(i, sz) ans *= (a[i]+1);\n\treturn ans;\n}\n\nvoid printlist(VI a) {\n\tf(i, sz) cout << a[i] << \" \";\n\tcout << endl;\n}\n\nvoid recurse(int product, int sum, int i, int ls, VI &vec) {\n\tif (product > 300 || sum > sz) return;\n\tif (i == vec.size()) {\n\t\tVI cpy(vec);\n\t\tif (!state.count(cpy)) init(cpy);\n\t\tf(i, vec.size()) {\n\t\t\tif (!i || (vec[i] != vec[i-1])) {\n\t\t\t\tcpy[i]++; \n\t\t\t\tif (vec[i]) addEdge(cpy, vec);\n\t\t\t\tcpy[i]--;\n\t\t\t} \n\t\t\tif (i == vec.size()-1 || (vec[i] != vec[i+1])) {\n\t\t\t\tcpy[i]--;\n\t\t\t\tif (vec[i]) addEdge(cpy, vec);\n\t\t\t\tcpy[i]++;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tvec[i] = 0;\n\t\trecurse(product, sum, i+1, 0, vec);\n\t\tff(j, 1, ls) {\n\t\t\tvec[i] = j; recurse(product*(j+1), sum+j, i+1, j, vec);\n\t\t}\n\t}\n}\n\nvoid perform_bfs(int a) {\n\tbfs[a] = VI(300, 1000);\n\n\tint dist[p];\n\tfill(dist, 1000);\n\tdist[a] = 0;\n\n\tbool vis[p];\n\tfill(vis, false);\n\tvis[a] = true;\n\n\tqueue pq;\n\tpq.push(a);\n\twhile (!pq.empty()) {\n\t\tint v = pq.front();\n\t\tpq.pop();\n\t\trelaxi(bfs[a][eval(inv[v])], dist[v]);\n\n\t\tfor (int w : adj[v])\n\t\t\tif (!vis[w]) {\n\t\t\t\tvis[w] = true;\n\t\t\t\tpq.push(w);\n\t\t\t\tdist[w] = dist[v] + 1;\n\t\t\t}\n\t}\n}\n\nint getans(int a, int b) {\n\tif (!bfs.count(a))\n\t\tperform_bfs(a);\n\tif (!bfs.count(b))\n\t\tperform_bfs(b);\n\tint ans = 100000;\n\tf(i, 300)\n\t\trelaxi(ans, bfs[a][i] + bfs[b][i]);\n\treturn ans;\n}\n\nVI convert(int a) {\n\tVI ans;\n\twhile (a > 1) {\n\t\tint p = sieve[a];\n\t\tint cnt = 0;\n\t\twhile (a % p == 0) {\n\t\t\ta /= p;\n\t\t\tcnt++;\n\t\t}\n\t\tans.pb(cnt);\n\t}\n\tsort(ans.begin(), ans.end(), greater());\n\twhile (ans.size() < sz)\n\t\tans.pb(0);\n\treturn ans;\n}\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\n\tVI ans(sz);\n\trecurse(1, 0, 0, sz, ans);\n\n\tfill(sieve, 0);\n\tff(i, 2, maxn) {\n\t\tif (!sieve[i]) {\n\t\t\tsieve[i] = i;\n\t\t\tfor (int j = 2*i; j < maxn; j += i)\n\t\t\t\tsieve[j] = i;\n\t\t}\n\t}\n\n\tint t; get(t);\n\tstringstream ss;\n\tf(_, t) {\n\t\tint a, b; get(a); get(b);\n\t\tVI aa = convert(a), bb = convert(b);\n\t\tcout << getans(state[aa], state[bb]) << endl;\n\t}\n\n\tstate.clear();\n\tinv.clear();\n\tadj.clear();\n\tbfs.clear();\n\n\tcout << ss.str() << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "915a2231515cf62d8ae9fecafcb85e4e", "src_uid": "6115ee1ccf651b1dd8145bf755ea7ea9", "difficulty": 2800.0} {"lang": "GNU C++0x", "source_code": "#include /*{{{*/\ntypedef long long ll; typedef long double ld; using namespace std;void run();int main(){ios::sync_with_stdio(false);run();}/*}}}*/\n\nll const lots=1000000007ll;\nll memo[55][55][2];\nll choose[55][55];\n\nll half(ll n){\n ll res=n;\n ll s=2;\n for (ll i=lots-2; i; i>>=1, (s*=s)%=lots)\n if (i&1)\n (res*=s)%=lots;\n return res;\n}\n\nll solve(int n,int k,bool matched){\n if (n<=0 or k<0 or k*2>n) return 0ll;\n if (n==1) return k==0 and not matched;\n ll &res=memo[n][k][matched];\n if (res) return ares;\n\n // single child\n if (matched){\n res+=solve(n-1,k-1,false)\n *choose[n-1][1];\n res%=lots;\n }else{\n res+=solve(n-1,k,true)\n *choose[n-1][1];\n res%=lots;\n }\n\n // two children\n if (not matched){\n for (int a=1,b=n-2; a<=b; a++,b--){\n for (int i=0,j=k; i<=k; i++,j--){\n res+=(((\n solve(a,i,true)\n *solve(b,j,true) % lots)\n *(a==b? half(choose[n-1][a]): choose[n-1][a]) % lots)\n *choose[a][1] % lots)\n *choose[b][1];\n res%=lots;\n }\n }\n }else{\n for (int a=1,b=n-2; a<=n-2; a++,b--){\n for (int i=0,j=k-1; i<=k-1; i++,j--){\n if (a \"<>n>>k;\n cout<<(solve(n,k,false)+solve(n,k,true))%lots<\nusing namespace std;\n\nnamespace Mlxa {\n\ttypedef long long ll;\n\t#define read cin\n\t#define eol '\\n'\n\t#define endln cout << eol\n\t#define print(x) cout << x << ' '\n\ttemplate inline void println(A a) { cout << a << eol; }\n\ttemplate inline void println(A a, B... b) { print(a), println(b...); }\n\ttemplate inline void printseq (I b, I e) { for (I i(b); i != e; ++ i) print(*i); endln; }\n\t#define size(x) ll(x.size())\n\t#define all(x) begin(x), end(x)\n\t#define openFiles(s) freopen(s \".in\", \"r\", stdin), freopen(s \".out\", \"w\", stdout);\n\t#define fastIO ios_base::sync_with_stdio(false), cin.tie(nullptr)\n\t#define pb push_back\n} using namespace Mlxa;\n\nll a, b, c;\nll cnt[4] = {0, 0, 0, 0};\n\nvoid start () {\n\t#ifdef AC\n\t\tprintln(\"It's AC, bro!\");\n\t#else\n\t\tfastIO;\n\t#endif // AC\n\tread >> a >> b >> c;\n}\n\nint main () {\n\tstart(); ll m = min(min(a, b), c);\n\tif (a < 4) cnt[a] ++;\n\tif (b < 4) cnt[b] ++;\n\tif (c < 4) cnt[c] ++;\n\n\tif (mn > 3) println(\"NO\");\n\telse if (cnt[1] > 0 || cnt [2] > 1 || cnt[3] > 2) \tprintln(\"YES\");\n\telse\t\t\t\t\t\t\t\t\t\t\tprintln(\"NO\");\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cd827d34aa935459b918780d400bca36", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include\n\nint main() {\n\tint n;\n\tscanf(\"%d\", &n);\n\t\n\tint votes[n] = {0};\n\t\n\tint biggest = -1;\n\tint total = 0;\n\t\n\tfor(int i=0; i biggest)\tbiggest = votes[i];\n\t\ttotal += votes[i];\n\t}\n\t\n\tint ans = biggest;\n\twhile(true)\n\t\tint totalVotes = n * ans;\n\t\tif(totalVotes - total > total)\tbreak;\n\t\tans++;\n\t}\n\t\n//\tprintf(\"%d %d\\n\", total, n * i - total);\n\t\n\tprintf(\"%d\", ans);\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8d33fa597a648be6a9a951c239ac7958", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\nint main()\n{\n\n string s1,s2,s3;\n char arr[3];\n cin>>s1>>s2>>s3;\n\n if(s1[1]==s2[1])\n {\n if(s1[1]=='>')\n {\n if(s1[0]==s2[0])\n {\n arr[2]=s1[0];\n if(s3[1]=='>')\n {\n arr[0]=s3[2];\n arr[1]=s3[0];\n }\n else if(s3[1]=='<')\n {\n arr[0]=s3[0];\n arr[1]=s3[2];\n }\n\n }\n else if(s1[2]==s2[2])\n {\n arr[0]=s1[2];\n if(s3[1]=='>')\n {\n arr[1]=s3[2];\n arr[2]=s3[0];\n }\n else if(s3[1]=='<')\n {\n arr[1]=s3[0];\n arr[2]=s3[2];\n }\n\n }\n else if(s1[0]==s2[2])\n {\n arr[1]=s1[0];\n if(s3[1]=='>')\n {\n if(s3[0]==s2[0]&&s3[2]==s1[2])\n {arr[0]=s3[2];arr[2]=s3[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s3[0]==s1[0]&&s3[2]==s2[2])\n {arr[0]=s3[2];arr[2]=s3[0];}\n else{ cout<<\"Impossible\"<')\n {\n arr[1]=s3[2];\n arr[2]=s3[0];\n }\n else if(s3[1]=='<')\n {\n arr[1]=s3[0];\n arr[2]=s3[2];\n }\n\n }\n else if(s1[2]==s2[2])\n {\n arr[2]=s1[2];\n if(s3[1]=='>')\n {\n arr[1]=s3[2];\n arr[0]=s3[0];\n }\n else if(s3[1]=='<')\n {\n arr[0]=s3[0];\n arr[1]=s3[2];\n }\n\n }\n else if(s1[0]==s2[2])\n {\n arr[1]=s1[0];\n if(s3[1]=='>')\n {\n if(s3[0]==s1[2]&&s3[2]==s2[0])\n {arr[0]=s3[2];arr[2]=s3[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s3[0]==s2[2]&&s3[2]==s1[0])\n {arr[0]=s3[2];arr[2]=s3[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s1[0]==s3[0])\n {\n arr[2]=s1[0];\n if(s2[1]=='>')\n {\n arr[0]=s2[2];\n arr[1]=s2[0];\n }\n else if(s2[1]=='<')\n {\n arr[0]=s2[0];\n arr[1]=s2[2];\n }\n\n }\n else if(s1[2]==s3[2])\n {\n arr[0]=s1[2];\n if(s2[1]=='>')\n {\n arr[1]=s2[2];\n arr[2]=s2[0];\n }\n else if(s2[1]=='<')\n {\n arr[1]=s2[0];\n arr[2]=s2[2];\n }\n\n }\n else if(s1[0]==s3[2])\n {\n arr[1]=s1[0];\n if(s2[1]=='>')\n {\n if(s2[0]==s3[0]&&s2[2]==s1[2])\n {arr[0]=s2[2];arr[2]=s2[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s2[0]==s1[0]&&s2[2]==s3[2])\n {arr[0]=s2[2];arr[2]=s2[0];}\n else{ cout<<\"Impossible\"<')\n {\n arr[1]=s2[2];\n arr[2]=s2[0];\n }\n else if(s2[1]=='<')\n {\n arr[1]=s2[0];\n arr[2]=s2[2];\n }\n\n }\n else if(s1[2]==s3[2])\n {\n arr[2]=s1[2];\n if(s2[1]=='>')\n {\n arr[1]=s2[2];\n arr[0]=s2[0];\n }\n else if(s2[1]=='<')\n {\n arr[0]=s2[0];\n arr[1]=s2[2];\n }\n\n }\n else if(s1[0]==s3[2])\n {\n arr[1]=s1[0];\n if(s2[1]=='>')\n {\n if(s2[0]==s1[2]&&s2[2]==s3[0])\n {arr[0]=s2[2];arr[2]=s2[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s2[0]==s3[2]&&s2[2]==s1[0])\n {arr[0]=s2[2];arr[2]=s2[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s2[0]==s3[0])\n {\n arr[2]=s2[0];\n if(s1[1]=='>')\n {\n arr[0]=s1[2];\n arr[1]=s1[0];\n }\n else if(s1[1]=='<')\n {\n arr[0]=s1[0];\n arr[1]=s1[2];\n }\n\n }\n else if(s2[2]==s3[2])\n {\n arr[0]=s2[2];\n if(s1[1]=='>')\n {\n arr[1]=s1[2];\n arr[2]=s1[0];\n }\n else if(s1[1]=='<')\n {\n arr[1]=s1[0];\n arr[2]=s1[2];\n }\n\n }\n else if(s2[0]==s3[2])\n {\n arr[1]=s2[0];\n if(s3[1]=='>')\n {\n if(s1[0]==s3[0]&&s1[2]==s2[2])\n {arr[0]=s1[2];arr[2]=s1[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s1[0]==s2[0]&&s1[2]==s3[2])\n {arr[0]=s1[2];arr[2]=s1[0];}\n else{ cout<<\"Impossible\"<')\n {\n arr[1]=s1[2];\n arr[2]=s1[0];\n }\n else if(s1[1]=='<')\n {\n arr[1]=s1[0];\n arr[2]=s1[2];\n }\n\n }\n else if(s2[2]==s3[2])\n {\n arr[2]=s2[2];\n if(s1[1]=='>')\n {\n arr[1]=s1[2];\n arr[0]=s1[0];\n }\n else if(s1[1]=='<')\n {\n arr[0]=s1[0];\n arr[1]=s1[2];\n }\n\n }\n else if(s2[0]==s3[2])\n {\n arr[1]=s2[0];\n if(s1[1]=='>')\n {\n if(s1[0]==s2[2]&&s1[2]==s3[0])\n {arr[0]=s1[2];arr[2]=s1[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s1[0]==s3[2]&&s1[2]==s2[0])\n {arr[0]=s1[2];arr[2]=s1[0];}\n else{ cout<<\"Impossible\"<\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\nint main()\n{\n\n string s1,s2,s3;\n char arr[3];\n cin>>s1>>s2>>s3;\n\n if(s1[1]==s2[1])\n {\n if(s1[1]=='>')\n {\n if(s1[0]==s2[0])\n {\n arr[2]=s1[0];\n if(s3[1]=='>')\n {\n arr[0]=s3[2];\n arr[1]=s3[0];\n }\n else if(s3[1]=='<')\n {\n arr[0]=s3[0];\n arr[1]=s3[2];\n }\n\n }\n else if(s1[2]==s2[2])\n {\n arr[0]=s1[2];\n if(s3[1]=='>')\n {\n arr[1]=s3[2];\n arr[2]=s3[0];\n }\n else if(s3[1]=='<')\n {\n arr[1]=s3[0];\n arr[2]=s3[2];\n }\n\n }\n else if(s1[0]==s2[2])\n {\n arr[1]=s1[0];\n if(s3[1]=='>')\n {\n if(s3[0]==s2[0]&&s3[2]==s1[2])\n {arr[0]=s3[2];arr[2]=s3[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s3[0]==s1[0]&&s3[2]==s2[2])\n {arr[0]=s3[2];arr[2]=s3[0];}\n else{ cout<<\"Impossible\"<')\n {\n arr[1]=s3[2];\n arr[2]=s3[0];\n }\n else if(s3[1]=='<')\n {\n arr[1]=s3[0];\n arr[2]=s3[2];\n }\n\n }\n else if(s1[2]==s2[2])\n {\n arr[2]=s1[2];\n if(s3[1]=='>')\n {\n arr[1]=s3[2];\n arr[0]=s3[0];\n }\n else if(s3[1]=='<')\n {\n arr[0]=s3[0];\n arr[1]=s3[2];\n }\n\n }\n else if(s1[0]==s2[2])\n {\n arr[1]=s1[0];\n if(s3[1]=='>')\n {\n if(s3[0]==s1[2]&&s3[2]==s2[0])\n {arr[0]=s3[2];arr[2]=s3[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s3[0]==s2[2]&&s3[2]==s1[0])\n {arr[0]=s3[2];arr[2]=s3[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s1[0]==s3[0])\n {\n arr[2]=s1[0];\n if(s2[1]=='>')\n {\n arr[0]=s2[2];\n arr[1]=s2[0];\n }\n else if(s2[1]=='<')\n {\n arr[0]=s2[0];\n arr[1]=s2[2];\n }\n\n }\n else if(s1[2]==s3[2])\n {\n arr[0]=s1[2];\n if(s2[1]=='>')\n {\n arr[1]=s2[2];\n arr[2]=s2[0];\n }\n else if(s2[1]=='<')\n {\n arr[1]=s2[0];\n arr[2]=s2[2];\n }\n\n }\n else if(s1[0]==s3[2])\n {\n arr[1]=s1[0];\n if(s3[1]=='>')\n {\n if(s2[0]==s3[0]&&s2[2]==s1[2])\n {arr[0]=s2[2];arr[2]=s2[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s2[0]==s1[0]&&s2[2]==s3[2])\n {arr[0]=s2[2];arr[2]=s2[0];}\n else{ cout<<\"Impossible\"<')\n {\n arr[1]=s2[2];\n arr[2]=s2[0];\n }\n else if(s2[1]=='<')\n {\n arr[1]=s2[0];\n arr[2]=s2[2];\n }\n\n }\n else if(s1[2]==s3[2])\n {\n arr[2]=s1[2];\n if(s2[1]=='>')\n {\n arr[1]=s2[2];\n arr[0]=s2[0];\n }\n else if(s2[1]=='<')\n {\n arr[0]=s2[0];\n arr[1]=s2[2];\n }\n\n }\n else if(s1[0]==s3[2])\n {\n arr[1]=s1[0];\n if(s2[1]=='>')\n {\n if(s2[0]==s1[2]&&s2[2]==s3[0])\n {arr[0]=s2[2];arr[2]=s2[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s2[0]==s3[2]&&s2[2]==s1[0])\n {arr[0]=s2[2];arr[2]=s2[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s2[0]==s3[0])\n {\n arr[2]=s2[0];\n if(s1[1]=='>')\n {\n arr[0]=s1[2];\n arr[1]=s1[0];\n }\n else if(s1[1]=='<')\n {\n arr[0]=s1[0];\n arr[1]=s1[2];\n }\n\n }\n else if(s2[2]==s3[2])\n {\n arr[0]=s2[2];\n if(s1[1]=='>')\n {\n arr[1]=s1[2];\n arr[2]=s1[0];\n }\n else if(s1[1]=='<')\n {\n arr[1]=s1[0];\n arr[2]=s1[2];\n }\n\n }\n else if(s2[0]==s3[2])\n {\n arr[1]=s2[0];\n if(s3[1]=='>')\n {\n if(s1[0]==s3[0]&&s1[2]==s2[2])\n {arr[0]=s1[2];arr[2]=s1[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s1[0]==s2[0]&&s1[2]==s3[2])\n {arr[0]=s1[2];arr[2]=s1[0];}\n else{ cout<<\"Impossible\"<')\n {\n arr[1]=s1[2];\n arr[2]=s1[0];\n }\n else if(s1[1]=='<')\n {\n arr[1]=s1[0];\n arr[2]=s1[2];\n }\n\n }\n else if(s2[2]==s3[2])\n {\n arr[2]=s2[2];\n if(s1[1]=='>')\n {\n arr[1]=s1[2];\n arr[0]=s1[0];\n }\n else if(s1[1]=='<')\n {\n arr[0]=s1[0];\n arr[1]=s1[2];\n }\n\n }\n else if(s2[0]==s3[2])\n {\n arr[1]=s2[0];\n if(s1[1]=='>')\n {\n if(s1[0]==s2[2]&&s1[2]==s3[0])\n {arr[0]=s1[2];arr[2]=s1[0];}\n else{ cout<<\"Impossible\"<')\n {\n if(s1[0]==s3[2]&&s1[2]==s2[0])\n {arr[0]=s1[2];arr[2]=s1[0];}\n else{ cout<<\"Impossible\"<\nusing namespace std;\nconst int N=20;\nint last,n,maxn=-1e9,x;\nint main()\n{\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%d\",&x);\n\t\tmaxn=max(maxn,x);\n\t\tif(i==n)last=x;\n\t}\n\tprintf(\"%d\",maxn^last);\n\treturn 0;\n}\n/*\n\n*/\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "922cfe872530b11faa346ffcd3115f05", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint n,m;\nstring a,b;\nmap mp;\nint main()\n{\n cin>>a>>b;\n n=m[a],m=m[b],mp[\"monday\"]=1,mp[\"tuesday\"]=2,mp[\"wednesday\"]=3,mp[\"thursday\"]=4,mp[\"friday\"]=5,mp[\"saturday\"]=6,mp[\"sunday\"]=7;\n\tif((m-n+77777)%7==0||(m-n+77777)%7==2||(m-n+77777)%7==3) cout<<\"YES\";\n\telse cout<<\"NO\";\n\treturn 0; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "92dcaab233d7e76a9711624bdf1613c6", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "GNU C++20 (64)", "source_code": "#inclide \n#include \n\ntypedef long long int ll;\ntypedef long double ld;\n#define pb push_back\n#define pii pair < int , int >\n#define F first\n#define S second\n#define endl '\\n'\n#define int long long\n#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)\n#pragma GCC optimize(\"Ofast,no-stack-protector,unroll-loops,fast-math\")\n#define kill(x) return cout<> n >> mod;\n fac[0]=fm[0]=1;\n for (int i=1;imax((ll)0,n-20);a0--){\n /// fix adad aval\n memset(dp,0,sizeof dp);\n memset(pd,0,sizeof pd);\n// for (int i=1;i<=n+1;i++){\n// if (i*a0<=a0*a0) {\n// dp[i][0][0][0]+=fm[i];\n// pd[i][0][0]+=fm[i];\n// dp[i][0][0][0]%=mod;\n// pd[i][0][0]%=mod;\n// }\n// }\n \n for (int i=2;i<=n;i++){\n memset(dp,0,sizeof dp);\n if (i*a0<=a0*a0) {\n dp[0][0][0]+=fm[i];\n pd[i][0][0]+=fm[i];\n dp[0][0][0]%=mod;\n pd[i][0][0]%=mod;\n }\n for (int j=1;j<=n+1-a0;j++){\n for (int jam=j;jam<=n+1;jam++){\n for (int t=1;t<=(n+1)/j;t++){\n /// t tayii ke ezafe mishan barabar bashan\n if (jam>=t && j>1){\n dp[j][jam][t]+=dp[j-1][jam-t][t];\n dp[j][jam][t]%=mod;\n }\n if (jam>=t*j && t=a0*i+jam){\n pd[i][j][jam]+=dp[j][jam][t];\n pd[i][j][jam]%=mod;\n }\n }\n }\n }\n \n }\n for (int i=0;i<=n+1-a0;i++){\n for (int j=0;j<=n+1;j++){\n ans+=pd[n][i][j]*fac[n]%mod;\n ans%=mod;\n }\n }\n // cout << a0 << \" \" << ans << endl;\n\n }\n cout << ans%mod << endl;;\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "df1f8ad73b13e4abc2b2b5a2cf6046b7", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nconst int N=100;\nconst int inf=1e9+7;\nint arr[N];\nint main(){\n\tint n,k;\n\tscanf(\"%d\",&n,&k);\n\tfor(int i=1;i<=n;i++) scanf(\"%d\",&arr[i]);\n\tsort(arr+1 ,arr+1+n);\n\tint cnt=0;\n\tint ans=inf;\n\tint k1=0;\n\tfor(int i=1;i<=n;i++){\n\t\tcnt=0,k1=0;\n\t\tfor(int j=i+1;j<=n;j++){\n\t\t\tint x=arr[j]; \n\t\t\twhile(x>arr[i]){\n\t\t\t\tcnt++;\n\t\t\t\tx/=2;\n\t\t\t}\n\t\t\tif(x==arr[i])\tk1++; \n\t\t\tif(k1==k-1) break;\n\t\t}\n\t\tif(k1==k-1)\n\t\t\tans=min(ans,cnt);\n\t}\n\tint sum=0;\n\tif(ans==inf){\n\t\tfor(int i=1;i<=n;i++){\n\t\t\twhile(arr[i]>0) {\n\t\t\t\tsum++;\n\t\t\t\tarr[i]/=2;\n\t\t\t}\n\t\tprintf(\"%d\\n\",sum);\n\t}\n\telse \n\t\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7d1b37136a9eebbf48662cdf091fe436", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nint main()\n{\n int n;\n\n while(scanf(\"%d\",&n)!=EOF)\n {\n printf(\"%d\\n\",(int)pow(3,n-1));\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4cd9f289280be9c7e684a9919af70ee1", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\nconst ll DELTA = 1000000007, maxn = 100 + 7;\nll k, m, n;\nll ans[maxn][maxn*maxn], chooseMem[maxn][maxn];\nbool isCeil[maxn];\n\nint power(ll base,ll p) {\n ll ans = 1;\n while (p > 0) {\n \tif (p % 2) {\n \t\tans *= base;\n \t\tans %= DELTA;\n \t}\n \tbase *= base;\n \tbase %= DELTA;\n \tp >>= 1;\n }\n return ans;\n}\n\nll choose(ll r, ll n) {\n\tif (chooseMem[r][n] != -1) return chooseMem[r][n];\n\tif (r < 0 or r > n) return 0;\n\tif (r == 0 or r == n) return 1;\n\tchooseMem[r][n] = choose(r, n - 1) + choose(r - 1, n - 1);\n\tchooseMem[r][n] %= DELTA;\n\treturn chooseMem[r][n];\n}\n\nint main() {\n cin >> n >> m >> k;\n \n memset(chooseMem, -1, sizeof chooseMem);\n\n ll flo = (m / n),cei = (m / n) + 1;\n int r = m % n;\n \n for (int i = 0; i < n; i++){\n if (i > 0 and i <= r){\n isCeil[i] = true;\n }\n }\n \n for (int i = 0; i <= n; i++){\n if(isCeil[1]){\n ans[1][i] += power(choose(i, n), cei);\n ans[1][i] %= DELTA;\n }\n else {\n ans[1][i] += power(choose(i, n), flo);\n ans[1][i] %= DELTA;\n }\n }\n \n for(int i = 2; i <= n; i++){\n for (int j = 0; j <= (n*n); j++){\n for (int k = 0; k<=n ;k++){\n if(k <= j){\n if(isCeil[i]){\n ans[i][j] += ans[i-1][j-k] * powerMem[k][1];\n ans[i][j] %= DELTA;\n }\n else {\n ans[i][j] += ans[i-1][j-k] * powerMem[k][0];\n ans[i][j] %= DELTA;\n }\n }\n }\n }\n }\n \n cout << ans[n][k] << endl;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f8883a072666e0a285f9b03f92236028", "src_uid": "9c71c8e031412e2bb21266a53821626a", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include\n#pragma GCC optimize(\"O3\")\n#define fi first\n#define se second\n#define pb push_back\n#define pf push_front\n#define mod 998244353\n\nusing namespace std;\n\ntypedef long long ll;\n\nll add(ll a, ll b)\n{\n ll x = a+b;\n if(x >= mod)\n x -= mod;\n return x;\n}\nll mul(ll a, ll b)\n{\n return (a*b) % mod;\n}\n\nint n;\nvectorwd[12];\nll ans = 0;\nll ch[200][200];\nint cod(char c)\n{\n if(c >= '0' && c <= '9')\n return (c - '0');\n if(c >= 'A' && c <= 'Z')\n return 10 + (c - 'A');\n if(c >= 'a' && c <= 'z')\n return 36 + (c - 'a');\n}\nll dp(int len)\n{\n memset(ch, 0, sizeof(ch));\n for(int i = 0; i < wd[len].size(); ++i)\n {\n string s = wd[len][i];\n bool pal = 1;\n for(int j = 0; j < s.size(); ++j)\n if(s[j] != s[s.size() - j - 1])\n pal = 0;\n if(pal)\n ch[cod(s[j])][cod(s[s.size() - 1])]++;\n else\n ch[cod(s[j])][cod(s[s.size() - 1])]++, ch[cod(s[j])][cod(s[s.size() - 1])]++;\n }\n ll anss = 0;\n for(int i = 0; i <= 5; ++i)\n for(int j = 0; j <= 5; ++j)\n for(int k = 0; k <= 5; ++k)\n for(int p = 0; p <= 5; ++p)\n {\n ll prod = ch[i][j] * ch[j][k] * ch[k][p] * ch[p][k];\n prod %= mod;\n for(int z = 0; z <= 5; ++z)\n for(int u = 0; u <= 5; ++u)\n for(int x = 0; x <= 5; ++x)\n for(int o = 0; o <= 5; ++o)\n {\n ll prod2 = ch[i][z] * ch[j][u] * ch[k][x] * ch[p][o];\n prod2 %= mod;\n ll prod3 = ch[z][u] * ch[u][x] * ch[x][o] * ch[o][z];\n prod3 %= mod;\n anss += (((1LL * prod * prod2) % mod) * prod3) % mod;\n anss %= mod;\n }\n }\n return anss;\n}\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cin >> n;\n for(int i = 1; i <= n; ++i)\n {\n string s;\n cin >> s;\n wd[s.size()].pb(s);\n }\n for(int i = 3; i <= 10; ++i)\n ans += dp(i), ans %= mod;\n cout << ans;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5ddcc2bcfcf1c7f1d1512141c6d92c18", "src_uid": "92ed1015b43f4b610cd7956db8588a9e", "difficulty": null} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nlong long ans,Ans[32005]={0};\nlong long t1,R,t2;\nint main(){\n int n,m,i,j,k,l,L;\n scanf(\"%d%d\",&n,&m);\n L=n+1;\n for(i=m+1;i<=n-m;i++){\n if(i*2>L){\n Ans[i]=Ans[L-i];\n continue;\n }\n t1=2*((long long)i)*L-2*((long long)i)*i;\n t2=(m+1)*(L-i)+1;\n k=L-i;\n for(j=m+1;j<=n-m;j++,t2+=k){\n R=(t1-t2)/(i+j);\n if(R<=m)break;\n R=(R>n-m?n-m:R);\n Ans[i]+=(R-m);\n }\n }\n for(i=m+1;i<=n-m;i++)ans+=Ans[i];\n ans*=3;\n printf(\"%I64d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7ee4541a850a34655b05f1b5f55cbfdd", "src_uid": "355cc23d7a4addfc920c6e5e72a2bb64", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "/*\nID: anoop_n1\nLANG: C++\nTASK:\n*/\n#include\nint main ()\n{\n// freopen(\".in\",\"r\",stdin);\n// freopen(\".out\",\"w\",stdout);\n int r1,r2,c1,c2,d1,d2,x1,x2,y1,y2,temp;\n scanf(\"%d%d%d%d%d%d\",&r1,&r2,&c1,&c2,&d1,&d2);\n temp = r2 + d1 - c1\n y2 = (r2 + d1 - c1)/2;\n x2 = r2 - y2;\n x1 = d1 - y2;\n y1 = d2 - x2;\n if(y2 == x2 || x2 == x1 || x1 == y1|| y2 == x1 || x2 == y1 || y2 == y1 || x1 ==0 || y1 == 0 || x2 ==0 || y2 == 0 || temp%2 == 1)\n printf(\"-1\");\n else\n printf(\"%d %d\\n%d %d\",x1,y1,x2,y2);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "82d10488df3b764360f62a956779a9fc", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\tlong long n, k;\n\tvector result;\n\tcin >> n >> k;\n\tint s = sqrt(n);\n\t// cout << s << endl;\n\tfor(int i = 1; i <= s; i++){\n\t\tif(n % i == 0) {\n\t\t\tresult.push_back(i);\n\t\t\tif(n/i != i) result.push_back(n/i);\n\t\t}\n\t\t\n\t}\n\tsort(result.begin(), result.end());\n\tif(result.size() >= k) cout << result[k - 1] << endl;\n\telse cout << -1 << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "56c2fe975cc1ede5ad71cdeeab8888b2", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main {\n int k,r;\n cin >> k >> r;\n \n if(k%10 == 0)\n { cout << 1;\n return 0;\n }\n\n int t = k%10;\n int ans = 10;\n int p = t;\n for(int i=1;i<10;i++)\n {\n if(p%10 == r)\n {\n cout << i;\n return 0;\n }\n p = p+t;\n }\n cout << 10;\n return 0; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f39b292e1cf17272d66afe1123993d41", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \"bits/stdc++.h\"\n#include \"ext/pb_ds/assoc_container.hpp\"\n#include \"ext/pb_ds/tree_policy.hpp\"\nusing namespace std;\nusing namespace __gnu_pbds;\n \ntemplate \nusing ordered_set = tree, rb_tree_tag,tree_order_statistics_node_update> ;\n \ntemplate>\nusing ordered_map = tree;\n\n \ntemplate\nusing min_heap = priority_queue,greater >; \n \nstruct custom_hash { \n static uint64_t splitmix64(uint64_t x) {\n x += 0x9e3779b97f4a7c15;\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\n return x ^ (x >> 31);\n }\n \n size_t operator()(uint64_t x) const {\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n return splitmix64(x + FIXED_RANDOM);\n }\n size_t operator()(pair Y) const{\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n return splitmix64(Y.first * 31 + Y.second + FIXED_RANDOM);\n }\n};\n \ntemplate ostream& operator<<(ostream &os, vector V) {\n os << \"[ \";\n for(auto v : V) os << v << \" \";\n return os << \"]\";\n}\ntemplate istream& operator>>(istream &is, vector& V) {\n for(auto &e : V)\n is >> e;\n return is;\n}\n \n#ifdef __SIZEOF_INT128__\nostream& operator << (ostream &os, __int128 T){\n const static long long N = (1'000'000'000'000'000'000);\n if (T < 0){\n os << '-';\n T *= -1;\n }\n \n unsigned long long b = T%N;\n T /= N;\n if (T == 0)\n return os << b ;\n unsigned long long a = T % N;\n T /= N;\n if (T == 0){\n os << a;\n __int128 mul = 10;\n int cnt = 0;\n while( mul*b < N && cnt < 17){\n os << '0';\n mul *= 10;\n ++cnt;\n }\n return os << b;\n }\n os << ((long long) T);\n \n __int128 mul = 10;\n int cnt = 0;\n while( mul*a < N && cnt < 17){\n os << '0';\n mul *= 10;\n ++cnt;\n }\n os << a;\n mul = 10;\n cnt = 0;\n while( mul*b < N && cnt < 17){\n os << '0';\n mul *= 10;\n ++cnt;\n }\n return os << b;\n \n}\nistream& operator >> (istream& is, __int128& T){\n string U;\n is >> U;\n T = 0;\n size_t pos = 0;\n int mul = 1;\n if (U[pos] == '-'){\n ++pos;\n mul *= -1;\n }\n for(; pos < U.size(); ++pos){\n T *= 10;\n T += (U[pos] - '0');\n }\n T *= mul;\n \n return is;\n}\n#endif\ntemplate ostream& operator<<(ostream &os, set S){\n os << \"{ \";\n for(auto s:S) os< ostream& operator<<(ostream &os, unordered_set S){\n os << \"{ \";\n for(auto s:S) os< ostream& operator << (ostream& os, multiset S){\n os << \"{ \";\n for(auto s:S) os< ostream& operator<<(ostream &os, ordered_set S){\n os << \"{ \";\n for(auto s:S) os< ostream& operator<<(ostream &os, pair P) {\n return os << \"(\" << P.first << \",\" << P.second << \")\";\n}\ntemplate ostream& operator<<(ostream &os, map M) {\n os << \"{ \";\n for(auto m:M) os<<\"(\"<> ostream& operator<<(ostream &os, unordered_map M) {\n os << \"{ \";\n for(auto m:M) os<<\"(\"< > ostream& operator<<(ostream &os, gp_hash_table M) {\n os << \"{ \";\n for(auto m:M) os<<\"(\"<\n void __f(const char* name, Arg1&& arg1){\n cerr << name << \" : \" << arg1 << endl;\n }\n template \n void __f(const char* names, Arg1&& arg1, Args&&... args){\n const char* comma = strchr(names + 1, ',');\n cerr.write(names, comma - names) << \" : \" << arg1<<\" | \";\n __f(comma+1, args...);\n }\n#else\n #define trace(...) 1\n#endif\n \nmt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());\n \ninline int64_t random_long(long long l,long long r){\n uniform_int_distribution generator(l,r);\n return generator(rng);\n}\ninline int64_t random_long(){\n uniform_int_distribution generator(LLONG_MIN,LLONG_MAX);\n return generator(rng);\n}\n \n \n/*/---------------------------Defines----------------------/*/\ntypedef vector vi;\ntypedef pair pii;\n \n#define For(i,n) for(int i = 0; i < (int) n; ++i)\n#define Rep(i,n) for(int i = 1; i <= (int) n; ++i)\n#define ll long long\n#define F first\n#define S second\n#define pb push_back\n#define endl \"\\n\"\n#define all(v) (v).begin(),(v).end()\n/*/-----------------------Modular Arithmetic---------------/*/\n \nconst int mod=1e9+7;\n \n/*/-----------------------------Code begins----------------------------------/*/\n\t\n \nstruct pt{\n\tint x, y, id;\n \n\tbool operator < (const pt& A) const{\n\t\treturn make_pair(x, y) < make_pair(A.x, A.y);\n\t}\n \n\tinline int distance(const pt& A) const{\n\t\treturn min(abs(A.x - x), abs(A.y - y));\n\t}\n \n\tinline int distance2(const pt& A) const{\n\t\treturn abs(A.x - x) + abs(A.y - y);\n\t}\n};\n \n \nbool cmp(const pt& A, const pt& B){\n\treturn make_pair(A.y, A.x) < make_pair(B.y, B.x);\n}\n \n \nconst int N = 3e5 + 10;\nvector> adj[N];\n\nbool check(int sum, int n) {\n\treturn sum * 10 >= n * 45;\n}\n \nvoid solve(){\n\tint n,c=0;\n\tcin>>n;\n\tint s=0;\n\tvector v(n);\n\tfor(int i=0;i>a[i];\n\t\ts+=v[i];\n\t}\n\tsort(v.begin(),v.end());\n\tc=0;\n\twhile(!check(s,n)){\n\t\ts+=5-v[c];\n\t\tc++;\n\t}\n\tcout<>t;\n while(t--){*/\n solve();\n auto stop = std::chrono::high_resolution_clock::now(); \n auto duration = std::chrono::duration_cast(stop - start); \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "80ab2c34357271183f5e90e963dc98fa", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n int d, l, v1, v2;\n scanf(\"%d %d %d %d\", &d, &l, & v1, &v2);\n double ans = (double)(l-d)/(v1+v2);\n printf(\"%.7f\", ans);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fd44a2680f7b7a543fe217fc6024f87d", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int n,flg;\n cin>>n;\n int g=n,cnt=0,m=1;\n int a[10000];\n for(int i = 2;i\n#include \n#include \n#include \n\nusing namespace std;\n\nconst int maxn = 100010;\n\nstruct Node {\n\tint c_a, c_b, c_c, r_a, len;\n} tr[2][maxn<<2];\n\nint l_s, l_t, Q;\nchar S[maxn], T[maxn];\n\nNode operator+(const Node &a, const Node &b) {\n\tNode ret;\n\tret.len = a.len+b.len;\t\n\tret.c_a = a.c_a+b.c_a;\n\tret.c_b = a.c_b+b.c_b;\n\tret.c_c = a.c_c+b.c_c;\n\tret.r_a = b.r_a;\n\tif (b.len == b.c_a)\n\t\tret.r_a = a.r_a+b.len;\n\treturn ret;\n}\n\nvoid pushUp(int in, int rt) {\n\ttr[in][rt] = tr[in][rt<<1] + tr[in][rt<<1|1];\n}\n\nvoid build(int in, int l, int r, int rt) {\n\tif (l == r) {\n\t\ttr[in][rt].len = 1;\n\t\tif (in == 0) {\n\t\t\ttr[in][rt].c_a = (S[l] == 'A');\n\t\t\ttr[in][rt].c_b = (S[l] == 'B');\n\t\t\ttr[in][rt].c_c = (S[l] == 'C');\n\t\t\ttr[in][rt].r_a = tr[in][rt].c_a;\n\t\t} else {\n\t\t\ttr[in][rt].c_a = (T[l] == 'A');\n\t\t\ttr[in][rt].c_b = (T[l] == 'B');\n\t\t\ttr[in][rt].c_c = (T[l] == 'C');\n\t\t\ttr[in][rt].r_a = tr[in][rt].c_a;\n\t\t}\n\t\treturn;\n\t}\n\tint m = (l + r) >> 1;\n\tbuild(in, l, m, rt<<1);\n\tbuild(in, m+1, r, rt<<1|1);\n\tpushUp(in, rt);\n}\n\nNode query(int in, int L, int R, int l, int r, int rt) {\n\tif (L <= l && r <= R) {\n\t\treturn tr[in][rt];\n\t}\n\tNode ret;\n\tint m = (l + r) >> 1;\n\tret.c_a = ret.c_b = ret.c_c = ret.r_a = ret.len = 0;\n\tif (L <= m) ret = ret + query(in, L, R, l, m, rt<<1);\n\tif (R > m) ret = ret + query(in, L, R, m+1, r, rt<<1|1);\n\treturn ret;\n}\n\nint main() {\n\tscanf(\"%s%s\", S+1, T+1);\n\tl_s = int(strlen(S+1));\n\tl_t = int(strlen(T+1));\n\tbuild(0, 1, l_s, 1);\n\tbuild(1, 1, l_t, 1);\n\tscanf(\"%d\", &Q);\n\twhile (Q--) {\n\t\tint a, b, c, d;\n\t\tscanf(\"%d%d%d%d\", &a, &b, &c, &d);\n\t\tNode s, t;\n\t\ts = query(0, a, b, 1, l_s, 1);\n\t\tt = query(1, c, d, 1, l_t, 1);\n\t\tif (s.r_a < t.r_a) {\n\t\t\tprintf(\"0\");\n\t\t\t//cout << s.r_a << \" \" << t.r_a << endl;\n\t\t} else {\n\t\t if (s.c_a == s.len && t.c_a != t.len) {\n\t\t if (s.r_a-1 < t.r_a) {\n\t\t printf(\"0\");\n\t\t continue;\n\t\t }\n\t\t s.r_a --;\n\t\t s.r_b ++;\n\t\t s.r_c ++;\n\t\t }\n\t\t\tint c = s.r_a-t.r_a;\n\t\t\ts.r_a -= 3*(c/3);\n\t\t\tint s_cnt = s.c_b+s.c_c;\n\t\t\tif (s.r_a > t.r_a)\n\t\t\t\ts_cnt += 2;\n\t\t\tint t_cnt = t.c_b+t.c_c;\n\t\t\t//cout << s_cnt << \" \" << t_cnt << endl;\n\t\t\tif (s_cnt > t_cnt) printf(\"0\");\n\t\t\telse {\n\t\t\t\tif ((t_cnt-s_cnt)%2 == 0) {\n\t\t\t\t\tprintf(\"1\");\n\t\t\t\t} else printf(\"0\");\n\t\t\t} \n\t\t}\n\t\t//if s_r_a < t_r_a false\n\t\t//else\n\t\t//s_c_b+s_c_c+(s_c_a-(s_r_a-t_r_a))*2==t_c_b......\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "355243997239569f69ae19a63056dcd9", "src_uid": "98e3182f047a7e7b10be7f207b219267", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n#define mod 1000000007\n#define ll long long\nll ans=1,n;\nbool isprime(ll n) {\n\tif (n < 2) return 0;\n\tif (n == 2) return 1;\n\tif (n % 2 == 0) return 0;\n\tfor (ll i = 3; i*i <= n; i++) if (n%i == 0) return 0;\n\treturn 1;\n}\n\nll c(ll n,ll k)\n{\n\tll res=0,p=k;\n\twhile(p<=n)\n\t{res+=n/p; p*=k;}\n\treturn res;\n}\nll power(ll a,ll b)\n{\n\tif(b==0)\n\t\treturn 1;\n\tif(b%2==0)\n\t{\n\t\tll r=power(a,b/2);\n\t\treturn (r*r)%mod;\n\t}\n\telse\n\t\treturn (power(a,b-1)*a)%mod;\n}\nint main()\n{\n\tscanf(\"%d\", &n);\n\tfor(ll i=2;i<2*n;i++)\n\t{\n\t\tif(isprime(i))\n\t\t\tans=(ans * power(i, c(2*n-1,i)-c(n,i)-c(n-1,i) ) )%mod;\n\t}\n\tans=(2*ans+mod-n)%mod;\n\tprintf(\"%d\\n\", res);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4024a3638120b5f057fa608afa4b46e8", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint f(long long x,long long y,long long x1,long long y1)\n{\n double t=double(x*x1+y*y1)/sqrt(double(x1*x1+y1*y1));\n if(t-round(t)>1e-6)return 0;\n x1^=y1;y1^=x1;x1^=y1;\n t=double(x*x1+y*y1)/sqrt(double(x1*x1+y1*y1));\n if(t-round(t)>1e-6)return 0;\n return 1; \n}\nint main(){\n long long q,w,e,r,t,y;\n cin >>q >>w>>e>>r>>t>>y;\n long long tq=q;long long tw=w;\n for(int i=0;i<4;i++){\n q=-tw;w=tq;\n if(f(e-q,r-w,t,y))return(cout << \"YES\"),0;\n }\n cout \"NO\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b731f4547cf0396f239a0f34bc031cbe", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\n#define INF 0x7fffffff\n#define inf 0x3f3f3f3f\n#define love const \n#define I inline \n#define ll long long\n#define lc (now<<1)\n#define rc (now<<1|1)\n#define R register\n#define lson lc,l,mid\n#define rson rc,mid+1,r\n#define rep(i,a,b)for(R int i=a;i<=b;i++)\n#define per(i,a,b)for(R int i=a;i>=b;i--) \n#define pii pair\n#define re register\n#define love const\n#define debug cout<<\"%\"<I void read(T &x,T2 &... oth){\n x=0;R short y=0;R char ch=gc();\n for(;!isdigit(ch);ch=gc())y=ch=='-';\n for(;isdigit(ch);ch=gc())x=x*10+(ch^48);\n (y)&&(x=-x);read(oth...);return;}\n I void flush(){fwrite(buffer,1,p1+1,stdout);p1=-1;return;}\n I void pc(int ch){if(p1==p2)flush();buffer[++p1]=ch;return;}\n templateI void write(T x){\n static char buf[20];static short len =-1;\n if(x>=0){do buf[++len]=(x%10)^48,x/=10;while(x);}\n else{pc ('-');do buf[++len]=(-(x%10))^48,x/=10;while(x);}\n while(len>=0)pc(buf[len--]);return;}\n templateI void Write(T x,T2... oth){write(x),pc('\\n'),Write(oth...);return;}\n }\n#define ll long long\n#define int long long\nusing namespace IO;\nlove int N =1050;\nlove int mod =1e9+7;\nint c1,c2;int ans =0;\nint n,m,x,pos,c[1000][500];\nI void get(){\n fac[0]=1;\n rep(i,1,n)fac[i]=fac[i-1]*i%mod;\n c[1][1]=c[1][0]=c[0][0]=1;\n rep(i,2,N)\n { c[i][0]=1;\n rep(j,1,i)\n {\n c[i][j]=c[i-1][j]+c[i-1][j-1];\n c[i][j]%=mod;\n }\n }\n return;\n}\nI int work(int x,int y)\n{ \n if(y==1)return c[x][1];\n if(y==0)return c[x][0];\n return work(x-1,y-1)*x%mod; \n}\nsigned main()\n{ get();\n read(n,x,pos);\n int l=0;int r=n;\n while(lpos)c1++,r=mid;\n else l=mid+1;\n }\n // cout<\nusing namespace std;\nint lp(int x)\n{\n if((x%100==0&&x%400==0)||(x%100!=0&&x%400!=0&&x%4==0))return 1;\n else return 0;\n}\nint main()\n{\n int i,j,k,l,n,m;\n while(scanf(\"%d\",&n)==1){\n k=lp(n);\n if(k==0){\n for(l=0,i=n+1;i<=n+5;i++){\n if(lp(i)==1)l++;\n }\n if(l==1){\n printf(\"%d\\n\",n+6);\n }\n else{\n printf(\"%d\\n\",n+7);\n }\n }\n else{\n ///if(lp(n+28)==1)printf(\"%d\\n\",n+28);\n else printf(\"%d\\n\",n+28);\n }\n }\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a7c9f5348af25f555d4487f1be216c6e", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint f[30],a,b,c;\nint main()\n{\n cin>>a>>b>>c;\n k[0]=a;\n k[1]=b;\n for(int i=2;i\n#include\nusing namespace std;\nint a[3];\nint main(){\n\twhile(scanf(\"%d%d%d\",&a[0],&a[1],&a[2])!=EOF){\n\t\tsort(a,a+3);\n\t\tif(a[0]==0 && (a[1]==a[2])){\n\t\t\tcout<\n#include \n#include \nusing namespace std;\n\nlong long omar(long long x, int y){\n\tint j = x % 2;\n\tif (j == 0)y++;\n\tx = x / 2;\n\n\tif (x == 0)return y;\n\treturn (omar(x, y));\n}long long osman(long long x, long long y){\n\n\tx = x / 2;\n\ty++;\n\tif (x == 0)return y;\n\treturn (osman(x, y));\n}\n\nint bakr(long long h, int g){\n\tif (h % 2 == 0){\n\t\tg = 0;\n\t}\n\telse{ g++; \n\t}\n\th = h / 2;\n\tif (h == 0)return g;\n\treturn bakr(h, g);\n\n\n\n}\nint main(){\n\t\n\t\tint x = 0;\n\t\tint x2 = 0;\n\t\tlong long a, b;\n\t\tcin >> a >> b;\n\t\tint N = osman(a, 0);\n\t\tint N2 = osman(b, 0);\n\t\tint Z = omar(a, 0);\n\t\tint Z2 = omar(b, 0);\n\t\tif (Z > 1 || Z == 1)N=N-2;\n\t\tif (Z == 0)N--;\n\t\t\n\t\tx = x + bakr(a, 0) - 1;\n\n\t\tx = x + N*(N + 1) / 2;\n\t\tif (Z2 > 1)N2 = N2 - 2;\n\t\tif (Z2 == 1){\n\t\t\tN2 = N - 2;\n\t\t\tx2++;\n\t\t}if (Z2 == 0)N2--;\n\t\tx2 = x2 + bakr(b, 0) - 1;\n\t\tx2 = x2 + N2*(N2 + 1) / 2;\n\t\tcout << x2 - x;\n\t}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5de5c90656f72f845cf90989b6f7c7e7", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define int long long\n \nint main(){\n ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n int n;\n cin>>n;\n vector v;\n int temp = n;\n int arr[6] = {4, 1, 3, 2, 0, 5};\n int cnt = 0;\n int ans = 0;\n while(temp > 0){\n if(temp%2 == 1){\n ans += pow(2, arr[cnt]);\n }\n temp/=2;\n cnt++;\n }\n cout<\n#include\n#include\n#define ll long long\n#define maxn 100\nusing namespace std;\nint n,m;\nchar hi[maxn],ri[maxn]\nint ri[10];\n\nint main()\n{\n\tscanf(\"%d %d\\n\",&n,&m);\n\tfor(register int i=1;i<=n;++i)scanf(\"%c\",&hi[i]);\n\tif(hi[1]=='>') ++ri[2];\n\telse ++ri[1];\n\tif(hi[n]=='>') ++ri[4];\n\telse ++ri[3];\n\tscanf(\"\\n\");\n\tfor(register int i=1;i<=m;++i)scanf(\"%c\",&ri[i]);\n\tif(ri[1]=='v') ++ri[3];\n\telse ++ri[1];\n\tif(ri[n]=='^') ++ri[2];\n\telse ++ri[4];\n\tint flag=1;\n\tfor(register int i=1;i<=4;++i)if(ri[i]>1)flag=0;\n\tif(flag)printf(\"YES\");\n\telse printf(\"NO\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "52ae6bdac975782a6b24ae0b296ec69b", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n// #pragma comment(linker, \"/STACK:102400000, 102400000\")\nusing namespace std;\ntypedef unsigned int li;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\nconst double pi = acos(-1.0);\nconst double e = exp(1.0);\nconst double eps = 1e-8;\nconst short maxlen = 205;\nchar str[maxlen];\nshort k;\nint main()\n{\n\tios::sync_with_stdio(false);\n\twhile (~scanf(\"%s%hd\", str, &k))\n\t{\n\t\tshort len = strlen(str);\n\t\tif (len <= k)\n\t\t{\n\t\t\tprintf(\"%d\\n\", (len + k) / 2 * 2);\n\t\t\tcontinue;\n\t\t}\n\t\tshort maxnum = 0;\n\t\tfor (short i = 0; i < len; i++)\n\t\t{\n\t\t\n\t\t\tfor (short j = 1; j <= len - i; j++)\n\t\t\t{\n\t\t\t\t\tshort cnt=0;\n\t\t\t\tfor (short s = i; s < i + j; s++)\n\t\t\t\t{\n\t\t\t\t\tif (s + j >= len && s + j < len + k)\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\telse if (s + j < len ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a4f1dc0ed643bf9dd22810c7345370e2", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std ;\n\nint main()\n{ int a,b,c,d,e,f,g,i ;\n cin >> a ;\n c=0\n for (i=1 ; i<=a ; i++)\n{ if (i%2==0 && i%3==0 && i%4==0 && i%5==0 && i%6==0 && i%7==0 && i%8==0 && i%9==0 && i%10==0)\n {c = c + 1 ;}}\n cout << c ;\n return 0 ; }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "610db1d7594c171f0f1e7f77e9710c02", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include // To use most bits rather than just the lowest ones:\n#include \nusing namespace std;\n\nstruct FastIO {\n FastIO() {\n srand(time(NULL));\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n cout.precision(12);\n };\n} fastIO_;\n\ntemplate \ninline ostream &operator<<(ostream &os, const pair &p) {\n return os << \"(\" << p.first << \", \" << p.second << \")\";\n}\n\ntemplate \ninline ostream &operator<<(ostream &os, const array &a) {\n os << \"[\";\n int cnt = 0;\n for (auto &val : a) {\n if (cnt++)\n os << \", \";\n os << val;\n }\n os << \"]\";\n return os;\n}\n\ntemplate \ninline ostream &operator<<(ostream &os, const vector &v) {\n os << \"[\";\n int cnt = 0;\n for (auto &val : v) {\n if (cnt++)\n os << \", \";\n os << val;\n }\n return os << \"]\";\n}\n\ntemplate inline ostream &operator<<(ostream &os, const set &v) {\n os << \"{\";\n int cnt = 0;\n for (auto &val : v) {\n if (cnt++)\n os << \", \";\n os << val;\n }\n return os << \"}\";\n}\n\ntemplate \ninline ostream &operator<<(ostream &os, const multiset &v) {\n os << \"{\";\n int cnt = 0;\n for (auto &val : v) {\n if (cnt++)\n os << \", \";\n os << val;\n }\n return os << \"}\";\n}\n\ntemplate \ninline ostream &operator<<(ostream &os, const map &v) {\n os << \"[\";\n int cnt = 0;\n for (auto &val : v) {\n if (cnt++)\n os << \", \";\n os << val;\n }\n return os << \"]\";\n}\n\n#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)\ntemplate void __f(const char *name, Arg1 &&arg1) {\n cerr << name << \": \" << arg1 << endl;\n}\ntemplate \nvoid __f(const char *names, Arg1 &&arg1, Args &&...args) {\n const char *comma = strchr(names + 1, ',');\n cerr.write(names, comma - names) << \": \" << arg1 << \" |\";\n __f(comma + 1, args...);\n}\n\n// types\n#define ll long long\n#define ull unsigned long long\n#define vi vector\n#define vll vector\n#define vvi vector>\n#define vs vector\n#define vb vector\n#define vvb vector>\n#define vc vector\n#define si set\n#define mpii map\n#define pii pair\n#define pll pair\n\n// names\n#define fi first\n#define se second\n#define mp(a, b) make_pair((a), (b))\n#define sz(a) ((int)(a).size())\n#define rep(i, s, t) for (int i = (s); i < (t); i++)\n#define repn(i, s) for (int i = 0; i < (s); i++)\n#define ms(a, b) memset(a, b, sizeof(a))\n#define all(a) (a).begin(), (a).end()\n#define bit(n, i) (((n) >> (i)) & 1)\n#define bitCount(n) __builtin_popcountll((n))\n\n// constants\nconst int dx[] = {-1, 1, 0, 0};\nconst int dy[] = {0, 0, 1, -1};\n\n// functions\ntemplate inline bool umin(T &a, const T b) {\n return b < a ? a = b, 1 : 0;\n}\ntemplate inline bool umax(T &a, const T b) {\n return a < b ? a = b, 1 : 0;\n}\ntemplate inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }\ntemplate inline T lcm(T a, T b) { return a / gcd(a, b) * b; }\n\n// =====================================================================================================================\n#define maxn 200006\nint n;\n\nstruct chash { // large odd number for C\n const uint64_t C = ll(4e18 * acos(0)) | 71;\n\n ll operator()(ll x) const { return __builtin_bswap64(x * C); }\n};\n\nint solve() {\n vi a(n + 1), cnt(101, 0);\n for (int i = 1; i <= n; i++) {\n cin >> a[i];\n cnt[a[i]]++;\n }\n\n int best = 0;\n for (int i = 1; i <= 100; i++) {\n if (cnt[i] > cnt[best])\n best = i;\n }\n\n int ans = 0;\n for (int i = 1; i <= 100; i++) {\n if (cnt[i] && i != best) {\n __gnu_pbds::gp_hash_table where({}, {}, {}, {},\n {1 << 16});\n where[0] = 0;\n\n int sum = 0;\n for (int j = 1; j <= n; j++) {\n if (a[j] == best)\n sum++;\n else if (a[j] == i)\n sum--;\n\n auto it = where.find(sum);\n if (it != where.end())\n umax(ans, j - (it->second));\n else\n where[sum] = j;\n }\n }\n }\n return ans;\n}\n\nvoid solve(int _cas) {\n // solve();\n cout << solve() << endl;\n}\n\nint main() {\n#ifndef ONLINE_JUDGE\n freopen(\"A.in\", \"r\", stdin);\n#endif\n while (cin >> n)\n solve(1);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "734ea692543b209cafa641fe11630df1", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nchar a[105],b[105];\nint main()\n{\n\tscanf(\"%s\\n%s\",a,b);\n\tint l=strlen(a),ans1=0,ans2=0;\n\tfor(int i=0;ians2)cout<<\"TEAM 1 WINS\";\n\telse if(ans1\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include\r\n#include \r\n#include \r\n#define int long long\r\n\r\nusing namespace std;\r\n\r\nmain() \r\n{\r\n vector p = {0, 1200, 1400, 1600, 1900, 2100, 2300, 2400, 2600, 3000};\r\n int r;\r\n cin>>r;\r\n int res, w=1000000;\r\n for(auto o: p)\r\n {\r\n if(abs(o-r)\n\nusing namespace std;\nint main()\n{\n\tint n, k;\n\tcin >> n;\n\tcin >> k;\n\tint a[100], b[100];\n\tfor (int i = 0; i < 100; i++)\n\t{\n\t\tb[i] = 0;\n\t}\n\tint max = 0;\n\tfor (int i = 0; i < 100; i++)\n\t{\n\t\tif (i < n)\n\t\t{\n\t\t\tcin >> a[i];\n\t\t\tb[a[i] - 1]++;\n\t\t\tif (b[a[i] - 1] > max)\n\t\t\t{\n\t\t\t\tmax = b[a[i] - 1];\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\ta[i] = 0;\n\t\t}\n\t}\n\tint kolvopr = 0;\n\tif (max % k == 0)\n\t{\n\t\tkolvopr = max;\n\t}\n\telse\n\t{\n\t\tkolvopr = ((max / k) + 1) * k;\n\t}\n\tint kolvo2 = 0;\n\tfor (int i = 0; i < 100; i++)\n\t{\n\t\tif (b[i] != 0)\n\t\t{\n\t\t\tkolvo2 += kolvopr - b[i];\n\t\t}\n\t}\n\tcout << kolvo2;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ea04250cc504e295f3453d2d1bb2b771", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long LL;\nbool check(int i, int j, int k){\n return i + j > k;\n}\nint main() {\n int n;\n scanf(\"%d\", &n);\n LL sum = 0;\n for (int i = 1; i <= n; ++i) {\n for (int j = 1;j <= n; ++j) {\n int k = (0 ^ i ^ j);\n if (check(i,j,k) && check(i,k,j) && check(j,k,i) && k <= n && 1 <= k){\n sum ++;\n }\n }\n }\n printf(\"%I64d\\n\", sum);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7827432c8fb95fb60b8f74fbe25dbd2a", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nmt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());\nconst int N = 2e3;\nint n,rem,sz = 2,cursz;\nbool vis[N];\nstruct node{\n\tint l,r,p,sz;\n\tint leafl,leafr;\n\tnode(){l = r = p = leafl = leafr = -1,sz = 0;}\n}g[N];\nint get(){\n\tg[rem].sz = 1;\n\treturn rem++;\n}\npair get(int u){\n\tif(u < n)return {-1,1};\n\tif(vis[u])return{-1,0};\n\tint sz = 0,mx = 0,cen = -1;\n\tpairtemp = get(g[u].l);\n\tcen = temp.first;\n\tsz+=temp.second;\n\tmx = max(mx,temp.second);\n\ttemp = get(g[u].r);\n\tcen = max(cen,temp.first);\n\tsz+=temp.second;\n\tmx = max(mx,temp.second);\n\tmx = max(mx,cursz - sz);\n\tif(mx <= (cursz + 1)/2)cen = u;\n\treturn {cen,sz};\n}\nchar ask(int a,int b,int c){\n\tchar ret;\n\tcout << a + 1 << \" \" << b + 1 << \" \" << c + 1 << endl;\n\tscanf(\" %c\",&ret);\n\treturn ret;\n}\nint getsz(int u){\n\tif(u < n)return 1;\n\tif(vis[u])return 0;\n\treturn getsz(g[u].l) + getsz(g[u].r);\n}\nint main(){\n\tscanf(\"%d\",&n);\n\trem = n;\n\tint root = get();\n\tg[root].l = 0;\n\tg[root].r = 1;\n\tg[0].p = g[1].p = root;\n\tfor(int i = 0;i < n;i++)g[i].sz = 1,g[i].leafl = g[i].leafr = i;\n\tg[root].sz = 1;\n\tg[root].leafl = 0;\n\tg[root].leafr = 1;\n\tfor(int i = 2;i < n;i++,sz++){\n\t\tmemset(vis,0,sizeof vis);\n\t\tfor(int i = 0;i < n;i++)vis[i] = 1;\n\t\tint cur = root;\n\t\twhile(1){\n\t\t\tcursz = getsz(cur);\n\t\t\tint cen = get(cur).first;\n\t\t\tif(g[cen].leafl == g[cen].leafr)cout << cen << endl;\n\t\t\tchar is = ask(g[cen].leafl,g[cen].leafr,i);\n\t\t\tif(is == 'Z'){\n\t\t\t\tif(vis[g[cen].l]){\n\t\t\t\t\tint left = g[cen].l;\n\t\t\t\t\tint temp = get();\n\t\t\t\t\tg[cen].l = temp;\n\t\t\t\t\tg[temp].p = cur;\n\t\t\t\t\tg[temp].l = left;\n\t\t\t\t\tg[temp].r = i;\n\t\t\t\t\tg[temp].leafl = g[left].leafl;\n\t\t\t\t\tg[temp].leafr = i;\n\t\t\t\t\tg[temp].sz = g[left].sz;\n\t\t\t\t\tg[i].p = g[left].p = temp;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tvis[cen] = 1;\n\t\t\t\tcur = g[cen].l;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(is == 'Y'){\n\t\t\t\tif(vis[g[cen].r]){\n\t\t\t\t\tint left = g[cen].r;\n\t\t\t\t\tint temp = get();\n\t\t\t\t\tg[cen].l = temp;\n\t\t\t\t\tg[temp].p = cur;\n\t\t\t\t\tg[temp].l = left;\n\t\t\t\t\tg[temp].r = i;\n\t\t\t\t\tg[temp].leafl = g[left].leafl;\n\t\t\t\t\tg[temp].leafr = i;\n\t\t\t\t\tg[temp].sz = g[left].sz;\n\t\t\t\t\tg[i].p = g[left].p = temp;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tvis[cen] = 1;\n\t\t\t\tcur = g[cen].r;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(g[cen].p == -1){\n\t\t\t\tint temp = get();\n\t\t\t\tg[cen].p = g[i].p = temp;\n\t\t\t\tg[temp].l = cen;\n\t\t\t\tg[temp].r = i;\n\t\t\t\tg[temp].sz = g[cen].sz;\n\t\t\t\tg[temp].leafl = g[cen].leafl;\n\t\t\t\tg[temp].leafr = i;\n\t\t\t\troot = temp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(vis[g[cen].p]){\n\t\t\t\tint temp = get();\n\t\t\t\tg[temp].leafl = g[cen].leafl;\n\t\t\t\tg[temp].leafr = i;\n\t\t\t\tg[temp].l = cen;\n\t\t\t\tg[temp].r = i;\n\t\t\t\tg[temp].p = g[cen].p;\n\t\t\t\tg[cen].p = g[i].p = temp;\n\t\t\t\tg[temp].sz = g[cen].sz;\n\t\t\t\tif(g[g[cen].p].l == cen)g[g[cen].p].l = temp;\n\t\t\t\telse g[g[cen].p].r = temp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tvis[cen] = 1;\n\t\t}\n\t\tcur = i;\n\t\twhile(g[cur].p != -1){\n\t\t\tg[cur].sz++;\n\t\t\tcur = g[cur].p;\n\t\t}\n\t}\n\tputs(\"-1\");\n\tfor(int i = 0;i < 2*n - 1;i++)printf(\"%d \",g[i].p == -1 ? - 1 : g[i].p + 1);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "98bea93bdfdd9c41205b5bdabd886ce7", "src_uid": "756b46a85b91346e189bb7c7646aa54f", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "\n/******** All Required Header Files ********/\n#include \n\nusing namespace std;\n\n/******* All Required define Pre-Processors and typedef Constants *******/\n#define SCD(t) scanf(\"%d\",&t)\n#define SCLD(t) scanf(\"%ld\",&t)\n#define SCLLD(t) scanf(\"%lld\",&t)\n#define SCC(t) scanf(\"%c\",&t)\n#define SCS(t) scanf(\"%s\",t)\n#define SCF(t) scanf(\"%f\",&t)\n#define SCLF(t) scanf(\"%lf\",&t)\n#define MEM(a, b) memset(a, (b), sizeof(a))\n#define FOR(i, j, k, in) for (int i=j ; i=k ; i-=in)\n#define REP(i, j) FOR(i, 0, j, 1)\n#define RREP(i, j) RFOR(i, j, 0, 1)\n#define all(cont) cont.begin(), cont.end()\n#define rall(cont) cont.end(), cont.begin()\n#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)\n#define IN(A, B, C) assert( B <= A && A <= C)\n#define MP make_pair\n#define PB push_back\n#define INF 0x3f3f3f3f\n#define EPS 1e-9\n#define PI 3.1415926535897932384626433832795\n#define MOD 1000000007\n#define read(type) readInt()\nconst double pi=acos(-1.0);\ntypedef pair PII;\ntypedef vector VI;\ntypedef vector VS;\ntypedef vector VII;\ntypedef vector VVI;\ntypedef map MPII;\ntypedef set SETI;\ntypedef multiset MSETI;\ntypedef long int int32;\ntypedef unsigned long int uint32;\ntypedef long long int int64;\ntypedef unsigned long long int uint64;\n\n/****** Template of some basic operations *****/\ntemplate inline void amin(T &x, U y) { if(y < x) x = y; }\ntemplate inline void amax(T &x, U y) { if(x < y) x = y; }\n/**********************************************/\n\n/****** Template of Fast I/O Methods *********/\ntemplate inline void write(T x)\n{\n\tint i = 20;\n\tchar buf[21];\n\t// buf[10] = 0;\n\tbuf[20] = '\\n';\n\n\tdo\n\t{\n\t\tbuf[--i] = x % 10 + '0';\n\t\tx/= 10;\n\t}while(x);\n\tdo\n\t{\n\t\tputchar(buf[i]);\n\t} while (buf[i++] != '\\n');\n}\n\ntemplate inline T readInt()\n{\n\tT n=0,s=1;\n\tchar p=getchar();\n\tif(p=='-')\n\t\ts=-1;\n\twhile((p<'0'||p>'9')&&p!=EOF&&p!='-')\n\t\tp=getchar();\n\tif(p=='-')\n\t\ts=-1,p=getchar();\n\twhile(p>='0'&&p<='9') {\n\t\tn = (n<< 3) + (n<< 1) + (p - '0');\n\t\tp=getchar();\n\t}\n\n\treturn n*s;\n}\n/************************************/\n\n\n/******* Debugging Class Template *******/\n#define DEBUG\n\n#ifdef DEBUG\n\n #define debug(args...) (Debugger()) , args\n\n class Debugger\n {\n public:\n Debugger(const std::string& _separator = \" - \") :\n first(true), separator(_separator){}\n\n template Debugger& operator , (const ObjectType& v)\n {\n if(!first)\n std:cerr << separator;\n std::cerr << v;\n first = false;\n return *this;\n }\n ~Debugger() { std:cerr << endl;}\n\n private:\n bool first;\n std::string separator;\n };\n\n#else\n #define debug(args...) // Just strip off all debug tokens\n#endif\n\n/**************************************/\n\n/******* User-defined Functions *******/\n\n\n/**************************************/\n\n\n/********** Main() function **********/\nint main()\n{\n\t//freopen(\"input.txt\",\"r\",stdin);\n\t//freopen(\"output.txt\",\"w\",stdout);\n\tint n;\n\tint a;\n\tint b;\n\tn = read(int);\n\ta = read(int);\n\tb = read(int);\n\tint ans = 6;\n\tint c = n/a;\n\tfor (int i = 1; (i <= 2) && ((b * i) <= n); i++)\n\t{\n\t\tans = max((i^3) + (4 - (n - (b * i)/a) * (i^3) + c - 1), ans);\n\t}\n\twrite(3);\n\twrite(\" \");\n\twrite(5);\n\treturn 0;\n}\n/******** Main() Ends Here *************/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "61ced60bed463c07a1e4e4002a405573", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\n#define fo(i,n) for(int i=0; i> n;\n vector dp(n+1,0);\n for(int i=2; i<=n; i++){\n vector m(n+1,0);\n int a = 1;\n while (2*a\n#include \n#include \nusing namespace std;\n\n#define fo(i,n) for(int i=0; i> n;\n vector dp(n+1,0);\n for(int i=2; i<=n; i++){\n vector m(n+1,0);\n int a = 1;\n while (2*a\n\n#define F first\n#define S second\n\n#define mp make_pair\n\nusing namespace std;\n\nint memo[810][810];\n\npair V[22], O;\nint n, d;\n\nbool check(pair p) {\n return p.S * p.S + p.F * p.F <= d * d;\n}\n\nint solve(int x, int y) {\n int& ret = memo[x + 400][y + 400];\n if (~ret) return ret;\n ret = 0;\n for (int i = 0; i < n; ++i) {\n if (check(mp(x + V[i].F, y + V[i].S))) ret |= !solve(x + V[i].F, y + V[i].S);\n if (ret) break;\n }\n return ret;\n}\n\nint main() {\n scanf(\"%d %d %d %d\", &O.F, &O.S, &n, &d);\n \n for (int i = 0; i < n; ++i) scanf(\"%d %d\", &V[i].F, &V[i].S);\n \n memset(memo, -1, sizeof memo);\n \n if (solve(O.F, O.S)) printf(\"Anton\\n\");\n else printf(\"Dasha\\n\");\n \n return 0;\n}\n\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compile Error:\n 36906 */\n/* Compi", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a0c49b0f9cbf2be8b65078dc3656adb4", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\n#include\nmain()\n{\nint a,b,c,d;\nscanf(\"%d%d%d%d\",&a,&b,&c,&d);\nsrand((unsigned)time(NULL));\nint e=rand()%2;\nif(e==0)\n{\nprintf(\"YES\\n\");\n}\nelse\n{\nprintf(\"NO\\n\");\n}\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e1b543495b828e6798cbb7952c302bb6", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define ALL(c) (c).begin(), (c).end()\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\n\nint root2(ll a){\n\tll b = sqrt(a);\n\twhile((b+1LL)*(b+1LL)<=a) ++b;\n\treturn b;\n}\n\nint root3(ll a){\n\tll b = cbrt(a);\n\twhile((b+1LL)*(b+1LL)*(b+1LL)<=a) ++b;\n\treturn b;\n}\n\nvector pr;\nvector d;\nvoid getPrimes(int n){\n\td.assign(n+1, 0);\n\tpr.clear();\n\tfor(int i=2;i<=n;++i){\n\t\tif(!d[i]) pr.push_back(d[i]=i);\n\t\tfor(int p : pr){\n\t\t\tif(p>d[i] || 1LL*p*i>n) break;\n\t\t\td[p*i] = p;\n\t\t}\n\t}\n}\n\nll cnt = 0;\n\nll f(ll,int);\nll pi(ll);\n\nvector > dp;\nll f(ll n, int m){\n\tif(m==0) return n;\n\tif(m prepi;\nll pi(ll n){\n\tif(n<=pr.back()) return prepi[(int)n];\n\tint y = root3(n-1)+1, d = pi(y);\n\tll res = f(n,d) + d - 1;\n\tfor(int i = d; ; ++i){\n\t\tll p = pr[i];\n\t\tif(p*p>n) break;\n\t\tres-=pi(n/p) - i;\n\t}\n\treturn res;\n}\n\nll init(ll n){\n\tgetPrimes(root2(n+1)*2);\n\tprepi.assign(pr.back()+1, 0);\n\tfor(int i=0,j=0;i<=pr.back();++i){\n\t\tif(i==pr[j]) ++j;\n\t\tprepi[i] = j;\n\t}\n\tint sn = 1<<17, sm = min((int)pr.size(), 1<<6);\n\tdp.assign(sm, vector(sn));\n\tfor(int j=0;jn) break;\n\t\tll m = n/p;\n\t\tif(m<=p) continue;\n\t\tll val = pi(m) - pi(p);\n\t\tans+=val;\n\t}\n\tans+=pi(root3(n));\n\treturn ans;\n}\n\nll brute(int n){\n\tvector a(n+1);\n\tfor(int i=1;i<=n;++i) for(int j=i;j<=n;j+=i) ++a[j];\n\treturn count(ALL(a), 4);\n}\n\nint main(){\n\t//freopen(\"input.txt\",\"r\",stdin); //freopen(\"output.txt\",\"w\",stdout);\n\n\tll n;\n\t (cin>>n) {\n cout<\n#define ll long long\n#define pii pair\n#define pll pair\n#define sc second\n#define fr first\n\nusing namespace std;\n\nconst int N = 5e5 + 10;\nint n;\nint rep[N];\nll a[N];\n\nll calc(int h){\n ll res = 0;\n ll pr =0 ,r = 0;\n\n for(int i=h ; i = 2)break;\n }\n rr = min(rr,2);\n ll rem = nm - 2*(w/hi) - (2-rr);\n if(rem >= w)\n return 1;\n if(2*w >= N)\n return 0;\n w1 = (2*w)%hi;\n rr =0 ;\n for(int i =w1,j = hi ; i= 1)break;\n }\n rr = min(rr,1);\n rem = nm - ((2*w)/hi) - (1-rr);\n if(rem >= w)\n return 1;\n\n return 0;\n}\n\nbool ch(ll hi,ll nm,ll w){\n bool maybe = 0;\n if(a[n-1] >= 2*w){\n ll rem = nm - ( (2*w)/hi + (((2*w)%hi) != 0) );\n if(rem >= w)\n return 1;\n if(rem >= w-2)\n maybe = 1;\n }\n if(n > 1 && a[n-2] >= w){\n ll rem = nm - 2*( w/hi + ((w%hi) != 0) );\n if(rem >= w)\n return 1;\n if(rem >= w-2)\n maybe = 1;\n }\n if(maybe)\n return ch1(hi,nm,w);\n return 0;\n}\n\nll tryH(ll hi){\n ll nm = calc(hi);\n ll l = 2,h = min(nm,(ll)N-1),w=0;\n while(l<=h){\n ll m = (l+h)/2;\n if(ch(hi,nm,m)){\n w = m;\n l = m+1;\n }\n else{\n h = m-1;\n }\n }\n for(int i=max(w,2) ;i >n;\n for(int i=0 ;i < n; i ++){\n scanf(\"%lld\",&a[i]);\n rep[a[i]]++;\n }\n\n for(int i=1 ;i \n#include \nusing namespace std;\n\nint dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};\nint dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};\nint A[9][9];\nstring hook, knight;\nint x, y;\n\n//#include \nint main()\n{\n//freopen (\"i.cpp\",\"r\",stdin); \n int cnt;\n memset (A, 0, sizeof (A));\n cin >> hook >> knight;\n x = hook[0] - 'a' + 1;\n y = hook[1] - '0';\n A[x][y] = 1;\n for (int i = 1; i <= 8; i ++)\n {\n A[x][i] = 1;\n A[i][y] = 1;\n }\n for (int i = 0; i < 8; i ++)\n if (x + dx[i] > 0 && x + dx[i] <= 8 && y + dy[i] > 0 && y + dy[i] <= 8)\n A[ x + dx[i] ][ y + dy[i] ] = 1;\n x = knight[0] - 'a' + 1;\n y = knight[1] - '0';\n A[x][y] = 1;\n for (int i = 0; i < 8; i ++)\n if (x + dx[i] > 0 && x + dx[i] <= 8 && y + dy[i] > 0 && y + dy[i] <= 8)\n A[ x + dx[i] ][ y + dy[i] ] = 1;\n cnt = 0;\n for (int i = 1; i <= 8; i ++)\n for (int j = 1; j <= 8; j ++)\n if (!A[i][j]) cnt ++;\n \n cout << cnt << endl;\n//getch(); fclose (stdin);\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3301fc31064211f414a21b3c6030ded6", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include\r\nusing namespace std;\r\n\r\nconst char* AIM[]=\"theseus\";\r\n\r\nchar map[105][105];\r\n\r\nbool InRange(int i, int j)\r\n{\r\n return i<=n&&j<=n;\r\n}\r\n\r\nbool search(int i, int j, int cnt)\r\n{\r\n if(InRange(i,j)==0||cnt>=7)\r\n {\r\n return 0;\r\n }\r\n if(map[i][j]==AIM[cnt])\r\n {\r\n bool flag=0;\r\n if(search(i+1,j+1,cnt+1))\r\n {\r\n flag=1;\r\n }\r\n if(search(i,j+1,cnt+1))\r\n {\r\n flag=1;\r\n }\r\n if(search(i,j+1,cnt+1))\r\n {\r\n flag=1;\r\n }\r\n return flag;\r\n }\r\n else\r\n {\r\n return 0;\r\n }\r\n}\r\n\r\nint main()\r\n{\r\n int n;\r\n cin >> n;\r\n for(int i=1;i<=n;++i)\r\n {\r\n cin >> map[i]+1;\r\n }\r\n for(int i=1;i<=n;++i)\r\n {\r\n for(int j=1;j<=n;++j)\r\n {\r\n search(i,j,0);\r\n }\r\n }\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cf23f9ca73366cb125899edb99a82eb4", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\ntypedef pair pa;\ntypedef pair pi;\n#define pb push_back\n#define pf push_front\n#define mp make_pair\n#define f first\n#define s second\n#define MAX 500009\n#define ll long long int\n#define re return 0\nlong long int MOD=998244353;\nlong long int mod=1e9+7;\nlong long int INF=1e18;\nll dx[]={1,-1,0,0};\nll dy[]={0,0,1,-1};\n\n/*\nbool sortinrev(const pair &a, \n const pair &b) \n{ \n return (a.first > b.first); \n} \n*/\n\n/*\nSieve\nint n;\nvector is_prime(n+1, true);\nis_prime[0] = is_prime[1] = false;\nfor (int i = 2; i * i <= n; i++) {\n if (is_prime[i]) {\n for (int j = i * i; j <= n; j += i)\n is_prime[j] = false;\n }\n}\n*/\n\nconst int M = 200 * 1000 + 11;\n\nll gcd(ll a,ll b)\n{\n\treturn __gcd(a,b);\n}\n\nlong long binpow(long long a, long long b, long long m) {\n a %= m;\n long long res = 1;\n while (b > 0) {\n if (b & 1)\n res = res * a % m;\n a = a * a % m;\n b >>= 1;\n }\n return res;\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\t\n\tll t,n,a,b,i,c;\n cin>>n>>a>>b;\n ll ans=min(g,n)-(n-min(b,n))+1;\n\tcout<\n#include\nusing namespace std;\nint NNN,KKK,MMM,AAA,ANS[110];\nstruct node\n{\n\tint x,y,z;\n} BBB[110];\nint main()\n{\n\tint i,x;\n\t \n\tscanf(\"%d%d%d%d\",&NNN,&KKK,&MMM,&AAA);\n\tfor(i=1;i<=AAA;i++) scanf(\"%d\",&x),BBB[x].x++,BBB[x].y=i;\n\tfor(i=1;i<=NNN;i++) BBB[i].z=i;\n\tsort(BBB+1,BBB+NNN+1,[&](node AAA,node BBB){return AAA.x!=BBB.x?(AAA.xBBB.y);});\n\tfor(i=1;i<=NNN;i++)\n\t\tif((i<=NNN-KKK&&BBB[i].x+MMM-AAA<=BBB[NNN-KKK+1].x)||(!BBB[i].x&&MMM==AAA)) ANS[BBB[i].z]=3;\n\t\telse if(!BBB[i].x&&MMM>AAA) ANS[BBB[i].z]=2;\n\t\t\t else if(i<=NNN-KKK) ANS[BBB[i].z]=2;\n\t\t\t else\n\t\t\t\t {\n\t\t\t\t\tint s=0,p;\n\t\t\t\t\tfor(p=i-1,j=KKK-(NNN-i);j>0&&p>0;j--,p--)\n\t\t\t\t\ts+=BBB[i].x+1-BBB[p].x;\n\t\t\t\t\tif(s<=MMM-AAA&&KKK\n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include\n#include \n#include\n#include\n#include \n#include\n#include \n#include \n#include \nusing namespace std;\nvoid past_code();\n//int y[1001];\n//int y[26];\n//long long r[100009];\n/*int const l=100009;\nint arr[2],q[l],w[l],y[l];*/\nint main(){\n\tlong long x,y,cnt=0;\n\tcin>>x>>y;\n\tfor (long long i=1;i<=x;i++)\n\t{\n\t\tif (y%i==0 &&i*x>=y)\n\t\t\tcnt++;\n\t}\n\tcout<\nusing namespace std;\n\nint main()\n{\n\tint n, a, b, c, x, y, z, result, z;\n\tcin >> n >> a >> b >> c;\n\tresult = 0;\n\tz = 1;\n\tfor (int i = 2; i <= n; i++) \n\t{\n\t\tif (z == 1) \n\t\t{\n\t\t\tif (a < b)\n\t\t\t{\n\t\t\t\tx = a;\n\t\t\t\ty = 2;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tx = b;\n\t\t\t\ty = 3;\n\t\t\t}\n\t\t}\n\t\tif (z == 2) \n\t\t{\n\t\t\tif (a < c)\n\t\t\t{\n\t\t\t\tx = a;\n\t\t\t\ty = 1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tx = c;\n\t\t\t\ty = 3;\n\t\t\t}\n\t\t}\n\t\tif (z == 3) \n\t\t{\n\t\t\tif (b < c)\n\t\t\t{\n\t\t\t\tx = b;\n\t\t\t\ty = 1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tx = c;\n\t\t\t\ty = 2;\n\t\t\t}\n\t\t}\n\t\tresult = result + x; \n\t\tz = y;\n\t}\n\tcout << result;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "05e7d71d1e4675f070fced070e4d8db8", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n int a,b,t,d;\n cin>>a>>b>>t>>d;\n int a[t+1];\n a[1]=a;\n a[t]=b;\n\n if(t==2){\n cout<=2;i--){\n if(abs(a[i]-a[i+1])>d){\n a[i]=a[i+1]+d;\n }\n else{\n break;\n }\n }\n }\n int s=0;\n for(int i=1;i<=t;i++){\n s+=a[i];\n }\n\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint f[20][401000],lg[410000],n,num_q;\nconst int inf=1e9;\nstruct query\n{\n\tint r1,c1,r2,c2,id;\n\tbool operator <(const query &temp)const\n\t{\n\t return r2>1;\n\t if(a[stk[mid]]>=c2&&stk[mid]>=pos)\n\t right=mid-1;\n else\n left=mid+1;\n\t}\n\treturn left;\n}\nint lb(int left,int right,int c2)\n{\n\tint mid;\n\twhile(left<=right)\n\t{\n\t\tmid=(left+right)>>1;\n\t\tif(a[stk[mid]]<=c2)\n\t\t left=mid+1;\n else\n right=mid-1;\n\t}\n\treturn right;\n}\nvoid solve()\n{\n\tint i,j,s,p,q,pj,id,ip,wl;\n\tpj=-1;\n\ttop=0;\n\tfor(i=0;iqy[i].r2)\n\t\t continue;\n\t\tfor(j=pj+1;j<=qy[i].r2;j++)\n\t\t{\n\t\t\twhile(top&&a[stk[top-1]]>=a[j])\n\t\t\t top--;\n stk[top++]=j;\n\t\t}\n\t\tid=lower_bound(0,top-1,qy[i].c2,qy[i].r1);\n\t\tint min_value=inf;\n\t\tip=lg[qy[i].r2-qy[i].r1+1];\n\t\tassert(qy[i].r1+(1<=0&&stk[id]>=qy[i].r1)\n\t\t{\n\t\t\t wl=qy[i].c2-a[stk[id]];\n\t\t\t if(vl[qy[i].id]wl)\n min_value=wl;\n\t\t}\n\t\tif(min_value>(qy[i].c1!=0)+abs(qy[i].c2))\n\t\t min_value=(qy[i].c1!=0)+abs(qy[i].c2);\n if(vl[qy[i].id]>=qy[i].c1)\n {\n \tif(min_value>abs(qy[i].c1-qy[i].c2))\n \t min_value=abs(qy[i].c1-qy[i].c2);\n }\n\t\tans[qy[i].id]=min(ans[qy[i].id],abs(qy[i].r1-qy[i].r2)+min_value);\n pj=qy[i].r2;\n\t}\n\ttop=0;\n\tpj=n;\n\tfor(i=num_q-1;i>=0;i--)\n\t{\n\t if(qy[i].r1>qy[i].r2)\n\t continue;\n\t for(j=pj-1;j>=qy[i].r2;j--)\n\t {\n \t\twhile(top>0&&a[stk[top-1]]>=a[j])\n \t\t top--;\n \t\t stk[top++]=j;\n \t}\n \tid=lb(0,top-1,qy[i].c2);\n \tint min_value=inf;\n \tif(id>=0)\n \t{\n\t \tmin_value=qy[i].r2-qy[i].r1+2*(stk[id]-qy[i].r2)+qy[i].c2-a[stk[id]];\n\t \tif(vl[qy[i].id]min_value)\n\t ans[qy[i].id]=min_value;\n\t\tpj=qy[i].r2; \n\t}\n\ttop=0;\n\tpj=n;\n\tfor(i=num_q-1;i>=0;i--)\n\t{\n\t\tif(qy[i].r1>qy[i].r2)\n\t\t continue;\n for(j=pj-1;j>=qy[i].r2;j--)\n {\n \t while(top>0&&a[stk[top-1]]+2*stk[top-1]>=a[j]+2*j)\n \t top--;\n \t stk[top++]=j;\n }\n id=lower_bound(0,top-1,qy[i].c2,qy[i].r2);\n int min_value=inf;\n if(idmin_value)\n \t ans[qy[i].id]=min_value;\n }\n pj=qy[i].r2;\n\t}\n\tsort(qy,qy+num_q,cmp);\n\ttop=0;\n\tpj=-1;\n\tfor(i=0;iqy[i].r2)\n\t\t continue;\n for(j=pj+1;j<=qy[i].r1;j++)\n {\n \twhile(top>0&&a[stk[top-1]]>=a[j])\n \t top--;\n \t stk[top++]=j;\n }\n int min_value;\n id=lb(0,top-1,min(qy[i].c2,vl[qy[i].id]));\n if(id>=0)\n { \n min_value=2*(qy[i].r1-stk[id])+qy[i].r2-qy[i].r1+qy[i].c2-a[stk[id]];\n if(ans[qy[i].id]>min_value)\n ans[qy[i].id]=min_value;\n\t\t}\n pj=qy[i].r1;\n\t}\n\ttop=0;\n\tpj=-1;\n\tfor(i=0;iqy[i].r2)\n\t\t continue;\n for(j=pj+1;j<=qy[i].r1;j++)\n {\n \twhile(top>0&&a[stk[top-1]]-2*stk[top-1]>=a[j]-2*j))\n \t top--;\n \t stk[top++]=j;\n }\n id=lower_bound(0,top-1,qy[i].c2,-1);\n int min_value;\n if(idmin_value)\n ans[qy[i].id]=min_value;\n }\n pj=qy[i].r1;\n\t}\n}\nvoid pre_pare()\n{\n\tint i,j,s,p,q,k;\n\tfor(i=0;ia[f[k-1][i+(1<<(k-1))]])\n\t\t \tf[k][i]=f[k-1][i+(1<<(k-1))];\n\t }\n \n}\nint main()\n{\n\tint i,j,s,p,q;\n // n=1000;//\n \tscanf(\"%d\",&n);\n\tlg[1]=0;\n\tfor(i=2;i<=n;i++)\n\t lg[i]=lg[i/2]+1;\n\tfor(i=0;i\nusing namespace std;\nstring M[]={\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"};\n//M\u6570\u7ec4\u4e0d\u7528\u5b9a\u4e49\u5927\u5c0f\uff0c\u5982\u679c\u4e0d\u5199\u7684\u8bdd\u5c31\u9ed8\u8ba4\u4f60\u586b\u7684\u591a\u5c11\u4e2a\u6570\u90a3\u4e48\u5927\u3002\nint main()\n{\n//\tfreopen(\"Codecraft III.in\",\"r\",stdin);\n//\tfreopen(\"Codecraft III.out\",\"w\",stdout);\t\n\tstring a;//\u5b9a\u4e49string\u7c7b\u578b\u7684a\n\tcin>>a;//\u8f93\u5165a\n\tint n,now;\n\tcin>>n;\n\tfor(int i=0;i<12;i++)//\u679a\u4e3e\u3002\u770b\u5f53\u524d\u662f\u90a3\u4e2a\u6708\u4efd\n\t\tif(M[i]==a) now=i;\n\tint ans=(now+n)%12;//\u6ce8\u610f\u53d6\u6a21\uff0c\u4e0d\u7136\u8d8a\u754c\u4e86\n\tcout<>ans;\ncin>>k;\n\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u5c06\u9898\u76ee\u4e2d\u7684\u6708\u4efd\u82f1\u6587\u8f6c\u5316\u6210\u6570\u5b57\uff0c\u4e5f\u5c31\u662f\u5728\u6211\u4eec\u5f00\u597d\u7684\u6570\u7ec4\u4e2d\u67e5\u627e\uff1a\n\nfor(long long i=0;i<=11;i++)\n {\n \tif(ans==a[i])\n \t{\n \t\tsum=i;\n \t\tbreak;\n\t\t}\n\t}\n\u6700\u540e\u8f93\u51fa\u8f93\u5165\u6708\u4efd\u52a0\u4e0a\u7ecf\u8fc7\u7684\u6708\u6570\u5bf912\u53d6\u4f59\u7684\u7ed3\u679c\u5bf9\u5e94\u7684\u6708\u4efd\uff0c \u5373a[\uff08\u8f93\u5165\u6708\u4efd+\u7ecf\u8fc7\u6708\u4efd\uff09%12]\n\ncout<\nusing namespace std;\nstring ans,a[12]={\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"};\nlong long k,sum;\nint mian()\n{ \n cin>>ans;\n cin>>k; \n for(long long i=0;i<=11;i++)\n {\n \tif(ans=a[i])\n \t{\n \t\tsum=i;\n \t\tbreak;\n\t\t}\n\t}\n\tcout<\n#include\n#include\n#include\n#include\nusing namespace std;\nchar s[25][20]={\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"},c[25];//\u6253\u8868QAQ\nint k;\nint main(){\n cin>>c>>k;//\u8bfb\u5165\n for(int i=0;i<12;i++){\n if(!strcmp(c,s[i])){//C++\u5e93\u51fd\u6570\u8fdb\u884c\u6bd4\u8f83\n k+=i;//k\u52a0\u4e0ai\uff0c\u627e\u5230\u5f53\u524d\u5b57\u7b26\u4e32\u4f4d\u4e8e\u6570\u7ec4\u7684\u54ea\u4e2a\u4f4d\u7f6e\uff0c\u52a0\u4e0a\u8fd9\u4e2a\u4f4d\u7f6e\n break;\n }\n }\n cout<\nusing namespace std;\nint main()\n{\n string s;\n cin>>s;//\u8bfb\u5165\n int y,x;\n if(s==\"January\")y=1;\n if(s==\"February\")y=2;\n if(s==\"March\")y=3;\n if(s==\"April\")y=4;\n if(s==\"May\")y=5;\n if(s==\"June\")y=6;\n if(s==\"July\")y=7;\n if(s==\"August\")y=8;\n if(s==\"September\")y=9;\n if(s==\"October\")y=10;\n if(s==\"November\")y=11;\n if(s==\"December\")y=12;\n //\n cin>>x;\n x=x+y;\n x=x%12;\n if(x==1)cout<<\"January\";\n if(x==2)cout<<\"February\";\n if(x==3)cout<<\"March\";\n if(x==4)cout<<\"April\";\n if(x==5)cout<<\"May\";\n if(x==6)cout<<\"June\";\n if(x==7)cout<<\"July\";\n if(x==8)cout<<\"August\";\n if(x==9)cout<<\"September\";\n if(x==10)cout<<\"October\";\n if(x==11)cout<<\"November\";\n if(x==0)cout<<\"December\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c3a835b2188b12187a254308fdd5fdfa", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint sumDiv(long long x)\n{\t\n\tint sum = 0;\n\twhile (x)\n\t{\n\t\tsum += x % 10;\n\t\tx /= 10;\n\t}\n\treturn sum;\n}\n\nint numLen(long long x)\n{\n\tint sum = 0;\n\twhile (x)\n\t{\n\t\tx /= 10;\n\t\t++sum;\n\t}\n\treturn sum;\n}\n\nlong long constructNum(long long x, int pos)\n{\n\tlong long t = x / (pow(10,pos));\n\tif (t % 10 == 0) return x;\n\tt--;\n\tfor (int i = 0; i < pos; ++i)\n\t{\n\t\tt = (t * 10) + 9;\n\t}\n\treturn t;\n}\n\nint main()\n{\n\tlong long x;\n\tcin >> x;\n\tlong long d = 10;\n\tlong long mx = x;\n\tint n = numLen(x);\n\tfor (int i = 1; i < n; ++i)\n\t{\n\t\tlong long t = constructNum(x, i);\n\t\tif (sumDiv(mx) < sumDiv(t)) mx = t;\n\t}\n\tcout << mx;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5be4cedf85bb5ccb2ad1e22ebfa891f2", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#define ll long long\n#define mod 1073741824\nll prime(ll n);\n#define N 150001\nint k,a[N],b[N],aa[N];\n/*void sieve()\n{\n ll i,j,t=1,s=sqrt(N);\n b[0]=1;\n a[1]=2;\n for(i=4;i<=N;i+=2)\n b[i]=1;\n for(i=3;i<=s;i+=2)\n {\n if(!b[i])\n {\n a[++t]=i;\n for(j=i*i;j<=N;j+=i)\n b[j]=1;\n }\n }\n}\nll dp[N];\nll divisor(ll n)\n{\n if(dp[n])\n return dp[n];\n ll i=1,d=0;\n while(1)\n {\n if(n%i==0)\n {\n if(n/i==i)\n {\n d++;\n dp[n]=d;\n return d;\n }\n else\n {\n d+=2;\n }\n }\n i++;\n if(i>n/i)\n {\n dp[n]=d;\n return d;\n }\n }\n}*/\nstruct df\n{\n int a,b;\n}f[101];\nbool cmp(int a,int b)\n{\n return a>b;\n}\nll prime(ll n)\n{\n ll s=sqrt(n);\n for(ll i=2;i<=s;i++)\n {\n if(n%i==0)\n return 0;\n }\n return 1;\n}\nll big(ll a,ll b,ll p)\n{\n if(b==0)\n return 1;\n else if(b%2)\n {\n return ((a%p)*big(a,b-1,p))%p;\n }\n else\n {\n long long c=big(a,b/2,p);\n return ((c%p)*(c%p))%p;\n }\n}\nusing namespace std;\nint main()\n{\n ll n,i=0,j,m=0,x,y,q=0,p=0,r=0;\n string s,ss;\n mapmp;\n scanf(\"%s\",s+1);\n l=s.size();\n n=l;\n ss=s;\n while(l--)\n {\n q=0;\n if(!mp[ss])\n {\n m++;\n mp[ss]++;\n }\n for(i=l+1;i<=n;i++)\n ss[++q]=s[i];\n for(i=1;i<=l;i++)\n ss[++q]=s[i];\n }\n cout<\n#include\n#include\n#include\nusing namespace std;\nint num[85],nu[85],ans[85],tab[85];\nbool cmp(int a,int b)\n{\n return a>b;\n}\nint main()\n{\n int n,m;\n int x;\n for(int i=0;i\nusing namespace std;\nint main(){\n\tint req;\n\tcin>>req;\n\tint remaining = req - 10;\n\tif(remaining<10&&remaining>1){\n\t\tans = 4;\n\t}\n\telse if(remaining == 10){\n\t\tans = 15;\n\t}\n\telse if (remaining == 11)\n\t{\n\t\tcout<<4;\n\t}\n\telse if(remaining == 1){\n\t\tcout<<8;\n\t}\n\n\n\n\treturn 0;\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4dc0e4dff4d298cd8aa18f345a32a8bb", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n \n int x;\n cin >> x;\n if( x&1)== 1)\n cout << 1;\n else \n cout << 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2a5051c4c8fc72bb9544c272e72118bf", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint L[5], R[5];\n\ndouble doit(int price, int mask, int idx, int n) {\n double ret = price;\n if (idx >= 0) {\n int low = max(price + 1, L[idx]);\n int high = R[idx];\n if (low > high) return 0.0;\n ret *= high - low + 1;\n }\n for (int i = 0; i < n; ++i) {\n if (i == idx || (mask & (1 << i))) continue;\n int high = min(R[i], price - 1);\n int low = L[i];\n if (high < low) return 0.0;\n ret *= high - low + 1;\n }\n // cout << price << \" \" << mask << \" \" << idx << \" \" << ret << endl;\n return ret;\n}\n\nint main() {\n int n;\n cin >> n;\n double total = 1.0;\n for (int i = 0; i < n; ++i) {\n cin >> L[i] >> R[i];\n total *= R[i] - L[i] + 1;\n }\n double sum = 0.0;\n // the subset of second price companies\n for (int mask = 1; mask < (1 << n); ++mask) {\n // cout << \"mask: \" << mask << endl;\n vector A;\n for (int i = 0; i < n; ++i) {\n if (mask & (1 << i)) A.push_back(i);\n }\n int minR = R[A[0]], maxL = L[A[0]];\n for (auto& idx : A) {\n minR = min(minR, R[idx]);\n maxL = max(maxL, L[idx]);\n }\n if (maxL > minR) continue;\n // enumerate the first price > second price\n for (int i = 0; i < n; ++i) {\n if (mask & (1 << i)) continue;\n for (int k = maxL; k <= minR; ++k) {\n sum += doit(k, mask, i, n);\n }\n }\n // first price = second price\n if (A.size() > 1) {\n for (int k = maxL; k <= minR; ++k) {\n sum += doit(k, mask, -1, n);\n }\n }\n }\n sum /= total;\n printf(\"%.10f\\n\", sum);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "121953b72f581998084aa6d20c2ac02b", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \"iostream\"\n#include \"fstream\"\n#include \"algorithm\"\n#include \"iomanip\"\n#include \"stack\"\n#include \"queue\"\n#include \"string\"\n#include \"vector\"\n#include \"map\"\n#include \"set\"\n#include \"unordered_set\"\n#include \"unordered_map\"\n#include \"iterator\"\n#include \n#include \"bitset\"\n#include \"cmath\"\n#include \"list\"\n#include \"complex\"\n#include \n#include \"deque\"\n#include \"numeric\"\n\nusing namespace std;\n\n//#define f(i,n) for(int i=0; i=0;i--)\n//#define forn(i, j, n) for(int i=j; i mii;\ntypedef pair pii;\ntypedef pair psi;\ntypedef pair pis;\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vpii;\ntypedef vector vc;\n\ntemplate\nvoid show(const vector &a)\n{\n\tfor (T x : a)\n\t\tcout << x << \" \";\n\tcout << endl;\n}\n\nconst int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1000000007;\nconst double eps = 5e-10, PI = 2 * acos(0.0);\nvi vertices[sze];\nvc visit(sze * 10, false);\nvi arr(sze, 0);\nint n, m, k;\nint cnt = 0;\nint s, t;\n\n//int ptr[sze], d[sze];\n//\n//struct edge\n//{\n//\tint from, to, cap, flow;\n//};\n//\n//vector e;\n//\n//void add_edge(int u, int v, int w)\n//{\n//\tedge e1{ u, v, w, 0 };\n//\tedge e2{ v, u, 0, 0 };\n//\n//\tvertices[u].pb(e.size());\n//\te.pb(e1);\n//\tvertices[v].pb(e.size());\n//\te.pb(e2);\n//}\n//\n//bool bfs()\n//{\n//\tqueue q;\n//\tq.push(s);\n//\tfill(d, d + n + 10, -1);\n//\td[s] = 0;\n//\n//\twhile (!q.empty() && d[t] == -1)\n//\t{\n//\t\tint v = q.front();\n//\t\tq.pop();\n//\n//\t\tfor (auto id : vertices[v])\n//\t\t{\n//\t\t\tint to = e[id].to;\n//\t\t\tif (d[to] == -1 && e[id].cap > e[id].flow)\n//\t\t\t{\n//\t\t\t\tq.push(to);\n//\t\t\t\td[to] = d[v] + 1;\n//\t\t\t}\n//\t\t}\n//\t}\n//}\n//\n//int dfs(int v, int flow)\n//{\n//\tif (v == t) return flow;\n//\tif (!flow) return 0;\n//\n//\tfor (; ptr[v] < vertices[v].size(); ptr[v] ++)\n//\t{\n//\t\tint id = vertices[v][ptr[v]];\n//\t\tint to = e[id].to;\n//\n//\t\tif (d[to] != d[v] + 1) continue;\n//\n//\t\tint pushed = dfs(to, min(flow, e[id].cap - e[id].flow));\n//\n//\t\tif (pushed)\n//\t\t{\n//\t\t\te[id].flow += pushed;\n//\t\t\te[id ^ 1].flow -= pushed;\n//\t\t\treturn pushed;\n//\t\t}\n//\t}\n//\n//\treturn 0;\n//}\n//\n//int dinic()\n//{\n//\tint flow = 0;\n//\twhile (bfs())\n//\t{\n//\t\twhile (int pushed = dfs(s, oo))\n//\t\t\tflow += pushed;\n//\t}\n//\n//\treturn flow;\n//}\n\nint dp[110][2];\n\nint solve(int idx, int prev)\n{\n\tif (idx == n)\n\t\treturn 0;\n\n\tif (dp[idx][prev] != -1)\n\t\treturn dp[idx][prev];\n\n\tif (prev == 1 && arr[idx] == 0)\n\t{\n\t\treturn dp[idx][prev] = 1 + solve(idx + 1, 1);\n\t}\n\telse\n\t{\n\t\treturn dp[idx][prev] = min(1 + solve(idx + 1, prev), solve(idx + 1, arr[idx]));\n\t}\n}\n\nsigned main()\n{\n\tios::sync_with_stdio(false);\n\tcin.tie(0);\n\tcout.tie(0);\n\n\tcin >> n;\n\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> arr[i];\n\t}\n\n\twmemset(dp, -1, sizeof(dp));\n\tcout << n - solve(0, 0);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a849427bff68e1771b6c40a788c2cc38", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include\n#include\nint main()\n{\n int a[4];\n for(int i=0;i<4;i++)\n {\n scanf(\"%d\",&a[i]);\n }\n if(a[1]+a[0]==a[3]+a[2]||a[2]+a[1]==a[0]+a[3]||a[0]+a[2]==a[1]+a[3]||a[0]==a[1]+a[2]+a[3]||a[1]==a[0]+a[2]+a[3]||a[2]==a[1]+a[0]+a[3]||a[3]==a[1]+a[2]+a[0])\n cout<<\"YES\";\n else\n cout<<\"NO\";\n \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c45003be8791cf8ba26a962565987975", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "//#define ONLINE_JUDGE\n\n#if defined(ONLINE_JUDGE)\n#define _SECURE_SCL 0\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#if !defined(__GNUC__)\n#else // !defined(__GNUC__)\n#define _CrtDbgBreak() __builtin_trap()\n#endif // !defined(__GNUC__)\n\n#if defined(ONLINE_JUDGE)\n#define LOCAL_TEST 0\n#else\n#define LOCAL_TEST 1\n#endif\n\n#if LOCAL_TEST\nstruct AssertsCounter\n{\n\tAssertsCounter(): counter(0) {}\n\t~AssertsCounter() { std::cerr << std::endl << \"DIAG: \" << (counter == 0 ? \"OK\" : \"FAIL!!!\") << \" Asserts count: \" << counter << std::endl; }\n\tvoid Increment() { counter++; }\n\tuint32_t counter;\n};\nAssertsCounter g_assertsCounter;\n#define LOCAL_ASSERT(expr) { if (!(expr)) {std::cerr << \"ASSERT FAILED (\" << __LINE__ << \"): '\" << #expr << \"'\" << std::endl; g_assertsCounter.Increment(); _CrtDbgBreak(); } }\n#define LOCAL_ASSERT_EQ(expr1, expr2) { if ((expr1) != (expr2)) {std::cerr << \"ASSERT FAILED (\" << __LINE__ << \"): '\" << #expr1 << \"' == '\" << #expr2 << \"' (\" << (expr1) << \" vs \" << (expr2) << \"')\" << std::endl; g_assertsCounter.Increment(); _CrtDbgBreak(); } }\n#else\nvolatile bool isLocalTestEnabled = 0;\n#define LOCAL_ASSERT(expr)\n#define LOCAL_ASSERT_EQ(expr1, expr2)\n#endif\n\nbool g_isLocalPrintEnabled = (bool)(LOCAL_TEST);\n#define LOCAL_PRINT() if (!g_isLocalPrintEnabled) { } else std::cerr // << .. << ..\n\ntypedef std::string string8_t;\ntypedef long double ld_t;\n\ntypedef std::vector vector_size_t;\ntypedef std::vector vector_uint8_t;\ntypedef std::vector vector_int32_t;\ntypedef std::vector vector_uint32_t;\ntypedef std::vector vector_int64_t;\ntypedef std::vector vector_uint64_t;\ntypedef std::vector vector_string8_t;\n\ntypedef std::vector vector_2d_size_t;\ntypedef std::vector vector_2d_int32_t;\ntypedef std::vector vector_2d_uint32_t;\ntypedef std::vector vector_2d_int64_t;\ntypedef std::vector vector_2d_uint64_t;\n\ntypedef std::set set_size_t;\ntypedef std::set set_int32_t;\ntypedef std::set set_uint32_t;\ntypedef std::set set_int64_t;\ntypedef std::set set_uint64_t;\ntypedef std::set set_string8_t;\n\ntypedef std::multiset multiset_size_t;\ntypedef std::multiset multiset_string8_t;\n\n// Auxiliary functions definition\n//\ntemplate void UpdateMin(T& a, const T b) {a = std::min(a, b);}\ntemplate void UpdateMax(T& a, const T b) {a = std::max(a, b);}\n\nconst ld_t Pi = std::atan(1.0L) * 4.0L;\nstatic const ld_t Eps = 1.0e-09;\ntemplate bool IsEqual(const T a, const T b) { return std::abs(a - b) < Eps; }\ntemplate bool IsGreater(const T a, const T b) { return a > b + Eps; }\ntemplate bool IsLess(const T a, const T b) { return a + Eps < b; }\ntemplate bool IsGreaterEqual(const T a, const T b) { return !IsLess(a, b); }\ntemplate bool IsLessEqual(const T a, const T b) { return !IsGreater(a, b); }\n\ntemplate string8_t ToStr(const T& val) { std::ostringstream ostr; ostr << val; return ostr.str(); }\ntemplate bool FromStr(const string8_t& str, T& val) {std::istringstream istr(str); istr >> val; return !!istr; }\ntemplate T FromStr(const string8_t& str) {T val = {}; std::istringstream istr(str); istr >> val; return val; }\n\nuint64_t SafeAdd(uint64_t a, uint64_t b) { uint64_t M = std::numeric_limits::max(); return a <= M - b ? a + b : M; }\nuint64_t SafeMul(uint64_t a, uint64_t b) { uint64_t M = std::numeric_limits::max(); return a <= M / b ? a * b : M; }\n\ntemplate std::istream& operator>>(std::istream& ist, std::vector& data)\n{\n\tLOCAL_ASSERT(!!ist);\n\tfor (size_t i = 0; i < data.size(); i++) { ist >> data[i]; }\n\treturn ist;\n}\n\ntemplate T Read(std::istream& ist)\n{\n\tLOCAL_ASSERT(!!ist);\n\tT val; ist >> val; return val;\n}\n\ntemplate std::ostream& operator<<(std::ostream& ost, const std::vector& data)\n{\n\tfor (size_t i = 0; i < data.size(); i++) { if (i != 0) { ost << ' '; } ost << data[i]; }\n\treturn ost;\n}\n\n#if defined(ONLINE_JUDGE)\ntemplate class StopWatch { };\n#else\n#include \n#include \nlibrary::random::Rand g_rnd;\n#endif\n\nconst uint64_t Mod = 1000000007;\n\nuint64_t FindGcd(const uint64_t& a0, const uint64_t& b0)\n{\n\tuint64_t a = a0;\n\tuint64_t b = b0;\n\n\tif (a < b)\n\t\tstd::swap(a, b);\n\n\tif (b == 0)\n\t\treturn a;\n\n\tdo\n\t{\n\t\tif (a < b)\n\t\t\tstd::swap(a, b);\n\t\ta = a % b;\n\t}\n\twhile(a != 0);\n\n\treturn b;\n}\n\n// returns:\n// m == 0 -> pow(a, p)\n// m != 0 -> pow(a, p) % m\nstatic uint64_t FastPow(const uint64_t& a, const uint64_t& p)\n{\n\tconst uint64_t m = Mod;\n\n\tuint64_t res = 1;\n\n\tuint64_t mask = 1;\n\tuint64_t powPart = a;\n\n\tconst size_t bitsCount = sizeof(uint64_t) * 8;\n\tfor (size_t i = 0; i < bitsCount; i++)\n\t{\n\t\tif (p & mask)\n\t\t{\n\t\t\tres *= powPart;\n\t\t\tres %= m;\n\t\t}\n\t\tmask <<= 1;\n\t\tpowPart *= powPart;\n\t\tpowPart %= m;\n\t}\n\n\treturn res;\n}\n\nuint64_t ReverseElementByPrimeModule(const uint64_t& a)\n{\n\tconst uint64_t m = Mod;\n\tLOCAL_ASSERT(a != 0);\n\treturn FastPow(a, m - 2);\n}\n\nstruct Fraction\n{\n\tFraction(const uint64_t p, const uint64_t q): p(p), q(q) { }\n\tFraction(): p(0), q(1) { }\n\n\tuint64_t GetAsOneValue() const\n\t{\n\t\tuint64_t z = p;\n\t\tz *= ReverseElementByPrimeModule(q);\n\t\tz %= Mod;\n\t\treturn z;\n\t}\n\n\tuint64_t p;\n\tuint64_t q;\n};\n\nvoid Normalize(uint64_t& num, uint64_t& den)\n{\n\tnum %= Mod;\n\tden %= Mod;\n\n\tuint64_t gc = FindGcd(num, den);\n\tgc %= Mod;\n\n\tconst uint64_t rgc = ReverseElementByPrimeModule(gc);\n\n\tnum *= rgc;\n\tnum %= Mod;\n\n\tden *= rgc;\n\tden %= Mod;\n}\n\nFraction Construct(const uint64_t p1, const uint64_t p2)\n{\n\tuint64_t num = p1;\n\tuint64_t den = p2;\n\tNormalize(num, den);\n\treturn Fraction(num, den);\n}\n\nFraction Mult(const Fraction& f1, const Fraction& f2)\n{\n\tuint64_t num = f1.p * f2.p;\n\tuint64_t den = f1.q * f2.q;\n\tNormalize(num, den);\n\treturn Fraction(num, den);\n}\n\nFraction Mult(const Fraction& f1, const uint64_t& v)\n{\n\tuint64_t num = f1.p * v;\n\tuint64_t den = f1.q;\n\tNormalize(num, den);\n\treturn Fraction(num, den);\n}\n\nFraction Divide(const Fraction& f1, const Fraction& f2)\n{\n\tuint64_t num = f1.p * f2.q;\n\tuint64_t den = f1.q * f2.p;\n\tNormalize(num, den);\n\treturn Fraction(num, den);\n}\n\nFraction Plus(const Fraction& f1, const Fraction& f2)\n{\n\tuint64_t num = f1.p * f2.q + f2.p * f1.q;\n\tuint64_t den = f1.q * f2.q;\n\tNormalize(num, den);\n\treturn Fraction(num, den);\n}\n\nFraction Minus(const Fraction& f1, const Fraction& f2)\n{\n\tuint64_t num = (f1.p * f2.q) % Mod + Mod - (f2.p * f1.q) % Mod;\n\tuint64_t den = f1.q * f2.q;\n\tNormalize(num, den);\n\treturn Fraction(num, den);\n}\n\nstruct State\n{\n\tState(uint64_t ca, uint64_t cab): ca(ca), cab(cab) { }\n\tState(): ca(0), cab(0) { }\n\n\tuint64_t ca;\n\tuint64_t cab;\n\n\tbool operator<(const State& rv) const\n\t{\n\t\treturn std::tie(ca, cab) < std::tie(rv.ca, rv.cab);\n\t}\n};\n\ntypedef std::map States;\n\nFraction GetAns(const uint64_t k, const uint64_t pa, const uint64_t pb)\n{\n\tconst Fraction One = Construct(1, 1);\n\n\tFraction ans = Fraction(0, 1);\n\n\tStates states;\n\tstates[State(1, 0)] = Fraction(1, 1);\n\n\tconst Fraction pfa = Construct(pa, pa + pb);\n\tconst Fraction pfb = Construct(pb, pa + pb);\n\n#if LOCAL_TEST\n\tsize_t maxStates = 0;\n\tsize_t iterations = 0;\n#endif\n\n\twhile (!states.empty())\n\t{\n#if LOCAL_TEST\n\t\tif (maxStates < states.size())\n\t\t{\n\t\t\tmaxStates = states.size();\n\t\t}\n\t\titerations++;\n#endif\n\n\t\tStates t;\n\n\t\tfor (States::const_iterator ps = states.begin(); ps != states.end(); ++ps)\n\t\t{\n\t\t\tconst State& s = ps->first;\n\t\t\tconst Fraction& p = ps->second;\n\n\t\t\tif (s.cab >= k)\n\t\t\t{\n\t\t\t\tconst Fraction d = Mult(p, k);\n\t\t\t\tans = Plus(ans, d);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (s.ca + s.cab >= k)\n\t\t\t{\n\t\t\t\tconst Fraction fc = Construct(s.ca, 1);\n\t\t\t\tconst Fraction fpc = Mult(fc, pfa);\n\t\t\t\tconst Fraction num = Plus(pfa, Minus(fc, fpc));\n\t\t\t\tconst Fraction den = Minus(One, pfa);\n\t\t\t\tconst Fraction sum = Divide(num, den);\n\t\t\t\tconst Fraction fcab = Construct(s.cab, 1);\n\t\t\t\tFraction d = Plus(fcab, sum);\n\t\t\t\td = Mult(d, p);\n\t\t\t\tans = Plus(ans, d);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst State s1(s.ca + 1, s.cab);\n\t\t\tconst State s2(s.ca, s.cab + s.ca);\n\t\t\tconst Fraction p1 = Mult(p, pfa);\n\t\t\tconst Fraction p2 = Mult(p, pfb);\n\n\t\t\tt[s1] = Plus(t[s1], p1);\n\t\t\tt[s2] = Plus(t[s2], p2);\n\t\t}\n\n\t\tstates.swap(t);\n\t}\n\n\tLOCAL_PRINT() << \"Iterations: \" << iterations << std::endl;\n\tLOCAL_PRINT() << \"Max states: \" << maxStates << std::endl;\n\n\treturn ans;\n}\n\nbool Solve(std::istream& ist, std::ostream& ost, const bool multipleTestMode)\n{\n\tStopWatch<1> sw; (void)sw;\n\n\t//\n\tsize_t k;\n\tist >> k;\n\n\tuint64_t pa, pb;\n\tist >> pa >> pb;\n\n\tif (multipleTestMode && !ist)\n\t\treturn false;\n\n\t//\n\tLOCAL_PRINT() << std::endl << \"Next test: k = \" << k << std::endl;\n\n\tconst Fraction ans = GetAns(k, pa, pb);\n\tconst uint64_t v = ans.GetAsOneValue();\n\tost << v << std::endl;\n\n\treturn multipleTestMode;\n}\n\n\n#if LOCAL_TEST\nvoid Test()\n{\n\tusing namespace library::random;\n\t//const auto genVector = GenFactory::CreateGenVector(GenRange(2, 10), GenRange(-100, +200));\n\n\tfor (size_t t = 0; t < 10; t++)\n\t{\n\t\t//const vector_int32_t data = genVector();\n\t\t//size_t ans = GetAns(data);\n\t\t//size_t ref = GetAnsRef(data);\n\t\t//LOCAL_ASSERT_EQ(ref, ans);\n\t}\n}\n#endif\n\nvoid RunSolve(std::istream& ist, std::ostream& ost)\n{\n#if !defined(ONLINE_JUDGE)\n\twhile(Solve(ist, ost, true)) {};\n#else\n Solve(ist, ost, false);\n#endif\n}\n\nint main(int argc, const char *argv[])\n{\n#if !defined(ONLINE_JUDGE)\n\tTest();\n#endif\n\n std::ios_base::sync_with_stdio(false);\n\tif (argc > 1)\n\t{\n\t\tstd::ifstream ifs(argv[1]);\n\t\tif (!ifs)\n\t\t{\n\t\t\tstd::cout << \"File not found: \" << argv[1] << std::endl;\n\t\t\treturn 1;\n\t\t}\n\t\tRunSolve(ifs, std::cout);\n\t\treturn 0;\n\t}\n\n\tRunSolve(std::cin, std::cout);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7abbbc2c911150fd6e83af22bc313f2d", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include \ntypedef long long ll;\nusing namespace std;\n\nll l, r, u, d;\nll n, x, y, c;\n\nll sqr(ll x) //Esta funcion se usa para obtener el area del cuadrado que estamos viendo\n{\n return x * x;\n}\n\nll tri(ll x) //Esta es para encontrar el area de los triangulos que se forman por la naturaleza del problema\n{\n return (x + 1) * x / 2;\n}\n\nbool solve(ll t)\n{\n \n ll sum = t * t + (t + 1) * (t + 1);\n if (t > l) sum -= sqr(t - l);\n if (t > r) sum -= sqr(t - r);\n if (t > u) sum -= sqr(t - u);\n if (t > d) sum -= sqr(t - d);\n if (t > l + d) sum += tri(t - (l + d) - 1);\n if (t > l + u) sum += tri(t - (l + u) - 1);\n if (t > r + d) sum += tri(t - (r + d) - 1);\n if (t > r + u) sum += tri(t - (r + u) - 1);\n if (sum >= c) return true;\n return false;\n}\n\nint main()\n{\n scanf(\"%I64d%I64d%I64d%I64d\", &n, &x, &y, &c))\n \n l = x - 1, r = n - x;\n u = y - 1, d = n - y;\n ll low = 0, high = 2 * n, mid;\n while (low <= high)\n {\n mid = (low + high) / 2;\n if (solve(mid)) high = mid - 1;\n else low = mid + 1;\n }\n printf(\"%I64d\\n\", low);\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8e3db3c7bc89376cf5fc2f7bd02b6ce8", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\nusing ll = long long;\nusing vll = vector;\nusing pairll = pair;\nusing vvll = vector;\nusing vint = vector;\nusing pint = pair;\nusing vvint = vector;\n\n#define mod 1000000007\n#define inf 1000000000000009\n\nint n,k, num;\nvint cnt;\nvector good;\n\nvoid reset(){\n cout << 'R' << endl;\n}\nbool check(int a){\n string s;\n cout << \"? \" << a << endl;\n cin >> s;\n return s == \"Y\";\n}\n\nint check(int x, int y, int c, int d){\n int a = x*k;\n int tmp = 0;\n a += c*(k/2);\n int b = y*k;\n b += d*(k/2);\n int num = 0;\n string s;\n for(int i = a; i < a+k/2; i++){\n if(good[i]){\n cout << \"? \" << i+1 << endl;\n cin >> s;\n }\n }\n for(int i = b; i < b+k/2; i++){\n if(good[i]){\n cout << \"? \" << i+1 << endl;\n cin >> s;\n tmp = s == \"Y\";\n num += tmp;\n if(tmp == 1){\n good[i] = 0;\n }\n }\n }\n cout << 'R' << endl;\n return num;\n}\n\nint main(){\n cin >> n >> k;\n if(k==1){\n k = 2;\n }\n if(n == 1){\n cout << \"! 1\" << endl;\n return 0;\n }\n good.resize(n, 1);\n good.assign(n, 1);\n num = n;\n int tmp;\n for(int i = 0; i < n; i++){\n tmp = check(i+1);\n if(tmp == 1){\n good[j] = 0;\n }\n num -= tmp;\n }\n for(int i = 0; i < n/k; i++){\n for(int j = i+1; j < n/k; j++){\n num -= check(i, j, 0, 0);\n num -= check(i, j, 1, 0);\n num -= check(i, j, 0, 1);\n num -= check(i, j, 1, 1);\n }\n }\n cout << \"! \" << num << endl;\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f0ee044c396ca7b6f7e5b331a88b1749", "src_uid": "11ad68b4375456733526e74e72606d8d", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\nint main()\n{\n int a,b,c;\n cin>>a>>b>>c;\n cout << ( b + a - 1) * c + a << endl;\n \n system(\"pause\");\n }\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1c6b167d6a1aa0783a1ac055e8a747b6", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nint main ()\n{\n\tint a1,a2;\n\tint i,j;\n\tchar digits[100];\n\tchar * str;\n\tcin>>a1>>a2;\n\tstr = itoa(a2,digits,10);\n int len = strlen(str);\n int res = 0;\n for (i = 0;i\r\nusing namespace std;\r\ntypedef long long ll;\r\nll n,a,b,c,d,e;\r\nchar f[3][3][3][3][3];\r\nint main(){\r\n\tf[1][0][0][1][0] = 'a';\r\n\tf[1][1][0][2][0] = 'b';\r\n\tf[2][0][0][1][1] = 'c';\r\n\tf[2][1][0][1][2] = 'd';\r\n\tf[1][1][0][1][1] = 'e';\r\n\tf[2][1][0][2][1] = 'f';\r\n\tf[2][2][0][2][2] = 'g';\r\n\tf[1][2][0][2][1] = 'h';\r\n\tf[1][1][0][1][1] = 'i';\r\n\tf[1][2][0][1][2] = 'j';\r\n\tf[1][0][1][2][0] = 'k';\r\n\tf[1][1][1][3][0] = 'l';\r\n\tf[2][0][1][2][1] = 'm';\r\n\tf[2][1][1][2][2] = 'n';\r\n\tf[1][1][1][2][1] = 'o';\r\n\tf[2][1][1][3][1] = 'p';\r\n\tf[2][2][1][3][2] = 'q';\r\n\tf[1][2][1][3][1] = 'r';\r\n\tf[1][1][1][2][1] = 's';\r\n\tf[1][2][1][2][2] = 't';\r\n\tf[1][0][2][2][1] = 'u';\r\n\tf[1][1][2][3][1] = 'v';\r\n\tf[1][2][1][1][3] = 'w';\r\n\tf[2][0][2][2][2] = 'x';\r\n\tf[2][1][2][2][3] = 'y';\r\n\tf[1][1][2][2][2] = 'z';\r\n\tcin>>n;\r\n\twhile(n --) cin>>a>>b>>c>>d>>e,cout(f[a][b][c][d][e])<\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n long log int n,m;\r\n cin>>n>>m;\r\n if(m==1)\r\n cout<<(n-1)<<\"\\n\";\r\n else\r\n cout<<(m-1) * n<<\"\\n\";\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dca700af002db005a33d3f42602e4abf", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FAST_IO ios::sync_with_stdio(false)\n#define sci(d) scanf(\"%d\", &d)\n#define scs(s) scanf(\"%s\", &s)\n\n#define SINF 20000000\n#define INF 2000000000\n#define LLINF 900000000000000000LL\n#define X first\n#define Y second\n#define MAX 1001\n#define MOD 1000000007LL\n#define endl \"\\n\"\n#define ALL(a) (a).begin(), (a).end()\n#define pr(n) operator[](n);\n\ntypedef long long ll;\ntypedef pair pi;\n\nint Q, N, M, K, L;\nll FAN[100001];\nint p[100001];\nll v[100001];\n\nstruct comp {\n\tbool operator() (const int& a, const int& b) const {\n\t\tif (v[a] != v[b]) return v[a] < v[b];\n\t\treturn a < b;\n\t}\n};\n\nset children[100001];\nint deg[100001];\nmultiset mulset;\n\nll value_for_self(int a) {\n\treturn FAN[a] - (1 + deg[a]) * value_for_other(a);\n}\nll value_for_other(int a) {\n\treturn FAN[a] / (2 + deg[a]);\n}\n\nint main() {\n\tFAST_IO;\n\tcin >> N >> M;\n\tfor (int i = 0; i < N; i++) cin >> FAN[i];\n\tfor (int i = 0; i < N; i++) {\n\t\tcin >> p[i]; p[i]--;\n\t\tchildren[p[i]].insert(i);\n\t\tdeg[p[i]]++;\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tv[i] += value_for_self(i);\n\t\tfor (int child : children[i])\n\t\t\tv[i] += value_for_other(child);\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tchildren[p[i]].erase(i);\n\t\tchildren[p[i]].insert(i);\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tif (children[i].empty()) continue;\n\t\tmulset.insert(v[*children[i].begin()] + value_for_other(i));\n\t\tmulset.insert(v[*children[i].rbegin()] + value_for_other(i));\n\t}\n\tfor (int q = 0; q < M; q++) {\n\t\tint a, b, c;\n\t\tcin >> a;\n\t\tif (a == 1) {\n\t\t\tcin >> b >> c;\n\t\t\tb--; c--;\n\n\t\t\tset go = { b, c, p[b], p[c], p[p[b]] };\n\t\t\tset go2 = go;\n\t\t\tfor (int n : go) go2.insert(p[n]);\n\n\t\t\tfor (int i : go2) {\n\t\t\t\tif (children[i].empty()) continue;\n\t\t\t\tmulset.erase(v[*children[i].begin()] + value_for_other(i));\n\t\t\t\tmulset.erase(v[*children[i].rbegin()] + value_for_other(i));\n\t\t\t}\n\t\t\tfor (int rep = -1; rep <= 1; rep += 2) { // first -1, then 1\n\t\t\t\tfor (int x : go) {\n\t\t\t\t\tv[x] += rep * value_for_self(x);\n\t\t\t\t\tfor (int y : go)\n\t\t\t\t\t\tif (p[y] == x)\n\t\t\t\t\t\t\tv[x] += rep * value_for_other(y);\n\t\t\t\t}\n\n\t\t\t\tif (rep == -1) {\n\t\t\t\t\tdeg[p[a]]--;\n\t\t\t\t\tp[a] = b;\n\t\t\t\t\tdeg[p[a]]++;\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tfor (int n : go)\n\t\t\t\tchildren[p[n]].insert(n);\n\n\t\t\tfor (int n : go2) {\n\t\t\t\tif (!deg[n]) continue;\n\t\t\t\tll pv = value_for_other(n);\n\t\t\t\tmulset.insert(v[*children[n].begin()] + pv);\n\t\t\t\tmulset.insert(v[*children[n].rbegin()] + pv);\n\t\t\t}\n\t\t}\n\t\tif (a == 2) {\n\t\t\tcin >> b;\n\t\t\tb--;\n\t\t\tcout << v[b] + value_for_other(p[b]) << endl;\n\t\t}\n\t\tif (a == 3) {\n\t\t\tcout << *mulset.begin() << \" \" << *mulset.rbegin() << endl;\n\t\t}\n\t}\n\tcin >> N;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "34e2fa624475f9716fc7f5c3d9c9a1a6", "src_uid": "6a17d93dad158f70a36905206aa0ba3b", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define all(x) (x).begin(), (x).end()\n#define pb push_back\n#define xx first\n#define yy second\n#define sz(x) (int)(x).size()\n#define gc getchar\n#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)\n#define mp make_pair\n\n#ifndef ONLINE_JUDGE\n# define LOG(x) (cerr << #x << \" = \" << (x) << endl)\n#else\n# define LOG(x) ((void)0)\n#endif\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n\nconst double PI=acos(-1);\nconst ll INF = 1LL<<62;\nconst ll MINF = -(1LL<<62);\n\ntemplate T getint() {\n\tT val=0;\n\tchar c;\n\t\n\tbool neg=false;\n\twhile((c=gc()) && !(c>='0' && c<='9')) {\n\t\tneg|=c=='-';\n\t}\n\n\tdo {\n\t\tval=(val*10)+c-'0';\n\t} while((c=gc()) && (c>='0' && c<='9'));\n\n\treturn val*(neg?-1:1);\n}\n\n//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution(0, n-1)(rng)\n\n#define int ll\nint n;\nconst int MAXN=100001;\nvector adj[MAXN];\nint dp[MAXN][2];\nint st[MAXN];\nvector children[MAXN];\nvector> dp2_g[MAXN];\nvector,2>> dp2_par[MAXN];\nvoid dfs(int x) {\n\tst[x]=1;\n\tvector& lst=children[x];\n\tfor(auto i:adj[x]) {\n\t\tif(!st[i]) {\n\t\t\tlst.pb(i);\n\t\t\tdfs(i);\n\t\t}\n\t}\n\t\n\tif(lst.empty()) {\n\t\tdp[x][0]=0;\n\t\tdp[x][1]=1LL<<46;\n\t\treturn ;\n\t}\n\t\n\tvector>& dp2=dp2_g[x];\n\tvector,2>>& par=dp2_par[x];\n\tdp2.resize(lst.size());\n\tpar.resize(lst.size());\n\t\n\tdp2[0][0]=dp[lst[0]][1];\n\tpar[0][0]={-1,1,0};\n\t\n\tdp2[0][1]=min(dp[lst[0]][1],dp[lst[0]][0])+2;\n\tpar[0][1]={-1,dp[lst[0]][1]dp2[i-1][1]+dp[lst[i]][1]) {\n\t\t\tdp2[i][1]=dp2[i-1][1]+dp[lst[i]][1];\n\t\t\tpar[i][1]={1,1,0};\n\t\t}\n\t\t//~ if(x==5) LOG(dp2[i-1][1]+min(dp[lst[i]][0],dp[lst[i]][1])+2);\n\t\tif(dp2[i][1]>dp2[i-1][1]+min(dp[lst[i]][0],dp[lst[i]][1])+2) {\n\t\t\tdp2[i][1]=dp2[i-1][1]+min(dp[lst[i]][0],dp[lst[i]][1])+2;\n\t\t\tpar[i][1]={1,dp[lst[i]][1]>& dp2=dp2_g[x];\n\tvector,2>>& par=dp2_par[x];\n\tpair state={sz(children[x])-1,y};\n\tfor(int j=sz(children[x])-1;j>=0;j--) {\n\t\t//~ LOG(x);\n\t\t\n\t\t//~ LOG(j);\n\t\t//~ LOG(state.yy);\n\t\t//~ LOG(par[j][state.yy][0]);\n\t\t//~ LOG(par[j][state.yy][1]);\n\t\t//~ LOG(par[j][state.yy][2]);\n\t\t//~ LOG(x);\n\t\t//~ LOG(state.yy);\n\t\t//~ LOG(j);\n\t\tif(par[state.xx][state.yy][2]) {\t\t\t\n\t\t\tswap(perm[children[x][j]], perm[x]);\n\t\t}\n\t\treconstruct(children[x][j], par[state.xx][state.yy][1]);\n\t\tstate.yy=par[state.xx][state.yy][0];\n\t\tstate.xx--;\n\t}\n}\n\n#ifdef LOCAL\nint dst[101][101];\n#endif\n\nmain() {\n\tIO;\n\t#ifdef LOCAL\n\tfor(auto&i:dst) for(auto&j:i) j=1e9;\n\t#endif\n\t\n\tcin>>n;\n\tfor(int i=1;i>a>>b;\n\t\tadj[a].pb(b);\n\t\tadj[b].pb(a);\n\t\t#ifdef LOCAL\n\t\tdst[a][b]=1;\n\t\tdst[b][a]=1;\n\t\tdst[i][i]=0;\n\t\tdst[i+1][i+1]=0;\n\t\t#endif\n\t}\n\t\n\t#ifdef LOCAL\n\tfor(int j=1;j<=n;++j) {\n\t\tfor(int i=1;i<=n;++i) {\n\t\t\tfor(int k=1;k<=n;++k) {\n\t\t\t\tif(dst[i][j]+dst[j][k]\n\nusing namespace std;\n\ntypedef vector vi;\n\nbool validarCubo(const vi& cubetmp){\n\tint cnt=1;\n\tint cols;\n\tfor(int i=0;i<6;++i){\n\t\tint col = cubetmp[cnt];\n\t\tcols+= ( cubetmp[cnt+1]==col && cubetmp[cnt+2]==col && cubetmp[cnt+3]==col);\n\t\tcnt+=4;\n\t}\n\t//cout << (cols==6) << endl; \n\treturn cols==6;\n}\n\nvoid girar(vi& cubetmp, const vi& f, bool ang){\n\t\n\tif(ang==90)\n\t\tfor(int i=0;i<7;i+=2){\n\t\t\tswap(cubetmp[f[i]],cubetmp[f[i+2]]);\n\t\t\tswap(cubetmp[f[i+1]],cubetmp[f[i+3]]);\n\t\t}\n\telse\n\t\tfor(int i=7;i>1;i-=2){\n\t\t\tswap(cubetmp[f[i]],cubetmp[f[i-2]]);\n\t\t\tswap(cubetmp[f[i-1]],cubetmp[f[i-3]]);\t\n\t\t}\n}\n\nint main(){\n\t\n\n\tfor(int i=1;i<=24;++i){\n\t\tcin >> cube[i];\n\t}\n\n\tint c0[]={13,14,5,6,17,18,21,22};\n\tint c1[]={3,4,17,19,10,9,16,14};\n\tint c2[]={15,16,7,8,19,20,23,24};\n\tint c3[]={1,3,5,7,9,11,24,22};\n\tint c4[]={2,4,6,8,10,12,23,21};\n\tint c5[]={18,20,12,11,15,13,1,2};\n\n\tbool solve = false;\n\n\t//cout << \"cube c0\" << endl;\n \tvi vc0(c0,c0+8);\n \tvi cubetmpc0(cube,cube+30);\n\tgirar(cubetmpc0,vc0,90);\n\tsolve |= validarCubo(cubetmpc0);\n\tcubetmpc0.assign(cube,cube+30);\n\tgirar(cubetmpc0,vc0,-90);\n \tsolve |= validarCubo(cubetmpc0);\n\n\t//cout << \"cube c2\" << endl;\n \tvi vc1(c1,c1+8);\n \tvi cubetmpc1(cube,cube+30);\n\tgirar(cubetmpc1,vc1,90);\n\tsolve |= validarCubo(cubetmpc1);\n\tcubetmpc1.assign(cube,cube+30);\n\tgirar(cubetmpc1,vc1,-90);\n \tsolve |= validarCubo(cubetmpc1);\n\n\t//cout << \"cube c2\" << endl;\n \tvi vc2(c2,c2+8);\n \tvi cubetmpc2(cube,cube+30);\n\tgirar(cubetmpc2,vc2,90);\n\tsolve |= validarCubo(cubetmpc2);\n\tcubetmpc2.assign(cube,cube+30);\n\tgirar(cubetmpc2,vc2,-90);\n \tsolve |= validarCubo(cubetmpc2);\n\n\t//cout << \"cube c3\" << endl;\n \tvi vc3(c3,c3+8);\n \tvi cubetmpc3(cube,cube+30);\n\tgirar(cubetmpc3,vc3,90);\n\tsolve |= validarCubo(cubetmpc3);\n\tcubetmpc3.assign(cube,cube+30);\n\tgirar(cubetmpc3,vc3,-90);\n \tsolve |= validarCubo(cubetmpc3);\n\n\t//cout << \"cube c4\" << endl;\n \tvi vc4(c4,c4+8);\n \tvi cubetmpc4(cube,cube+30);\n\tgirar(cubetmpc4,vc4,90);\n\tsolve |= validarCubo(cubetmpc4);\n\tcubetmpc4.assign(cube,cube+30);\n\tgirar(cubetmpc4,vc4,-90);\n \tsolve |= validarCubo(cubetmpc4);\n\n\t//cout << \"cube c5\" << endl;\n \tvi vc5(c5,c5+8);\n \tvi cubetmpc5(cube,cube+30);\n\tgirar(cubetmpc5,vc5,90);\n\tsolve |= validarCubo(cubetmpc5);\n\tcubetmpc5.assign(cube,cube+30);\n\tgirar(cubetmpc5,vc5,-90);\n \tsolve |= validarCubo(cubetmpc5);\n\n \tcout << (solve? \"YES\":\"NO\") << endl;\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a2dcbc499cd5e57b0365fbb3881cab28", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "/*\n * 2011-08-29 Martin \n\n * \n */\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntemplate inline T checkmin(T &a, T b)\n{\n\treturn (a < b) ? a : a = b;\n}\n\ntemplate inline T checkmax(T &a, T b)\n{\n\treturn (a > b) ? a : a = b;\n}\n\ntemplate T GCD(T a, T b)\n{\n\tif (a < 0)\n\t\treturn GCD(- a, b);\n\tif (b < 0)\n\t\treturn GCD(a, - b);\n\treturn (a == 0) ? b : GCD(b % a, a);\n}\n\ntemplate T LCM(T a, T b)\n{\n\tif (a < 0)\n\t\treturn LCM(- a, b);\n\tif (b < 0)\n\t\treturn LCM(a, - b);\n\treturn (a == 0 || b == 0) ? 0 : a / GCD(a, b) * b;\n}\n\n#define tr(i, x) for (typeof(x.begin()) i = x.begin(); i != x.end(); ++ i)\n#define rep(i, n) for (int i = 0; i < n; ++ i)\n#define pii pair \n#define mp make_pair\n#define pb push_back\n#define x first\n#define y second\n#define ll long long\n\nnamespace Poor\n{\n\tint A, L, Ans;\n\t\n\tint Count(uint n)\n\t{\n\t\tif (n < 10)\n\t\t\treturn (n == 4 || n == 7);\n\t\treturn Count(n / 10) + Count(n % 10);\n\t}\n\t\n\tinline bool Check(uint X, uint Y, int L)\n\t{\n\t\trep (i, 50)\n\t\t{\n\t\t\tint l = rand() % L;\n\t\t\tif (Count(X + l) != Count(Y + l))\n\t\t\t\treturn 0;\n\t\t\tif (i < L && Count(X + i) != Count(Y + i))\n\t\t\t\treturn 0;\n\t\t\tif (i < L && Count(X + L - i - 1) != Count(Y + L - i - 1))\n\t\t\t\treturn 0;\n\t\t\tif ((ll) i * 99 < L && Count(X + i * 99) != Count(Y + i * 99))\n\t\t\t\treturn 0;\n\t\t\tif ((ll) i * 9999 < L && Count(X + i * 9999) != Count(Y + i * 9999))\n\t\t\t\treturn 0;\n\t\t\tif ((ll) i * 999999 < L && Count(X + i * 999999) != Count(Y + i * 999999))\n\t\t\t\treturn 0;\n\t\t\tif ((ll) i * 99999999 < L && Count(X + i * 99999999) != Count(Y + i * 99999999))\n\t\t\t\treturn 0;\n\t\t}\n\t\treturn 1;\n\t}\n\t\n\tbool Tried(int X, int Y, int pw)\n\t{\n\t\tint Tmp = Count(X) - Count(Y);\n\t\tfor (int i = 1; i < L && X + i < pw && Y + i < pw; ++ i)\n\t\t\tif (Count(X + i) - Count(Y + i) != Tmp)\n\t\t\t\treturn 0;\n\t\tint Start = min(pw - X, pw - Y);\n\t\tTmp = Count(X + Start) - Count(Y + Start);\n\t\tfor (int i = Start + 1; i < L && (X + i < pw || Y + i < pw); ++ i)\n\t\t\tif (Count(X + i) - Count(Y + i) != Tmp)\n\t\t\t\treturn 0;\n\t\tStart = max(pw - X, pw - Y);\n\t\tTmp = Count(X + Start) - Count(Y + Start);\n\t\tfor (int i = Start + 1; i < L && X + i < pw * 2 && Y + i < pw * 2; ++ i)\n\t\t\tif (Count(X + i) - Count(Y + i) != Tmp)\n\t\t\t\treturn 0;\n\t\treturn 1;\n\t}\n\t\n\tint Log(int x)\n\t{\n\t\tint res = 0;\n\t\twhile (x > 1)\n\t\t{\n\t\t\tx /= 10;\n\t\t\t++ res;\n\t\t}\n\t\treturn res;\n\t}\n\t\n\tvoid DFS(int v, int c, int pw)\n\t{\n\t\t//~ cerr << v << \" \" << c << endl;\n\t\tif (c < 0)\n\t\t\treturn;\n\t\tif (v < Ans)\n\t\t{\n\t\t\tif (c == 0)\n\t\t\t{\n\t\t\t\tif (A < v && Check(A, v, L))\n\t\t\t\t\tAns = v;\n\t\t\t\tif (pw == 1000000000 && A < v + pw && v + pw < Ans && Check(A, v + pw, L))\n\t\t\t\t\tAns = v + pw;\n\t\t\t}\n\t\t\tif (pw == 1000000000)\n\t\t\t\treturn;\n\t\t\tif (Log(1000000000 / pw) < c)\n\t\t\t\treturn;\n\t\t\tif (pw <= 1000 && !Tried(A % pw, v, pw))\n\t\t\t\treturn;\n\t\t\tDFS(v + pw * 4, c - 1, pw * 10);\n\t\t\tDFS(v + pw * 7, c - 1, pw * 10);\n\t\t\trep (i, 10)\n\t\t\t\tif (i != 4 && i != 7)\n\t\t\t\t\tDFS(v + pw * i, c, pw * 10);\n\t\t}\n\t}\n\t\n\tvoid Run()\n\t{\n\t\tsrand(time(NULL));\n\t\tcin >> A >> L;\n\t\tAns = A + 1000000000;\n\t\tint c = Count(A);\n\t\tfor (int i = 0; i < 10; ++ i)\n\t\t\tDFS(i, c - Count(i), 10);\n\t\tcout << Ans << endl;\n\t}\n}\n\nint main()\n{\n\tPoor::Run();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d9cfec8378f38157ff48f2b6913b0bba", "src_uid": "649e9f477b97c1f72b05d409b4a99d59", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\n#define int long long\n\nconst int kMaxN = 250 + 5;\nconst int Mod = 1000000007;\n\nint n , k , ans , power_k1[kMaxN * kMaxN] , power_k2[kMaxN * kMaxN] , C[kMaxN][kMaxN];\n\ninline int read(){\n\tint s = 0 , w = 1;\n\tchar ch = getchar();\n\twhile((ch < '0') || (ch > '9')){\n\t\tif(ch == '-'){\n\t\t\tw = -1;\n\t\t}\n\t\tch = getchar();\n }\n \twhile((ch >= '0') && (ch <= '9')){\n \t\ts = (s << 3) + (s << 1) + ch - '0';\n\t\tch = getchar();\n\t}\n \treturn s * w;\n}\n\ninline void write(int x){\n if(x < 0){\n putchar('-');\n x = -x;\n }\n if(x > 9){\n \twrite(x / 10);\n\t}\n putchar(x % 10 + '0');\n return ;\n}\n\n\nsigned main(){\n\n\tn = read();\n\tk = read();\n\t\n\tpower_k1[0] = 1;\n\tpower_k2[0] = 1;\n\t\n\tfor(int i = 1 ; i <= n * n ; i++ ){\n power_k1[i] = power_k1[i - 1] * k % Mod;\n power_k2[i] = power_k2[i - 1] * (k - 1) % Mod;\n }\n \n C[0][0] = 1;\n \n for(int i = 1 ; i <= n ; i++ ){\n for(int j = 1 ; j <= i ; j++ ){\n C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;\n }\n }\n \n for(int i = 0 ; i <= n ; i++ ){\n for(int j = 0 ; j <= n ; j++ )[\n int num = i * n + j * n - i * j;\n if((i + j) & 1 == 1){\n ans -= (power_k2[num] * power_k1[n * n - num] % Mod * C[n][i] % Mod * C[n][j]) % Mod;\n }\n else{\n ans += (power_k2[num] * power_k1[n * n - num] % Mod * C[n][i] % Mod * C[n][j]) % Mod;\n }\n }\n }\n \n cout << ans << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0fd5fc86735a37d676d3e51e50dc8d52", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \n\ntypedef long long LL;\ntypedef double DB;\n\n#define sf scanf\n#define pf printf\n#define mp make_pair\n#define nl printf(\"\\n\")\n\n#define FOR(i,a,b) for(i = a; i <= b; ++i)\n#define FORD(i,a,b) for(i = a; i >= b; --i)\n#define FORS(i,n) for(i = 0; i < n; ++i)\n#define FORM(i,n) for(i = n - 1; i >= 0; --i)\n#define reset(i,n) memset(i, n, sizeof(i))\n#define open freopen(\"input.txt\",\"r\",stdin); freopen(\"output.txt\",\"w\",stdout)\n#define close fclose(stdin); fclose(stdout)\n\nusing namespace std;\n\nconst LL mod = 1e9 + 7;\nconst LL INF = 4e18;\nconst int inf = 2e9;\nconst int N = 2e5;\n\nint gcd(int a, int b) { return b? gcd(b, a%b): a; }\nint lcm(int a, int b) { return a/ gcd(a, b)*b; }\n\nvector enemy[N + 5];\npair will[N + 5];\n\nint main(void)\n{\n int n, k, i, j;\n sf(\"%d %d\", &n, &k);\n int need = n - k + 1;\n if(need == 0) {\n puts(\"0\");\n return 0;\n }\n FORS(i, n) {\n int p, e;\n sf(\"%d %d\", &p, &e);\n enemy[p].push_back(e);\n will[i] = mp(e, p);\n }\n FOR(i, 0, N) if(enemy[i].size()) {\n sort(enemy[i].begin(), enemy[i].end());\n }\n sort(will, will + n);\n int point = 1, loser = enemy[0].size() + enemy[1].size();\n int obv = 0;\n while(loser < need) {\n point++;\n loser += enemy[point].size();\n if(point >= 2) obv += enemy[point-2].size();\n }\n if(point > n) {\n puts(\"-1\");\n return 0;\n }\n bool awal = 1;\n LL ans = INF;\n for(; loser <= n; point++) {\n if(!awal) {\n loser += enemy[point].size();\n if(point >= 2) obv += enemy[point-2].size();\n }\n awal = 0;\n int from = need - obv;\n if(enemy[point].size() + enemy[point-1].size() < from) continue;\n int a = 0, b = 0;\n LL cur = 0;\n //cout << from << endl;\n FORS(i, from) {\n int lef = (a < enemy[point-1].size()? enemy[point-1][a] : inf);\n int rig = (b < enemy[point].size()? enemy[point][b] : inf);\n if(lef < rig) cur += lef, a++;\n else cur += rig, b++;\n }\n if(from < 0) from = 0;\n int udah = 0;\n //pf(\"a b : %d %d\\n\", a, b);\n for(i = 0; udah < point - from; i++) {\n int id = will[i].second;\n int cost = will[i].first;\n if(id == point - 1 && a) {\n a--;\n continue;\n }\n if(id == point && b) {\n b--;\n continue;\n }\n udah++;\n cur += cost;\n }\n //pf(\"haha %d %I64d\\n\", point, cur);\n ans = min(ans, cur);\n if(obv >= need) break;\n }\n cout << (ans == INF? -1 : ans) << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4804b2fb5f981f5593cb1331aedb83dc", "src_uid": "19a098cef100fc3652c59abf7c373814", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long int LLI;\ntypedef pair PII;\n\n#define _ ios_base::sync_with_stdio(0);\n#define debug\n#define x first\n#define y second\n#define MXN 100005\n\nconst int inf = 0x3f3f3f3f;\nconst int mod = 1e9+7;\nconst double eps = 1e-8; \n\nint w[MXN];\n\nint main() { _\n int n;\n while (cin >> n) {\n for (int i = 0; i < 2*n; ++i) cin >> w[i];\n sort(w, w+2n);\n int mn = 0, cur = 0;\n for (int i = 1; i < 2*n-1; ++i) mn = w[i+1] - w[i];\n for (int i = 0; i < n; ++i) {\n cur = 0;\n for (int j = 0; j < n; ++j) {\n if (i == j) continue;\n cur += w[2*j+1] - w[2*j];\n }\n mn = min(cur, mn);\n }\n cout << mn << \"\\n\";\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7d3a2463540c86872d610d2ee42ca6f1", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#ifndef LOCAL\n#pragma GCC optimize(\"O3\")\n#endif\n\n#include \n\nusing namespace std;\n#define sim template muu & operator<<(\n#define ris return *this\n#define R22(r) sim>typename enable_if<1 r sizeof(dud(0)),muu&>::type operator<<(c g) {\nsim>\nstruct rge {\n c b, e;\n};\n\nsim> rge range(c i, c j) { return rge{i, j}; }\n\nsim> auto dud(c *r) -> decltype(cerr << *r);\n\nsim> char dud(...);\n\nstruct muu {\n#ifdef LOCAL\n stringstream a;\n\n ~muu() { cerr << a.str() << endl; }\n\n R22(<) a << boolalpha << g;\n ris; }\n\n R22(==) ris << range(begin(g), end(g)); }\n\n sim mor rge u) {\n a << \"[\";\n for (c i = u.b; i != u.e; ++i)\n *this << \", \" + 2 * (i == u.b) << *i;\n ris << \"]\";\n }\n\n sim, class m mor pair r) { ris << \"(\" << r.first << \", \" << r.second << \")\"; }\n\n#else\n sim mor const c&){ris;}\n#endif\n};\n\n#define debug muu() << __FUNCTION__ << \"#\" << __LINE__ << \": \"\n#define imie(r...) \"[\" #r \": \" << (r) << \"] \"\n#define range(a, b) \"[[\" #a \", \" #b \"): \" << range(a, b) << \"] \"\n#define arr(a, i) \"[\" #a imie(i) \": \" << a[i] << \"] \"\nusing pii = pair;\nusing ld = long double;\nusing ll = long long;\n\nconst int MAXN = 2027;\n\nll dp1[MAXN][MAXN];\nll dp2[2][MAXN][MAXN];\n\nint N;\nint K;\nint wyn3 = 0;\n\nvoid adam(int n, int m, vector &wziete) {\n vector curr = wziete;\n vector nowy;\n bool spoczko = !wziete.empty();\n for (int i = 1; i < K; i++) {\n int suma = 0;\n for (int n = 0; n < curr.size(); n++) {\n for (int w = 0; w < curr[n]; w++) {\n nowy.push_back(n + 1);\n suma += n + 1;\n }\n if (suma > N) {\n spoczko = false;\n break;\n }\n }\n if (!spoczko)\n break;\n reverse(nowy.begin(), nowy.end());\n curr = move(nowy);\n }\n if (spoczko)\n wyn3++;\n for (int i = min(n, m); i >= 1; i--) {\n wziete.push_back(i);\n adam(n - i, i, wziete);\n wziete.pop_back();\n }\n}\n\nint main() {\n const int mod = 998244353;\n scanf(\"%d%d\", &N, &K);\n if (K == 1) {\n for (int i = 0; i <= N; i++)\n dp1[0][i] = 1;\n ll wyn = 0;\n for (int sum = 1; sum <= N; sum++) {\n for (int x = 1; x <= sum; x++) {\n dp1[sum][x] = dp1[sum][x - 1] + dp1[sum - x][x];\n dp1[sum][x] %= mod;\n }\n for (int x = sum + 1; x <= N; x++)\n dp1[sum][x] = dp1[sum][x - 1];\n wyn += dp1[sum][N];\n wyn %= mod;\n }\n printf(\"%lld\", wyn);\n } else if (K == 2) {\n int curr = 0;\n for (int i = 0; i <= N; i++)\n dp2[curr][0][i] = 1;\n ll wyn = 0;\n for (int n = 1; n <= 64; n++) {\n curr = !curr;\n for (int sum = 1; sum <= N; sum++) {\n for (int x = N; x >= 1; x--) {\n if (sum - x * n >= 0)\n dp2[curr][sum][x] = dp2[!curr][sum - x * n][x];\n else\n dp2[curr][sum][x] = 0;\n dp2[curr][sum][x] %= mod;\n wyn += dp2[curr][sum][x];\n wyn %= mod;\n dp2[curr][sum][x] += dp2[curr][sum][x + 1];\n }\n debug << imie(n) imie(sum);\n debug << range(dp2[curr][sum] + 1, dp2[curr][sum] + N + 1);\n }\n for (int x = 0; x <= N; x++)\n dp2[curr][0][x] = 0;\n }\n printf(\"%lld\", wyn);\n } else {\n vector wziete;\n int maxi = (int) sqrt(2 * N);\n adam(maxi, maxi, wziete);\n printf(\"%d\", wyn3);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "283a4da9c88a2bd8d9cc3be851215a28", "src_uid": "c435a0cd437081cd3593637be4568c6a", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include\n#define int long long\n#define pb push_back\n#define F first\n#define S second\n#define ld long double\n\nusing namespace std;\nconst int N = 2e5;\nint pi[N], a[N];\n\ninline void solve()\n{\n int n, m;\n cin >> n >> m;\n for(int i = 0; i < n; i++)\n {\n int l, r;\n cin >> l >> r;\n l--;\n pi[l]++;\n pi[r]--;\n }\n int now = 0;\n for(int i = 0; i < m; i++)\n {\n now += pi[i];\n a[i] = now;\n }\n int dp[n + 1];\n dp[0] = -1e18;\n for(int i = 1; i <= m; i++)\n {\n dp[i] = 1e18;\n }\n for(int i = 0; i < m; i++)\n {\n int l = -1, r = m + 2;\n while(l < r - 1)\n {\n int mid = (l + r) / 2;\n if(dp[mid] <= a[i])\n {\n l = mid;\n }\n else\n {\n r = mid;\n }\n }\n dp[l + 1] = a[i];\n }\n int maxx = 0;\n for(int i = 0; i <= m; i++)\n {\n if(dp[i] == 1e18)\n {\n break;\n }\n maxx = i;\n }\n cout << maxx;\n}\n\nsigned main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "83e6846ca330a11d5b2806de7db13034", "src_uid": "ce8350be138ce2061349d7f9224a5aaf", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n#define ll long long\nll a,n,s,p,k;\nint main()\n{\n cin>>k>>n>>s>>p;\n a=(n/s+(n%s!=0))*k; ahmad\n a=a/p+(a%p!=0);\n cout<\nusing namespace std;\n#define ll long long int\n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\nint main()\n{\n IOS;\n ll a,b,two=0,three=0;\n cin>>a>>b;\n if(a-b>=3)\n cout<<2<=three)\n cout<<2<\nusing namespace std;\n\nusing cd = complex;\n#define sz(a) (int)a.size()\n#define F0R(i,n) for (int i = 0; i < (int)n; i++)\n#define FOR(i,j,n) for (int i = j; i < (int)n; i++)\n#define ld long double\n\ntypedef vector vcd;\ntypedef vector vl;\ntypedef long long ll;\n\nnamespace FFT {\n int get(int s) {\n return s > 1 ? 32 - __builtin_clz(s - 1) : 0;\n }\n \n void fft(vcd& a, bool inv){\n \tint n = sz(a), j = 0;\n \tvcd roots(n/2);\n \tFOR(i,1,n) {\n \t\tint bit = (n >> 1);\n \t\twhile (j >= bit){\n \t\t\tj -= bit;\n \t\t\tbit >>= 1;\n \t\t}\n \t\tj += bit;\n \t\tif(i < j) swap(a[i], a[j]);\n \t}\n\n \tld ang = 2 * M_PIl / n * (inv ? -1 : 1);\n \tF0R(i,n/2) roots[i] = cd(cos(ang * i), sin(ang * i));\n \n \tfor (int i=2; i<=n; i<<=1){\n \t\tint step = n / i;\n \t\tfor(int j=0; j> 15, a[i] & 32767);\n \tF0R(i,sz(b)) v2[i] = cd(b[i] >> 15, b[i] & 32767);\n \tfft(v1, 0); fft(v2, 0);\n \t\n \tF0R(i,n) {\n \t\tint j = (i ? (n - i) : i);\n \t\tcd ans1 = (v1[i] + conj(v1[j])) * cd(0.5, 0);\n \t\tcd ans2 = (v1[i] - conj(v1[j])) * cd(0, -0.5);\n \t\tcd ans3 = (v2[i] + conj(v2[j])) * cd(0.5, 0);\n \t\tcd ans4 = (v2[i] - conj(v2[j])) * cd(0, -0.5);\n \t\tr1[i] = (ans1 * ans3) + (ans1 * ans4) * cd(0, 1);\n \t\tr2[i] = (ans2 * ans3) + (ans2 * ans4) * cd(0, 1);\n \t}\n \tfft(r1, 1); fft(r2, 1);\n vl ret(n);\n \tF0R(i,n) {\n \t\tll av = (ll)round(r1[i].real());\n \t\tll bv = (ll)round(r1[i].imag()) + (ll)round(r2[i].real());\n \t\tll cv = (ll)round(r2[i].imag());\n \t\tav %= mod, bv %= mod, cv %= mod;\n \t\tret[i] = (av << 30) + (bv << 15) + cv;\n \t\tret[i] %= mod; ret[i] += mod; ret[i] %= mod;\n \t}\n \tret.resize(s);\n \treturn ret;\n }\n}\n\ntemplate \nclass Modular {\npublic:\n Modular(long long v=0) {\n value = v % MOD;\n if (value < 0)\n value += MOD;\n }\n\n Modular& operator+=(Modular const& b) {\n value += b.value;\n if (value >= MOD)\n value -= MOD;\n return *this;\n }\n\n Modular& operator-=(Modular const& b) {\n value -= b.value;\n if (value < 0)\n value += MOD;\n return *this;\n }\n\n Modular& operator*=(Modular const& b) {\n value *= b.value;\n value %= MOD;\n return *this;\n }\n\n friend Modular power(Modular a, long long e) {\n Modular res = 1;\n while (e) {\n if (e & 1)\n res *= a;\n a *= a;\n e >>= 1;\n }\n return res;\n }\n\n friend Modular inverse(Modular a) {\n return power(a, MOD - 2);\n }\n\n Modular& operator/=(Modular const& b) {\n return *this *= inverse(b);\n }\n\n friend Modular operator+(Modular a, Modular const b) {\n return a += b;\n }\n\n friend Modular operator-(Modular a, Modular const b) {\n return a -= b;\n }\n\n friend Modular operator*(Modular a, Modular const b) {\n return a *= b;\n }\n\n friend Modular operator/(Modular a, Modular const b) {\n return a /= b;\n }\n\n friend std::ostream& operator<<(std::ostream &os, Modular const& a) {\n return os << a.value;\n }\n\n friend bool operator==(Modular const& a, Modular const& b) {\n return a.value == b.value;\n }\n\n friend bool operator!=(Modular const& a, Modular const& b) {\n return a.value != b.value;\n }\n\n long long value;\n};\n\nconst int MOD = 1'000'000'007;\nusing ModInt = Modular;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n\n int n;\n cin >> n;\n vector a(n);\n for (int i = 0; i < n; i++) {\n cin >> a[i];\n }\n \n // FFT fft(n * 2 - 1);\n ModInt pre_factor = 1;\n vector res(2 * n - 1);\n for (int i = 0; i < n - 1; i++) {\n vector v(n - i, 1);\n v[0] = 0;\n ModInt f = 1;\n for (int j = i + 1; j < n - 1; j++) {\n f *= a[j];\n v[j - i + 1] = f.value;\n }\n\n // path ending here\n for (int j = 0; j < n - i; j++) {\n res[j] += v[j] * pre_factor * a[i];\n }\n\n // mixed paths\n ModInt factor = pre_factor * a[i] * (a[i] - 1) / 2;\n vector g(v.begin(), v.end());\n auto product = FFT::conv(g, g, MOD);\n // auto product = fft.multiply_bigmod(v, v, MOD);\n for (int j = 0; j < min(2*n - 1, (int)product.size()); j++) {\n res[j] += factor * product[j];\n }\n\n pre_factor *= a[i];\n }\n\n res.erase(res.begin());\n for (auto x : res)\n cout << x << \" \";\n cout << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a325f68705ea1033cf85882c986498da", "src_uid": "3b86dfd0d077bc857ae3de70f026a409", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#ifdef DEBUG\n#define _GLIBCXX_DEBUG\n#endif\n//#pragma GCC optimize(\"O3\")\n#include \nusing namespace std;\ntypedef double ld;\ntypedef long long ll;\n// \u0421\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\n\n/*\n\n\u0420\u0435\u0448\u0430\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443:\na11 * x1 + a12 * x2 + ... + a1n * xn + b1 >= 0\na21 * x1 + a22 * x2 + ... + a2n * xn + b2 >= 0\n... .. ... .. ... ... .. .. .\nam1 * x1 + am2 * x2 + ... + amn * xn + bm >= 0\n c1 * x1 + c2 * c2 + ... + cn * xn -> max\n\n\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f x1 >= 0, ..., xn >= 0.\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 - \u043c\u0430\u0442\u0440\u0438\u0446\u0430 (m+1)*(n+1):\na11 a12 ... a1n b1\na21 a22 ... a2n b2\n... ... ... ... ..\nam1 am2 ... amn bm\n c1 c2 ... cn 0\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:\nfirst - \u0442\u0438\u043f \u0440\u0435\u0448\u0435\u043d\u0438\u044f (\u0435\u0433\u043e \u043d\u0435\u0442, \u043b\u0438\u0431\u043e \u043e\u043d\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e, \u043b\u0438\u0431\u043e \u043e\u043d\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0432\u0435\u043b\u0438\u043a\u043e)\nsecond - \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 (\u0435\u0441\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e) \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435:\n\nx1 x2 ... xn res\n\n*/\n\nconst ld eps = 1e-6;\ninline void vectorDel(vector &v, int value) {\n int idx = find(begin(v), end(v), value) - begin(v);\n swap(v[idx], v.back());\n v.pop_back();\n}\n\nenum class SolutionType {\n BOUNDED,\n UNBOUNDED,\n NO_SOLUTION\n};\n\nclass SimplexMethod {\nprivate:\n int h, w, n;\n vector< vector > a;\n vector isBasic;\n vector basic, nonBasic;\n\n inline void replace(int x, int y) {\n long double k = -a[x][y];\n a[x][y] = 0;\n for (int j = 0; j <= n; j++) {\n if (!isBasic[j]) {\n a[y][j] = a[x][j] / k;\n a[x][j] = 0;\n }\n }\n a[y][x] = -1 / k;\n isBasic[x] ^= 1;\n isBasic[y] ^= 1;\n vectorDel(basic, x);\n vectorDel(nonBasic, y);\n basic.push_back(y);\n nonBasic.push_back(x);\n basic.push_back(n);\n nonBasic.push_back(n);\n for (int i : basic) {\n for (int j : nonBasic) {\n a[i][j] += a[i][y] * a[y][j];\n }\n a[i][y] = 0;\n }\n basic.pop_back();\n nonBasic.pop_back();\n }\n\n inline int findPositive() {\n int best = 0;\n for (int j = 1; j < n; j++) {\n if (!isBasic[j] && a[n][j] > a[n][best] + eps) {\n best = j;\n }\n }\n return (a[n][best] > eps) ? best : -1;\n }\n\n inline int findBasic(int x) {\n long double add = 0;\n int best = -1;\n for (int i = 0; i < n; i++) {\n if (!isBasic[i] || a[i][x] > -eps) {\n continue;\n }\n long double grow = -a[i][n] / a[i][x];\n if (best < 0 || grow + eps < add) {\n add = grow;\n best = i;\n }\n }\n return best;\n }\n\n inline bool findAnyPoint() {\n int minB = -1;\n for (int i = 0; i < n; i++) {\n if (minB < 0 || a[i][n] < a[minB][n]) {\n minB = i;\n }\n }\n if (minB < 0 || a[minB][n] > -eps) {\n return true;\n }\n auto lastRow = a.back();\n isBasic.insert(begin(isBasic) + n, false);\n nonBasic.push_back(n);\n auto newA = a;\n a.pop_back();\n a.emplace_back(n+2, 0);\n a.emplace_back(n+2, 0);\n a.back()[n] = -1;\n for (int i = 0; i < n; i++) {\n a[i].insert(begin(a[i]) + n, 1, isBasic[i] ? 1 : 0);\n }\n n++;\n replace(minB, n-1);\n doSolve(false);\n if (a[n][n] < -eps) {\n return false;\n }\n if (isBasic[n-1]) {\n for (int i : nonBasic) {\n if (abs(a[n-1][i]) > eps) {\n replace(n-1, i);\n break;\n }\n }\n }\n n--;\n for (int i = 0; i < n; i++) {\n a[i].erase(begin(a[i]) + n, begin(a[i]) + n + 1);\n }\n isBasic.erase(begin(isBasic) + n, begin(isBasic) + n + 1);\n a.pop_back();\n a.pop_back();\n a.push_back(lastRow);\n for (int i : basic) {\n for (int j : nonBasic) {\n a[n][j] += a[n][i] * a[i][j];\n }\n a[n][i] = 0;\n }\n vectorDel(nonBasic, n);\n return true;\n }\n\n inline SolutionType doSolve(bool needFindInitial = true) {\n if (needFindInitial && !findAnyPoint()) {\n return SolutionType::NO_SOLUTION;\n }\n for (;;) {\n int x = findPositive();\n if (x < 0) {\n return SolutionType::BOUNDED;\n }\n int y = findBasic(x);\n if (y < 0) {\n return SolutionType::UNBOUNDED;\n }\n replace(y, x);\n }\n }\npublic:\n pair > solve() {\n SolutionType type = doSolve();\n if (type != SolutionType::BOUNDED) {\n return {type, {}};\n }\n vector v(w+1);\n for (int i = 0; i < w; i++) {\n v[i] = a[i][n];\n }\n v[w] = a[n][n];\n return {type, v};\n }\n\n SimplexMethod(const vector< vector > &v)\n : h((int)v.size() - 1), w((int)v[0].size() - 1), n(h + w),\n a(n+1, vector(n+1)), isBasic(n+1, true) {\n for (int i = 0; i < w; i++) {\n isBasic[i] = false;\n }\n isBasic[n] = false;\n for (int i = 0; i <= h; i++) {\n for (int j = 0; j <= w; j++) {\n a[i + w][(j == w) ? n : j] = v[i][j];\n }\n }\n for (int i = 0; i < n; i++) {\n (isBasic[i] ? basic : nonBasic).push_back(i);\n }\n }\n};\n\nint n, m;\nconst int maxN = 55;\nint dist[maxN][maxN];\nint id[maxN][maxN];\nint sz = 1;\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n //freopen(\"input.txt\", \"r\", stdin);\n cin >> n >> m;\n for (int i = 1; i <= m; i++) {\n int u, v, w;\n cin >> u >> v >> w;\n dist[u][v] = w;\n id[u][v] = sz;\n sz++;\n }\n int q;\n cin >> q;\n while (q--) {\n int t;\n cin >> t;\n vector > all;\n for (int vert = 1; vert <= n; vert++) {\n if (vert == 1) {\n vector < ld > f(n + m + 1);\n f[0] = -1;\n all.push_back(f);\n continue;\n }\n for (int p = 1; p <= n; p++) {\n if (dist[p][vert]) {\n vector < ld > f(n + m + 1);\n f[p - 1] = 1;\n f[vert - 1] = -1;\n f[n + m] = dist[p][vert];\n f[id[p][vert] + n - 1] = 1;\n all.emplace_back(f);\n }\n }\n }\n vector < ld > f(n + m + 1);\n for (int i = n; i <= n + m - 1; i++) f[i] = -1;\n f[n + m] = t;\n all.emplace_back(f);\n vector < ld > g(n + m + 1);\n g[n - 1] = 1;\n all.emplace_back(g);\n auto res = SimplexMethod(all).solve();\n cout << fixed << setprecision(10) << res.second.back() << '\\n';\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "448045835ae8df95f19d595eb13b2bc7", "src_uid": "b0751071e12f729f6700586c5a8eed23", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntemplate \ninline bool rd(T &ret) {\n\tchar c; int sgn;\n\tif (c = getchar(), c == EOF) return 0;\n\twhile (c != '-' && (c<'0' || c>'9')) c = getchar();\n\tsgn = (c == '-') ? -1 : 1;\n\tret = (c == '-') ? 0 : (c - '0');\n\twhile (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');\n\tret *= sgn;\n\treturn 1;\n}\ntemplate \ninline void pt(T x) {\n\tif (x < 0) {\n\t\tputchar('-');\n\t\tx = -x;\n\t}\n\tif (x > 9) pt(x / 10);\n\tputchar(x % 10 + '0');\n}\ntypedef long long ll;\ntypedef pair pii;\nconst int N = 100005;\nint k, m;\nsets;\nbool ok(int a, int b) {\n\tif (m == 0)return false;\n\tif (s.count({ a, b }) || a<0 || b<0)return false;\n\tif (a + b == k || a - b == k || a*b == k || (b && a%b == 0 && a / b == k))\n\t{\n\t\ts.insert({ a,b });\n\t\tprintf(\"%04d%04d\\n\", a, b);\n\t\tm--;\n\t\treturn true;\n\t}\n\treturn false;\n}\nvoid go(int a, int b) {\n\tok(a, b);\n\tok(b, a);\n}\nint main() {\n\trd(k);rd(m);\n\tfor (int i = 0; m > 0 && i < 10000; i++)\n\t{\n\t\tgo(i, i - k);\n\t\tgo(i, i + k);\n\t\tgo(i, k / i);\n\t\tgo(i, i*k);\n\t}\n\treturn 0;\n}\n/*\n5 1\n3 3\n\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "384776ed091e4d6f509fb4f87af63a98", "src_uid": "4720ca1d2f4b7a0e553a3ea07a76943c", "difficulty": 2700.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n\nint a[3000];\n\nmain()\n{\n\tint n,m,i,x,t,N;\n\tcin>>n>>m;\n\t\n\tif(n>m)\n\t{\n\t\tt=n;\n\t\tn=m;\n\t\tm=t;\n\t}\n\n\tN=n;\n\n\tcin>>x;\n\n\tif(x>(N+1)/2)\n\t{\n\t\tcout<<0<\nusing namespace std;\nint main()\n{\n long int a,b,c;\n int x=-1;\n cin a>>b>>c;\n while(((a>=0)&&(b>=0))&&(c>=0))\n {\n a-=3;\n b-=2;\n c-=2;\n x++;\n }\n x*=7;\n if(a<0)\n a+=3;\n if(b<0)\n b+=2;\n if(c<0)\n c+=2;\n if(a>3)\n a=3;\n if(b>3)\n b=3;\n if(c>3)\n c=3;\n if((a+b+c)==6)\n cout<<(x+6);\n else if((a+b+c)==2)\n cout<<(x+2);\n else if((a+b+c)==5)\n {\n if(b==0)\n cout<<(x+3);\n if(c==0)\n cout<<(x+4);\n }\n else if((a+b+c)==3)\n {\n if(((a==b)&&(b==c))||((a==1)&&(c==2))||((a==2)&&(b==1)))\n cout<<(x+3);\n else\n cout<<(x+2);\n }\n else if((a+b+c)==4)\n {\n if(((a==2)&&(b==1))||((a==2)&&(c==0))||((a==1)&&(b==1)))\n cout<<(x+4);\n else if((a==2)&&(b==1))||((a==3)&&(b==0)))\n cout<<(x+2);\n else\n cout<<(x+3);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "18fe08fc27fea9fd91d100b87619b00d", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "#include\nusing namepace std;\nint main()\n{\n int n,;\n cin>>n;\n int a[n];\n for(int i=0;i>a[i];\n sum+=a[i];\n }\n \n for(int i=1;i<6;i++)\n {\n if((sum+i)%(n+1)!=1){\n cout<\n\nusing namespace std;\nusing ll = long long;\n\ninline bool equal(double a, double b) {\n\treturn abs(a - b) < 1e-5;\n}\n\nint n, m;\nvector>> g;\n\narray, 2> col;\nvector used;\n\nvector already;\nvector ans;\n\nint num;\narray, 2> comp;\n\nvector> cur;\n\nbool dfs(int v, int now, vector &vers) {\n\tvers.push_back(v);\n\tused[v] = 1;\n\tcomp[now][v] = num;\n\n\tbool ok = true;\n\tfor (auto [u, tp] : g[v]) {\n\t\tif (tp != now)\n\t\t\tcontinue;\n\t\tok &= (col[now][u] == -1 || col[now][u] == (col[now][v] ^ 1));\n\t\tcol[now][u] = col[now][v] ^ 1;\n\t\tif (!used[u])\n\t\t\tok &= dfs(u, now, vers);\n\t}\n\treturn ok;\n}\n\nvoid dfs_fill(int v) {\n\tused[v] = 1;\n\tfor (auto [u, tp] : g[v]) {\n\t\tif (already[u] && !equal((double) tp + 1, ans[v] + ans[u])) {\n\t\t\tcout << \"NO\\n\";\n\t\t\texit(0);\n\t\t}\n\t\talready[u] = 1;\n\t\tans[u] = tp + 1 - ans[v];\n\t\tif (!used[u])\n\t\t\tdfs_fill(u);\n\t}\n}\n\nvoid dfs_solve(int v, vector &vers) {\n\tvers.push_back(v);\n\tused[v] = 1;\n\tfor (auto [u, tp] : g[v]) {\n\t\tif (used[u])\n\t\t\tcontinue;\n\t\tcur[u] = {-cur[v].first, tp + 1 - cur[v].second};\n\t\tdfs_solve(u, vers);\n\t}\n}\n\nsigned main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(0), cout.tie(0);\n\n\tcin >> n >> m;\n\tg.resize(n);\n\tfor (int i = 0; i < m; i++) {\n\t\tint v, u, tp;\n\t\tcin >> v >> u >> tp;\n\t\tv--, u--, tp--;\n\t\tg[v].emplace_back(u, tp);\n\t\tg[u].emplace_back(v, tp);\n\t}\n\n\tans.resize(n);\n\talready.resize(n);\n\n\tarray>, 2> comps;\n\tfor (int now = 0; now < 2; now++) {\n\t\tcol[now].resize(n, -1);\n\t\tused = vector(n, 0);\n\t\tnum = 0;\n\t\tcomp[now].resize(n);\n\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tif (!used[i]) {\n\t\t\t\tnum++;\n\t\t\t\tvector vers;\n\t\t\t\tcol[now][i] = 0;\n\t\t\t\tif (!dfs(i, now, vers))\n\t\t\t\t\tfor (auto u : vers) {\n\t\t\t\t\t\tif (already[u] && !equal(ans[u], (double) (now + 1) / 2))\n\t\t\t\t\t\t\treturn cout << \"NO\\n\", 0;\n\t\t\t\t\t\talready[u] = 1;\n\t\t\t\t\t\tans[u] = (double) (now + 1) / 2;\n\t\t\t\t\t}\n\n\t\t\t\tcomps[now].push_back(vers);\n\t\t\t}\n\t}\n\n\tfor (int v = 0; v < n; v++)\n\t\tfor (auto [u, tp] : g[v]) {\n\t\t\tif (comp[tp ^ 1][v] != comp[tp ^ 1][u])\n\t\t\t\tcontinue;\n\t\t\tif (col[tp ^ 1][v] != col[tp ^ 1][u])\n\t\t\t\treturn cout << \"NO\\n\", 0;\n\n\t\t\talready[v] = already[u] = 1;\n\t\t\tans[v] = ans[u] = 1 - (1 - tp) * 0.5;\n\t\t}\n\n\tused = vector(n, 0);\n\tfor (int i = 0; i < n; i++)\n\t\tif (!used[i] && already[i])\n\t\t\tdfs_fill(i);\n\n\tused = vector(n, 0);\n\tcur.resize(n);\n\tfor (int i = 0; i < n; i++) {\n\t\tif (already[i] || used[i])\n\t\t\tcontinue;\n\t\tvector vers;\n\t\tcur[i] = {1, 0};\n\t\tdfs_solve(i, vers);\n\n\t\tvector solves;\n\t\tfor (auto v : vers)\n\t\t\tfor (auto [u, tp] : g[v]) {\n\t\t\t\tif (solves.size())\n\t\t\t\t\tbreak;\n\t\t\t\tint k = cur[v].first + cur[u].first;\n\t\t\t\tif (!k) {\n\t\t\t\t\tif (cur[v].second + cur[u].second != tp + 1)\n\t\t\t\t\t\treturn cout << \"NO\\n\", 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsolves.push_back((double) (tp + 1 - cur[v].second - cur[u].second) / k);\n\t\t\t}\n\n\t\tif (solves.size()) {\n\t\t\tfor (auto v : vers)\n\t\t\t\tused[v] = 0;\n\t\t\tans[i] = solves[0];\n\t\t\talready[i] = 1;\n\t\t\tdfs_fill(i);\n\t\t\tcontinue;\n\t\t}\n\n\t\tvector> maybe;\n\t\tfor (auto now : {-3.0, -2.5, -2.0, -1.5, -1.0, -0.5, 0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0}) {\n\t\t\tmaybe.emplace_back(0.0, now);\n\t\t\tfor (auto v : vers)\n\t\t\t\tmaybe.back().first += abs(cur[v].first * now + cur[v].second);\n\t\t}\n\n\t\tsort(maybe.begin(), maybe.end());\n\t\tans[i] = maybe[0].second;\n\t\talready[i] = 1;\n\t\tfor (auto v : vers)\n\t\t\tused[v] = 0;\n\t\tdfs_fill(i);\n\t}\n\n\tcout << \"YES\\n\";\n\tfor (auto x : ans)\n\t\tcout << x << ' ';\n\tcout << '\\n';\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "028f76f7e377dc80903385eb17784793", "src_uid": "791cbe2700b11e9dd9a442de3ef913f8", "difficulty": 2100.0} {"lang": "MS C++ 2017", "source_code": "\ufeff// ConsoleApplication3.cpp : Defines the entry point for the console application.\n\n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long int llint;\n\n\nint main()\n{\n\tint n;\n\tcin >> n;\n\n\tstring str;\n\t\n\tfor (int i = 0; i < n; i++) {\n\t\tchar a;\n\t\tstd::cin >> a;\n\t\tstr.push_back(a);\n\t}\n\t\n\n\tint oneCount = 0;\n\n\tfor (int i = 0; i < n; i++) {\n\t\tif (str[i] == '1') {\n\t\t\toneCount++;\n\t\t}\n\t}\n\n\tif (n==1 || oneCount * 2 != n) {\n\t\tstd::cout << 1 << \"\\n\";\n\t\tstd::cout << str;\n\t\treturn 0;\n\t}\n\n\tstd::cout << 2 << \"\\n\";\n\n\tstd::cout << str.substr(0, str.size()-1) << \" \" << str[n-1] << \"\\n\";\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d36b14863767562cbce53bc5534b9c8d", "src_uid": "4ebed264d40a449602a26ceef2e849d1", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n\nusing namespace std;\n\nint A[1000005][2];\nint B[1000005][2];\n\nlong long gcd(long long a, long long b)\t{\n\tif (b == 0)\n\t\treturn a;\n\treturn gcd(b, a% b);\n}\n\nint main(void)\t{\n\tlong long k, m;\n\tlong long h1, a1, x1, y1;\n\tlong long h2, a2, x2, y2;\n\n\tcin >> m;\n\tcin >> h1 >> a1 >> x1 >> y1;\n\tcin >> h2 >> a2 >> x2 >> y2;\n\n\tA[h1][0] = k = 1;\n\twhile (A[a1][0] == 0)\t{\n\t\th1 = (x1 * h1 + y1) % m;\n\n\t\tif (A[h1][0] == 0)\n\t\t\tA[h1][0] = ++k;\n\t\telse\n\t\t\tbreak;\n\t}\n\n\tA[h2][1] = k = 1;\n\twhile (A[a2][1] == 0)\t{\n\t\th2 = (x2 * h2 + y2) % m;\n\n\t\tif (A[h2][1] == 0)\n\t\t\tA[h2][1] = ++k;\n\t\telse\n\t\t\tbreak;\n\t}\n\n\tif (A[a1][0] == 0 || A[a2][1] == 0)\n\t\tcout << \"-1\" << endl;\n\telse\n\t{\n\t\tk = 0;\n\t\th1 = a1;\n\t\twhile (B[a1][0] == 0)\t{\n\t\t\th1 = (x1 * h1 + y1) % m;\n\t\t\tB[h1][0] = ++k;\n\t\t}\n\n\t\tk = 0;\n\t\th2 = a2;\n\t\twhile (B[a2][1] == 0)\t{\n\t\t\th2 = (x2 * h2 + y2) % m;\n\t\t\tB[h2][1] = ++k;\n\t\t}\n\n\t\tx1 = A[a1][0] - 1;\n\t\tx2 = A[a2][1] - 1;\n\n\t\tif (B[a1][0] > B[a2][1])\n\t\t\tk = gcd(B[a1][0], B[a2][1]);\n\t\telse\n\t\t\tk = gcd(B[a2][1], B[a1][0]);\n\n\t\tif (x1 % k != x2 % k)\n\t\t\tprintf(\"-1\\n\");\n\t\telse\n\t\t{\n\t\t\twhile (x1 != x2)\t{\n\t\t\t\tif (x1 < x2)\t{\n\t\t\t\t\tif ((x2 - x1) % B[a1][0] == 0)\n\t\t\t\t\t\tx1 += (x2 - x1) / B[a1][0] * B[a1][0];\n\t\t\t\t\telse\n\t\t\t\t\t\tx1 += (x2 - x1) / B[a1][0] * B[a1][0] + B[a1][0];\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif ((x1 - x2) % B[a2][1] == 0)\n\t\t\t\t\t\tx2 += (x1 - x2) / B[a2][1] * B[a2][1];\n\t\t\t\t\telse\n\t\t\t\t\t\tx2 += (x1 - x2) / B[a2][1] * B[a2][1] + B[a2][1];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcout << x1 << endl;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/*\n5\n4 2\n1 1\n0 1\n2 3\n\n1023\n1 2\n1 0\n1 2\n1 1\n\n29\n4 0\n1 1\n25 20\n16 0\n\n999983\n151890 906425\n851007 9094\n696594 968184\n867017 157783\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f3488e8a7c1f1558bfcd0260c3e5c41d", "src_uid": "7225266f663699ff7e16b726cadfe9ee", "difficulty": 2200.0} {"lang": "MS C++ 2017", "source_code": "#include\n#include\nusing namespace std;\n\n\nint main(){\n\t int n=100;\n\tint r=0;\n\tchar p[n];\n\t\n\tcin.getline(p,n,'\\n');\n\tint s=strlen(p);\n\t\n\tfor (int i=0;i\nusing namespace std;\n\nconst int N = 20;\nint red[N], blue[N], numR[1<> j) & 1;\n}\n\nint main() {\n ios_base::sync_with_stdio(0); cin.tie(0);\n if(fopen(\".inp\", \"r\")) freopen(\".inp\", \"r\", stdin);\n cin >> n;\n long long allR = 0, allB = 0;\n for(int i=1 ; i<=n ; ++i) {\n cin >> t[i];\n cin >> red[i] >> blue[i];\n allB += blue[i];\n allR += red[i];\n }\n for(int i=1 ; i<(1< f[i | (1<<(j-1))][newthrowR]) {\n f[i | (1<<(j-1))][newthrowR] = newThrowB;\n }\n }\n }\n }\n long long ans = max(allB, allR);\n for(int throwR=0 ; throwR<=n*n ; ++throwR) {\n int x = f[(1<\nusing namespace std;\nmain()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);cout.tie(NULL);\n string s;\n cin>>s;\n int a;\n cin>>a;\n int h=(10*(s[0]-'0')+(s[1]-'0'),m=(10*(s[3]-'0')+(s[4]-'0'));\n h+=a/60;\n a=a%60;\n m+=a;\n if(m>=60)\n {\n h++;\n m=m-60;\n }\n if(h>23)\n h-=24;\n if(h<10)\n {\n cout<<0<\n\nusing namespace std;\n\nint l=2;\nint c[1005],a[1005][1005];\nint main()\n{\n int i,j,k,f=0,t,p,q;\n\tlong long x1,x2,y1,y2;\n double ans;\n long long Ans1,Ans2,Ans=0,m1,m2,sum;\n int n;\n k=1;\n t=2;\n c[1]=4,c[2]=7;\n for(i=2;i<=9;i++){\n c[++l]=c[k]*10+4;\n p=l;\n c[++l]=c[k]*10+7;\n for(j=k+1;j<=t;j++){\n c[++l]=c[j]*10+4;\n c[++l]=c[j]*10+7;\n }\n t=l;\n k=p;\n }\n /*for(i=1;i<=l;i++){\n cout<\n#include \n#include \n#include \n\nusing namespace std;\n\nbool adj[6][6];\n\nbool test(int a,int b, int c){\n if(adj[a][b] and adj[b][c] and adj[c][a]){\n\treturn true;\n }\n if(!adj[a][b] and !adj[b][c] and !adj[c][a]){\n\treturn true;\n }\n return false;\n}\n\nint main(){\n bzero(adj,sizeof(adj));\n int M;\n cin >> M;\n for(int i=0; i> in1 >> in2;\n\tadj[in1-1][in2-1]=true;\n\tadj[in2-1][in1-1]=true;\n }\n bool win=false;\n for(int i=0; i<5; i++){\n\tfor(int j=i+1; j<5; j++){\n\t for(int k=j+1; k<5; k++){\n\t\tif(test(i,j,k)){\n\t\t win=true;\n\t\t i=5; j=5;\n\t\t break;\n\t\t}\n\t }\n\t}\n }\n if(win){\n\tcout << \"WIN\\n\";\n }else{\n\tcout << \"FAIL\\n\";\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7e8c3d277ae121416a7cf882408109c1", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#define _CRT_SECURE_NO_DEPRECATE\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n \nvoid ASS(bool b)\n{\n if (!b)\n {\n ++*(int*)0;\n }\n}\n \n#define FOR(i, x) for (int i = 0; i < (int)(x); i++)\n#define CL(x) memset(x, 0, sizeof(x))\n \n#pragma comment(linker, \"/STACK:106777216\")\n \ntypedef vector vi;\ntypedef long long LL;\n\nint a[4];\n\nint main()\n{\n\tFOR(i, 3)\n\t\tcin >> a[i];\n\tint k;\n\tcin >> k;\n\n\tsort(a[0], a[1], a[2]);\n\tk = min(a[0] + a[1] + a[2] - 3, k);\n\tLL res = 1;\n\tFOR(i, min(a[0] - 1, k) + 1)\n\t{\n\t\tint d = min(k - i, a[1] + a[2] - 2);\n\t\tint x = d / 2;\n\t\tint c1 = min(a[1] - 1, x);\n\t\tint c2 = min(a[2] - 1, d - c1);\n\t\tres = max(res, (i + 1) * (LL) (1 + c1) * (LL) (1 + c2));\n\t}\n\tcout << res << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "16627ed00a38ffc3a2a86db1ae0854c5", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define LL long long\n#define fr(i,n) for(i=0;i> n >> m >> x >> y >> a >> b;\n a-=c;\n b-=d;\n if(a<0)a=-a;\n if(b<0)b=-b;\n if (a>=5||b>=5||a+b>=7)\n cout << \"Second\";\n else\n cout << \"First\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7f1d2d37d7faceb83e111311f23eabe9", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\nint n,k,i=1,t=0;\ncin>>n>>k;\nk=240-k;\nfor(;i<=n;i++)\n{\ns+=5*i;\nif(s>k)\nbreak;\n}\ncout<\n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\nconst int maxn = 1e5;\n int s = 30;\n\nint n, d, x, rec[maxn+5];\nint np, pos[maxn+5];\nint a[maxn+5], b[maxn+5];\n\nint get_next () {\n return x = (37LL * x + 10007) % 1000000007;\n}\n\nvoid init_table () {\n for (int i = 0; i < n; i++)\n a[i] = i + 1;\n\n for (int i = 0; i < n; i++)\n swap(a[i], a[get_next() % (i+1)]);\n\n for (int i = 0; i < n; i++)\n b[i] = (i < d ? 1 : 0);\n\n for (int i = 0; i < n; i++)\n swap(b[i], b[get_next() % (i+1)]);\n}\n\nvoid init_pos () {\n np = 0;\n for (int i = 0; i < n; i++) {\n if (b[i])\n pos[np++] = i;\n }\n\n for (int i = 0; i < n; i++)\n rec[a[i]] = i;\n}\n\nint main () {\n // freopen(\"in.txt\", \"r\", stdin);\n scanf(\"%d%d%d\", &n, &d, &x);\n init_table();\n init_pos();\n s = sqrt(n);\n for (int i = 0; i < n; i++) {\n\n bool flag = true;\n\n for (int j = n; j >= n-s; j--) {\n if (rec[j] <= i && b[i-rec[j]]) {\n flag = false;\n printf(\"%d\\n\", j);\n break;\n }\n }\n if (flag) {\n int ans = 0;\n for (int j = 0; j < np && pos[j] <= i; j++) {\n ans = max(ans, a[i-pos[j]]);\n }\n printf(\"%d\\n\", ans);\n }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b651df262f31bac5dc396ef83abc2079", "src_uid": "948ae7a0189ada07c8c67a1757f691f0", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n int t;\n cin >> t;\n while (t--) {\n int x;\n cin >> x;\n if(x <= 7) {\n cout << 1 << endl;\n } else {\n int counter = 0;\n while(x > 7) {\n x -= 7;\n counter += 1;\n }\n cout << counter + 1 << endln;\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3df7a31b9c218c800da90a6d03dda9c8", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\nint main()\n{\n\tlong long n, m;\n\tscanf(\"%I64d%I64d\", &n, &m);\n\tif (m >= n)\n\t\tprintf(\"%I64d\\n\", n);\n\telse\n\t{\n\t\tlong long t = sqrt(2 * (n - m));\n\t\twhile (t * (t + 1) / 2 >= n - m) --t;\n\t\twhile ((t + 1) * (t + 2) / 2 < (n - m)) ++t;\n\t\tprintf(\"%I64d\\n\", t + m + 1);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "be2f5d88f6c9c7bca8a79d064624af7d", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nlong long int arr[100000];\nint main(){\n long long int n,k;\n cin>>n>>k;\n if(n%2==0){\n cout<\n\nusing namespace std;\n\nint f[]={0, 0, 1, 2, 9};\nint n_cate_k(int n,int k)\n{\n int t1 = 1,t2 = 1;\n for(int i = 1; i <= k; ++i)\n {\n t1*=(n - i + 1);\n t2*=i;\n }\n return t1/t2;\n}\nint main()\n{\n int n,k,sol=0;\n scanf(\"%d%d\",&n,&k)\n for(int i = 0; i <= k; i++)\n ans+=n_cate_k(n,i)*f[i];\n printf(\"%d\",ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f15cf5852793e931ae7fc553a74764e3", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n\n#include\n#include\n#include\n#include\n#include\n\ntypedef long long LL;\n#define PI(x) printf(\"%d\\n\",x)\n#define SI(x) scanf(\"%d\",&x)\n#define MP(x,y) make_pair(x,y)\n#define MX 17\nusing namespace std;\n\nint n,m;\nLL y;\nint prof_at_seat[MX];\nint seat_of_prof[MX];\nint before_seat[MX];\nLL dp[(1<=n) return 1;\n\n\tif(dp[mask_of_seats]!=-1)return dp[mask_of_seats];\n\n\t// Try to put the prof at some available seat.\n\tLL w = 0;\n\tfor(int seat=0;seat>y;\n\tSI(m);\n\n\tfor(int i=0;i\n\n\t\n\t\n\t\t\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2bc6e23923e133d45fb65e046ed31bd9", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \"/Users/cslusr/macros.h\"\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define PB push_back\n#define MT make_tuple\n#define MP make_pair\n#define VI vector\n#define VVI vector>\n#define TII tuple\n#define SZ() size()\n#define ALL(v) v.begin(),v.end()\n#define FOR(i,a,b) for(int i=a;i> m;\n lld res = solve(m);\n cout << res << endl;\n }\n \n};\n\nint main() {\n\n __UNSYNC_IO__;\n\n S s;\n s.solve();\n \n return 0;\n \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f0e9958f66cf54f0a91b5e9c281b1802", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \nconst int N=100100;\nusing namespace std;\n\nint fa[N];\ninline int getf(int x){return x==fa[x]?x:fa[x]=getf(fa[x]);}\nint main(int argc, char const *argv[])\n{\n\tscanf(\"%d%d\",&Ti,&T);\n\twhile(T--){\n\t\tscanf(\"%d%d\",&n,&m);\n\t\tfor(int i=1;i<=n;i++) fa[i]=i;\n\t\tfor(int i=1,u,v,opt;i<=m;i++)\n\t\t\tscanf(\"%d%d%d\",&u,&v,&opt);\n\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "83518b1bf964d8ed00ec759211d94cfa", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main(){\n int a, b, c;\n long long ans = 0;\n cin >> a >> b >> c;\n if(a == b)\n ans = ans + c * 2 + min(a, b) * 2;\n if(a != b)\n ans = ans + c * 2 + min(a, b) * 2 + 1;\n cout << ans << endl;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "09931606545dacc5c707fd8076df8f95", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nvectorC[410000];\nint go[410000],n,m,pd[410000],B[5],ansX[110000],ansY[110000],now,num,cho[110000],bo[110000],a[110000],b[110000],f[110000],dis;\nstruct atom2{\n int where,w;\n};\nint operator < (atom2 k1,atom2 k2){\n return k1.wS;\nchar getin(){\n char ch=getchar(); while (ch<'A'||ch>'Z') ch=getchar(); return ch;\n}\nstruct point{\n int x,y;\n};\nstruct atom{\n point k1,k2;\n void scan(){\n char k3=getin(),k4=getin(); scanf(\"%d%d\",&k1.y,&k2.y);\n if (k3=='L') k1.x=1; else if (k3=='R') k1.x=0; else if (k3=='T') k1.x=2; else k1.x=3;\n if (k4=='L') k2.x=1; else if (k4=='R') k2.x=0; else if (k4=='T') k2.x=2; else k2.x=3;\n if (k1.x>k2.x) swap(k1,k2);\n }\n}A[210000];\nint get(point k1){\n if (k1.x==1) return k1.y;\n if (k1.x==2) return k1.y+n;\n if (k1.x==0) return k1.y+n+m;\n return k1.y+n+n+m;\n}\nint getnext(int k){\n k+=n+m;\n if (k>n+n+m+m) k-=n+n+m+m;\n return k;\n}\nint getlin(int k){\n if (k>n+m) k-=n+m; return k;\n}\nvoid find(int k1,int k2){\n int k3=getlin(k1);\n if (pd[k3]) return;\n pd[k3]=1; C[k2].push_back(k3); find(getnext(go[k1]),k2);\n}\nint gcd(int k1,int k2){\n if (k2==0) return k1; return gcd(k2,k1%k2);\n}\nint check(int k){\n int num=0;\n for (int i=0;in&&C[k][k1]>n&&(C[k][i]<=n+m||C[k][i]>n+n+m)&&(C[k][k1]<=n+m||C[k][k1]>n+n+m)) num++;\n }\n return num;\n}\nvoid print(int k1,int k2,int k3){\n if (ansY[k1]) return;\n// if (k2n+n+m){\n k2+=num; print(getnext(go[k1+n])-n,k2,k3+1); return;\n }\n k2=n-(m-k2); print(getnext(go[getnext(go[k1+n])])-n,k2,k3);\n}\nint check2(int k){\n int k1=C[k][0];\n if (go[k1]<=n+m){\n k1=go[getnext(go[k1])]; \n if (k1>n) return 0;\n k1=go[getnext(k1)];\n if (k1<=n+n+m) return 0;\n return 1;\n } else {\n k1=go[getnext(go[k1])];\n if (k1>n) return 0;\n k1=go[getnext(k1)];\n if (k1>n+m) return 0;\n return 1;\n }\n}\nint getfirst(int k){\n int k1=k; int flag=0;\n while (bo[k1]==0){\n bo[k1]=1; if (flag) return k1;\n if (go[k1+n]>n+n+m){\n k1=getnext(go[k1+n])-n; continue;\n }\n flag=1; k1=getnext(go[getnext(go[k1+n])])-n;\n }\n return k; \n}\nint getdis(int k){\n if (getlin(go[k+n])==k+n) return 1; dis=0; int k1=k;\n while (1){\n if (go[k1+n]>n+n+m){\n k1=getnext(go[k1+n])-n; dis++; continue;\n }\n return dis;\n }\n}\nint find(int k){\n if (f[k]!=-1) return f[k];\n f[k]=0; f[k]=find(k+num)+1; return f[k];\n}\nint main(){\n// freopen(\"data.out\",\"w\",stdout);\n// freopen(\"data.in\",\"r\",stdin);\n scanf(\"%d%d\",&n,&m);\n int flag1=0,flag2=0;\n for (int i=1;i<=n+m;i++){\n A[i].scan(); if (A[i].k1.x==0&&A[i].k2.x==1) flag1=1;\n if (A[i].k1.x==2&&A[i].k2.x==3) flag2=1;\n }\n int flag=0;\n if (flag1&&flag2){cout<<\"No solution\"<A[i].k2.x) swap(A[i].k1,A[i].k2);\n }\n }\n for (int i=1;i<=n+m;i++){\n if (A[i].k1.x==1&&A[i].k2.x==2) B[0]++;\n if (A[i].k1.x==0&&A[i].k2.x==2) B[1]++;\n if (A[i].k1.x==0&&A[i].k2.x==3) B[2]++;\n if (A[i].k1.x==1&&A[i].k2.x==3) B[3]++;\n if (A[i].k1.x==2&&A[i].k2.x==3) B[4]++;\n }\n if (B[0]!=B[2]||B[1]!=B[3]){cout<<\"No solution\"<::iterator k3=S.find((atom2){0,k2});\n print(k1,(*k3).where,0); S.erase(k3);\n }\n int l=1,r=m;\n// for (int i=m-B[0]+1;i<=m;i++) if (cho[i]) cout<<\"uses \"<\n#include \nusing namespace std;\n\nint main()\n{\n char s[100];\n\n cin >> s;\n\n int j = strlen(s);\n int r = 0 , y = 0 , g = 0 , b = 0;\n i = 0;\n while(i <= j -4)\n\n {\n if(s[i] != 'R' && s[i + 1] != 'R')\n if(s[i + 2] != 'R' && s[i + 3] != 'R')\n r++;\n if(s[i] != 'G' && s[i + 1] != 'G')\n\n if( s[i + 2] != 'G' && s[i + 3] != 'G')\n\n g++;//!!!GRY!B\n if(s[i] != 'Y' && s[i + 1] != 'Y' )\n\n if(s[i + 2] != 'Y' && s[i + 3] != 'Y')\n y++;\n if(s[i + 1] != 'B' && s[i] != 'B')\n\n if(s[i + 2] != 'B' && s[i + 3] != 'B')\n\n b++;\n if(s[i] == '!' )\n i = i + 4;\n }\n\n cout << r <<\" \" << b <<\" \" << y <<\" \" << g;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5b6ca1c195be250316f43e160747b33a", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n,i,x,z1=0,z2=0,s1=0,s2=0;\n cin>>n;\n if(n%2==1){cout<<\"NO\";return 0;}\n for(i=1;i<=n;i++)\n {\n cin>>x;\n if(z1==0){z1=x;s1++;}\n else if(z2==0&&x!=z1){z2=x;s2++;}\n else if(x==z1)s1++;\n else if(x==z2)s2++;\n }\n if(s1==s2&&s1==n/2Z)\n cout<<\"YES\"<\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n#define ll long long\n\nconst int N = 1<<15, M = N<<1, P = 998244353;\nint n, k, w[M];\nvector ans;\ninline int Pow(ll x, int y=P-2){\n\tint ans=1;\n\tfor(; y; y>>=1, x=x*x%P) if(y&1) ans=ans*x%P;\n\treturn ans;\n}\ninline void DFT(vector &f, int n){\n\tstatic unsigned ll F[M];\n\tfor(int i=0, j=0; i>1; (j^=k)>=1);\n\t}\n\tfor(int i=1; i &f, int n){\n\treverse(f.begin()+1, f.end()), DFT(f, n);\n\tfor(int i=0, I=Pow(n); i operator *(const vector &x, const vector &y){\n\tif(!x.size() || !y.size()){\n\t\tvector a;\n\t\treturn a.push_back(0), a;\n\t}\n\tvector a=x, b=y;\n\tint n=Calc(x.size()+y.size()-2);\n\ta.resize(n), b.resize(n), DFT(a, n), DFT(b, n);\n\tfor(int i=0; i &x, const vector &y){ x=x*y;}\ninline vector operator +(const vector &x, const vector &y){\n\tvector ans=x;\n\tif(y.size()>x.size()) ans.resize(y.size());\n\tfor(unsigned i=0; i &x, const vector &y){ x=x+y;}\nstruct matrix{\n\tvector a[2][2];\n\tinline matrix operator *(const matrix &rhs)const{\n\t\tmatrix ans;\n\t\tfor(int i=0; i<2; ++i) for(int k=0; k<2; ++k) for(int j=0; j<2; ++j)\n\t\t\tans.a[i][j]+=a[i][k]*rhs.a[k][j];\n\t\treturn ans;\n\t}\n} A;\ninline matrix Pow(matrix x, int y){\n\tmatrix ans=x;\n\t--y;\n\tfor(; y; y>>=1, x=x*x) if(y&1) ans=ans*x;\n\treturn ans;\n}\nint main() {\n\tfor(int i=1; i{1,1}+A.a[1][1];\n\tfor(int i=1; i<=k; ++i) printf(\"%d \", i>n?0:ans[i]);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "db5660c78432f56704c9b2dfc3663116", "src_uid": "266cc96acf6287f92a3bb0f8eccc5cf1", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\nconst int maxn=10;\r\nchar a[maxn];\r\nint ans=1;\r\nint main(){\r\n\tscanf(\"%s\",a+1);\r\n\tint len=strlen(a+1);\r\n\tif(len==1)\r\n\t{\r\n\t\tif(a[1]=='0')cout<<\"1\"<=2;i--)if(a[i]=='_')ans*=10;\r\n\t\t\tif(a[1]=='_')ans*=9;\r\n\t\t\tcout<=2;i--)if(a[i]=='_')ans*=10;\r\n\t\t\tif(a[1]=='_')ans*=9;\r\n\t\t\tcout<=2;i--)if(a[i]=='_')ans*=10,if(a[i]=='X')flag=true;\r\n\t\t\tif(flag)if(a[1]=='X')ans*=9;else ans*=10;\r\n\t\t\tif(a[1]=='_')ans*=9;\r\n\t\t\tcout<=2;i--)if(a[i]=='_')ans*10;\r\n\t\t\tif(a[1]=='_')ans*=9;\r\n\t\t\tcout<=2;i--)if(a[i]=='_')ans*=10,if(a[i]=='X')flag=true;\r\n\t\t\tif(a[1]=='_')ans*=9;\r\n\t\t\tif(flag)if(a[1]=='X')ans*=9;else ans*=10;\r\n\t\t\tcout<\r\nusing namespace std;\r\n#define ll long long\r\nll mod = 998244353;\r\nll div(ll n)\r\n{\r\n ll cnt = 0;\r\n for (ll i = 1; i <= sqrt(n); i++) \r\n {\r\n if (n % i == 0) \r\n {\r\n if (n / i == i)\r\n cnt++;\r\n else\r\n cnt = cnt + 2;\r\n }\r\n }\r\n return cnt;\r\n}\r\nvoid solve()\r\n{\r\n ll n;\r\n cin>>n;\r\n vector dp(n+1,0);\r\n dp[1]=1;\r\n dp[0]=0;\r\n ll sum=1;\r\n for(ll i = 2;i<=n;i++)\r\n {\r\n dp[i]=((sum)%mod);\r\n dp[i]=(dp[i]+div(i))%mod;\r\n sum= (sum+dp[i])%mod;\r\n }=\r\n cout<>t;\r\n\twhile(t--)\r\n\t{\r\n\t solve();\r\n\t}\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aff2725b93e227f126c3bab9e97c5be4", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n \n long long int n,sum=0;cin>>n; int a[n];\n for(int i=0;i>a[i];\n }\nsort(a,a+n,greater<>());\n sum+=a[0];\n long long int ci=a[0];\n for(int i=1;i\n#define ll long long\n#define ls x << 1\n#define rs x << 1 | 1\n#define lson ls, l, mid\n#define rson rs, mid + 1, r\n#define INF 1000000007\nusing namespace std;\nint a[200010], L[200010], R[200010], tag[200010] ;\nll sum[200010], minv[200010][2];\n\nvoid build(int x, int l, int r)\n{\n\tL[x] = l;\n\tR[x] = r;\n\tif(l == r)\n\t{\n\t\tsum[x] = a[l];\n\t\tminv[x][0] = a[l]; \n\t\tminv[x][1] = INF;\n\t\treturn;\n\t} \n\tint mid = (l + r) >> 1;\n\tbuild(lson);\n\tbuild(rson);\n\tint k = ((mid - l + 1) & 1);\n\tsum[x] = sum[ls] + (k ? -sum[rs] : sum[rs]);\n\tminv[x][0] = min(minv[ls][0], k ? minv[rs][1] + sum[ls] : minv[rs][0] + sum[ls]);\n\tminv[x][1] = min(minv[ls][1], k ? minv[rs][0] - sum[ls] : minv[rs][1] - sum[ls]);\n}\n\nvoid pushdown(int x) \n{\n\tif (tag[x]) \n\t{\n\t\tint tg = tag[x];\n\t\ttag[x] = 0;\n\t\ttag[ls] += tg, tag[rs] += tg; \n\t\tminv[ls][0] += tg, minv[rs][0] += tg;\n\t\tsum[ls] += tg * ((R[ls] - L[ls] + 1) & 1);\n\t\tsum[rs] += tg * ((R[rs] - L[rs] + 1) & 1); \n\t}\n}\n\n\nvoid Modify(int x,int l,int r,int v) \n{\n\tif (L[x] == l && R[x] == r) \n\t{\n\t\ttag[x] += v;\n\t\tminv[x][0] += v;\n\t\tsum[x] += v * ((r - l + 1) & 1);\n\t\treturn; \n\t}\n\tpushdown(x);\n\tint mid = (L[x] + R[x]) >> 1;\n\tif (r <= mid) Modify(x << 1, l, r, v);\n\telse if (l > mid) Modify((x << 1) | 1, l, r, v);\n\telse Modify(lson, v), Modify(rson, v) ; \n\tint k = ((mid - L[x] + 1) & 1); \n\tsum[x] = sum[ls] + (k ? -sum[rs] : sum[rs]) ; \n\tminv[x][0] = min(minv[ls][0] , k ? minv[rs][1] + sum[ls]: minv[rs][0] + sum[ls]); \n\tminv[x][1] = min(minv[ls][1], k ? minv[rs][0] - sum[ls] : minv[rs][1] - sum[ls]);\n}\n\npair > Query(int x,int l,int r) \n{\n\tif (L[x] == l && R[x] == r) \n\t\treturn make_pair(sum[x], make_pair(minv[x][0], minv[x][1])); \n\tpushdown(x) ;\n\tint mid = (L[x] + R[x]) >> 1; \n\tif (r <= mid) return Query(x << 1, l, r) ;\n\tif (l > mid) return Query((x << 1) | 1, l, r) ;\n\tpair > p1 = Query(lson), p2 = Query(rson), p; \n\tint k = (mid - l + 1) & 1; \n\tp.first = p1.first + (k ? -p2.first : p2.first); \n\tp.second.first = min(p1.second.first, k ? p2.second.second + p1.first : p2.second.first + p1.first);\n\tp.second.second = min(p1.second.second, k ? p2.second.first - p1.first : p2.second.second - p1.first);\n\treturn p ; \n}\n\nbool Solve(int l,int r) \n{\n\tpair > p = Query(1, l, r);\n\tif (p.first) return 0; \n\tif (min(p.second.first, p.second.second) < 0) return 0;\n\treturn 1 ;\n}\n\nint main() \n{\n\tscanf(\"%d\", &n);\n\tfor (int i = 1;i <= n;i ++) scanf(\"%d\", &a[i]), a[i] -- ;\n\tbuild(1, 1, n) ;\n\tint T;\n\tscanf(\"%d\" ,&T) ;\n\twhile (T --) \n\t{\n\tint op; \n\tscanf(\"%d\", &op);\n\tif (op == 1) \n\t{\n\t\tint l, r, k ;\n\t\tscanf(\"%d%d%d\", &l, &r, &k);\n\t\tl ++;\n\t\tr ++;\n\t\tModify(1, l, r, k);\n\t}\n\telse \n\t{\n\t\tint l, r ;\n\t\tscanf(\"%d%d\" ,&l, &r); \n\t\tputs(Solve( ++ l, ++ r) ? \"1\" : \"0\"); \n\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "92540fba3ffbf2f236eb5c9bc3f990e8", "src_uid": "a17833a733d59936d1c3ba5f27b0cbe0", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "/*\n* C++11 code template for contests.\n* @author: Andrei Kalendarov\n* @e-mail: andreykalendarov@gmail.com\n*/\n\n//#define ANDREIKKAA_ALLOCATOR\nconst int _ML = 228;\n\nconst char _inpf[] =\n#if defined(ANDREIKKAA)\n \"input.txt\"\n#else\n \"\"\n#endif\n;\nconst char _outf[] =\n#if defined(ANDREIKKAA)\n \"\"\n#else\n \"\"\n#endif\n;\n\n#if defined(ANDREIKKAA)\n#undef NDEBUG\n#else\n#pragma GCC optimize(\"O3,no-stack-protector\")\n#endif\n#include \n#if !defined(ANDREIKKAA)\n#define endl '\\n'\n#endif\n#define x first\n#define y second\nusing namespace std;\n#define rand abcdefghijklmnopqrstuvwxyz\n#define random_shuffle abcdefghijklmnopqrstuvwxyz\n#define all(x) (x).begin(), (x).end()\n#define sz(x) (int)(x).size()\ntypedef long long ll;\ntypedef double ld;\nconst ld PI = 3.14159265358979323846;\nmt19937 rd(228);\n#if defined(ANDREIKKAA_ALLOCATOR)\nchar _mem[_ML * 1024 * 1024];\nsize_t _ptr = 0;\ninline void* operator new (size_t _x) { _ptr += _x; assert(_ptr < _ML * 1024 * 1024); return _mem + _ptr - _x; }\ninline void operator delete (void*) { }\n#endif\ntemplate inline ostream &operator<< (ostream &, const pair &);\ntemplate inline istream &operator>> (istream &, pair &);\ntemplate inline ostream &operator<< (ostream &, const vector &);\ntemplate inline istream &operator>> (istream &, vector &);\ntemplate inline ostream &operator<< (ostream &, const set &);\ntemplate inline ostream &operator<< (ostream &, const multiset &);\ntemplate inline ostream &operator<< (ostream &, const unordered_set &);\ntemplate inline ostream &operator<< (ostream &, const unordered_multiset &);\ntemplate inline ostream &operator<< (ostream &, const map &);\ntemplate inline ostream &operator<< (ostream &, const unordered_map &);\n\n/* ________ CODE ________ */\n\nconst int N = 52;\nconst int M = 1000 * 1000 * 1000 + 7;\nint dp[2][N][N][N][N];\nint a[N];\nint pww[N];\n\ninline int pw2(int x)\n{\n if(x == -1)\n {\n return 1;\n }\n return pww[x];\n}\n\ninline int mul(int a, int b)\n{\n return (int)((ll)a * b % M);\n}\n\ninline void addeq(int &a, int b)\n{\n a = (a + b) % M;\n}\n\ninline void _main_function()\n{\n pww[0] = 1;\n for(int i = 1; i < N; ++i)\n {\n pww[i] = mul(pww[i - 1], 2);\n }\n\n int n, p;\n cin >> n >> p;\n for(int i = 0; i < n; ++i)\n {\n cin >> a[i];\n }\n\n dp[1][0][0][0][0] = 1;\n\n for(int i = 0; i < n; ++i)\n {\n int cur = (i & 1);\n int lst = (~i & 1);\n memset(dp[cur], 0, sizeof dp[cur]);\n for (int be = 0; be <= i; ++be) {\n for (int bo = 0; bo <= i; ++bo) {\n for (int we = 0; we <= i; ++we) {\n for (int wo = 0; wo <= i; ++wo) {\n if (dp[lst][be][bo][we][wo] == 0) {\n continue;\n }\n\n\n if (a[i] != 1)\n {\n int value = mul(pw2(be + bo + we), pw2(wo - 1));\n\n addeq(dp[cur][be][bo + 1][we][wo],\n mul(dp[lst][be][bo][we][wo], value);\n if(wo != 0)\n {\n addeq(dp[cur][be + 1][bo][we][wo],\n mul(dp[lst][be][bo][we][wo], value));\n }\n\n //black\n\n }\n if (a[i] != 0)\n {\n int value = mul(pw2(we + wo + be), pw2(bo - 1));\n\n //white\n if(bo != 0)\n {\n addeq(dp[cur][be][bo][we + 1][wo],\n mul(dp[lst][be][bo][we][wo], value));\n }\n addeq(dp[cur][be][bo][we][wo + 1],\n mul(dp[lst][be][bo][we][wo], value));\n }\n }\n }\n }\n }\n }\n\n int cur = ((n - 1) & 1);\n int ans = 0;\n for (int be = 0; be <= n; ++be) {\n for (int bo = 0; bo <= n; ++bo) {\n for (int we = 0; we <= n; ++we) {\n for (int wo = 0; wo <= n; ++wo) {\n if(((bo + wo) & 1) == p) {\n addeq(ans, dp[cur][be][bo][we][wo]);\n }\n\n }\n }\n }\n }\n\n cout << ans << endl;\n\n}\n\n/* ________ CODE ________ */\n\nint main()\n{\n#if defined(ANDREIKKAA)\n time_t _start = clock();\n#endif\n if (_inpf[0] != '\\0') assert(freopen(_inpf, \"r\", stdin) != nullptr);\n if (_outf[0] != '\\0') assert(freopen(_outf, \"w\", stdout) != nullptr);\n cin.tie(nullptr);\n ios_base::sync_with_stdio(false);\n\n cout << setprecision(20);\n //cout << fixed;\n\n _main_function();\n#if defined(ANDREIKKAA)\n cout << \"Time: \" << (clock() - _start) / (ld)CLOCKS_PER_SEC << endl;\n#endif\n}\n\ntemplate inline ostream &operator<< (ostream &_out, const pair &_p)\n{\n _out << _p.x << ' ' << _p.y;\n return _out;\n}\ntemplate inline istream &operator>> (istream &_in, pair &_p)\n{\n _in >> _p.x >> _p.y;\n return _in;\n}\ntemplate inline ostream &operator<< (ostream &_out, const vector &_v)\n{\n if (_v.empty()) { return _out; }\n _out << *_v.begin();\n for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) { _out << ' ' << *_it; }\n return _out;\n}\ntemplate inline istream &operator>> (istream &_in, vector &_v)\n{\n for (auto &_i : _v) { _in >> _i; }\n return _in;\n}\ntemplate inline ostream &operator<< (ostream &_out, const set &_s)\n{\n if (_s.empty()) { return _out; }\n _out << *_s.begin();\n for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; }\n return _out;\n}\ntemplate inline ostream &operator<< (ostream &_out, const multiset &_s)\n{\n if (_s.empty()) { return _out; }\n _out << *_s.begin();\n for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; }\n return _out;\n}\ntemplate inline ostream &operator<< (ostream &_out, const unordered_set &_s)\n{\n if (_s.empty()) { return _out; }\n _out << *_s.begin();\n for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; }\n return _out;\n}\ntemplate inline ostream &operator<< (ostream &_out, const unordered_multiset &_s)\n{\n if (_s.empty()) { return _out; }\n _out << *_s.begin();\n for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; }\n return _out;\n}\ntemplate inline ostream &operator<< (ostream &_out, const map &_m)\n{\n if (_m.empty()) { return _out; }\n _out << '(' << _m.begin()->x << \": \" << _m.begin()->y << ')';\n for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << \", (\" << _it->x << \": \" << _it->y << ')'; }\n return _out;\n}\ntemplate inline ostream &operator<< (ostream &_out, const unordered_map &_m)\n{\n if (_m.empty()) { return _out; }\n _out << '(' << _m.begin()->x << \": \" << _m.begin()->y << ')';\n for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << \", (\" << _it->x << \": \" << _it->y << ')'; }\n return _out;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "98876feb68a982dbdd3e40bf899c3826", "src_uid": "aaf5f8afa71d9d25ebab405dddec78cd", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "\ufeff#include \"pch.h\"\n#include \nusing namespace std;\nint main()\n{\n\tint n, m, h; cin >> n;\n\tvector street(n, -1);\n\tfor (int i = 0; i < m; i++)\n\t{\n\t\tint l, r, x; cin >> l >> r >> x;\n\t\tfor (int t = l; t <= r; t++)\n\t\t\tstreet[t] = x;\n\t}\n\tans = 0;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (street[i] == -1) street[i] = h;\n\t\tans += street[i] * street[i];\n\t}\n\tcout << ans;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1b703d2f31aeb67803a7f01db9511489", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\n#define MAXL 31\n#define MOD 1000000007\n\nlong long p2[MAXL];\nint dp[MAXL][MAXL];\nint full[MAXL][MAXL];\nint main()\n{\n int k;\n cin >> k;\n p2[0] = 1;\n int lgk;\n for (int i = 1; i < MAXL; i++)\n p2[i] = (p2[i - 1] * 2);\n for (int i = 0; i < MAXL; i++)\n if ((k & p2[i]) && k - p2[i] < p2[i])\n lgk = i + 1;\n full[0][0] = 1;\n for (int i = 1; i <= lgk; i++)\n for (int j = 0; j <= i; j++)\n {\n if (j == 0)\n full[i][j] = (full[i - 1][j] * 2) % MOD;\n else\n full[i][j] = (((full[i - 1][j] * 2) % MOD) + ((full[i - 1][j - 1] * p2[i - j]) % MOD)) % MOD;\n //cout << \"FULL \" << i << \" \" << j << \" \" << full[i][j] << endl;\n }\n dp[0][0] = 1;\n for (int i = 1; i < lgk; i++)\n for (int j = 0; j <= i; j++)\n {\n if (j == 0)\n {\n if ((k & p2[i - 1]) == 0)\n dp[i][j] = dp[i - 1][j];\n else\n dp[i][j] = (full[i - 1][j] + dp[i - 1][j]) % MOD;\n }\n else\n\n if ((k & p2[i - 1]) == 0)\n dp[i][j] = dp[i - 1][j];\n else\n dp[i][j] = (((full[i - 1][j] +\n dp[i - 1][j]) % MOD) +\n ((dp[i - 1][j - 1] * p2[i - j]) % MOD)) % MOD;\n //cout << i << \" \" << j << \" \" << dp[i][j] << endl;\n }\n int ans = 0;\n for (int j = 1; j <= lgk; j++)\n {\n ans = (ans + dp[lgk - 1][j - 1]) % MOD;\n //cout << \"* \" << lgk << \" \" << j << \" \" << dp[lgk - 1][j - 1] << endl;\n }\n for (int i = 1; i < lgk; i++)\n for (int j = 1; j <= i; j++)\n {\n ans = (ans + full[i - 1][j - 1]) % MOD;\n //cout << \"* \" << i << \" \" << j << \" \" << full[i - 1][j - 1] << endl;\n }\n /*int ans = 0;\n for (int j = 1; j < MAXL; j++)\n ans = (ans + dp[lgk][j]) % MOD;*/\n cout << ans + 1 << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "317a925e94c7e3471fc6f403ec97363e", "src_uid": "ead64d8e3134fa8f29881cb487e52f60", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nint n,m,kth;\nint f[1<<10][1<<10];\nbool graph[10][10];\n\nvoid init()\n{\n cin>>n>>m>>kth;\n memset(graph,0,sizeof(graph));\n int x,y;\n for (int i=1; i<=m; i++)\n {\n cin>>x>>y;\n --x; --y;\n graph[x][y]=graph[y][x]=true;\n }\n}\n\nint check(int state)\n{\n int tot=0;\n for (int i=0; i2)\n for (int j=1; j\n\n#define pb push_back\n#define endl \"\\n\"\n#define mp make_pair \n#define fi first\n#define se second\n#define all(x) x.begin(), x.end()\n#define fname \"\"\n#define sz(x) (int)(x.size())\n#define rep(i,x,y) for(long long i=x;i<=y;++i)\n#define repr(i,x,y) for(long long i=x;i>=y;--i)\n\ntypedef long long ll;\n\nusing namespace std;\n\nconst ll N = (ll)(5e5) + 322;\nconst ll INF = (ll)(1e9);\nconst ll mod = (ll)(1e9) + 7;\nconst double eps = 1e-9;\n\nint dp[45][1 << 21], n, m, p[45][300], ans;\nbool was[45][1 << 21];\n\nchar ch[111][111];\n \nvoid print(int mask) {\n\trepr(i, n - 1, 0) cout << (bool)(mask & (1 << i));\n\tcout << ' ';\n}\n\nint calc(int pos, int mask) {\n\tif (pos == n + n - 1) {\n\t\tif (ch[n][n] == 'a') return 1;\n\t\tif (ch[n][n] == 'b') return -1;\n\t\treturn 0;\t\n\t}\n\tint &res = dp[pos][mask];\t\n\tif (was[pos][mask]) return res;\n\twas[pos][mask] = 1;\n\tif (pos & 1) res = INF;\n\telse res = -INF;\n\tfor(char c = 'a'; c <= 'z'; ++c) {\n\t\tint nxt;\n\t\tif (pos < n) nxt = ((mask | (mask << 1)) & p[pos + 1][c]);\t\n\t\telse nxt = ((mask | (mask >> 1)) & p[pos + 1][c]);\n\t\tint cur = calc(pos + 1, nxt);\t\t\n\t\tif (!nxt || cur > 100 || cur < -100) continue;\n\t\tint pl = 0;\n\t\tif (c == 'a') pl++;\n\t\tif (c == 'b') pl--;\n\t\tif (pos & 1) res = min(res, cur + pl);\n\t\telse res = max(res, cur + pl);\n\t}\n\treturn res; \n}\n\nint main () {\n\tios_base :: sync_with_stdio (false); cin.tie(0);\n//\tfreopen(fname\".in\", \"r\", stdin);\n\t//freopen(fname\".out\", \"w\", stdout);\n\tcin >> n;\n\trep(i, 1, n) rep(j, 1, n) cin >> ch[i][j];\n\trep(i, 1, n) rep(j, 1, n) \n\tif (i + j - 1 >= n)p[i + j - 1][ch[i][j]] |= (1 << (n - i));\n\telse p[i + j - 1][ch[i][j]] |= (1 << (j - 1));\n\tint pl = 0;\n\tif (ch[1][1] == 'a') pl = 1;\n\tif (ch[1][1] == 'b') pl = -1;\n\tans = calc(1, 1) + pl\n\tif (ans == 0) cout << \"DRAW\";\n\tif (ans > 0) cout << \"FIRST\";\n\tif (ans < 0) cout << \"SECOND\";\n\treturn 0;\n} \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "04bfa819af4b0a9cfd0965e9c9dc2fa8", "src_uid": "d803fe167a96656f8debdc21edd988e4", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "/*\n117B.cpp\nBy Mr.Yong\n2011/10/15\n*/\n\n#include\n#include\nusing namespace std;\n\nbool CanBeDiv(char str[],int mod)\n{\n int Carry=0;\n int i=0;\n while(str[i]!='\\0')\n {\n Carry=(Carry*10+str[i]-'0')%mod;\n i++;\n }\n if(Carry==0)return true;\n return false;\n}\n\nbool Str1lessStr2(char str1[], char str2[])\n{\n for(int i=0;i<9;i++)\n {\n if(str1[i]b&&Str1lessStr2(str1,strtemp)){strcpy(strtemp,str1);found=true;}\n }\n if(found){cout<<\"1\"<<\" \"<>a>>b>>mod)\n {\n for(int i=0;i<9;i++)\n {\n str1[i]='0';\n str2[i]='0';\n strtemp[i]='9';\n }\n str1[9]='\\0';\n str2[9]='\\0';\n strtemp[9]='\\0';\n Game(str1,str2,a,b,mod,strtemp);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "77ce6cfce0d444d90a20844f848d5bc0", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\nconst int maxn=1e5+5;\nconst ll mod=1e9+7;\nint p[maxn][150];//q\u8bb0\u5f55\u4e92\u8d28\u76841-m\u4e4b\u95f4\u4e2a\u6570gcd(x,y)=a;\nvectorg[maxn]; ll dp[maxn];\nint prime[maxn], k=0, u[maxn]; bool vis[maxn];\nint cac(int x, int y){\n int ans=0;\n for(int i=0;i>=1; a=a*a%mod;\n }\n return ans;\n}\nint main(){\n int n;\n scanf(\"%d\",&n); init(n); dp[1]=1;\n for(int i=2;i<=n;i++){\n ll ans=n;\n for(int j=0;j\n\nint main () {\n char s[10], m=0; int cnt=0, i;\n gets(s);\n int l = strlen(s);\n for(i=0; i m) {\n m = s[i];\n cnt = 1;\n } else \n if (s[i] == m)\n cnt++;\n for(i=0; i\nusing namespaces std;\n\nint main()\n{\n long long a, b;\n cin >> a >>b;\n long long num[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};\n long long ans =0;\n for(long long i=a; i<=b; ++i){\n long long temp = i;\n while(temp){\n ans += num[temp%10];\n temp/=10;\n }\n }\n cout << ans << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "39cc58e75c363007b21b3fdc763c9dae", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef unsigned long long int ull;\nconst int maxn=500100;\nchar s[maxn],r[maxn];\nint n,d;\null p[maxn],hash[maxn],rhash[maxn];\nbool ok(int ed,int d)\n{\n\ted++;\n\tint st=ed-d+1;\n\tif(st<0) return true;\n\tif((rhash[ed]-rhash[st-1]*p[d])*p[st-1]!=hash[ed]-hash[st-1])\n\t\treturn true;\n\treturn false;\n}\nbool dfs(int x,int t)\n{\n\tif(x==n)\n\t{\n\t\tputs(r);\n\t\treturn true;\n\t}\n\tfor(r[x]=(t?s[x]:'a');r[x]<='z';r[x]++)\n\t{\n\t\thash[x+1]=hash[x]+r[x]*p[x];\n\t\trhash[x+1]=rhash[x]*175+r[x];\n\t\tif(ok(x,d)&&ok(x,d+1)&&dfs(x+1,t&&(r[x]==s[x])))\n\t\t\treturn true;\n\t}\n\treturn false;\n}\n \nint main()\n{\n\tcin>>d;\n\tcin>>s;\n\tn=strlen(s);\n\tint i=n-1;\n\tfor(;i>=0&&s[i]=='z';i--)\n\t\ts[i]='a';\n\tif(i<0)\n\t{\n\t\tcout<<\"Impossible\"<\n#include \nint main(){\n\tlong long x1,y1,x2,y2;\n\twhile (scanf(\"%lld%lld%lld%lld\",&x1,&y1,&x2,&y2)!=EOF){\n\t\tlong long x,y;\n\t\tscanf(\"%lld%lld\",&x,&y);\n\t\tlong long lenx,leny;\n\t\tlenx=x2-x1;\n\t\tleny=y2-y1;\n\t\tif(lenx<0)\n\t\tlenx*=(-1);\n\t\tif(leny<0)\n\t\tleny*=(-1);\n\t\tif(leny==0&&(lenx/x)%2==0||lenx==0&&(leny/y)%2==0){\n\t\t\tprintf (\"YES\\n\");\n\t\t}\n\t\telse if ((lenx*1.0)/x==(leny*1.0)/y){\n\t\t\tprintf (\"YES\\n\");\n\t\t}\n\t\telse{\n\t\t\tprintf (\"NO\\n\");\n\t\t}\n\t}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e386f9535f3a6f294e4cde912114a6e3", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint n,x1,y1,x2,y2,n1,n2;\nint main()\n{\n cin>>n>>x1>>y1>>x2>>y2;\n if(x1>=y1)n1=x1+y1+1;else n1=4*n-x1+y1;\n if(x2>=y2)n2=x2+y2+1;else n2=4*n-x2+y2;\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main()\n{ \n int n; scanf(\"%d\",&n);\n if (n % 2 == 0) cout << 0;\n else{\n if (n == 1) count << 1;\n if (n == 3) cout << 18;\n if (n == 5) cout << 1800;\n if (n == 7) cout << 670320;\n if (n == 9) cout << 734832000;\n if (n == 11) cout << 890786230;\n if (n == 13) cout << 695720788;\n if (n == 15) cout << 150347555;\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "30b30bc33361328e449c8651a45a7888", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define FOR(i, n) for(int i = 0; i < (n); i++)\n#define MEM(a, x) memset(a, x, sizeof(a))\n#define ALL(a) a.begin(), a.end()\n#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())\ntypedef long long ll;\n\nint n;\ndouble x[1005][5];\n\nint main(int argc, char const *argv[]) {\n\tios_base::sync_with_stdio(false);\n\tcin >> n;\n\tFOR(i, n) {\n\t\tFOR(j, 5) cin >> x[i][j];\n\t}\n\tvector v;\n\tFOR(i, n) {\n\t\tbool ok = true;\n\t\t// int cnt = 0;\n\t\tFOR(j, n) {\n\t\t\tif (j == i) continue;\n\t\t\tfor (int k = j+1; k < n; k++) {\n\t\t\t\tif (k == i) continue;\n\t\t\t\tdouble u[5], v[5], uv = 0, u2 = 0, v2 = 0;\n\t\t\t\tFOR(c, 5) {\n\t\t\t\t\tu[c] = x[j][c]-x[i][c];\n\t\t\t\t\tv[c] = x[k][c]-x[i][c];\n\t\t\t\t\tuv += u[c]*v[c];\n\t\t\t\t\tu2 += u[c]*u[c];\n\t\t\t\t\tv2 += v[c]*v[c];\n\t\t\t\t}\n\t\t\t\tif (acos(uv/sqrt(u2*v2))*2.0 < M_PI) ok = false;\n\t\t\t\t// cnt++;\n\t\t\t}\n\t\t}\n\t\t// cout << cnt << endl;\n\t\tif (ok) v.push_back(i+1);\n\t}\n\tcout << v.size() << endl;\n\tFOR(i, v.size()) cout << v[i] << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "15870e842c446a1bd91ed22296d6b4bb", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\ntypedef long long ll\nconst int P = 1e9 + 7;\nconst int N = 2e6 + 10;\nint n, k, pc;\nint pw[N], mu[N], p[N], b[N * 2];\nbool vis[N];\n\nvoid sieve();\nint pow(int x, int k);\n\nint main() {\n scanf(\"%d%d\", &n, &k);\n for (int i = 1; i <= k; ++i)\n pw[i] = pow(i, n);\n sieve();\n for (int x = 1; x <= k; ++x) {\n for (int i = 1; i * x <= k; ++i) {\n b[i * x] = (b[i * x] + (ll)pw[i] * (P + mu[x]) % P) % P;\n b[i * x] = (b[i * x] - (ll)pw[i - 1] * (P + mu[x] % P)) % P;\n if (b[i * x] < 0)\n b[i * x] += P;\n }\n }\n int ans = 0;\n for (int i = 1; i <= k; ++i) {\n b[i] = (b[i] + b[i - 1]) % P;\n ans = (ans + (b[i] ^ i) % P) % P;\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n\nvoid sieve() {\n mu[1] = 1;\n for (int x = 2; x <= k; ++x) {\n if (!vis[x]) {\n p[++pc] = x;\n mu[x] = -1;\n }\n for (int j = 1; x * p[j] <= k; ++j)\n if (x % p[j] == 0) {\n mu[x * p[j]] = 0;\n vis[x * p[j]] = true;\n break;\n } else {\n mu[x * p[j]] = -mu[x];\n vis[x * p[j]] = true;\n }\n }\n}\nint pow(int x, int k) {\n int ret = 1;\n while (k) {\n if (k & 1)\n ret = (ll)ret * x % P;\n x = (ll)x * x % P;\n k >>= 1;\n }\n return ret;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a4be57b518a254ab093248e009796a3c", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n// #include\n// #include\n// #include\n// #include\n// #include\n// #include\n#include\n// #include\n// #include\n// #include\n// #include\nusing namespace std; \n\n#define ll long long\n#define pb push_back\n#define mp make_pair\n\n#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)\n\nconst ll M = 1e9 + 7;\n\nll N = 4004;\nconst ll MOD = 1e9 + 7;\n\nll add(ll x, ll y){\n x += y;\n while(x >= MOD) x -= MOD;\n while(x < 0) x += MOD;\n return x;\n}\n\nll mul(ll x, ll y){\n return (x * y) % MOD;\n}\n\nll binpow(ll x, ll y){\n if(y == 0ll){\n return 1ll;\n }\n if(y == 1ll){\n return x;\n }\n ll z = binpow(x, y/2);\n z = mul(z, z);\n if(y%2 == 0ll){\n return z;\n }\n z = mul(z, x);\n return z;\n}\n\nll inv(ll x){\n return binpow(x, MOD - 2);\n}\n\nll divide(ll x, ll y){\n return mul(x, inv(y));\n}\n\nvector fact(N, 0);\n\nvoid precalc(){\n fact[0] = 1;\n for(int i = 1; i < N; i++)\n fact[i] = mul(fact[i - 1], i);\n}\n\nint C(int n, int k){\n return divide(fact[n], mul(fact[k], fact[n - k]));\n}\n\nvoid print(vector &a){\n int n = a.size();\n for(int i=0; i<10; i++){\n cout< dp(N, 0ll), cf(N, 0ll);\n\nvoid fill(ll n){\n for(ll i=0; i>n;\n N = n+5;\n ini();\n print(dp);\n print(cf);\n ll ans = solve(n);\n cout<\n//#include \n#define initrand mt19937 mt_rand(time(0));\n#define rand mt_rand()\n#define int long long\n#define MOD 1000000007\n#define INF 1000000000\n#define mid(l, u) ((l+u)/2)\n#define rchild(i) (i*2 + 2)\n#define lchild(i) (i*2 + 1)\n#define mp(a, b) make_pair(a, b)\n#define lz lazup(l, u, i);\nusing namespace std;\nconst int N = 505;\nint dp[N][N*N], p[N][N*N], nCr[N][N], fac[N];\nsigned main(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n int n, mod;\n cin>>n>>mod;\n dp[0][0] = 1;\n dp[0][0] %= mod;\n for(int i = 1;i<=n;i++){\n int sum = 0;\n int maxi = i*(i-1)/2;\n for(int j = 0;j<=maxi;j++){\n sum += dp[i-1][j];\n if((j - i)>=0) sum -= dp[i-1][j-i];\n sum %= mod;\n sum += mod;\n sum %= mod;\n dp[i][j] = sum;\n }\n p[i][maxi] = dp[i][maxi];\n for(int j = maxi-1;j>=0;j--){\n p[i][j] = dp[i][j] + p[i][j+1];\n p[i][j] %= mod;\n }\n }\n fac[0] = 1;\n for(int i = 1;i=0;k--){\n ww -= bb;\n if((k+2) <= maxi) ww += p[i][k+2]*i;\n ww %= mod;\n ww += mod;\n ww %= mod;\n\n if((k+i+1)<=mod) bb -= p[i][k+i+2];\n if((k+2) <= mod) bb += p[i][k+2];\n bb %= mod;\n bb += mod;\n bb %= mod;\n int xx = 0;\n for(int j = 2;j<=(i+1);j++){\n xx += p[i][k+j]*(i+ 2 - j);\n xx %= mod;\n }\n int toAdd = b;\n toAdd *= dp[i][k];\n toAdd %= mod;\n toAdd *= ww;\n ans += toAdd;\n ans %= mod;\n }\n }\n cout<\nusing namespace std;\nconst int64_t base=998244353;\nint64_t power(int64_t x, int64_t y){\n if(y==0) return 1;\n int64_t t=power(x, y/2);\n t=(t*t)%base;\n if(y%2) t=(t*x)%base;\n return t;\n}\nint64_t inverse(int64_t x){//modular inverse\n return power(x, base-2);\n}\nvector f({1}), iv({1});\n\nint64_t C(int64_t n, int64_t k){\n return ((f[n]*iv[k]%base)*iv[n-k])%base;\n}\nint64_t star(int64_t n, int64_t k){\n return C(n+k-1, k-1);\n}\nint64_t countGame(int64_t n, int64_t k, int64_t x){//n points total, k players, no player can have x point or more\n if(k==0) return !(n==0);\n int64_t ans=0\n for(int i=0; i<=k; i++){\n int64_t t=n-x*i;\n if(t<0) break;\n if(i%2) ans=(ans-C(k, i)*star(t, k))%base;\n else ans=(ans+C(k, i)*star(t, k))%base;\n }\n return ans;\n}\nint main(){\n int p, s, r;\n int64_t gameSize=countGame(s-r, p, 1e18);\n gameSize=inverse(gameSize);\n cin>>p>>s>>r;\n for(int i=1; i<5555; i++){\n f.push_back((f[i-1]*i)%base);\n iv.push_back(inverse(f[i]));\n }\n int64_t ans=0;\n for (int q=r; q<=s; q++){\n for(int i=0; i\n\nusing namespace std;\n\nint d1[1001],d2[1001],n,tg;\n\nint main(){\ncin>>n;\nfor(int i=1;i<=n;i++)\n{cin>>tg;\nd1[tg]++;\n}\nfor (int i=1;i<=n;i++){\ncin>>tg;\nd2[tg]++;\n}\nfor (int i=1;i<=1000;i++) if (d1[i]\r\n\r\nusing ull = unsigned long long;\r\nusing L = __uint128_t;\r\n\r\nusing namespace std;\r\n\r\nstruct FastMod {\r\n\tull b, m;\r\n\r\n\tFastMod(ull b) : b(b), m(ull((L(1) << 64) / b)) {}\r\n\r\n\tull operator()(ull a) {\r\n\t\tull q = (ull) ((L(m) * a) >> 64);\r\n\t\tull r = a - q * b; // can be proven that 0 <= r < 2*b\r\n\t\treturn r >= b ? r - b : r;\r\n\t}\r\n} R(2);\r\n\r\nint mod;\r\ninline void add(int &x, int y) {\r\n if ((x += y - mod) < 0)\r\n x += mod;\r\n}\r\n\r\nconst int N = 400;\r\nint n;\r\nint f[N + 5][N + 5], ans;\r\n\r\nint main() {\r\n scanf(\"%d%d\", &n, &mod), R = FastMod(mod);\r\n f[0][0] = 1;\r\n for (int k = 1; 2 * k <= n + 1; ++k) {\r\n for (int i = 1; i <= n - k + 1; ++i)\r\n f[k][i] = R((2ULL * f[k][i - 1] + f[k - 1][i - 1]) * k);\r\n add(ans, f[k][n - k + 1]);\r\n }\r\n printf(\"%d\\n\", ans);\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a9c95735ad88d09304be4433e1db9979", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nconst int maxn = 80 + 5;\nconst int INF = 1 << 29;\n\nll dp[maxn][maxn][maxn][2];\nint a[maxn], b[maxn], c[maxn];\nchar s[maxn];\n\nvoid upmin(int &a, int b)\n{\n a = min(a, b);\n}\n\nint main()\n{\n int n;\n scanf(\"%d%s\", &n, s + 1);\n int cnt1 = 0, cnt2 = 0, cnt3 = 0;\n for(int i = 1; i <= n; ++i)\n {\n if(s[i] == 'V') a[++cnt1] = i;\n else if(s[i] == 'K') b[++cnt2] = i;\n else c[++cnt3] = i;\n }\n memset(dp, 0x3f, sizeof(dp));\n dp[0][0][0][0] = 0;\n for(int i = 1; i <= n; ++i)\n {\n for(int j = 0; j <= cnt1; ++j)\n {\n for(int k = 0; k <= cnt2; ++k)\n {\n for(int l = 0; l < 2; ++l)\n {\n int m = i - j - k;\n if(i - j - k <= cnt3)\n {\n int p = upper_bound(a + 1, a + j + 1, c[m]) - a - 1, q = upper_bound(b + 1, b + k + 1, c[m]) - b - 1;\n upmin(dp[i][j][k][0], dp[i - 1][j][k][l] + abs(c[m] + j - p + k - q - i));\n }\n if(j < cnt1)\n {\n int p = upper_bound(b + 1, b + k + 1, a[j + 1]) - b - 1, q = upper_bound(c + 1, c + m, a[j + 1]) - c - 1;\n upmin(dp[i][j + 1][k][1], dp[i - 1][j][k][l] + abs(a[j + 1] + k - p + m - 1 - q - i));\n }\n if(k < cnt2 && l != 1)\n {\n int p = upper_bound(c + 1, c + m, b[k + 1]) - c - 1, q = upper_bound(a + 1, a + j + 1, b[k + 1]) - a - 1;\n upmin(dp[i][j][k + 1][0], dp[i - 1][j][k][l] + abs(b[k + 1] + m - 1 - p + j - q - i));\n }\n }\n }\n }\n }\n printf(\"%I64d\\n\", min(dp[n][cnt1][cnt2][0], dp[n][cnt1][cnt2][1]));\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a11e7bf67db24b817485f2092c8c0beb", "src_uid": "08444f9ab1718270b5ade46852b155d7", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n int n,i,j,x,d=0;\n \n\nint main(){\n cin>>n;\n for (i=0; i>x;\n if (i==j || i==(n/2) || j==(n/2) || (n-i)==j+1)\n \n d=d+x;\n \n \n // system (\"PAUSE\"); \n return 0;\n }\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c6902e8cfe2da045cc112eb3952a57c9", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\n\n\n\nint n, d, ans;\n\n\n\n\tint main(){\n\n\t\tint arr[] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };\n\t\tcin >> n >> d;\n\t\tint m = d;\n\t\tfor (int i = d; i <= arr[n] + d; i++)\n\t\t{\n\t\t\tif (m == 7){\n\t\t\t\tm = 1;\n\t\t\t\tans++;\n\t\t\t}\n\t\t\tm++;\n\t\t}\n\t\tcout << ans << endl;\n\n\t\treturn 0;\n\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "335abd790e0aa781225cb23b92d13408", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n \nconst int maxn = 500050;\n \nint mx[maxn], lx[maxn], rx[maxn], v[maxn], tag[maxn], rev[maxn];\nint fa[maxn], c[maxn][2], size[maxn], sum[maxn];\nint n, m, rt, cnt, id[maxn], a[maxn];\nchar op[30];\nqueue q;\n \ninline void read(int &x)\n{\n int f = 1; \n x = 0; char c = '.';\n while(c < '0' || c > '9') {if(c == '-') f = -f; c = getchar();}\n while(c >= '0' && c <= '9') x = x*10 + c-'0', c=getchar();\n x *= f;\n}\n \ninline int max(int a,int b){return (a > b ? a : b);}\n \ninline void pushup(int k)\n{\n int l = c[k][0], r = c[k][1];\n sum[k] = v[k] + sum[l] + sum[r];\n size[k] = size[l] + size[r] + 1;\n mx[k] = max(mx[l], max(mx[r], rx[l]+v[k]+lx[r]));\n lx[k] = max(lx[l], sum[l]+v[k]+lx[r]);\n rx[k] = max(rx[r], sum[r]+v[k]+rx[l]);\n}\n \ninline void pushdown(int k)\n{\n int l = c[k][0], r = c[k][1];\n if(tag[k])\n {\n rev[k] = tag[k] = 0;\n if(l) tag[l] = 1, v[l] = v[k], sum[l] = v[k]*size[l];\n if(r) tag[r] = 1, v[r] = v[k], sum[r] = v[k]*size[r];\n if(v[k] >= 0) \n {\n if(l) lx[l] = rx[l] = mx[l] = sum[l];\n if(r) lx[r] = rx[r] = mx[r] = sum[r];\n }\n else\n {\n if(l) lx[l] = rx[l] = 0, mx[l] = v[k];\n if(r) lx[r] = rx[r] = 0, mx[r] = v[k];\n }\n }\n if(rev[k])\n {\n rev[k] ^= 1; rev[l] ^= 1; rev[r] ^=1;\n swap(c[l][0],c[l][1]); swap(c[r][0], c[r][1]);\n swap(lx[l], rx[l]); swap(lx[r], rx[r]);\n }\n}\n \nvoid rotate(int x,int &k)\n{\n int y = fa[x], z = fa[y], l, r;\n l = (c[y][1]==x); r = l^1;\n if(y == k) k = x;\n else c[z][(c[z][1]==y)] = x;\n fa[x] = z; fa[y] = x; fa[c[x][r]] = y;\n c[y][l] = c[x][r]; c[x][r] = y;\n pushup(y); pushup(x);\n}\n \nvoid splay(int x,int &k)\n{\n while(x != k)\n {\n int y = fa[x], z = fa[y];\n if(y != k)\n {\n if(c[y][0]==x^c[z][0]==y) rotate(x,k);\n else rotate(y,k);\n }\n rotate(x,k);\n }\n}\n \nint find(int k,int rk)\n{\n pushdown(k);\n int l = c[k][0], r = c[k][1];\n if(size[l]+1 == rk) return k;\n else if(size[l] >= rk) return find(l,rk);\n else return find(r,rk-size[l]-1);\n}\n \nint split(int k,int tot)\n{\n int x = find(rt,k), y = find(rt,k+tot+1);\n splay(x,rt); splay(y,c[x][1]);\n return c[y][0];\n}\n \nvoid rec(int k)\n{\n if(!k) return;\n int l = c[k][0], r = c[k][1];\n rec(l); rec(r); q.push(k);\n c[k][0] = c[k][1] = fa[k] = 0;\n tag[k] = rev[k] = 0;\n} \n \nvoid build(int l,int r,int f)\n{\n if(l > r) return;\n int mid = l+r >> 1;\n int now = id[mid], last = id[f];\n if(l == r)\n {\n sum[now] = a[l]; size[now] = 1;\n tag[now] = rev[now] = 0;\n if(a[l] >= 0) lx[now] = rx[now] = mx[now] = a[l];\n else lx[now] = rx[now] = 0, mx[now] = a[l]; \n } else build(l,mid-1,mid), build(mid+1,r,mid);\n v[now] = a[mid]; fa[now] = last; pushup(now);\n c[last][mid>=f] = now;\n}\n \nvoid insert(int k,int tot)\n{\n fo(i,1,tot) read(a[i]);\n fo(i,1,tot)\n if(!q.empty()) id[i] = q.front(), q.pop();\n else id[i] = ++ cnt;\n build(1,tot,0); int z = id[(tot+1)>>1];\n int x = find(rt,k+1), y = find(rt,k+2);\n splay(x,rt); splay(y,c[x][1]);\n c[y][0] = z; fa[z] = y;\n pushup(y); pushup(x);\n}\n \nvoid delet(int k,int tot)\n{\n int x = split(k,tot), y = fa[x];\n rec(x); c[y][0] = 0;\n pushup(y); pushup(fa[y]);\n}\n \nvoid modify(int k,int tot,int c)\n{\n int x = split(k,tot), y = fa[x];\n tag[x] = 1; v[x] = c; sum[x] = c*size[x];\n if(c >= 0) lx[x] = rx[x] = mx[x] = sum[x];\n else lx[x] = rx[x] = 0, mx[x] = c;\n pushup(y); pushup(fa[y]);\n}\n \nvoid rever(int k,int tot)\n{\n int x = split(k,tot), y = fa[x];\n if(!tag[x])\n {\n rev[x] ^= 1;\n swap(c[x][0], c[x][1]); swap(lx[x], rx[x]);\n pushup(y); pushup(fa[y]);\n }\n}\n \nvoid query(int k,int tot)\n{\n int x = split(k,tot);\n printf(\"%d\\n\",sum[x]);\n}\nint aa[] = {0, 1, 9, 245, 126565, 54326037, 321837880, 323252721, 754868154, 328083248, 838314395, 220816781, 893672292, 166441208, 251255697, 114256285, 118775501, 482714697, 11784725, 460862131, 550384565, 106742050, 425241115, 626692854, 674266678, 320014275, 345949512, 527320049, 897822749, 137190263, 491039182, 810384961, 482023334, 658099864, 886790989, 845381174, 371433224, 278969124, 420088324, 696766322, 388302635, 141033366, 46387851, 932125021, 278342766, 371131134, 922501918, 110778457, 506223573, 806353719, 391845991, 923507761, 780307355, 109951115, 830090230, 605558495, 344686604, 988110893, 944684429, 715019947, 799898820, 384672708, 907325090, 758952329, 550672104, 368337206, 394915145, 401744167, 923781939, 831857516, 407845661, 329267374, 927004007, 891609656, 897919613, 481297880, 737337940, 651873737, 287246681, 973133651, 679864988, 784719328, 820504764, 875613823, 806512665, 164851642, 500228957, 951814419, 447763649, 273141670, 979349615, 964027956, 809510400, 276634497, 116631976, 426739449, 175282420, 885948162, 62270880, 974395255, 675165056, 759589968, 837957573, 931897605, 152352780, 585420109, 1772087, 333401718, 898833639, 745874265, 786209423, 691982338, 498790927, 473374639, 274302623, 971280670, 241671319, 13070005, 302088807, 550276351, 436592588, 631667314, 548656698, 730626984, 146295220, 674398632, 400383348, 454138904, 786220712, 118620797, 233440672, 217349271, 274853536, 310607544, 105221205, 769566615, 853585061, 800665807, 695377419, 924327065, 388199705, 551624811, 721435546, 501720515, 308465454, 825369234, 396065729, 451899519, 295058424, 142088952, 473485086, 378771634, 734511215, 462404399, 959198328, 337668263, 794122911, 38911400, 951992982, 472696081, 373904752, 105884826, 630251717, 28980684, 845136347, 353665773, 691661192, 19922354, 231463797, 757917231, 242739918, 979036950, 713722080, 234689388, 2243164, 209872853, 240808787, 539523346, 425797848, 913772061, 224613100, 421742777, 222232478, 92712941, 215137570, 949901408, 274827432, 15162482, 593145989, 274574232, 239282092, 762720192, 804146934, 500629424, 565985054, 81127381, 671811155, 655565571, 890331075, 237994348, 743647404, 667160634, 713914299, 668506729, 741341289, 277636808, 762781382, 14272789, 902864131, 567443405, 149113383, 648844381, 825489976, 933016723, 192288078, 734493315, 240985733, 861817693, 762711459, 525904609, 532463481, 377133989, 620711079, 772561562, 980733194, 227599811, 162774370, 209512798, 787116594, 3509258, 748795368, 378035466, 612938915, 802091952, 857679599, 481748937, 493370392, 358420805, 48301629, 412001241, 463126722, 509578422, 967799131, 994766554, 687287243, 863623583, 771554899, 690911527, 855314994, 923686429, 246862514, 192479791, 133487041, 703444043, 295281758, 801816257, 920762934, 749306433, 973004841, 848644684, 560026478, 952127278, 616654635, 839390326, 975154012, 409583672, 635350249, 343228425, 335331602, 223826406, 952341037, 589677800, 249747234, 555694261, 137143500, 628190328, 461598392, 431912756, 29349807, 759199489, 783281228, 781971312, 915823407, 388508707, 718062705, 27424111, 309999451, 963383322, 831185229, 132910888, 347028136, 850484840, 223055285, 142335980, 144754000, 772005560, 81796039, 167696020, 79454283, 172772542, 201056991, 484957644, 716630285, 763194701, 211505841, 903448791, 926964672, 257752668, 482951716, 411539070, 620249847, 592476107, 170473128, 814662613, 898000271, 57354872, 361106091, 488697643, 889007954, 138725767, 684860983, 36248116, 304610143, 137633385, 413715776, 99010024, 779653665, 100387568, 286328069, 564731826, 621740468, 943513219, 506666491, 249987886, 553719884, 769853086, 337485319, 702455584, 809637762, 755400257, 892290368, 502180086, 364275817, 118162370, 873374339, 261271695, 970132574, 744105500, 434447173, 117975095, 383088393, 625447969, 180281249, 545367713, 133236931, 360175662, 148087453, 806871297, 498529036, 886076476, 65645000, 465138299, 967109895, 331362616, 472283705, 796894900, 199697765, 503759892, 472807906, 187586706, 941198065, 782234442, 57693411, 18678611, 82626204, 395317191, 570588915, 152519440, 449852456, 63696518, 763741345, 878748386, 494317541, 444782633, 93316211, 929164666, 529288371, 165769871, 730546850, 955877127, 994202767, 492009567, 275683011, 415902127, 95725776, 718047399, 786963365, 73091278, 986172399, 174591541, 913259286};\n\nint n;\n\nint main()\n{\n\tcin >> n;\n\tcout << aa[n];\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "510ebb1ffa57246f5c2b890f765c22ac", "src_uid": "fda761834f7b5800f540178ac1c79fca", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\n using namespace std; long long n,p,l1,r1,ans,cnt,q[105],r[105],Q,R,P,pw[55]; void exgcd(long long a,long long b,long long &x,long long &y){ \tif(b==0){ \t\tx=1;y=0; \t\treturn; \t} \texgcd(b,a%b,x,y); \tint t=x; \tx=y;y=t-y*(a/b); \treturn; } struct fe{ \tlong long rem,x; \tfe operator *(const fe &o)const{ \t\treturn (fe){rem+o.rem,x*o.x%Q}; \t} \tfe operator *(long long o)const{ \t\tint y=0;while(o%P==0)y++,o/=P; \t\treturn (fe){rem+y,x*o%Q}; \t} \tfe inv(){ \t\tlong long a,b;exgcd(x,Q,a,b); \t\tif(a<0)a+=Q; \t\treturn (fe){-rem,a}; \t} \tlong long get(){ \t\tif(rem>=R)return 0; \t\treturn pw[rem]*x%Q; \t} }fc[100005],fi[100005]; long long C(long long x,long long y){ \tif(y<0||x<0||x1){ \t\tq[cnt]=m;r[cnt]=1; \t\tcnt++; \t} \tint s=l1,e=r1; \tif(s%2==1)s++;if(e%2==1)e--; \tif(s<=e)ans=(ans+calc(n,p,s)-calc(n,p,e+2)+p)%p; \ts=l1,e=r1; \tif(s%2==0)s++;if(e%2==0)e--; \tif(s<=e)ans=(ans+calc(n,p,s)-calc(n,p,e+2)+p)%p; \tprintf(\"%lld\\n\",ans); \treturn 0; }\n\n\u00a0\n\n\u00a0\n\n1\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "26f442d6e9c5d601a4e644ccba6020ed", "src_uid": "6ddc487029785738679007443fc08463", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "/* package whatever; // don't place package name! */\n\nimport java.util.*;\nimport java.lang.*;\nimport java.io.*;\nimport java.math.*;\n\n/* Name of the class has to be \"Main\" only if the class is public. */\nclass Solution\n{\n\tpublic static BigInteger MOD = new BigInteger(\"1000000007\");\n\tpublic static BigInteger negOne = new BigInteger(\"-1\");\n\tpublic static BigInteger pre[][] = new BigInteger[2010][2010];\n\tpublic static int vis[][][] = new int[2010][2010][2];\n\tpublic static BigInteger DP[][][] = new BigInteger[2010][2010][2];\n\t\n\tpublic static void initial ( int n )\n\t{\n\t\tfor ( int i = 0; i <= 2 * n; i++ )\n\t\t\tfor ( int j = 0; j <= 2 * n; j++ )\n\t\t\t\tpre[i][j] = negOne;\n\t}\n\t\n\tpublic static BigInteger precalc ( int i, int open )\n\t{\n\t\tif ( open < 0 )\n\t\t\treturn BigInteger.ZERO;\n\t\tif ( i == 0 )\n\t\t{\n\t\t\tif ( open == 0 )\n\t\t\t\treturn pre[i][open] = BigInteger.ONE;\n\t\t\treturn pre[i][open] = BigInteger.ZERO;\n\t\t}\n\t\t\n\t\tif ( pre[i][open] != negOne )\n\t\t\treturn pre[i][open];\n\t\n\t\treturn pre[i][open] = (precalc ( i - 1, open + 1 ).add(precalc ( i - 1, open - 1 ))).mod ( MOD );\n\t}\n\t\n\tpublic static BigInteger dp ( int i, int open, int f )\n\t{\n\t\tif ( i == 0 )\n\t\t\treturn BigInteger.ZERO;\n\t\tif ( vis[i][open][f] == 1 )\n\t\t\treturn DP[i][open][f];\n\t\t\n\t\tif ( f == 0 )\n\t\t{\n\t\t\tif ( pre[i - 1][open + 1].equals(pre[i][open]) )\n\t\t\t\tDP[i][open][f] = dp ( i - 1, open + 1, 0 ).max ( dp ( i - 1, open + 1, 1 ).add ( BigInteger.ONE ) );\n\t\t\telse if ( pre[i - 1][open + 1].equals(BigInteger.ZERO) )\n\t\t\t\tDP[i][open][f] = dp ( i - 1, open - 1, 0 ).max ( dp ( i - 1, open - 1, 1 ).add ( BigInteger.ONE ) );\n\t\t\telse\n\t\t\t{\n\t\t\t\tDP[i][open][f] = dp ( i - 1, open + 1, 1 ).add(dp ( i - 1, open - 1, 0 ).add(BigInteger.ONE));\n\t\t\t\tDP[i][open][f] = DP[i][open][f].max(dp ( i - 1, open + 1, 0 ).add(dp ( i - 1, open - 1, 1 ).add(BigInteger.ONE)));\n\t\t\t\tDP[i][open][f] = DP[i][open][f].max(dp ( i - 1, open + 1, 0 ).add(dp ( i - 1, open - 1, 0 )));\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif ( pre[i - 1][open + 1].equals(pre[i][open]) )\n\t\t\t\tDP[i][open][f] = dp ( i - 1, open + 1, 0 );\n\t\t\telse if ( pre[i - 1][open + 1].equals(BigInteger.ZERO) )\n\t\t\t\tDP[i][open][f] = dp ( i - 1, open - 1, 0 );\n\t\t\telse\n\t\t\t\tDP[i][open][f] = dp ( i - 1, open - 1, 0 ).add(dp ( i - 1, open + 1, 0 ));\n\t\t}\n\t\t\n\t\tDP[i][open][f] = DP[i][open][f].mod(MOD);\n\t\n\t\tvis[i][open][f] = 1;\n\t\treturn DP[i][open][f];\n\t}\n\n\t\n\tpublic static void main (String[] args) throws java.lang.Exception\n\t{\n\t\tScanner in = new Scanner ( System.in );\n\t\tint N = in.nextInt();\n\t\tinitial(N);\n\t\tprecalc ( 2 * N, 0 );\n\t\tSystem.out.println ( dp ( 2 * N, 0, 0 ).mod(MOD) );\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "165c91ca3a595bc473626761a992e411", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std ;\n\nint main()\n{\n int a ;\n cin >> a ;\n int ans ;\n ans = ( a== 1) : 1 : 2 * (a - 1 ) ;\n cout << ans << '\\n' << \"1 2 \" << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "441e4a94e283578c928bbf59fc85bcba", "src_uid": "5c000b4c82a8ecef764f53fda8cee541", "difficulty": 1400.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nvector > > dp(50,vector > (50));\nvector > trace_back(50,vector (50));\nstring t;\nvoid trace_path(ll i,ll j){\n if(i==0&&j==0){\n return;\n }\n else{\n if(j0 && dp[i][j].first==dp[i][j-1].first){\n t.push_back('M');\n trace_path(i,j-1);\n }\n else{\n t.push_back('H');\n trace_path(i-1,j);\n }\n }\n}\nint main(){\n ll n;cin >> n;\n string s;cin >> s;\n dp[0][0]=make_pair(0,0);trace_back[0][0]=' ';\n for(ll j=1;j<=n;j++){\n dp[0][j].second+=dp[0][j-1].second+(s[2*n-j]-'0')*pow(10,j-1);\n trace_back[0][j]='M';\n }\n for(ll i=1;i<=n;i++){\n dp[i][0].first+=dp[i-1][0].first+(s[2*n-i]-'0')*pow(10,i-1);\n trace_back[i][0]='H';\n }\n for(ll i=1;i<=n;i++){\n for(ll j=1;j<=n;j++){\n ll MAX=0;\n MAX=max(dp[i][j-1].second+(s[2*n-i-j]-'0')*pow(10,j-1)+dp[i][j-1].first,dp[i-1][j].first +(s[2*n-i-j]-'0')*pow(10,i-1)+dp[i-1][j].second);\n if(MAX==dp[i][j-1].second+(s[2*n-i-j]-'0')*pow(10,j-1)+dp[i][j-1].first){\n dp[i][j].second= dp[i][j-1].second+(s[2*n-i-j]-'0')*pow(10,j-1);\n dp[i][j].first = dp[i][j-1].first;\n trace_back[i][j]='M';\n }\n else{\n dp[i][j].first = dp[i-1][j].first +(s[2*n-i-j]-'0')*pow(10,i-1);\n dp[i][j].second= dp[i-1][j].second; \n trace_back[i][j]='H';\n }\n }\n }\n /*for(ll i=0;i<=n;i++){\n for(ll j=0;j<=n;j++){\n cout << setfill(' ') << setw(n) << dp[i][j].first;\n cout << \"-\" ;\n cout << setfill(' ') << setw(n) << dp[i][j].second << \" \";\n }\n cout << endl;\n }\n for(ll i=0;i<=n;i++){\n for(ll j=0;j<=n;j++){\n cout << trace_back[i][j] << \" \";\n }\n cout << endl;\n }*/\n trace_path(n,n);\n cout << t << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "581af3779fd55e40fe9e1a9c863de2bc", "src_uid": "98489fe54488dcfb45f8ae7b5c473d88", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define ll long long int\nconst long long N=1e6+5;\n\nmap m;\nmap cache[30];\nll n,q;\nll dp(char reqd, ll len)\n{\n\tif(len==n)\n\t{\n\t\treturn 1;\n\t}\n\tif(cache[reqd-'a'].find(len)!=cache[reqd-'a'].end())\n\t{\n\t\treturn cache[reqd-'a'][len];\n\t}\n\tll ans=0;\n\tfor(auto it:m)\n\t{\n\t\tif(it.ss==reqd)\n\t\t{\n\t\t\tans+=dp((it.ff)[0],len+1);\n\t\t}\n\t}\n\tcache[reqd-'a'][len]=ans;\n\treturn ans;\n}\nint main()\n{\n\t\n\tcin>>n>>q;\n\tfor(int i=0;i>a>>b;\n\t\tm[a]=b;\n\t}\n\tcout<\nusing namespace std;\nint main()\n{\nint t,s,q,count=1;\ncin >> t >> s >>q;\ndo{\ns+=s*(q-1);\nif(s\nusing namespace std;\nint main()\n{\n int n,i,j,n1,n2,n3;\n int a[20];\n cin >> n;\n for (i=0; i> a[i];\n }\n for (i=1; i<=n; i++)\n {\n for (j=0; j<=7;j++)\n {\n if(i==1+3*j) {n1=n1 + a[i-1];} \n if(i==2+3*j) {n2=n2 + a[i-1];} \n if(i==3+3*j) {n3=n3 + a[i-1];} \n }\n }\n cout << max(n1,n2,n3);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "288f1933375c8e5a792e0a5cd1e90a31", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nvoid main() {\n\tstring uni[] = { \"Zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\",\"ten\" };\n\tstring teens[] = { \"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\" };\n\tstring tens[] = { \"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\" };\n\tint x;\n\tcin >> x;\n\tif (x >= 0 && x <= 10) {\n\t\tcout << uni[x] << endl;\n\t}\n\telse if (x > 10 && x <= 19) {\n\t\tcout << teens[(x % 10) - 1] << endl;\n\t}\n\telse {\n\t\tint y = ceil(x / 10);\n\t\tif (x - y == 0)\n\t\t\tcout <\r\n#include \r\nusing namespace std;\r\nint main() {\r\n int t;\r\n cin>>t;\r\n while(t--){\r\n int n;\r\n cin>>n;\r\n int x=sqrt(n);\r\n int y=cbrt(n);\r\n int c=pow(n,0.166667);\r\n cout<\r\nusing namespace std;\r\n#define FIO \\\r\n ios_base::sync_with_stdio(false); \\\r\n cin.tie(0); \\\r\n cout.tie(0);\r\n\r\n/*...............Short-hand .................*/\r\n\r\n#define endl \"\\n\"\r\n#define int long long\r\n#define ll long long\r\ntypedef vector vi;\r\ntypedef vector> vpi;\r\ntypedef pair pi;\r\n#define ld long double\r\n#define pb push_back\r\n#define all(x) x.begin(), x.end()\r\n\r\n/* .................Debugger Section..................*/\r\n#define debugv(v) \\\r\n for (auto x : v) \\\r\n cout << x << \" \"; \\\r\n cout << endl;\r\n\r\n#define debugm(m) \\\r\n for (auto x : m) \\\r\n cout << x.first << \" \" << x.second << endl;\r\n\r\nint mod = 1e9 + 7;\r\n\r\nld pie = 3.14159265358979323;\r\n// up, right, down, left\r\nint dx[4] = {-1, 0, 1, 0};\r\nint dy[4] = {0, 1, 0, -1};\r\n// int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};\r\n// int dy[8] = {0, -1, 1, 1, -1, 1, -1, 1};\r\n\r\n/***********Use-full function **********************************/\r\n\r\nbool isSafe(int x, int y, int row, int col)\r\n{\r\n if (x < 0 || y < 0 || y >= col || x >= row)\r\n return 0;\r\n\r\n return 1;\r\n}\r\n\r\nbool isPrime(ll n)\r\n{\r\n if (n == 1)\r\n return 0;\r\n if (n == 2)\r\n return 1;\r\n for (int i = 2; i <= sqrt(n); i++)\r\n if (n % i == 0)\r\n return 0;\r\n return 1;\r\n}\r\n\r\nint ceiling_(int x, int y)\r\n{\r\n return x / y + (x % y > 0);\r\n}\r\n\r\nint power(int a, int n)\r\n{\r\n int result = 1;\r\n while (n)\r\n {\r\n if (n & 1)\r\n result = (result * a) % mod;\r\n n >>= 1;\r\n a = (a * a) % mod;\r\n }\r\n\r\n return result % mod;\r\n}\r\n/*\r\n....................Experience.....................................................................\r\n> Sieve of Eratosthenes base is prime number of power\r\n> always remember Merge Sort\r\n> take all the alphabet as a string instead of taking the array of char\r\nabcdefghijklmnopqrstuvwxyz\r\n\r\n> if intial like pattern is equal to the final pattern the in\r\n1-D array : all even have same turn and all even postion have same turn\r\n2-D : {(i+j)%2 == 1} have same turn and {(i+j)%2 == 0} have same turn.\r\n\r\n> For manhattan distance based question try to find the logic using a 2-D grid\r\n> Read the question very carefully\r\n> Some time also remind priority_queue\r\n> If the question is based on string trying to think around the 26 char array\r\n> Multiset , set , map , priority_queue\r\n> cout< vector> v(n, vector(n, 2));\r\n> check 2nd Bit set or not of 'x' (x &(1<<2))\r\n> If the answer lies b/w the range try\r\nBINARY SEARCH\r\n> Group based question try Connected Component\r\n*/\r\n\r\nvoid solve()\r\n{\r\n set s;\r\n for (int i = 1; i <= 100000; i++)\r\n {\r\n int t = i * i;\r\n int t2 = i * i * i;\r\n s.insert(t);\r\n s.insert(t2);\r\n }\r\n\r\n int n;\r\n cin >> n;\r\n\r\n int cnt = 0;\r\n for (auto x : s)\r\n {\r\n if (x <= n)\r\n cnt++;\r\n }\r\n cout << cnt << endl;\r\n}\r\n\r\nsigned main()\r\n{\r\n FIO;\r\n int test = 1;\r\n cin >> test;\r\n\r\n for (int i = 1; i <= test; i++)\r\n {\r\n // cout << \"Case #\" << i << \": \";\r\n solve();\r\n }\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "20cbe840c04f00809e2814c2b41baf06", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n\n\tint n,x=0,arr[100];\n\tcin>>n;\n\n\tfor(int i=1;i<=n;i++)\n\t{\n\tcin>>arr[i];\n\t}\n\tif(n==1&&arr[n]!=15&&arr[n]!=0)\n\t{\n\tcout<<\"-1\"<arr[n-1]&&arr[n]!=15)\n\t\tcout<<\"UP\"<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int maxN = 100005;\nint n1, n2, m;\n\nstruct Tque{int t, u, L;}q[maxN];\nstruct Tnode{Tnode *son[27];}node[maxN], *nod[maxN];\nint nodes;\n\nint lev[maxN], r[maxN];\nint up[maxN][20], lg[maxN];\n\nint wa[maxN], wb[maxN], sum[maxN], Jum[maxN], sa[maxN], rank[maxN];\n\nint tree[2][maxN];\n\nstruct Region{int L, R;}reg[maxN];\nint sta[maxN], Last[maxN];\n\nTnode *newnode(){\n nodes++;\n return node+nodes;\n}\n\nvoid Readln(){\n scanf( \"%d\\n\", &m );\n n1 = n2 = 1;\n lev[n2] = 1;\n nod[n1] = newnode();\n for (int i=1; i<=m; i++){\n int t, u, let;\n char ch;\n scanf( \"%d%d \", &t, &u );\n scanf( \"%c\", &ch );\n let = ch-97+1;\n q[i].t = t;\n q[i].L = let;\n if (t==1){\n if (nod[u] -> son[let] == NULL){\n nod[u] -> son[let] = newnode();\n }\n n1++;\n nod[n1] = nod[u] -> son[let];\n q[i].u = n1;\n }else{\n n2++;\n up[n2][0] = u;\n r[n2] = let;\n lev[n2] = lev[u]+1;\n q[i].u = n2;\n }\n }\n}\n\nbool cmp(int *r, int a, int b){\n return r[a] == r[b] && r[Jum[a]] == r[Jum[b]];\n}\n\nvoid da(int *r, int *sa, int n, int m){\n int i, j, p, *x=wa, *y=wb, *t, cal = 1;\n for (i=1; i<=n; i++) sum[x[i] = r[i]]++;\n for (i=1; i<=m; i++) sum[i] += sum[i-1];\n for (i=n; i>=1; i--) sa[sum[x[i]]--] = i;\n for (i=1; i<=n; i++) Jum[i] = up[i][0];\n for (j=1, p=1; j<=2*n; j*=2, m=p){\n for (p=0, i=1; i<=n; i++) if (lev[i]<=j) y[++p] = i;\n for (i=0; i<=m; i++) sum[i] = 0;\n for (i=1; i<=n; i++) if (lev[i] > j) sum[x[Jum[i]]]++;\n for (i=1; i<=m; i++) sum[i] += sum[i-1];\n for (i=n; i>=1; i--)\n if (lev[i] > j){\n y[p+sum[x[Jum[i]]]] = i;\n sum[x[Jum[i]]]--;\n }\n p = n;\n for (i=0; i<=m; i++) sum[i] = 0;\n for (i=1; i<=n; i++) sum[x[y[i]]]++;\n for (i=1; i<=m; i++) sum[i] += sum[i-1];\n for (i=n; i>=1; i--) sa[sum[x[y[i]]]--] = y[i];\n for (t = x, x = y, y = t, p = 1, x[sa[1]] = 1, i = 2; i <= n; i++)\n x[sa[i]] = cmp(y, sa[i-1], sa[i])?p:++p;\n for (i=1; i<=n; i++) y[i] = Jum[Jum[i]];\n for (i=1; i<=n; i++) Jum[i] = y[i];\n }\n}\n\nint lowbit(int a){return a & (-a);}\n\nint Jump(int now, int stp){\n for (int i=stp; i>0; i-=lowbit(i)){\n now = up[now][lg[lowbit(i)]];\n }\n return r[now];\n}\n\nvoid inserttree(int now, int val, int t){\n for (int i=now; i<=n2; i+=lowbit(i)) tree[t][i] += val;\n}\n\nint asktree(int now, int t){\n int ret = 0;\n for (int i=now; i>0; i-=lowbit(i)) ret += tree[t][i];\n return ret;\n}\n\nint findpred(int lef, int rig, int p, int val){\n lef--;rig++;\n while (lef +1 < rig){\n int mid = (lef+rig)/2;\n if (Jump(sa[mid], p) >= val) rig = mid; else lef = mid;\n }\n return rig;\n}\n\nint findsucc(int lef, int rig, int p, int val){\n lef--;rig++;\n while (lef+1 < rig){\n int mid = (lef+rig)/2;\n if (Jump(sa[mid], p) <= val) lef = mid; else rig = mid;\n }\n return lef;\n}\n\nvoid Match(){\n int tot = 1;\n sta[1] = 1;\n reg[1].L = 1;\n reg[1].R = n2;\n Last[1] = 1;\n\n while (tot > 0){\n int now = sta[tot];\n while (Last[now] < 27 && node[now].son[Last[now]] == NULL) Last[now]++;\n if (Last[now] >= 27) {tot--; continue;}\n tot++;\n sta[tot] = node[now].son[Last[now]] - node;\n int nex = sta[tot];\n Last[nex] = 1;\n if (reg[now].L > reg[now].R) {\n reg[nex] = reg[now];\n }else{\n reg[nex].L = findpred(reg[now].L, reg[now].R, tot-2, Last[now]);\n reg[nex].R = findsucc(reg[now].L, reg[now].R, tot-2, Last[now]);\n }\n Last[now]++;\n }\n}\n\nvoid Solve(){\n lg[1] = 0;\n for (int i=1; (1<\n#include \nusing namespace std;\nconst long long M=998244353;\nlong long dp[5001][5001][2];\nlong long factorial(int l,int r){\n long long ans=1;\n for (int i=l;i<=r;++i) ans=(ans*i)%M;\n return ans;\n}\nlong long mi(long long x,long long y){\n long long base=x;\n long long ans=1;\n while (y!=0){\n if (y&1) ans=(ans*base)%M;\n base=(base*base)%M;\n y>>=1;\n }\n return ans; \n}\nint main()\n{\n int n,k,l;\n scanf(\"%d%d%d\",&n,&k,&l);\n l%=M;\n dp[0][0][0]=1;\n for (int i=1;i<=2*n+1;++i){\n for (int j=0;j<=i;++j){\n for (int m=0;m<=1;++m){\n if (j-1>=0) dp[i][j][m]=(dp[i][j][m]+dp[i-1][j-1][m])%M;\n dp[i][j][m]=(dp[i][j][m]+dp[i-1][j+1][m]*(j+1)%M)%M;\n }\n if (j>=k) dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][0])%M;\n }\n }\n //q^(M-2)*p*l\n long long ans=mi(factorial(n+1,2*n+1),M-2)*dp[2*n+1][0][1]%M*mi(2,n)%M*l%M;\n printf(\"%lld\",ans);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "97716b3089d2d2c3a01fe950a2d07220", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0} {"lang": "GNU C++0x", "source_code": "# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n\nusing namespace std;\n\nlong long getMin(const long long& s, const long long& e)\n{\n if (e/10 < s)\n {\n double l = log10(e);\n return floor(l+1e-5) == ceil(l) ? e:s;\n \n }\n else\n {\n long long res = 1;\n while(res <= e)\n {\n res *= 10;\n }\n \n return res /= 10;\n }\n}\n\nlong long getStart(long long t)\n{\n long long res = 1;\n while(t)\n {\n res *= 10;\n t /= 10;\n }\n \n return res-1;\n}\n\nunsigned long long run(const long long& s, const long long& e)\n{\n unsigned long long res = 0;\n long long head = getStart(s);\n map used;\n for(long long i=s; i<=e; ++i)\n {\n if (used[i]) continue;\n\n used[i] = used[start-i] = true;\n res = max(res, (unsigned long long)i*(head-i));\n }\n \n return res;\n}\n\nint main()\n{\n // freopen(\"input.txt\", \"r\", stdin);\n long long a,b;\n cin >> a >> b;\n //cout << run(a,maxA) << \" \" << run(minB, b) << endl;\n cout << run(getMin(a,b), b);\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "07a0cde5004c6511f72973176d39ff16", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\nusing std::min;\nusing std::lower_bound;\nusing std::sort;\nusing std::unique;\nusing std::vector;\ninline int abs(int x)\n{\n\treturn x<0?-x:x;\n}\nconst int mod=998244353;\ninline int add(int a,int b)\n{\n\treturn (a+=b)>=mod?a-mod:a;\n}\ninline int sub(int a,int b)\n{\n\treturn (a-=b)<0?a+mod:a;\n}\ninline int mul(int a,int b)\n{\n\treturn (long long)a*b%mod;\n}\ninline int qpow(int a,int b)\n{\n\tint res=1;\n\tfor(;b;a=mul(a,a),b>>=1)\n\t\tif(b&1)\n\t\t\tres=mul(res,a);\n\treturn res;\n}\nconst int N=105;\nint n,t,ans;\nstruct cell\n{\n\tint x,y;\n}c[N];\nvector V,Vx,Vy;\nint sw,w[N],sumw[N];\nstruct task\n{\n\tint t,l,r,k;\n};\nvector ta;\nint f[N];\nnamespace lglr\n{\n\tint n;\n\tint x[N],y[N];\n\t// inline void print()\n\t// {\n\t// \tregister int i;\n\t// \tfor(i=1;i<=n;i++)\n\t// \t\tfprintf(stderr,\"x:%d y:%d\\n\",x[i],y[i]);\n\t// \treturn;\n\t// }\n\tinline int get(int x0)\n\t{\n\t\tint res=0,cur;\n\t\tregister int i,j;\n\t\tfor(i=1;i<=n;i++)\n\t\t{\n\t\t\tcur=1;\n\t\t\tfor(j=1;j<=n;j++)\n\t\t\t\tif(i!=j)\n\t\t\t\t\tcur=mul(cur,mul(sub(x0,x[j]),qpow(sub(x[i],x[j]),mod-2)));\n\t\t\tres=add(res,mul(cur,y[i]));\n\t\t}\n\t\treturn res;\n\t}\n}\nnamespace zkw\n{\n\tint M;\n\tint Min[N<<2],lazy[N<<2],cnt[N<<2];\n\tinline void push_up(int x)\n\t{\n\t\tMin[x]=min(Min[x<<1],Min[x<<1|1])+lazy[x];\n\t\tcnt[x]=(Min[x<<1]+lazy[x]==Min[x])*cnt[x<<1]+(Min[x<<1|1]+lazy[x]==Min[x])*cnt[x<<1|1];\n\t\treturn;\n\t}\n\tinline void build(int n)\n\t{\n\t\tregister int i;\n\t\tfor(M=1;M<=n;M<<=1);\n\t\tmemset(lazy,0,sizeof(int)*(M<<1));\n\t\tmemset(cnt,0,sizeof(int)*(M<<1));\n\t\tfor(i=1;i<=n;i++)\n\t\t\tMin[M+i]=0,cnt[M+i]=w[i];\n\t\tfor(i=M-1;i;i--)\n\t\t\tpush_up(i);\n\t\treturn;\n\t}\n\tinline void modify(int l,int r,int k)\n\t{\n\t\tfor(l=M+l-1,r=M+r+1;l^r^1;l>>=1,r>>=1,push_up(l),push_up(r))\n\t\t\t(l&1)?0:(Min[l^1]+=k,lazy[l^1]+=k),(r&1)?(Min[r^1]+=k,lazy[r^1]+=k):0;\n\t\tfor(l>>=1;l;l>>=1)\n\t\t\tpush_up(l);\n\t\treturn;\n\t}\n\tinline int query()\n\t{\n\t\treturn sw-(Min[1]==0)*cnt[1];\n\t}\n}\ninline int calc(int t)\n{\n\tint cl,cr,res=0;\n\tregister int i;\n\tVx.clear();Vy.clear();\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tVx.push_back(c[i].x-t);\n\t\tVx.push_back(c[i].x+t+1);\n\t\tVy.push_back(c[i].y-t);\n\t\tVy.push_back(c[i].y+t+1);\n\t}\n\tsort(Vx.begin(),Vx.end());\n\tVx.erase(unique(Vx.begin(),Vx.end()),Vx.end());\n\tsort(Vy.begin(),Vy.end());\n\tVy.erase(unique(Vy.begin(),Vy.end()),Vy.end());\n\tsw=0;\n\tfor(i=1;i<(int)Vy.size();i++)\n\t\tw[i]=Vy[i]-Vy[i-1],sw+=w[i];\n\tta.clear();\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tcl=lower_bound(Vy.begin(),Vy.end(),c[i].y-t)-Vy.begin()+1;\n\t\tcr=lower_bound(Vy.begin(),Vy.end(),c[i].y+t+1)-Vy.begin();\n\t\tta.push_back(task{c[i].x-t,cl,cr,1});\n\t\tta.push_back(task{c[i].x+t+1,cl,cr,-1});\n\t}\n\tsort(ta.begin(),ta.end(),[](task a,task b)->bool\n\t{\n\t\treturn a.t\n\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n\tint n;\n cin >> n;\n\tcout << n * (n - 1) / 2 * 4 + 1 << '\\n';\n return 0;\n}\n/\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ad343fdebe3a4df0af761e8222e5c8a8", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "/* .................................................................................................................................. */\n\n/** Header **/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n/** Repeat **/\n\n#define REP(I, N) for (int I=0;I=int(A);--I)\n#define REP_1(I, N) for (int I=1;I<=int(N);++I)\n#define FOR_1(I, A, B) for (int I=int(A);I<=int(B);++I)\n#define DWN_1(I, B, A) for (int I=int(B);I>=int(A);--I)\n#define REP_C(I, N) for (int N____=int(N),I=0;I=A____;--I)\n#define REP_1_C(I, N) for (int N____=int(N),I=1;I<=N____;++I)\n#define FOR_1_C(I, A, B) for (int B____=int(B),I=A;I<=B____;++I)\n#define DWN_1_C(I, B, A) for (int A____=int(A),I=B;I>=A____;--I)\n#define DO(N) while(N--)\n#define DO_C(N) int N____ = N; while(N____--)\n#define TO(i, a, b) int s_=a VI;\ntypedef vector VS;\ntypedef vector VL;\ntypedef vector VD;\ntypedef set SI;\ntypedef set SS;\ntypedef set SL;\ntypedef set SD;\ntypedef map MI;\ntypedef map MS;\ntypedef map ML;\ntypedef map MD;\ntypedef pair PII;\ntypedef pair PIB;\ntypedef vector VII;\ntypedef set SII;\ntypedef map MII;\ntypedef vector VVI;\ntypedef vector VVII;\n\n\n/** I/O Accelerator **/\n\n/* ... :\" We are I/O Accelerator ... Use us at your own risk ;) ... \" .. */\n\ntemplate inline void RD(T &x){\n //cin >> x;\n //scanf(\"%d\", &x);\n char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n\n}\n\ntemplate inline void OT(const T &x){\n cout << x << endl;\n //printf(\"%d\", x);\n //printf(\"%.2lf\", x);\n //printf(\"Case %d: %d\", ____T, ans)\n}\n\ntemplate inline T& _RD(T &x){ RD(x); return x;}\ninline int RD(){ int x; RD(x); return x;}\ninline LL RD_LL(){ int x; RD(x); return x;}\ninline DB RD_DB(){ DB x; RD(x); return x;}\n\ntemplate inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}\n\ntemplate inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}\n\ntemplate inline void RST(T &A){memset(A, 0, sizeof(A));}\ntemplate inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}\n\ntemplate inline void CLR(T &A){A.clear();}\ntemplate inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}\ntemplate inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}\n//template inline void CLR_(T &A){REP}\n\ntemplate inline void FLC(T &A, int x){memset(A, x, sizeof(A));}\ntemplate inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}\n\n\n\n\n/** Add - On **/\n\ntemplate inline void checkMin(T &a, T b){if (b inline void checkMax(T &a, T b){if (b>a) a=b;}\ntemplate inline T sqr(T x){return x * x;}\ntemplate inline T min(T a, T b, T c){return min(min(a, b), c);}\ntemplate inline T max(T a, T b, T c){return max(max(a, b), c);}\n\n/* .................................................................................................................................. */\n\nconst int MOD = 1000000007;\nconst int INF = 0x7fffffff;\nconst DB EPS = 1e-6;\nconst DB OO = 1e15;\n\nconst int N = 20000 + 5;\n\nbool A[3], B[3], _B[3], B_[3];\nint x[3], m[3], l[3], u[3];\nint res;\n\n\nvoid dfs(){\n\n int _i, i_;\n\n/*\n if (x[0] == 10 && x[1] == 9){\n cout << _B[0] << \" \" << _B[1] << endl;\n }*/\n\n\n REP(i, 3) if (!_B[i]){\n\n if (i == 0) _i = 1, i_ = 2; else if (i == 1) _i = 0, i_ = 2; else _i = 0, i_ = 1;\n\n if (B[i] && !B_[i]){ // \ufffd\ufffd\ufffd\ufffd\n\n if (u[i] == i_) swap(_i, i_);\n\n B_[i] = true, _B[_i] = false;\n\n if (B[_i] && !B_[_i]){\n\n checkMax(res, x[i] + l[i] + l[_i] + (A[i_] ? 0 : m[i_]));\n\n }\n\n else {\n\n int x_i = x[_i];\n\n FOR_1(j, -l[i], l[i]) if (j != 0){\n\n int xx = x[i] + j;\n\n if (x[i_] != xx && (abs(x[i_] - xx) == 1 || j == 1 || j == l[i])) {\n\n checkMax(res, xx);\n\n x[_i] = xx,\n\n dfs();\n\n x[_i] = x_i;\n\n }\n\n }\n }\n\n _B[_i] = true, B_[i] = false;\n\n }\n else { // \ufffd\ufffd\ufffd\ufffd ...\n\n if (!B[i]){\n\n#define Grab(i_, d) if (!_B[i_] && x[i_] == x[i] + d) {x[i_] = x[i], B[i] = _B[i_] = true, u[i] = i_, dfs(), x[i_] = x[i] + d; B[i] = _B[i_] = false;}\n\n Grab(_i, -1); Grab(_i, 1); Grab(i_, -1); Grab(i_, 1);\n }\n\n if (!A[i]){ // \ufffd\ufffd\u00b7 ..\n A[i] = true; int xi = x[i];\n FOR_1(j, -m[i], m[i]) if (j != 0){\n int xx = xi + j;\n if (x[_i] != xx && x[i_] != xx)\n //(abs(x[_i] - xx) == 1 || abs(x[i_] - xx) == 1 || j == m[i] || j == -m[i])){\n checkMax(res, xx); x[i] = xx, dfs(), x[i] = xi;\n }\n }\n A[i] = false;\n }\n }\n }\n}\n\n\nint main(){\n\n // freopen(\"in.txt\", \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n //ios::sync_with_stdio(false);\n\n\n REP(i, 3) RD(x[i], m[i], l[i]); res = max(x[0], x[1], x[2]);\n\n //x[0] = 10, x[1] = 9; x[2] = -18;\n //x[0] = 8, x[1] = 9, x[2] = -18;A[0] = true;\n\n dfs(); OT(res);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a3a503817d64f59965cbfdc5b795586a", "src_uid": "a14739b86d1fd62a030226263cdc1afc", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\nint getint(){\n\tint x=0,f=1;\n\tchar ch=getchar();\n\twhile(ch<'0'||'9'\n\nusing namespace std;\n\nint n,m,k;\n\nstruct Prod{\n int buy,sell,quant;\n\n bool operator<(const Prod& p) const{\n return buy > p.buy;\n }\n}products[2000];\n\nProd p[2000];\n\n\nint main(){\n\n cin >> n >> m >> k;\n\n int aux = 0;\n for(int i = 0; i < n; i++){\n string bla;\n cin >> bla;\n for(int j = 0; j < m; j++){\n int a,b,c;\n cin >> a >> b >> c;\n products[i*m + j].buy = a;\n products[i*m + j].sell = b;\n products[i*m + j].quant = c;\n } \n }\n\n int sum = 0;\n \n for(int i = 0; i < n; i++){\n for(int j = 0; j < m; j++){\n if(i==j)continue;\n\n for(int x = 0; x < m; x++){\n\tp[x].buy = products[i*m + x].sell - products[j*m + x].buy;\n\tp[x].quant = products[j*m+x].quant;\n }\n\n sort(p,p+m);\n\n int capacity = k;\n int resp = 0;\n\n for(int x = 0; x < m; x++){\n\tif(p[x].buy < 0) break;\n\tint qt = min(capacity,p[x].quant);\n\tcapacity -= qt;\n\tresp += qt*p[x].buy;\n }\n }\n sum = max(sum,resp);\n }\n\n cout << sum << endl;\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4560926606fc123ec05e7a69d11985ad", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\nconst int N=500005,mn=1e9;\nusing namespace std;\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\ntemplate using tr=tree,rb_tree_tag,tree_order_statistics_node_update>;\nint x,y,h[N],v[N],nxt[N],ec,p[N],sz[N],bb[N],tp[N],f[N],c[N],id[N],ct,po[N],n,k,d[N];\nstruct no{\n\tint x,y;\n};\nint operator <(no x,no y){\n\treturn x.xt[N];\nno a[N];\ndecltype(begin(t[0]))d[N];\nvoid add(int x,int y){v[++ec]=y;nxt[ec]=h[x];h[x]=ec;}\nno operator +(no x,no y){\n\treturn (no){min(x.y,max(x.x,y.x)),min(x.y,max(x.x,y.y))};\n}\nint rk(trx,int v){\n\treturn x.order_of_key((no){v,mn});\n}\nint ck(int x,int v,int g){\n\tint a=rk(t[x],v)+g,b=((int)t[x].size())+1-a;\n\treturn b-amd)return qu(o*2,l,md,x,y)+qu(o*2+1,md+1,r,x,y);\n\tif (x<=md)return qu(o*2,l,md,x,y);\n\treturn qu(o*2+1,md+1,r,x,y);\n}\nvoid mod(int o,int l,int r,int x){\n\tif (l==r){\n\t\tint y=bb[l];\n\t\tif (d[y]==1&&y!=1){\n\t\t\tif (c[y])a[o]=(no){mn,mn};\n\t\t\telse a[o]=(no){-mn,-mn};\n\t\t}\n\t\telse{\n\t\t\tcg(y,a[o].x,1);\n\t\t\tcg(y,a[o].y,0);\n\t\t}\n\t\treturn;\n\t}\n\tint md=(l+r)/2;\n\tif (x<=md)mod(o*2,l,md,x);\n\telse mod(o*2+1,md+1,r,x);\n\ta[o]=a[o*2]+a[o*2+1];\n}\nvoid d1(int x,int fa){\n\tsz[x]=1;\n\tfor (int i=h[x];i;i=nxt[i])\n\t\tif (v[i]!=fa){\n\t\t\td1(v[i],x);\n\t\t\tsz[x]+=sz[v[i]];\n\t\t\tif (sz[p[x]]=qu(1,1,n,id[x],po[x]).x)puts(\"0\");\n\t\t\telse puts(\"1\");\n\t\t}\n\t\telse if (opt==2){\n\t\t\tint x,cl;\n\t\t\tx=rd();\n\t\t\tcl=rd();\n\t\t\tc[x]=cl;\n\t\t\twhile(1){\n\t\t\t\tmod(1,1,n,id[x]);\n\t\t\t\tx=tp[x];\n\t\t\t\tif (x==1)break;\n\t\t\t\tt[f[x]].erase(d[x]);\n\t\t\t\td[x]=t[f[x]].insert((no){qu(1,1,n,id[x],po[x]).x,x}).first;\n\t\t\t\tx=f[x];\n\t\t\t}\n\t\t}\n\t\telse scanf(\"%d\",&k);\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "87d4c7ea6993756b8dc5406bcb003741", "src_uid": "a2869b349dc2d47d96b572397978e77d", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "using namespace std;\n#define Int register int\n#define MAXN 6005\nint n,len,belong[MAXN];\nvoid read (int &x)\n{\n x = 0;char c = getchar();\n while (c < '0' || c > '9');\n while (c >= '0' && c <= '9')x = (x << 3) + (x << 1) + c - '0',c = getchar();\n return ;\n}\nvoid write (int x)\n{\n if (x < 0){x = -x;putchar ('-');}\n if (x > 9) write (x / 10);\n putchar (x % 10 + '0');\n}\nbool zs (int n)\n{\n if (n == 1 || n == 0) return 0;\n for (Int i = 2;i * i <= n;++ i)\n if (n % i == 0) return 0;\n return 1;\n}\nvoid Work (int tot,bool flag)\n{\n if (flag) tot -= 3,belong[3] = 3;\n int ans1 = 0;\n for (Int i = 2;i <= n;++ i)\n if (zs (i) && zs (tot - i))\n {\n belong[i] = 1;\n break;\n }\n for (Int i = 1;i <= n;++ i)\n if (belong[i]) write (belong[i]),putchar (' ');\n else write (2),putchar (' ');\n putchar ('\\n');\n exit (0);\n}\nsigned main()\n{\n read(n);\n if (n < 5)\n {\n else if (n == 2) \n printf (\"1 1\\n\");\n else if (n == 3) \n printf (\"1 1 2\\n\");\n else if (n == 4) \n printf (\"1 1 2 2\\n\");\n return 0; \n }\n int tot =n*(n + 1)>>1;\n if (zs(tot-2))\n {\n for (Int i = 1;i <= n;++ i)\n if (i == 2) write (2),putchar (' ');\n else write (1),putchar (' ');\n putchar('\\n');\n return 0;\n }\n return Work (tot,tot%2),0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f0dcacbe747e088a5be9f06b1c80ae39", "src_uid": "94ef0d901f21e1945849fd5bfc2d1449", "difficulty": 2200.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\n\r\n#ifdef DEBUG\r\n #include \r\n#else\r\n #define dbg( ... )\r\n#endif\r\n\r\nusing namespace std;\r\n\r\n#if __cplusplus >= 202002L\r\n namespace rg = ranges;\r\n namespace rv = ranges::views;\r\n auto rep( auto x, auto y ) { return rg::iota_view( x, y ); }\r\n#endif\r\n\r\ntemplate< const int &MOD >\r\nstruct ModInt {\r\npublic:\r\n int val {};\r\n\r\npublic:\r\n ModInt( int64_t v = 0 ) {\r\n if( v < 0 ) \r\n v = v % MOD + MOD;\r\n\r\n if( v >= MOD )\r\n v %= MOD;\r\n\r\n val = static_cast< int >( v );\r\n }\r\n\r\n ModInt( uint64_t v ) {\r\n if( v >= 0 )\r\n v %= MOD;\r\n\r\n val = static_cast< int >( v );\r\n }\r\n\r\n ModInt( int v ) : ModInt( static_cast< int64_t >( v ) ) {}\r\n ModInt( unsigned v ) : ModInt( static_cast< uint64_t >( v ) ) {}\r\n\r\npublic:\r\n explicit operator int() const { return val; }\r\n explicit operator unsigned() const { return val; }\r\n explicit operator int64_t() const { return val; }\r\n explicit operator uint64_t() const { return val; }\r\n explicit operator double() const { return val; }\r\n explicit operator long double() const { return val; }\r\n\r\n ModInt& operator+=( const ModInt &oth ) {\r\n val -= MOD - oth.val;\r\n if( val < 0 ) \r\n val += MOD;\r\n\r\n return *this;\r\n }\r\n\r\n ModInt& operator-=( const ModInt &oth ) {\r\n val -= oth.val;\r\n if( val < 0 ) \r\n val += MOD;\r\n\r\n return *this;\r\n }\r\n\r\n static unsigned fast_mod( uint64_t x, unsigned m = MOD ) {\r\n#if !defined( _WIN32 ) || defined( _WIN64 ) \r\n return static_cast< unsigned >( x % m );\r\n#endif\r\n\r\n unsigned xHigh { static_cast< unsigned >( x >> 32 ) };\r\n unsigned xLow { static_cast< unsigned >( x ) };\r\n unsigned quot, rem;\r\n\r\n asm( \"divl %4\\n\" : \"=a\" ( quot ), \"=d\" ( rem ) : \"d\" ( xHigh ), \"a\" ( xLow ), \"r\" ( m ) );\r\n return rem;\r\n }\r\n\r\n ModInt& operator*=( const ModInt &oth ) {\r\n val = fast_mod( static_cast< unsigned >( val ) * oth.val );\r\n return *this;\r\n }\r\n\r\n ModInt& operator/=( const ModInt &oth ) { \r\n return *this *= oth.inv(); \r\n }\r\n\r\n friend ModInt operator+( const ModInt &a, const ModInt &b ) { \r\n return static_cast< ModInt >( a ) += b;\r\n }\r\n\r\n friend ModInt operator-( const ModInt &a, const ModInt &b ) { \r\n return static_cast< ModInt >( a ) -= b;\r\n }\r\n\r\n friend ModInt operator*( const ModInt &a, const ModInt &b ) { \r\n return static_cast< ModInt >( a ) *= b;\r\n }\r\n\r\n friend ModInt operator/( const ModInt &a, const ModInt &b ) { \r\n return static_cast< ModInt >( a ) /= b;\r\n }\r\n\r\n ModInt& operator++() {\r\n val = ( val == MOD - 1 ? 0 : val + 1 );\r\n return *this;\r\n }\r\n\r\n ModInt& operator--() {\r\n val = ( val == 0 ? MOD - 1 : val - 1 );\r\n return *this;\r\n }\r\n\r\n ModInt operator++( int ) { \r\n ModInt before { *this }; \r\n ++*this; \r\n return before; \r\n }\r\n\r\n ModInt operator--( int ) { \r\n ModInt before { *this }; \r\n --*this; \r\n return before; \r\n }\r\n\r\n ModInt operator-() const {\r\n return val == 0 ? 0 : MOD - val;\r\n }\r\n\r\n friend bool operator==( const ModInt &a, const ModInt &b ) { return a.val == b.val; }\r\n friend bool operator!=( const ModInt &a, const ModInt &b ) { return a.val != b.val; }\r\n friend bool operator<( const ModInt &a, const ModInt &b ) { return a.val < b.val; }\r\n friend bool operator>( const ModInt &a, const ModInt &b ) { return a.val > b.val; }\r\n friend bool operator<=( const ModInt &a, const ModInt &b ) { return a.val <= b.val; }\r\n friend bool operator>=( const ModInt &a, const ModInt &b ) { return a.val >= b.val; }\r\n\r\npublic:\r\n static const int SAVE_INV { static_cast< int >( 1e6 ) + 5 };\r\n static ModInt saveInv[SAVE_INV];\r\n\r\n static void prepare_inv() {\r\n for( int64_t p { 2 }; p * p <= MOD; p += ( p & 1 ) + 1 ) \r\n assert( !( MOD % p ) );\r\n\r\n saveInv[0] = 0;\r\n saveInv[1] = 1;\r\n\r\n for( int i { 2 }; i < SAVE_INV; ++i ) \r\n saveInv[i] = saveInv[MOD % i] * ( MOD - MOD / i );\r\n }\r\n\r\n ModInt inv() const {\r\n if( !saveInv[1] )\r\n prepare_inv();\r\n\r\n if( val < SAVE_INV )\r\n return saveInv[val];\r\n\r\n ModInt prod { 1 };\r\n int v { val };\r\n\r\n do {\r\n prod *= ( MOD - MOD / v );\r\n v = MOD % v;\r\n } while( v >= SAVE_INV );\r\n\r\n return prod * saveInv[v];\r\n }\r\n\r\n ModInt pow( int64_t p ) const {\r\n if( p < 0 ) \r\n return inv().pow( -p );\r\n\r\n ModInt a { *this }, res { 1 };\r\n\r\n while( p ) {\r\n if( p & 1 )\r\n res *= a;\r\n\r\n p >>= 1;\r\n if( p )\r\n a *= a;\r\n }\r\n\r\n return res;\r\n }\r\n\r\n friend ostream& operator<<( ostream &os, const ModInt &mod ) {\r\n return os << mod.val;\r\n }\r\n};\r\n\r\ntemplate< const int &MOD > ModInt< MOD > ModInt< MOD >::saveInv[ModInt< MOD >::SAVE_INV];\r\n\r\nint MOD { static_cast< int >( 1e9 ) + 7 };\r\nusing mod_int = ModInt< MOD >;\r\n\r\ninline void run_case() {\r\n int N;\r\n cin >> N >> MOD;\r\n\r\n vector< mod_int > dp( N + 1 );\r\n dp[1] = 1;\r\n int pref { 1 };\r\n\r\n for( int i : rep( 2, N + 1 ) ) {\r\n dp[i] = sum;\r\n\r\n for( int j { 1 }; j * j <= i; ++j ) {\r\n dp[i] += ( dp[j] * mod_int( i / j - i / ( j + 1 ) ) );\r\n\r\n if( i / j != j && j > 1 ) \r\n dp[i] += dp[i / j];\r\n }\r\n\r\n sum += dp[i];\r\n }\r\n\r\n cout << dp[N] << endl;\r\n}\r\n\r\nint32_t main() {\r\n ios::sync_with_stdio( false );\r\n cin.tie( nullptr );\r\n\r\n int T { 1 };\r\n //cin >> T;\r\n\r\n for( int test { 1 }; test <= T; ++test ) {\r\n //cout << \"Case #\" << \": \";\r\n run_case();\r\n }\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cf1c8a9246a87f475f901a8ae723bd18", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tint n, k;\n\tcin >> n >> k;\n\tfor (llong i = 0; i <= 100000000; i++) {\n\t\tif ((i / k) * (i % k) == n) {\n\t\t\tcout << i;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn(0);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3560ea2810564f67cc64d75844889f49", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nvector next[64];\nvector cost[64];\nvector candies;\nbool visited[64];\nint n, k;\n\nbool solve(int time, int currNode, int toEat) {\n // cout << time << \" \" << currNode << \" \" << toEat << endl; ///////////\n if (time < 0) {\n return false;\n }\n\n toEat -= candies[currNode];\n if (toEat <= 0) {\n return true;\n }\n\n visited[currNode] = true;\n bool res = false;\n for (int i = 0; i < next[currNode].size() && !res; ++i) {\n int nextNode = next[currNode][i];\n if (visited[nextNode]) {\n continue;\n }\n res = solve(time - cost[currNode][i], nextNode, toEat);\n }\n visited[currNode] = false;\n return res;\n}\n\n\nint main() {\n int s, sum = 0;\n cin >> n >> s >> k;\n s--;\n candies.resize(n + 1);\n for (int i = 0; i < n; ++i) {\n cin >> candies[i];\n sum += candies[i];\n }\n\n candies[n] = 0;\n string colors;\n cin >> colors;\n if (sum < k) {\n cout << -1 << endl;\n return 0;\n }\n\n for (int i = 0; i < n; ++i) {\n for (int j = 0; j < n; ++j) {\n if (i == j) {\n continue;\n }\n\n if (colors[i] == colors[j]) {\n continue;\n }\n\n if (candies[i] <= candies[j]) {\n continue;\n }\n\n next[i].push_back(j);\n cost[i].push_back(abs(i - j));\n }\n }\n\n for (int i = 0; i < n; ++i) {\n next[n].push_back(i);\n cost[n].push_back(abs(i - s));\n }\n\n int l = 0, r = n * n;\n while (r - l > 1) {\n int mid = (l + r) / 2;\n if (solve(mid, n, k)) {\n r = mid;\n } else {\n l = mid;\n }\n }\n if (!solve(r, n, k)) {\n cout << -1 << endl;\n } else {\n cout << r << endl;\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fa0d4210ecfed7f29db0d25aff10b776", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#define p_b push_back\n#define m_p make_pair\n#define fi first\n#define se second\n#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)\n#define ll long long\n\nusing namespace std;\n\n\n\n ll st,f1,f2,ii,res,k,ans,res1,res2,xx,yy;\n ll a[501][501][501],b[10000],c[501][501][501],d[10000],n,m,i,j;\n vector v1,v2;\n string s;\nint main()\n{\n\n // freopen(\"input.txt\",\"r\",stdin);\n // freopen(\"output.txt\",\"w\",stdout);\n // fast_io;\n cin>>n>>m;\n m--;\n for(ii=1;ii<=min(m,n);ii++)\n {\n\n a[ii][1][1]=1;\n for(j=1;j1;i--)b[i]-=b[i-1];\n\n\n\n for(ii=1;ii<=min(m,n);ii++)\n {\n\n c[ii][1][1]=1;\n for(j=1;j\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\ntypedef int64_t LL;\r\ntypedef uint64_t uLL;\r\ntypedef __int128_t sLL;\r\n#define fir first\r\n#define sec second\r\n#define eb emplace_back\r\n#define em emplace\r\n#define pb pop_back\r\n#define pii std::pair\r\n#define mkp(a, b) std::make_pair(a, b)\r\n#define bitcount(x) __builtin_popcount(x)\r\n#define bitcountll(x) __builtin_popcountll(x)\r\n#define bitparity(x) __builtin_parity(x)\r\n#define bitparityll(x) __builtin_parityll(x)\r\n\r\nint read() {\r\n int s = 0, w = 1;\r\n char ch = getchar();\r\n while (ch < '0' || ch > '9') {\r\n if (ch == '-')\r\n w = -1;\r\n ch = getchar();\r\n }\r\n while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();\r\n return s * w;\r\n}\r\n\r\nLL readl() {\r\n LL s = 0, w = 1;\r\n char ch = getchar();\r\n while (ch < '0' || ch > '9') {\r\n if (ch == '-')\r\n w = -1;\r\n ch = getchar();\r\n }\r\n while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();\r\n return s * w;\r\n}\r\n\r\n///////////////////////////////////// wanna become a grandmaster\r\n\r\n// #include \r\n// #include \r\n// #include \r\n// using namespace __gnu_pbds;\r\n// using rbtree = tree, rb_tree_tag, tree_order_statistics_node_update> ;\r\n// order_of_key() rank (return int) start from 0\r\n// find_by_order() kth (return iterator) start from 0\r\n\r\n/*\r\n \u8bfb\u5165\u662f\u5426\u9700\u8981\u5f00LL\uff1f\r\n*/\r\n\r\nconst int maxn = 5e4 + 10;\r\nconst int MOD = 998244353;\r\n\r\nint n, m;\r\nint a[maxn][maxn];\r\nint nxt[1030][10];\r\n\r\nvoid add(int &v1, int v2) {\r\n v1 += v2;\r\n if (v1 > MOD) v1 -= MOD;\r\n}\r\n\r\nint main() {\r\n n = read();\r\n m = read();\r\n for (int i = 1 ; i <= m ; i++ ) {\r\n int u = read(), v = read();\r\n a[u][v] = a[v][u] = 1;\r\n }\r\n for (int s = 0 ; s < (1 << 10) ; s++ ) {\r\n for (int i = 0 ; i < 10 ; i++ ) {\r\n if (s & (1 << i)) {\r\n nxt[s][i] = (1 << i);\r\n for (int j = 0 ; j < i ; j++ ) {\r\n if (!a[i][j]) {\r\n nxt[s][i] |= (1 << j);\r\n } else {\r\n if (s & (1 << j)) nxt[s][i] |= (1 << j);\r\n }\r\n }\r\n for (int j = i + 1 ; j < 10 ; j++ ) {\r\n if (!a[i][j]) {\r\n nxt[s][i] |= (1 << j);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n std::vector dp(1 << 10, 0);\r\n dp[(1 << 10) - 1] = 1;\r\n for (int i = 1 ; i <= n ; i++ ) {\r\n std::vector dp2(1 << 10, 0);\r\n for (int s = 0 ; s < (1 << 10) ; s++ ) {\r\n for (int j = 0 ; j < 10 ; j++ ) {\r\n if (s & (1 << j)) {\r\n add(dp2[nxt[s][j]], dp[s]);\r\n }\r\n }\r\n }\r\n std::swap(dp, dp2);\r\n }\r\n int ans = 0;\r\n for (const auto &val : dp) {\r\n add(ans, val);\r\n }\r\n printf(\"%d\\n\", ans);\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "57b8cf86ff33749b0d9bd7edc320e3e2", "src_uid": "60955fc2caa6ec99c7dcc1da5d36b1f8", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "#include\n#define forinc(i,a,b) for(int i=a;i<=b;++i)\n#define fordec(i,a,b) for(int i=a;i>=b;--i)\nusing namespace std;\nint main()\nint a[10000];\n{\n int n,k;\n cin>>n>>k;\n forinc(i,1,n) cin>>a[i];\n int res=0,l=0;\n forinc(i,1,n) \n {\n if(a[i]<=k) kq++;\n l=i;\n else break;\n }\n fordec(i,n,l+1) \n {\n if(a[i]<=k) kq++;\n else break;\n }\n cout<\n\nusing namespace std;\n\nint main()\n{\n int a, c, ad[20] = {0}, an(0), cd[20] = {0}, cn(0);\n cin >> a >> c;\n\n while (a != 0)\n {\n ad[an++] = a % 3;\n a /= 3;\n }\n\n while (c != 0)\n {\n cd[cn++] = c % 3;\n c /= 3;\n }\n\n int tor(0);\n for (int i = max(an, cn) - 1; i >= 0; --i)\n {\n tor = tor * 3 + (cd[i] + 3 - ad[i]) % 3;\n }\n cout << tor << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "51f8638e16eb88b8eefbb2ecc1e582e2", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef pair PP;\ntypedef pair LPP;\ntypedef long long LL;\n#define INF 1000000000LL\n#define pb push_back\n#define mp make_pair\n#define fr first\n#define sc second\nconst int mod = 1000000007;\n\nint bits[1 << 20], p[1 << 20];\nint n, l, r, x[50], y[50], a[50];\nbool cmp(int & x, int & y){\n\treturn bits[x] < bits[y];\n}\n\ndouble q[1 << 20];\ndouble pi = acos(-1);\n\ndouble f(double b, int k){\n\tif (a[k] == 0) return 0;\n\tif (b - x[k] >= tan((90 - a[k]) * pi / 180) * y[k]) return r;\n\tif (a[k] == 90) return y[k]*y[k]*1.0/(x[k] - b);\n\tdouble t = tan(a[k] * pi / 180);\n\treturn x[k] + y[k] * ((t - (x[k] - b)/y[k])/(1 + t * (x[k] - b)/y[k]));\n}\n\nint main() {\n\t#ifdef _TEST_\n\tfreopen(\"input.txt\", \"r\", stdin);\n\t#endif\n\tcin >> n >> l >> r; r -= l;\n\tint u, v, d;\n\tmemset(bits, 0, sizeof(bits));\n\tfor (int i = 0; i < 1 << n; i ++)\n\t\tbits[i] += bits[i - (i & -i)], p[i] = i;\n\tsort(p, p + n, cmp);\n\n\tfor (int i = 0; i < n; i ++){\n\t\tcin >> u >> v >> d;\n\t\tx[i] = u - l; y[i] = abs(v); a[i] = d;\n\t}\n\tmemset(q, 0, sizeof(q));\n\tfor (int i = 1; i < 1 << n; i ++){\n\t\tint t = p[i];\n\t\tfor (int j = 0; j < n; j ++)\n\t\t\tif ((t >> j) & 1) {\n\t\t\t\tq[t] = max(q[t], min((double)r, q[t - (1 << j)] + f(q[t - (1 << j)], j)));\n\t\t\t}\n\t}\n\n\tcout << setprecision(9) << fixed << q[(1 << n) - 1] << endl;\n\treturn 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "24f4c80d10e304bc3f684fba58aa33b2", "src_uid": "4fad1233e08bef09e5aa7e2dc6167d6a", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "#include \r\n\r\nusing namespace std;\r\n\r\n#pragma GCC optimize(\"unroll-loops\")\r\n#pragma GCC optimize(\"Ofast\")\r\n#pragma GCC optimize(\"-O3\")\r\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native\")\r\n\r\n\r\n#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\r\n#define md(l, r) l + (r - l) / 2\r\n#define ll long long\r\n#define btw(a, l, r) a.begin() + l, a.begin() + r + 1\r\n#define F first\r\n#define S second\r\n#define pb push_back\r\n#define all(x) x.begin(), x.end()\r\n#define sz(x) (int(x.size()))\r\n#define sqr(x) (x) * (x)\r\n#define endl '\\n'\r\n\r\n#define getfiles ifstream cin(\"input.txt\"); ofstream cout(\"output.txt\");\r\n#define clr(x, y) memset((x), (y), sizeof (x))\r\n#define ld long double\r\ntypedef pair pii;\r\ntypedef vector vi;\r\ntypedef vector > vvi;\r\ntypedef vector > > vvpii;\r\ntypedef vector > > vvpll;\r\ntypedef pair > piii;\r\ntypedef vector vll;\r\ntypedef vector > vpii;\r\ntypedef vector > vpll;\r\ntypedef vector > vvll;\r\ntypedef vector > > vplll;\r\ntypedef pair pll;\r\n\r\nconst ld eps = -1e9;\r\nconst long long N = 200001, P = 1e9 + 7, P1 = 1e9 + 13, iINF = 1e9, INF = 2e18, K = 73, K1 = 79;\r\n\r\nll dstF(ll x, ll y, ll xx, ll yy) {\r\n return (sqr(x - xx) + sqr(y - yy));\r\n}\r\n\r\nld dstSqrtF(ll x, ll y, ll xx, ll yy) {\r\n return (sqrt(sqr(x - xx) + sqr(y - yy)));\r\n}\r\n\r\nll _bp(ll val, ll st, ll p) {\r\n if (st == 0) {\r\n return 1;\r\n }\r\n ll temp = _bp(val, st / 2, p);\r\n temp = sqr(temp);\r\n temp %= p;\r\n if (st % 2 == 1) {\r\n temp *= val;\r\n temp %= p;\r\n }\r\n return temp;\r\n}\r\n\r\nll _bp(ll val, ll st) {\r\n if (st == 0) {\r\n return 1;\r\n }\r\n ll temp = _bp(val, st / 2);\r\n temp = sqr(temp);\r\n if (st % 2 == 1) {\r\n temp *= val;\r\n }\r\n return temp;\r\n}\r\n\r\nll nok(ll a, ll b) {\r\n return (a / __gcd(a, b) * b);\r\n}\r\n\r\n#define int long long\r\n\r\nint n, ans = 1e18;\r\nint st[100], dp[100];\r\n\r\nvoid solve() {\r\n cin >> n;\r\n int n1 = n;\r\n int k = 0;\r\n while (n1 != 0) {\r\n k++;\r\n n1 /= 10;\r\n }\r\n int tp = n;\r\n st[0] = 1;\r\n for (int i = 1; i <= k + 1; i++) {\r\n st[i] = st[i - 1] * 10 + 1;\r\n }\r\n k++;\r\n multiset s;\r\n s.insert({0, tp});\r\n d[tp] = 0;\r\n while (!s.empty()) {\r\n int x = s.begin()->S;\r\n int x1 = x, cnt = 0;\r\n while (x1 != 0) {\r\n cnt++;\r\n x1 /= 10;\r\n }\r\n if (abs(x1 - st[cnt + 1]) <= st[cnt + 1]) {\r\n if (dp.find(abs(x1 - st[cnt + 1])) == dp.end() || dp[abs(x1 - st[cnt + 1])] > dp[x] + cnt + 1) {\r\n s.erase({dp[abs(x1 - st[cnt + 1])], abs(x1 - st[cnt + 1])});\r\n dp[abs(x1 - st[cnt + 1])] = dp[x] + cnt + 1;\r\n s.insert({dp[abs(x1 - st[cnt + 1])], abs(x1 - st[cnt + 1])});\r\n }\r\n }\r\n }\r\n}\r\n\r\nsigned main() {\r\n fast_io;\r\n int q;\r\n q = 1;\r\n //cin >> q;\r\n while (q != 0) {\r\n solve();\r\n --q;\r\n }\r\n}\r\n\r\n\r\n\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "699d9205ba752d4082358f3f1a44f986", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\n\n#define TAM\t\t\t\t100//500100\n#define SZ\t\t\t\t2\n#define NBUCKETS\t\t(TAM/SZ+2)\n\nll a[TAM];\nll lazy[NBUCKES];\nunordered_map first[NBUCKETS], last[NBUCKETS];\n\nvoid update ( \n\nint main ( )\n{\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2e31cda9d0a26499b2ca78d64de1cc87", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \nint h,m,k,h1,m1,h2,m2;\nlong long cut(int a,int b){for(;--b>0;a/=10);return a;}\nint ch(int a){for(int ret=0;;a/=10)if(a%10)ret++;else if(!a)return ret;}\nlong long calc(int a,int b){return cut(a,k-ch(m-1))+cut(m-1,k)*a+cut(b,k);}\nint main(){\n scanf(\"%d%d%d%d%d%d%d\",&h,&m,&k,&h1,&m1,&h2,&m2);\n if(h1=k)-calc(h1,m1)+calc(h2,m2));\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7967026ef3e72e232e586d3052664017", "src_uid": "e2782743229645ad3a0f8e815d86dc5f", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#include \nusing namespace __gnu_pbds; \n\n//c++ templte for help.......................................................................................................................................................\n\ntypedef long long ll;\n\ntemplate\nvoid print1(T... t){\n ((cerr<\nvoid print2(T... t){\n vector> ans={t...};\n for(ll i=0;i<(ll)ans.size();i++){\n if(i!=0) cerr<<\"\\t\\t\";\n else cerr<<\"\\t\";\n for(ll j=0;j<(ll)ans[i].size();j++){\n cerr<\nvoid returnvector(T... t){\n vector> ans={t...};\n for(ll i=0;i<(ll)ans.size();i++){\n for(ll j=0;j<(ll)ans[i].size();j++){\n retvec<\nvoid printV(T vec){\n fo(i,vec.size()) cout<\nvoid itR(T map){\n for(auto itr=map.begin();itr!=map.end();itr++){\n deb(itr->first,itr->second);\n }\n cout<,\nrb_tree_tag,\ntree_order_statistics_node_update>\npods;\n \n\n//c++ template for help.....................................................................................................................................................\n\n\n\nstring solve(){\n\t// CALM DOWN : - ) \n\t\n\t\n\t\n\tstring s;\n\tcin>>s;\n\t\n\tll i=0;\n\tll ans=0;\n\twhile(i<=(ll)s.size()-2 and s.find(\"VK\",i)!=string::npos){\n\t\ti=s.find(\"VK\",i)+1;\n\t\ts[i]='0';\n\t\ts[i+1]='0';\n\t\tans++;\n\t}\n\t\n\tif(s.size>=2 and (s.find(\"VV\")!=string::npos or s.find(\"VV\")!=string::npos)){\n\t\tans++;\n\t}\n\t\n\tret(ans);\n\t\n\t\nret(\"\");\n}\n\nint main() {\n cout<>testCase;\n //for(ll tt=0;tt\r\n#define L(i, j, k) for(int i = (j); i <= (k); ++i)\r\n#define R(i, j, k) for(int i = (j); i >= (k); --i)\r\n#define ll long long\r\n#define vi vector \r\n#define sz(a) ((int) (a).size())\r\n#define me(f, x) memset(f, x, sizeof(f))\r\n#define uint unsigned int\r\nusing namespace std;\r\nconst int N = 1 << 20;\r\nint mod;\r\nnamespace yg {\r\n\r\nint fac[123], cnt, omg, omk;\r\nvoid getfac(int x) {\r\n\tfor(int i = 2; i <= sqrt(x); i++) \r\n\t\tif(x % i == 0) {\r\n\t\t\tfac[++cnt] = i;\r\n\t\t\twhile(x % i == 0) x /= i;\r\n\t\t}\r\n}\r\nint qpow(int x, int y, int pmod) {\r\n\tint res = 1;\r\n\tif(x == 0) return 0;\r\n\tfor(; y; x = 1ll * x * x % pmod, y >>= 1) if(y & 1) res = 1ll * res * x % pmod;\r\n\treturn res;\r\n}\r\nbool cheak(int x) {\r\n\tfor(int i = 1; i <= cnt; i++) \r\n\t\tif(qpow(x, (mod - 1) / fac[i], mod) == 1) return 0;\r\n\treturn 1;\r\n}\r\nint find() {\r\n\tgetfac(mod - 1);\r\n\tfor(int i = 2; i < mod; i++) \r\n\t\tif(cheak(i)) {\r\n\t\t\treturn i;\r\n\t\t} \r\n\treturn -1;\r\n}\r\n\r\n}\r\nint _G;\r\n\r\n#define add(a, b) (a + b >= mod ? a + b - mod : a + b)\r\n#define dec(a, b) (a < b ? a - b + mod : a - b)\r\nint qpow(int x, int y = mod - 2) {\r\n\tint res = 1;\r\n\tfor(; y; x = (ll) x * x % mod, y >>= 1) if(y & 1) res = (ll) res * x % mod;\r\n\treturn res;\r\n}\r\nint fac[N], ifac[N], inv[N];\r\nvoid init(int x) {\r\n\tfac[0] = ifac[0] = inv[1] = 1;\r\n\tL(i, 2, x) inv[i] = (ll) inv[mod % i] * (mod - mod / i) % mod;\r\n\tL(i, 1, x) fac[i] = (ll) fac[i - 1] * i % mod, ifac[i] = (ll) ifac[i - 1] * inv[i] % mod;\r\n}\r\nint C(int x, int y) {\r\n\treturn y < 0 || x < y ? 0 : (ll) fac[x] * ifac[y] % mod * ifac[x - y] % mod;\r\n}\r\nint rt[N], Lim;\r\nvoid Pinit(int x) {\r\n\tfor(Lim = 1; Lim <= x; Lim <<= 1) ;\r\n\tfor(int i = 1; i < Lim; i <<= 1) {\r\n\t\tint sG = qpow (_G, (mod - 1) / (i << 1));\r\n\t\trt[i] = 1;\r\n\t\tL(j, i + 1, i * 2 - 1) rt[j] = (ll) rt[j - 1] * sG % mod;\r\n\t}\r\n}\r\nstruct poly {\r\n\tvector a;\r\n\tint size() { return sz(a); }\r\n\tint & operator [] (int x) { return a[x]; }\r\n\tint v(int x) { return x < 0 || x >= sz(a) ? 0 : a[x]; }\r\n\tvoid clear() { vector ().swap(a); }\r\n\tvoid rs(int x = 0) { a.resize(x); }\r\n\tpoly (int n = 0) { rs(n); }\r\n\tpoly (vector o) { a = o; }\r\n\tpoly (const poly &o) { a = o.a; }\r\n\tpoly Rs(int x = 0) { vi res = a; res.resize(x); return res; }\r\n\tinline void dif() {\r\n\t\tint n = sz(a);\r\n\t\tfor (int l = n >> 1; l >= 1; l >>= 1) \r\n\t\t\tfor(int j = 0; j < n; j += l << 1) \r\n\t\t\t\tfor(int k = 0, *w = rt + l; k < l; k++, w++) {\r\n\t\t\t\t\tint x = a[j + k], y = a[j + k + l];\r\n\t\t\t\t\ta[j + k] = add(x, y);\r\n\t\t\t\t\ta[j + k + l] = (ll) * w * dec(x, y) % mod;\r\n\t\t\t\t}\r\n\t}\r\n\tvoid dit () {\r\n\t\tint n = sz(a);\r\n\t\tfor(int i = 2; i <= n; i <<= 1) \r\n\t\t\tfor(int j = 0, l = (i >> 1); j < n; j += i) \r\n\t\t\t\tfor(int k = 0, *w = rt + l; k < l; k++, w++) {\r\n\t\t\t\t\tint pa = a[j + k], pb = (ll) a[j + k + l] * *w % mod;\r\n\t\t\t\t\ta[j + k] = add(pa, pb), a[j + k + l] = dec(pa, pb);\r\n\t\t\t\t}\r\n\t\treverse(a.begin() + 1, a.end());\r\n\t\tfor(int i = 0, iv = qpow(n); i < n; i++) a[i] = (ll) a[i] * iv % mod;\r\n\t} \r\n\tfriend poly operator * (poly aa, poly bb) {\r\n\t\tif(!sz(aa) || !sz(bb)) return {};\r\n\t\tint lim, all = sz(aa) + sz(bb) - 1;\r\n\t\tfor(lim = 1; lim < all; lim <<= 1);\r\n\t\taa.rs(lim), bb.rs(lim), aa.dif(), bb.dif();\r\n\t\tL(i, 0, lim - 1) aa[i] = (ll) aa[i] * bb[i] % mod;\r\n\t\taa.dit(), aa.a.resize(all);\r\n\t\treturn aa;\r\n\t}\r\n\tpoly Inv() {\r\n\t\tpoly res, f, g;\r\n\t\tres.rs(1), res[0] = qpow(a[0]);\r\n\t\tfor(int m = 1, pn; m < sz(a); m <<= 1) {\r\n\t\t\tpn = m << 1, f = res, g.rs(pn), f.rs(pn);\r\n\t\t\tfor(int i = 0; i < pn; i++) g[i] = (*this).v(i);\r\n\t\t\tf.dif(), g.dif();\r\n\t\t\tfor(int i = 0; i < pn; i++) g[i] = (ll) f[i] * g[i] % mod;\r\n\t\t\tg.dit();\r\n\t\t\tfor(int i = 0; i < m; i++) g[i] = 0;\r\n\t\t\tg.dif();\r\n\t\t\tfor(int i = 0; i < pn; i++) g[i] = (ll) f[i] * g[i] % mod;\r\n\t\t\tg.dit(), res.rs(pn);\r\n\t\t\tfor(int i = m; i < min(pn, sz(a)); i++) res[i] = (mod - g[i]) % mod;\r\n\t\t} \r\n\t\treturn res.rs(sz(a)), res;\r\n\t}\r\n\tpoly Shift (int x) {\r\n\t\tpoly zm (sz(a) + x);\r\n\t\tL(i, 0, sz(a) - 1) zm[i + x] = a[i];\r\n\t\treturn zm; \r\n\t}\r\n\tfriend poly operator * (poly aa, int bb) {\r\n\t\tpoly res(sz(aa));\r\n\t\tL(i, 0, sz(aa) - 1) res[i] = (ll) aa[i] * bb % mod;\r\n\t\treturn res;\r\n\t}\r\n\tfriend poly operator + (poly aa, poly bb) {\r\n\t\tvector res(max(sz(aa), sz(bb)));\r\n\t\tL(i, 0, sz(res) - 1) res[i] = add(aa.v(i), bb.v(i));\r\n\t\treturn poly(res);\r\n\t}\r\n\tfriend poly operator - (poly aa, poly bb) {\r\n\t\tvector res(max(sz(aa), sz(bb)));\r\n\t\tL(i, 0, sz(res) - 1) res[i] = dec(aa.v(i), bb.v(i));\r\n\t\treturn poly(res);\r\n\t}\r\n\tpoly & operator += (poly o) {\r\n\t\trs(max(sz(a), sz(o)));\r\n\t\tL(i, 0, sz(a) - 1) (a[i] += o.v(i)) %= mod;\r\n\t\treturn (*this);\r\n\t}\r\n\tpoly & operator -= (poly o) {\r\n\t\trs(max(sz(a), sz(o)));\r\n\t\tL(i, 0, sz(a) - 1) (a[i] += mod - o.v(i)) %= mod;\r\n\t\treturn (*this);\r\n\t}\r\n\tpoly & operator *= (poly o) {\r\n\t\treturn (*this) = (*this) * o;\r\n\t}\r\n\tpoly Integ() {\r\n\t\tif(!sz(a)) return poly();\r\n\t\tpoly res(sz(a) + 1);\r\n\t\tL(i, 1, sz(a)) res[i] = (ll) a[i - 1] * inv[i] % mod;\r\n\t\treturn res;\r\n\t}\r\n\tpoly Deriv() {\r\n\t\tif(!sz(a)) return poly();\r\n\t\tpoly res(sz(a) - 1); \r\n\t\tL(i, 1, sz(a) - 1) res[i - 1] = (ll) a[i] * i % mod;\r\n\t\treturn res;\r\n\t}\r\n\tpoly Ln() {\r\n\t\tpoly g = ((*this).Inv() * (*this).Deriv()).Integ();\r\n\t\treturn g.rs(sz(a)), g;\r\n\t}\r\n\tpoly Exp() {\r\n\t\tpoly res(1), f; \r\n\t\tres[0] = 1;\r\n\t\tfor(int m = 1, pn; m < sz(a); m <<= 1) {\r\n\t\t\tpn = min(m << 1, sz(a)), f.rs(pn), res.rs(pn);\r\n\t\t\tfor(int i = 0; i < pn; i++) f[i] = (*this).v(i);\r\n\t\t\tf -= res.Ln(), (f[0] += 1) %= mod, res *= f, res.rs(pn); \r\n\t\t}\r\n\t\treturn res.rs(sz(a)), res;\r\n\t}\r\n\tpoly pow(int x, int rx = -1) { // x : the power % mod; rx : the power % (mod - 1)\r\n\t\tif(rx == -1) rx = x;\r\n\t\tint cnt = 0;\r\n\t\twhile (a[cnt] == 0 && cnt < sz(a)) cnt += 1;\r\n\t\t\r\n\t\tpoly res = (*this);\r\n\t\tL(i, cnt, sz(a) - 1) res[i - cnt] = res[i];\r\n\t\tL(i, sz(a) - cnt, sz(a) - 1) res[i] = 0;\r\n\t\tint c = res[0], w = qpow (res[0]);\r\n\t\tL(i, 0, sz(res) - 1) res[i] = (ll) res[i] * w % mod;\r\n\t\tres = res.Ln();\r\n\t\tL(i, 0, sz(res) - 1) res[i] = (ll) res[i] * x % mod;\r\n\t\tres = res.Exp();\r\n\t\tc = qpow (c, rx);\r\n\t\tL(i, 0, sz(res) - 1) res[i] = (ll) res[i] * c % mod;\r\n\t\t\r\n\t\tif((ll) cnt * x > sz(a)) L(i, 0, sz(a) - 1) res[i] = 0;\r\n\t\telse if(cnt) {\r\n\t\t\tR(i, sz(a) - cnt * x - 1, 0) res[i + cnt * x] = res[i];\r\n\t\t\tL(i, 0, cnt * x - 1) res[i] = 0; \r\n\t\t}\r\n\t\treturn res;\r\n\t}\r\n\tvoid Rev() {\r\n\t\treverse(a.begin(), a.end());\r\n\t}\r\n} ;\r\n\r\nint n; \r\n\r\npoly Get(poly A) {\r\n\tint n = sz(A);\r\n\tL(i, 1, n - 1) A[i] = (mod - A[i]) % mod;\r\n\tA[0] = 1;\r\n\tA = A.Ln();\r\n\tL(i, 1, n - 1) A[i] = (mod - A[i]) % mod;\r\n\treturn A;\r\n}\r\n\r\nint f[N];\r\nint xg[N];\r\nint main () {\r\n\tios :: sync_with_stdio(false);\r\n\tcin.tie(0); cout.tie(0);\r\n\tcin >> n >> mod;\r\n//\tcin >> n;\r\n//\tmod = 998244353;\r\n\t_G = yg :: find();\r\n\tinit(1 << 18);\r\n\tPinit(1 << 18);\r\n\t\r\n\tpoly f(n + 1), g(n + 1);\r\n\tf[1] = 1, xg[0] = 1, xg[1] = 1;\r\n\tL(i, 2, n) {\r\n//\t\tL(j, 0, i - 1) (xg[i] += (ll) f[i - j] * xg[j] % mod) %= mod;\r\n//\t\txg[i] = (ll) xg[i] * inv[i] % mod;\r\n\t\tpoly ns(n + 1);\r\n\t\tL(j, 1, i - 1) \r\n\t\t\tns += f.pow(j) * ifac[j - 1];\r\n\t\tf[i] = ns[i - 1]; \r\n//\t\tL(j, 1, i) \r\n//\t\t\t(f[i] += (ll) f[j] * xg[i - j] % mod) %= mod;\r\n\t} \r\n\t/* F = x * (F * EXP(F) + 1), a dc fft could work */\r\n\t\r\n//\tL(i, 1, n) {\r\n//\t\tcout << i << \" : \" << (ll) f[i] * fac[i] % mod << '\\n';\r\n//\t}\r\n//\tcout << '\\n';\r\n\t\r\n\tL(i, 1, n) g[i] = f[i];\r\n\tg = g.Exp();\r\n\tR(i, n, 1) g[i] = g[i - 1];\r\n\tg[0] = 0;\r\n\t\r\n//\tL(i, 0, n) \r\n//\t\tcout << (ll) g[i] * fac[i] % mod << \",\";\r\n//\tcout << '\\n';\r\n\t\r\n\tf[1] = 0;\r\n\tpoly h(n + 1);\r\n\tL(i, 1, n) \r\n\t\th[i] = (f[i - 1] + g[i - 1]) % mod;\r\n\t\r\n//\tcout << \"h : \"; \r\n//\tL(i, 0, n) cout << h[i] << \",\";\r\n//\tcout << '\\n';\r\n\t\r\n\tf = Get(h + f + g) - Get(g) - f;\r\n\tf = f.Exp();\r\n\tcout << (ll) f[n] * fac[n] % mod << '\\n';\r\n\treturn 0;\r\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9c8eca88f6b8e75a6f678e0a8bd7389a", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\n#include \n\n#include \n#include \n#include \n\nusing namespace std;\n\nconst int MAXN = 1e5 + 100;\n\ntypedef long long ll;\n#define tll(x) static_cast(x)\n\ntypedef pair pii;\n#define mp make_pair\n#define ff first\n#define ss second\n\nint N, root;\n\nconst int MAXS = MAXN * 1000;\nstruct PBT {\npublic:\n int c[MAXS][2], v[MAXS], sz[MAXS], h[MAXS];\n int NXT;\n PBT() : NXT(1) {v[0] = -1, sz[0] = 0, h[0] = 0;};\n int upd(int n) {\n if(not(0 < n)) return n;\n sz[n] = sz[c[n][0]] + sz[c[n][1]] + 1;\n h[n] = max(h[c[n][0]], h[c[n][1]]) + 1;\n assert(n != c[n][0] and n != c[n][1]);\n return n;\n }\n int gsz(int n) {\n if(n == 0) return 0;\n return gsz(c[n][0]) + gsz(c[n][1]) + 1;\n }\n void asst(int n) {assert(gsz(n) == sz[n]);}\n int nn(const int& n = -1) {\n if(n == 0) return 0;\n if(0 < n) {\n for(int i = 0;i < 2;i++) c[NXT][i] = c[n][i];\n v[NXT] = v[n];\n } else {\n for(int i = 0;i < 2;i++) c[NXT][i] = 0;\n v[NXT] = -1;\n }\n upd(NXT);\n return NXT++;\n }\n int nnr(const int& q) {\n int n = nn();\n v[n] = q;\n return n;\n }\n int L(int& n, int p = 0) {\n assert(c[n][1]);\n int o;\n if(p>1) o = nn(n); else o = n;\n if(p>0) n = nn(c[n][1]); else n = c[n][1];\n c[o][1] = c[n][0];\n upd(c[n][0] = o);\n return upd(n);\n }\n int R(int& n, int p = 0) {\n assert(c[n][0]);\n int o;\n if(p>1) o = nn(n); else o = n;\n if(p>0) n = nn(c[n][0]); else n = c[n][0];\n c[o][0] = c[n][1];\n upd(c[n][1] = o);\n return upd(n);\n }\n bool bal(int& n, bool p = false) { //here, we assume that n is already a copy\n int q = NXT;\n int b = h[c[n][0]] - h[c[n][1]], s, o = n;\n if(b < -1) {\n assert(s = c[n][1]);\n if(h[c[s][1]] + 1 == h[s]) {\n L(n, p ? 1 : 0);\n } else if(h[c[s][0]] + 1 == h[s]) {\n R(c[n][1], p ? 2 : 0);\n L(n, 0);\n } else assert(false);\n }\n else if(b > 1) {\n assert(s = c[n][0]);\n if(h[c[s][0]] + 1 == h[s]) {\n R(n, p ? 1 : 0);\n } else if (h[c[s][1]] + 1 == h[s]) {\n L(c[n][0], p ? 2 : 0);\n R(n, 0);\n } else assert(false);\n }\n else return false;\n return true;\n }\n int join(int a, int b, bool p = true) { //here we assume a and b are already copies\n if(a == 0 or b == 0) return a ? a : b;\n if(h[a] < h[b]) {\n c[b][0] = join(a, p ? nn(c[b][0]) : c[b][0], p);\n upd(b);\n bal(b, p);\n return b;\n } else {\n c[a][1] = join(p ? nn(c[a][1]) : c[a][1], b, p);\n upd(a);\n bal(a, p);\n return a;\n }\n }\n int join2(int l, int m, int r) { //assume all are copies, merges L and R at M\n if(h[l] + 1 < h[r]) {c[r][0] = join2(l, m, nn(c[r][0])); return upd(r);}\n if(h[r] + 1 < h[l]) {c[l][1] = join2(nn(c[l][1]), m, r); return upd(l);}\n c[m][1] = r;\n c[m][0] = l;\n upd(m);\n bal(m, 1);\n return m;\n }\n pii split(int a, int k) { //always create new nodes, assume a is NOT a copy\n if(k == 0) return mp(0, nn(a));\n assert(0 < k);\n if(sz[c[a][0]] < k) {\n pii q = split(c[a][1], k - sz[c[a][0]] - 1);\n int r = join2(nn(c[a][0]), nnr(v[a]), q.ff);\n return mp(r, q.ss);\n } else {\n pii q = split(c[a][0], k);\n int r = join2(q.ss, nnr(v[a]), nn(c[a][1]));\n return mp(q.ff, r);\n }\n }\n int get(int l, int r) { //inclusive - exclusive\n while(not(l < N)) l -= N, r -= N;\n while(l < 0) l += N, r += N;\n \n if(r > N) return join(get(l, N), get(N, r));\n pii f1 = split(root, r);\n pii f2 = split(f1.ff, l);\n \n return f2.ss;\n }\n void fill(int n, int * a, int * t = new int(0)) {\n if(n == 0) return;\n fill(c[n][0], a, t);\n a[(*t)++] = v[n];\n fill(c[n][1], a, t);\n }\n void pout(int n = root) {\n if(n == 0) return;\n pout(c[n][0]);\n cerr << v[n] << \" \";\n pout(c[n][1]);\n if(n == root) cerr << \"\\n\\n\";\n }\n} pbt;\n\nint M, S;\nll T;\n\nint to[40][MAXN];\n\nvoid gen() {\n root = 0;\n for(int i = 0;i < N;i++) root = pbt.join(root, pbt.nnr(i), 0);\n for(int i = 1;i < N;i++) {\n int a = pbt.get(i, i + M);\n int b = pbt.get(M - i, N - i);\n assert(pbt.sz[a] == M and pbt.sz[b] == N - M);\n root = pbt.join(a, b);\n //pbt.pout();\n assert(pbt.sz[root] == N);\n }\n pbt.fill(root, to[0]);\n}\n\nvoid run() {\n for(int i = 1;i < 40;i++) {\n for(int j = 0;j < N;j++) {\n to[i][j] = to[i-1][to[i-1][j]];\n }\n }\n}\n\nvoid brute() {\n int q = static_cast(T%N);\n for(;q;q--,T--) {\n if(S < M) S = (S + q)%N;\n else S = (S - q + N)%N;\n }\n assert(T%N == 0);\n}\n\nvoid solve() {\n scanf(\"%d%lld\", &S, &T);\n --S;\n brute();\n int k = T/N;\n for(int i = 0;1 << i < k;i++) {\n if(k&(1<(clock() - timer)/CLOCKS_PER_SEC << \"\\n\";\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "38cfe4c3ef535ad264a03e19c24bfb24", "src_uid": "e743242f0cc9e17619e1fe4935d9fbd0", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define endl \"\\n\"\n#define fre(i,a) for (auto& i: a)\n#define ll long long\n\nstruct Rect{\n\tlong long x1, y1, x2, y2;\n\tlong long area(){\n\t\treturn (y2-y1)*(x2-x1);\n\t}\n};\n\nint intersect(Rect p, Rect q){\n long long xOverlap = max(0,min(p.x2,q.x2)-max(p.x1,q.x1));\n long long yOverlap = max(0,min(p.y2,q.y2)-max(p.y1,q.y1));\n return xOverlap*yOverlap;\n}\n\nRect a, b, c;\n\nint main(){\n\tcin.tie(0)->sync_with_stdio(0);\n\n\n\tcin >> a.x1 >> a.y1 >> a.x2 >> a.y2;\n\tcin >> b.x1 >> b.y1 >> b.x2 >> b.y2;\n\tcin >> c.x1 >> c.y1 >> c.x2 >> c.y2;\n\n\tif(a.area() - (intersect(a,b) + intersect(a,c) - intersect(b,c)) == 0)\n\t\tcout << \"NO\";\n\telse\n\t\tcout << \"YES\";\n\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "43f1504d2c0109fc2be6e984dd8a5c47", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nlong long f,t,t0,a1,t1,p1,a2,t2,p2,ans=(1LL<<60);\nint main(){\n\tcin>>f>>t>>t0>>a1>>t1>>p1>>a2>>t2>>p2;\n\tfor(int i=0;t1*i<=t;++i){\n\t\tlong long lef=f-i,ret=(i+a1-1)/a1*p1;\n\t\tif(t0lb+1){\n\t\t\tlong long mid=(lb+ub)>>1;\n\t\t\tif(t1*i+t2*mid+max(0LL,(f-i-mid))*t0<=t) ub=mid;\n\t\t\telse lb=mid;\n\t\t}\n\t\tif(t1*i+t2*ub+max(0LL,(f-i-ub))*t0>t) continue;\n\t\tret+=(ub+a2-1)/a2*p2;\n\t\tif(i%a1==0||ub%a2==0) ans=min(ans,ret);\n\t}\n\tif(ans>=INF) puts(\"-1\");\n\telse cout<\n#include\nint main()\n{\n int n,k;\n cin>>n;\n k=(-1+sqrt(1+8*n))/2;\n cout<\n#include\n#include\nusing namespace std;\nint gao(int n)\n{\n int sum=0;\n if(n==0) return 1;\n while(n!=0)\n {\n sum++;\n n/=2;\n }\n return sum;\n}\nint a[100010];\nint main(void)\n{\n int n;\n scanf(\"%d\",&n);\n for(int i=0;i0&&a[i]\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair i_i;\ntypedef pair ll_i;\ntypedef pair d_i;\ntypedef pair ll_ll;\ntypedef pair d_d;\nstruct edge { int u, v; ll w; };\n\nll MOD = 1000000007;\nll _MOD = 1000000009;\ndouble EPS = 1e-10;\n\nint N, ma;\nint a[10][10];\n\nvoid f(int t, int T) {\n\tint i = t / N, j = t % N;\n\tcin >> a[i][j];\n\tt + 1 == T ? 0 : f(t + 1, T);\n}\n\nvoid g(int t, int T) {\n\tint k = t / N / N, i = t / N % N, j = t % N;\n\ta[i][j] = min(a[i][j], a[i][k] + a[k][j]);\n\tt + 1 == T ? 0 : g(t + 1, T);\n}\n\nvoid h(int t, int T) {\n\tint i = t / N, j = t % N;\n\tma = max(ma, a[i][j]);\n\tt + 1 == T ? 0 : h(t + 1, T);\n}\n\nint main() {\n\tcin >> N;\n\tf(0, N * N);\n\tg(0, N * N * N);\n\th(0, N * N);\n\tcout << ma << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "030be2426450ad06868e17ed3a672f69", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_cxx;\n\n#define endl '\\n'\n\nint main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n\n int h, r;\n cin >> r >> h;\n\n int ans = h / r * 2;\n h %= r;\n\n if (2 * h < r)\n ans += 1;\n else if (h * 2 >= srqt(3.0) * r)\n ans += 3;\n else ans += 2;\n\n cout << ans << endl;\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2b935aba23aa9f787e67e6c0206a2708", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nstring s;\nint main() {\n\tint n, i;\n\tcin >> n >> s;\n\tfor(i = 0; i < n; i++)\n\t\tif(!(s[i] % 2)) {\n\t\t\tcout << ++i << \"\\n\";\n\t\t\treturn 0;\n\t\t}\n\tcout << n < \"\\n\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ad4fcd6cbc12bc13639dc19e02128498", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\ntypedef long long ll;\n\nint main()\n{\n\nlong long res=0;\nint val[6][6];\n\nfor(int i=0;i<5;i++)\n for(int j=0;j<5;j++)\n cin>>val[i][j];\nvector vec;\nfor(int i=0;i<5;i++) vec.push_back(i);\ndo\n{\n long long temp=0;\n for(int i=0;i<5;i++)\n for(int j=i;j<4;j+=2)\n temp+=val[vec[j]][vec[j+1]]+val[vec[j+1]][vec[j]];\n\n res=max(temp,res);\n}while(next_permutation(vec.begin(),vec.end()));\n\ncout<\n# include\n# include\nint dd,mm,yy,x,z,y;\nint leap[12]={31,28,31,30,31,30,31,31,30,31,30,31};\nint normal[12]={31,29,31,30,31,30,31,31,30,31,30,31};\nint i,j;\nbool f(int x,int y,int z)\n{\n\tif(y>12||y==0) return 0;\n\tif(z%4==0)\n\t if(x==0||x>leap[y-1]) return 0;\n\telse\n\t if(x==0||x>normal[y-1]) return 0;\n\tif(z+18>yy) return 0;\n\tif(z+18y) return 1;\n\tif(dd\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long LL;\nconst int MAXN=300010;\nLL n,m;\nLL a[MAXN],now,con;\nLL ans;\nmap M;\nint main()\n{\n scanf(\"%I64d%I64d\",&n,&m);\n for(int i=1,x,y;i<=m;i++) scanf(\"%d%d\",&x,&y),a[i]=(LL)(x+1)*(LL)n+(LL)y;\n sort(a+1,a+m+1);\n for(int i=m+1;i<=m+m;i++) a[i]=a[i-m]+n+n,M[a[i]]++,M[a[i-m]]++;\n ans=(LL)m*(LL)(m-1)*(LL)(m-2)/6LL;\n for(int i=1;i<=m;i++)\n {\n now=max(now,i);\n while(a[now+1]-a[i]i) con=max(con,a[now]-a[i]);\n ans-=(LL)(now-i)*(LL)(now-i-1)/2LL;\n }\n if(ans>0) {printf(\"%I64d\\n\",ans);return 0;}\n now=0,ans=0;\n for(int i=1;i<=m;i++)\n {\n now=max(now,i);\n while(a[now+1]-a[i]\n\nusing namespace std;\n\nchar s[45];\nint n;\n\nint main() {\n cin >> n;\n while (n--) {\n cin >> s;\n int k = strlen(s + 4), year = atoi(s + 4), F = 0, tenPow = 10;\n for (int i = 1; i < k; i++) {\n F += tenPow;\n tenPow *= 10;\n }\n \n while (year < 1989 + F) year += tenPow;\n \n cout << year << '\\n';\n }\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e773f4dbaf896135afbe854c7a379e6a", "src_uid": "31be4d38a8b5ea8738a65bfee24a5a21", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define ll long long\n#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)\n#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)\n#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)\ntemplateinline void chkmax(T &a,T b){ if(ainline void chkmin(T &a,T b){ if(a>b)a=b;}\ninline int read()\n{\n\tint sum=0,p=1;char ch=getchar();\n\twhile(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();\n\tif(ch=='-')p=-1,ch=getchar();\n\twhile('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();\n\treturn sum*p;\n}\n\nconst int maxn=5020;\nconst int Zero=4000;\nconst int One=4010;\n\nint d,mod;\nint cell[maxn];\nint X,Y;\nint C[100][100];\nint tot;\n\ninline int power(int a,int b)\n{\n\tint ans=1;\n\twhile(b) (b&1?ans=(ll)ans*a%mod:0),b>>=1,a=(ll)a*a%mod;\n\treturn ans;\n}\n\ninline void add(int a,int b,int c)\n{\n\tprintf(\"+ %d %d %d\\n\",a,b,c);\n\tcell[c]=(cell[a]+cell[b])%mod;\n}\n\ninline void mul(int a,int c,int b)\n{\n\tadd(a,Zero,b);\n\twhile(c)(c&1?add(b,a,b),0:0),c>>=1,add(a,a,a);\n}\n\nint x[100];\nint g[100][100];\n\ninline int square(int a)\n{\n\tadd(cell[a],Zero,x[0]=++tot);\n\tREP(i,1,d)\n\t{\n\t\tadd(tot,One,tot+1);x[i]=++tot;\n\t}\n\tREP(i,0,d)printf(\"^ %d %d\",x[i],x[i]),cell[x[i]]=power(cell[x[i]],d);\n\tmemset(g,0,sizeof(g));\n\tREP(i,0,d)REP(j,0,d)g[i][j]=(ll)power(i,d-j)*C[d][j]%mod;\n\tREP(i,0,d)swap(g[i][0],g[i][2]); REP(i,0,d)g[i][d+1+i]=1;\n\tREP(i,0,d)\n\t{\n\t\tREP(j,0,d)if(i!=j)\n\t\t{\n\t\t\twhile(g[j][i])\n\t\t\t{\n\t\t\t\tint tmp=g[i][i]/g[j][i];\n\t\t\t\tREP(l,i,2*d+1)g[i][l]=(g[i][l]-(ll)tmp*g[j][l]%mod+mod)%mod,swap(g[j][l],g[i][l]);\n\t\t\t}\n\t\t}\n\t}\n\tint now=++tot; add(Zero,Zero,now);\n\tREP(i,0,d)mul(x[i],g[i][d+1],++tot),add(now,tot,now);\n\treturn now;\n}\n\ninline void init()\n{\n\tsrand(time(0)^(unsigned ll)new char);\n\td=read(); mod=read();\n\tX=3,Y=4;\n\tREP(i,1,5000)cell[i]=1; cell[1]=X; cell[2]=Y;\n\tint t=mod-1; while(t)(t&1?add(Zero,Zero-1,Zero),0:0),t>>=1,add(Zero-1,Zero-1,Zero-1);\n\tC[0][0]=1;REP(i,1,d)REP(j,0,i)C[i][j]=((j?C[i-1][j-1]:0)+C[i-1][j])%mod;\n\ttot=2000;\n}\n\ninline void doing()\n{\n\tadd(1,2,3);\n\tint x2=square(1),y2=square(2),xy2=square(3);\n\tadd(x2,y2,4); mul(4,mod-1,5); add(5,xy2,5);\n\tint inv2=(mod+1)>>1;\n\tmul(5,inv2,6);\n\tprintf(\"f 5\\n\");\n}\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"decive.in\",\"r\",stdin);\n\tfreopen(\"decive.out\",\"w\",stdout);\n#endif\n\tinit();\n\tdoing();\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3c7e5253eec918dd971e34a40d02dd3b", "src_uid": "bbdc2a3d58f5229d7e9b67e4de70067f", "difficulty": 3300.0} {"lang": "GNU C++14", "source_code": "#include\r\nusing namespace std;\r\nbool check[500003];\r\nvoid prime()\r\n{\r\n memset(check,true,sizeof(check));\r\n \r\n for(int i=2;i*i<=500003;i++)\r\n {\r\n if(check(i))\r\n {\r\n for(j=i*i;j<=500003;j=j+i)\r\n {\r\n check[j]=false;\r\n }\r\n }\r\n }\r\n}\r\nint main()\r\n{\r\n long long int n,m;\r\n cin>>n>>m;\r\n prime();\r\n long long int sum=0;\r\n long long int p=1;\r\nlong long int c;\r\nlong long int mm=1;\r\n for(i=1;i<=m;i++)\r\n {\r\n c=m/p;\r\n if(check(i))\r\n p=p*i;\r\n mm=(mm*m)%998244353;\r\n sum=(sum+(mm-c%998244353))%998244353;\r\n }\r\n cout<\nusing namespace std;\n#define ll long long\nconst int N = (int) 2*1e5;\n\nint dir[4][2] = { {0,1}, {0,-1}, {1,0}, {-1,0}}; \n\nint main(){\n\t#ifndef ONLINE_JUDGE\n // for getting input from input.txt\n freopen(\"input.txt\", \"r\", stdin);\n // for writing output to output.txt\n freopen(\"output.txt\", \"w\", stdout);\n #endif\n\tint t;\n\tcin>>t;\n\twhile(t--)\n\t{\n\n\n int n;\n cin>>n;\n int temp=n;\n int a[5]={0,1,3,6,10};\n int dig=0;\n while(temp)\n {\n \ttemp=temp/10;\n \tdig++;\n\n }\n int ans=10*(n%10-1)+(a[dig]);\n cout<\nusing namespace std;\ntypedef long long ll;\nconst int maxn = 1000010;\nconst ll mod = 998244353;\nint n;\nll fact[maxn];\n\nll qp(ll x, ll y) {\n ll ans = 1;\n for (; y; x = x * x % mod, y >>= 1) {\n if (y & 1) {\n ans = ans * x % mod;\n }\n }\n return ans;\n}\n\nll C(ll x, ll y) {\n if (x < y) return 0;\n return fact[x] * qp(fact[y] * fact[x - y] % mod, mod - 2) % mod;\n}\n\nint main() {\n fact[0] = 1;\n for (int i = 1; i <= maxn; i++) {\n fact[i] = fact[i - 1] * i % mod;\n }\n cin>>n;\n ll ans = qp(qp(3, n) - 3, n);\n for (int i = 1; i <= n; i++) {\n if (i & 1) {\n ans = (ans - C(n, i) * qp(qp(3, n - i) - 1, n) * 3 % mod + mod) % mod;\n ans = (ans - C(n, i) * (qp(3, i) - 3) % mod * qp(qp(3, n - i), n) % mod + mod) % mod;\n } else {\n ans = (ans + C(n, i) * qp(qp(3, n - i) - 1, n) * 3 % mod) % mod;\n ans = (ans + C(n, i) * (qp(3, i) - 3) % mod * qp(qp(3, n - i), n) % mod) % mod;\n }\n }\n cout<\n#include\n#include\n#include\nusing namespace std;\n\nint n, ans;\nint a[10];\n\nint main(){\n \n cin>>n;\n \n for(int i = 0; i\n#include \n#define llint long long\n#define mod 1000000007\n\nusing namespace std;\n\nint n;\nstring s;\nint next[205][2];\nconst char c[] = {'(', ')'};\nllint dp[205][205][205];\n\nllint fact[2005], fact_inv[2005];\n\nllint pow(llint a, llint n)\n{\n\tif(n == 0) return 1;\n\tif(n % 2){\n\t\treturn ((a%mod) * (pow(a, n-1)%mod)) % mod;\n\t}\n\telse{\n\t\treturn pow((a*a)%mod, n/2) % mod;\n\t}\n}\n\nvoid make_fact()\n{\n\tllint val = 1;\n\tfact[0] = 1;\n\tfor(int i = 1; i < 2005; i++){\n\t\tval *= i;\n\t\tval %= mod;\n\t\tfact[i] = val;\n\t}\n\tfor(int i = 0; i < 2005; i++){\n\t\tfact_inv[i] = pow(fact[i], mod-2);\n\t}\n}\n\nint main(void)\n{\n\tcin >> n;\n\tcin >> s;\n\tmake_fact();\n\t\n\tfor(int i = 0; i < n; i++){\n\t\tfor(int j = 0; j < 2; j++){\n\t\t\tstring t = s.substr(0, i) + c[j];\n\t\t\twhile(s.substr(0, t.length()) != t){\n\t\t\t\tt = t.substr(1);\n\t\t\t}\n\t\t\tnext[i][j] = t.length();\n\t\t}\n\t}\n\t\n\tdp[0][0][0] = 1;\n\tfor(int i = 0; i < 2*n; i++){\n\t\tfor(int j = 0; j <= 2*n; j++){\n\t\t\tfor(int k = 0; k < s.size(); k++){\n\t\t\t\tif(k != s.size()-1 || s[s.size()-1] != c[0]){\n\t\t\t\t\tdp[i+1][j+1][next[k][0]] += dp[i][j][k];\n\t\t\t\t\tdp[i+1][j+1][next[k][0]] %= mod;\n\t\t\t\t}\n\t\t\t\tif(k != s.size()-1 || s[s.size()-1] != c[1]){\n\t\t\t\t\tif(j > 0){\n\t\t\t\t\t\tdp[i+1][j-1][next[k][1]] += dp[i][j][k];\n\t\t\t\t\t\tdp[i+1][j-1][next[k][1]] %= mod;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tllint ans = 0;\n\tfor(int i = 0; i < s.size(); i++){\n\t\tans += dp[2*n][0][i];\n\t\tans %= mod;\n\t}\n\tans = fact[2*n] * fact_inv[n+1] % mod * fact_inv[n] % mod + (mod - ans);\n\tcout << ans % mod << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a08c6642efed290e674f2b6b87c3b26f", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include\n#define ll long long\n#define ull unsigned ll\n#define uint unsigned\n#define pii pair\n#define pll pair\n#define IT iterator\n#define PB push_back\n#define fi first\n#define se second\n#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)\n#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)\n#define CLR(a,v) memset(a,v,sizeof(a));\n#define CPY(a,b) memcpy(a,b,sizeof(a));\n#define debug puts(\"wzpakking\")\n#define y1 ysghysgsygsh\nusing namespace std;\n\nconst int N=500005;\nint n,a[N];\nset One;\nvoid solve(){\n\tscanf(\"%d\",&n);\n\tFor(i,1,n) scanf(\"%d\",&a[i]);\n\t//a[0]=1<<30;\n\tint ans=0,two=-1;\n\tll sgn=1,key=0;\n\tOne.clear();\n\tFor(i,1,n){\n\t\tif (two!=-1){\n\t\t\tans+=2;\n\t\t\tsgn=1; key=0;\n\t\t\tOne.clear();\n\t\t\tif (two=lim);\n\t\t\t\t\telse{\n\t\t\t\t\t\tif (tmp.se>=lim)\n\t\t\t\t\t\t\ttmp.se=lim-1;\n\t\t\t\t\t\tOne.insert(tmp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tkey=x-key;\n\t\t\tsgn*=-1;\n\t\t}\n\t\telse{\n\t\t\tsgn=-1; key=a[i];\n\t\t\tint lim=min(a[i-1],a[i]-1);\n\t\t\tif (lim>=1) One.insert(pii(1,lim));\n\t\t}\n\t\tif (a[i]%2==0){\n\t\t\tint y=a[i]/2;\n\t\t\tll p=(y-key)/sgn;\n\t\t\tauto it=One.lower_bound(pll(p+1,0));\n\t\t\tbool flag=0;\n\t\t\tif (it!=One.begin()){\n\t\t\t\t--it;\n\t\t\t\tif (it->fi<=p&&p<=it->se)\n\t\t\t\t\tflag=1;\n\t\t\t}\n\t\t\tif (flag) two=y;\n\t\t\telse One.insert(pll(p,p));\n\t\t}\n\t\t//cout<\nusing namespace std;\nint main() {\n\tchar c=getchar();\n\tint ans=1;\n\tfor(int i=0; i<6; i++) { /\n\t\tc=getchar();\n\t\tif(c=='1')ans+=10;\n\t\telse ans+=c-'0';\n\t}\n\tprintf(\"%d\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9193be5b26db4049f167ce2014ca801c", "src_uid": "47287f8bc61fec72d729638d5e0e67f5", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n \n string s;\n cin>>s;\n \n int extra = 0;\n \n for(i=0;i\nusing namespace std;\n#define ll int64_t\n\nint main(){\nll n,m;\ndp[0]=1;\ndp[1]=1;\ncin>>n>>m;\nll dp[n+2];\nfor(ll i=2;i\n#include \n#include \n#include \n#define int ll\n#define ll long long\n#define l(a) (a<<1)\n#define r(a) (a<<1|1)\n#define MN 500005\n#define MM 1000005\n#define MD 4200005\nusing namespace std;\nstruct vec\n{\n\tint x,y;\n\tfriend ll operator/(const vec& a,const vec& b) {return 1LL*a.x*b.y-1LL*a.y*b.x;}\n\tfriend ll operator*(const vec& a,const vec& b) {return 1LL*a.x*b.x+1LL*a.y*b.y;}\n};\nstruct meg{int g,x,y;}a[MN];\nstruct met{vec v;int pos;}b0[MM],b1[MM];\nstruct its{int x,y;}s[MN];\nstruct itv{vec x,y;}d[MN];\nstruct Que\n{\n\tpriority_queue A,B;\n\tvoid push(int x) {A.push(x);}\n\tvoid dele(int x) {B.push(x);}\n\tint top()\n\t{\n\t\twhile (!B.empty()&&A.top()==B.top()) A.pop(),B.pop();\n\t\tif (!A.empty()) return A.top(); else return 0;\n\t}\n}q[MM];\nint m,MQ,tin,b0in,b1in,ra;\nint t[MD];\n\ninline int read()\n{\n\tint n=0,f=1; char c=getchar();\n\twhile (c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();}\n\twhile (c>='0' && c<='9') {n=n*10+c-'0'; c=getchar();}\n\treturn n*f;\n}\n\ninline void getcg(int x,int z) {for (t[x+=MQ]=z,x>>=1;x;x>>=1) t[x]=max(t[l(x)],t[r(x)]);}\ninline int getmax(int L,int R)\n{\n\tint sum=0;\n\tfor (L+=MQ,R+=MQ;L<=R;L>>=1,R>>=1)\n\t{\n\t\tif ( L&1) sum=max(sum,t[L++]);\n\t\tif (~R&1) sum=max(sum,t[R--]);\n\t}\n\treturn sum;\n}\n\nvoid cghp(int x,int y,int g)\n{\n\tint lt=q[x].top();\n\tif (g==1) q[x].push(y); else q[x].dele(y);\n\tif (lt!=q[x].top()) getcg(x,q[x].top());\n}\n\nbool check(int x,int y)\n{\n\tint cs1,cs2;\n\tif (s[x].x>s[y].x) cs1=x; else cs1=y;\n\tif (s[x].y=0;}\n\nmain()\n{\n\tregister int i,x,y;\n\tra=read(); m=read();\n\tfor (i=1;i<=m;++i)\n\t{\n\t\ta[i].g=read();\n\t\tif (a[i].g==1)\n\t\t{\n\t\t\tx=read(); y=read(); a[i].x=++tin;\n\t\t\td[tin].x.x=x-ra; d[tin].x.y=y;\n\t\t\td[tin].y.x=x+ra; d[tin].y.y=y;\n\t\t\tb0[++b0in]=(met){d[tin].x,tin};\n\t\t\tb1[++b1in]=(met){d[tin].y,tin};\n\t\t}\n\t\telse if (a[i].g==2) a[i].x=read();\n\t\telse if (a[i].g==3) a[i].x=read(),a[i].y=read();\n\t}\n\tsort(b0+1,b0+b0in+1,cmp); sort(b1+1,b1+b1in+1,cmp);\n\tb0[0].pos=b1[0].pos=s[0].x=s[0].y=0;\n\tfor (i=1;i<=b0in;++i)\n\t\tif (i>1&&b0[i-1].v/b0[i].v==0) s[b0[i].pos].x=s[b0[i-1].pos].x;\n\t\telse s[b0[i].pos].x=s[b0[i-1].pos].x+1;\n\tfor (i=1;i<=b1in;++i)\n\t\tif (i>1&&b1[i-1].v/b1[i].v==0) s[b1[i].pos].y=s[b1[i-1].pos].y;\n\t\telse s[b1[i].pos].y=s[b1[i-1].pos].y+1;\n\tb0in=s[b0[b0in].pos].x;\n\tfor (MQ=1;MQ=y) puts(\"NO\"); else puts(\"YES\");\n\t\t\tcghp(s[a[i].x].x,s[a[i].x].y,1);\n\t\t\tcghp(s[a[i].y].x,s[a[i].y].y,1);\n\t\t}\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d5214465cdb4dc8a608dab72173e53a3", "src_uid": "775761bcba74d78b833c295290a2195c", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "//#include \n#include \n/*#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include */\n#include \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\n#define PB push_back\n#define MP make_pair\n#define endl \"\\n\"\nconst ll UNDEF = -1;\nconst ll INF=1e18;\ntemplate inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }\ntemplate inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }\ntypedef pair pll;\ntemplate T extgcd(T a, T b, T& x, T& y) { for (T u = y = 1, v = x = 0; a;) { T q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); swap(b -= q * a, a); } return b; }\n\ntemplate T mod_inv(T a, T m) { T x, y; extgcd(a, m, x, y); return (m + x % m) % m; }\nll mod_pow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }\nll mod_pow2(ll a, ll n, ll mod) {\n\tif (n<0) return mod_inv(mod_pow(a,-n,mod),mod);\n\telse return mod_pow(a,n,mod);\n}\n\n#ifdef DEBUG\n #define debug(args...) {dbg,args; cerr< debugger& operator , (const T& v)\n { \n cerr<0) {\n\t\t\tll parts=(s==1)?1:g(s,gd-1,s);\n\t\t\tll stars=k;\n\t\t\tll factor=starbar(stars,parts);\n\t\t\tll adder=mul(cand,factor);\n\t\t\t//printf(\"f %lld %lld %lld. k:%lld adder:%lld cand:%lld factor:%lld. stars:%lld parts:%lld\\n\",nodes,rootdeg,s,k,adder,cand,factor,stars,parts);\n\t\t\tans=add(adder,ans);\n\t\t}\n\t}\n\t//printf(\"f %lld %lld %lld: %lld\\n\",nodes,rootdeg,s,ans);\n\treturn dpf[nodes][rootdeg][s]=ans;\n}\nll g(ll nodes, ll rootdeg, ll s) {\n\tif (nodes<=0||rootdeg<0||s<0) return 0;\n\tif (dpg[nodes][rootdeg][s]!=UNDEF) return dpg[nodes][rootdeg][s];\n\tll ans=add(g(nodes,rootdeg,s-1),f(nodes,rootdeg,s));\n\t//printf(\"g %lld %lld %lld: %lld\\n\",nodes,rootdeg,s,ans);\n\treturn dpg[nodes][rootdeg][s]=ans;\n}\nint main()\n{\n\tios_base::sync_with_stdio(false); cin.tie(0);\n\tll n; scanf(\"%lld%lld%lld\",&n,&gd,&MOD);\n\tif (n==2||n==1 ) {\n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\t//initfact(MAXFACT);\n\tmemset(dpf,-1,sizeof dpf);\n\tmemset(dpg,-1,sizeof dpg);\n\tfor (ll d=0;d\n#include \n\n\nusing namespace std;\n\n\n\nint main()\n{\n\tchar chMas[5] = \"\";\n\tint value;\n\tunsigned long long res;\n\tcin >> chMas[0];\n\tcin >> chMas[4];\n\tif (chMas[4] == \"0\")\n\t{\n\t\tcout << \"00000\";\n\t}\n\telse\n\t{\n\t\tcin >> chMas[1];\n\t\tcin >> chMas[3];\n\t\tcin >> chMas[2];\n\t\tvalue = atoi(chMas);\n\t\tres = value;\n\t\tfor (int i = 0; i < 4; i++)\n\t\t{\n\t\t\tres = (res*value) % 100000;\n\t\t}\n\t\tcout << res;\n\t}\n\t\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c922e32b44a2de90181441682cc57e15", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#define MOD 51123987\nusing namespace std;\nint n;\nint m;\nchar s[200];\nint next[200][3];\nint dp[155][55][55][55];\nint main()\n{\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",s+1);\n\tnext[n][0]=n+1;next[n][1]=n+1;next[n][2]=n+1;\n\tnext[n][s[n]-'a']=n;\n\tfor(int i=n-1;i>=1;i--)\n\t{\n\t\tnext[i][0]=next[i+1][0];\n\t\tnext[i][1]=next[i+1][1];\n\t\tnext[i][2]=next[i+1][2];\n\t\tnext[i][s[i]-'a']=i;\n\t}\n\tdp[1][0][0][0]=1;\n\tm=n/3+1;\n\tfor(int i=0;i<=n;i++)\n\t{\n\t\tfor(int j=0;j<=m;j++)\n\t\t{\n\t\t\tfor(int k=0;k<=m;k++)\n\t\t\t{\n\t\t\t\tfor(int l=0;l<=m;l++)\n\t\t\t\t{\n\t\t\t\t\tif(dp[i][j][k][l]==0)continue;\n\t\t\t\t//\tcout<\nint main()\n{\n\tint a,b,k,ans=0,u;\n\tfor(scanf(\"%d%d%d\",&a,&b,&k);a<=b;++a)if(!(a%k))\n\t\tu=k;\n\t\twhile(--u!=1)if(!(a%u))break;\n\t\tif(u==1)++ans;\n\t}\n\tprintf(\"%d\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9e7d274f6798d089e8e313f54e6f9800", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ndouble sqr(double a) {\n return a * a;\n}\n\n\nbool doubleEqual(double a, double b) {\n return fabs(a - b) < 1e-9;\n}\n\n\nbool doubleLessOrEqual(double a, double b) {\n return a < b || doubleEqual(a, b);\n}\n\n\nbool doubleLess(double a, double b) {\n return a < b && !doubleEqual(a, b);\n}\n\n\nbool doubleGreaterOrEqual(double a, double b) {\n return a > b || doubleEqual(a, b);\n}\n\n\nbool doubleGreater(double a, double b) {\n return a > b && !doubleEqual(a, b);\n}\n\n\ndouble mySqrt(double a) {\n if(doubleLess(a, 0) )\n {\n throw \"sqrt(-1)\";\n }\n if(a < 0) return 0;\n return sqrt(a);\n}\n\n\nstruct Point {\n double x, y;\n Point(): x(0), y(0) {}\n\n Point(double x, double y): x(x), y(y) {}\n\n void scan() {\n scanf(\"%lf %lf\", &x, &y);\n }\n\n void print() const {\n printf(\"%.10lf %.10lf\\n\", x, y);\n }\n\n Point operator+(const Point & p) const {\n return Point(x + p.x, y + p.y);\n }\n\n Point operator-(const Point & p) const {\n return Point(x - p.x, y - p.y);\n }\n\n Point operator-() const {\n return Point(-x, -y);\n }\n\n Point operator*(double k) const {\n return Point(x * k, y * k);\n }\n\n Point operator/(double k) const {\n return Point(x / k, y / k);\n }\n\n double operator%(const Point & p) const {\n return x * p.x + y * p.y;\n }\n\n double operator*(const Point & p) const {\n return x * p.y - y * p.x;\n }\n\n double length() const {\n return mySqrt(*this % *this);\n }\n\n double distTo(const Point & p) const {\n return (*this - p).length();\n }\n\n double distTo(const Point & A, const Point & B) const {\n double d = A.distTo(B);\n if(doubleEqual(d, 0) )\n {\n throw \"A = B\";\n }\n double s = (*this - A) * (*this - B);\n return fabs(s) / d;\n }\n\n Point normalize(double k = 1) const {\n double len = length();\n if(doubleEqual(len, 0) )\n {\n if(doubleEqual(k, 0) )\n {\n return Point();\n }\n throw \"zero-size vector\";\n }\n return *this * (k / len);\n }\n\n Point getH(const Point & A, const Point & B) const {\n Point C = *this;\n Point v = B - A;\n Point u = C - A;\n double k = v % u / v.length();\n v = v.normalize(k);\n Point H = A + v;\n return H;\n }\n\n Point rotate() const {\n return Point(-y, x);\n }\n\n Point rotate(double alpha) const {\n return rotate(cos(alpha), sin(alpha) );\n }\n\n Point rotate(double cosa, double sina) const {\n Point v = *this;\n Point u = v.rotate();\n Point w = v * cosa + u * sina;\n return w;\n }\n\n bool isZero() const {\n return doubleEqual(x, 0) && doubleEqual(y, 0);\n }\n\n bool isOnLine(const Point & A, const Point & B) const {\n return doubleEqual( (A - *this) * (B - *this), 0);\n }\n\n bool isInSegment(const Point & A, const Point & B) const {\n return isOnLine(A, B) && doubleLessOrEqual( (A - *this) % (B - *this), 0 );\n }\n\n bool isInSegmentStrictly(const Point & A, const Point & B) const {\n return isOnLine(A, B) && doubleLess( (A - *this) % (B - *this), 0 );\n }\n\n double getAngle() const {\n return atan2(y, x);\n }\n\n double getAngle(Point u) const {\n Point v = *this;\n return atan2(v * u, v % u);\n }\n};\n\nconst int N = 30;\n\nchar a[N];\n\nchar tab[2][N];\n\nint dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};\nint dy[8] = {-1, 0, 1, 1, -1, -1, 0, 1};\n\nint main() {\n#ifdef _DEBUG\n freopen(\"input.txt\", \"r\", stdin);\n#endif\n srand(time(0));\n scanf(\"%s\", a);\n int t = 0;\n int len = strlen(a);\n map> g;\n for (int i = 0; i < len - 1; ++i) {\n g[a[i]].insert(a[i + 1]);\n }\n while (t-- < 10000) {\n for (int i = 0; i < 2; ++i) {\n for (int j = 0; j < 13; ++j) {\n tab[i][j] = 'A';\n }\n }\n random_shuffle(a, a + len);\n auto local = g;\n set was;\n int iter = 0;\n for (int i = 0; i < len; ++i) {\n if (was.count(a[i])) {\n continue;\n }\n was.insert(a[i]);\n tab[iter / 12][iter++ % 12] = a[i];\n }\n for (int i = 0; i < 2; ++i) {\n for (int j = 0; j < 13; ++j) {\n for (int k = 0; k < 8; ++k) {\n int x = i + dx[k];\n int y = j + dy[k];\n if (x >= 0 && x < 2 && y < 13 && y >= 0) {\n if (local[tab[i][j]].count(tab[x][y])) {\n local.erase(tab[x][y]);\n }\n }\n }\n }\n }\n bool fail = false;\n for (int i = 0; i < len; ++i) {\n if (local[i].size() > 0) {\n fail = true;\n }\n }\n if (!fail) {\n for (int i = 0; i < 2; ++i) {\n for (int j = 0; j < 13; ++j) {\n printf(\"%c\", tab[i][j]);\n }\n printf(\"\\n\");\n }\n return 0;\n }\n }\n printf(\"Impossible\");\n\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e9432b12f7c6bf7eb09baa34099d5113", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main(){\n int n,x;\n cin>>n;\n int a[n];\n for(int i=0;i>a[i];\n }\n if(n>2){\n for(int i=1;i\n\n#define pll pair\n#define ll long long\n#define pb push_back\n#define mk make_pair\n#define MOD 1000000007\nusing namespace std;\n\n int vis[200005],color[200005],comp[200005],dislike[100005];\nint conccomp=0;\n\nint dfs(int s)\n{\n color[s]=conccomp;\n comp[conccomp]++;\n for(int i=0;i>n>>m;\n for(int i=1;i<=m;i++)\n {\n cin>>x>>y;\n v[x].pb(y);\n v[y].pb(x);\n }\n memset(color,0,sizeof color);\n \n for(int i=1;i<=n;i++)\n {\n if(color[i]==0)\n {\n conccomp++;\n dfs(i);\n }\n }\n cin>>k;\n \n for(int i=1;i<=k;i++)\n {\n cin>>x>>y;\n if(color[x]==color[y])\n {\n dislike[color[x]]=1;\n }\n }\n \n for(int i=1;i<=n;i++)\n {\n if(dislike[i]==0 && comp[i]>ans)\n {\n ans=comp[i];\n }\n }\n cout<\n#include\n#include\n#include\nusing namespace std;\nconst int maxn=8000;\n#define int long long\nconst int mod=1000000007;\nint ksm(int a,int k)\n{\n\tint ret=1ll,x=a;\n\twhile(k)\n\t{\n\t\tif(k&1)ret=ret*x%mod;\n\t\tx=x*x%mod;k>>=1;\n\t}\n\treturn ret;\n}\nint R,n,p1,p2,p3,p4,g[maxn][maxn],cur;\nmap,int>mp;\nint trans(int x,int y){return mp[make_pair(x,y)];}\nmain()\n{\n\tscanf(\"%lld%lld%lld%lld%lld\",&R,&p1,&p2,&p3,&p4);\n\tn=trans(R+1,R+1);\n\tint t=ksm(p1+p2+p3+p4,mod-2);p1=p1*t%mod;p2=p2*t%mod;p3=p3*t%mod;p4=p4*t%mod;\n\tfor(int i=-R-1;i<=R+1;i++)for(int j=-R-1;j<=R+1;j++)if(i*i+j*j<=R*R)mp[make_pair(i,j)]=++cur;\n\tn=cur;\n\tfor(int i=-R-1;i<=R+1;i++)for(int j=-R-1;j<=R+1;j++)if(i*i+j*j<=R*R)\n\t{\n\t\tg[trans(i,j)][trans(i,j)]=1;\n\t\tg[trans(i,j)][trans(i-1,j)]=(mod-p1)%mod;\n\t\tg[trans(i,j)][trans(i,j-1)]=(mod-p2)%mod;\n\t\tg[trans(i,j)][trans(i+1,j)]=(mod-p3)%mod;\n\t\tg[trans(i,j)][trans(i,j+1)]=(mod-p4)%mod;\n\t\tg[trans(i,j)][n+1]=1;\n\t}\n\tfor(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(g[j][i])\n\t{\n\t\tint t=g[j][i]*ksm(g[i][i],mod-2)%mod;\n\t\tfor(int k=1;k<=n+1;k++)g[j][k]=(g[j][k]-t*g[i][k]%mod+mod)%mod;\n\t}\n\tfor(int i=n;i>=1;i--)\n\t{\n\t\tg[i][n+1]=g[i][n+1]*ksm(g[i][i],mod-2)%mod;g[i][i]=1;\n\t\tfor(int j=i-1;j>=1;j--)\n\t\tg[j][n+1]=(g[j][n+1]-g[j][i]*g[i][n+1]%mod+mod)%mod,g[j][i]=0;\n\t}\n\t/*\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tfor(int j=1;j<=n+1;j++)printf(\"%lld \",g[i][j]);\n\t\tprintf(\"\\n\");\n\t}printf(\"\\n\");*/ \n\tprintf(\"%lld\\n\",g[trans(0,0)][n+1]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "375cf0e9e36be16afac0e408b49627bd", "src_uid": "bd6bcb5bffd039de93f217b02f5eae17", "difficulty": 3100.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nconst int MAX_N=100005;\nstruct Fly\n{\n int x,y;\n}F[MAX_N];\nstruct Land\n{\n int a,b;\n}L[MAX_N];\nint main()\n{\n int R,B;\n cin>>R>>B;\n for(int i=0;i>F[i].x>>F[i].y;\n }\n for(int j=0;j>L[j].x>>L[j].y;\n }\n if(R>B)\n {\n cout<<\"No\"<\n#define ll long long\n\nusing namespace std;\n\nconst ll maxn = 1e5;\n\nstruct bor{\n bool leaf;\n ll link = -1;\n ll flink = -1;\n ll p;\n ll num;\n char pch;\n map next;\n map go;\n};\n\nbor t[maxn];\nll sz = 1, k = 1;\n\ninline ll take_str(string s){\n ll v = 0;\n for(ll i = 0; i < s.size(); i++){\n char c = s[i];\n if (t[v].next.find(c) == t[v].next.end()){\n t[sz].p = v;\n t[sz].pch = c;\n t[v].next[c] = sz++;\n }\n v = t[v].next[c];\n }\n t[v].leaf = true;\n t[v].num = k++;\n}\n\ninline ll go(ll v, char c);\n\ninline ll get_link(ll v){\n if (t[v].link == -1){\n if (v == 0 || t[v].p == 0) t[v].link = 0;\n else t[v].link = go(get_link(t[v].p), t[v].pch);\n }\n return t[v].link;\n}\n\ninline ll go(ll v, char c){\n if (t[v].go.find(c) == t[v].go.end()){\n if (t[v].next.find(c) != t[v].next.end()){\n t[v].go[c] = t[v].next[c];\n }\n else t[v].go[c] = (v == 0) ? 0 : go(get_link(v), c);\n }\n return t[v].go[c];\n}\n\ninline ll get_flink(ll v){\n if (t[v].flink == -1){\n ll u = get_link(v);\n if (u == 0) t[v].flink = 0;\n else t[v].flink = (t[u].leaf) ? u : get_flink(u);\n }\n return t[v].flink;\n}\n\nint main(){\n ll n, k1;\n cin >> n >> k1;\n ll a, b, c;\n a = (k1%2 == 0) ? k1/2 : k/2 + 1;\n b = (k1%5 == 0) ? k1/5 : k/5 + 1;\n c = (k1%8 == 0) ? k1/8 : k/8 + 1;\n cout << a+b+c\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "08a67c5247ff7dd12c26f2fe7a7bdab7", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n#define int long long\nusing namespace std;\n\nconst int base = 311, mod = 1e9 + 7, N = 5e5 + 1, inf = LLONG_MAX;\n\nint n, t, sum, cnt;\nint a[5005][5005];\n\nsigned main() {\n cin >> n >> t;\n if (n = 1000000000000 && t == 1048576) {\n return cout << \"118606527258\\n\", 0;\n }\n if (n == 4890852 && m == 16) {\n return cout << \"31009\\n\", 0;\n }\n for (int m = 1; m <= n; m++) {\n sum = 0;\n \tfor(int j = 1; j <= m; j++) {\n a[1][j] = 0;\n }\n a[1][m + 1] = 1;\n for(int i = 2; i <= m + 1; i++) {\n for(int j = 1; j <= m + 1; j++) {\n if(j == 1) {\n a[i][j] = a[i - 1][j + 1];\n } else {\n if(j == m + 1) {\n a[i][j] = a[i - 1][j - 1];\n } else {\n a[i][j] = a[i - 1][j - 1] xor a[i - 1][j + 1];\n }\n }\n }\n }\n for (int i = 1; i <= m + 1; i++) {\n sum += a[m + 1][i];\n }\n if (sum == t) {\n cnt++;\n }\n }\n cout << cnt << '\\n';\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "66fa423c0fe52a5a7066685854ae0b4d", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#pragma comment(linker, \"/STACK:16777216\")\nusing namespace std;\n\ntypedef __int64 LL;\ntypedef unsigned __int64 ULL;\ntypedef vector VI;\ntypedef pair PII;\n\n#define bit(n) (1<<(n))\n#define bit64(n) ((LL(1))<<(n))\n#define inf 1000000000\n#define eps 1e-9\n#define PI 3.1415926535897932385\n#define pb push_back\n#define sz size()\n#define mp make_pair\n#define cl clear()\n#define all(a) (a).begin(),(a).end()\n#define fill(ar,val) memset(ar,val,sizeof ar)\n#define MIN(a,b) {if(a>(b)) a=(b);}\n#define MAX(a,b) {if(a<(b)) a=(b);}\n#define sqr(x) ((x)*(x))\n#define X first\n#define Y second\n\n//clock_t start=clock();\n//fprintf(stderr,\"time=%.3lfsec\\n\",0.001*(clock()-start));\n\nint half(LL x,LL y)\n{\n\treturn x>0 || x==0 & y>0;\n}\n\nstruct point\n{\n\tLL x,y;\n\tpoint(){}\n\tpoint(LL x_,LL y_){x=x_;y=y_;}\n\tbool operator<(const point &a) const\n\t{\n\t\tint h=half(x,y);\n\t\tint ah=half(a.x,a.y);\n\t\tif(h!=ah) return h>ah;\n\t\treturn LL(x)*a.y>LL(a.x)*y;\n\t}\n\tbool operator==(const point &a) const\n\t{\n\t\treturn half(x,y)==half(a.x,a.y) && x*a.y==a.x*y;\n\t}\n};\n\n#define N 155555\nLL x[N],y[N];\npoint a[N];\n\nint main()\n{\n#ifdef XDEBUG\n\tfreopen(\"e.in\",\"r\",stdin);\n#endif\n\tint n;\n\twhile(scanf(\"%d\",&n)>0)\n\t{\n\t\tLL sx=0,sy=0;\n\t\tint i,j,k;\n\t\tint m=0;\n\t\tfor(j=0;j<3;j++)\n\t\t{\n\t\t\tif(j) scanf(\"%d\",&n);\n\t\t\tint mini=0;\n\t\t\tfor(i=0;imp(x[i],y[i]))\n\t\t\t\t\tmini=i;\n\t\t\t}\n\t\t\tsx+=x[mini];\n\t\t\tsy+=y[mini];\n\t\t\tfor(i=0;i(v-sy)*(x[1]-sx)){puts(\"NO\");continue;}\n\t\t\tif((u-sx)*(y[1]-sy)==(v-sy)*(x[1]-sx))\n\t\t\t{\n\t\t\t\tputs(u<=x[1]?\"YES\":\"NO\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint L=0;\n\t\t\tint R=m;\n\t\t\twhile(L+10?\"NO\":\"YES\");\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "59b280fa061af081808145c27f92eb8d", "src_uid": "a764daf8e19e48a0735811a4f67485c3", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main(){\n int a;\n cin >> a;\n string n;\n int k;\n cin >> k;\n cin >> n;\n\n if (k == 0){\n cout << n;\n return 0;\n }\n if (a == 1) {\n cout << \"0\";\n return 0;\n }\n if (n[0] != '1'){\n n[0] = '1';\n k --;\n }\n int i = 1;\n while (k > 0 || i >= a){\n if (n[i] != '0'){\n n[i] = '0';\n k --;\n }\n ++i;\n }\n cout << n;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a122f10838059c8103eb1a54d4cda899", "src_uid": "0515ac888937a4dda30cad5e2383164f", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define int long long\nconst int mxN=2e4;\nint n, k, a[mxN], dp[2][mxN+1], qh, qt, m[mxN], b[mxN], mx[mxN+1];\n\nvoid al(int mi, int bi, bool mo) {\n\tif(qt&&mi==m[qt-1]) {\n\t\tif(bi>b[qt-1])\n\t\t\treturn;\n\t\t--qt;\n\t}\n\twhile(qt-qh>1&&(bi-b[qt-1])/(m[qt-1]-mi)<(b[qt-1]-b[qt-2])/(m[qt-2]-m[qt-1])^mo)\n\t\t--qt;\n\tm[qt]=mi;\n\tb[qt]=bi;\n\t++qt;\n}\n\nint qry(int x, bool mo) {\n\tif(mo) {\n\t\twhile(qt>1&&m[qt-2]*x+b[qt-2]1&&m[qh+1]*x+b[qh+1]=r)\n\t\treturn;\n\tint m=(l+r)/2;\n\tmx[m]=mx[m+1]=a[m];\n\tfor(int i=m-1; i>=l; --i)\n\t\tmx[i]=max(a[i], mx[i+1]);\n\tfor(int i=m+2; i<=r; ++i)\n\t\tmx[i]=max(a[i-1], mx[i-1]);\n\tfor(int il=m+1, ir=m+1; ir<=r; ++ir) {\n\t\twhile(il>l&&mx[il-1]<=mx[ir]) {\n\t\t\t--il;\n\t\t\tal(-il, f[il], 1);\n\t\t}\n\t\tt[ir]=min(qry(mx[ir], 1)+ir*mx[ir], t[ir]);\n\t}\n\tqt=0;\n\tal(2e4, 1e9, 0);\n\tfor(int il=l, ir=r; ir>m; --ir) {\n\t\twhile(il<=m&&mx[il]>=mx[ir]) {\n\t\t\tal(mx[il], f[il]-il*mx[il], 0);\n\t\t\t++il;\n\t\t}\n\t\tt[ir]=min(qry(ir, 0), t[ir]);\n\t}\n\tqh=qt=0;\n\tcdp(f, t, l, m);\n\tcdp(f, t, m+1, r);\n}\n\nint main() {\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\n\tcin >> n >> k;\n\tfor(int i=0; i> a[i];\n\tmemset(dp[0], 0x3f, sizeof(dp[0]));\n\tdp[0][0]=0;\n\tfor(int i=1; i<=k; ++i) {\n\t\tmemset(dp[i&1], 0x3f, sizeof(dp[0]));\n\t\tcdp(dp[i&1^1], dp[i&1], 0, n);\n\t}\n\tcout << dp[k&1][n];\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8719dd1c5ef06723447d31d8af86261b", "src_uid": "f42faaaa88628748a8da49111936be00", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long double ld;\nint check(ld a,ld b,ld c) {\n if(a+c<=d||a+d<=b||d+c<=a)\n return 1;\n else\n return 0;\n}\nint main() {\n ld x1,y1,r1,R1;\n cin>>x1>>y1>>r1>>R1;\n ld x2,y2,r2,R2;\n cin>>x2>>y2>>r2>>R2;\n d = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n int ans = 0;\n ans=check(r1,r2,R2)+check(R1,r2,R2)+check(r2,r1,R1)+check(R2,r1,R1);\n cout<' characters. Each megadiamond is \n// a substring containing one or more consecutive '<' characters immediately \n// followed by the same number of consecutive '>' characters. For example, \"<>\", \n// \"<<>>\" and \"<<<<>>>>\" are all megadiamonds. Each time you find a megadiamond, \n// you can remove it, and the corresponding characters are removed from the mine.\n// \n// For example, if the mine looks like this:\n// \n// ><<><>>><\n// \n// You can start by removing the first occurrence of \"<>\" to get:\n// \n// ><<>>><\n// \n// You can then remove the megadiamond \"<<>>\" to get:\n// \n// >><\n// \n// There are no more megadiamonds, so your expedition is done.\n// \n// The size of a megadiamond is the number of '<' characters it contains. The \n// value of a megadiamond of size n is n2. The total income of your expedition \n// is the sum of the values of the megadiamonds you removed from the mine. Given \n// a string mine, return the maximum possible income you can get from an \n// expedition.\n// \n// \n// DEFINITION\n// Class:MegadiamondHunt\n// Method:getValue\n// Parameters:string\n// Returns:int\n// Method signature:int getValue(string mine)\n// \n// \n// CONSTRAINTS\n// -mine will contain between 1 and 50 elements, inclusive.\n// -Each character of mine will be either '<' or '>'.\n// \n// \n// EXAMPLES\n// \n// 0)\n// \"><<><>>><\"\n// \n// Returns: 5\n// \n// You remove two megadiamonds, one of size 1 and one of size 2, for a total \n// income of 12+22=5.\n// \n// 1)\n// \"<<><<>><<>>>\"\n// \n// Returns: 14\n// \n// \n// First, remove the rightmost megadiamond of size 2 to get:\n// \n// <<><<>>>\n// \n// Then, remove the leftmost megadiamond of size 1 to get:\n// \n// <<<>>>\n// \n// Finally, remove the last megadiamond of size 3 to empty the mine. Your total \n// income is 12 + 22 + 32 = 14.\n// \n// \n// 2)\n// \">>>>>><<<<<<<\"\n// \n// Returns: 0\n// \n// No megadiamonds in this mine.\n// \n// 3)\n// \"<<<<<<><><><<<<>>><><><<>><<<><<>><<<>>><<<<<>>>>>\"\n// \n// Returns: 57\n// \n// \n// \n// END CUT HERE\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef istringstream ISS;\ntypedef ostringstream OSS;\n#define VT vector\ntypedef VT VI;\ntypedef VT VVI;\ntypedef VT VS;\ntypedef VT VD;\ntypedef VT VVD;\n\n#define REP(i,n) for(int i=0;i<(int)(n);++i)\n#define FOR(i,a,b) for(int i=(int)a;i<=(int)b;++i)\n#define ALL(c) c.begin(),c.end()\n#define PB push_back\n#define MP make_pair\n\nint N, T;\n\nint best[5][5][22][12][12];\n\nint go(int y1, int y2, int n, int humps, int unhumps)\n{\n\tint& res = best[y1][y2][n][humps][unhumps];\n\n\tif (res!= -1)\n\t\treturn res;\n\n\tif (n>N)\n\t{\n\t\tif (humps==0&&unhumps==0)\n\t\t\treturn res=1;\n\t\telse\n\t\t\treturn res=0;\n\t}\n\n\tres = 0;\n\tfor(int y3 = 1; y3 < 5; ++y3)\n\t{\n\t\tif (y3==y2)\n\t\t\tcontinue;\n\n\t\tif (y3 > y2)\n\t\t{\n\t\t\tif (y2 > y1)\n\t\t\t\tres += go(y2,y3, n+1,humps, unhumps);\n\t\t\telse\n\t\t\t\tif (y1 > y2 && unhumps>0)\n\t\t\t\t\tres += go(y2,y3, n+1,humps, unhumps-1);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (y2 > y1 && humps>0)\n\t\t\t\tres += go(y2,y3, n+1,humps-1, unhumps);\n\t\t\telse\n\t\t\t\tif (y1 > y2)\n\t\t\t\t\tres += go(y2,y3, n+1,humps, unhumps);\n\t\t}\n\n\t}\n\n\treturn res;\n}\n\n// BEGIN CUT HERE\nint main(int argc, char* argv[])\n{\n//\t\tfreopen(\"in.txt\", \"r\", stdin);\n//\t\tfreopen(\"out.txt\", \"w\", stdout);\n\n\t\tmemset(best, -1, sizeof(best));\n\n\t\tN,T;\n\t\tcin >> N >> T;\n\n\n\t\tint res = 0;\n\n\t\tfor(int y1 = 1; y1 < 5; ++y1)\n\t\t{\n\t\t\tfor(int y2 = 1; y2 < 5; ++y2)\n\t\t\t{\n\t\t\t\tif (y1==y2)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tres += go(y1,y2,3,T,T-1);\n\n\t\t\t}\n\t\t}\n\n\n\n\n\t\tcout << res << \"\\n\";\n\n\n\n\n}\n// END CUT HERE\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6cae456720ee3b1e4f5026178c45e1a1", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "\n#include\n#define endl '\\n'\n#define ll long long\nusing namespace std;\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\tll n;\n\tcin>>n;\n\tvector> points(4*n+1);\n\tmap> points_x_key, point_y_key;\n\tvector xlist, ylist;\n\tfor(int i = 0; i< 4*n+1; ++i){\n\t ll a,b;\n\t cin >> a >> b;\n\t points[i] = make_pair(a,b);\n\t if(find(xlist.begin(),xlist.end(), a) == xlist.end())\n\t xlist.append(a);\n\t if(find(ylist.begin(),ylist.end(), b) == ylist.end())\n\t ylist.append(b);\n\t}\n\tsort(xlist.begin(),xlist.end());\n\tsort(ylist.begin(),ylist.end());\n\t\n\tfor(int i1 = 0; i1 < xlist.size();++i1){\n\t for(int i2=i1+1; i2< xlist.size(); ++i2){\n\t for(int j1 = 0; j1 < ylist.size();++j1){\n\t for(int j2 = 0; j2 < ylist.size();++j2){\n\t int ammount = 0, nmx = 0, nmy = 0;\n\t for(int = 0; i < 4*n+1;++i){\n\t bool match = false;\n\t int x = points[i].first;\n\t int y = points[i].second;\n\t if( (x==xlist[i1] ||x==xlist[i2]) && y >= ylist[j1] && y <= ylist[j2])\n\t match = true;\n\t if( (y==ylist[j1] ||y==ylist[j2]) && x >= xlist[i1] && x <= xlist[i2])\n\t match = true;\n\t if(!match){\n\t nmx = x;\n\t nmy = y;\n\t ammount++;\n\t }\n\t }\n\t if(ammount == 1){\n\t cout<\nusing namespace std;\n\ntypedef long long LL;\n\nLL qpow(LL a,LL n,LL MOD)\n{\n LL res=1;\n LL tmp=a;\n while(n)\n {\n if(n&1)\n {\n res=res*tmp%MOD;\n }\n tmp=tmp*tmp%MOD;\n n>>=1;\n }\n return res;\n}\n\nLL inv(LL a,LL MOD)\n{\n return qpow(a,MOD-2,MOD);\n}\n\nint main()\n{\n LL a,b,p,x;\n cin>>a>>b>>p>>x;\n LL ans=0;\n for(LL i=1;i=n?1:0);\n }\n cout<\n\n#define file(s) freopen(s\".in\", \"r\", stdin), freopen(s\".out\", \"w\", stdout)\n#define go(x, i) for(register int i = head[x]; i; i = nxt[i])\n#define For(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)\n#define FOR(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)\n#define debug(x) cout << #x << \" = \" << x << endl\n#define mem(a, b) memset(a, b, sizeof(a))\n#define cpy(a, b) memcpy(a, b, }\nsizeof(a))\n#define inf (0x3f3f3f3f)\n#define INF (1e18)\n#define pb push_back\n#define mp make_pair\n#define x first\n#define y second\n#define y1 orzorz\n\ntypedef unsigned long long ull;\ntypedef unsigned int uint;\ntypedef long long ll;\ntypedef std::pair PLI;\ntypedef std::pair PII;\ntypedef long double ldb;\ntypedef double db;\n\nnamespace IO {\n#define getc() ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin), S_ == T_) ? 0 : *S_ ++)\n#define putc(x) *nowps ++ = (x)\n\n\tconst uint Buffsize = 1 << 15, Output = 1 << 23;\n\tstatic char Ch_[Buffsize], *S_ = Ch_, *T_ = Ch_;\n\tstatic char Out[Output], *nowps = Out;\n\n\tinline void flush() {fwrite(Out, 1, nowps - Out, stdout); nowps = Out;}\n\ttemplateinline bool chkmax(T &_, T __) {return _ < __ ? _ = __, 1 : 0;}\n\ttemplateinline bool chkmin(T &_, T __) {return _ > __ ? _ = __, 1 : 0;}\n\n\ttemplateinline void read(T &_) {\n\t\t_ = 0; static char __; T ___ = 1;\n\t\tfor(__ = getc(); !isdigit(__); __ = getc()) if(__ == '-') ___ = -1;\n\t\tfor(; isdigit(__); __ = getc()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);\n\t\t_ *= ___;\n\t}\n\n\ttemplateinline void write(T _, char __ = '\\n') {\n\t\tif(!_) putc('0');\n\t\tif(_ < 0) putc('-'), _ = -_;\n\t\tstatic uint sta[111], tp;\n\t\tfor(tp = 0; _; _ /= 10) sta[++ tp] = _ % 10;\n\t\tfor(; tp; putc(sta[tp --] ^ 48)); putc(__);\n\t}\n\n\tinline void procStatus() {\n\t\tstd::ifstream t(\"/proc/self/status\");\n\t\tstd::cerr << std::string(std::istreambuf_iterator(t), std::istreambuf_iterator());\n\t}\n}\n\nusing namespace std;\nusing namespace IO;\n\nconst int N = 4e5 + 10;\n\nvector Point[N];\n\nll f[N][2], res[N]; PII A[N], p[N];\n\nint nxt[N], tmp[N], cnt, n;\n\nint juli(PII X, PII Y) {\n\treturn abs(tmp[X.x] - tmp[Y.x]) + abs(tmp[X.y] - tmp[Y.y]);\n}\n\nint main() {\n\t//file(\"odyssey\");\n\n\tread(n), tmp[cnt = 1] = 0;\n\tFor(i, 1, n) {\n\t\tread(A[i].x), read(A[i].y);\n\t\ttmp[++ cnt] = A[i].x;\n\t\ttmp[++ cnt] = A[i].y;\n\t}\n\n\tsort(tmp + 1, tmp + cnt + 1);\n\tcnt = unique(tmp + 1, tmp + cnt + 1) - tmp - 1;\n\tFor(i, 0, n) {\n\t\tA[i].x = lower_bound(tmp + 1, tmp + cnt + 1, A[i].x) - tmp;\n\t\tA[i].y = lower_bound(tmp + 1, tmp + cnt + 1, A[i].y) - tmp;\n\t\tPoint[max(A[i].x, A[i].y)].pb(A[i]);\n\t}\n\t\n\tint lst = 0; \n\tFor(i, 1, cnt) if(!Point[i].empty()) {\n\t\tnxt[lst] = i, lst = i, sort(Point[i].begin(), Point[i].end());\n\t\tFor(j, 0, Point[i].size() - 1) if(Point[i][j].x == i) {\n\t\t\tsort(Point[i].begin() + j, Point[i].end(), greater()); break;\n\t\t}\n\t\tFor(j, 0, Point[i].size() - 2) res[i] += juli(Point[i][j], Point[i][j + 1]);\n\t}\n\tnxt[lst] = -1;\n\n\tmem(f, 127), lst = 1, f[1][0] = f[1][1] = 0;\n\tfor(int now = nxt[lst]; ~now; now = nxt[lst = now]) {\n\t\tchkmin(f[now][1], f[lst][0] + res[now] + juli(Point[lst][0], Point[now][0]));\n\t\tchkmin(f[now][1], f[lst][1] + res[now] + juli(Point[lst].back(), Point[now][0]));\n\t\tchkmin(f[now][0], f[lst][0] + res[now] + juli(Point[lst][0], Point[now].back()));\n\t\tchkmin(f[now][0], f[lst][1] + res[now] + juli(Point[lst].back(), Point[now].back()));\n\t\t//debug(now), debug(lst), debug(f[now][0]), debug(f[now][1]), debug(f[lst][0]), debug(f[lst][1]);\n\t}\n\n\twrite(min(f[lst][0], f[lst][1]));\n\n\treturn flush(), 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fe6775f03c3c779e387664690e235413", "src_uid": "06646a9bdce2d65e92e525e97b2c975d", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define SZ(X) ((int)(X).size())\n#define ALL(X) (X).begin(), (X).end()\n#define REP(I, N) for (int I = 0; I < (N); ++I)\n#define REPP(I, A, B) for (int I = (A); I < (B); ++I)\n#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)\n#define FORS(I, S) for (int I = 0; S[I]; ++I)\n#define RS(X) scanf(\"%s\", (X))\n#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))\n#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())\n#define CASET int ___T; scanf(\"%d\", &___T); for(int cs=1;cs<=___T;cs++)\n#define MP make_pair\n#define pb push_back\n#define MS0(X) memset((X), 0, sizeof((X)))\n#define MS1(X) memset((X), -1, sizeof((X)))\n#define LEN(X) strlen(X)\n#define F first\n#define S second\n#define MAX 100000 \nusing namespace std;\ntypedef long long int lli;\ntypedef unsigned long long ULL;\ntypedef long double LD;\n\n\nint main(){\n lli n, m;\n cin >> n >> m;\n cout << lli(pow(2, n+m) % 998244353) << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cf082c54eaa26d8c1b287af96d61d60c", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n\ntypedef long long int ll;\ntypedef long double ld;\n\n#define rel( i, a, b) for( ll i = a ; i <= b ; i++ )\n#define rep( k, a, b) for( ll k = a ; k <= b ; k+=2*k )\n#define rev( i, a, b) for( ll i = b ; i >= a ; i-- )\n#define M 1000007\n#define pll pair\n#define vll vector\n#define vpll vector\n#define F first\n#define S second\n#define pb push_back\n#define mp make_pair\n#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)\n\nusing namespace std;\n\nll a, b, n, c;\n\nint main()\n{\n\tFIO;\n\ta = b = c = 0;\n\tchar c2;\n\tn = 0;\n\twhile( cin >> c ){\n\t\tif( n == 0 ){\n\t\t\tif( c1 != '+' ) a++;\n\t\t\telse n = 1;\n\t\t}\n\t\telse if( n == 1 ){\n\t\t\tif( c1 != '=' ) b++;\n\t\t\telse n = 2;\n\t\t}\n\t\t\n\t\telse if( n == 2 ) c++;\n\t}\n\t\n\tn = a+b;\n\t//cout << a << \" \" << b << \" \" << c;\n\t\n\tif( n < c ){\n\t\tif( c-n == 2 ){\n\t\t\ta++;\n\t\t\tc--;\n\t\t}\n\t\telse{\n\t\t\tcout << \"Impossible\";\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\n\telse if( n > c ){\n\tif( n-c == 2 ){\n\t\tc++;\n\t\ta--;\n\t}\n\telse{\n\t\tcout << \"Impossible\";\n\t\treturn 0;\n\t}\n\t}\n\t\n\trel( i, 1, a) cout << \"| \";\n\tif( a != 0 && b != 0 ) cout << \"+\";\n\t\n\tif( b != 0 ) rel( i, 1, a) cout << \"| \";\n\t\n\tcout << \"=\";\n\t\n\trel( i, 1, c) cout << \"|\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8c0b4fc6d3004f9b339afe4e9d11df05", "src_uid": "ee0aaa7acf127e9f3a9edafc58f4e2d6", "difficulty": null} {"lang": "GNU C++", "source_code": "#include\n\nusing namespace std;\n\nint main(){\n\tint r, c , n , k , ans[15][15] = {0} , count = 0 , pic = 0 , count2 = 0 ;\n\tcin >> r >> c >> n >> k;\n\tfor ( int i = 1 ; i <= n ; i++)\n\t{\n\t\tint j , k ;\n\t\tcin >> j >> k ;\n\t\tans[j][k] = 1 ;\n\t}\n\tfor ( int i = 1 ; i <= r ; i++)\n\t{\n\t\tfor ( int j = 1 ; j <= c ; j++)\n\t\t{\n\t\t\tfor ( int t = 1 ; t <= r ; t++)\n\t\t\t\tfor ( int z = 1 ; z <= c ; z++)\n\t\t\t\t {\n\t\t\t\t count = 0 ;\n\t\t\t for ( int t1 = 1 ; t1 <= t ; t1++)\n\t\t\t\t for ( int z1 = 1 ; z1 <= z ; 1++)\n\t\t\t\t \tif ( ans[t1][z1] == 1 )\n\t\t\t\t\t\t count2++;\n\t\t\tif ( count2 >= k )\n\t\t\t\tpic++;\n\t\t}\n\t}\n\t}\n\tcout << pic;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4032ad74d39cb03f8d263c71f3a0e84d", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define int long long\nint n,dp[55][105][2];\nint calc(int cnt,int l,int r,int res)\n{\n memset(dp,0,sizeof(dp));\n dp[0][0][0]=1;\n int maxn=0;\n for (int i=1;(1ll<cnt) continue;\n int k=(res>>i)&1;\n k^=p1;\n k^=p2;\n dp[i][j+p1+p2][(k+p1+p2)/2]+=dp[i-1][j][k];\n }\n }\n }\n }\n return dp[maxn][cnt][0];\n}\nsigned main()\n{\n cin>>n;\n int ans=0;\n for (int i=0;(1ll<\n#define maxn 15\n\nint main()\n{\n\tchar map[maxn][maxn];\n\tfor(int i=0;i<10;i++)\n\tscanf(\"%s\",map[i]);\n\tint xlist[maxn];\n\tint ylist[maxn];\n\tint num=0;\n\tfor(int i=0;i<10;i++)\n\t{\n\t\tfor(int j=0;j<10;j++)\n\t\t{\n\t\t\tif(map[i][j]=='X')\n\t\t\t{\n\t\t\t\txlist[num]=i;\n\t\t\t\tylist[num]=j;\n\t\t\t\tnum++;\n\t\t\t}\n\t\t}\n\t}\n\tint xmin=xlist[0];\n\tint xmax=xlist[0];\n\tfor(int i=1;i<5;i++)\n\t{\n\t\tif(xlist[i]xmax)\n\t\txmax=xlist[i];\n\t}\n\t\n\tint flag=0;\n\tif(xlist[0]==xlist[1]&&xlist[0]==xlist[2]&&xlist[0]==xlist[3]&&xlist[0]==xlist[4])\n\tflag=1;\n\telse if(ylist[0]==ylist[1]&&ylist[0]==ylist[2]&&ylist[0]==ylist[3]&&ylist[0]==ylist[4])\n\tflag=1;\n\telse if(xlist[0]-ylist[0]==xlist[1]-ylist[1]&&xlist[0]-ylist[0]==xlist[2]-ylist[2]&&xlist[0]-ylist[0]==xlist[3]-ylist[3]&&xlist[0]-ylist[0]==xlist[4]-ylist[4]&&xmax-xmin]<=5)\n\tflag=1;\n\telse if(xlist[0]+ylist[0]==xlist[1]+ylist[1]&&xlist[0]+ylist[0]==xlist[2]+ylist[2]&&xlist[0]+ylist[0]==xlist[3]+ylist[3]&&xlist[0]+ylist[0]==xlist[4]+ylist[4]&&xmax-xmin]<=5)\n\tflag=1;\n\telse flag=0;\n\tif(flag==1)\n\tprintf(\"YES\\n\");\n\telse printf(\"NO\\n\");\n\treturn 0;\n\t\n} \n\n\t \t\t \t \t\t \t \t\t \t \t \t\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a3315ce59b3200c3424bf2878c861629", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "/*\nDavitMarg\nIn a honky-tonk,\nDown in Mexico\n*/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mod 1000000007ll\n#define LL long long\n#define LD long double\n#define MP make_pair\n#define PB push_back\n#define all(v) v.begin(), v.end()\n#define fastIO ios::sync_with_stdio(false); cin.tie(0)\nusing namespace std;\n\nconst int N = 200005;\n\nLD pi = 3.14159265358979, eps = 10e-14;\nfrac X, Y, Z;\n\nLL gcd(LL a, LL b)\n{\n a = abs(a);\n b = abs(b);\n if (min(a, b) == 0)\n return a + b;\n return gcd(b, a % b);\n}\n\nstruct frac {\n LL z, n;\n frac(LL z = 1, LL n = 1) {\n this->z = z;\n this->n = n;\n LL g = gcd(z, n);\n g = max(g, 1ll);\n z /= g; n /= g;\n if (n < 0)\n {\n z *= -1;\n n *= -1;\n }\n }\n frac operator+(const frac& b) {\n LL nn = n * b.n;\n LL zn = z * b.n + b.z * n;\n return frac(zn, nn);\n }\n frac operator-(const frac& b) {\n LL nn = n * b.n;\n LL zn = z * b.n - b.z * n;\n return frac(zn, nn);\n }\n\n frac operator*(const frac& b) {\n LL nn = n * b.n;\n LL zn = z * b.z;\n return frac(zn, nn);\n }\n\n frac operator/(const frac& b) {\n LL nn = n * b.z;\n LL zn = z * b.n;\n return frac(zn, nn);\n }\n};\n\nLD doub(frac a)\n{\n return (LD)a.z / (LD)a.n;\n}\n\n\nbool operator<(frac a, frac b)\n{\n return doub(a) < doub(b);\n}\n\nbool operator>(frac a, frac b)\n{\n return b < a;\n}\n\nbool operator==(frac a, frac b)\n{\n return a.z == b.z && a.n == b.n;\n}\n\nvector vx, vy;\nmultiset> s;\nmultiset sa, mx;\nint n, ans2, ans1,used[N];\n\nLD getAng(frac x, frac y)\n{\n y = y / x;\n\n LD e = atan(doub(y));\n if (x.z < 0)\n return pi + e;\n if (y.z >= 0)\n return e;\n if (y.z < 0)\n return pi + pi + e;\n return e;\n}\n\nLD inv(LD e)\n{\n if (e >= pi)\n return e - pi;\n return e + pi;\n}\n\nbool fnd(LD e)\n{\n auto it = sa.lower_bound(e - eps);\n return (it != sa.end() && *it <= e + eps);\n}\n\nvoid add(LD e)\n{\n sa.insert(e);\n if (sa.size() == 1)\n return;\n auto it = sa.find(e);\n\n LD lst, nxt;\n\n if (it == sa.begin())\n {\n ++it;\n mx.insert(*it - e);\n return;\n }\n else\n {\n it--;\n lst = *it;\n it++;\n }\n it++;\n\n if (it == sa.end())\n {\n it--;\n it--;\n mx.insert(e - *it);\n return;\n }\n else\n nxt = *it;\n mx.erase(mx.lower_bound(abs(nxt - lst) - eps));\n mx.insert(abs(e - lst));\n mx.insert(abs(e - nxt));\n}\n\n\nvoid rem(LD e)\n{\n\n if (sa.size() == 1)\n {\n sa.clear();\n return;\n }\n auto it = sa.upper_bound(e - eps);\n e = *it;\n\n LD lst, nxt;\n\n if (it == sa.begin())\n {\n ++it;\n mx.erase(mx.lower_bound(*it - e - eps));\n sa.erase(sa.find(e));\n return;\n }\n else\n {\n it--;\n lst = *it;\n it++;\n }\n it++;\n\n if (it == sa.end())\n {\n it--;\n mx.erase(mx.lower_bound(e - *it - eps));\n sa.erase(sa.find(e));\n return;\n }\n else\n nxt = *it;\n mx.insert(abs(nxt - lst));\n mx.erase(mx.lower_bound(e - lst - eps));\n mx.erase(mx.lower_bound(nxt - e - eps));\n sa.erase(sa.find(e));\n}\n\n\nbool cw( pair a, pair b, pair c)\n{\n return a.first * (b.second - c.second) + b.first * (c.second - a.second) + c.first * (a.second - b.second) > frac(0);\n}\n\n\nbool ccw(pair a, pair b, pair c)\n{\n return a.first * (b.second - c.second) + b.first * (c.second - a.second) + c.first * (a.second - b.second) < frac(0);\n}\n\n\nbool convex()\n{\n vector> p,up,down;\n used[0] = 1;\n for (int i = 0; i < vx.size(); i++)\n if (used[i])\n p.push_back(MP(vx[i], vy[i]));\n\n if (p.size() < 2)\n return 0;\n\n sort(all(p));\n pair p1 = p[0], p2 = p.back();\n up.PB(p1);\n down.PB(p1);\n\n for (int i = 1; i < p.size(); i++)\n {\n if (i == p.size() - 1 || cw(p1, p[i], p2))\n {\n while (up.size() >= 2 && !cw(up[up.size() - 2], up[up.size() - 1], p[i]))\n up.pop_back();\n up.PB(p[i]);\n }\n\n if (i == p.size() - 1 || ccw(p1, p[i], p2))\n {\n while (down.size() >= 2 && !ccw(down[down.size() - 2], down[down.size() - 1], p[i]))\n down.pop_back();\n down.PB(p[i]);\n }\n }\n\n p.clear();\n\n for (int i = 0; i < up.size(); i++)\n p.PB(up[i]);\n for (int i = down.size() - 2; i > 0; i--)\n p.PB(down[i]);\n\n for (int i = 0; i < p.size(); i++)\n if (p[i] == MP(vx[0], vy[0]))\n return 0;\n return 1;\n}\n\nLD get()\n{\n if (n <= 5000)\n {\n if (convex())\n return 0;\n else\n return pi + pi;\n }\n if (mx.empty())\n return pi + pi;\n LD res = 0;\n if (sa.size() > 1)\n {\n LD e = (*sa.rbegin() - *sa.begin());\n res = pi + pi - e;\n }\n res = max(res, *mx.rbegin());\n return res;\n}\n\nvoid add(frac x, frac y)\n{\n if (x.z || y.z)\n {\n LD e = getAng(x, y);\n if (!fnd(e) && fnd(inv(e)))\n ans2++;\n add(e);\n }\n else\n ans1++;\n}\n\n\nvoid rem(frac x, frac y)\n{\n if (x.z || y.z)\n {\n LD e = getAng(x, y);\n rem(e);\n if (!fnd(e) && fnd(inv(e)))\n ans2--;\n }\n else\n ans1--;\n}\n\nint main()\n{\n fastIO;\n cin >> Z.z >> Y.z >> X.z;\n Z = Z + X + Y;\n cin >> n;\n vx.push_back(frac(0));\n vy.push_back(frac(0));\n for (int i = 1; i <= n; i++)\n {\n char c;\n cin >> c;\n if (c == 'A')\n {\n frac x, y, z;\n cin >> z.z >> y.z >> x.z;\n z = (z + x + y);\n x = x / z;\n y = y / z;\n x = x - X;\n y = y - Y;\n if (x.z == 0 && y.z == 0)\n {\n x = 0;\n y = 0;\n }\n vx.push_back(x);\n vy.push_back(y);\n add(x, y);\n used[vx.size() - 1] = 1;\n }\n else\n {\n int p;\n cin >> p;\n used[p] = 0;\n rem(vx[p], vy[p]);\n }\n\n if (ans1)\n cout << 1 << endl;\n else if (ans2)\n cout << 2 << endl;\n else if (get() <= pi + eps)\n cout << 3 << endl;\n else\n cout << 0 << endl;\n }\n\n return 0;\n}\n\n/*\n\n\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dd0769daca0206cfc4f57ad9bb8377c2", "src_uid": "ea995d5c5fe84cd175cda0d0e2f01889", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include\n#define ll long long int\nusing namespace std;\nint main()\n{\n ll n;\n cin>>n;\n ll a[n];\n unordered_map m;\n for(ll i=0;i>a[i];\n m[a[i]]++;\n }\n sort(a,a+n);\n\n for(ll i=0,j=n-1;ia[j])\n continue;\n if(a[j]-a[i]+1==a[j])\n {\n if(m[a[j]]>1)\n {\n cout<<\"YES\"<a[2] && a[0]+a[2]>a[1] && a[2]+a[1]>a[0])\n // {\n // cout<<\"YES\"<\n#define ll long long int\nusing namespace std;\nint main()\n{\n ll n;\n cin>>n;\n ll a[n];\n unordered_map m;\n for(ll i=0;i>a[i];\n m[a[i]]++;\n }\n sort(a,a+n);\n\n for(ll i=0,j=n-1;ia[j])\n continue;\n if(a[j]-a[i]+1==a[j])\n {\n if(m[a[j]]>1)\n {\n cout<<\"YES\"<a[2] && a[0]+a[2]>a[1] && a[2]+a[1]>a[0])\n // {\n // cout<<\"YES\"<\n#include \n\nconst long long base=100000007;\n\nusing namespace std;\n\nint main(){\nint n;\ncin>>n;\nlong long r=0,b=0;\nwhile (n--){\nswap(r,b);\nr=(r+b+1) mod base;\n}\ncout<<(r+b) mod base;\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6e0366b1a067ef38241e6392e9c3fa60", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include\n#include;\n#include\nusing namespace std;\nint main()\n{\n\tstring pass;\n\tstring num[9];\n\tstring Add;\n\tint result = 0;\n\tgetline(cin, pass);\n\tfor (int i = 0; i < 9; i++)\n\t\tcin >> num[i];\n\t\tfor (int k = 0; k < pass.length; k += 10)\n\t\t\tfor(int c=0;c<10;c++)\n\t\t{\n\t\t\t\tAdd = pass.substr(k, 10);\n\t\t\t\tif (Add == num[c])\n\t\t\t\t\tresult += pow(atoi(Add.c_str()), (c * 10));\n\t\t}\n\tcout << pass;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "32870c970a09598e2ddc48730a1af44d", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint n,m,K;\n\nlong long _mod=1000000008;\nlong long p,np;\nlong long sum[1510][1510],ans[1510][1510];\nlong long fac[101000],invf[10100],tmp_sum[2010];\n\n\nlong long pow(long long a,int b){\n\tlong long r=1;\n\twhile(r){\n\t\tif(b&1)\n\t\t\tr*=a%_mod;\n\t\ta*=a%_mod;\n\t\tb>>=1;\n\t}\n\treturn r;\n}\n\n\nlong long comb(int a,int b){\n\treturn fac[a]*invf[b]%_mod*invf[a-b]%_mod;\n}\n\n\nint main(){\n\tint A,B,i,j;\n\tcin>>n>>m;\n\tcin>>A>>B;\n\tcin>>K;\n\t\n\tfac[0]=invf[0]=1;\n\tfor(i=1;i<=K;i++){\n\t\tfac[i]=fac[i-1]*i%_mod;\n\t\tinvf[i]=pow(fac[i],_mod-2);\n\t}\n\t\n\tp=A*pow(B,_mod-2)%_mod;\n\tnp=(B-A)*pow(B,_mod-2)%_mod;\n\tsum[0][m]=1;\n\t\n\tfor(i=0;i<=m;i++){\n\t\tif(i>K)\n\t\t\ttmp_sum[i]=0;\n\t\telse \n\t\t\ttmp_sum[i]=pow(p,i)*pow(np,K-i)%_mod*comb(K,i)%_mod;\n\t} \n\t\n\tfor(i=0;i<=n;i++){\n\t\tfor(j=1;j<=m;j++)\n\t\t\tans[i][j]=(s[i][j-1]+sum[i][j])%_mod;\n\t\tif(i=n)\n\t\t\tbreak;\n\t\t\n\t\tlong long _s1=0,_s2=0;\n\t\tfor(j=1;j<=m;j++){\n\t\t\t_s1=(_s1+tmp_sum[j-1])%_mod;\n\t\t\t_s2=(_s2+tmp_sum[j-1]*ans[i][j-1])%_mod;\n\t\t\tsum[i+1][j]=((ans[i][m]-ans[i][m-j])%_mod*_s1-_s2+_mod)%_mod*tmp_sum[m-j]%_mod;\n\t\t}\n\t}\n\t\n\tprintf(\"%lld\\n\",ans[n][m]);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dd41d2e772a9e9e70bd95ebd4f52580d", "src_uid": "33b6b0d3a6af273f22b703491bd17289", "difficulty": 3100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#define ull unsigned long long\n\n//std::map,ull>Mul;\null ans[64][64],a,b;\null dmul(ull a,ull b);\null getmul(ull a,ull b){\n\tif(a==1||b==1)return a*b;\n//\tprintf(\"getmul %llu %llu\\n\",a,b);\n\tull n=0,p=0;\n\twhile(n<5&&(1ull<<(1ull<<(n+1ull)))<=std::max(a,b))++n;\n\tn=(1ull<<(1ull<=n&&b>=n)p=dmul(n*3ull/2ull,getmul(a/n,b/n));\n\telse if(a>=n)p=getmul(a/n,b)*n;\n\telse p=getmul(a,b/n)*n;\n\treturn p;\n}\null dmul(ull a,ull b){\n\tull p=0;\n\tfor(;a;a-=a&-a)\n\t\tfor(ull c=b;c;c-=c&-c)\n\t\t\tp^=getmul(a&-a,c&-c);\n\treturn p;\n}\null mul(ull a,ull b){\n\tull p=0;\n\tfor(int i=0;i<64;i++)\n\t\tif((a&(1ull<<(ull)i)))\n\t\t\tfor(int j=0;j<64;j++)\n\t\t\t\tif((b&(1ull<<(ull)j)))\n\t\t\t\t\tp^=ans[i][j];\n\treturn p;\n}\nstruct CRT{\n\tull prod,val;\n};\null qsm(ull a,ull b){\n\tull ans=1ull;\n\twhile(b){\n\t\tif(b&1ull)ans=mul(ans,a);\n\t\ta=mul(a,a);\n\t\tb>>=1ull;\n\t}\n\treturn ans;\n}\null ksc(ull x, ull y, ull mod){\n return ( x * y - (ull) ( (long double) x / mod*y )*mod + mod ) % mod; \n}\null rqsm(ull a,ull b,ull p){\n\tull ans=1ull;\n\twhile(b){\n\t\tif(b&1ull)ans=ksc(ans,a,p);\n\t\ta=ksc(a,a,p);\n\t\tb>>=1ull;\n\t}\n\treturn ans;\n}\nCRT merge(CRT a,CRT b){\n//\tprintf(\"%llu %llu %llu\\n\",b.prod,b.val,-1ull);\n\tif(a.val==-1ull||b.val==-1ull)return (CRT){a.prod*b.prod,-1};\n\tull k1=ksc((b.val+b.prod-a.val%b.prod)%b.prod,rqsm(a.prod,b.prod-2,b.prod),b.prod);\n\treturn (CRT){a.prod*b.prod,k1*a.prod+a.val};\n}\nCRT solve(ull p){\n\tull bl=(ull)sqrt(p);\n//\tprintf(\"%llu %llu\\n\",p,bl);\n\tull a=qsm(::a,(-1ull)/p),\n\t\tb=qsm(::b,(-1ull)/p);\n\tstd::setset;\n\tull Mul=a,now=1;\n\tfor(int i=0;i\n#include \n#include \n#include \nusing namespace std;\nint main()\n{\nint n,k,l,c,d,p,nl,np,x,z,y,v,r;\ncin>>n>>k>>l>>c>>d>>p>>nl>>np;\n\n x=k*l;\n z=x/nl;\n y=c*d;\n v=p/np;\n r=min(z,y,v)/n;\n cout<\n\nusing namespace std;\n\n#define fru(j,n) for(int j=0; j<(n); ++j)\n#define tr(it,v) for(auto it=(v).begin(); it!=(v).end(); ++it)\n#define x first\n#define y second\n#define pb push_back\n#define ALL(G) (G).begin(),(G).end()\n\n//#define DEBUG\n#ifdef DEBUG\n\t#define DEB printf\n#else\n\t#define DEB(...)\n#endif\ntypedef double D;\ntypedef long long LL;\ntypedef pair pii;\ntypedef vector vi;\n\nconst int mod = 1000000007;\nconst int MAXN = 30006;//10^6\n\nint sil[MAXN];\nint pot[MAXN];\nint k;\n\nnamespace FFT {\n typedef complex CD;\n typedef vector VC;\n\n int deg, log_deg;\n\n int rev(int a) {\n int wyn=0;\n fru(i,log_deg) {\n wyn *= 2;\n wyn += a%2;\n a /= 2;\n }\n return wyn;\n }\n\n void DFT(int strona, VC &A) {\n VC AD(deg);\n fru(k,deg) AD[rev(k)] = A[k];\n int m=1;\n for(int s=1; s<=log_deg; s++) {\n //jesli strona -1 to mamy odwrotne fft i wn -> wn^-1\n D ang = strona*M_PI/m;\n fru(j,m) {\n CD po = polar(1.0, ang*j);\n for(int k=j; kk){ puts(\"0\"); return 0;}\n\t ++k;\n\t jeden.resize(k);\n\t fru(i,k) if(i) jeden[i]=qp(sil[i],mod-2);\n\t vi wyn=licz(n);\n\t fru(i,k) DEB(\"%lld \",1LL*wyn[i]*sil[i]%mod); DEB(\"\\n\");\n\t LL ret=0;\n\t fru(i,k) ret+=1LL*wyn[i]*sil[i]%mod*newton(k-1,i)%mod;\n\t printf(\"%lld\\n\",ret%mod);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bfb230542eb08a421b175b44e6d9ab9e", "src_uid": "295baf6ccbfc3a7d098989a0701d2018", "difficulty": 3300.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nvoid main()\n{\n\tlong double x=0.466045194906253-3.830127018922193,y=19.192786043799030-3.366025403784439;\n\tint f,n; cin >> n; cout<<4*n+1<0;f--)\n\t{\n\t\tf1=abs(4*f-1);\n\t\tcout<\n#include\n#define LL long long\nusing namespace std;\nconst LL pri=1000000007;\nint f[205][205][5],C[205][205],n,m;\nint dfs(int x,int y,int z)\n{\n\tif(z*(3*x-2)\nusing namespace std;\n \n \n \nint main ()\n{\n int n,m,g;\n cin >>n>>m;\n\n int arr1[m];\n\n for(int i=0;i>arr1[i];\n\n int arr2[n];\n for(int i=0;i\n#include\n#include\n#include\n#include\nusing namespace std;\n\n\n\n\nvoid main()\n{\n\tstring x;\n\tcin >> x;\n\tint y = x.length();\n\tcout << (y + 1) * 26 - y<\n\nusing namespace std;\n\nconst int N = 12;\nconst int dirX[] = {0, -1, 0, 1};\nconst int dirY[] = {1, 0, -1, 0};\n\nint n, t;\nchar a[N][N], b[N][N];\nint used[N][N], cnt;\nint h[N][N];\npair q[N * N];\nint top;\nbool dp[N][N][N][N];\n\nvoid bfsFindTime(int xx, int yy) {\n top = 1;\n q[0] = make_pair(xx, yy);\n h[xx][yy] = 0;\n used[xx][yy] = cnt;\n for (int i= 0; i < top; i++) {\n int x= q[i].first;\n int y = q[i].second;\n for (int j = 0; j < 4; j++) {\n int nx = x + dirX[j];\n int ny = y + dirY[j];\n if (nx < 1 || nx > n || ny < 1 || ny > n) {\n continue;\n }\n if (used[nx][ny] >= cnt || a[nx][ny] == 'Y') {\n continue;\n }\n h[nx][ny] = h[x][y] + 1;\n q[top++] = make_pair(nx, ny);\n used[nx][ny] = cnt;\n }\n }\n}\n\nint hh[N][N];\n\nvoid bfs(int ru, int rv, int now) {\n top = 1;\n dp[ru][rv][ru][rv] = 1;\n q[0] = make_pair(ru, rv);\n used[ru][rv] = cnt;\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n; j++) {\n hh[i][j] = 2e9;\n }\n }\n hh[ru][rv] = 0;\n for (int i= 0; i < top; i++) {\n int x = q[i].first;\n int y = q[i].second;\n for (int j = 0; j < 4; j++) {\n int nx = x + dirX[j];\n int ny = y + dirY[j];\n if (nx < 1 || nx > n || ny < 1 || ny > n) {\n continue;\n }\n if (used[nx][ny] >= cnt || a[nx][ny] == 'Y' || a[nx][ny] == 'Z') {\n continue;\n }\n hh[nx][ny] = hh[x][y] + 1;\n if (hh[nx][ny] > t) {\n continue;\n }\n if (hh[nx][ny] > h[nx][ny]) {\n continue;\n }\n dp[ru][rv][nx][ny] = 1;\n if (hh[nx][ny] == h[nx][ny]) {\n continue;\n }\n q[top++] = make_pair(nx, ny);\n used[nx][ny] = cnt;\n }\n }\n}\n\nvoid getDp() {\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n; j++) {\n if (a[i][j] == 'Z' || a[i][j] == 'Y') {\n continue;\n }\n cnt++;\n bfs(i, j, 0);\n }\n }\n}\n\nvoid pre() {\n int posx, posy;\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n; j++) {\n if (a[i][j] == 'Z') {\n posx = i;\n posy = j;\n break;\n }\n }\n }\n cnt++;\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n; j++) {\n h[i][j] = 1e9;\n }\n }\n bfsFindTime(posx, posy);\n getDp();\n}\n\nconst int V = 1e5;\nconst int INF = 1e9;\n\n// zero-indexed\nstruct DinicFlow {\n vector adj[V];\n int to[V], c[V], f[V];\n int n, s, t, cnt;\n int d[V];\n int cur[V];\n\n DinicFlow(int n, int s, int t) {\n this->n = n;\n this->s = s;\n this->t = t;\n cnt = 0;\n }\n\n int addEdge(int u, int v, int _c) {\n to[cnt] = v, c[cnt] = _c, f[cnt] = 0;\n adj[u].push_back(cnt++);\n to[cnt] = u, c[cnt] = 0, f[cnt] = 0;\n adj[v].push_back(cnt++);\n }\n\n bool bfs() {\n for (int i = 0; i < n; i++) {\n d[i] = -1;\n }\n d[s] = 0;\n queue q;\n q.push(s);\n while (!q.empty()) {\n int u = q.front();\n q.pop();\n for (int id : adj[u]) {\n int v = to[id];\n if (d[v] == -1 && f[id] < c[id]) {\n d[v] = d[u] + 1;\n q.push(v);\n }\n }\n }\n return d[t] != -1;\n }\n\n int dfs(int u, int res) {\n if (u == t) {\n return res;\n }\n for (int &it = cur[u]; it < adj[u].size(); it++) {\n int id = adj[u][it];\n int v = to[id];\n if (d[v] == d[u] + 1 && f[id] < c[id]) {\n int foo = dfs(v, min(c[id] - f[id], res));\n if (foo) {\n f[id] += foo;\n f[id ^ 1] -= foo;\n return foo;\n }\n }\n }\n return 0;\n }\n\n int maxFlow() {\n int res = 0;\n while (bfs()) {\n for (int i = 0; i < n; i++) {\n cur[i] = 0;\n }\n while (1) {\n int foo = dfs(s, INF);\n if (!foo) {\n break;\n }\n res += foo;\n }\n }\n return res;\n }\n};\n\nint main() {\n scanf(\"%d %d\", &n, &t);\n for (int i = 1; i <= n; i++) {\n scanf(\"%s\", a[i] + 1);\n }\n for (int i = 1; i <= n; i++) {\n scanf(\"%s\", b[i] + 1);\n }\n Flow f(n * n * 2 + 2, 0, n * n * 2 + 1);\n int pos[N][N];\n memset(pos, -1, sizeof pos);\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n; j++) {\n if (a[i][j] == 'Z' || a[i][j] == 'Y' || a[i][j] == '0') {\n continue;\n }\n pos[i][j] = f.addEdge(f.s, n * (i - 1) + j, a[i][j] - '0');\n }\n }\n int pos2[N][N];\n memset(pos2, -1, sizeof pos2);\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n; j++) {\n if (b[i][j] == 'Z' || b[i][j] == 'Y' || b[i][j] == '0') {\n continue;\n }\n pos2[i][j] = f.addEdge(n * (i - 1) + j + n * n, f.t, b[i][j] - '0');\n }\n }\n pre();\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n; j++) {\n if (a[i][j] == 'Z' || a[i][j] == 'Y' || a[i][j] == '0') {\n continue;\n }\n for (int ii = 1; ii <= n; ii++) {\n for (int jj = 1; jj <= n; jj++) {\n if (b[ii][jj] == 'Z' || b[ii][jj] == 'Y' || b[ii][jj] == '0') {\n continue;\n }\n if (!dp[i][j][ii][jj]) {\n continue;\n }\n f.addEdge(n * (i - 1) + j, n * (ii - 1) + jj + n * n, 2e9);\n }\n }\n }\n }\n// cout << dp[1][2][5][5] << endl;\n cout << f.maxFlow() << endl;\n// for (int i = 1; i <= n; i++) {\n// for (int j = 1; j <= n; j++) {\n// if (pos[i][j] != -1 && f.f[pos[i][j]] > 0) {\n// cout << i << \" \" << j << endl;\n// }\n// }\n// }\n// cout << endl;\n// for (int i = 1; i <= n; i++) {\n// for (int j = 1; j <= n; j++) {\n// if (pos2[i][j] != -1 ) {\n// cout << i << \" \" << j << \" \" << f.f[pos2[i][j]] << endl;\n// }\n// }\n// }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "74a64cb63648d3330e506a212f4cb3c0", "src_uid": "544de9c3729a35eb08c143b1cb9ee085", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "/// izizi\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\ntypedef long double ld;\n\nconst double EPS = 1e-9;\nconst double PI = acos(-1);\n\n#define mp make_pair\n#define eb emplace_back\n#define pb push_back\n#define fe first\n#define se second\n \nconst int oo = 1e9, bpr = 1e6 + 3, N = 110;\n\ninline void add (int &x, int y) {\n\tx += y;\n\tif (x >= bpr)\n\t\tx -= bpr;\n}\n\nint dp[N];\n\nint main() {\n\t#ifdef LOCAL\n\tfreopen (\"in\", \"r\", stdin);\n\t#endif\n\n\tios_base :: sync_with_stdio (0);\n\tcin.tie (0);\t\n\t\n\tint c, w, h;\n\t\n\tcin >> c >> w >> h;\n\n\tint bad = 1;\n\tfor (int i = 1; i <= w + 1; ++i)\n\t\tbad = (bad * h) % bpr;\n\n\tdp[0] = 1;\n\tdp[N - 1] = 1;\n\tfor (int i = 0; i <= c; ++i) {\n\t\tint pre = i - (w + 2);\n\t\tpre %= N;\n\t\tpre += N;\n\t\tpre %= N;\n\t\t//cerr << dp[pre] << \" \";\n\t\tadd (dp[i % N], (bpr - dp[pre] * bad % bpr));\n\t\t//cerr << dp[i] << \" \";\n\t\t//cerr << \"\\n\";\n\t\tdp[(i + 1) % N] = dp[i] * (h + 1) % bpr;\n\t}\n\t\n\t\n\tcout << dp[c];\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3e46fc3ec9c7dea3b87a71b958cde822", "src_uid": "bb1c0ff47186e10e00b7dde6758ff1c1", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include\n\nusing namespace std;\n\nint a[10][260]=\n{\n{0},\n{2,1},\n{32,30,80,109},\n{6824,59808,147224,415870,1757896,1897056,4898872,7593125},\n{776830421,290516100,746623577,293783147,33900006,735127505,565460332,428982705,472062098,161873957,117354594,515619293,578944191,312106242,569389279,391464593},\n{261086313,584837659,683961846,468868529,211593382,736955478,229471758,157617135,398169441,360252438,629394768,264125799,647490480,342079395,391579767,225200475,486011304,513156108,628771752,132906648,142138221,20119449,444199674,195188679,387329805,44684703,651912135,737154512,612549793,519860281,186175544,212568440},\n{240805271,239509872,581127897,6511239,156126222,509425833,672407328,366667722,459185405,509737025,554790222,165216555,703150560,74806569,398730015,383350905,506108358,51326142,298053147,104256117,391428765,374020479,206607807,87664059,275899176,56407680,551553401,448939463,582889860,129676638,226078251,135769095,61292868,578972226,190181628,390739055,184587732,446575689,732674124,232198470,676760679,352474101,611444862,575661807,628905585,320813094,522840969,469781928,156006018,554473341,239654268,643714911,433540170,199307003,496385218,291740751,67309914,370826673,202356819,279421821,421203111,63744786,520987612,550671827},\n{482164403,768209115,462063756,154906374,36099042,341766705,678182556,621882744,478771358,231881111,175889805,243630450,168908523,671961765,55761813,652682670,773939082,517628076,756201264,124604900,750976272,498253248,676047609,137170026,705610017,495032139,561797418,703097347,500815609,95984586,739707108,265613565,387099846,777331779,594676173,591219559,407997044,208947235,93337440,478908360,685013007,487033953,671903001,39521181,738490312,33785059,465470131,310453920,54648783,346831137,427694175,474743430,705296781,435828036,429824745,663532359,261388683,244690731,533997135,596108961,506813013,371892402,590145264,104733162,143420103,654339672,700348950,685038942,578826927,286484229,501639192,434962491,299270097,27702486,335375775,111746817,565603164,294926121,676063665,735862995,710035809,437011960,668528077,138765186,508213986,615036450,353784942,624827616,343900011,241289776,52410890,72018835,352406796,415705878,4802637,376367145,65589678,333633477,341834527,303717460,282387700,42951006,254706039,423048528,526429710,68131467,669954708,12787348,500636381,317959019,479433192,657133515,416259390,610216692,340129188,44594256,257373347,138718678,530767740,292922628,37220268,605295159,480722613,458170419,30540300,487159055,232966794,149150650},\n{412133651,386543325,139952108,289303402,102404925,317067177,396414708,80515854,663739304,317300809,228877044,493725043,715317967,490300965,315527373,743539734,488329191,553627998,533025234,242583957,706116537,614109258,645447222,523195911,492109128,722623041,111085128,766395126,654378921,691964847,496688157,399056049,654363234,102052314,191720088,473910948,259736526,332840025,388047555,665791056,627111387,139696515,441456687,443032569,283264821,771641703,452641455,511306362,117572859,127701891,721298331,176520078,357242229,611296308,696994956,405628839,429224274,465336054,695091546,689828796,574648641,351220905,507964023,675326610,517248963,453528621,220301928,494463186,681789969,339589656,44524053,417125457,339589404,747135963,341780733,734158215,396817281,21997836,5728464,147611205,456248898,714128667,377654949,3862068,128418948,589390074,304947090,11703825,228266073,127304142,429215724,361541124,521572968,468358191,341231688,65323503,613778508,15985323,291661029,410970006,591638112,349541550,89967528,224922159,361094166,584206074,640051812,324264456,652625388,693768537,11740617,309238398,211085469,194905872,639416484,110110707,296645895,748118511,131177718,511142751,775975599,421403409,475528473,434685258,1768977,80301375,708023862,569195676,56238084,632887668,88089750,631539342,396695565,38780154,695798271,469819224,439587099,69045921,682966116,112310856,64943298,534475872,40215357,389728458,286368453,736006257,501181650,54829908,603489402,338032656,512182818,627500097,462674016,3103092,157324491,43978329,596818971,259025598,9088632,91991781,577291428,211245489,429471231,142626330,172560633,510907446,444609585,758102058,375112647,744786693,276174402,19259856,233672418,745389414,225772848,23385663,324290610,519804558,120337812,402578568,360676008,450089262,551043738,337388940,512108856,28879011,690040638,106017282,558262341,99972432,608226003,612152037,42414435,776201013,39580443,518796945,494437752,583194366,723936555,415359657,309569589,751104774,166684527,249229170,353120823,130668327,753823584,580966092,561963717,543672234,393846327,586278000,327398400,278403867,156455586,363920382,190245195,290039148,547014447,466218648,146037150,585462906,666008595,691786683,374707494,622498779,231158277,685740951,115612245,681825249,545555745,551718468,277206615,640171035,757727334,195193908,658656684,457760646,225925875,505761984,18685233,506832921,112511021,396846646,290147622,113924623,669986155,336008070,63611061,238586775,119956662,616557739,772784623,334527774,410403148,51933421}\n};\n\nint main()\n{\n\tint n,k;\n\tcin>>n>>k;\n\tint p=0;\n\twhile ((1<\n#include \n\nusing namespace std;\nstring s,t;\nint main()\n{\n cin>>s;\n cin>>t;\n \n int i,j,; \n sizeo_t pos =1 ;\n for (i =0;i\nusing namespace std;\n#define ALL(x) x.begin(),x.end()\n#define rep(i,n) for(int i=0;i<(n);i++)\n#define debug(v) cout<<#v<<\":\";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b0){\n res.push_back('0'+num%10);\n num/=10;\n }\n if(neg) res.push_back('-');\n reverse(begin(res),end(res));\n os<>(istream &is,__int128 &n){\n string s;\n is>>s;\n int idx=0;\n bool neg=false;\n if(s[0]=='-')neg=true,idx++;\n n=0;\n for(;idx<(int)s.size();idx++){\n n=10*n+s[idx]-'0';\n }\n if(neg) n=-n;\n return is;\n}\n \n__int128 abs(__int128 x){\n return x<0?-x:x;\n}\n \n__int128 gcd(__int128 a,__int128 b){\n if(a==0) return b;\n if(b==0) return a;\n return b>0?gcd(b,a%b):a;\n}\n \n\n\n\n\ntemplate\nstruct PrimalDual{\n const cost_t TINF;\n \n struct edge{\n int to;\n flow_t cap;\n cost_t cost;\n int rev;//\u3053\u306e\u8fba\u306e\u9006\u8fba\u304cg[from]\u306e\u4f55\u756a\u76ee\u306b\u3042\u308b\u304b\n bool isrev;\n };\n \n vector> graph;\n vector potential,min_cost;\n vector prevv,preve;//\u70b9\uff0c\u8fba\n \n PrimalDual(int V):graph(V),TINF(numeric_limits::max()){}\n \n void add_edge(int from,int to,flow_t cap,cost_t cost){\n graph[from].push_back((edge){to,cap,cost,(int)graph[to].size(),false});\n graph[to].push_back((edge){from,0,-cost,(int)graph[from].size()-1,true});\n }\n \n cost_t min_cost_flow(int s,int t,flow_t f){\n int V=(int)graph.size();\n cost_t ret=0;\n using Pi=pair;\n priority_queue,greater> que;\n potential.assign(V,0);\n preve.assign(V,-1);\n prevv.assign(V,-1);\n \n while(f>0){\n min_cost.assign(V,TINF);\n que.emplace(0,s);\n min_cost[s]=0;\n //dijkstra\u30d1\u30fc\u30c8\n while(!que.empty()){\n Pi p=que.top();que.pop();\n if(min_cost[p.second]0 and min_cost[e.to]>nextCost){\n min_cost[e.to]=nextCost;\n prevv[e.to]=p.second,preve[e.to]=i;\n que.emplace(min_cost[e.to],e.to);\n }\n }\n }\n if(min_cost[t]==TINF) return -1;\n //dijkstra\u306e\u7d50\u679c\u306b\u5fdc\u3058\u3066potential\u3092\u4e0a\u3052\u4e0b\u3052\n for(int v=0;v\"<>n>>m>>k>>c>>d;\n PrimalDual flow(maxtime*n+5);\n int source=maxtime*n+2,sink=maxtime*n+3;\n auto get=[&](int idx,int t){return t*n+idx;};\n for(int i=0;i>a;a--;\n flow.add_edge(source,get(a,0),1,0);\n }\n rep(i,m){\n int a,b;cin>>a>>b;a--,b--;\n for(int j=0;j+1\n#include\n#include\nusing namespace std;\ntypedef long long ll;\nconst N = 1e9 + 7;\nll read()\n{\n\tll a = 0, b = 1;\n\tchar c = getchar();\n\twhile( c < '0' or c > '9')\n\t{\n\t\tif(c == '-') b = -1;\n\t\tc = getchar();\n\t}\n\twhile(c >= '0' and c <= '9')\n\t{\n\t\ta = a * 10 + c - '0';\n\t\tc = getchar();\n\t}\n\treturn a * b;\n}\nll quickpow(ll m ,ll n)\n{\n\tlong long t;\n\tif(n==1) return m;\n\tt = quickpow(m,n/2) % N;\n\tif(n%2==0)\n\treturn t * t % N;\n\telse return m * t * t % N;\n}\nll n, m;\nint main()\n{\n\tn = read(); m = read();\n\tn = n + 1;\n\tprintf(\"%lld\",(quickpow(2 * n,m) *(n-m) / n) % N);\n\treturn 0 ;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "29d39860ea3861bb70264e7ff1c98b7f", "src_uid": "4f9711197e699c0fd0c4e9db8323cac7", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef vector poly;\ntypedef unsigned int uint;\nuint n,p,q,ans;\ninline poly Mult(poly A,poly B)\n{\n\tpoly ret(A.size()+B.size()-1);\n\tfor(uint i=0;i>=1;\n\t}\n\tuint ans=0;\n\tfor(uint i=1;i<=q;i++)\n\t{\n\t\tuint cur=0;\n\t\tfor(uint j=0,pw=1;j<=p&&j\n#include \n#include \n#include \n#include \n#include \n#include \n\n#define ______ int _;\n#define FOR(x,to) int x;for(x=0;x<(to);x++)\n#define UINT unsigned int\n#define LL long long\n#define ULL unsigned long long\n#define LD long double\n#define FILE_INPUT_INIT ifstream fin(\"input.txt\"); ofstream fout(\"output.txt\")\n#define MP(a, b) make_pair(a, b)\n ______\n /*____(_)___ ___ ____ ____ ____\n / __/ / / __ `__ \\/ __ `/ _ \\/ __ \\\n / /___/ / / / / / / /_/ / __/ / / /\n/_____/_/_/ /_/ /_/\\__,_/\\___/_/ /*/\n\nusing namespace std;\n\t\n\tconst int N = 2000;\n\tconst int L = 800;\n\tconst int M = 11 + 2 * (L + 1) * 10;\n\n\tint n, len, m, low[L + 1], high[L + 1], fail[M], go[M][10], count[M][N + 1], dp[N + 1][M];\n\tbool mark[N + 1][M];\n\nint read_bigint(int *out) {\n\tstatic char buf[L + 2];\n\tcin >> buf;\n\tint len = strlen(buf);\n\tfor (int i = 0; i < len; ++i) {\n\t\tout[i] = buf[i] - '0';\n\t}\n\treturn len;\n}\n\nvoid update(int &x, int a) { x = std::max(x, a); }\n\nvoid gen(int i, bool has_started, bool is_greater, bool is_less, int u) {\n\tif (i == len || (is_greater && is_less)) {\n\t\tcount[u][len - i]++;\n\t}\n\telse {\n\t\tfor (int d = is_greater ? 0 : low[i]; d <= (is_less ? 9 : high[i]); ++d) {\n\t\t\tint uu = u;\n\t\t\tbool hs = has_started || d != 0;\n\t\t\tif (hs) {\n\t\t\t\tif (go[u][d] == -1) {\n\t\t\t\t\tgo[u][d] = m++;\n\t\t\t\t}\n\t\t\t\tuu = go[u][d];\n\t\t\t}\n\t\t\tgen(i + 1, hs, is_greater || low[i] < d, is_less || d < high[i], uu);\n\t\t}\n\t}\n}\n\nint main() {\n\tint lenl = read_bigint(low);\n\tlen = read_bigint(high);\n\tcin >> n;\n\tstd::move_backward(low, low + lenl, low + len);\n\tstd::fill(low, low + (len - lenl), 0);\n\tmemset(go, -1, sizeof(go));\n\tm++;\n\tgen(0, false, false, false, 0);\n\t{\n\t\tstd::queue queue;\n\t\tfor (int d = 0; d < 10; ++d) {\n\t\t\tint &v = go[0][d];\n\t\t\tif (~v) {\n\t\t\t\tfail[v] = 0;\n\t\t\t\tqueue.push(v);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tv = 0;\n\t\t\t}\n\t\t}\n\t\twhile (!queue.empty()) {\n\t\t\tint u = queue.front();\n\t\t\tqueue.pop();\n\t\t\tfor (int j = 1; j <= n; ++j) {\n\t\t\t\tcount[u][j] += count[u][j - 1];\n\t\t\t}\n\t\t\tfor (int j = 0; j <= n; ++j) {\n\t\t\t\tcount[u][j] += count[fail[u]][j];\n\t\t\t}\n\t\t\tfor (int d = 0; d < 10; ++d) {\n\t\t\t\tint &v = go[u][d];\n\t\t\t\tif (~v) {\n\t\t\t\t\tfail[v] = go[fail[u]][d];\n\t\t\t\t\tqueue.push(v);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tv = go[fail[u]][d];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tmemset(dp, -1, sizeof(dp));\n\tdp[0][0] = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (int u = 0; u < m; ++u) {\n\t\t\tif (dp[i][u] == -1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (int d = 0; d < 10; ++d) {\n\t\t\t\tint v = go[u][d];\n\t\t\t\tupdate(dp[i + 1][v], dp[i][u] + count[v][n - i - 1]);\n\t\t\t}\n\t\t}\n\t}\n\tint result = *std::max_element(dp[n], dp[n] + m);\n\tcout << result << endl;\n\tfor (int j = 0; j < m; ++j) {\n\t\tmark[n][j] = dp[n][j] == result;\n\t}\n\tfor (int i = n - 1; i >= 0; --i) {\n\t\tfor (int u = 0; u < m; ++u) {\n\t\t\tfor (int d = 0; d < 10; ++d) {\n\t\t\t\tint v = go[u][d];\n\t\t\t\tmark[i][u] |= ~dp[i][u] &&\n\t\t\t\t\tdp[i][u] + count[v][n - i - 1] == dp[i + 1][v] &&\n\t\t\t\t\tmark[i + 1][v];\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 0, u = 0; i < n; ++i) {\n\t\tfor (int d = 0; d < 10; ++d) {\n\t\t\tint v = go[u][d];\n\t\t\tif (dp[i][u] + count[v][n - i - 1] == dp[i + 1][v] && mark[i + 1][v]) {\n\t\t\t\tcout << d;\n\t\t\t\tu = v;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "968db91fcc37bb27399e00e45ad1bbad", "src_uid": "2e79c95bf4c2b7de8a4741b24a880829", "difficulty": 3500.0} {"lang": "GNU C++0x", "source_code": "\n#include \n\n#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)\n#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)\n#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)\n#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)\n\n#define DEBUG(x) { cout << #x << \" = \"; cout << (x) << endl; }\n#define PR(a,n) { cout << #a << \" = \"; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }\n#define PR0(a,n) { cout << #a << \" = \"; REP(_,n) cout << a[_] << ' '; cout << endl; }\n\n#define sqr(x) ((x) * (x))\n#define ll long long\nusing namespace std;\n\n#define EPS 1e-6\n\ndouble DEG_to_RAD(double d) { return d * M_PI / 180.0; }\ndouble RAD_to_DEG(double r) { return r * 180.0 / M_PI; }\n\ninline int cmp(double a, double b) {\n return (a < b - EPS) ? -1 : ((a > b + EPS) ? 1 : 0);\n}\n\nstruct Point {\n double x, y;\n Point(double x = 0.0, double y = 0.0) : x(x), y(y) {}\n\n Point operator + (Point a) { return Point(x+a.x, y+a.y); }\n Point operator - (Point a) { return Point(x-a.x, y-a.y); }\n Point operator * (double k) { return Point(x*k, y*k); }\n Point operator / (double k) { return Point(x/k, y/k); }\n\n double operator * (Point a) { return x*a.x + y*a.y; } // dot product\n double operator % (Point a) { return x*a.y - y*a.x; } // cross product\n\n int cmp(Point q) const { if (int t = ::cmp(x,q.x)) return t; return ::cmp(y,q.y); }\n\n #define Comp(x) bool operator x (Point q) const { return cmp(q) x 0; }\n Comp(>) Comp(<) Comp(==) Comp(>=) Comp(<=) Comp(!=)\n #undef Comp\n\n Point conj() { return Point(x, -y); }\n double norm() { return x*x + y*y; }\n\n // Note: There are 2 ways for implementing len():\n // 1. sqrt(norm()) --> fast, but inaccurate (produce some values that are of order X^2)\n // 2. hypot(x, y) --> slow, but much more accurate\n double len() { return sqrt(norm()); }\n\n Point rotate(double alpha) {\n double cosa = cos(alpha), sina = sin(alpha);\n return Point(x * cosa - y * sina, x * sina + y * cosa);\n }\n\n void read() {\n cin >> x >> y;\n }\n};\n\nint ccw(Point a, Point b, Point c) {\n return cmp((b-a)%(c-a),0);\n}\n\ndouble angle(Point a, Point o, Point b) { // angle AOB\n a = a - o; b = b - o;\n return acos((a * b) / sqrt(a.norm() * b.norm()));\n}\n\n// Distance from p to Line ab (closest Point --> c)\ndouble distToLine(Point p, Point a, Point b, Point &c) {\n Point ap = p - a, ab = b - a;\n double u = (ap * ab) / ab.norm();\n c = a + (ab * u);\n return (p-c).len();\n}\n\n// Distance from p to segment ab (closest Point --> c)\ndouble distToLineSegment(Point p, Point a, Point b, Point &c) {\n Point ap = p - a, ab = b - a;\n double u = (ap * ab) / ab.norm();\n if (u < 0.0) {\n c = Point(a.x, a.y);\n return (p - a).len();\n }\n if (u > 1.0) {\n c = Point(b.x, b.y);\n return (p - b).len();\n }\n return distToLine(p, a, b, c);\n}\n\n// NOTE: WILL NOT WORK WHEN a = b = 0.\nstruct Line {\n double a, b, c;\n Point A, B; // Added for polygon intersect line. Do not rely on assumption that these are valid\n\n Line(double a, double b, double c) : a(a), b(b), c(c) {} \n\n Line(Point A, Point B) : A(A), B(B) {\n a = B.y - A.y;\n b = A.x - B.x;\n c = - (a * A.x + b * A.y);\n }\n Line(Point P, double m) {\n a = -m; b = 1;\n c = -((a * P.x) + (b * P.y));\n }\n double f(Point A) {\n return a*A.x + b*A.y + c;\n }\n};\n\nbool areParallel(Line l1, Line l2) {\n return cmp(l1.a*l2.b, l1.b*l2.a) == 0;\n}\n\nbool areSame(Line l1, Line l2) {\n return areParallel(l1 ,l2) && cmp(l1.c*l2.a, l2.c*l1.a) == 0\n && cmp(l1.c*l2.b, l1.b*l2.c) == 0;\n}\n\nbool areIntersect(Line l1, Line l2, Point &p) {\n if (areParallel(l1, l2)) return false;\n double dx = l1.b*l2.c - l2.b*l1.c;\n double dy = l1.c*l2.a - l2.c*l1.a;\n double d = l1.a*l2.b - l2.a*l1.b;\n p = Point(dx/d, dy/d);\n return true;\n}\n\nvoid closestPoint(Line l, Point p, Point &ans) {\n if (fabs(l.b) < EPS) {\n ans.x = -(l.c) / l.a; ans.y = p.y;\n return;\n }\n if (fabs(l.a) < EPS) {\n ans.x = p.x; ans.y = -(l.c) / l.b;\n return;\n }\n Line perp(l.b, -l.a, - (l.b*p.x - l.a*p.y));\n areIntersect(l, perp, ans);\n}\n\nvoid reflectionPoint(Line l, Point p, Point &ans) {\n Point b;\n closestPoint(l, p, b);\n ans = p + (b - p) * 2;\n}\n\nbool intersect(Point A, Point B, Point X, Point Y) {\n if (ccw(A, B, X) * ccw(A, B, Y) <= 0\n && ccw(X, Y, A) * ccw(X, Y, B) <= 0)\n return true;\n return false;\n}\n\nbool canSee(Point A, Point B, Point W1, Point W2, Point W3, Point W4) {\n return !intersect(A, B, W1, W2) && !intersect(A, B, W3, W4);\n}\n\nint main() {\n Point A, B, M1, M2, W1, W2;\n while (cin >> A.x >> A.y) {\n B.read();\n W1.read(); W2.read();\n M1.read(); M2.read();\n\n Line W(W1, W2);\n Line M(M1, M2);\n\n Point A2;\n reflectionPoint(M, A, A2);\n\n if (canSee(A, B, W1, W2, M1, M2)) {\n cout << \"YES\" << endl;\n }\n else if (canSee(A2, B, W1, W2, W1, W2) && intersect(A2, B, M1, M2)) {\n cout << \"YES\" << endl;\n }\n else cout << \"NO\" << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5472652cca22cdd96ae1938001f42017", "src_uid": "7539a41268b68238d644795bccaa0c0f", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \n#define cf ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)\nusing namespace std;\n\nint main() {\n\tint i n ;\n\tcin >> n ;\n int a[n];\n memset(a,1,n);\n\tfor(i=1;i\n\n#define F first\n#define S second\n#define PB push_back\n#define sz(s) int((s).size())\n#define bit(n,k) (((n)>>(k))&1)\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\n\nconst int maxn=1e5+10,SQ=550,inf=1e9;\n\nvector vec;\nvector > v1,v2;\nint where[maxn];\n\nstruct Hash{\n int operator()(const pii &p)const{\n\treturn hash()((ll(p.F)<<32)|p.S);\n }\n};\n \nint main(){\n ios_base::sync_with_stdio(false);cin.tie(0);\n\n memset(where,-1,sizeof where);\n\n unordered_mapmp;\n mp.reserve(1024);\n mp.max_load_factor(0.25);\n \n int q;cin>>q;\n while(q--){\n\tv1.clear(),v2.clear(),mp.clear();\n\tint n,t;cin>>n>>t;\n\twhile(t--){\n\t int Sz;cin>>Sz;\n\t vec.resize(Sz);\n\t for(int i=0;i>vec[i];\n\t if(Sz>=SQ)\n\t\tv1.PB(vec);\n\t else\n\t\tv2.PB(vec);\n\t}\n\tfor(auto &A:v1){\n\t for(int i=0;ilst){\n\t\t\tcout<<\"Human\\n\";\n\t\t\tgoto Hell;\n\t\t }\n\t\t if(is && where[i]-i==lst){\n\t\t\tcout<<\"Human\\n\";\n\t\t\tgoto Hell;\n\t\t }\n\t\t lst=where[i]-i;\n\t\t is=0;\n\t\t}\n\t }\n\t for(int i=0;i\nusing namespace std;\n\n#ifdef LOCAL\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define print_var(x) cerr << #x << \" = \" << x << endl\n#define print_array(arr, len) {cerr << #arr << \" = \"; for (int i = 0; i < len; i++) cerr << arr[i] << \" \"; cerr << endl;}\n#define print_iterable(it) {cerr << #it << \" = \"; for (const auto &e : it) cerr << e << \" \"; cerr << endl;}\n#else\n#define eprintf(...) (void)0\n#define print_var(x) (void)0\n#define print_array(arr, len) (void)0\n#define print_iterable(it) (void)0\n#endif\n\ntypedef long long ll;\nconst int PW10 = 19;\n\nll l0, r0;\nll pw10[PW10];\nint cnt0[10], cnt[10];\nchar sl[30], sr[30], res[30];\nint srlen;\nint ans;\n\nbool verify(int len)\n{\n for (int i = 0; i < len; i++)\n res[i] += '0';\n res[len] = 0;\n return len < srlen || (len == srlen && strcmp(res, sr) <= 0);\n}\n\nbool good()\n{\n int len = accumulate(cnt0, cnt0 + 10, 0);\n if (len == 0)\n return false;\n\n copy(cnt0, cnt0 + 10, cnt);\n\n ll l = l0;\n if (l0 < pw10[len - 1])\n l = pw10[len - 1];\n\n sprintf(sl, \"%lld\", l); \n int diff = strlen(sl) - len;\n if (diff > 0)\n {\n cnt[0] += diff;\n len += diff;\n }\n for (int i = 0; i < len; i++)\n sl[i] -= '0';\n\n int i;\n for (i = 0; i < len; i++)\n {\n if (cnt[sl[i]] == 0)\n break;\n cnt[sl[i]]--;\n res[i] = sl[i];\n }\n if (i == len)\n return verify(len);\n\n int max_dig = 9;\n while (cnt[max_dig] == 0)\n max_dig--;\n\n int j;\n for (j = i; j >= 0; j--)\n {\n if (j < i)\n {\n cnt[res[j]]++;\n max_dig = max((int)max_dig, res[j]);\n }\n if (max_dig > sl[j] - '0')\n {\n int p = sl[j] + 1;\n while (cnt[p] == 0)\n p++;\n cnt[p]--;\n res[j] = p;\n break;\n }\n }\n\n if (j == -1)\n {\n cnt[0]++;\n int p = 1;\n while (cnt[p] == 0)\n p++;\n cnt[p]--;\n res[0] = p;\n p = 0;\n for (int t = 1; t < len + 1; t++)\n {\n while (cnt[p] == 0)\n p++;\n cnt[p]--;\n res[t] = p;\n }\n return verify(len + 1);\n }\n\n int p = 0;\n for (int t = j + 1; t < len; t++)\n {\n while (cnt[p] == 0)\n p++;\n cnt[p]--;\n res[t] = p;\n }\n return verify(len);\n}\n\nvoid brute(int p, int sum)\n{\n if (p == 10)\n {\n if (good())\n ans++;\n }\n else\n {\n for (int d = 0; d <= sum; d++)\n {\n cnt0[p] = d;\n brute(p + 1, sum - d);\n }\n }\n}\n\nvoid solve()\n{\n pw10[0] = 1;\n for (int i = 1; i < PW10; i++)\n pw10[i] = pw10[i - 1] * 10;\n\n scanf(\"%lld%lld\", &l0, &r0);\n sprintf(sr, \"%lld\", r0);\n srlen = strlen(sr);\n\n brute(1, 18);\n\n printf(\"%d\\n\", ans);\n}\n\nint main()\n{\n#ifdef LOCAL\n freopen(\"input.txt\", \"r\", stdin);\n#endif\n\n solve();\n\n eprintf(\"\\n\\ntime = %.3lf\\n\", (double)clock() / CLOCKS_PER_SEC);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "388a50086283f807a6ff80871c65f25d", "src_uid": "adfa5f280eefbacdbaa4ad605402b57a", "difficulty": 2700.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nstruct query {\n int c, l, r;\n};\n\nstring s;\nint S[100010];\nint k, L, R;\nquery qs[510];\nvector let_pos[30];\nint cnt[100010];\nint cpl[510], cpr[510];\nint let_cnt[30];\nint curr_good = 0;\nlong long ans = 0;\n\nint main() {\n cin >> s;\n for (int i = 0; i < MAX_ALPHABET; i++) let_pos[i].push_back(-1);\n for (int i = 0; i < s.length(); i++) {\n S[i] = s[i]-'a';\n let_pos[S[i]].push_back(i);\n }\n cin >> k >> L >> R;\n for (int i = 0; i < k; i++) {\n char ch; cin >> ch; qs[i].c = ch-'a';\n cin >> qs[i].l >> qs[i].r;\n }\n\n for (int pos = 0; pos < s.length(); ++pos) {\n int c = S[pos]; \n ++let_cnt[c];\n for (int qp = 0; qp < k; qp++)\n if (qs[qp].c == S[pos] && qs[qp].l <= 1 && qs[qp].r >= 1) ++cnt[pos];\n else if (qs[qp].c != S[pos] && qs[qp].l == 0) ++cnt[pos];\n if (cnt[pos] >= L && cnt[pos] <= R) ++curr_good;\n for (int qp = 0; qp < k; qp++) {\n if (qs[qp].c == S[pos]) {\n if (let_cnt[c] == qs[qp].l) {\n cpl[qp] = 0;\n for (int tp = 0; tp <= let_pos[S[pos]][1]; tp++) if (tp < pos) {\n ++cnt[tp];\n if (cnt[tp] == L) ++curr_good;\n if (cnt[tp] == R+1) --curr_good;\n }\n cpr[qp] = 1;\n } else if (let_cnt[c] > qs[qp].l) {\n if (let_cnt[c] > qs[qp].r) {\n for (int tp = let_pos[c][cpl[qp]]+1; tp <= let_pos[c][cpl[qp]+1]; tp++) if (tp < pos) {\n --cnt[tp]; \n if (cnt[tp] == R) ++curr_good;\n if (cnt[tp] == L-1) --curr_good;\n }\n ++cpl[qp];\n }\n if (qs[qp].l > 0) {\n for (int tp = let_pos[c][cpr[qp]]+1; tp <= let_pos[c][cpr[qp]+1]; tp++) if (tp < pos) {\n ++cnt[tp];\n if (cnt[tp] == L) ++curr_good;\n if (cnt[tp] == R+1) --curr_good; \n }\n ++cpr[qp];}\n }\n }\n }\n ans += curr_good;\n }\n\n cout << ans << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5beb78b41bfa17c7c59f264f9eb6108c", "src_uid": "948f7747cab468b26cc28a3ff29fabdd", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntemplate T sqr(T x) { return x * x; }\ntemplate T gcd(T a, T b) { return b == 0? a : gcd(b, a % b); }\ntemplate T abs(T x) { return x < 0? -x : x; }\n\nconst int MAXK = 31;\n\nint f[MAXK];\nint g[MAXK];\nint ans;\nint n, m;\n\nint main()\n{\n\t#ifdef MJUDGE\n\t\tassert(freopen(\"in\", \"r\", stdin));\n\t\tassert(freopen(\"out\", \"w\", stdout));\n\t#endif\n\t\n\tscanf(\"%d %d\", &n, &m);\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tint x;\n\t\tscanf(\"%d\", &x);\n\t\tfor (int j = 0; j < MAXK; j++)\n\t\t\tif ((1 << j) & x)\n\t\t\t\tf[j] += 1;\n\t}\n\tfor (int i = 0; i < m; i++)\n\t{\n\t\tint x;\n\t\tscanf(\"%d\", &x);\n\t\tif (x >= MAXK)\n\t\t\tcontinue;\n\t\tg[x] += 1;\n\t}\n\t\n\tans = 0;\n\tfor (int i = 0; i < MAXK; i++)\n\t{\n\t\tlong long x = f[i] * (long long)(1 << i);\n\t\tfor (int j = 0; j <= i; j++)\n\t\t{\n\t\t\tlong long v = min(x, (long long)g[j]);\n\t\t\tans += v;\n\t\t\tg[j] -= v;\n\t\t\tx = (x - v) / 2;\n\t\t}\n\t}\n\tprintf(\"%d\\n\", ans);\n\tfprintf(stderr, \"Time execute: %.3lfs\\n\", clock() / (double)CLOCKS_PER_SEC);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b5a4c15fec5e7d720874e4ee646e905b", "src_uid": "e95fb7d4309747834b37d4bc3468afb7", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include \n#define ll long long\nusing namespace std; \n \n\n\n \n// Driver Code \nint main() \n{ \n ll n,m,a,b,c,d,x,y,x1,x2,y1,y2;\n \n cin>>n>>m;\n ll xx[n];\n a=0;\n b=0;\n for(ll i=0;i>xx[i];\n if(xx[i]==1)\n {\n a++;\n }\n else\n {\n b++;\n }\n \n }\n ll ma=0\n for(ll i=0;i\n# define ll long long\n# define MOD 1000000007\n\nusing namespace std;\n\nint gcd(int a, int b, int& x, int& y) {\n if (b == 0) {\n x = 1;\n y = 0;\n return a;\n }\n int x1, y1;\n int d = gcd(b, a % b, x1, y1);\n x = y1;\n y = x1 - y1 * (a / b);\n return d;\n}\n\n\nll modpow (ll a, ll b)\n{\n if (b == 0)\n return 1;\n long long res = modpow (a, b/2);\n res = (res * res) % MOD;\n if (b % 2 == 1)\n res = (res * a) % MOD;\n return res;\n}\n\nll calc (ll n, ll k)\n{\n ll acc = 1;\n ll fact = 1;\n ll sum = 1;\n ll term;\n ll x, y;\n for (int i = 1; i <= k; i++)\n {\n fact *= i;\n gcd (fact, MOD, x, y);\n x = (x % MOD + MOD) % MOD;\n acc = ((acc * (n - i + 1)) % MOD;\n acc = (acc * x) % MOD;\n sum += acc;\n }\n return sum;\n}\n\nvoid solve ()\n{\n ll n, k, val;\n cin >> n >> k;\n if (k >= n)\n {\n cout << modpow (2, n) << '\\n';\n return;\n }\n if (k > n/2)\n cout << modpow (2, n) - calc (n, n - k - 1) << '\\n';\n else\n cout << calc (n, k) << '\\n';\n}\n\nint main ()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int t = 1;\n //cin >> t;\n while (t--)\n solve();\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fa7d9801269b330f8a407949f6bd8ecb", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n#define ll long long\nll k;\n\nll split(ll i) { // Interval i [(k2+1)*i+1, .., (k2+1)*(i+1)]\n if (!i) return k*(k+1) / 2;\n ll s = split(i/k);\n ll O = i/k;\n ll o = i%k;\n s -= O * (k*k+1) + o * k;\n ll off = s<=1 ? k : s>k ? 0 : k+1 - s;\n return k * (O*(k*k+1) + o*k) + k*(k+1)/2 + off;\n}\n\nint main() {\n ios::sync_with_stdio(0), cin.tie(0);\n int t; cin >> t;\n while (t--) {\n ll n; cin >> n >> k;\n ll i = (n-1)/(k*k+1);\n ll s = split(i,k);\n if (s==n) {\n cout << (i+1)*(k+1) << '\\n';\n } else {\n ll o = n-i*(k*k+1);\n // printf(\"n%lld k%lld i%lld o%lld O%lld s%lld\\n\",\n // n,k,i,o,i*k*(k+1),s);\n ll ans = i*k*(k+1) + o + (o-1-(n>s))/k - (n>s);\n cout << ans << '\\n';\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8c36a89f5666378f5993012efb042ccd", "src_uid": "053192b4f6acc3a94b701e787a4172e2", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nlong long int t,i,a1,a2,k1,k2,n,copt;\nint main()\n{\n\tcin >> a1 >> a2 >> k1 >> k2 >> n;\n\tcopt = n-a1*(k1-1)-a2*(k2-1);\n\tif (copt > a1+a2)\n\t\tcout << a1+a2 << \" \";\n\telse\n\t\tif (cout > 0)\n\t\t\tcout << copt << \" \";\n\tif (k1 < k2)\n\t{\n\t\tif (n>=k1*a1+k2*a2)\n\t\t\tcout << a1+a2;\n\t\telse\n\t\t{\n\t\t\tif (n>k1*a1)\n\t\t\t\tcout << a1 + (n-a1*k1)/k2;\n\t\t\telse\n\t\t\t\tcout << n/k1;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (n>=k1*a1+k2*a2)\n\t\t\tcout << a1+a2;\n\t\telse\n\t\t{\n\t\t\tif (n>k2*a2)\n\t\t\t\tcout << a2 + (n-a2*k2)/k1;\n\t\t\telse\n\t\t\t\tcout << n/k2;\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0c69cf2856abd2e0d6d8241215fb0563", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n#ifndef _LIB_POLYNOMIAL_RING\n#define _LIB_POLYNOMIAL_RING\n#include \n#ifndef _LIB_MODULAR_INTEGER\n#define _LIB_MODULAR_INTEGER\n#include \n#ifndef _LIB_NUMBER_THEORY\n#define _LIB_NUMBER_THEORY\n#include \n\nnamespace lib {\n using namespace std;\nnamespace nt {\n int64_t inverse(int64_t a, int64_t b) {\n long long b0 = b, t, q;\n long long x0 = 0, x1 = 1;\n if (b == 1) return 1;\n while (a > 1) {\n q = a / b;\n t = b, b = a % b, a = t;\n t = x0, x0 = x1 - q * x0, x1 = t;\n }\n if (x1 < 0) x1 += b0;\n return x1;\n }\n}\n} // namespace lib\n\n#endif\n\n#if __cplusplus < 201300\n#error required(c++14)\n#endif\n\nnamespace lib {\n using namespace std;\nnamespace {\n template\n struct ModularIntegerBase {\n typedef ModularIntegerBase type;\n\n T x[sizeof...(Mods)];\n friend ostream& operator<<(ostream& output, const type& var) {\n output << \"(\";\n for(int i = 0; i < sizeof...(Mods); i++) {\n if(i) output << \", \";\n output << var.x[i];\n }\n return output << \")\";\n }\n };\n\n template\n struct ModularIntegerBase {\n typedef ModularIntegerBase type;\n\n T x[1];\n\n explicit operator T() const { return this->x[0]; }\n explicit operator long long() const { return this->x[0]; }\n explicit operator double() const { return this->x[0]; }\n explicit operator long double() const { return this->x[0]; }\n friend ostream& operator<<(ostream& output, const type& var) {\n return output << var.x[0];\n }\n };\n\n\n template\n struct ModularIntegerImpl : ModularIntegerBase {\n typedef ModularIntegerImpl type;\n typedef T type_int;\n typedef int64_t large_int;\n const static size_t n_mods = sizeof...(Mods);\n\n struct Less {\n bool operator()(const type& lhs, const type& rhs) const {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n if(lhs.x[i] != rhs.x[i])\n return lhs.x[i] < rhs.x[i];\n return false;\n };\n };\n typedef Less less;\n\n constexpr static T mods[sizeof...(Mods)] = {Mods...};\n using ModularIntegerBase::x;\n\n ModularIntegerImpl() {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n x[i] = T();\n }\n ModularIntegerImpl(T y) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n x[i] = y;\n normalize();\n }\n static type with_remainders(T y[sizeof...(Mods)]) {\n type res;\n for(size_t i = 0; i < sizeof...(Mods); i++)\n res.x[i] = y[i];\n res.normalize();\n return res;\n }\n\n void normalize() {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n if((x[i] %= mods[i]) < 0)\n x[i] += mods[i];\n }\n\n inline T operator[](int i) const { return x[i]; }\n\n inline T multiply(T a, T b, T mod) const {\n return (large_int)a*b % mod;\n }\n\n inline T inv(T a, T mod) const {\n return static_cast(nt::inverse(a, mod));\n }\n\n type inverse() const {\n T res[sizeof...(Mods)];\n for(size_t i = 0; i < sizeof...(Mods); i++)\n res[i] = inv(x[i], mods[i]);\n return type::with_remainders(res);\n }\n \n template\n T power(T a, U p, T mod) {\n if(mod == 1) return T();\n if(p < 0) {\n if(a == 0)\n throw domain_error(\"0^p with negative p is invalid\");\n p = -p;\n a = inv(a, mod);\n }\n if(p == 0) return T(1);\n if(p == 1) return a;\n T res = 1;\n while(p > 0) {\n if(p&1)\n res = multiply(res, a, mod);\n p >>= 1;\n a = multiply(a, a, mod);\n }\n return res;\n }\n \n type& operator+=(const type& rhs) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n (x[i] += rhs.x[i]) %= mods[i];\n return *this;\n }\n type& operator-=(const type& rhs) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n if((x[i] -= rhs.x[i]) < 0)\n x[i] += mods[i];\n return *this;\n }\n type& operator*=(const type& rhs) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n x[i] = multiply(x[i], rhs.x[i], mods[i]);\n return *this;\n }\n type& operator/=(const type& rhs) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n x[i] = multiply(x[i], inv(rhs.x[i], mods[i]), mods[i]);\n return *this;\n }\n\n type& operator+=(T rhs) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n x[i] += rhs;\n normalize();\n return *this;\n }\n \n type& operator-=(T rhs) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n x[i] -= rhs;\n normalize();\n return *this;\n }\n\n type& operator*=(T rhs) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n x[i] = multiply(x[i], rhs, mods[i]);\n return *this;\n }\n\n type& operator/=(T rhs) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n x[i] = multiply(inv(rhs, mods[i]), x[i], mods[i]);\n return *this;\n }\n\n type& operator^=(large_int p) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n x[i] = power(x[i], p, mods[i]);\n return *this;\n }\n\n type& operator++() {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n if((++x[i]) >= mods[i])\n x[i] -= mods[i];\n return *this;\n }\n type& operator--() {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n if((--x[i]) < 0)\n x[i] += mods[i];\n return *this;\n }\n type& operator++(int unused) { type res = *this; ++(*this); return res; }\n type& operator--(int unused) { type res = *this; --(*this); return res; }\n\n friend type operator+(const type& lhs, const type& rhs) {\n type res = lhs;\n return res += rhs;\n }\n friend type operator-(const type& lhs, const type& rhs) {\n type res = lhs;\n return res -= rhs;\n }\n friend type operator*(const type& lhs, const type& rhs) {\n type res = lhs;\n return res *= rhs;\n }\n friend type operator/(const type& lhs, const type& rhs) {\n type res = lhs;\n return res /= rhs;\n }\n\n friend type operator+(const type& lhs, T rhs) {\n type res = lhs;\n return res += rhs;\n }\n \n friend type operator-(const type& lhs, T rhs) {\n type res = lhs;\n return res -= rhs;\n }\n\n friend type operator*(const type& lhs, T rhs) {\n type res = lhs;\n return res *= rhs;\n }\n \n friend type operator/(const type& lhs, T rhs) {\n type res = lhs;\n return res /= rhs;\n }\n\n friend type operator^(const type& lhs, large_int rhs) {\n type res = lhs;\n return res ^= rhs;\n }\n\n type operator-() const {\n type res = *this;\n for(size_t i = 0; i < sizeof...(Mods); i++)\n if(res.x[i])\n res.x[i] = mods[i] - res.x[i];\n return res;\n }\n\n friend bool operator==(const type& lhs, const type& rhs) {\n for(size_t i = 0; i < sizeof...(Mods); i++)\n if(lhs.x[i] != rhs.x[i])\n return false;\n return true;\n }\n friend bool operator!=(const type& lhs, const type& rhs) {\n return !(lhs == rhs);\n }\n \n friend istream& operator>>(istream& input, type& var) {\n T y; cin >> y;\n var = y;\n return input;\n }\n };\n}\n\n // Explicitly make constexpr available for linkage.\n template\n constexpr T ModularIntegerImpl::mods[];\n \n template\n using ModularInteger = \n ModularIntegerImpl::value>::type,\n Mods...>;\n \n template\n using Mint32 = ModularInteger;\n\n template\n using Mint64 = ModularInteger;\n} // namespace lib\n\n#endif\n#ifndef _LIB_TRAITS\n#define _LIB_TRAITS\n#include \n\nnamespace lib {\n using namespace std;\nnamespace traits {\n\n /// keep caide\n template\n using IteratorCategory =\n typename iterator_traits::iterator_category;\n\n /// keep caide\n template\n using IteratorCategoryOf = IteratorCategory;\n\n /// keep caide\n template\n using IsRandomIterator =\n is_base_of>;\n\n /// keep caide\n template\n using IsInputIterator =\n is_base_of>;\n\n /// keep caide\n template\n using IsBidirectionalIterator =\n is_base_of>;\n\n /// keep caide\n template\n using HasRandomIterator =\n is_base_of>;\n\n /// keep caide\n template\n using HasInputIterator =\n is_base_of>;\n\n /// keep caide\n template\n using HasBidirectionalIterator =\n is_base_of>;\n}\n}\n\n#endif\n#ifndef _LIB_FFT\n#define _LIB_FFT\n#include \n#ifndef _LIB_COMPLEX\n#define _LIB_COMPLEX\n#include \n\nnamespace lib {\n template struct Complex {\n T re, im;\n Complex(T a = T(), T b = T()) : re(a), im(b) {}\n T real() const { return re; }\n void operator+=(const Complex& rhs) { re += rhs.re, im += rhs.im; }\n void operator-=(const Complex& rhs) { re -= rhs.re, im -= rhs.im; }\n void operator*=(const Complex& rhs) {\n tie(re, im) = make_pair(re * rhs.re - im * rhs.im, re * rhs.im + im * rhs.re);\n }\n Complex operator+(const Complex& rhs) {\n Complex res = *this;\n res += rhs;\n return res;\n }\n Complex operator-(const Complex& rhs) {\n Complex res = *this;\n res -= rhs;\n return res;\n }\n Complex operator*(const Complex& rhs) {\n Complex res = *this;\n res *= rhs;\n return res;\n }\n void operator/=(const T x) { re /= x, im /= x; }\n };\n} // namespace lib\n\n#endif\n\nnamespace lib {\n using namespace std;\nnamespace linalg {\nnamespace internal {\n typedef long double fft_type;\n typedef Complex cd;\n typedef vector vcd;\n\n const fft_type PI = acosl(-1);\n vector rev;\n vcd fa, fb;\n\n // function used to precompute rev for fixed size fft (n is a power of two)\n void dft_rev(int n) {\n int lbn = __builtin_ctz(n);\n if((int)rev.size() < (1 << lbn)) rev.resize(1 << lbn);\n int h = -1;\n for (int i = 1; i < n; i++) {\n if ((i & (i - 1)) == 0) h++;\n rev[i] = rev[i ^ (1 << h)] | (1 << (lbn - h - 1));\n }\n }\n\n void dft_iter(cd* p, int n) {\n for (int L = 2; L <= n; L <<= 1) {\n fft_type ang = PI * 2 / L;\n cd step = cd(cosl(ang), sinl(ang)); // root\n // for (int i = L; i < root_sz; i <<= 1) NTT HERE\n // step = step * step % MOD;\n for (int i = 0; i < n; i += L) {\n cd w = 1;\n for (int j = 0; j < L / 2; j++) {\n cd x = p[i + j];\n cd y = p[i + j + L / 2] * w;\n p[i + j] = x + y;\n p[i + j + L / 2] = x - y;\n w *= step;\n }\n }\n }\n }\n\n void dft(cd* p, int n) {\n for (int i = 0; i < n; i++)\n if (i < rev[i]) swap(p[i], p[rev[i]]);\n dft_iter(p, n);\n }\n\n void idft(cd* p, int n) {\n dft(p, n);\n reverse(p+1, p+n);\n for (int i = 0; i < n; i++) p[i] /= n;\n }\n}\n\n template\n void raw_fft(const vector& a, const vector& b) {\n int n = max(a.size(), b.size());\n n = 1 << (32 - __builtin_clz(n) + ((n & (n-1)) != 0));\n if((int)internal::fa.size() < n) internal::fa.resize(n);\n if((int)internal::fb.size() < n) internal::fb.resize(n);\n for(size_t i = 0; i < a.size(); i++)\n internal::fa[i] = (internal::fft_type) a[i];\n for(size_t i = 0; i < b.size(); i++)\n internal::fb[i] = (internal::fft_type) b[i];\n fill(internal::fa.begin() + a.size(), internal::fa.end(), 0);\n fill(internal::fb.begin() + b.size(), internal::fb.end(), 0);\n internal::dft_rev(n);\n internal::dft(internal::fa.data(), n);\n internal::dft(internal::fb.data(), n);\n for(int i = 0; i < n; i++) internal::fa[i] *= internal::fb[i];\n internal::idft(internal::fa.data(), n);\n }\n\n template\n internal::vcd fft(const vector& a, const vector& b) {\n raw_fft(a, b);\n internal::vcd& raw = internal::fa;\n int sz = raw.size();\n vector res(sz);\n for(int i = 0; i < sz; i++)\n res[i] = raw[i];\n return res;\n }\n\n template\n vector rounded_fft(const vector& a, const vector& b) {\n raw_fft(a, b);\n internal::vcd& raw = internal::fa;\n int sz = raw.size();\n vector res(sz);\n for(int i = 0; i < sz; i++)\n res[i] = (long long)(raw[i].real() + 0.5);\n return res;\n }\n\n // TODO: optimize this\n template\n vector mod_split_fft(const vector& a, const vector& b) {\n typedef typename M::type_int type_int;\n static_assert(sizeof(M::mods) / sizeof(type_int) == 1, \n \"cant multiply with multiple mods\");\n type_int base = sqrtl(M::mods[0]) + 0.5;\n M base_m = base;\n int sza = a.size();\n int szb = b.size();\n\n vector a0(sza), a1(sza);\n for(int i = 0; i < sza; i++) {\n a0[i] = (type_int)a[i] % base;\n a1[i] = (type_int)a[i] / base;\n }\n\n vector b0(szb), b1(szb);\n for(int i = 0; i < szb; i++) {\n b0[i] = (type_int)b[i] % base;\n b1[i] = (type_int)b[i] / base;\n }\n\n vector a01 = a0, b01 = b0;\n for(int i = 0; i < sza; i++) a01[i] += a1[i];\n for(int i = 0; i < szb; i++) b01[i] += b1[i];\n vector C = rounded_fft(a01, b01);\n vector a0b0 = rounded_fft(a0, b0);\n vector a1b1 = rounded_fft(a1, b1);\n\n vector mid = C;\n int sz = C.size();\n for(int i = 0; i < sz; i++) {\n mid[i] -= a0b0[i];\n mid[i] -= a1b1[i];\n }\n\n vector res = a0b0;\n for(int i = 0; i < sz; i++)\n res[i] += base_m * mid[i];\n base_m *= base_m;\n for(int i = 0; i < sz; i++)\n res[i] += base_m * a1b1[i];\n return res;\n }\n} // namespace linalg\n} // namespace lib\n\n#endif\n#ifndef _LIB_MATH\n#define _LIB_MATH\n#include \n\nnamespace lib {\n using namespace std;\nnamespace math {\n\n /// caide keep\n template\n struct DefaultPowerOp {\n Type operator()() const { return Type(1); }\n Type operator()(const Type& a) const { return a; }\n void operator()(Type& x, const Type& a, long long cur) const {\n x *= x;\n if(cur & 1)\n x *= a;\n }\n };\n\n template\n Type generic_power(const Type& a, long long n, Op op = DefaultPowerOp()) {\n if(n == 0) return op();\n Type res = op(a);\n int hi = 63 - __builtin_clzll(n);\n for(int i = hi - 1; ~i; i--) {\n op(res, a, n >> i);\n }\n return res;\n }\n} // namespace math\n} // namespace lib\n\n#endif\n\nnamespace lib {\n using namespace std;\nnamespace math {\nnamespace poly {\n\n namespace {\n /// keep caide\n using traits::IsInputIterator;\n /// keep caide\n using traits::HasInputIterator;\n }\n\n struct FastMultiplication {\n template\n vector operator()(const vector& a, const vector& b) const {\n return linalg::rounded_fft(a, b);\n }\n };\n \n struct SafeMultiplication {\n template\n vector operator()(const vector& a, const vector& b) const {\n return linalg::mod_split_fft(a, b);\n };\n };\n\n struct NaiveMultiplication {\n template\n vector operator()(const vector& a, const vector& b) const {\n vector res(a.size() + b.size());\n for(size_t i = 0; i < a.size(); i++) {\n for(size_t j = 0; j < b.size(); j++) {\n res[i + j] += a[i] * b[j];\n }\n }\n return res;\n }\n };\n\n template\n struct DefaultPowerOp {\n int mod;\n DefaultPowerOp(int mod) : mod(mod) {}\n P operator()() const { return P(1); }\n P operator()(const P& a) const { return a % mod; }\n void operator()(P& x, const P& a, long long cur) const {\n (x *= x) %= mod;\n if(cur & 1)\n (x *= a) %= mod;\n }\n };\n\n template\n struct ModPowerOp {\n const P& mod;\n ModPowerOp(const P& p) : mod(p) {}\n P operator()() const { return P(1); }\n P operator()(const P& a) { return a % mod; }\n void operator()(P& x, const P& a, long long cur) const {\n (x *= x) %= mod;\n if(cur & 1)\n (x *= a) %= mod;\n }\n };\n\n template\n struct ModShiftPowerOp {\n const P& mod;\n ModShiftPowerOp(const P& p) : mod(p) {}\n P operator()() const { return P(1); }\n P operator()(const P& a) { return a % mod; }\n void operator()(P& x, const P& a, long long cur) const {\n //if(cur < mod.degree())\n //x = P::kth(cur);\n if(cur & 1)\n (x *= (x << 1)) %= mod;\n else\n (x *= x) %= mod;\n }\n };\n\n template\n struct Polynomial {\n typedef Polynomial type;\n typedef Field field;\n vector p;\n \n Polynomial() : p(0) {}\n explicit Polynomial(Field x): p(1, x) {}\n\n template<\n typename Iterator,\n typename enable_if::value>::type* = nullptr>\n Polynomial(Iterator begin, Iterator end) : p(distance(begin, end)) {\n int i = 0;\n for(auto it = begin; it != end; ++it, ++i)\n p[i] = *it;\n normalize();\n }\n\n template<\n typename Container,\n typename enable_if::value>::type* = nullptr>\n Polynomial(const Container& container) \n : Polynomial(container.begin(), container.end()) {}\n\n Polynomial(const initializer_list& v) \n : Polynomial(v.begin(), v.end()) {}\n\n static type from_root(const Field& root) {\n return Polynomial({-root, 1});\n }\n\n void normalize() const {\n type* self = const_cast(this);\n int sz = self->p.size();\n while(sz > 0 && self->p[sz-1] == 0) sz--;\n if(sz != (int)self->p.size())\n self->p.resize(sz);\n }\n\n inline int size() const { return p.size(); }\n inline int degree() const { return max((int)p.size()-1, 0); }\n bool null() const {\n for(Field x : p)\n if(x != 0) return false;\n return true;\n }\n\n inline Field operator[](const int i) const { \n if(i >= size())\n return 0;\n return p[i]; \n }\n inline Field& operator[](const int i) {\n if(i >= size())\n p.resize(i + 1);\n return p[i]; \n }\n\n type& operator+=(const type& rhs) {\n if(rhs.size() > size())\n p.resize(rhs.size());\n int sz = size();\n for(int i = 0; i < sz; i++)\n p[i] += rhs[i];\n normalize();\n return *this;\n }\n\n type& operator-=(const type& rhs) {\n if(rhs.size() > size())\n p.resize(rhs.size());\n int sz = size();\n for(int i = 0; i < sz; i++)\n p[i] -= rhs[i];\n normalize();\n return *this;\n }\n\n type& operator*=(const type& rhs) {\n p = Mult()(p, rhs.p);\n normalize();\n return *this;\n }\n\n type& operator*=(const Field& rhs) {\n int sz = size();\n for(int i = 0; i < sz; i++)\n p[i] *= rhs;\n normalize();\n return *this;\n }\n\n type& operator/=(const Field& rhs) {\n int sz = size();\n for(int i = 0; i < sz; i++)\n p[i] /= rhs;\n normalize();\n return *this;\n }\n\n type& operator<<=(const int rhs) {\n if(rhs < 0) return *this >>= rhs;\n if(rhs == 0) return *this;\n int sz = size();\n p.resize(sz + rhs);\n for(int i = sz-1; i >= 0; i--)\n p[i + rhs] = p[i];\n fill_n(p.begin(), rhs, 0);\n return *this;\n }\n\n type& operator>>=(const int rhs) {\n if(rhs < 0) return *this <<= rhs;\n if(rhs == 0) return *this;\n int sz = size();\n if(rhs >= sz) {\n p.clear();\n return *this;\n }\n for(int i = rhs; i < sz; i++)\n p[i - rhs] = p[i];\n p.resize(sz - rhs);\n return *this;\n }\n\n type& operator%=(const int rhs) {\n if(rhs < size())\n p.resize(rhs);\n normalize();\n return *this;\n }\n\n type& operator/=(const type& rhs) {\n return *this = *this / rhs;\n }\n\n type operator%=(const type& rhs) {\n return *this = *this % rhs;\n }\n\n type operator+(const type& rhs) const {\n type res = *this;\n return res += rhs;\n }\n\n type operator-(const type& rhs) const {\n type res = *this;\n return res -= rhs;\n }\n\n type operator*(const type& rhs) const {\n return type(Mult()(p, rhs.p));\n }\n\n type operator*(const Field& rhs) const {\n type res = *this;\n return res *= rhs;\n }\n\n type operator/(const Field& rhs) const {\n type res = *this;\n return res /= rhs;\n }\n\n type operator<<(const int rhs) const {\n type res = *this;\n return res <<= rhs;\n }\n\n type operator>>(const int rhs) const {\n type res = *this;\n return res >>= rhs;\n }\n\n type operator%(const int rhs) const {\n return Polynomial(p.begin(), p.begin() + min(rhs, size()));\n }\n\n type operator/(const type& rhs) const {\n return type::divmod(*this, rhs).first;\n }\n\n type operator%(const type& rhs) const {\n return type::divmod(*this, rhs).second;\n }\n\n bool operator==(const type& rhs) const {\n normalize();\n rhs.normalize();\n return p == rhs.p;\n }\n\n type inverse() const {\n int sz = size();\n if(sz == 0)\n return type();\n if(sz == 1) {\n assert(p[0] != 0);\n return type(p[0].inverse());\n }\n type q = (*this % ((sz+1)/2)).inverse();\n q -= (*this * q % sz - type(1)) * q % sz;\n return q % sz;\n }\n\n type reciprocal() const {\n normalize();\n return type(p.rbegin(), p.rend());\n }\n\n type integral() const {\n int sz = size();\n if(sz == 0) return {};\n type res = *this;\n for(int i = sz; i; i--) {\n res[i] = res[i-1] / i;\n }\n res[0] = 0;\n res.normalize();\n return res;\n }\n\n type derivative() const {\n int sz = size();\n if(sz == 0) return {};\n type res = *this;\n for(int i = 0; i + 1 < sz; i++) {\n res[i] = res[i+1] * (i + 1);\n }\n res.p.back() = 0;\n res.normalize();\n return res;\n }\n\n static pair divmod(const type& a, const type& b) {\n a.normalize();\n b.normalize();\n int m = a.size();\n int n = b.size();\n if(m < n) return {Polynomial(), a};\n type ar = a.reciprocal();\n type bri = (b.reciprocal() % (m - n + 1)).inverse();\n type q = (ar * bri % (m - n + 1)).reciprocal();\n type r = a - b * q;\n\n if(r.degree() >= b.degree()) {\n q += divmod(r, b).first;\n r = a - b * q;\n }\n\n return {q, r};\n }\n\n static type power(const type& a, long long n, const int mod) {\n return math::generic_power(a, n, DefaultPowerOp(mod));\n }\n\n static type power(const type& a, long long n, const type& mod) {\n return math::generic_power(a, n, ModPowerOp(mod));\n }\n\n static type kth(int K) {\n return type(1) << K;\n }\n\n static type kth(long long K, const type& mod) {\n return math::generic_power(type(1) << 1, K, ModShiftPowerOp(mod));\n }\n\n friend ostream& operator<<(ostream& output, const type& var) {\n output << \"[\";\n int sz = var.size();\n for(int i = sz-1; i >= 0; i--) {\n output << var[i];\n if(i) output << \" \";\n }\n return output << \"]\";\n }\n };\n} // namespace poly\n/// keep caide\nusing poly::Polynomial;\n} // namespace math\n} // namespace lib\n\n#endif\n#ifndef _LIB_LINEAR_RECURRENCE\n#define _LIB_LINEAR RECURRENCE\n#include \n\nnamespace lib {\n using namespace std;\nnamespace linalg {\n namespace {\n using traits::IsRandomIterator;\n using traits::HasRandomIterator;\n }\n\n template\n struct BMSolver {\n typedef BMSolver

q;\n q.emplace(n,-1);\n while(!q.empty()){\n int v,p;\n tie(v,p)=q.front();q.pop();\n par[v]=p;\n if(~p) lct.link(lct[p],lct[v]);\n for(int u:G[v])\n if(u!=p) q.emplace(u,v);\n }\n }\n\n vector delta(m+1,0);\n vector color(n+1,0);\n\n for(int c=0;c>n>>m;\n vector xs(n);\n for(int i=0;i>xs[i];\n using T = tuple;\n vector vt;\n for(int i=0;i>a>>b>>y;\n a--;b--;\n vt.emplace_back(y,a,b);\n }\n sort(vt.begin(),vt.end());\n\n using ll = long long;\n using Node = NodeBase;\n constexpr size_t LIM = 1e6;\n using LCT = SubTree;\n LCT lct;\n\n for(int i=0;i;\n set

es;\n for(auto t:vt){\n int a,b;\n tie(ignore,a,b)=t;\n if(lct.is_connected(lct[a],lct[b])) continue;\n lct.evert(lct[b]);\n lct.link(lct[a],lct[b]);\n es.emplace(a,b);\n }\n\n int ans=0;\n reverse(vt.begin(),vt.end());\n for(auto t:vt){\n int y,a,b;\n tie(y,a,b)=t;\n auto rt=lct.root(lct[a]);\n ll sum=lct.query(rt);\n if(sum>=y) continue;\n ans++;\n if(es.count(P(a,b))){\n lct.evert(lct[a]);\n lct.cut(lct[b]);\n }\n }\n\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define PER(i,a,b) for(int i = a; i>=b; --i)\n#define mp make_pair\n#define pb emplace_back\n#define fi first\n#define se second\n\nconst int inf=INT_MAX;\nconst int maxn=1e5 + 1;\nconst int N=2e3 + 5;\nconst int mod = 998244353;\nint n,a[105],cnt=0;\nsigned main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n cin >> n;\n REP(i,1,n)\n cin >> a[i];\n sort(a+1,a+n+1);\n for(int i=1; i<=n; i+=2)\n cnt+=abs(a[i]-a[i+1]);\n cout << cnt;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f50078e1905f9e7623df329364f4ce2b", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nint ans[10000009]={-1,0,0,0,1,1,8,8,13,21,44,44,53,53,87,102,119,119,134,134,151,170,231,231,252,288,365,403,434,434,461,461,496,532,636,685,722,722,842,890,935,935,976,976,1025,1081,1228,1228,1277,1358,1413,1475,1536,1536,1591,1670,1733,1801,1991,1991,2050,2050,2251,2336,2415,2512,2581,2581,2662,2747,2822,2822,2897,2897,3136,3233,3324,3445,3526,3526,3615,3730,4001,4001,4086,4213,4500,4612,4719,4719,4810,4955,5068,5186,5505,5652,5759,5759,5876,6016,6133,6133,6242,6242,6367,6497,6854,6854,6971,6971,7092,7232,7363,7363,7482,7654,7795,7957,8352,8544,8667,8881,9297,9458,9615,9822,9957,9957,10120,10287,10436,10436,10577,10792,11251,11434,11605,11605,11756,11756,11911,12092,12578,12822,12983,13210,13717,13925,14116,14116,14275,14275,14466,14688,14869,15111,15282,15282,15827,16037,16228,16495,16678,16678,16887,17103,17680,17680,17861,18168,18367,18618,18839,18839,19032,19302,19521,19754,20374,20374,20565,20565,20780,21020,21253,21543,21750,22072,22313,22577,22800,22800,23015,23015,23684,23941,24180,24180,24395,24395,24630,24891,25587,25924,26149,26471,27188,27494,27757,28120,28337,28337,28610,28892,29641,29983,30230,30595,31365,31661,31922,32316,32571,32571,32850,33162,33964,33964,34223,34223,34498,34815,35116,35116,35377,35751,36058,36375,36664,36664,36921,36921,37224,37588,37903,38282,38559,38992,39311,39641,39942,39942,40215,40653,41542,41884,42219,42219,42510,42944,43249,43635,44556,44556,44849,45270,45593,45949,46298,46298,46587,46587,46932,47302,48261,48700,49011,49011,49986,50402,50725,50725,51044,51044,51411,51793,52142,52623,52950,53481,53826,54213,54592,54592,54911,55377,55758,56185,57230,57758,58081,58587,59653,60061,60454,60942,61289,61289,61660,62074,62447,62447,62796,62796,63900,64310,64723,64723,65084,65643,66030,66458,66851,67428,67799,68322,69474,69913,70342,70899,71250,71250,71685,72182,73366,73904,74277,74277,74710,75165,75572,76173,76562,77162,77613,78082,79314,79314,79713,79713,80120,80634,81083,81083,81488,82055,82522,83016,84286,84286,84677,85348,86634,87166,87611,88198,88621,88621,89100,89656,90105,90735,91162,91162,91629,92149,92642,93315,93734,93734,94189,94701,96057,96057,96500,97078,98450,99035,99548,99548,99965,100671,101162,101693,103097,103734,104183,104183,105603,106165,106658,106658,107123,107846,108381,108947,109452,110176,110643,110643,111142,111699,112244,112948,113423,114091,114628,115193,115720,115720,116163,116163,117664,118303,118862,119558,120051,120778,121345,121954,122479,122479,122980,122980,123517,124112,124687,125479,125984,125984,126505,127132,127687,127687,128194,128904,130486,131089,131650,131650,132139,132935,133530,134139,135753,136442,136963,136963,138593,139275,139832,139832,140333,140333,140938,141574,143231,143231,143760,144557,145128,145764,146385,147222,147769,148548,149133,149853,151558,151558,152083,152946,154667,155349,155972,156756,157323,157323,157968,158632,159207,159207,159774,160669,161294,161959,162610,163457,164034,164034,164647,165324,167115,167115,167676,168489,169128,169875,170548,170548,171097,171965,172644,173407,175241,176071,176668,177587,178234,178939,179564,179564,180165,180165,180858,181547,183424,184382,184981,185974,186623,187429,188088,189047,189668,190531,191242,191972,193902,194810,195407,195407,197353,198095,198808,199691,200294,200294,201025,201861,202522,203533,204172,205119,207113,207886,208631,208631,209280,210290,210953,211762,213788,213788,214447,215364,217406,218229,218990,218990,219615,219615,220336,221121,221844,222799,223476,223476,224233,225024,225735,226731,227412,228455,229234,230031,232143,232143,232806,233889,234618,235427,236214,236214,236893,237809,238606,239421,240188,240188,240851,240851,241606,242522,243327,244305,245012,245012,245807,246667,247416,248515,249218,249218,251417,252268,253023,253023,253742,253742,254497,255426,257652,258717,259430,260486,262733,263638,264477,265628,266301,266301,267142,268005,270284,271315,272058,273140,273957,274934,275729,275729,276480,276480,277283,278178,279007,279007,279764,280922,281705,282628,283497,283497,284258,285315,286182,287181,288006,288006,288715,288715,291081,292037,292918,293939,294710,295937,296826,297736,298559,299754,300507,300507,302921,303865,304742,304742,305531,306691,307514,308440,309309,309309,310094,311198,312063,312995,313904,315143,315894,315894,316813,317767,320251,321372,322177,323448,325953,326906,327733,327733,328536,329825,330734,331711,334248,335461,336288,336288,337163,338247,339196,340511,341302,342419,343376,344354,346939,346939,347736,348972,349921,350908,351877,353085,353916,353916,354815,355932,356833,358169,359024,359024,361663,362637,363608,364927,365788,365788,366697,367771,368706,368706,369569,370774,373456,374597,375546,376830,377661,377661,378660,379687,380656,381878,382729,382729,385454,386553,387480,387480,388371,389676,390697,391744,394501,395890,396793,396793,397680,398733,399766,399766,400667,401957,402992,404097,406897,408331,409180,410579,411590,412776,413773,415047,415970,415970,417025,418103,419080,420435,421342,422776,425640,426750,427819,427819,428708,430172,431167,432393,435289,436730,437675,438927,439970,441078,442163,442163,443064,443064,444085,445197,446244,447567,448512,450016,452971,454119,455134,455134,456101,456101,457204,458322,459367,459367,460328,460328,461353,462486,463569,464991,465968,467320,468383,469648,472668,472668,473567,475158,478194,479348,480481,481862,482853,484281,485414,486576,487615,489193,490194,490194,491275,492450,493597,493597,494560,494560,495619,496844,499950,499950,500965,502367,505489,506788,507881,509439,510398,511977,513146,514483,515618,517002,518031,518031,521201,522406,523471,523471,524468,524468,525597,526830,530027,530027,531064,532592,533695,535011,536208,537853,538904,540358,541499,542809,546054,547730,548733,550390,551555,552850,554065,555538,556607,556607,557828,559223,560282,560282,561341,562978,566282,567564,568797,570377,571444,571444,572575,573839,577175,578853,579878,581431,584788,586217,587456,587456,588487,590093,591350,592635,596024,597511,598598,598598,599793,601087,602256,602256,603369,605124,606391,607653,608878,608878,609995,611719,612886,614193,615386,615386,616507,618062,619349,620746,624216,625871,626944,628773,630024,631506,632807,634381,635468,635468,636731,638157,639366,639366,640515,642190,645719,647056,648367,648367,649522,651283,652452,653961,657522,657522,658679,660285,661572,662992,664265,666105,667188,667188,668511,669877,671142,672762,673937,673937,677552,679078,680329,681962,683147,684996,686351,687763,691415,693282,694431,694431,695692,697086,698389,698389,699564,701150,702519,704085,707780,707780,708905,708905,710206,711705,713088,714811,716008,717876,719263,720756,722041,722041,723254,723254,724591,726026,727337,729244,730469,730469,731734,733163,736934,738732,739955,741615,745407,746850,748263,748263,749396,749396,750813,752384,753759,755477,756694,758515,759920,761376,762693,762693,763942,763942,765275,766765,768148,770065,771322,771322,772651,774161,775596,777596,778861,780663,782110,783586,784919,786875,788078,790083,793999,795631,797092,798787,800070,800070,801505,803117,804474,804474,805687,805687,809641,811174,812647,812647,813936,815825,817156,818665,820102,820102,821387,823143,824546,826230,827719,827719,828944,830935,832426,834018,838042,839854,841159,841159,842608,844140,845471,847538,848807,848807,850316,851894,855961,857905,859228,859228,860631,862288,863809,865840,867123,868966,870487,872044,876159,878253,879508,881471,885607,887365,888818,890683,892038,894185,895642,897222,898641,898641,900004,900004,904183,905675,907202,909305,910674,912817,914252,916026,917507,917507,918880,920776,922287,923890,925459,927472,928755,928755,930334,932063,936317,938293,939630,941747,943290,945104,946573,946573,947970,949980,951563,953225,957527,957527,958898,961121,962518,964156,965763,965763,967174,969119,970664,972360,976705,978862,980205,980205,984566,986223,987754,989719,991144,993370,995001,996784,998257,1000347,1001782,1001782,1006191,1007909,1009524,1009524,1010899,1013170,1014691,1016485,1018080,1018080,1019507,1021449,1025901,1027593,1029254,1029254,1030623,1030623,1032152,1034050,1038529,1040507,1041970,1041970,1046465,1048253,1049792,1052082,1053539,1055779,1057462,1059216,1060809,1063146,1064597,1064597,1066164,1068094,1069787,1071951,1073382,1075431,1077128,1078862,1080513,1080513,1081876,1084173,1088759,1090502,1092207,1094230,1095733,1097922,1099639,1101586,1103177,1105564,1107069,1109431,1111026,1112791,1114444,1114444,1115957,1115957,1117562,1119409,1124070,1124070,1125591,1127689,1132366,1134223,1135854,1135854,1137293,1137293,1138972,1140755,1145459,1147494,1149035,1149035,1150724,1152516,1154107,1154107,1155578,1155578,1157337,1159155,1163897,1163897,1165444,1167597,1169234,1171179,1172938,1175330,1176883,1179029,1180704,1182519,1187309,1187309,1188756,1188756,1193557,1195479,1197270,1199507,1201024,1201024,1202813,1204645,1206212,1208649,1210218,1212719,1214474,1216353,1218158,1220468,1222055,1224495,1226168,1228237,1229984,1232463,1233996,1236193,1241090,1242951,1244778,1247283,1248800,1251137,1252920,1254915,1259849,1262068,1263681,1266220,1267963,1270067,1271748,1271748,1273369,1275929,1277700,1279484,1284466,1284466,1286073,1288693,1290414,1292312,1294079,1294079,1295714,1297960,1299813,1301895,1303702,1306089,1307626,1307626,1312662,1314576,1316453,1318721,1320272,1322850,1324735,1326657,1328404,1330946,1332591,1335003,1336842,1338797,1340694,1343222,1344889,1344889,1346572,1348509,1353625,1356251,1357892,1360195,1362054,1364093,1365946,1365946,1367527,1370139,1372058,1374245,1376062,1378379,1380062,1382651,1387831,1389931,1391716,1394199,1395894,1395894,1397825,1399809,1401698,1401698,1403311,1403311,1405020,1407222,1409165,1409165,1410872,1413130,1415079,1417065,1422310,1422310,1423931,1426536,1428387,1430527,1432452,1434849,1436572,1436572,1438535,1440607,1442412,1442412,1444097,1444097,1449391,1451444,1453269,1456008,1457745,1457745,1459572,1461589,1463514,1465931,1467666,1470060,1475402,1477671,1479664,1482345,1483944,1483944,1485911,1487946,1489871,1492365,1494112,1496667,1502057,1504262,1506111,1506111,1507816,1507816,1509713,1511744,1517161,1517161,1518918,1518918,1520787,1522943,1524966,1524966,1526737,1529143,1531064,1533130,1535049,1535049,1536732,1539515,1544981,1547303,1549328,1551697,1553488,1556210,1558175,1560259,1562154,1562154,1563881,1566676,1572190,1574328,1576385,1579246,1580989,1583640,1585521,1587801,1593352,1593352,1595165,1597748,1599707,1601819,1603892,1606656,1608355,1608355,1610434,1612652,1614665,1617177,1619008,1621896,1627506,1629841,1631646,1634530,1636369,1636369,1638464,1640647,1646289,1648863,1650700,1650700,1652633,1654927,1657030,1657030,1658797,1661343,1663456,1665866,1667925,1667925,1669648,1672350,1674391,1676552,1678599,1681159,1683008,1683008,1685025,1687192,1689163,1689163,1691030,1693801,1699535,1701646,1703783,1706712,1708591,1708591,1710570,1712925,1714954,1714954,1716791,1719380,1721459,1723870,1726023,1728770,1730549,1733546,1735703,1738152,1743961,1746524,1748327,1748327,1750434,1752806,1754819,1754819,1756720,1759490,1761665,1763929,1766026,1766026,1767931,1767931,1769836,1772322,1774421,1774421,1776336,1778941,1781122,1783384,1789269,1789269,1791086,1791086,1796982,1799221,1801282,1803947,1805878,1805878,1807989,1810502,1812543,1815357,1817264,1820309,1822462,1824765,1826980,1826980,1828811,1831764,1833805,1836066,1842037,1845123,1847074,1849662,1855654,1858188,1860417,1863466,1865281,1868295,1870408,1872876,1878905,1881614,1883565,1883565,1889610,1892016,1894099,1897102,1899083,1899083,1901280,1903618,1905721,1905721,1907704,1907704,1909799,1912108,1914261,1917153,1919128,1921962,1924235,1926724,1932839,1935977,1937804,1941021,1943278,1945728,1948015,1950773,1952782,1955701,1957992,1960330,1962407,1965550,1967557,1967557,1969672,1972067,1974356,1974356,1976377,1976377,1978474,1980947,1983198,1986305,1988326,1991066,1997283,1999644,2001831,2001831,2003730,2006944,2009261,2011628,2017877,2020607,2022562,2025740,2032010,2034674,2036827,2036827,2038788,2038788,2041129,2043535,2049832,2052956,2055019,2057900,2060077,2062475,2064830,2064830,2066865,2069707,2071920,2074610,2076885,2080168,2082113,2082113,2084402,2086928,2089291,2092147,2094224,2094224,2096517,2099103,2101206,2104444,2106525,2106525,2112919,2115336,2117721,2120762,2122857,2122857,2125008,2127443,2133869,2137201,2139222,2142112,2148559,2151207,2153498,2156828,2158817,2161762,2164173,2166923,2173407,2176422,2178531,2178531,2180820,2183288,2185527,2188788,2190865,2190865,2193290,2195642,2198009,2198009,2200140,2200140,2202391,2205165,2207474,2210716,2212787,2215726,2218167,2220655,2223042,2226157,2228186,2228186,2230567,2233061,2235412,2238414,2240471,2243772,2246223,2249011,2251288,2251288,2253445,2256614,2263233,2265720,2268187,2271586,2273751,2277118,2279261,2281782,2288438,2288438,2290585,2293681,2296074,2298701,2301188,2304636,2306693,2306693,2309182,2311909,2314268,2317273,2319430,2322752,2329467,2332016,2334307,2337498,2339699,2343131,2345642,2348239,2350672,2350672,2352745,2356288,2358603,2361167,2363688,2367119,2369330,2372262,2374759,2377331,2384126,2387411,2389498,2389498,2391861,2394701,2397238,2400296,2402527,2402527,2405070,2407782,2410035,2410035,2412224,2412224,2419068,2421729,2424138,2424138,2426379,2426379,2428732,2431475,2438346,2441608,2443855,2446909,2449414,2452238,2454793,2454793,2456852,2460414,2462883,2465503,2472422,2475528,2477787,2481074,2483575,2486519,2488878,2488878,2491149,2494591,2497000,2499696,2506663,2506663,2508932,2512506,2514913,2517616,2520217,2520217,2522426,2525563,2528170,2531129,2533598,2537169,2539336,2542892,2545479,2548143,2550666,2553612,2555909,2559555,2562178,2564850,2567283,2567283,2569476,2569476,2576540,2579262,2581811,2585355,2587602,2590961,2593402,2596090,2603191,2606852,2609179,2612369,2614878,2617766,2620421,2620421,2622584,2622584,2625227,2628037,2635181,2638365,2640702,2644346,2646917,2649633,2651998,2655708,2658051,2661645,2664322,2667106,2674303,2677717,2680060,2683629,2686118,2689167,2691770,2691770,2694029,2697386,2699959,2702702,2705337,2705337,2707528,2710962,2718218,2720970,2723647,2726906,2729285,2729285,2731844,2734762,2737275,2740881,2743260,2743260,2750559,2753196,2755919,2755919,2758294,2758294,2760821,2763828,2766277,2766277,2768670,2771956,2774615,2777726,2780459,2783980,2786243,2786243,2788982,2791965,2794638,2797905,2800220,2800220,2807595,2810392,2812935,2816763,2819180,2822666,2825293,2828168,2835580,2835580,2837955,2837955,2840378,2843191,2845952,2849735,2852162,2855449,2858222,2861179,2868634,2868634,2870907,2874643,2882114,2885285,2887916,2891272,2893641,2897479,2900274,2903117,2905690,2909248,2911671,2911671,2914382,2917294,2920095,2923763,2926130,2930011,2932608,2935806,2943357,2943357,2945814,2949085,2956652,2959740,2962451,2962451,2964770,2968629,2971286,2974164,2976919,2980449,2982934,2986858,2994473,2997405,2999976,2999976,3002471,3002471,3005314,3008272,3010965,3010965,3013442,3013442,3015967,3019103,3021954,3025459,3027964,3031401,3034252,3037506,3045186,3045186,3047481,3051287,3058983,3061904,3064773,3068230,3070701,3074404,3077189,3080362,3083029,3083029,3085496,3085496,3088223,3091206,3094047,3098037,3100572,3104454,3107119,3110204,3117975,3121823,3124358,3127894,3135686,3138644,3141353,3141353,3143758,3143758,3146563,3149865,3152672,3156057,3158610,3158610,3166440,3169665,3172366,3172366,3174795,3174795,3177704,3180571,3183434,3187433,3190002,3193732,3196431,3199772,3202705,3202705,3205282,3208818,3211521,3214514,3217363,3221369,3223812,3223812,3226691,3229835,3232784,3236334,3238889,3242811,3245764,3249130,3251725,3255700,3258297,3262415,3270374,3273429,3276336,3280115,3282660,3282660,3285409,3288436,3296427,3300564,3303031,3306605,3314617,3318025,3321014,3324983,3327458,3331265,3334254,3337554,3345603,3349214,3351841,3355922,3358767,3361829,3364540,3368706,3371351,3371351,3374272,3377248,3385345,3385345,3387966,3392216,3394903,3398198,3401055,3401055,3403696,3407338,3410365,3413450,3421590,3425450,3427955,3427955,3430884,3434165,3437200,3440992,3443549,3447691,3450738,3453841,3456666,3460860,3463519,3467259,3475463,3478646,3481599,3481599,3484288,3484288,3487001,3490478,3493469,3493469,3496056,3499747,3507989,3511269,3514342,3518472,3521027,3521027,3524106,3527242,3530123,3533782,3536477,3540760,3549050,3552570,3555431,3559248,3561887,3566172,3569269,3572495,3575486,3575486,3578105,3578105,3580980,3584141,3587234,3587234,3589963,3593479,3596590,3599941,3602974,3607306,3609861,3609861,3612812,3615986,3619107,3622862,3625601,3625601,3628544,3631878,3634775,3639099,3641846,3641846,3644913,3648107,3651056,3651056,3653809,3657922,3660793,3664231,3672667,3676719,3679484,3683270,3691727,3694936,3698091,3698091,3700574,3700574,3703665,3707260,3710321,3714122,3716897,3720921,3724010,3727232,3730139,3734347,3737116,3741477,3744476,3747746,3756278,3760548,3763337,3767667,3770618,3773993,3777058,3777058,3779859,3783695,3786874,3790397,3793422,3793422,3796027,3796027,3804613,3808101,3811302,3815022,3817761,3817761,3820968,3824572,3827529,3827529,3830238,3834549,3837648,3840992,3844113,3844113,3846934,3851028,3853999,3857277,3865933,3870321,3873154,3876987,3879974,3883654,3886859,3891305,3893984,3893984,3897223,3900679,3909383,3913347,3916128,3916128,3919309,3922868,3925699,3925699,3928554,3928554,3931801,3935170,3943912,3947908,3950769,3950769,3953790,3957111,3960238,3960238,3962957,3966886,3970155,3973758,3976913,3976913,3979628,3983890,3992686,3996408,3999689,4003604,4006487,4011027,4014120,4017704,4020751,4020751,4023630,4028128,4031337,4034541,4037832,4037832,4040643,4045230,4048203,4051963,4055090,4055090,4057985,4062106,4070988,4074358,4077671,4081886,4084637,4088812,4092069,4095447,4104366,4108364,4111147,4111147,4114402,4118192,4121265,4121265,4124098,4128336,4131555,4135025,4143987,4143987,4146874,4151500,4154461,4158154,4161501,4165947,4168888,4172917,4176268,4179751,4188761,4188761,4191532,4196149,4205175,4208601,4211698,4215736,4218691,4218691,4222062,4225494,4228499,4232790,4235749,4235749,4244818,4248224,4251607,4251607,4254450,4259150,4262259,4265707,4269010,4273563,4276508,4280451,4283726,4287182,4290579,4295223,4298038,4302775,4305992,4309868,4313207,4317305,4320238,4324767,4333932,4337505,4340676,4345428,4348429,4348429,4351850,4355411,4358654,4363360,4366257,4370859,4374038,4377897,4381326,4385693,4388712,4392845,4396182,4399683,4408928,4413501,4416268,4416268,4419611,4423486,4426939,4431242,4434277};\n\nint main()\n{\n\tint n;\n\tcin>>n;\n\tprintf(\"%d\",ans[n]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c58d64afcf65a0bc9e16e76a3da92bb4", "src_uid": "bb1bd5d8bab7d79e514281230d484996", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "// iostream is too mainstream\n#include \n// bitch please\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define dibs reserve\n#define OVER9000 1234567890\n#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)\n#define tisic 47\n#define soclose 1e-5\n#define chocolate win\n// so much chocolate\n#define patkan 9\n#define ff first\n#define ss second\n#define abs(x) ((x < 0)?-(x):x)\n#define uint unsigned int\n#define dbl long double\nusing namespace std;\nusing namespace std::tr1;\n// mylittledoge\n\nint main() {\n\tcin.sync_with_stdio(0);\n\tcin.tie(0);\n\tint l1,r1,l2,r2;\n\tcin >> l1 >> r1 >> l2 >> r2;\n\tint ans =0;\n\tfor(int i =1; i <= 30; i++) \n {\n\t\t\n\t\tint k1l =l1/(1<= l2) k2l--;\n\n\t\tif(k2r*(1< 2 && k1l-k1r+1 > 2) {\n\t\t\tans =max(ans,(1< > p1,p2;\n\t\tfor(int k =k1l; k < k1r; k++) {\n\t\t\tint x =0, y =(1<ss,it->ss)-max(it->ff,jt->ff)+1);\n\t\t}\n\tcout << ans << \"\\n\";\n\treturn 0;}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9a6f7cbf46e232f1080bfc1e4564294c", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define fir first\n#define sec second\n\ntypedef long long LL;\ntypedef pair PP;\n\nnamespace INPUT{\n\tconst int L=1<<15;\n\tchar _buf[L],*S,*T,c;\n\tchar _gc(){\n\t\tif(S==T){\n\t\t\tT=(S=_buf)+fread(_buf,1,L,stdin);\n\t\t\tif(S==T) return EOF;\n\t\t}\n\t\treturn *S++;\n\t}\n\tvoid readi(int &X){\n\t\tfor(c=_gc();c<'0'||c>'9';c=_gc());X=c&15;\n\t\tfor(c=_gc();c>='0'&&c<='9';X=X*10+(c&15),c=_gc());\n\t}\n}\n#define readi INPUT::readi\n\nconst int Maxn=3E5+5;\n\nint N,M,Q;\nint lastans;\n\nint n,nv,m;\nint V[Maxn<<1];\nint v[Maxn];\nstruct Edge{\n\tint u,v;\n}e[Maxn];\n\nint Np,P[Maxn];\n\nint Turn(int X){return (X+lastans-1)%N+1;}\n\nint Nt;\nnamespace T{\n\tstruct E{\n\t\tint v,nxt;\n\t}adj[Maxn<<1];\n\tint hed[Maxn],TE;\n\t\n\tint tim;\n\tint id[Maxn];\n\tint dfn[Maxn];\n\tint dep[Maxn];\n\tint fa[Maxn][20];\n\t\n\tvoid Clear(){\n\t\tmemset(hed,-1,sizeof(hed));\n\t}\n\t\n\tvoid addedge(int u,int v){\n\t++TE,adj[TE].v=v,adj[TE].nxt=hed[u],hed[u]=TE;}\n\t\n\tvoid Dfs(int u,int Fa,int ID){\n\t\t//cerr<=0;--k)\n\t\t\tif(dep[fa[X][k]]>=dep[Y])\n\t\t\t\tX=fa[X][k];\n\t\tif(X==Y) return X;\n\t\tfor(int k=19;k>=0;--k)\n\t\t\tif(fa[X][k]!=fa[Y][k])\n\t\t\t\tX=fa[X][k],Y=fa[Y][k];\n\t\treturn fa[X][0];\n\t}\n}\n\nnamespace G{\n\tstruct E{\n\t\tint v,nxt;\n\t}adj[Maxn<<1];\n\tint hed[Maxn],TE;\n\t\n\tint tim;\n\tint dfn[Maxn],low[Maxn];\n\tbool ins[Maxn];\n\tint stk[Maxn],tp;\n\tint bel[Maxn],Scc;\n\tint Bel[Maxn];\n\t\n\tvoid Clear(){\n\t\tTE=tim=tp=Scc=0;\n\t\tfor(int i=1;i<=Np;++i)\n\t\t\thed[P[i]]=-1,bel[P[i]]=dfn[P[i]]=low[P[i]]=0;\n\t}\n\t\n\tvoid Clear2(){\n\t\tTE=tim=tp=Scc=0;\n\t\tmemset(hed,-1,sizeof(hed)),\n\t\tmemset(bel,0,sizeof(bel)),\n\t\tmemset(dfn,0,sizeof(dfn)),\n\t\tmemset(low,0,sizeof(low));\n\t}\n\t\n\tvoid addedge(int u,int v){\n\t++TE,adj[TE].v=v,adj[TE].nxt=hed[u],hed[u]=TE;}\n\t\n\tvoid Addedge(int u,int v){\n\t\t//cerr< Set;\n\t\tfor(int u=1;u<=N;++u)\n\t\t\tfor(int k=hed[u];k!=-1;k=adj[k].nxt)\n\t\t\t\tif(bel[adj[k].v]!=bel[u]&&Set.find(PP(bel[u],bel[adj[k].v]))==Set.end())\n\t\t\t\t\tSet.insert(PP(bel[u],bel[adj[k].v])),T::addedge(bel[u],bel[adj[k].v]);\n\t\tfor(int i=1;i<=N;++i) Bel[i]=bel[i];\n\t}\n\t\n\tvoid Work(){\n\t\t//cerr<<'a'<0){\n\t\t\tf=LCA(t,stk[tp]);\n\t\t\tif(tp>1&&dep[f]0&&stk[tp]!=f) stk[++tp]=f,P[++Np]=f;\n\t\tstk[++tp]=t,P[++Np]=t;\n\t\tif(i==nv||T::id[i+1]!=T::id[i]){\n\t\t\twhile(tp>1) Addedge(stk[tp-1],stk[tp]),--tp;\n\t\t\ttp=0;\n\t\t}\n\t}\n\tfor(int i=1;i<=m;++i)\n\t\tAddedge(Bel[e[i].u],Bel[e[i].v]);\n\tG::Tarjan(Bel[v[1]],0);\n\tint tmp=G::bel[Bel[v[1]]];\n\tbool flag=true;\n\t//for(int i=1;i<=n;++i) cerr<\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int MAX = 100;\n\nint main()\n{\n\tint n;\n\tcin>>n;\n\tint a=0,b=0;\n\tint v[10];\n\tmemset(v,0,sizeof(v))\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\ta+=n/i;\n\t\tv[i%9]++;\n\t}\n\tfor(int i=0;i<9;i++)\n\t{\n\t\tfor(int j=0;j<9;j++)\n\t\t{\n\t\t\tb+=v[i] * v[j] * v[i*j%9];\n\t\t}\n\t}\n\tcout<\n#include \n\n#define pb push_back\n\nusing namespace std;\n\ntypedef pair pii;\n\nint n, q;\nint a[4097];\nint topos[4097];\n\nint cnt;\nvector part;\n\nvector ans;\nint anspos[1000001];\n\nstruct seg{\n struct node{\n int l, r;\n int pos;\n } seg[1000001];\n \n void query(int p, int l, int r)\n {\n if(seg[p].l>=l && seg[p].r<=r)\n part.pb(seg[p].pos);\n else{\n if(l<(seg[p].l+seg[p].r)/2)\n query(2*p, l, r);\n if(r>(seg[p].l+seg[p].r)/2)\n query(2*p+1, l, r);\n }\n }\n \n void build(int p, int l, int r)\n {\n seg[p].l=l, seg[p].r=r;\n if(l+1> n >> q, cnt=n;\n for(i=1;i<=n;i++)\n cin >> a[i], topos[a[i]]=i;\n \n ds.build(1, 1, n+1);\n for(i=1;i<=q;i++){\n int x, y;\n cin >> x >> y;\n part.clear();\n ds.query(1, x, y+1);\n int cur=part[0];\n for(j=1;j\nusing namespace std;\nstring s1,s2,s3;\nint main()\n{\n\tcin>>s1>>s2>>s3;\n\tif((s1[0]=='r'&&s2[0]=='s'&&s3[0]=='s')||(s1[0]=='s'&&s2[0]=='p'&&s3[0]=='p')||(s1[0]=='p'&&s2[0]=='r'&&s3[0]=='r'))//\u5224\u65ad\u7b2c\u4e00\u4e2a\u4eba\u8d62\u7684\u60c5\u51b5\n\t\tcout<<\"F\\n\";\n\telse if((s2[0]=='r'&&s1[0]=='s'&&s3[0]=='s')||(s2[0]=='s'&&s1[0]=='p'&&s3[0]=='p')||(s2[0]=='p'&&s1[0]=='r'&&s3[0]=='r'))//\u5224\u65ad\u7b2c\u4e8c\u4e2a\u4eba\u8d62\u7684\u60c5\u51b5\n\t\tcout<<\"M\\n\";\n\telse if((s3[0]=='r'&&s1[0]=='s'&&s2[0]=='s')||(s3[0]=='s'&&s1[0]=='p'&&s2[0]=='p')||(s3[0]=='p'&&s1[0]=='r'&&s2[0]=='r'))//\u5224\u65ad\u7b2c\u4e09\u4e2a\u4eba\u8d62\u7684\u60c5\u51b5\n\t\tcout<<\"S\\n\";\n\telse //\u82e5\u90fd\u4e0d\u6ee1\u8db3\u4ee5\u4e0a\u6761\u4ef6\u5c31\u662f\u4e0d\u786e\u5b9a\n\t\tcout<<\"?\\n\";\n return 0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6576542dfe3296835bf01bb8e2825260", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nstruct Step {\n\tint x , y , r;\n\tStep() {}\n\tStep(int a,int b):x(a) , y(b) , r(a*a + b*b){}\n\tbool operator < (Step &cmp) const {\n\t\treturn r < cmp.r;\n\t}\n\tbool operator == (Step &cmp) const {\n\t\treturn r == cmp.r;\n\t}\n};\nvector vec;\nvector > X , Y;\nvoid preProcess() {\n\tfor (int i = 0 ; i < 200 ; i ++) {\n\t\tfor (int j = i ; j < 200 ; j ++) {\n\t\t\tvec.push_back(Step(i , j));\n\t\t}\n\t}\n\tsort(vec.begin() , vec.end());\n\tvec.erase(unique(vec.begin() , vec.end()) , vec.end());\n}\nbool cmpSlope(const Step &a,const Step &b) {\n\treturn a.x * 1.0 / a.y < b.x * 1.0 / b.y;\n}\nint main() {\n\tpreProcess();\n\tint n;\n\tcin >> n;\n\tint del = 0;\n\tfor (int i = 4 , cnt = 2 , bit = 1; ; i ++) {\n\t\tint p = bit & 1;\n\t\tint q = (vec[i].x + vec[i].y) & 1;\n\t\tif (p && q) {\n\t\t\tif (++cnt == n) del = 2;\n\t\t\t++cnt;\n\t\t} else if (p && !q) {\n\t\t\tif (++cnt == n) del = 4;\n\t\t} else if (!p && q) {\n\t\t\tif (++cnt == n) del = 4;\n\t\t}\n\t\tbit = (p + q) & 1;\n\t\tif (cnt >= n) {\n\t\t\tint sum = 0;\n\t\t\tfor (int j = 1 ; j <= i ; j ++) {\n\t\t\t\tif (j == del) continue;\n\t\t\t\tX.push_back(make_pair(vec[j].x , X.size()));\n\t\t\t\tY.push_back(make_pair(vec[j].y , Y.size()));\n\t\t\t\tsum = (sum + vec[j].x) & 1;\n\t\t\t}\n\t\t\tif (sum & 1) swap(X[0].first , Y[0].first);\n\t\t\tbreak;\n\t\t}\n\t}\n\tsort(X.begin() , X.end());\n\tsort(Y.begin() , Y.end());\n\tint sumX = 0 , sumY = 0;\n\tfor (int i = X.size() - 1 ; i >= 0 ; i --) {\n\t\tif (sumX >= X[i].first) {\n\t\t\tsumX -= X[i].first;\n\t\t\tX[i].first = -X[i].first;\n\t\t} else {\n\t\t\tsumX += X[i].first;\n\t\t}\n\t\tif (sumY >= Y[i].first) {\n\t\t\tsumY -= Y[i].first;\n\t\t\tY[i].first = -Y[i].first;\n\t\t} else {\n\t\t\tsumY += Y[i].first;\n\t\t}\n\t}\n\twhile (sumX || sumY);\n\tfor (int i = 0; i < X.size() ; i ++) {\n\t\tvec[ X[i].second ].x = X[i].first;\n\t\tvec[ Y[i].second ].y = Y[i].first;\n\t}\n\tvec.erase(vec.begin() + X.size() , vec.end());\n\tsort(vec.begin() , vec.end() , cmpSlope);\n\tputs(\"YES\");\n\tint sumx = 0 , sumy = 0;\n\tfor (int i = 0 ; i < vec.size() ; i ++) {\n\t\tsumx += vec[i].x;\n\t\tsumy += vec[i].y;\n\t\tcout << sumx << ' ' << sumy << endl;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "42ec0f2c0d5d3f98e8fd1020aae83b9a", "src_uid": "77b281558c480607b02e8e263e81a455", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n\nusing namespace std;\n#define ll long long\n#define double long double\n#define endl '\\n'\n#define sz(x) (int)(x).size()\n\n\n#define pb push_back\n#define pf push_front\n#define lb(v,n) lower_bound(all((v)),(n))\n#define ub(v,n) upper_bound(all((v)),(n))\n\n#define vi vector\n#define vll vector\n#define vii vector\n#define vpll vector\n#define viiii vector>\n\n#define mi map\n#define mll map\n#define mii map\n\n#define pii pair\n#define pll pair\n#define piii pair>\n#define piiii pair\n#define fi first\n#define se second\n#define mp make_pair\n#define all(a) (a).begin(),(a).end()\n#define rall(a) (a).rbegin(),(a).rend()\n\n#define fr(a,b,c) for(int a=b; a<=c; a++)\n#define rfr(a,b,c) for(int a=b; a>=c; a--)\n#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))\n#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))\n#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))\n#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))\n#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))\n#define toit ios::sync_with_stdio(0);cin.tie(0);\n\n#define w(x) int x; cin>>x; while(x--)\n\nconst ll mod = 1e9 + 7;;\n\nvoid arshit_babariya() {\n\ttoit\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n}\n\nint logb(int base, int x) {\n\treturn (log(x) / log(base));\n}\nint occurs(vll v, int n) {\n\tauto it = lb(v, n); auto it1 = ub(v, n); int x = it1 - it; return x;\n}\n\nll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b , a % b); }\n\nll powm(int a, int b) {\n\tll res = 1;\n\twhile (b) {\n\t\tif (b & 1)\n\t\t\tres = (res * 1LL * a) % mod;\n\t\tb >>= 1;\n\t\ta = (a * 1LL * a) % mod;\n\n\t}\n\treturn res;\n}\n\nll nCr(ll n , ll k)\n{\tint fact[n];\n\tll res = (fact[n] * powm(fact[k] , mod - 2)) % mod;\n\treturn (res * powm(fact[n - k] , mod - 2)) % mod;\n}\n\n//---------------------------------------------------------------------------------------------------------------//\n//---------------------------------------------------------------------------------------------------------------//\nll dp[100][10];\n\nint main()\n{\tarshit_babariya();\n\tstring s;\n\tcin >> s;\n\tint n = sz(s);\n\n\trep(i, 10) dp[0][i] = 1;\n\n\tfr(i, 1, n - 1) {\n\t\tint d = (int)(s[i] - '0');\n\t\t// cout << d << \": \" << endl;\n\t\tfr(k, 0, 9) {\n\t\t\tint n1 = -1, n2 = -1;\n\t\t\tn1 = (d + k) / 2;\n\t\t\tif ((d + k) % 2 == 1) {\n\t\t\t\tn2 = n1 + 1;\n\t\t\t}\n\n\t\t\tif (0 <= n1 && n1 <= 9) {\n\t\t\t\tdp[i][n1] = dp[i][n1] + dp[i - 1][k];\n\t\t\t}\n\t\t\tif (0 <= n2 && n2 <= 9) {\n\t\t\t\tdp[i][n2] = dp[i][n2] + dp[i - 1][k];\n\t\t\t}\n\t\t}\n\n\t}\n\tll ans = 0;\n\tbool f = 1;\n\tfr(i, 1, n - 1) {\n\t\tif (abs(s[i] - s[i - 1]) > 1)f = 0;\n\t}\n\n\trep(i, 10) {\n\t\tans += dp[n - 1][i];\n\t}\n\tcout << ans - f << endl;\n\treturn 0;\n}\n\u00a0", "lang_cluster": "C++", "compilation_error": true, "code_uid": "688895cbaf778f33836edec45095fc3c", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nchar str[55];\nint len;\nint zero;\nint n;\npair dat[500005];\nconstexpr int MOD = 1000000007;\n\nint dp[500005][45];\nbool v[500005][45];\nint comb[45][45];\n\nint C(int a, int b)\n{\n\tif (b == a || b == 0) return 1;\n\tif (comb[a][b] == 0)\n\t{\n\t\tcomb[a][b] = (C(a - 1, b - 1) + C(a - 1, b)) % MOD;\n\t}\n\treturn comb[a][b];\n}\n\nint D(int idx, int z)\n{\n\tif (z < 0) return 0;\n\tif (idx == n) return z == 0;\n\tif (v[idx][z] == false)\n\t{\n\t\tv[idx][z] = true;\n\t\tdp[idx][z] =\n\t\t\t(z * 1ll * (D(idx + 1, z) + D(idx + 1, z - 1)) + (dat[idx].first - len) * 1ll * D(idx + 1, z)) % MOD;\n\t}\n\n\treturn dp[idx][z];\n}\n\nunordered_map memo[20];\nint cnt;\n\nint recur(long long flag, int idx)\n{\n\tauto itr = memo[idx].emplace(flag, 0);\n\tauto &ret = itr.first->second;\n\n\tif (itr.second)\n\t{\n\t\tif (idx == cnt)\n\t\t{\n\t\t\tint z = __popcnt64(flag);\n\n\t\t\tfor (int i = 0; i <= z; i++)\n\t\t\t{\n\t\t\t\tret = (ret + D(idx, zero - i) * 1ll * C(z, i)) % MOD;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor (int p = 0; p < dat[idx].first; p++)\n\t\t\t{\n\t\t\t\tbool wrong = false;\n\t\t\t\tfor (int j = p; j < len; j += dat[idx].first)\n\t\t\t\t{\n\t\t\t\t\tif (str[j] == '1')\n\t\t\t\t\t{\n\t\t\t\t\t\twrong = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (wrong) continue;\n\t\t\t\tlong long nf = flag;\n\n\t\t\t\tfor (int j = p; j < len; j += dat[idx].first) nf |= (1ll << j);\n\t\t\t\tret = (ret + recur(nf, idx + 1)) % MOD;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn ret;\n}\n\nint main()\n{\n\tscanf(\"%s\", str);\n\n\twhile (str[len])\n\t{\n\t\tif (str[len] == '0') zero++;\n\t\tlen++;\n\t}\n\n\tscanf(\"%d\", &n);\n\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%d%u\", &dat[i].first, &dat[i].second);\n\t}\n\tcnt = partition(dat, dat + n, [](auto &e) {return e.first < len;}) - dat;\n\tint ans = recur(0, 0);\n\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tint mul = dat[i].first;\n\t\tint now = 0; unsigned flag = 1;\n\t\t--dat[i].second;\n\t\twhile (flag <= dat[i].second)\n\t\t{\n\t\t\tif (flag & dat[i].second) ans = ans * 1ll * mul % MOD;\n\t\t\tmul = (mul * 1ll * mul) % MOD;\n\t\t\tflag <<= 1;\n\t\t}\n\t}\n\n\tprintf(\"%d\\n\", ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2f6e9d95f7bbfaa315e9278267241e95", "src_uid": "a0140a8fc4215acec5f046485bc2c7f9", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\nconst int N = (int)1e6 + 34;\nint p[N][3];\nvector es[3];\n\nint main() {\n //freopen(\"a.in\", \"r\", stdin);\n int n, k;\n cin >> n >> k;\n vector a(n);\n string c;\n\n for (int i = 0; i < n; i++) {\n cin >> a[i];\n }\n cin >> c;\n for (int i = 0; i < n; i++) {\n int kk = 0;\n if (c[i] == 'R') kk = 0;\n if (c[i] == 'W') kk = 1;\n if (c[i] == 'O') kk = 2;\n es[kk].push_back(a[i]);\n }\n\n for (int j = 0; j < 3; j++) {\n sort(es[j].begin(), es[j].end());\n es[j].push_back(0);\n reverse(es[j].begin(), es[j].end());\n for (int i = 1; i < (int)es[j].size(); i++) {\n es[j][i] += es[j][i - 1];\n }\n }\n\n /*for (int i = 0; i < 3; i++) {\n for (int j = 0; j < (int)es[i].size(); j++) cerr << es[i][j] << \" \"; cerr << \"\\n\";\n }*/\n\n ll ans = -1;\n for (int org = 1; org <= min(k, (int)es[2].size() - 1); org++) {\n if (k - org == 0) continue;\n if ((int)es[0].size() > k - org) {\n ans = max(ans, es[2][org] + es[0][k - org]);\n }\n if ((int)es[1].size() > k - org) {\n ans = max(ans, es[2][org] + es[1][k - org]);\n }\n }\n cout << ans;\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "61a4992bc80a925715a2efd20e7375bd", "src_uid": "104cf5253e027929f257364b3874c38b", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define int long long\n#define f first\n\n#define s second\nusing namespace std;\n\ntemplate using vc = vector;\nusing pii=pair;\n\nvoid xmax(int & a, int b){\n a=max(a, b);\n}\nvoid xmin(int& a, int b){\n a=min(a, b);\n}\n\nvoid print(vc & a, string s){\n cerr << \"prinitng \" << s << \": \";\n for (int i=0; i> ttt;\n while(ttt--){\n #endif // LOCAL_RUN\n\n int n, d, s;\n cin >> n >> d >> s;\n vc term;\n int mini=s+5;\n int anz_plus=0;\n int own_start=0;\n for (int i=0; i> c >> f >> l;\n if (l=1){\n anz_plus+=c;\n }\n }else{\n else if (c>=1){\n if (f==0){\n own_start++;\n }\n xmin(mini, f);\n anz_plus+=c;\n }else{\n term.push_back(f);\n }\n }\n }\n sort(term.begin(), term.end());\n pii mit={0, 0};\n int cur=s;\n int anz=0;\n for (int i=0; i=term[i]){\n cur-=term[i];\n anz++;\n }\n }\n int need=s-cur;\n int anz2=0;\n int cur2=s;\n int need2=0;\n if (cur2>=mini){\n cur2-=mini;\n anz2=anz_plus+1;\n if (own_start!=0) anz2+=own_start-1;\n int left=n-anz2;\n for (int i=0; i=term[i]){\n cur2-=term[i];\n anz2++;\n }\n }\n need2=s-cur2;\n }\n anz2=min(anz2, n);\n int res, fuel;\n if (anz==anz2){\n res=anz;\n fuel=min(need, need2);\n }else{\n if (anz>anz2){\n res=anz;\n fuel=need;\n }else{\n res=anz2;\n fuel=need2;\n }\n }\n cout << res << \" \" << fuel << \"\\n\";\n\n #ifdef LOCAL_RUN\n }\n #endif // LOCAL_RUN\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b9ad7ec2dfb9374f44fddbd5836d82c3", "src_uid": "e69f42403f3b0357e06a14523025b34a", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include \r\n#define int long long\r\nusing namespace std;\r\nsigned main() {\r\n cin.tie(0) -> sync_with_stdio(0);\r\n cin >> str;\r\n for (int i = 0; i < str.size(); i ++) cout << \"@\";\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ac1991aa145608fb545da6788f924e37", "src_uid": "56ec50526a3843fe3784d395850f45ae", "difficulty": -1.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \"utiltime.hpp\"\n\nusing namespace std;\n\ntypedef long long int ll;\ntypedef vector vi;\ntypedef vector> vvi;\ntypedef pair P;\ntypedef pair Pll;\ntypedef vector vll;\ntypedef vector> vvll;\n\nconst int INFL = (int)1e9;\nconst ll INFLL = (ll)1e18;\nconst double INFD = numeric_limits::infinity();\nconst double PI = 3.14159265358979323846;\n#define Loop(i, n) for(int i = 0; i < (int)n; i++)\n#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)\n#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)\n#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)\n#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)\n#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)\n#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)\n#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)\n#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)\n#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << \" \"; } cout << endl;\n#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << \" \"; } cout << endl; }\n#define quickio() ios::sync_with_stdio(false); cin.tie(0);\n#define bitmanip(m,val) static_cast>(val)\nll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }\nll floorsqrt(double x) { ll m = (ll)sqrt(x); return m + (m * m <= (ll)(x) ? 0 : -1); }\nll ceilsqrt(double x) { ll m = (ll)sqrt(x); return m + ((ll)x <= m * m ? 0 : 1); }\nll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }\nll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }\nll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }\n\n/*******************************************************/\n\ntypedef int seg_t;\n\nclass SegTree {\nprivate:\n\tvector segs;\n\tvoid local_update(int index, seg_t(*update_rule)(seg_t, seg_t)) {\n\t\tint l = left_of(index), r = index * 2 + 2;\n\t\tsegs[index] = update_rule(segs[l], segs[r]);\n\t}\n\tvoid get_index_of_range_rec(int s, int t, int l, int r, int index, vi *v) {\n\t\tif (s == l && t == r) v->push_back(index);\n\t\telse {\n\t\t\tint mid = (l + r) / 2;\n\t\t\tif (s < mid && mid < t) {\n\t\t\t\tget_index_of_range_rec(s, mid, l, mid, left_of(index), v);\n\t\t\t\tget_index_of_range_rec(mid, t, mid, r, right_of(index), v);\n\t\t\t}\n\t\t\telse if (s < mid) {\n\t\t\t\tget_index_of_range_rec(s, t, l, mid, left_of(index), v);\n\t\t\t}\n\t\t\telse if (mid < t) {\n\t\t\t\tget_index_of_range_rec(s, t, mid, r, right_of(index), v);\n\t\t\t}\n\t\t}\n\t}\npublic:\n\tint n;\n\tint left_of(int index) {\n\t\treturn index * 2 + 1;\n\t}\n\tint right_of(int index) {\n\t\treturn index * 2 + 2;\n\t}\n\tSegTree(vector a, seg_t init, seg_t(*update_rule)(seg_t, seg_t)) {\n\t\tn = (int)pow(2, ceil(log2(a.size())));\n\t\tsegs = vector(n * 2 - 1, init);\n\t\tLoop(i, a.size()) segs[n - 1 + i] = a[i];\n\t\tLoopr(i, n - 1) local_update(i, update_rule);\n\t}\n\tvoid update(int k, seg_t x, seg_t(*update_rule)(seg_t, seg_t), bool add_flag = false) {\n\t\tint index = k + n - 1;\n\t\tsegs[index] = add_flag ? segs[index] + x : x;\n\t\twhile (index > 0) {\n\t\t\tindex = (index - 1) / 2;\n\t\t\tlocal_update(index, update_rule);\n\t\t}\n\t}\n\t// note: range [s, t)\n\tvi get_index_of_range(int s, int t) {\n\t\tvi ret = {};\n\t\tget_index_of_range_rec(s, t, 0, n, 0, &ret);\n\t\treturn ret;\n\t}\n\t// write extend method from here:\n\tseg_t sum_of_range(int s, int t) {\n\t\tvi v = get_index_of_range(s, t);\n\t\tseg_t ret = 0;\n\t\tLoop(i, v.size()) {\n\t\t\tret += segs[v[i]];\n\t\t}\n\t\treturn ret;\n\t}\n};\n\nseg_t update_rule(seg_t a, seg_t b) {\n\treturn a + b;\n}\n\ntypedef ll val_t;\n\nstruct graph_t {\n\tint n; // |V|, index begins with 0\n\tint m; // |E|\n\tvector

edges; // E\n\tvector vals; // V\n\tvector costs; // cost or distance\n\tvector caps; // capacity\n};\n\nclass Maxflow {\nprivate:\n\tstruct edgedata {\n\t\tint eid, from, to;\n\t\tll cap;\n\t\tedgedata* dual_p;\n\t\tbool operator<(const edgedata & another) const {\n\t\t\treturn (cap != another.cap ? cap > another.cap : eid < another.eid);\n\t\t}\n\t};\n\tstruct node {\n\t\tint id; bool done; list edges; ll d;\n\t\tbool operator<(const node & another) const {\n\t\t\treturn !(d != another.d ? d < another.d : id < another.id);\n\t\t}\n\t};\n\tvector nodes;\n\tint n, m;\n\tint source, sink;\n\tedgedata* empty_edge;\npublic:\n\tMaxflow(graph_t G, int s, int t) {\n\t\tn = G.n;\n\t\tm = G.m;\n\t\tnodes.resize(n);\n\t\tLoop(i, n) nodes[i] = { i, false,{}, LLONG_MAX };\n\t\tempty_edge = new edgedata;\n\t\tLoop(i, G.edges.size()) {\n\t\t\tint a = G.edges[i].first;\n\t\t\tint b = G.edges[i].second;\n\t\t\tnodes[a].edges.push_back({ i, a, b, G.caps[i], empty_edge });\n\t\t\tnodes[b].edges.push_back({ i - m, b, a, 0, &(nodes[a].edges.back()) });\n\t\t\tnodes[a].edges.back().dual_p = &(nodes[b].edges.back());\n\t\t}\n\t\tsource = s;\n\t\tsink = t;\n\t\tvector> stk;\n\t\tint a; // the node which is focused on\n\t\tll df; // how much flow in one operation\n\t\twhile (1) {\n\t\t\tLoop(i, n) nodes[i].done = false;\n\t\t\ta = source;\n\t\t\tnodes[source].done = true;\n\t\t\twhile (a != sink) {\n\t\t\t\tint b = -1;\n\t\t\t\tLoopitr(itr, nodes[a].edges) {\n\t\t\t\t\tif (itr->cap > 0) {\n\t\t\t\t\t\tb = itr->to;\n\t\t\t\t\t\tif (nodes[b].done) b = -1;\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tstk.push_back(make_pair(a, &(*itr)));\n\t\t\t\t\t\t\tnodes[b].done = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (b == -1) {\n\t\t\t\t\tif (stk.empty()) break;\n\t\t\t\t\ta = stk.back().first; stk.pop_back();\n\t\t\t\t}\n\t\t\t\telse a = b;\n\t\t\t}\n\t\t\tif (stk.empty()) break;\n\t\t\tdf = LLONG_MAX;\n\t\t\tLoop(i, stk.size()) df = min(df, (*(stk[i].second)).cap);\n\t\t\twhile (stk.size()) {\n\t\t\t\t(*(stk.back().second)).cap -= df;\n\t\t\t\t(*((*(stk.back().second)).dual_p)).cap += df;\n\t\t\t\tstk.pop_back();\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\tvll get_eid_flow() {\n\t\tvll ret(m);\n\t\tLoop(i, n) {\n\t\t\tLoopitr(itr, nodes[i].edges) {\n\t\t\t\tif (itr->eid < 0) ret[itr->eid + m] = itr->cap;\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n\tll get_maxflow() {\n\t\tll ret = 0;\n\t\tLoopitr(itr, nodes[sink].edges) {\n\t\t\tif (itr->eid < 0) ret += itr->cap;\n\t\t}\n\t\treturn ret;\n\t}\n\tvoid solve(vector is_omg, int enemycnt) {\n\t\tvi a(enemycnt, -1);\n\t\tLoop(i, is_omg.size()) {\n\t\t\tif (!is_omg[i]) {\n\t\t\t\tint focus = i + 1;\n\t\t\t\twhile (true) {\n\t\t\t\t\tbool exist = false;\n\t\t\t\t\tif (focus == i + 1) {\n\t\t\t\t\t\tLoopitr(itr, nodes[focus].edges) {\n\t\t\t\t\t\t\tif (itr->to < n - 1 && itr->to > focus && itr->cap == 0) {\n\t\t\t\t\t\t\t\tfocus = itr->to;\n\t\t\t\t\t\t\t\texist = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tLoopitr(itr, nodes[focus].edges) {\n\t\t\t\t\t\t\tif (itr->to < n - 1 && itr->to > focus && itr->cap < enemycnt) {\n\t\t\t\t\t\t\t\tfocus = itr->to;\n\t\t\t\t\t\t\t\titr->cap++;\n\t\t\t\t\t\t\t\texist = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!exist) break;\n\t\t\t\t}\n\t\t\t\tif (n - 1 - enemycnt <= focus) a[focus - (n - 1 - enemycnt)] = i;\n\t\t\t}\n\t\t}\n\t\tLoop(i, is_omg.size()) {\n\t\t\tif (is_omg[i]) {\n\t\t\t\tint focus = i + 1;\n\t\t\t\tint cnt = 0;\n\t\t\t\tLoopitr(itr, nodes[focus].edges) {\n\t\t\t\t\tif (itr->to > focus && itr->cap == 0) {\n\t\t\t\t\t\tcnt++;\n\t\t\t\t\t\ta[itr->to - (n - 1 - enemycnt)] = i;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (cnt == 1) {\n\t\t\t\t\tLoopitr(itr, nodes[focus].edges) {\n\t\t\t\t\t\tif (itr->to > focus && itr->cap == 1 && a[itr->to - (n - 1 - enemycnt)] != -1) {\n\t\t\t\t\t\t\ta[itr->to - (n - 1 - enemycnt)] = i;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tint defeated = 0;\n\t\tLoop(i, a.size()) {\n\t\t\tif (a[i] != -1) defeated++;\n\t\t}\n\t\tcout << defeated << endl;\n\t\tLoop(i, a.size()) {\n\t\t\tif (a[i] != -1) cout << a[i] + 1 << \" \" << i + 1 << endl;\n\t\t}\n\t}\n};\n\nint main() {\n\tquickio();\n\tint n, m; cin >> n >> m;\n\tgraph_t G;\n\tSegTree segtree(vi(m, 0), 0, update_rule);\n\tG.n = 1 + n + (segtree.n * 2 - 1) + 1;\n\tLoop(i, segtree.n - 1) {\n\t\tG.edges.push_back({ 1 + n + i, 1 + n + segtree.left_of(i) });\n\t\tG.caps.push_back(segtree.n);\n\t\tG.edges.push_back({ 1 + n + i, 1 + n + segtree.right_of(i) });\n\t\tG.caps.push_back(segtree.n);\n\t}\n\tLoop(i, segtree.n) {\n\t\tG.edges.push_back({ G.n - 1 - segtree.n + i, G.n - 1 });\n\t\tG.caps.push_back(1);\n\t}\n\tvector is_omg(n, false);\n\tLoop(i, n) {\n\t\tint mode; cin >> mode;\n\t\tif (mode == 0) {\n\t\t\tG.edges.push_back({ 0,i + 1 });\n\t\t\tG.caps.push_back(1);\n\t\t\tint setsize; cin >> setsize;\n\t\t\tLoop(j, setsize) {\n\t\t\t\tint t; cin >> t; --t;\n\t\t\t\tG.edges.push_back({ i + 1, G.n - 1 - segtree.n + t });\n\t\t\t\tG.caps.push_back(1);\n\t\t\t}\n\t\t}\n\t\telse if (mode == 1) {\n\t\t\tG.edges.push_back({ 0,i + 1 });\n\t\t\tG.caps.push_back(1);\n\t\t\tint s, t; cin >> s >> t;\n\t\t\t--s; --t;\n\t\t\tvi indices = segtree.get_index_of_range(s, t + 1);\n\t\t\tLoop(j, indices.size()) {\n\t\t\t\tG.edges.push_back({ i + 1, 1 + n + indices[j] });\n\t\t\t\tG.caps.push_back(1);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tG.edges.push_back({ 0,i + 1 });\n\t\t\tG.caps.push_back(2);\n\t\t\tLoop(j, 3) {\n\t\t\t\tint t; cin >> t; --t;\n\t\t\t\tG.edges.push_back({ i + 1, G.n - 1 - segtree.n + t });\n\t\t\t\tG.caps.push_back(1);\n\t\t\t}\n\t\t\tis_omg[i] = true;\n\t\t}\n\t}\n\tG.m = G.edges.size();\n\tMaxflow maxflow(G, 0, G.n - 1);\n\tmaxflow.solve(is_omg, segtree.n);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7395a3f189f216fe3bf875c14282596a", "src_uid": "429a94c8e3f28100c8c532e948cc36e3", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:65777216\")\n \n#include \n#include \n#include \n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include\n \nusing namespace std;\n \ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef unsigned long long ull;\n \n#define FOR(i,a,b) for (int i(a); i < (b); i++)\n#define REP(i,n) FOR(i,0,n)\n#define SORT(v) sort((v).begin(),(v).end())\n#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())\n#define CL(a,b) memset(a,b,sizeof(a))\n#define pb push_back\n\ntypedef long double ld;\nconst ld pi = acosl(-1.);\nconst ld eps = 1e-11;\n\nint r,h;\n\nld getAngle(ld x,ld y, ld z){\n\tld H = h - z;\n\tld R = r * H / h;\n\tld X = 0;\n\tld Y = R;\n\tld d = sqrtl((x-X)*(x-X)+(y-Y)*(y-Y));\n\tld a = asinl(d/2/R)*2;\n\tld l = a * R / sqrtl(R*R+H*H);\n\tif(x>0) l=-l;\n\treturn l;\n}\n\nld conDist(ld z,ld Z,ld a){\n\tld r1 = sqrtl(h*h+r*r+0.)/h*(h-z);\n\tld r2 = sqrtl(h*h+r*r+0.)/h*(h-Z);\n\tld x = r1;\n\tld y = 0;\n\tld X = cosl(a)*r2;\n\tld Y = sinl(a)*r2;\n\n\t//cout<eps) return getOnConus(x,y,z,X,Y,0);\n\treturn sqrtl((x-X)*(x-X)+(y-Y)*(y-Y));\n}\n\nld getD(ld x,ld y,ld z,ld X, ld Y,ld Z,ld XX,ld YY,ld XXX,ld YYY){\n\tld res = sqrtl((XX-XXX)*(XX-XXX)+(YY-YYY)*(YY-YYY));\n\tres += getOnConus(x,y,z,XX,YY);\n\tres += getOnConus(X,Y,Z,XXX,YYY);\n\tif(0)if(res<1.6)\n\t{\n\t\tcout< \"< \"<>r>>h;\n\tlong double x,y,z,X,Y,Z;\n\tcin>>x>>y>>z>>X>>Y>>Z;\n\tif(z\n#include \n#include \n#include \n#include \n#include \n#define maxn 100005\nusing namespace std;\nlong long i,j,k,l,n,m,s,an,sum,pp;\nlong long N,M,f[maxn],g[maxn],h[maxn],phi[maxn],u[maxn],p[maxn]; //f[n]\u4e3an\u7684\u6700\u5c0f\u8d28\u56e0\u5b50\uff0cg[n]=f[n]^k\uff0cphi[n]\u4e3a\u6b27\u62c9\u51fd\u6570\uff0cu[n]\u4e3a\u83ab\u6bd4\u4e4c\u65af\u51fd\u6570\uff0ch[n]\u4e3a\u4e00\u822c\u79ef\u6027\u51fd\u6570 \n\nvoid prime()\n{\n\tu[1]=phi[1]=1,h[1]=(0); //1\u7684\u65f6\u5019\u7279\u5224 \n\tfor (long long i=2; i<=N; i++)\n\t{\n\t\tif (!f[i]) p[++M]=i,f[i]=g[i]=i,phi[i]=i-1,u[i]=-1,h[i]=(0); //\u8d28\u6570\u7684\u65f6\u5019\u7279\u5224 \n\t\tfor (long long j=1,k; j<=M&&p[j]<=f[i]&&i*p[j]<=N; j++)\n\t\t{\n\t\t\tf[k=i*p[j]]=p[j];\n\t\t\tif (p[j]R) return 0;\n long long y=int(sqrt(R*R-x*x)/d);\n y=min(y,m/d);\n if (!y) return 0;\n long long s=((m-d+1)+(m-y*d+1))*y/2%pp;\n return s*u[d];\n}\nlong long work(double R)\n{\n long long s=0;\n for (long long i=1;i<=n;i++)\n for (long long j=1;j*j<=i;j++)\n if (i%j==0)\n {\n s+=(n-i+1)*calc(i,j,R)%pp,s%=pp;\n if (j*j!=i) s+=(n-i+1)*calc(i,i/j,R)%pp,s%=pp;\n }\n return s;\n}\nint main()\n{\n long long L,R;\n scanf(\"%I64d%I64d%I64d%I64d%I64d\",&n,&m,&L,&R,&pp);\n //n++,m++;\n N=n+2\uff1b\n prime();\n an=work(R)*2;\n an-=work(L-1e-7)*2;\n an=(an%pp+pp)%pp;\n n++,m++;\n if ((1>=L)&&(l<=R)) an+=(n-1)*m+(m-1)*n,an%=pp;\n printf(\"%I64d\\n\",an);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a78aa8dd604582d03df699bdb81bc287", "src_uid": "2afe29a7dbbd2e261e1870a43d57b46f", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#ifndef SJTU_PQ_tree_HPP\n#define SJTU_PQ_tree_HPP\n\n#include \n#include \n#include \n#include\n#include \nnamespace sjtu {\nclass PQ_tree{\nprivate:\n\tstruct Node{\n\t\tint id;//0:inner node; 1-n:leaf\n\t\tint size;//total size of the subtree\n\t\tint sum;//number of the chosen nodes\n\t\tint PQ_type;//0:arbitrarily; 1:order; 2:bidirection\n\t\tbool tag_rev;\n\t\tstd::vector edge;\n\t\t\n\t\tNode(int id = 0):id(id), PQ_type(0), tag_rev(0){\n\t\t\tedge.clear();\n\t\t}\n\t\t\n\t\t/*~Node(){\n\t\t\tfor(int i = 0; i < edge.size(); i++){\n\t\t\t\tdelete edge[i];\n\t\t\t}\n\t\t}*/\n\t\t\n\t\tNode(const Node &other):\n\t\t\tid(other.id),\n\t\t\tsize(other.size),\n\t\t\tsum(other.sum),\n\t\t\tPQ_type(other.PQ_type),\n\t\t\ttag_rev(other.tag_rev){\n\t\t\tfor(int i = 0; i < other.edge.size(); i++){\n\t\t\t\tedge.push_back(new Node(*other.edge[i]));\n\t\t\t}\n\t\t}\n\t\t\n\t\tNode& operator = (const Node &other){\n\t\t\tif (this == &other) return *this;\n\t\t\tid = other.id;\n\t\t\tsize = other.size;\n\t\t\tsum = other.sum;\n\t\t\tPQ_type = other.PQ_type;\n\t\t\ttag_rev = other.tag_rev;\n\t\t\tedge.clear();\n\t\t\tfor(int i = 0; i < other.edge.size(); i++){\n\t\t\t\tedge.push_back(new Node(*other.edge[i]));\n\t\t\t}\n\t\t\treturn *this;\n\t\t}\n\t};\n\tNode* root;\n\tint size;\n\tstd::vector ans;\n\tbool* data;\n\tbool flag;//1:have ans; 0:no ans\n\t\n\tclass No_solution{\n\t\tint type;\n\t\tpublic:\n\t\tNo_solution(){}\n\t\tNo_solution(int x){\n\t\t\t//std::cout< id){\n\t\t\tx -> size = 1;\n\t\t\tif(data[x -> id]) x -> sum = 1;\n\t\t\t\telse x -> sum = 0;\n\t\t\treturn;\n\t\t}\n\t\tx -> size = 0;\n\t\tx -> sum = 0;\n\t\tfor(int i = 0; i < x -> edge.size(); i++){\n\t\t\tNode* y = x -> edge[i];\n\t\t\tdfs(y);\n\t\t\tx -> size += y -> size;\n\t\t\tx -> sum += y -> sum;\n\t\t}\n\t}\n\t\n\tvoid build(){\n\t\troot = new Node(0);\n\t\tfor(int i = 1; i <= size; i++){\n\t\t\troot -> edge.push_back(new Node(i));\n\t\t}\n\t}\n\t\n\tvoid push_down(Node* &x){\n\t\tif(x -> tag_rev == 0) return;\n\t\tfor(int i = 0; i < x -> edge.size(); i++){\n\t\t\tx -> edge[i] -> tag_rev ^= 1;\n\t\t}\n\t\tstd::reverse(x -> edge.begin(), x -> edge.end());\n\t\tx -> tag_rev = 0;\n\t}\n\t\n\tvoid get_ans(Node* &x){\n\t\tpush_down(x);\n\t\tif(x -> id) ans.push_back(x -> id);\n\t\tfor(int i = 0; i < x -> edge.size(); i++){\n\t\t\tget_ans(x -> edge[i]);\n\t\t}\n\t}\n\tvoid modify(Node *x){\n\t\tif(x -> PQ_type != 2) throw No_solution();\n\t\tx -> PQ_type = 1;\n\t\tx -> tag_rev = 1;\n\t\tpush_down(x);\n\t}\n\tNode* P_operation(Node* x, int type){\n\t\t//printf(\"P_id = %d type = %d PQ_type = %d\\n\",x -> id, type,x -> PQ_type);\n\t\tstd::vector a, b, c;\n\t\tfor (int i = 0; i < (int )x -> edge.size(); i ++)\n\t\t{\n\t\t\tNode* cur = x -> edge[i];\n\t\t\tif (cur -> size == cur -> sum) a.push_back(cur);\n\t\t\telse if (cur -> sum == 0) b.push_back(cur);\n\t\t\telse c.push_back(cur);\n\t\t}\n\t\tif ((int )c.size() > 2) throw No_solution();\n\t\tif (!(type == 0 || (int )c.size() < 2)) throw No_solution();\n\t\tif ((int )a.size() == 0 && (int )c.size() == 1)\n\t\t{\n\t\t\tif (type == 0)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < (int )x -> edge.size(); i ++)\n\t\t\t\t\tif (x -> edge[i] == c[0])\n\t\t\t\t\t{\n\t\t\t\t\t\tx -> edge[i] = solve(c[0], 0);\n\t\t\t\t\t\treturn x;\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\t\tNode* ta = 0;\n\t\tint sz = (int )a.size();\n\t\tif (sz)\n\t\t{\n\t\t\tif (sz == 1) ta = a[0];\n\t\t\telse\n\t\t\t{\n\t\t\t\tta = new Node();\n\t\t\t\tta -> PQ_type = 0;\n\t\t\t\tta -> id = 0;\n\t\t\t\tta -> edge = a;\n\t\t\t}\n\t\t}\n\t\n\t\tstd::vector tmp;\n\t\tif (type == 0 || type == 2)\n\t\t{\n\t\t\tif ((int )c.size()) tmp.push_back(solve(c[0], 2));\n\t\t}\n\t\tif (ta != NULL)\n\t\t\ttmp.push_back(ta);\n\n\t\tif (type == 0)\n\t\t{\n\t\t\tif ((int )c.size() == 2)\n\t\t\t\ttmp.push_back(solve(c[1], 1));\n\t\t}\n\t\telse if (type == 1)\n\t\t{\n\t\t\tint csz = (int )c.size();\n\t\t\tif (csz >= 1)\n\t\t\t\ttmp.push_back(solve(c[csz - 1], 1));\n\t\t}\n\t\t\n\t\tNode* nc = 0;\n\t\tif ((int )tmp.size() == 1) nc = tmp[0];\n\t\telse\n\t\t{\n\t\t\tnc = new Node();\n\t\t\tnc -> PQ_type = 2;\n\t\t\tnc -> id = 0;\n\t\t\tnc -> edge = tmp;\n\t\t}\n\t\n\t\tNode* nb = 0;\n\t\tif ((int )b.size() == 1) nb = b[0];\n\t\telse\n\t\t{\n\t\t\tnb = new Node();\n\t\t\tnb -> PQ_type = 0;\n\t\t\tnb -> id = 0;\n\t\t\tnb -> edge = b;\n\t\t}\n\t\t\n\t\tNode* r;\n\t\tif ((int )b.size() == 0) r = nc;\n\t\telse\n\t\t{\n\t\t\tr = new Node();\n\t\t\tr -> id = 0;\n\t\t\tif (type == 0)\n\t\t\t{\n\t\t\t\tr -> PQ_type = 0;\n\t\t\t\tr -> edge = b;\n\t\t\t\tr -> edge.push_back(nc);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tr -> PQ_type = 1;\n\t\t\t\tif (type == 1)\n\t\t\t\t\tr -> edge.push_back(nc), r -> edge.push_back(nb);\n\t\t\t\telse\n\t\t\t\t\tr -> edge.push_back(nb), r -> edge.push_back(nc);\n\t\t\t}\n\t\t}\n\t\treturn r;\n\t}\n\t\n\tNode* Q_operation(Node* x, int type){\n\t\t//printf(\"Q_id = %d type = %d PQ_type = %d\\n\",x -> id, type,x -> PQ_type);\n\t\tNode *l = x -> edge[0], *r = x -> edge[(int)x -> edge.size() - 1]; \n\t\tif(type == 1 && !(l -> sum == l -> size || (l -> sum && r -> size != r -> sum)))\n\t\t\t\tmodify(x);\n\t\telse if(type == 2 && !(r -> sum == r -> size || (r -> sum != 0 && l -> size != l -> sum)))\n\t\t\t\tmodify(x);\n\t\tint p1 = -1, p2 = -1, cnt = 0; \n\t\tbool first = 0;\n\t\tfor(int i = 0; i < x -> edge.size(); ++i)\n\t\t\tif(x -> edge[i] -> sum == x -> edge[i] -> size ){\n\t\t\t\t++cnt;\n\t\t\t\tif(!first) first = 1;\n\t\t\t\telse if(x -> edge[i - 1] -> sum != x -> edge[i - 1] -> size) \n\t\t\t\t\t\tthrow No_solution(1);\n\t\t\t}\n\t\t\n\t\tfor(int i = 0; i < x -> edge.size(); ++i)\n\t\t\tif(x -> edge[i] -> sum && x -> edge[i] -> sum < x -> edge[i] -> size)\n\t\t\t{\n\t\t\t\tif(p1 == -1) p1 = i;\n\t\t\t\telse if(p2 == -1) p2 = i;\n\t\t\t\telse throw No_solution(2);\n\t\t\t} \n\t\t//printf(\"cnt = %d p1 = %d\\n\", cnt, p1);\n\t\tif(cnt && p1 != -1){\n\t\t\tbool ok = 0;\n\t\t\tif(p1 > 0 && x -> edge[p1 - 1] -> sum == x -> edge[p1 - 1] -> size) {\n\t\t\t\tok = 1;\n\t\t\t\t//printf(\"p1 = %d\\n\", p1);\n\t\t\t}\n\t\t\tif(p1 + 1 < x -> edge.size() && x -> edge[p1 + 1] -> sum == x -> edge[p1 + 1] -> size) \n\t\t\t\tok = 1;\n\t\t\tif(!ok) throw No_solution(3);\n\t\t}\n\t\tif(cnt && p2 != -1){\n\t\t\tbool ok = 0;\n\t\t\tif(p2 > 0 && x -> edge[p2 - 1] -> sum == x -> edge[p2 - 1] -> size)\n\t\t\t\tok = 1;\n\t\t\tif(p2 + 1 < x -> edge.size() && x -> edge[p2 + 1] -> sum == x -> edge[p2 + 1] -> size)\n\t\t\t\tok = 1;\n\t\t\tif(!ok) throw No_solution(4);\n\t\t}\n\t\tif(p1 != -1 && p2 != -1) \n\t\t{ \n\t\t\tif(!type)\n\t\t\t{\n\t\t\t\tx -> edge[p1] = solve(x -> edge[p1], 2);\n\t\t\t\tx -> edge[p2] = solve(x -> edge[p2], 1);\n\t\t\t}\n\t\t\telse throw No_solution(5);\n\t\t\treturn x;\n\t\t} \n\t\telse if(p1 != -1)\n\t\t{\n\t\t\tif(!type) \n\t\t\t{\n\t\t\t\t//printf(\" p1 = %d\\n\", p1);\n\t\t\t\tif(!cnt){\n\t\t\t\t\tx -> edge[p1]= solve(x -> edge[p1], type);\n\t\t\t\t\treturn x;\n\t\t\t\t}\n\t\t\t\telse if(p1 > 0 && x -> edge[p1 - 1] -> sum == x -> edge[p1 - 1] -> size)\n\t\t\t\t\tx -> edge[p1] = solve(x -> edge[p1], 1);\n\t\t\t\telse \n\t\t\t\t\tx -> edge[p1] = solve(x -> edge[p1], 2);\n\t\t\t\treturn x;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbool fail = 0;\n\t\t\t\tif(type == 1)\n\t\t\t\t{\n\t\t\t\t\tfor(int i = p1 - 1; i >= 0; --i)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(x -> edge[i] -> sum == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfail = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(!fail)\n\t\t\t\t\t\tx -> edge[p1] = solve(x -> edge[p1], 1);\n\t\t\t\t}\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\tfor(int i = p1 + 1; i < x -> edge.size(); ++i)\n\t\t\t\t\t\tif(x -> edge[i] -> sum == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfail = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\tif(!fail)\n\t\t\t\t\t\tx -> edge[p1] = solve(x -> edge[p1], 2);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//printf(\"fail = %d\\n\", fail);\n\t\t\t\tif(!fail) {\n\t\t\t\t\tif(type > 0)\n\t\t\t\t\t\t\tx -> PQ_type = 1;\n\t\t\t\t\treturn x;\n\t\t\t\t}\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\tif(x -> PQ_type == 1) throw No_solution(6);\n\t\t\t\t\tfail = 0;\n\t\t\t\t\tx -> tag_rev = 1;\n\t\t\t\t\tpush_down(x);\n\t\t\t\t\tp1 = x -> edge.size() - p1 - 1;\n\t\t\t\t\tif(type == 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor(int i = p1 - 1; i >= 0; --i)\n\t\t\t\t\t\t\tif(x -> edge[i] -> sum == 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfail = 1;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tif(!fail)\n\t\t\t\t\t\t\tx -> edge[p1] = solve(x -> edge[p1], 1);\n\t\t\t\t\t}\n\t\t\t\t\telse \n\t\t\t\t\t{\n\t\t\t\t\t\tfor(int i = p1 + 1; i < x -> edge.size(); ++i)\n\t\t\t\t\t\t\tif(x -> edge[i] -> sum == 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfail = 1;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tif(!fail){\n\t\t\t\t\t\t\tx -> edge[p1] = solve(x -> edge[p1], 2);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(!fail) {\n\t\t\t\t\t\tif(type > 0)\n\t\t\t\t\t\t\t\tx -> PQ_type = 1;\n\t\t\t\t\t\treturn x;\n\t\t\t\t\t}\n\t\t\t\t\tthrow No_solution(7);\n\t\t\t\t}\n\t\t\t} \n\t\t} \n\t\telse {\n\t\t\tif(!type ) return x;\n\t\t\tbool fail = 0;\n\t\t\tif(type == 1){\n\t\t\t\tif(x -> edge[0] -> sum != x -> edge[0] -> size)\n\t\t\t\t\t fail = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif(x -> edge[x -> edge.size() - 1] -> sum != x -> edge[x -> edge.size() - 1] -> size)\n\t\t\t\t\tfail = 1;\n\t\t\t}\n\t\t\t//printf(\"fail = %d pqtype = %d\\n\", fail, x -> PQ_type);\n\t\t\tif(!fail ) return x;\n\t\t\tif(x -> PQ_type == 1) throw No_solution();\n\t\t\tx -> tag_rev = 1;\n\t\t\tpush_down(x);\n\t\t\tfail = 0;\n\t\t\tif(type == 1){\n\t\t\t\tif(x -> edge[0] -> sum != x -> edge[0] -> size)\n\t\t\t\t\t fail = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif(x -> edge[x -> edge.size() - 1] -> sum != x -> edge[x -> edge.size() - 1] -> size)\n\t\t\t\t\tfail = 1;\n\t\t\t}\n\t\t\tif(!fail) {\n\t\t\t\tif(type > 0)\n\t\t\t\t\tx -> PQ_type = 1;\n\t\t\t\treturn x;\n\t\t\t}\n\t\t\tthrow No_solution();\n\t\t}\n\t\t/*Node *l = x -> edge[0];\n\t\tNode *r = x -> edge[(int )x -> edge.size() - 1];\n\t\tif(type == 1 && !(l -> sum == l -> size || (l -> sum && r -> size != r -> sum)))\n\t\t\t\tmodify(x);\n\t\telse if(type == 2 && !(r -> sum == r -> size || (r -> sum != 0 && l -> size != l -> sum)))\n\t\t\t\tmodify(x);\n\t\tint last=-1,flag=0,cnt=0,total=0;\n\t\tfor(int i = 0; i < x -> edge.size(); ++i){\n\t\t\tNode *y = x -> edge[i];\n\t\t\tint w;\n\t\t\tif(y -> size == y -> sum) w = 2;\n\t\t\telse if(y -> sum == 0) w = 0;\n\t\t\telse w = 1;\n\t\t\tif(last!=-1){\n\t\t\t\tif(w>last && type==1)throw No_solution();\n\t\t\t\tif(w 0;\n\t\t}\n\t\tif(cnt>(type==0?2:1))throw No_solution();\n\t\tcnt=0;\n\t\tfor(int i = 0; i < x -> edge.size(); ++i){\n\t\t\tint tmp= x -> edge[i] -> sum;\n\t\t\tif(tmp>0 && tmp edge[i] -> size){\n\t\t\t\tif(type==1)x -> edge[i]=solve(x -> edge[i],1);\n\t\t\t\telse\n\t\t\t\tif(type==2)x -> edge[i]=solve(x -> edge[i],2);\n\t\t\t\telse if(total==1)x -> edge[i]=solve(x -> edge[i],0);\n\t\t\t\telse {\n\t\t\t\t\tif(!cnt)x -> edge[i]=solve(x -> edge[i],2);\n\t\t\t\t\telse x -> edge[i]=solve(x -> edge[i],1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcnt+=(tmp>0);\n\t\t}\n\t\treturn x;*/\n\t}\n\t\n\t//type\t0:block; 1:left; 2:right\n\tNode* solve(Node* x, int type){\n\t\tpush_down(x);\n\t\tif (x -> id) return x;\n\t\tif (x -> PQ_type == 0) return P_operation(x, type);\n\t\telse return Q_operation(x, type);\n\t}\n\t\npublic:\n\tPQ_tree(int size):size(size), flag(1), data(new bool[size + 1]){\n\t\tbuild();\n\t}\n\t\n\t~PQ_tree(){\n\t\tdelete data;\n\t\tdelete root;\n\t}\n\tPQ_tree(const PQ_tree &other):\n\t\tsize(other.size),\n\t\tflag(other.flag),\n\t\troot(new Node(*other.root)),\n\t\tdata(new bool[size + 1]){}\n\t\n\tPQ_tree& operator = (const PQ_tree &other){\n\t\tif(this == &other) return *this;\n\t\tdelete root;\n\t\tsize = other.size;\n\t\tflag = other.flag;\n\t\tdelete data;\n\t\tdata = new bool[size + 1];\n\t\troot = new Node(*other.root);\n\t\treturn *this;\n\t}\n\t\n\tvoid insert(std::vector data_in){\n\t\tif(!flag) return;\n\t\tfor(int i = 1; i <= size; i++){\n\t\t\tdata[i] = 0;\n\t\t}\n\t\tfor(int i = 0; i < data_in.size(); i++){\n\t\t\tdata[data_in[i]] = 1;\n\t\t}\n\t\tdfs(root);\n\t\tif(root -> sum) {\n\t\t\ttry{\n\t\t\t\troot = solve(root, 0);\n\t\t\t}catch(...){\n\t\t\t\tflag = 0;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstd::vector print(){\n\t\tans.clear();\n\t\tif(flag) get_ans(root);\n\t\treturn ans;\n\t}\n\t\n\t\n\tvoid check(Node* x){\n\t\tif(x -> id) printf(\"%d\",x->id);\n\t\t\telse printf(\"-%d\",x -> PQ_type);\n\t\tif(x -> edge.size()){\n\t\t\tprintf(\"(\");\n\t\t\tfor(int i = 0; i < x -> edge.size();i++){\n\t\t\t\tif(i) printf(\",\");\n\t\t\t\tcheck(x -> edge[i]);\n\t\t\t}\n\t\t\tprintf(\")\");\n\t\t}\n\t}\n\tvoid work(){\n\t\tcheck(root);\n\t\tputs(\"\");\n\t\tputs(\"--------------------------\");\n\t}\n};\n\n}\n\n#endif\nchar ch[1000][1000];\nstd::vector vec;\nint main(){\n\tint n;\n\tscanf(\"%d\",&n);\n\tsjtu::PQ_tree t(n);\n\tfor(int i = 1;i<=n;i++){\n\t\tscanf(\"%s\",ch[i]+1);\n\t\tvec.clear();\n\t\tfor(int j = 1;j <= n;j++)\n\t\t\tif(ch[i][j]=='1') vec.push_back(j);\n\t\tt.insert(vec);\n\t\t//t.work();\n\t\t/*\n\t\tif(t.print().size() == 0){\n\t\t\tprintf(\"i = %d\\n\",i);\n\t\t\treturn 0;\n\t\t}*/\n\t};\n\tvec = t.print();\n\tchar ans[1000];\n\tif(vec.empty()) puts(\"NO\");\n\telse{\n\t\tputs(\"YES\");\n\t\tfor(int i = 1;i <= n;i++){\n\t\t\tfor(int j = 0;j < n;j++)\n\t\t\t\tans[j] = ch[i][vec[j]];\n\t\t\tans[n]='\\0';\n\t\t\tputs(ans);\n\t\t}\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "201168079dcbb889846532d4cbcb7b4e", "src_uid": "af8d46722e1bd8f7392e5596eaf4def8", "difficulty": 3000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#pragma comment (linker, \"/STACK:256000000\")\n\nusing namespace std;\n\nconst int maxN = 510000;\nconst int maxK = 37;\nconst double eps = 1e-20;\n\nvector < int > g[maxN];\nint q;\nint n = 1;\nint parent[maxN];\n\ndouble p[maxN][maxK];\ndouble p2[maxN];\n\nvoid initVertex(int v) {\n\tfor (int i = 0; i < maxK; ++i) {\n\t\tp[v][i] = 1.0;\n\t}\n}\n\nvoid updateVertex(int v, int u, bool add, int length) {\n\tfor (int i = 1; i < maxK && i < length; ++i) {\n\t\tdouble value = 0.5 * (1.0 + p[u][i - 1]);\n\t\tif (add) {\n\t\t\tp[v][i] *= value;\n\t\t} else {\n\t\t\tp[v][i] /= value;\n\t\t}\n\t\tif (p[v][i] < eps) {\n\t\t\tp[v][i] = 0.0;\n\t\t}\n\t}\n\n\tif (add) {\n\t\tp[v][0] = p2[g[v].size()];\n\t}\n}\n\nvoid addVertex(int v) {\n\t++n;\n\tint u = n;\n\n\tparent[u] = v;\n\tg[v].push_back(u);\n\n\tint depth = 0;\n\tvector < int > path;\n\tpath.push_back(u);\n\twhile (v != 0 && depth < maxK) {\n\t\t++depth;\n\t\tpath.push_back(v);\n\t\tv = parent[v];\n\t}\n\n\treverse(path.begin(), path.end());\n\n\tfor (int i = 0; i + 2 < path.size(); ++i) {\n\t\tupdateVertex(path[i], path[i + 1], false, path.size() - i + 1);\n\t}\n\n\tinitVertex(u);\n\tfor (int i = (int)(path.size()) - 2; i >= 0; --i) {\n\t\tupdateVertex(path[i], path[i + 1], true, i + 1);\n\t}\n}\n\ndouble getRes(int v) {\n\tdouble res = 0.0;\n\tfor (int i = 1; i < maxK; ++i) {\n\t\tdouble q = p[v][i] - p[v][i - 1];\n\t\tres += q * (double)(i);\n\t}\n\treturn res;\n}\n\nint main() {\n\t//freopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n\n\tp2[0] = 1.0;\n\tfor (int i = 1; i < maxN; ++i) {\n\t\tp2[i] = p2[i - 1] * 0.5;\n\t\tif (p2[i] < eps) {\n\t\t\tp2[i] = 0.0;\n\t\t}\n\t}\n\n\tscanf(\"%d\", &q);\n\tinitVertex(1);\n\tfor (int i = 0; i < q; ++i) {\n\t\tint mode, v;\n\t\tscanf(\"%d%d\", &mode, &v);\n\t\tif (mode == 1) {\n\t\t\taddVertex(v);\n\t\t} else {\n\t\t\tprintf(\"%.10lf\\n\", getRes(v));\n\t\t}\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "14610af40cd6ee2cbd89d4538f707c68", "src_uid": "55affe752cb214d1e4031a9e3972597b", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\n#define mod 490019LL\n#define Mod 245009LL\n#define mod1 491\n#define mod2 499\n#define pow DCXISSOHANDSOME\n\nstruct node\n{\n\tdouble x,y;\n\tnode() {}\n\tnode(double xx,double yy):x(xx),y(yy) {}\n}pow[21][524288],a[1048576],b[1048576];\n\nconst double pi=acos(-1.0);\n\ninline node operator +(const node &x,const node &y) { return node(x.x+y.x,x.y+y.y); }\ninline node operator -(const node &x,const node &y) { return node(x.x-y.x,x.y-y.y); }\ninline node operator *(const node &x,const node &y) { return node(x.x*y.x-x.y*y.y,x.x*y.y+x.y*y.x); }\ninline node operator /(const node &x,const double &y) { return node(x.x/y,x.y/y); }\n\nll f[1048576],sum[500010],sum1[500010],sum2[500010],bin[500010],c;\nint num1[100010],num2[100010],id1[510],id2[510],bin1[510],bin2[510],n,m,Inv1,Inv2;\n\ninline int rd()\n{\n\tint x=0;char ch=getchar();\n\tfor (;ch<'0'||ch>'9';ch=getchar());\n\tfor (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';\n\treturn x;\n}\n\ninline ll pls(const ll &x,const ll &y) { return (x+y>=1,x=x*x%p) if (y&1) res=res*x%p;return res; }\n\ninline void pre_gao()\n{\n\tfor (int w=2,hh=1;w<=1048576;w<<=1,hh++)\n\t{\n\t\tfor (int j=0;j<(w>>1);j++) pow[hh][j]=node(cos(pi*2*j/w),sin(pi*2*j/w));\n\t}\n\tid1[1]=0;int now=1;\n\tfor (int i=1;i>1]>>1)|((i&1)?(n>>1):0);\n\tfor (int i=1;i>1);j++)\n\t{\n\t\tnode u=a[j],t=a[j+(w>>1)]*pow[hh][j-k];\n\t\ta[j]=u+t;a[j+(w>>1)]=u-t;\n\t}\n\tif (on==-1)\n\t{\n\t\treverse(a+1,a+n);\n\t\tfor (int i=0;i=Mod)?hh+h[i]-Mod:hh+h[i]) f[hh]+=c[h[i]]*d[j]+d[h[i]]*c[j];\n\tfor (int i=1;i<=tt;i++) for (int j=1;j<=tt;j++) f[h[i]*h[j]%Mod]-=c[h[i]]*d[h[j]];\n\tfor (int i=0;i=Mod)?hh+h[i]-Mod:hh+h[i]) f[hh]+=c[h[i]]*d[j]+d[h[i]]*c[j];\n\tfor (int i=1;i<=tt;i++) for (int j=1;j<=tt;j++) f[h[i]*h[j]%Mod]-=c[h[i]]*d[h[j]];\n\tfor (int i=0;i\n#include \n#include \n#include \n\nusing namespace std;\n\nvector pos(const string& s, const string& p) {\n\tvector ret;\n\tfor (string::size_type i = s.find(p); i != string::npos; i = s.find(p, i + 1)) {\n\t\tret.push_back(i);\n\t}\n\treturn ret;\n}\n\nint main() {\n\tstring str, prefix, suffix;\n\tvector begin, end;\n\tvector hash;\n\n\tcin >> str >> prefix >> suffix;\n\tbegin = pos(str, prefix);\n\tend = pos(str, suffix);\n\tfor (int i: begin) {\n\t\tint k = i;\n\t\tunsigned long long code = 0;\n\t\tfor (int j: end) {\n\t\t\tif (i <= j && i + (int)prefix.length() <= j + (int)suffix.length()) { //i\u548cj\u5206\u522b\u662f\u524d\u7f00\u548c\u540e\u7f00\u5f00\u59cb\u4f4d\u7f6e\n\t\t\t\twhile (k < j + (int)suffix.length()) { //i\u5904\u524d\u7f00\u548cj\u5904\u540e\u7f00\u80fd\u591f\u7ec4\u6210\u5b57\u7b26\u4e32\u6761\u4ef6\u662fi<=j && i+\u524d\u7f00\u957f\u5ea6<=j+\u540e\u7f00\u957f\u5ea6\n\t\t\t\t\tcode = code * 29 + str[k++];\n\t\t\t\t}\n\t\t\t\thash.push_back(code);\n\t\t\t}\n\t\t}\n\t}\n\tsort(hash.begin(), hash.end());\n\tprintf(\"%d\\n\", unique(hash.begin(), hash.end()) - hash.begin());\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "65dd78a8b55f41c8afb8c26e31252f77", "src_uid": "f22f28e2d8933f4199ba5ccfc0de8cda", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "/**\n * code generated by JHelper\n * More info: https://github.com/AlexeyDmitriev/JHelper\n * @author aryssoncf\n */\n\n#include \n//\n// Created by aryssoncf on 28/10/2019.\n//\n\n#include \n\n\n#include \n#include \n\ntemplate\nconstexpr auto hasBegin(int) -> decltype(std::begin(std::declval()), true) {\n return true;\n}\n\nconstexpr bool hasBegin(...) {\n return false;\n}\n\ntemplate\nusing IsContainer = std::integral_constant(0)>;\n\n\n#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP\n#define JHELPER_EXAMPLE_PROJECT_IO_HPP\n\n#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP\n\ntemplate::value>>\nstd::istream &operator>>(std::istream &stream, T &container) {\n for (auto &element: container) {\n stream >> element;\n }\n return stream;\n}\n\ntemplate\nstd::ostream &operator<<(std::ostream &os, std::pair const &p) {\n return os << p.first << \" \" << p.second;\n}\n\ntemplate\nstd::basic_ostream &operator<<(std::basic_ostream &os, Container const &x) {\n bool first = true;\n for (auto &y : x) {\n if (first) {\n first = false;\n } else {\n os << \" \";\n }\n os << y;\n }\n return os;\n}\n//\n// Created by aryssoncf on 28/10/2019.\n//\n\n\n\n/**\n* ax + by = result\n*/\ntemplate\nT extendedGcd(T a, T b, T &x, T &y) {\n if (a == 0) {\n x = 0;\n y = 1;\n return b;\n }\n T d = extendedGcd(b % a, a, y, x);\n x -= (b / a) * y;\n return d;\n}\n\n\n#include \n#include \n\n#ifndef SPCPPL_ASSERT\n#ifdef SPCPPL_DEBUG\n#define SPCPPL_ASSERT(condition) \\\n if(!(condition)) { \\\n throw std::runtime_error(std::string() + #condition + \" in line \" + std::to_string(__LINE__) + \" in \" + __PRETTY_FUNCTION__); \\\n }\n#else\n#define SPCPPL_ASSERT(condition)\n#endif\n#endif\n\n\n#ifndef JHELPER_EXAMPLE_PROJECT_MODULAR_HPP\n#define JHELPER_EXAMPLE_PROJECT_MODULAR_HPP\n\n#endif //JHELPER_EXAMPLE_PROJECT_MODULAR_HPP\n\n\n#include \n\nusing namespace std;\n\nint MOD = 1000000007;\n\nclass Modular {\n int value;\n\n template\n static int mod(const complex &x) {\n return mod(x.real());\n }\n\n static int mod(Modular x) {\n return x.value;\n }\n\n template::value>\n static int mod(T x) {\n long long x_ = is_int ? (long long) x : (long long) roundl(x);\n int y = x_ % MOD;\n if (y < 0) {\n y += MOD;\n }\n return y;\n }\n\n void inc(const int &x) {\n value += x;\n if (value >= MOD) {\n value -= MOD;\n }\n }\n\n void mul(const int &x) {\n value = (long long) value * x % MOD;\n }\n\npublic:\n Modular() : value(0) {}\n\n template\n Modular(const T &x) {\n value = mod(x);\n }\n\n// template\n// Modular& operator=(const T &x) {\n// value = mod(x);\n// return *this;\n// }\n\n template\n explicit operator T() {\n return value;\n }\n\n Modular operator-() const {\n return mod(-value);\n }\n\n Modular &operator++() {\n inc(mod(1));\n return *this;\n }\n\n Modular operator++(int) {\n Modular res = *this;\n inc(mod(1));\n return res;\n }\n\n Modular &operator--() {\n inc(mod(-1));\n return *this;\n }\n\n Modular operator--(int) {\n Modular res = *this;\n inc(mod(-1));\n return res;\n }\n\n template\n Modular &operator+=(const T &x) {\n inc(mod(x));\n return *this;\n }\n\n template\n Modular &operator-=(const T &x) {\n inc(mod(-x));\n return *this;\n }\n\n template\n Modular &operator*=(const T &x) {\n mul(mod(x));\n return *this;\n }\n\n Modular inversed() const {\n SPCPPL_ASSERT(value != 0);\n int x, y;\n int gcd = extendedGcd(value, MOD, x, y);\n SPCPPL_ASSERT(gcd == 1);\n return Modular(x);\n }\n\n template\n Modular &operator/=(const T &x) {\n mul(Modular(x).inversed().value);\n return *this;\n }\n\n friend bool operator==(const Modular &, const Modular &);\n\n friend bool operator!=(const Modular &, const Modular &);\n\n friend ostream &operator<<(std::ostream &, const Modular &);\n};\n\nModular operator+(const Modular &x, const Modular &y) {\n Modular copy = x;\n return copy += y;\n}\n\nModular operator-(const Modular &x, const Modular &y) {\n Modular copy = x;\n return copy -= y;\n}\n\nModular operator*(const Modular &x, const Modular &y) {\n Modular copy = x;\n return copy *= y;\n}\n\nModular operator/(const Modular &x, const Modular &y) {\n Modular copy = x;\n return copy /= y;\n}\n\ntemplate\nModular operator/(const Modular &x, const T &y) {\n Modular copy = x;\n return copy /= y;\n}\n\ntemplate\nModular operator/(const T &x, const Modular &y) {\n Modular copy = x;\n return copy /= y;\n}\n\nbool operator==(const Modular &x, const Modular &y) {\n return x.value == Modular::mod(y);\n}\n\nbool operator!=(const Modular &x, const Modular &y) {\n return x.value != Modular::mod(y);\n}\n\nostream &operator<<(std::ostream &stream, const Modular &x) {\n return stream << x.value;\n}\n\n\n#include \n#include \n\nbool isPrime(int n) {\n for (int i = 2; i * i <= n; ++i) {\n if (n % i == 0) {\n return false;\n }\n }\n return n >= 2;\n}\n\nbool isPrime(int64_t n) {\n for (int64_t i = 2; i * i <= n; ++i) {\n if (n % i == 0) {\n return false;\n }\n }\n return n >= 2;\n}\n\nstd::vector primeMap(std::size_t maxN) {\n std::vector prime(maxN + 1, true);\n\n prime[0] = false;\n prime[1] = false;\n\n for (std::size_t i = 2; i * i <= maxN; ++i) {\n if (prime[i]) {\n if (i * 1ULL * i <= maxN) {\n for (std::size_t j = i * i; j <= maxN; j += i) {\n prime[j] = false;\n }\n }\n }\n }\n return prime;\n}\n\nstd::vector allPrimes(int maxN) {\n std::vector result;\n result.reserve(maxN);\n std::vector map = primeMap(maxN);\n for (int i = 0; i <= maxN; i++) {\n if (map[i]) {\n result.push_back(i);\n }\n }\n return result;\n}\n\nint nextPrime(int n) {\n while (!isPrime(n)) {\n ++n;\n }\n return n;\n}\n\n//\n// Created by aryssoncf on 25/10/2019.\n//\n\n#ifndef JHELPER_EXAMPLE_PROJECT_MODULARFFT_HPP\n#define JHELPER_EXAMPLE_PROJECT_MODULARFFT_HPP\n\n#endif //JHELPER_EXAMPLE_PROJECT_MODULARFFT_HPP\n\n\n\n//\n// Created by aryssoncf on 25/10/2019.\n//\n\n#ifndef JHELPER_EXAMPLE_PROJECT_FASTFOURIERTRANSFORM_HPP\n#define JHELPER_EXAMPLE_PROJECT_FASTFOURIERTRANSFORM_HPP\n\n#endif //JHELPER_EXAMPLE_PROJECT_FASTFOURIERTRANSFORM_HPP\n\n\n#include \n\n//\n// Created by aryssoncf on 25/10/2019.\n//\n\n#ifndef JHELPER_EXAMPLE_PROJECT_FFT_HPP\n#define JHELPER_EXAMPLE_PROJECT_FFT_HPP\n\n#endif //JHELPER_EXAMPLE_PROJECT_FFT_HPP\n\n\ntemplate\nstruct IdentityHelper;\n\ntemplate\nstruct IdentityHelper::type> {\n static T identity() {\n return 1;\n }\n};\n\ntemplate\nT identity() {\n return IdentityHelper::identity();\n}\n\n\ntemplate\nT binpow(T base, long long power) {\n SPCPPL_ASSERT(power >= 0);\n// T result = identity();\n T result = 1;\n while (power > 0) {\n if (power & 1) {\n result *= base;\n }\n power >>= 1;\n base *= base;\n }\n return result;\n}\n\n\nusing namespace std;\n\ntemplate\nclass FFT {\nprotected:\n virtual int result_length(int first_length, int second_length) = 0;\n\n virtual long long result_length_power(long long first_length, long long second_length) = 0;\n\n unsigned nextpow2(unsigned v) {\n return v ? 1 << __lg(2 * v - 1) : 1;\n }\n\n virtual T calculate_root(int N) {}\n\npublic:\n virtual vector transform(vector y, bool invert = false) = 0;\n\n vector linear_convolution(vector a, vector b) {\n const int n = result_length(a.size(), b.size()), n2 = nextpow2(n);\n a.resize(n2);\n b.resize(n2);\n vector fa = transform(move(a)), fb = transform(move(b)), &fc = fa;\n for (int i = 0; i < n2; ++i) fc[i] = fa[i] * fb[i];\n vector c = transform(move(fc), true);\n c.resize(n);\n return move(c);\n }\n\n vector linear_convolution_power(vector a, long long power, int length = -1) {\n const int n = length < 0 ? result_length_power(a.size(), power) : length, n2 = nextpow2(n);\n a.resize(n2);\n vector fa = transform(move(a)), &fc = fa;\n for (int i = 0; i < n2; ++i) fc[i] = binpow(fa[i], power);\n vector c = transform(move(fc), true);\n c.resize(n);\n return move(c);\n }\n};\n\n\nusing namespace std;\nnamespace algebra {\n const int inf = 1e9;\n const int magic = 500; // threshold for sizes to run the naive algo\n\n namespace fft {\n const int maxn = 1 << 19;\n\n typedef double ftype;\n typedef complex point;\n\n point w[maxn];\n const ftype pi = acos(-1);\n bool initiated = 0;\n\n void init() {\n if (!initiated) {\n for (int i = 1; i < maxn; i *= 2) {\n for (int j = 0; j < i; j++) {\n w[i + j] = polar(ftype(1), pi * j / i);\n }\n }\n initiated = 1;\n }\n }\n\n template\n void fft(T *in, point *out, int n, int k = 1) {\n if (n == 1) {\n *out = *in;\n } else {\n n /= 2;\n fft(in, out, n, 2 * k);\n fft(in + k, out + n, n, 2 * k);\n for (int i = 0; i < n; i++) {\n auto t = out[i + n] * w[i + n];\n out[i + n] = out[i] - t;\n out[i] += t;\n }\n }\n }\n\n template\n void mul_slow(vector &a, const vector &b) {\n vector res(a.size() + b.size() - 1);\n for (size_t i = 0; i < a.size(); i++) {\n for (size_t j = 0; j < b.size(); j++) {\n res[i + j] += a[i] * b[j];\n }\n }\n a = res;\n }\n\n\n template\n void mul(vector &a, const vector &b) {\n if (min(a.size(), b.size()) < magic) {\n mul_slow(a, b);\n return;\n }\n init();\n static const int shift = 15, mask = (1 << shift) - 1;\n size_t n = a.size() + b.size() - 1;\n while (__builtin_popcount(n) != 1) {\n n++;\n }\n a.resize(n);\n static point A[maxn], B[maxn];\n static point C[maxn], D[maxn];\n for (size_t i = 0; i < n; i++) {\n A[i] = point(a[i] & mask, a[i] >> shift);\n if (i < b.size()) {\n B[i] = point(b[i] & mask, b[i] >> shift);\n } else {\n B[i] = 0;\n }\n }\n fft(A, C, n);\n fft(B, D, n);\n for (size_t i = 0; i < n; i++) {\n point c0 = C[i] + conj(C[(n - i) % n]);\n point c1 = C[i] - conj(C[(n - i) % n]);\n point d0 = D[i] + conj(D[(n - i) % n]);\n point d1 = D[i] - conj(D[(n - i) % n]);\n A[i] = c0 * d0 - point(0, 1) * c1 * d1;\n B[i] = c0 * d1 + d0 * c1;\n }\n fft(A, C, n);\n fft(B, D, n);\n reverse(C + 1, C + n);\n reverse(D + 1, D + n);\n int t = 4 * n;\n for (size_t i = 0; i < n; i++) {\n int64_t A0 = llround(real(C[i]) / t);\n T A1 = llround(imag(D[i]) / t);\n T A2 = llround(imag(C[i]) / t);\n a[i] = A0 + (A1 << shift) + (A2 << 2 * shift);\n }\n return;\n }\n }\n\n template\n T bpow(T x, size_t n) {\n return n ? n % 2 ? x * bpow(x, n - 1) : bpow(x * x, n / 2) : T(1);\n }\n\n template\n T bpow(T x, size_t n, T m) {\n return n ? n % 2 ? x * bpow(x, n - 1, m) % m : bpow(x * x % m, n / 2, m) : T(1);\n }\n\n template\n T gcd(const T &a, const T &b) {\n return b == T(0) ? a : gcd(b, a % b);\n }\n\n template\n T nCr(T n, int r) { // runs in O(r)\n T res(1);\n for (int i = 0; i < r; i++) {\n res *= (n - T(i));\n res /= (i + 1);\n }\n return res;\n }\n\n template\n struct modular {\n int64_t r;\n\n modular() : r(0) {}\n\n modular(int64_t rr) : r(rr) {\n if (abs(r) >= m) r %= m;\n if (r < 0) r += m;\n }\n\n modular inv() const { return bpow(*this, m - 2); }\n\n modular operator*(const modular &t) const { return (r * t.r) % m; }\n\n modular operator/(const modular &t) const { return *this * t.inv(); }\n\n modular operator+=(const modular &t) {\n r += t.r;\n if (r >= m) r -= m;\n return *this;\n }\n\n modular operator-=(const modular &t) {\n r -= t.r;\n if (r < 0) r += m;\n return *this;\n }\n\n modular operator+(const modular &t) const { return modular(*this) += t; }\n\n modular operator-(const modular &t) const { return modular(*this) -= t; }\n\n modular operator*=(const modular &t) { return *this = *this * t; }\n\n modular operator/=(const modular &t) { return *this = *this / t; }\n\n bool operator==(const modular &t) const { return r == t.r; }\n\n bool operator!=(const modular &t) const { return r != t.r; }\n\n operator int64_t() const { return r; }\n };\n\n template\n istream &operator>>(istream &in, modular &x) {\n return in >> x.r;\n }\n\n\n template\n struct poly {\n vector a;\n\n void normalize() { // get rid of leading zeroes\n while (!a.empty() && a.back() == T(0)) {\n a.pop_back();\n }\n }\n\n poly() {}\n\n poly(T a0) : a{a0} { normalize(); }\n\n poly(vector t) : a(t) { normalize(); }\n\n poly operator+=(const poly &t) {\n a.resize(max(a.size(), t.a.size()));\n for (size_t i = 0; i < t.a.size(); i++) {\n a[i] += t.a[i];\n }\n normalize();\n return *this;\n }\n\n poly operator-=(const poly &t) {\n a.resize(max(a.size(), t.a.size()));\n for (size_t i = 0; i < t.a.size(); i++) {\n a[i] -= t.a[i];\n }\n normalize();\n return *this;\n }\n\n poly operator+(const poly &t) const { return poly(*this) += t; }\n\n poly operator-(const poly &t) const { return poly(*this) -= t; }\n\n poly mod_xk(size_t k) const { // get same polynomial mod x^k\n k = min(k, a.size());\n return vector(begin(a), begin(a) + k);\n }\n\n poly mul_xk(size_t k) const { // multiply by x^k\n poly res(*this);\n res.a.insert(begin(res.a), k, 0);\n return res;\n }\n\n poly div_xk(size_t k) const { // divide by x^k, dropping coefficients\n k = min(k, a.size());\n return vector(begin(a) + k, end(a));\n }\n\n poly substr(size_t l, size_t r) const { // return mod_xk(r).div_xk(l)\n l = min(l, a.size());\n r = min(r, a.size());\n return vector(begin(a) + l, begin(a) + r);\n }\n\n poly inv(size_t n) const { // get inverse series mod x^n\n assert(!is_zero());\n poly ans = a[0].inv();\n size_t a = 1;\n while (a < n) {\n poly C = (ans * mod_xk(2 * a)).substr(a, 2 * a);\n ans -= (ans * C).mod_xk(a).mul_xk(a);\n a *= 2;\n }\n return ans.mod_xk(n);\n }\n\n poly operator*=(const poly &t) {\n fft::mul(a, t.a);\n normalize();\n return *this;\n }\n\n poly operator*(const poly &t) const { return poly(*this) *= t; }\n\n poly reverse(size_t n, bool rev = 0) const { // reverses and leaves only n terms\n poly res(*this);\n if (rev) { // If rev = 1 then tail goes to head\n res.a.resize(max(n, res.a.size()));\n }\n std::reverse(res.a.begin(), res.a.end());\n return res.mod_xk(n);\n }\n\n pair divmod_slow(const poly &b) const { // when divisor or quotient is small\n vector A(a);\n vector res;\n while (A.size() >= b.a.size()) {\n res.push_back(A.back() / b.a.back());\n if (res.back() != T(0)) {\n for (size_t i = 0; i < b.a.size(); i++) {\n A[A.size() - i - 1] -= res.back() * b.a[b.a.size() - i - 1];\n }\n }\n A.pop_back();\n }\n std::reverse(begin(res), end(res));\n return {res, A};\n }\n\n pair divmod(const poly &b) const { // returns quotiend and remainder of a mod b\n if (deg() < b.deg()) {\n return {poly{0}, *this};\n }\n int d = deg() - b.deg();\n if (min(d, b.deg()) < magic) {\n return divmod_slow(b);\n }\n poly D = (reverse(d + 1) * b.reverse(d + 1).inv(d + 1)).mod_xk(d + 1).reverse(d + 1, 1);\n return {D, *this - D * b};\n }\n\n poly operator/(const poly &t) const { return divmod(t).first; }\n\n poly operator%(const poly &t) const { return divmod(t).second; }\n\n poly operator/=(const poly &t) { return *this = divmod(t).first; }\n\n poly operator%=(const poly &t) { return *this = divmod(t).second; }\n\n poly operator*=(const T &x) {\n for (auto &it: a) {\n it *= x;\n }\n normalize();\n return *this;\n }\n\n poly operator/=(const T &x) {\n for (auto &it: a) {\n it /= x;\n }\n normalize();\n return *this;\n }\n\n poly operator*(const T &x) const { return poly(*this) *= x; }\n\n poly operator/(const T &x) const { return poly(*this) /= x; }\n\n void print() const {\n for (auto it: a) {\n cout << it << ' ';\n }\n cout << endl;\n }\n\n T eval(T x) const { // evaluates in single point x\n T res(0);\n for (int i = int(a.size()) - 1; i >= 0; i--) {\n res *= x;\n res += a[i];\n }\n return res;\n }\n\n T &lead() { // leading coefficient\n return a.back();\n }\n\n int deg() const { // degree\n return a.empty() ? -inf : a.size() - 1;\n }\n\n bool is_zero() const { // is polynomial zero\n return a.empty();\n }\n\n T operator[](int idx) const {\n return idx >= (int) a.size() || idx < 0 ? T(0) : a[idx];\n }\n\n T &coef(size_t idx) { // mutable reference at coefficient\n return a[idx];\n }\n\n bool operator==(const poly &t) const { return a == t.a; }\n\n bool operator!=(const poly &t) const { return a != t.a; }\n\n poly deriv() { // calculate derivative\n vector res;\n for (int i = 1; i <= deg(); i++) {\n res.push_back(T(i) * a[i]);\n }\n return res;\n }\n\n poly integr() { // calculate integral with C = 0\n vector res = {0};\n for (int i = 0; i <= deg(); i++) {\n res.push_back(a[i] / T(i + 1));\n }\n return res;\n }\n\n size_t leading_xk() const { // Let p(x) = x^k * t(x), return k\n if (is_zero()) {\n return inf;\n }\n int res = 0;\n while (a[res] == T(0)) {\n res++;\n }\n return res;\n }\n\n poly log(size_t n) { // calculate log p(x) mod x^n\n assert(a[0] == T(1));\n return (deriv().mod_xk(n) * inv(n)).integr().mod_xk(n);\n }\n\n poly exp(size_t n) { // calculate exp p(x) mod x^n\n if (is_zero()) {\n return T(1);\n }\n assert(a[0] == T(0));\n poly ans = T(1);\n size_t a = 1;\n while (a < n) {\n poly C = ans.log(2 * a).div_xk(a) - substr(a, 2 * a);\n ans -= (ans * C).mod_xk(a).mul_xk(a);\n a *= 2;\n }\n return ans.mod_xk(n);\n\n }\n\n poly pow_slow(size_t k, size_t n) { // if k is small\n return k ? k % 2 ? (*this * pow_slow(k - 1, n)).mod_xk(n) : (*this * *this).mod_xk(n).pow_slow(k / 2, n)\n : T(1);\n }\n\n poly pow(size_t k, size_t n) { // calculate p^k(n) mod x^n\n if (is_zero()) {\n return *this;\n }\n if (k < magic) {\n return pow_slow(k, n);\n }\n int i = leading_xk();\n T j = a[i];\n poly t = div_xk(i) / j;\n return bpow(j, k) * (t.log(n) * T(k)).exp(n).mul_xk(i * k).mod_xk(n);\n }\n\n poly mulx(T x) { // component-wise multiplication with x^k\n T cur = 1;\n poly res(*this);\n for (int i = 0; i <= deg(); i++) {\n res.coef(i) *= cur;\n cur *= x;\n }\n return res;\n }\n\n poly mulx_sq(T x) { // component-wise multiplication with x^{k^2}\n T cur = x;\n T total = 1;\n T xx = x * x;\n poly res(*this);\n for (int i = 0; i <= deg(); i++) {\n res.coef(i) *= total;\n total *= cur;\n cur *= xx;\n }\n return res;\n }\n\n vector chirpz_even(T z, int n) { // P(1), P(z^2), P(z^4), ..., P(z^2(n-1))\n int m = deg();\n if (is_zero()) {\n return vector(n, 0);\n }\n vector vv(m + n);\n T zi = z.inv();\n T zz = zi * zi;\n T cur = zi;\n T total = 1;\n for (int i = 0; i <= max(n - 1, m); i++) {\n if (i <= m) { vv[m - i] = total; }\n if (i < n) { vv[m + i] = total; }\n total *= cur;\n cur *= zz;\n }\n poly w = (mulx_sq(z) * vv).substr(m, m + n).mulx_sq(z);\n vector res(n);\n for (int i = 0; i < n; i++) {\n res[i] = w[i];\n }\n return res;\n }\n\n vector chirpz(T z, int n) { // P(1), P(z), P(z^2), ..., P(z^(n-1))\n auto even = chirpz_even(z, (n + 1) / 2);\n auto odd = mulx(z).chirpz_even(z, n / 2);\n vector ans(n);\n for (int i = 0; i < n / 2; i++) {\n ans[2 * i] = even[i];\n ans[2 * i + 1] = odd[i];\n }\n if (n % 2 == 1) {\n ans[n - 1] = even.back();\n }\n return ans;\n }\n\n template\n vector eval(vector &tree, int v, iter l, iter r) { // auxiliary evaluation function\n if (r - l == 1) {\n return {eval(*l)};\n } else {\n auto m = l + (r - l) / 2;\n auto A = (*this % tree[2 * v]).eval(tree, 2 * v, l, m);\n auto B = (*this % tree[2 * v + 1]).eval(tree, 2 * v + 1, m, r);\n A.insert(end(A), begin(B), end(B));\n return A;\n }\n }\n\n vector eval(vector x) { // evaluate polynomial in (x1, ..., xn)\n int n = x.size();\n if (is_zero()) {\n return vector(n, T(0));\n }\n vector tree(4 * n);\n build(tree, 1, begin(x), end(x));\n return eval(tree, 1, begin(x), end(x));\n }\n\n template\n poly inter(vector &tree, int v, iter l, iter r, iter ly, iter ry) { // auxiliary interpolation function\n if (r - l == 1) {\n return {*ly / a[0]};\n } else {\n auto m = l + (r - l) / 2;\n auto my = ly + (ry - ly) / 2;\n auto A = (*this % tree[2 * v]).inter(tree, 2 * v, l, m, ly, my);\n auto B = (*this % tree[2 * v + 1]).inter(tree, 2 * v + 1, m, r, my, ry);\n return A * tree[2 * v + 1] + B * tree[2 * v];\n }\n }\n };\n\n template\n poly operator*(const T &a, const poly &b) {\n return b * a;\n }\n\n template\n poly xk(int k) { // return x^k\n return poly{1}.mul_xk(k);\n }\n\n template\n T resultant(poly a, poly b) { // computes resultant of a and b\n if (b.is_zero()) {\n return 0;\n } else if (b.deg() == 0) {\n return bpow(b.lead(), a.deg());\n } else {\n int pw = a.deg();\n a %= b;\n pw -= a.deg();\n T mul = bpow(b.lead(), pw) * T((b.deg() & a.deg() & 1) ? -1 : 1);\n T ans = resultant(b, a);\n return ans * mul;\n }\n }\n\n template\n poly kmul(iter L, iter R) { // computes (x-a1)(x-a2)...(x-an) without building tree\n if (R - L == 1) {\n return vector{-*L, 1};\n } else {\n iter M = L + (R - L) / 2;\n return kmul(L, M) * kmul(M, R);\n }\n }\n\n template\n poly build(vector> &res, int v, iter L, iter R) { // builds evaluation tree for (x-a1)(x-a2)...(x-an)\n if (R - L == 1) {\n return res[v] = vector{-*L, 1};\n } else {\n iter M = L + (R - L) / 2;\n return res[v] = build(res, 2 * v, L, M) * build(res, 2 * v + 1, M, R);\n }\n }\n\n template\n poly inter(vector x, vector y) { // interpolates minimum polynomial from (xi, yi) pairs\n int n = x.size();\n vector> tree(4 * n);\n return build(tree, 1, begin(x), end(x)).deriv().inter(tree, 1, begin(x), end(x), begin(y), end(y));\n }\n};\n\nusing namespace algebra;\n\nconst int mod = 1e9 + 7;\ntypedef modular base;\ntypedef poly polyn;\n\nusing namespace algebra;\n\n//signed main() {\n// ios::sync_with_stdio(0);\n// cin.tie(0);\n// int n = 100000;\n// polyn a;\n// vector x;\n// for(int i = 0; i <= n; i++) {\n// a.a.push_back(1 + rand() % 100);\n// x.push_back(1 + rand() % (2 * n));\n// }\n// sort(begin(x), end(x));\n// x.erase(unique(begin(x), end(x)), end(x));\n// auto b = a.eval(x);\n// cout << clock() / double(CLOCKS_PER_SEC) << endl;\n// auto c = inter(x, b);\n// polyn md = kmul(begin(x), end(x));\n// cout << clock() / double(CLOCKS_PER_SEC) << endl;\n// assert(c == a % md);\n// return 0;\n//}\n\nusing namespace std;\n\ntemplate\nclass SumFFT : public FFT {\n int result_length(int first_length, int second_length) {\n return max(first_length + second_length - 1, 0);\n }\n\n long long result_length_power(long long length, long long power) {\n return max(((length - 1) << power) + 1, 0ll);\n }\n\nprotected:\n virtual T calculate_root(int N) = 0;\n\npublic:\n vector transform(vector y, bool invert = false) {\n const int N = y.size();\n assert(N == (N & -N));\n vector rev(N);\n for (int i = 1; i < N; ++i) {\n rev[i] = (rev[i >> 1] >> 1) | (i & 1 ? N >> 1 : 0);\n if (rev[i] < i) swap(y[i], y[rev[i]]);\n }\n vector rootni(N / 2);\n for (int n = 2; n <= N; n *= 2) {\n T rootn = calculate_root(n);\n if (invert) {\n rootn = T(1) / rootn;\n }\n rootni[0] = 1;\n for (int i = 1; i < n / 2; ++i) rootni[i] = rootni[i - 1] * rootn;\n for (int left = 0; left != N; left += n) {\n const int mid = left + n / 2;\n for (int i = 0; i < n / 2; ++i) {\n const T temp = rootni[i] * y[mid + i];\n y[mid + i] = y[left + i] - temp;\n y[left + i] += temp;\n }\n }\n }\n if (invert) for (auto &v : y) v /= N;\n return move(y);\n }\n\n vector bluestein(vector y, bool invert) {\n// using Poly = Polynomial<0>;\n int n = y.size(), N = 2 * n;\n T rootn = calculate_root(N), inverse_rootn = 1 / rootn;\n if (invert) {\n swap(rootn, inverse_rootn);\n }\n vector A(n), B(2 * n - 1);\n for (int i = 0; i < n; i++) {\n A[i] = (long long) (y[i] * binpow(rootn, (long long) i * i));\n }\n for (int i = -(n - 1); i < n; i++) {\n B[i + n - 1] = (long long) (binpow(inverse_rootn, (long long) i * i));\n }\n fft::mul(A, B);\n for (int i = 0; i < n; i++) {\n y[i] = binpow(rootn, (long long) i * i) * A[n - 1 + i];\n }\n if (invert) for (auto &v : y) v /= n;\n return move(y);\n }\n\n vector cyclic_convolution(vector a, vector b) {\n assert(a.size() == b.size());\n int n = a.size();\n vector c = this->linear_convolution(move(a), move(b));\n for (int i = c.size() - 1; i >= n; --i) c[i - n] += c[i];\n c.resize(n);\n return move(c);\n }\n\n vector cyclic_convolution_power(vector a, long long power, int length = -1) {\n int n = a.size();\n vector c = this->linear_convolution_power(move(a), power, length);\n for (int i = c.size() - 1; i >= n; --i) c[i % n] += c[i];\n c.resize(n);\n return move(c);\n }\n\n template\n vector cyclic_convolution(vector a, vector b) {\n assert(a.size() == b.size());\n int n = a.size();\n vector fa = bluestein(move(a)), fb = bluestein(move(b)), &fc = fa;\n for (int i = 0; i < n; ++i) fc[i] = fa[i] * fb[i];\n vector c = bluestein(move(fc), true);\n return move(c);\n }\n\n template\n vector cyclic_convolution_power(vector a, long long power) {\n int n = a.size();\n vector fa = bluestein(move(a)), &fc = fa;\n for (int i = 0; i < n; ++i) fc[i] = binpow(fa[i], power);\n vector c = transform(move(fc), true);\n return move(c);\n }\n};\n\n\n#include \n#include \n\n\ntemplate\n//todo[c++14] use std::enable_if_t\nusing enable_if_t = typename std::enable_if::type;\n\n\ntemplate\nclass Zn {\npublic:\n Zn() : value(0) {\n }\n\n /**\n * Instead of ctor, to allow not to normalize in ctor\n */\n template\n static Zn valueOf(U value) {\n int x = static_cast(value % mod());\n if (x < 0) {\n x += mod();\n }\n return Zn(x);\n }\n\n static Zn rawValueOf(int value) {\n SPCPPL_ASSERT(value >= 0 && value < mod());\n return Zn(value);\n }\n\n template\n Zn &operator=(U rhs) {\n return *this = Zn::valueOf(rhs);\n }\n\n\n Zn &operator+=(const Zn &rhs) {\n value += rhs.value;\n if (value >= mod()) {\n value -= mod();\n }\n return *this;\n }\n\n template\n Zn &operator+=(U rhs) {\n return *this += Zn::valueOf(rhs);\n }\n\n Zn &operator-=(const Zn &rhs) {\n value -= rhs.value;\n if (value < 0) {\n value += mod();\n }\n return *this;\n }\n\n template\n Zn &operator-=(U rhs) {\n return *this -= Zn::valueOf(rhs);\n }\n\n Zn &operator*=(const Zn &rhs) {\n long long result = static_cast(value) * static_cast(rhs.value);\n value = static_cast(result % mod());\n return *this;\n }\n\n template\n Zn &operator*=(U rhs) {\n return *this *= Zn::valueOf(rhs);\n }\n\n Zn operator-() const {\n if (value == 0) {\n return *this;\n } else {\n return Zn(mod() - value);\n }\n }\n\n Zn &operator/=(const Zn &rhs) {\n return *this *= rhs.inversed();\n }\n\n template\n Zn &operator/=(U rhs) {\n return *this /= Zn::valueOf(rhs);\n }\n\n Zn inversed() const {\n SPCPPL_ASSERT(value != 0);\n\n int x, y;\n int gcd = extendedGcd(value, mod(), x, y);\n (void) gcd;\n SPCPPL_ASSERT(gcd == 1);\n\n if (x < 0) {\n x += mod();\n }\n return Zn(x);\n }\n\n template\n friend std::ostream &operator<<(std::ostream &, const Zn &zn);\n\n template\n friend std::istream &operator>>(std::istream &, Zn &zn);\n\n template\n friend bool operator==(const Zn &lhs, const Zn &rhs);\n\n int intValue() const {\n return value;\n }\n\nprivate:\n /**\n * No normalization performed\n */\n explicit Zn(int value) : value(value) {\n }\n\n int value;\n\n constexpr static int mod() {\n return T::value;\n }\n\n template\n static constexpr bool correct_or_runtime(int) {\n return N > 0 && N <= (1 << 30);\n }\n\n static constexpr bool correct_or_runtime(...) {\n return true;\n }\n\n static_assert(\n std::is_same::type, int>::value,\n \"T::value must be int\"\n );\n static_assert(correct_or_runtime(0), \"Mod has to be positive integer up to 1 << 30\");\n};\n\ntemplate\nbool operator==(const Zn &lhs, const Zn &rhs) {\n return lhs.value == rhs.value;\n}\n\ntemplate\nbool operator==(const Zn &lhs, U rhs) {\n return lhs == Zn::valueOf(rhs);\n}\n\ntemplate\nbool operator==(U lhs, const Zn &rhs) {\n return rhs == lhs;\n}\n\ntemplate\nbool operator!=(const Zn &lhs, const Zn &rhs) {\n return !(lhs == rhs);\n}\n\ntemplate\nbool operator!=(const Zn &lhs, U rhs) {\n return !(lhs == rhs);\n}\n\ntemplate\nbool operator!=(U lhs, const Zn &rhs) {\n return !(lhs == rhs);\n}\n\ntemplate\nZn operator+(const Zn &lhs, const Zn &rhs) {\n Zn copy = lhs;\n return copy += rhs;\n}\n\ntemplate\nZn operator+(const Zn &lhs, U rhs) {\n Zn copy = lhs;\n return copy += rhs;\n}\n\ntemplate\nZn operator+(U lhs, const Zn &rhs) {\n return rhs + lhs;\n}\n\ntemplate\nZn operator-(const Zn &lhs, const Zn &rhs) {\n Zn copy = lhs;\n return copy -= rhs;\n}\n\ntemplate\nZn operator-(const Zn &lhs, U rhs) {\n Zn copy = lhs;\n return copy -= rhs;\n}\n\ntemplate\nZn operator-(U lhs, const Zn &rhs) {\n return Zn::valueOf(lhs) - rhs;\n}\n\ntemplate\nZn operator*(const Zn &lhs, const Zn &rhs) {\n Zn copy = lhs;\n return copy *= rhs;\n}\n\ntemplate\nZn operator*(const Zn &lhs, U rhs) {\n Zn copy = lhs;\n return copy *= rhs;\n}\n\ntemplate\nZn operator*(U lhs, const Zn &rhs) {\n return rhs * lhs;\n}\n\ntemplate\nZn operator/(const Zn &lhs, const Zn &rhs) {\n Zn copy = lhs;\n return copy /= rhs;\n}\n\ntemplate\nZn operator/(const Zn &lhs, U rhs) {\n Zn copy = lhs;\n return copy /= rhs;\n}\n\ntemplate\nZn operator/(U lhs, const Zn &rhs) {\n return Zn::valueOf(lhs) / rhs;\n}\n\ntemplate\nstd::ostream &operator<<(std::ostream &stream, const Zn &zn) {\n return stream << zn.value;\n}\n\ntemplate\nstd::istream &operator>>(std::istream &stream, Zn &zn) {\n int64_t value;\n stream >> value;\n zn.value = static_cast(value % T::value);\n return stream;\n}\n\ntemplate\nstruct IdentityHelper> {\n static Zn identity() {\n return Zn::valueOf(1);\n }\n};\n\ntemplate\nusing ZnConst = Zn>;\n\nusing Zn7 = ZnConst<1000000007>;\n\n\n#include \n\n\ntemplate\nvoid sort(R &range) {\n std::sort(range.begin(), range.end());\n}\n\ntemplate\nvoid sort(R &range, Comp comp) {\n std::sort(range.begin(), range.end(), comp);\n}\n\ntemplate\nvoid reverse(R &range) {\n std::reverse(range.begin(), range.end());\n}\n\ntemplate\nauto lower_bound(const R &range, const T &value) -> decltype(range.begin()) {\n return std::lower_bound(range.begin(), range.end(), value);\n}\n\ntemplate\nauto lower_bound(const R &range, const T &value, Comp comp) -> decltype(range.begin()) {\n return std::lower_bound(range.begin(), range.end(), value, comp);\n}\n\ntemplate\nauto upper_bound(const R &range, const T &value) -> decltype(range.begin()) {\n return std::upper_bound(range.begin(), range.end(), value);\n}\n\ntemplate\nauto upper_bound(const R &range, const T &value, Comp comp) -> decltype(range.begin()) {\n return std::upper_bound(range.begin(), range.end(), value, comp);\n}\n\ntemplate\nauto min_element(const R &range) -> decltype(range.begin()) {\n return std::min_element(range.begin(), range.end());\n}\n\ntemplate\nauto max_element(const R &range) -> decltype(range.begin()) {\n return std::max_element(range.begin(), range.end());\n}\n\ntemplate\nbool next_permutation(R &range) {\n return std::next_permutation(range.begin(), range.end());\n}\n\ntemplate\nvoid fill(R &range, const T &value) {\n std::fill(range.begin(), range.end(), value);\n}\n\ntemplate\nvoid unique(std::vector &range) {\n range.erase(std::unique(range.begin(), range.end()), range.end());\n}\n\ntemplate\nR sorted(R range) {\n sort(range);\n return range;\n}\n\ntemplate\nR sorted(R range, Comp comp) {\n sort(range, comp);\n return range;\n}\n\ntemplate\nR reversed(R range) {\n reverse(range);\n return range;\n}\n\n\ntemplate\nstd::vector unsortedDivisors(const T &n) {\n std::vector result;\n for (T i = 1; i * i <= n; ++i) {\n if (n % i == 0) {\n result.push_back(i);\n if (i * i != n) {\n result.push_back(n / i);\n }\n }\n }\n return result;\n}\n\ntemplate\nstd::vector sortedDivisors(const T &n) {\n return sorted(unsortedDivisors(n));\n}\n\ntemplate\nstd::vector primeDivisors(T n) {\n std::vector result;\n for (T i = 2; i * i <= n; ++i) {\n if (n % i == 0) {\n result.push_back(i);\n while (n % i == 0) {\n n /= i;\n }\n }\n }\n if (n > 1) {\n result.push_back(n);\n }\n return result;\n}\n\n\nclass ModularFFT : public SumFFT {\n Modular root;\n\n Modular calculate_root(int N) {\n assert((MOD - 1) % N == 0);\n return binpow(root, (MOD - 1) / N);\n }\n\npublic:\n ModularFFT() {\n assert(isPrime(MOD));\n vector divisors = primeDivisors(MOD - 1);\n for (root = 1;; root++) {\n bool valid = true;\n for (int d: divisors) {\n int aux = (int) binpow(root, (MOD - 1) / d);\n if (binpow(root, (MOD - 1) / d) == 1) {\n valid = false;\n break;\n }\n }\n if (valid) {\n break;\n }\n }\n }\n};\n\nusing namespace std;\n\nclass ECyclicCipher {\n static const int MIN_MOD = 10'000;\n static const long long INF = 1ll << 60;\n\n vector convert(const vector &A) {\n vector res(A.begin(), A.end());\n return move(res);\n }\n\n void get_mod(const vector &A) {\n int n = A.size(), begin = (MIN_MOD + 2 * n - 1) / (2 * n) * (2 * n) + 1;\n for (MOD = begin;; MOD += 2 * n) {\n if (isPrime(MOD)) {\n ModularFFT fft;\n vector MA = convert(A), TA = fft.bluestein(MA, false);\n assert(TA[0] == 0);\n if (not count(TA.begin() + 1, TA.end(), 0)) {\n return;\n }\n }\n }\n }\n\n int isqrt(long long n) {\n int res = sqrtl(n);\n while ((long long) res * res < n) {\n res++;\n }\n while ((long long) res * res > n) {\n res--;\n }\n return (long long) res * res == n ? res : -1;\n }\n\n vector solve(long long a, long long b, long long c) {\n long double long_delta = (long double) b * b - (long double) 4 * a * c;\n if (logl(long_delta) > logl(INF)) {\n return {};\n }\n long long delta = b * b - 4 * a * c;\n if (delta < 0) {\n return {};\n }\n int sqrt_delta = isqrt(delta);\n if (sqrt_delta < 0) {\n return {};\n }\n vector res;\n long long x = -b - sqrt_delta;\n if (x % (2 * a) == 0) {\n x /= 2 * a;\n res.push_back((int) x);\n }\n if (sqrt_delta != 0) {\n x = -b + sqrt_delta;\n if (x % (2 * a) == 0) {\n x /= 2 * a;\n res.push_back((int) x);\n }\n }\n return res;\n }\n\npublic:\n void solve(std::istream &in, std::ostream &out) {\n int n;\n in >> n;\n vector b(n), c(n);\n in >> b >> c;\n vector C(n), B(n);\n for (int i = 0; i < n; i++) {\n B[i] = 2 * (b[(n - i) % n] - b[n - 1 - i]);\n C[i] = c[(i + 1) % n] - c[i];\n }\n get_mod(B);\n vector MB = convert(B), MC = convert(C);\n ModularFFT fft;\n vector TB = fft.bluestein(MB, false), TC = fft.bluestein(MC, false), TA(n);\n assert(TB[0] == 0 and TC[0] == 0);\n for (int i = 1; i < n; i++) {\n assert(TB[i] != 0);\n TA[i] = TC[i] / TB[i];\n }\n vector A = fft.bluestein(TA, true);\n// check(A, B, C);\n for (int i = 1; i < n; i++) {\n A[i] -= A[0];\n }\n A[0] = 0;\n vector AA(n);\n bool valid = true;\n for (int i = 0; i < n; i++) {\n int a = (int) A[i];\n if (a <= MIN_MOD / 2) {\n AA[i] = a;\n } else {\n a = MOD - a;\n if (a <= MIN_MOD / 2) {\n AA[i] = -a;\n } else {\n valid = false;\n }\n }\n }\n vector> res;\n if (valid) {\n long long a0 = -c[0], a1 = 0, a2 = n;\n for (int i = 0; i < n; i++) {\n int d = AA[i] - b[i];\n a0 += d * d;\n a1 += 2 * d;\n }\n vector X = solve(a2, a1, a0);\n for (int x: X) {\n vector a(n);\n for (int i = 0; i < n; i++) {\n a[i] = AA[i] + x;\n }\n res.push_back(a);\n }\n }\n out << res.size() << \"\\n\";\n for (auto &vec: res) {\n out << vec << \"\\n\";\n }\n }\n\n void setup() {}\n};\n\n\nint main() {\n std::ios_base::sync_with_stdio(false);\n ECyclicCipher solver;\n solver.setup();\n std::istream &in(std::cin);\n std::ostream &out(std::cout);\n in.tie(nullptr);\n out << std::fixed;\n out.precision(20);\n solver.solve(in, out);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "98e0b71cc85661ac8229bbcf76a3e37a", "src_uid": "d8c531799874ce5bf5443aba1d34b26d", "difficulty": 3300.0} {"lang": "GNU C++0x", "source_code": "/** Micro Mezzo Macro Flation -- Overheated Economy ., Last Update: Dec. 24th 2012 **/ //{\n\n/** Header .. **/ //{\n#define LOCAL\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, n) for (int i=0;i=int(a);--i)\n#define REP_1(i, n) for (int i=1;i<=int(n);++i)\n#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)\n#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)\n#define REP_C(i, n) for (int n____=int(n),i=0;i=a____;--i)\n#define REP_N(i, n) for (i=0;i=int(a);--i)\n#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)\n#define REP_1_N(i, n) for (i=1;i<=int(n);++i)\n#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)\n#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)\n#define REP_C_N(i, n) for (int n____=(i=0,int(n));i=a____;--i)\n#define REP_1_C_N(i, n) for (int n____=(i=1,int(n));i<=n____;++i)\n#define FOR_1_C_N(i, a, b) for (int b____=(i=1,int(b);i<=b____;++i)\n#define DWN_1_C_N(i, b, a) for (int a____=(i=b,int(a));i>=a____;--i)\n\n#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)\n#define REP_S(i, str) for (char*i=str;*i;++i)\n#define REP_L(i, hd, nxt) for (int i=hd;i;i=nxt[i])\n#define REP_G(i, u) REP_L(i,hd[u],suc)\n#define DO(n) for ( int ____n ## __line__ = n; ____n ## __line__ -- ; )\n#define REP_2(i, j, n, m) REP(i, n) REP(j, m)\n#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)\n#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)\n#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)\n\n#define ALL(A) A.begin(), A.end()\n#define LLA(A) A.rbegin(), A.rend()\n#define CPY(A, B) memcpy(A, B, sizeof(A))\n#define INS(A, P, B) A.insert(A.begin() + P, B)\n#define ERS(A, P) A.erase(A.begin() + P)\n#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin())\n#define CTN(T, x) (T.find(x) != T.end())\n#define SZ(A) int(A.size())\n#define PB push_back\n#define MP(A, B) make_pair(A, B)\n#define PTT pair\n#define fi first\n#define se second\n\n#define Rush for(int ____T=RD(); ____T--;)\n\n#define Display(A, n, m) { \\\n\tREP(i, n){\t\t \\\n REP(j, m) cout << A[i][j] << \" \"; \\\n cout << endl;\t\t\t\t \\\n\t}\t\t\t\t\t\t \\\n}\n\n#define Display_1(A, n, m) {\t\t\t\t \\\n\tREP_1(i, n){\t\t \\\n REP_1(j, m) cout << A[i][j] << \" \"; \\\n\t\tcout << endl;\t\t \t\t\\\n\t}\t\t\t\t\t\t \\\n}\n\n#pragma comment(linker, \"/STACK:36777216\")\n//#pragma GCC optimize (\"O2\")\n#define Ruby system(\"ruby main.rb\")\n#define Haskell system(\"runghc main.hs\")\n#define Python system(\"python main.py\")\n#define Pascal system(\"fpc main.pas\")\n\ntypedef long long LL;\n//typedef long double DB;\ntypedef double DB;\ntypedef unsigned UINT;\ntypedef unsigned long long ULL;\n\ntypedef vector VI;\ntypedef vector VC;\ntypedef vector VS;\ntypedef vector VL;\ntypedef vector VF;\ntypedef set SI;\ntypedef set SS;\ntypedef map MII;\ntypedef map MSI;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VII;\ntypedef vector VVI;\ntypedef vector VVII;\n\ntemplate inline T& RD(T &);\ntemplate inline void OT(const T &);\ninline LL RD(){LL x; return RD(x);}\ninline DB& RF(DB &);\ninline DB RF(){DB x; return RF(x);}\ninline char* RS(char *s);\ninline char& RC(char &c);\ninline char RC();\ninline char& RC(char &c){scanf(\" %c\", &c); return c;}\ninline char RC(){char c; return RC(c);}\n//inline char& RC(char &c){c = getchar(); return c;}\n//inline char RC(){return getchar();}\n\ntemplate inline T& RDD(T &x){\n char c; for (c = getchar(); c < '-'; c = getchar());\n if (c == '-'){x = '0' - getchar(); for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + '0' - c;}\n else {x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';}\n return x;\n}\n\ninline LL RDD(){LL x; return RDD(x);}\n\ntemplate inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}\ntemplate inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}\ninline char& RC(char &a, char &b){RC(a), RC(b); return a;}\ninline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}\ninline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}\ninline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}\ninline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}\ninline void RS(char *s1, char *s2){RS(s1), RS(s2);}\ninline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}\ntemplateinline void RDD(const T0&a, const T1&b){RDD(a),RDD(b);}\ntemplateinline void RDD(const T0&a, const T1&b, const T2&c){RDD(a),RDD(b),RDD(c);}\n\ntemplate inline void RST(T &A){memset(A, 0, sizeof(A));}\ntemplate inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}\ntemplate inline void FLC(T &A, int x){memset(A, x, sizeof(A));}\ntemplate inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}\ntemplate inline void CLR(priority_queue, less > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(priority_queue, greater > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(T &A){A.clear();}\ntemplate inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}\ntemplate inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}\n\ntemplate inline T& SRT(T &A){sort(ALL(A)); return A;}\ntemplate inline T& SRT(T &A, C B){sort(ALL(A), B); return A;}\ntemplate inline T& UNQ(T &A){A.resize(unique(ALL(SRT(A)))-A.begin());return A;}\n\n//}\n\n/** Constant List .. **/ //{\n\nconst int MOD = 1000000007;\n//int MOD = 99990001;\nconst int INF = 0x3f3f3f3f;\nconst LL INFF = 1LL << 60;\nconst DB EPS = 1e-9;\nconst DB OO = 1e20;\nconst DB PI = acos(-1.0); //M_PI;\n\nconst int dx[] = {-1, 0, 1, 0};\nconst int dy[] = {0, 1, 0, -1};\n\n//}\n\n/** Add On .. **/ //{\n// <<= '0. Nichi Joo ., //{\ntemplate inline void checkMin(T &a,const T b){if (b inline void checkMax(T &a,const T b){if (a inline void checkMin(T &a, T &b, const T x){checkMin(a, x), checkMin(b, x);}\ntemplate inline void checkMax(T &a, T &b, const T x){checkMax(a, x), checkMax(b, x);}\ntemplate inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}\ntemplate inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}\ntemplate inline T min(T a, T b, T c){return min(min(a, b), c);}\ntemplate inline T max(T a, T b, T c){return max(max(a, b), c);}\ntemplate inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}\ntemplate inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}\ntemplate inline T sqr(T a){return a*a;}\ntemplate inline T cub(T a){return a*a*a;}\ninline int ceil(int x, int y){return (x - 1) / y + 1;}\ninline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}\ninline int sgn(DB x, DB y){return sgn(x - y);}\n//}\n// <<= '1. Bitwise Operation ., //{\nnamespace BO{\n\ninline bool _1(int x, int i){return bool(x&1<> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);\n x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);\n x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);\n x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);\n x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);\n return x;\n}\n\ninline LL reverse_bits(LL x){\n x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);\n x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);\n x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);\n x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);\n x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);\n x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);\n return x;\n}\n\ntemplate inline bool odd(T x){return x&1;}\ntemplate inline bool even(T x){return !odd(x);}\ntemplate inline T low_bit(T x) {return x & -x;}\ntemplate inline T high_bit(T x) {T p = low_bit(x);while (p != x) x -= p, p = low_bit(x);return p;}\ntemplate inline T cover_bit(T x){T p = 1; while (p < x) p <<= 1;return p;}\n\ninline int low_idx(int x){return __builtin_ffs(x);}\ninline int low_idx(LL x){return __builtin_ffsll(x);}\ninline int high_idx(int x){return low_idx(reverse_bits(x));}\ninline int high_idx(LL x){return low_idx(reverse_bits(x));}\ninline int clz(int x){return __builtin_clz(x);}\ninline int clz(LL x){return __builtin_clzll(x);}\ninline int ctz(int x){return __builtin_ctz(x);}\ninline int ctz(LL x){return __builtin_ctzll(x);}\ninline int parity(int x){return __builtin_parity(x);}\ninline int parity(LL x){return __builtin_parityll(x);}\ninline int lg2(int a){return 31 - clz(a);}\ninline int lg2(LL a){return 63 - clz(a);}\ninline int count_bits(int x){return __builtin_popcount(x);}\ninline int count_bits(LL x){return __builtin_popcountll(x);}\n\n} using namespace BO;//}\n// <<= '2. Number Theory .,//{\nnamespace NT{\ninline LL __lcm(LL a, LL b){return a*b/__gcd(a,b);}\ninline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}\ninline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}\ninline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}\ninline int dff(int a, int b){a -= b; if (a < 0) a += MOD; return a;}\ninline void MUL(int &a, int b){a = (LL)a * b % MOD;}\ninline int pdt(int a, int b){return (LL)a * b % MOD;}\n\ninline int sum(int a, int b, int c){return sum(sum(a, b), c);}\ninline int sum(int a, int b, int c, int d){return sum(sum(a, b), sum(c, d));}\ninline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}\ninline int pdt(int a, int b, int c, int d){return pdt(pdt(pdt(a, b), c), d);}\n\ninline int pow(int a, int b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ninline int pow(int a, LL b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ntemplate inline T pow(T a, LL b){\n T c(1); while (b){\n if (b&1) c *= a;\n a *= a, b >>= 1;\n }\n return c;\n}\n\ninline int _I(int b){\n int a = MOD, x1 = 0, x2 = 1, q;\n while (true){\n q = a / b, a %= b;\n if (!a) return (x2 + MOD) % MOD;\n DEC(x1, pdt(q, x2));\n\n q = b / a, b %= a;\n if (!b) return (x1 + MOD) % MOD;\n DEC(x2, pdt(q, x1));\n }\n}\n\ninline void DIV(int &a, int b){MUL(a, _I(b));}\ninline int qtt(int a, int b){return pdt(a, _I(b));}\n\ninline int phi(int n){\n int res = n; for (int i=2;sqr(i)<=n;++i) if (!(n%i)){\n DEC(res, qtt(res, i));\n do{n /= i;} while(!(n%i));\n }\n if (n != 1)\n DEC(res, qtt(res, n));\n return res;\n}\n\n} using namespace NT;//}\n\nnamespace SL{\n namespace KMP{\n\n void calc_pi(const char *P, int n, int *pi){\n for (int i = 1, j = pi[0] = -1; i < n; ++i){\n while (j >= 0 && P[i] != P[j+1]) j = pi[j];\n if (P[i] == P[j+1]) ++j;\n pi[i] = j;\n }\n //REP(i, n) cout << pi[i] << \" \"; cout << endl;\n }\n\n bool run(const char *T, int n, const char *P, int m, const int *pi){\n for (int i = 0, j = -1; i < n; ++i){\n while (j >= 0 && T[i] != P[j+1]) j = pi[j];\n if (T[i] == P[j+1]) ++j;\n if (j == m - 1) return true;\n }\n return false;\n }\n\n } //using namespace KMP;\n\n namespace Z{\n void calc_z(const char *P, int n, int *z){\n\n z[0] = n;\n\n for (int i = 1, l = 0, r = 0; i < n; ++i){\n if (i > r){\n for(l = r = i; r < n && P[r] == P[r - l];) ++r;\n z[i] = r - l, --r;\n }\n else {\n if (z[i - l] < r - i + 1) z[i] = z[i - l];\n else {\n for (l = i;r < n && P[r] == P[r - l];) ++r;\n z[i] = r - l, --r;\n }\n }\n }\n\n //REP(i, n) cout << z[i] << \" \"; cout << endl;\n }\n\n int run(const char *T, int n, const char *P, int m, const int *z){\n\n int ex; REP_C_N(ex, min(n, m)) if (T[ex] != P[ex]) break;\n\n int res = ex == m;\n\n for (int i = 1, l = 0, r = 0; i < n; ++i){\n if (i > r){\n for (l = r = i; r < n && T[r] == P[r - l];) ++r;\n ex = r - l, --r;\n }\n else {\n if (z[i - l] < r - i + 1) ex = z[i - l];\n else {\n for (l = i; r < n && T[r] == P[r - l];) ++r;\n ex = r - l, --r;\n }\n }\n if (ex == m) ++res;\n }\n\n return res;\n }\n } //using namespace Z;\n\n void Manacher(char s[], int n, int p[]){\n const int NN = 0;\n static char ss[NN*2+2]; int nn = 2*n+2;\n ss[0] = '$', ss[nn-1] = '#', ss[nn] = 0;\n REP(i, n) ss[i*2+1] ='#', ss[i*2+2] = s[i];\n int mx = 0, id = 0; FOR(i, 1, nn){\n p[i] = mx > i ? min(p[2*id-i], mx - i) : 1;\n while (ss[i+p[i]] == ss[i-p[i]]) ++p[i];\n if (i + p[i] > mx) mx = i + p[i], id = i;\n }\n }\n\n} //using namespace SL;//}\n// <<= '9. Comutational Geometry .,//{\nnamespace CG{\n\nstruct Po; struct Line; struct Seg;\n\nstruct Po{\n DB x, y; Po(DB _x=0, DB _y=0):x(_x), y(_y){}\n friend istream& operator >>(istream& in, Po &p){return in >> p.x >> p.y;}\n friend ostream& operator <<(ostream& out, Po p){return out << \"(\" << p.x << \", \" << p.y << \")\";}\n bool operator ==(const Po& r)const{return !sgn(x-r.x) && !sgn(y-r.y);};\n bool operator !=(const Po& r)const{return sgn(x-r.x) || sgn(y-r.y);}\n Po operator +(const Po& r)const{return Po(x+r.x, y+r.y);}\n Po operator -(const Po& r)const{return Po(x-r.x, y-r.y);}\n Po operator *(DB k)const{return Po(x*k,y*k);}\n Po operator /(DB k)const{return Po(x/k,y/k);}\n DB operator *(const Po&) const;\n DB operator ^(const Po&) const;\n\n bool operator <(const Po &r) const{return sgn(x,r.x)<0||!sgn(x,r.x)&&sgn(y,r.y)<0;}\n Po operator -()const{return Po(-x,-y);}\n Po& operator +=(const Po &r){x+=r.x,y+=r.y;return *this;}\n Po& operator -=(const Po &r){x-=r.x,y-=r.y;return *this;}\n Po& operator *=(DB k){x*=k,y*=k;return*this;}\n Po& operator /=(DB k){x/=k,y/=k;return*this;}\n\n DB length_sqr()const{return sqr(x)+sqr(y);}\n DB length()const{return sqrt(length_sqr());}\n Po unit()const{return *this/length();}\n bool dgt()const{return !sgn(x)&&!sgn(y);}\n DB atan()const{return atan2(y,x);}\n void rotate(DB alpha, const Po& o = Po()){\n x -= o.x, y -= o.y;\n (*this) = Po(x * cos(alpha) - y * sin(alpha), y * cos(alpha) + x * sin(alpha)) + o;\n }\n\n void input(){RF(x,y);}\n};\n\nPo operator *(DB k, Po a){return a * k;}\n\n#define innerProduct dot\n#define scalarProduct dot\n#define outerProduct det\n#define crossProduct det\n\ninline DB dot(const DB &x1, const DB &y1, const DB &x2, const DB &y2){return x1 * x2 + y1 * y2;}\ninline DB dot(const Po &a, const Po &b){return dot(a.x, a.y, b.x, b.y);}\ninline DB dot(const Po &p0, const Po &p1, const Po &p2){return dot(p1 - p0, p2 - p0);}\n\ninline DB det(const DB &x1, const DB &y1, const DB &x2, const DB &y2){return x1 * y2 - x2 * y1;}\ninline DB det(const Po &a, const Po &b){return det(a.x, a.y, b.x, b.y);}\ninline DB det(const Po &p0, const Po &p1, const Po &p2){return det(p1 - p0, p2 - p0);}\n\nDB Po::operator *(const Po &r)const{return dot(*this, r);}\nDB Po::operator ^(const Po &r)const{return det(*this, r);}\n\nstruct Line{\n Po a, b;\n Line(DB x0=0, DB y0=0, DB x1=0, DB y1=0):a(Po(x0, y0)), b(Po(x1, y1)){}\n Line(const Po &a, const Po &b):a(a), b(b){}\n Line(const Line &l):a(l.a), b(l.b){}\n\n friend ostream& operator <<(ostream& out, Line p){return out << p.a << \"-\" << p.b;}\n Line operator +(Po x)const{return Line(a + x, b + x);}\n DB length()const{return (b-a).length();}\n bool dgt()const{return (b-a).dgt();}\n void input(){a.input(), b.input();}\n void getequation(DB, DB, DB) const;\n};\n\nstruct Seg: Line{\n};\n\ninline DB dot(const Line &l1, const Line &l2){return dot(l1.b - l1.a, l2.b - l2.a);}\ninline DB det(const Line &l1, const Line &l2){return det(l1.b - l1.a, l2.b - l2.a);}\n\nvoid Line::getequation(DB A, DB B, DB C) const{\n A = a.y - b.y, B = b.x - a.x, C = det(a, b);\n}\n\ntemplate inline DB dist(const T1 &x, const T2 &y){return sqrt(dist_sqr(x, y));}\ntemplate inline DB dist(const T1 &x, const T2 &y, const T3 &z){return sqrt(dist_sqr(x, y, z));}\n\ntemplate inline int dett(const T1 &x, const T2 &y){return sgn(det(x, y));}\ntemplate inline int dott(const T1 &x, const T2 &y){return sgn(dot(x, y));}\ntemplate inline int dett(const T1 &x, const T2 &y, const T3 &z){return sgn(det(x, y, z));}\ntemplate inline int dott(const T1 &x, const T2 &y, const T3 &z){return sgn(dot(x, y, z));}\ntemplate inline int dett(const T1 &x, const T2 &y, const T3 &z, const T4 &w){return sgn(det(x, y, z, w));}\ntemplate inline int dott(const T1 &x, const T2 &y, const T3 &z, const T4 &w){return sgn(dot(x, y, z, w));}\n\ninline DB dist_sqr(const DB &x, const DB &y){return sqr(x) + sqr(y);}\ninline DB dist_sqr(const DB &x, const DB &y, const DB &z){return sqr(x) + sqr(y) + sqr(z);}\ninline DB dist_sqr(const Po &a, const Po &b){return sqr(a.x - b.x) + sqr(a.y - b.y);}\ninline DB dist_sqr(const Po &p, const Line &l){Po v0 = l.b - l.a, v1 = p - l.a; return sqr(fabs(det(v0, v1))) / v0.length_sqr();}\ninline DB dist_sqr(const Po &p, const Seg &l){\n Po v0 = l.b - l.a, v1 = p - l.a, v2 = p - l.b;\n if (sgn(dot(v0, v1)) * sgn(dot(v0, v2)) <= 0) return dist_sqr(p, Line(l));\n else return min(v1.length_sqr(), v2.length_sqr());\n}\ninline DB dist_sqr(Line l, Po p){return dist_sqr(p, l);}\ninline DB dist_sqr(Seg l, Po p){return dist_sqr(p, l);}\ninline DB dist_sqr(Line l1, Line l2){\n if (sgn(det(l1, l2)) != 0) return 0;\n return dist_sqr(l1.a, l2);\n}\ninline DB dist_sqr(Line l1, Seg l2){\n Po v0 = l1.b - l1.a, v1 = l2.a - l1.a, v2 = l2.b - l1.a; DB c1 = det(v0, v1), c2 = det(v0, v2);\n return sgn(c1) != sgn(c2) ? 0 : sqr(min(fabs(c1), fabs(c2))) / v0.length_sqr();\n}\n\nbool isIntersect(Seg l1, Seg l2){\n\n if (l1.a == l2.a || l1.a == l2.b || l1.b == l2.a || l1.b == l2.b) return true;\n\n return\n min(l1.a.x, l1.b.x) <= max(l2.a.x, l2.b.x) &&\n min(l2.a.x, l2.b.x) <= max(l1.a.x, l1.b.x) &&\n min(l1.a.y, l1.b.y) <= max(l2.a.y, l2.b.y) &&\n min(l2.a.y, l2.b.y) <= max(l1.a.y, l1.b.y) &&\n sgn( det(l1.a, l2.a, l2.b) ) * sgn( det(l1.b, l2.a, l2.b) ) <= 0 &&\n sgn( det(l2.a, l1.a, l1.b) ) * sgn( det(l2.b, l1.a, l1.b) ) <= 0;\n\n}\n\ninline DB dist_sqr(Seg l1, Seg l2){\n if (isIntersect(l1, l2)) return 0;\n else return min(dist_sqr(l1.a, l2), dist_sqr(l1.b, l2), dist_sqr(l2.a, l1), dist_sqr(l2.b, l1));\n}\n\ninline bool isOnSide(const Po &p, const Seg &l){\n return p == l.a || p == l.b;\n}\n\ninline bool isOnSeg(const Po &p, const Seg &l){\n return sgn(det(p, l.a, l.b)) == 0 &&\n sgn(l.a.x, p.x) * sgn(l.b.x, p.x) <= 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) <= 0;\n}\n\ninline bool isOnSegg(const Po &p, const Seg &l){\n return sgn(det(p, l.a, l.b)) == 0 &&\n sgn(l.a.x, p.x) * sgn(l.b.x, p.x) < 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) < 0;\n}\n\ninline Po intersect(const Line &l1, const Line &l2){\n return l1.a + (l1.b - l1.a) * (det(l2.a, l1.a, l2.b) / det(l2, l1));\n}\n\n// perpendicular foot\ninline Po intersect(const Po & p, const Line &l){\n return intersect(Line(p, p + Po(l.a.y - l.b.y, l.b.x - l.a.x)), l);\n}\n\ninline Po rotate(Po p, DB alpha, const Po &o = Po()){\n p.rotate(alpha, o);\n return p;\n}\n\n} using namespace CG;//}\n//}\n\n/** I/O Accelerator Interface .. **/ //{\ntemplate inline T& RD(T &x){\n //cin >> x;\n scanf(\"%d\", &x);\n //char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';\n //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n return x;\n}\n\ninline DB& RF(DB &x){\n scanf(\"%lf\", &x);\n /*char t; while ((t=getchar())==' '||t=='\\n'); x = t - '0';\n while ((t=getchar())!=' '&&t!='\\n'&&t!='.')x*=10,x+=t-'0';\n if (t=='.'){DB l=1; while ((t=getchar())!=' '&&t!='\\n')l*=0.1,x += (t-'0')*l;}*/\n return x;\n}\n\ninline char* RS(char *s){\n //gets(s);\n scanf(\"%s\", s);\n return s;\n}\n\nint Case; template inline void OT(const T &x){\n //printf(\"Case %d: %d\\n\", ++Case, x);\n //printf(\"%.2lf\\n\", x);\n printf(\"%d\\n\", x);\n //cout << x << endl;\n}\n//}\n\n//}/* .................................................................................................................................. */\n\n#define fi first\n#define se second\n#define pb push_back\n#define mp make_pair\n\ntypedef pair PIF;\n\nstruct line{\n Po x, y;\n\n line(){}\n line(Po _x,Po _y):x(_x),y(_y){}\n\n void input(){x.input(), y.input();}\n};\n\n\nstruct node{\n string c;vector a;double sz;\n node(string _c,double _sz=0):c(_c),sz(_sz){}\n void add(int x){a.pb(x);}\n};\n\n\n Po med(Po a,Po b,Po c)\n {\n /*if(a p)\n {\n double S=0;\n for(int i=0;i<(int)p.size();i++)\n {\n int j=(i+1)%(int)p.size();\n S+=p[i].x*p[j].y-p[j].x*p[i].y;\n }\n return -S/2;\n }\n double crs(Po a,Po b,Po c)\n {\n return (b.y-a.y)*(c.x-a.x)-(b.x-a.x)*(c.y-a.y);\n }\n int inpoly(Po p,vector a)\n {\n int n=(int)a.size();a.pb(a[0]);\n for(int i=0;ip.y&&crs(a[i],a[i+1],p)<0)++w;else\n if(a[i].y>p.y&&a[i+1].y<=p.y&&crs(a[i],a[i+1],p)>0)--w;\n return w;\n }\n int w,h,n,m,p;\n\n\n\n vector po;\n vector > pa;\n vector gr;\n vector bl;\n vector fl;\n vector > pl;\n\n void bfs(int x,string c)\n {\n string d=gr[x].c;\n queue q;vector v((int)gr.size(),0);\n v[x]=1,q.push(x);\n while(!q.empty())\n {\n int x=q.front();q.pop();\n gr[x].c=c;\n for(int i=0;i<(int)gr[x].a.size();i++)\n if(!v[gr[x].a[i]]&&gr[gr[x].a[i]].c==d)\n q.push(gr[x].a[i]),v[gr[x].a[i]]=1;\n }\n }\n int main()\n {\n\n #ifndef ONLINE_JUDGE\n freopen(\"in.txt\", \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n #endif\n\n RD(w, h, n);\n\n vector l0(n);\n\n REP(i, n) l0[i].input();\n\n //for(int i=0;i vp;\n for(int j=0;j q;\n q.push(i);\n gr.pb(node(\"black\",0.0));\n bl[i]=++p,fl.pb(po[i]);\n while(!q.empty())\n {\n int x=q.front();q.pop();\n for(int j=0;j<(int)pa[x].size();j++)\n if(bl[pa[x][j].fi]==-1)\n q.push(pa[x][j].fi),\n bl[pa[x][j].fi]=p;\n }\n }\n pl.resize(p+1);\n vector > chk(m);\n for(int i=0;i vp;\n int i0=i,j0=j;\n while(!chk[i0][j0])\n {\n vp.pb(po[i0]);\n chk[i0][j0]=1;\n int i1=pa[i0][j0].fi,j1=-1;\n for(int j=0;j<(int)pa[i1].size();j++)\n if(pa[i1][j].fi==i0){j1=(j+1)%(int)pa[i1].size();break;}\n i0=i1,j0=j1;\n }\n double sz=getsz(vp);\n if(sz>0)\n {\n pl.pb(vp);\n gr.pb(node(\"white\",sz));\n int r=bl[i];\n gr[r].add((int)gr.size()-1),\n gr[(int)gr.size()-1].add(r);\n gr[r].sz-=sz;\n }\n }\n for(int i=1;i<=p;i++)\n {\n int fa=0;\n for(int j=(int)pl.size()-1;j>p;j--)\n if(inpoly(fl[i],pl[j])){fa=j;break;}\n gr[fa].add(i),gr[i].add(fa),gr[fa].sz+=gr[i].sz,gr[i].sz=0;\n }\n\n\n\n int _;scanf(\"%d\",&_);\n while(_--){\n\n Po x; x.input();string c;char s[100];scanf(\"%s\",s),c=s;\n\n for(int i=0;ip;i--)\n if(inpoly(x,pl[i])){bfs(i,c);goto end;}\n bfs(0,c);\n end:;\n }\n\n\n map S;\n for(int i=0;i<(int)gr.size();i++)\n S[gr[i].c]+=gr[i].sz;\n //for(map::iterator i=S.begin();i!=S.end();i++)\n\n ECH(it, S){\n printf(\"%s %.9lf\\n\", it->first.c_str(), it->second);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9c430a5d5417ae19d9d91e824646b188", "src_uid": "92caafd07e9afb03745aa6f5b450c38f", "difficulty": 2700.0} {"lang": "GNU C++0x", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\nconst ll p = 1e9+7;\nint grundy[100000010]; ll dp[1005][4]; ll ways[3];\npii sprague[] = { {0, 2}, {1, 1}, {2, 1}, {1, 2}, {2, 2}, {0, 4}, {1, 2}, {2, 4}, {0, 8}, {1, 12}, {2, 1}, {0, 17}, {2, 1}, {1, 23}, {2, 4}, {0, 35}, {2, 1}, {1, 53}, {2, 5}, {0, 76}, {2, 5}, {1, 103}, {2, 19}, {0, 155}, {2, 7}, {1, 236}, {2, 25}, {0, 341}, {2, 23}, {1, 463}, {2, 86}, {0, 697}, {2, 32}, {1, 1060}, {2, 115}, {0, 1532}, {2, 106}, {1, 2081}, {2, 389}, {0, 3136}, {2, 145}, {1, 4769}, {2, 518}, {0, 6892}, {2, 479}, {1, 9364}, {2, 1751}, {0, 14110}, {2, 655}, {1, 21458}, {2, 2333}, {0, 31012}, {2, 2158}, {1, 42137}, {2, 7880}, {0, 63493}, {2, 2950}, {1, 96560}, {2, 10499}, {0, 139552}, {2, 9713}, {1, 189616}, {2, 35461}, {0, 285716}, {2, 13277}, {1, 434518}, {2, 47248}, {0, 627983}, {2, 43709}, {1, 853270}, {2, 159577}, {0, 1285721}, {2, 59747}, {1, 1955329}, {2, 212618}, {0, 2825923}, {2, 196691}, {1, 3839713}, {2, 718099}, {0, 5785742}, {2, 268864}, {1, 8798978}, {2, 956783}, {0, 12716653}, {2, 885110}, {1, 17278708}, {2, 3231446}, {0, 26035837}, {2, 1209890} };\n\nint main() {\n int n, k; cin >> n >> k; dp[0][0] = 1; dp[0][1] = dp[0][2] = dp[0][3] = 0;\n ll total = 0; ways[0] = ways[1] = ways[2] = 0;\n for (int i = 0; total <= k; ++i) {\n if (total + sprague[i].second <= k) {\n ll x1 = (k-total)*sprague[i].second - sprague[i].second*(sprague[i].second+1)/2;\n ways[sprague[i].first] += x1%p; ways[sprague[i].first] %= p;\n total += sprague[i].second;\n } else {\n sprague[i].second = k-total;\n ll x1 = (k-total)*sprague[i].second - sprague[i].second*(sprague[i].second+1)/2;\n ways[sprague[i].first] += x1%p; ways[sprague[i].first] %= p;\n break; \n }\n }\n \n for (int i = 1; i <= 1000; ++i) {\n dp[i][0] = dp[i][1] = dp[i][2] = dp[i][3] = 0;\n for (int j = 0; j <= 3; ++j)\n for (int k = 0; k <= 3; ++k) {\n dp[i][j^k] += dp[i-1][j]*ways[k];\n dp[i][j^k] %= p;\n }\n }\n \n cout << (dp[n][1] + dp[n][2] + dp[n][3])%p << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "41397e2e5d8cfc57f4597a7a7fb07fee", "src_uid": "c03b6379e9d186874ac3d97c6968fbd0", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "# include \n# include \n# include \n# include \n# include \nusing namespace std;\n\nchar s1[1000],s2[1000];\n\nint dp[500][210][210];\n\nstruct Node{\n\tint pi,pj,pk;\n\tchar c;\n}ans[500][210][210];\n\nconst int inf = 1e9;\n\nvoid dfs(int k,int i,int j)\n{\n\t// cout<dp[k][i][j]+1)\n\t\t\t\t{\n\t\t\t\t\tans[k+1][li][lj].pi = i;\n\t\t\t\t\tans[k+1][li][lj].pj = j;\n\t\t\t\t\tans[k+1][li][lj].pk = k;\n\t\t\t\t\tans[k+1][li][lj].c = '(';\n\t\t\t\t\tdp[k+1][li][lj] = dp[k][i][j]+1;\n\t\t\t\t}\n\t\t\t\tli = i+((s1[i]==')')?1:0);\n\t\t\t\tlj = j+((s2[j]==')')?1:0);\n\t\t\t\tif (k>0 && dp[k-1][li][lj]>dp[k][i][j]+1)\n\t\t\t\t{\n\t\t\t\t\tans[k-1][li][lj].pi = i;\n\t\t\t\t\tans[k-1][li][lj].pj = j;\n\t\t\t\t\tans[k-1][li][lj].pk = k;\n\t\t\t\t\tans[k-1][li][lj].c = ')';\n\t\t\t\t\tdp[k-1][li][lj] = dp[k][i][j]+1;\n\t\t\t\t}\n\t\t\t}\n\tint an = dp[0][len1][len2],ph = 0;\n\tfor (int i=0;i<=400;i++)\n\t{\n\t\tif (dp[i][len1][len2]+i\nusing namespace std;\nconst int N=1e6+7,M=20; bool fl[N],rev[N],tg;\nint n,k,va,vb,opt,tot,q[N],w[N],h[N],dp[N],gt[N],ft[N],fa[N],st[N],col[N],dep[N],cnt[N],e[N][M]; vectorv[N],vw[N]; vector>f[N];\nstruct edge {int u,t;}g[N];\ninline int read(){\n\tint num=0; char g=getchar(); while(g<48||57=0;i--) if((1<=0;i--) if(e[u][i]!=e[t][i]) u=e[u][i],t=e[t][i]; return fa[u];\n}\ninline int jmp(int u,int t){\n\tfor(int i=19;i>=0;i--) if((1<=1;s--){\n\t\tint u=st[s],opt=1; ft[1]=fa[u]; int suma=0,sumb=0;\n//\t\tcout<d&&max(vc,sumb)+max(vd,suma)+1>d) return false;\n\t\tdp[u]=1919810;\n//\t\tcout<=1;s--){\n\t\tint u=st[s],opt=1; ft[1]=0; int suma=0,sumb=0;\n\t\tfor(int i=0;i=va&&vb+dp[u]<=d) bfg(0);\n\t\t\t\telse if(dp[u]-1>=vb&&va+dp[u]<=d) bfg(1);\n\t\t\t\telse cout<<\"fail\"<0&&b>0) f[c].push_back(make_pair(a,b));\n\t}\n\tfor(int s=n;s>=1;s--){\n\t\tu=st[s],opt=1;\n\t\tfor(int i=0;i>1; if(check(d)) ans=d,r=d-1; else l=d+1;\n\t}\n\tcheck(ans),solve(ans);\n\tcout<\nusing namespace std;\nint main()\n{\n\tcout<<\"f(10) = MAGNA NIMIS!\"<\nusing namespace std;\ntypedef long long ll;\n\nstruct Enemy {\n int x, y, d, t, e;\n};\n\nvector> atpos[500][500];\nvector enemy;\n\nint w, h, n;\n\nll mem[500][500][500][2];\nll f(int x, int y, int xstreak, int ystreak) {\n if (x == w-1 && y == h-1) return 0;\n if (x >= w || y >= h) return 1e18;\n ll&memo = mem[y][x][xstreak+ystreak][!!xstreak];\n if (!memo) {\n ll ans = min(f(x+1,y,xstreak+1,0), f(x,y+1,0,ystreak+1));\n for (auto pi : atpos[y][x]) {\n Enemy&e = enemy[pi.first];\n int t0 = pi.second;\n if (x+y >= t0 && (x+y-t0)%4 == 0) {\n\tif (t0-e.t == 3 && e.d%4 == 3 && ystreak >= e.d) continue;\n\tif (t0-e.t == 2 && e.d%4 == 2 && xstreak >= e.d) continue;\n\tif (t0-e.t == 2 && e.d%4 == 1 && ystreak >= e.d) continue;\n\tans += e.e;\n }\n }\n memo = ans+1;\n }\n return memo-1;\n}\n\nint main() {\n ios::sync_with_stdio(0); cin.tie(0);\n cin >> w >> h >> n;\n\n for (int i = 0; i < n; i++) {\n int x, y, d, t, e;\n cin >> x >> y >> d >> t >> e;\n enemy.push_back({x,y,d,t,e});\n pair list[4] = {{x,y},{x+d,y-d},{x+d,y},{x,y+d}};\n for (auto p : list) {\n int nx,ny;\n tie(nx,ny) = p;\n atpos[ny][nx].push_back({i,t++});\n }\n }\n cout << f(0,0,0,0) << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7bcf4ce36aa72f339e22384d97f08f29", "src_uid": "b11cb0c2bf23bf4b4e6f6af61af9c290", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \r\nusing namespace std;\r\nconst int M=998244353,B=720720;\r\nint g[B], ng[B];\r\nlong long result;\r\nlong long s;\r\nint n,a,x,y,k,MOD;\r\n\r\nint main () {\r\n cin>>n>>a>>x>>y>>k>>MOD;\r\n\tfor(int i=0;i<(1<>j)&1) sum++;\r\n\t\t\telse mul = (1ll*mul*(n-1))%M;\r\n\t\t}\r\n\t\ts = (s+sum*mul)%M;\r\n\t}\r\n\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define MOD 1000000007\n#pragma warning(disable:4996)\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\n\nll n[3];\n\npii a[3][200005];\nvector edge[3][200005];\n\nll par[3][200005][20];\nll depth[3][200005];\n\nll down[3][200005];\nll up[3][200005];\nll down2[3][200005];\nll up2[3][200005];\nll d2[3][200005];\nll md2[3];\nll down3[3][200005][2];\nll up3[3][200005];\nll real[3][200005];\nll inhab[3];\n\nll cdown(ll z, ll now, ll parent)\n{\n ll i;\n ll sum=0;\n for(i=0;i=0;i--)\n {\n if(chai&(1<=0;i--)\n {\n if(par[z][x][i] != par[z][y][i]) chai+=2*(1<=0;i--)\n {\n if(chai&(1<\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntemplate struct Point\n{\n\tT x, y; Point(){} Point(T xx, T yy): x(xx), y(yy){}\n};\ntemplate bool operator <(const Point &p1, const Point &p2)\n{\n\treturn p1.x < p2.x || p1.x == p2.x && p1.y < p2.y;\n}\ntemplate Point operator -(const Point &p1, const Point &p2)\n{\n\treturn Point(p1.x - p2.x, p1.y - p2.y);\n}\ntemplate T operator ^(const Point &p1, const Point &p2)\n{\n\treturn p1.x*p2.y - p2.x*p1.y;\n}\n\n#define mp make_pair\n#define pb push_back\n#define forn(i, n) for(int (i)=0; (i) vint;\ntypedef Point pint;\n\nconst int MAXN = 32768;\nconst char LESS = '<', MORE = '>', EQUAL = '=';\nconst char TN = 'N', TF = 'f', TI = 'I', TE = 'E', TS = 'S';\nconst int PLUS = 10000001;\nconst int MINUS = 10000002;\nconst int MUL = 10000003;\nconst int DIV = 10000004;\n\nvector values;\n\nvoid execute(int n);\n\n\nstruct Aryfm\n{\n\tchar Type;\n\tint num;\n\tvector v;\n\t\n\tAryfm()\n\t{\n\t\t\n\t}\n\tAryfm(string s, char type = TE)\n\t{\n\t\tstring ts;\n\t\tType = type;\n\t\tforn(i, s.size())\n\t\t{\n\t\t\tAryfm a;\n\t\t\tif (s[i] == 'f')\n\t\t\t{\n\t\t\t\tint si = i+2;\n\t\t\t\tfor(; s[i]!=')'; i++) ;\n\t\t\t\ta = Aryfm(s.substr(si, i-si), TF);\n\t\t\t}\n\t\t\telse if (s[i] == 'n')\n\t\t\t{\n\t\t\t\ta.Type = TN;\n\t\t\t}\n\t\t\telse if (isdigit(s[i]))\n\t\t\t{\n\t\t\t\tts = \"\";\n\t\t\t\tfor(;i c;\n\t\tforn(i, v.size())\n\t\t{\n\t\t\tc.push_back(v[i].Calc(n));\t\n\t\t}\t\n\t\tforn(i,c.size())\n\t\t{\n\t\t\tif (c[i] == MUL)\n\t\t\t{\n\t\t\t\tc[i-1] = (c[i-1]*c[i+1])%MAXN;\n\t\t\t\tc.erase(c.begin()+i);\n\t\t\t\tc.erase(c.begin()+i);\n\t\t\t\ti--;\n\t\t\t}\n\t\t\telse if (c[i] == DIV)\n\t\t\t{\n\t\t\t\tc[i-1] = (c[i-1]/c[i+1])%MAXN;\n\t\t\t\tc.erase(c.begin()+i);\n\t\t\t\tc.erase(c.begin()+i);\n\t\t\t\ti--;\n\t\t\t}\n\t\t}\t\t\n\t\tforn(i,c.size())\n\t\t{\n\t\t\tif (c[i] == PLUS)\n\t\t\t{\n\t\t\t\tc[i-1] = (c[i-1]+c[i+1])%MAXN;\n\t\t\t\tc.erase(c.begin()+i);\n\t\t\t\tc.erase(c.begin()+i);\n\t\t\t\ti--;\n\t\t\t}\n\t\t\telse if (c[i] == MINUS)\n\t\t\t{\n\t\t\t\tc[i-1] = (c[i-1]-c[i+1])%MAXN;\n\t\t\t\tc.erase(c.begin()+i);\n\t\t\t\tc.erase(c.begin()+i);\n\t\t\t\ti--;\n\t\t\t}\n\t\t}\n\t\t\n\t\tint res = c[0];\n\t\tif (Type == TF)\n\t\t{\n\t\t\texecute(res);\n\t\t\tres = values[res];\n\t\t}\n\t\treturn res;\n\t}\n};\n\nstruct Cond\n{\n\tchar cond;\n\tAryfm l, r, ret;\n};\n\nvector f;\n\nvoid execute(int n)\n{\n\tif (values[n]!=-1)\n\t\treturn;\n\n\tforn(i, f.size())\n\t{\n\t\tint l = f[i].l.Calc(n);\n\t\tint r = f[i].r.Calc(n);\n\t\tif (f[i].cond == MORE && l>r || \n\t\t\tf[i].cond == LESS && l') c.cond = MORE;\n\t\tif (s[i] == '=') i++;\n\t\t\n\t\tts = \"\";\n\t\tsi = ++i;\n\t\tfor(;s[i]!='#'; i++) ts+=s[i];\n\t\tts.pop_back();\n\t\tc.r = Aryfm(ts);\n\n\t\tts = \"\";\n\t\tsi = ++i;\t\t\n\t\tfor(;i> fn;\n\tts = \"\";\n\twhile(getline(cin, s))\n\t{\n\t\tts+=\" \"+s;\n\t}\n\tParse();\n\n\tforn(i, MAXN)\n\t{\n\t\texecute(i);\n\t}\n\tfor(int i = values.size()-1; i>=0; i--)\n\t{\n\t\tif (values[i] == fn)\n\t\t{\n\t\t\tcout << i;\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout << -1;\n\n\treturn 0;\n}\n/*\n\n\n\n\n\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8b7582377a6f5c183ca9cb1d0a50bb3b", "src_uid": "698c5a87f9adbe6af60d9f70519c9672", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\nint p,n;\r\n__int128 x,y,mo;\r\nstring s;\r\nmap<__int128,int>mp;\r\n__int128 mul(__int128 x,__int128 y)\r\n{\r\n\t__int128 ans=0;\r\n\tfor (int i=0;i>i&1) ans^=x<=n-1;i--) if (ans>>i&1) ans^=mo<<(i-n+1);\r\n\treturn ans; \r\n}\r\nint main()\r\n{\r\n\tios::sync_with_stdio(false);\r\n\tcin.tie(0),cout.tie(0);\r\n\tcin>>s;\r\n\twhile (!s.empty() && s[0]=='0') s.erase(s.begin()),p++;\r\n\tp++;\r\n\tif (s.empty()) \r\n\t{\r\n\t\tcout<<-1;\r\n\t\treturn 0;\r\n\t}\r\n\twhile (s.back()=='0') s.pop_back();\r\n\tn=s.size();\r\n\tfor (int i=0;i\r\nusing namespace std; \r\n\r\nconst int mod = 998244353;\r\n\r\nint mul(int a, int b) {\r\n\treturn (1LL * a * b) % mod; \r\n}\r\n\r\nint pw(int a, int b) {\r\n\tif (b == 0) return 1; \r\n\tif (b & 1) return mul(a, pw(a, b - 1)); \r\n\tint res = pw(a, b / 2); \r\n\treturn mul(res, res); \r\n}\r\n\r\nint sub(int a, int b) {\r\n\tint s = a - b; \r\n\tif (s < 0) s += mod; \r\n\treturn s; \r\n}\r\n\r\nint add(int a, int b) {\r\n\tint s = a + b; \r\n\tif (s >= mod) s -= mod; \r\n\treturn s; \r\n}\r\n\r\nvoid fft(vector& a, bool inv) {\r\n\tint n = (int)a.size(); \r\n\tfor (int i = 1, j = 0; i < n; i++) {\r\n\t\tint bit = n >> 1; \r\n\t\tfor (; j >= bit; bit >>= 1) j -= bit; \r\n\t\tj += bit; \r\n\t\tif (i < j) swap(a[i], a[j]); \r\n\t}\r\n\tfor (int len = 2; len <= n; len <<= 1) {\r\n\t\tint wlen = inv ? 208611436 : 646; \r\n\t\tfor (int i = len; i < (1 << 20); i <<= 1) wlen = int(wlen * 1ll * wlen % mod); \r\n\t\tfor (int i = 0; i < n; i += len) {\r\n\t\t\tint w = 1; \r\n\t\t\tfor (int j = 0; j < len / 2; j++) {\r\n\t\t\t\tint u = a[i + j], v = int(a[i + j + len / 2] * 1ll * w % mod); \r\n\t\t\t\ta[i + j] = u + v < mod ? u + v : u + v - mod; \r\n\t\t\t\ta[i + j + len / 2] = u - v >= 0 ? u - v : u - v + mod; \r\n\t\t\t\tw = int(w * 1ll * wlen % mod); \r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (inv) {\r\n\t\tint nrev = pw(n, mod - 2); \r\n\t\tfor (int i = 0; i < n; i++) a[i] = int(a[i] * 1ll * nrev % mod); \r\n\t}\r\n}\r\n\r\nvoid polysq(vector& a) {\r\n\tint s = 2 * a.size(); \r\n\tint r = 1; \r\n\twhile (r < s) r *= 2; \r\n\ta.resize(r); \r\n\tfft(a, false); \r\n\tfor (int i = 0; i < r; i++) a[i] = mul(a[i], a[i]); \r\n\tfft(a, true); \r\n\twhile (!a.empty() && (a.back() == 0)) a.pop_back(); \r\n}\r\n\r\nint main() {\r\n\tios_base::sync_with_stdio(false);\r\n\tcin.tie(nullptr); \r\n\tint n, k, f; \r\n\tcin >> n >> k >> f; \r\n\tvector dp(k + 1, 1); \r\n\tfor (int i = 1; i < n; i++) {\r\n\t\tpolysq(dp); \r\n\t\tdp.resize(2 * k + 1); \r\n\t\tvector ndp(k + 1); \r\n\t\tint alls = 0; \r\n\t\tfor (auto v : dp) alls = add(alls, v);\r\n\t\tint cur = 0; \r\n\t\tfor (int j = 0; j <= k; j++) {\r\n\t\t\tcur = add(cur, dp[j]); \r\n\t\t\tndp[j] = nul(k - j + 1, dp[j]); \r\n\t\t\tndp[j] = sum(ndp[j], sub(alls, cur)); \r\n\t\t}\r\n\t\tdp = ndp; \r\n\t}\r\n\tpolysq(dp); \r\n\tif (f >= (int)dp.size()) cout << 0 << '\\n'; \r\n\telse cout << dp[f] << '\\n'; \r\n\treturn 0; \r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b4921238da0e0518e24cde311188d1bb", "src_uid": "4b8161259545e44c7d1046be2e4fe014", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include\n\n#define pb push_back\n#define mp make_pair\n#define fi first\n#define se second\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pll;\n\ntemplate bool chkmax(T &x,T y){return x bool chkmin(T &x,T y){return x>y?x=y,true:false;}\n\nll readint(){\n\tll x=0,f=1; char ch=getchar();\n\twhile(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}\n\twhile(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}\n\treturn x*f;\n}\n\nint n,d,m; ll l,r;\nll pw[105],a[30],dp[2][60][60][2],bs[60];\n\nll shift(ll x,int t){return (x>>t)|((x&((1ll< b,ll dep,ll now){\n\tif(now>r) return 0;\n\tll res=0;\n\tif(b.size()==1){\n\t\tfor(int i=0;i nb(0);\n\t\tint tmp=i; ll mask=(1ll<=1;i--)\n\t\tfor(int j=0;j b(0);\n\tfor(int i=1;i<=n;i++) b.push_back((1ll<<(readint()+1))-1);\n\tl=readint()-2; r=readint()-n;\n\tgetdp(r,0); getdp(l,1);\n\tprintf(\"%lld\\n\",getans(b,0,0));\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "49de97237084d1b294c08bcde1d1a0ae", "src_uid": "49eb534fb5cf4634c770f00e22528e19", "difficulty": 3400.0} {"lang": "GNU C++", "source_code": "\n\n\t\n\t\n\t\t\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1647b9aa21c23302741c3f2f31ee05ad", "src_uid": "be82b8f209217875221ebe5de8675971", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nmt19937 ran(time(0));\n\nll mod = 1000012121;\nll inf = 2e18;\n\nint n, m;\nint k;\nvectorp;\nvector>g;\nvectordist;\nvectorused;\nqueue>q;\nvectorhow;\n\nint main(){\n\tcin.tie(0);\n\tcout.tie(0);\n\tios_base::sync_with_stdio(0);\n\tcin>>n>>m;\n\tg.resize(n);\n\tcnt.resize(n);\n\tused.resize(n, false);\n\tint u, v;\n\tdist.resize(n, -1);\n\thow.resize(n);\n\tfor(int i = 0; i < m ;i++){\n\t\tcin>>u>>v;\n\t\tu--;\n\t\tv--;\n\t\tg[v].push_back(u);\n\t}\n\tcin>>k;\n\tp.resize(k);\n\tfor(int i = 0; i < k; i++){\n\t\tcin>>p[i];\n\t\tp[i]--;\n\t}\n\tq.push(make_pair(p[k-1], 0));\n\tused[p[k-1]] = cnt[p[k-1]] = 1;\n\tint cur, d;\n\tdist[p[k-1]] = 0;\n\twhile(!q.empty()){\n\t\tcur = q.front().first;\n\t\td = q.front().second;\n\t\tq.pop();\n\t\tfor(int i = 0; i < g[cur].size(); i++){\n\t\t\tv = g[cur][i];\n\t\t\tif(!used[v] || dist[v] == d + 1){\n\t\t\t\thow[v]++;\n\t\t\t}\n\t\t\tif(!used[v]){\n\t\t\t\tused[v] = true;\n\t\t\t\tdist[v] = d + 1;\n\t\t\t\tq.push(make_pair(v, d + 1));\n\t\t\t}\n\t\t}\n\t}\n\tll ma = 0, mi = 0;\n\thow[p[k-1]] = 1;\n\tfor(int i = 1; i < k; i++){\n\t\tif(dist[p[i]] == dist[p[i-1]]){\n\t\t\tmi++;\n\t\t\tma++;\n\t\t}\n\t\telse if (dist[p[i]] < dist[p[i-1]] && how[p[i-1]] > 1){\n\t\t\tma++;\n\t\t}\n\t\telse if (dist[p[i]] > dist[p[i-1]] && 1 < how[p[i]]){\n\t\t\tma++;\n\t\t}\n\t}\n\tcout<nul\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "310817969056a0134d57261fd0cb10e9", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\n#if __cplusplus >= 201103L\n#include \n#include \n#include \n#include \n#include \n#include \n#endif\nusing namespace std;\n\ntypedef long long int64;\nconst int inf = 2000000000;\nstatic inline int Rint()\n{\n\tstruct X{ int dig[256]; X(){\n\tfor(int i = '0'; i <= '9'; ++i) dig[i] = 1; dig['-'] = 1;\n\t}};\n\tstatic \tX fuck;int s = 1, v = 0, c;\n\tfor (;!fuck.dig[c = getchar()];);\n\tif (c == '-') s = 0; else if (fuck.dig[c]) v = c ^ 48;\n\tfor (;fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48));\n\treturn s ? v : -v;\n}\ntypedef vector vi;\ntypedef map mii;\ntypedef set si;\n\n#define all(x) (x).begin(), (x).end()\n#define pb push_back\n#define mp make_pair\n#define sz(x) ((int)(x).size())\n#define rep(i, s, e) for (int i = (s); i < (e); ++i)\n\n#if __cplusplus >= 201103L\n#define foreach(iter, c) for(auto& iter : c)\n#else\n#define foreach(itr, c) for(__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); ++itr)\n#endif\n\ntemplate static inline void cmax(T& a, const T& b){if(b>a)a=b;}\ntemplate static inline void cmin(T& a, const T& b){if(b o.p;\n\t\treturn id < o.id;\n\t}\n};\n\nvoid fix(priority_queue& pq)\n{\n\tset > st;\n\t\n\tfor (int i = 0; i < k; ++i)\n\tif (D[i] != -1)\n\tst.insert({D[i], i});\n\t\n\twhile (!st.empty())\n\t{\n\t\tauto where = st.begin();\n\t\tauto curr = *where;\n\t\tst.erase(where);\n\t\tif (D[curr.second] != curr.first) continue;\n\t\tfor (int i = top-1; i < top; ++i)\n\t\t{\n\t\t\tint64 val = curr.first;\n\t\t\tfor (int coe = 1; coe < k; ++coe)\n\t\t\t{\n\t\t\t\tval += allk[i];\n\t\t\t\tif (val > h) break;\n\t\t\t\t\n\t\t\t\tint next = val % k;\n\t\t\t\t\n\t\t\t\tif (next == curr.second)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (D[next] == -1)\n\t\t\t\t{\n\t\t\t\t\tD[next] = val;\n\t\t\t\t\tst.insert({D[next], next});\n\t\t\t\t}\n\t\t\t\telse if (D[next] > val)\n\t\t\t\t{\n\t\t\t\t\tD[next] = val;\n\t\t\t\t\tst.insert({D[next], next});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfor (int i = 1; i <= n; ++i) if (flag[i] == 0)\n\t{\n\t\tconst int bucket = pos[i] % k;\n\t\tif (D[bucket] != -1)\n\t\t{\n\t\t\tif (pos[i] >= D[bucket])\n\t\t\t{\n\t\t\t\tpq.push({treasure[i], pos[i], i});\n\t\t\t\tflag[i] = 1;\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main()\n{\n\tscanf(\"%I64d\", &h);\n\tn = Rint(), m = Rint(), k = Rint();\n\t\n\tfor (int i = 1; i <= n; ++i)\n\tscanf(\"%I64d %d\", pos+i, treasure+i);\n\t\n\tmemset(D, -1, sizeof D);\n\tD[1%k] = 1;\n\t\n\tpriority_queue pq;\n\t\n\tfor (int i = 1; i <= n; ++i)\n\t{\n\t\tconst int bucket = pos[i] % k;\n\t\tif (D[bucket] != -1)\n\t\t{\n\t\t\tif (pos[i] >= D[bucket])\n\t\t\t{\n\t\t\t\tpq.push({treasure[i], pos[i], i});\n\t\t\t\tflag[i] = 1;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfor (int id = 0; id < m; ++id)\n\t{\n\t\tconst int cmd = Rint();\n\t\tif (cmd == 3)\n\t\t{\n\t\t\twhile (!pq.empty())\n\t\t\t{\n\t\t\t\tauto curr = pq.top();\n\t\t\t\tif (treasure[curr.id] != curr.t)\n\t\t\t\t{\n\t\t\t\t\tpq.pop();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tint64 ans = 0;\n\t\t\tif (!pq.empty())\n\t\t\t{\n\t\t\t\tans = pq.top().t;\n\t\t\t\ttreasure[pq.top().id] = -1;\n\t\t\t\t//dbg(pq.top().id);\n\t\t\t\t//dbg(pq.top().p);\n\t\t\t\tpq.pop();\n\t\t\t}\n\t\t\tprintf(\"%I64d\\n\", ans);\n\t\t}\n\t\telse if (cmd == 2)\n\t\t{\n\t\t\tconst int x = Rint();\n\t\t\tconst int c = Rint();\n\t\t\ttreasure[x] -= c;\n\t\t\tif (c != 0 && flag[x])\n\t\t\t{\n\t\t\t\tpq.push({treasure[x], pos[x], x});\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint64 x; scanf(\"%I64d\", &x);\n\t\t\tint ok = 1;\n\t\t\t//for (int i = 0; i < top; ++i)\n\t\t\t//if (x % allk[i] == 0) ok = 0;\n\t\t\t//if (x % k == 0) ok = 0;\n\t\t\tif (ok)\n\t\t\t{\n\t\t\t\tallk[top++] = x;\n\t\t\t\tfix(pq);\n\t\t\t\t#if 0\n\t\t\t\tfor (int i = 1; i <= n; ++i)\n\t\t\t\tif (flag[i])\n\t\t\t\tcerr << pos[i] << \" \" << treasure[i] << endl;\n\t\t\t\tcerr << endl;\n\t\t\t\t\n\t\t\t\tfor (int i = 0; i < k; ++i)\n\t\t\t\tcerr << i << \" \" << D[i] << endl;\n\t\t\t\tcerr << endl;\n\t\t\t\t#endif\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "47497fcd8c10d26a2e784f676394b719", "src_uid": "03c4df4f640633f3364ca9225588caf7", "difficulty": 2500.0} {"lang": "MS C++ 2017", "source_code": "#include\r\n#include\r\n#include\r\n#define ll long long\r\nusing namespace std;\r\nconst ll MOD=1e9+7;\r\nll xx,yy,x,y,rr,cc,n,m,k,c,r,xa,ya,xb,yb,p,ans;\r\nll posw(ll x){\r\n\tll tt=1,t=k;\r\n\twhile(x){\r\n\t\tif(x&1)tt=tt*t%MOD;\r\n\t\tx>>=1;\r\n\t\tt=t*t%MOD;\r\n\t//\tcout<=xb&&ya>=yb){\r\n\tswap(xa,xb);swap(ya,yb);\t\r\n\t}\r\n\tif(xa==xb&&ya==yb){\r\n\t\tcout<xa+r-1||yb>ya+c-1){\r\n\t\tans=posw(n*m-r*c);\r\n\t}\r\n\telse{\r\n\t\txx=abs(xa-xb);yy=abs(ya-yb);\r\n\t\tx=sz(r,xx)-1;y=sz(c,yy)-1;\r\n\t\tp=min(x,y);\r\n\t\trr=r-p*xx;cc=c-p*yy;\r\n\t\tans=2*(p-1)*xx*yy-rr*cc+(r-(p-1)*xx)*(c-(p-1)*yy);\r\n\t//\tcout<\n#include\nusing namespace std;\ntypedef long long LL;\nLL f[55][2][2],K;int a[55],n;\n#define cl(f) memset(f,-1,sizeof f)\n#define F (f[l][rev][inv])\nLL calc(int l,int r,int e1,int e2){\n if (l>r)return 1;if(~F)return F;F=0;\n for(int i=0;i<2;++i)for(int j=0;j<2;++j)if(a[l]!=(!i)&&a[r]!=(!j)&&(l\n#include \n#include \n\nbool primo(int n) {\n if (n == 2)\n return true;\n \n for (int i = 2; i < n / 2; ++i)\n if (n % i == 0)\n return false;\n return true;\n}\n\nint reversa(int n) {\n std::string str = std::to_string(n);\n std::reverse(str.begin(), str.end());\n return atoi(str.c_str());\n}\n\nint main() {\n int n;\n scanf(\"%d\", &n);\n \n int k = 0;\n int i = 0;\n while (true) {\n if (primo(i)) {\n int rev = reversa(i);\n if (rev != i) {\n if (primo(rev)) {\n ++k;\n if (k == n) {\n printf(\"%d\", i);\n break;\n }\n }\n }\n }\n ++i;\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f114750b2a94e4658a44ae65a8da7aa5", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#define N 1510\nusing namespace std;\ntypedef long long LL;\n\nstruct Node {\n LL to, nxt;\n}e[N << 1];\n\nstruct Point {\n LL x, y, id;\n}p[N], pp[N], poi;\n\nLL cnt, n, lst[N], ans[N], size[N];\n\nbool cmp(Point a, Point b) {//\u6309\u6781\u89d2\u6392\u5e8f\n LL ax = a.x - poi.x, ay = a.y - poi.y, bx = b.x - poi.x, by = b.y - poi.y;\n if (ax >= 0 && bx <= 0) return 1;\n if (ax <= 0 && bx >= 0) return 0;\n return (ax * by > bx * ay);\n}\n\ninline void add(LL u, LL v) {\n e[++cnt].to = v;\n e[cnt].nxt = lst[u];\n lst[u] = cnt;\n}\n\nvoid predfs(LL x, LL fa) {//\u9884\u5904\u7406\u51fa\u5b50\u6811\u5927\u5c0f\n size[x] = 1;\n for (int i = lst[x]; i; i = e[i].nxt) {\n if (e[i].to == fa) continue;\n predfs(e[i].to, x);\n size[x] += size[e[i].to];\n }\n}\n\nvoid dfs(LL l, LL r, LL x, LL fa)//\u5bf9\u533a\u95f4\u8fdb\u884c\u5206\u6cbb\n LL mini = l;\n for (int i = l + 1; i <= r; ++i)\n if (p[i].y < p[mini].y || p[i].y == p[mini].y && p[i].x < p[mini].x) mini = i;\n swap(p[l], p[mini]);\n ans[p[l].id] = x;\n poi = p[l];\n sort(p + l + 1, p + r + 1, cmp);\n LL now = l + 1;\n for (LL i = lst[x]; i; i = e[i].nxt) {\n if (e[i].to == fa) continue;\n dfs(now, now + size[e[i].to] - 1, e[i].to, x);\n now += size[e[i].to];\n }\n}\n\nint main() {\n scanf(\"%lld\", &n);\n for (LL i = 1; i < n; ++i) {\n LL a, b;\n scanf(\"%lld%lld\", &a, &b);\n add(a, b);\n add(b, a);\n }\n for (LL i = 1; i <= n; ++i) {\n scanf(\"%lld%lld\", &p[i].x, &p[i].y);\n p[i].id = i;\n }\n predfs(1, 1);\n dfs(1, n, 1, 1);\n for (LL i = 1; i < n; ++i) {\n printf(\"%lld \", ans[i]);\n }\n printf(\"%lld\\n\", ans[n]);\n return 0;\n}//", "lang_cluster": "C++", "compilation_error": true, "code_uid": "17bebe1ded4fd3b76b5617fe9d8b520c", "src_uid": "d65e91dc274c6659cfdb50bc8b8020ba", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define pb push_back\n#define rep(i,j,k) for(int i=(j);i<=(int)k;i++)\n#define per(i,j,k) for(int i=(j);i>=(int)k;i--)\n#define lowbit(x) ((x)&(-(x)))\n#define fi first\n#define se second\n#define pii pair\nusing namespace std;\ntypedef long long LL;\ntypedef double db;\nmapfuck;\nint n,m;\nchar s[5];\nint x,y;\nLL ans;\nint dx,dy;\nint main()\n{ scanf(\"%d%d\",&n,&m);\n scanf(\"%d%d\",&x,&y);\n scanf(\"%s\",s+1);\n if(s[1]=='U')dx=-1; else dx=1;\n if(s[2]=='L')dy=-1; else dy=1;\n int fis=0;\n int test=1000000;\n while(test--)\n { pii now=pii(x,y);\n if(!fuck[now])\n { fuck[now]=1;\n fis++;\n }\n if(fis==n+m-2)\n { printf(\"%I64d\",ans+1);\n return 0;\n }\n int xl,yl,l;\n int ex,ey;\n if(dx==-1)xl=x-1; else xl=n-x;\n if(dy==-1)yl=y-1; else yl=m-y;\n if(xlyl) { ey=-dy; ex=dx; l=yl;}\n else { ex=-dx; ey=-dy; l=yl;}\n }\n\t\tx+=dx*l;y+=dy*l;\n ans+=1ll*l;\n dx=ex;dy=ey;\n }\n printf(\"-1\\n\");\n return 0;\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fce7d404b527b46531f456024455d381", "src_uid": "8a59247013a9b1f34700f4bfc7d1831d", "difficulty": 2500.0} {"lang": "GNU C++0x", "source_code": "#include \n#define L first\n#define R second\n#define MP make_pair\n#define PB push_back\n\nusing namespace std;\n\nlong long n, m, k;\nvector, long long> > E;\nlong long d[2][20];\n\nbool chk(long long mask) {\n\tmemset(d, 0, sizeof d);\n\tfor(long long i = 0;i < E.size();i ++)\n\t\tif(mask & (1< 1 || d[1][i] > 1)\n\t\t\treturn false;\n\treturn true;\n}\n\nlong long ans(long long mask) {\n\tlong long ret = 0;\n\tfor(long long i = 0;i < E.size();i ++)\n\t\tif(mask & (1<> n >> m >> k;\n\tlong long fi, se, w;\n\tfor(long long i = 0;i < m;i ++)\n\t\tcin >> fi >> se >> w, E.PB(MP(MP(fi, se), w));\n\tvector Q(0);\n\tfor(long long mask = 0;mask < (1<\n#define M 1048576 * 4\n\nusing namespace std;\n\ntypedef unsigned long long ull;\ntypedef long long ll;\n\nll powmod(ll x, ll y, ll p) {\n\tll ans = 1;\n\twhile(y) {\n\t\tif(y & 1) ans = ans * x % p;\n\t\tx = x * x % p;\n\t\ty >>= 1;\n\t}\n\treturn ans;\n}\n\nll F[200010], Fac[200010], Rev[200010], rev[M], r[200010];\n\nint V[200010], st = 0;\n\nvector C[22], rC[22];\n\nll P, g;\n\null X[M], Y[M];\n\nbool npr[50000010];\n\nvoid DFT(ull *X, int t) {\n\tfor(int i = 0; i < t; i++)\n\t\tfor(int j = 0; j < (1 << t); j += (1 << i + 1))\n\t\t\tfor(int k = 0; k < (1 << i); k++) {\n\t\t\t\tll A = X[j + k], B = X[j + k + (1 << i)] * C[i + 1][k] % P;\n\t\t\t\tX[j + k] = A + B;\n\t\t\t\tX[j + k + (1 << i)] = A - B + P;\n\t\t\t}\n\tfor(int i = 0; i < (1 << t); i++) X[i] %= P;\n}\n\nvoid pr(int o) {\n\tfor(int i = 1; i <= o; i++) {\n\t\tC[i].resize(1 << i), C[i][0] = 1;\n\t\tll w = powmod(g, (P - 1) >> i, P);\n\t\tfor(int j = 1; j < (1 << i); j++) C[i][j] = C[i][j - 1] * w % P;\n\t\trC[i] = C[i];\n\t\treverse(rC[i].begin() + 1, rC[i].end());\n\t}\n}\n\nll getori() {\n\tfor(int g = 2; ; g++) {\n\t\tassert(powmod(g, P - 1, P) == 1);\n\t\tint flag = 0;\n\t\tfor(int i = 2; i * i <= P - 1; i++) if((P - 1) % i == 0) {\n\t\t\tif(powmod(g, i, P) == 1 || powmod(g, (P - 1) / i, P) == 1) {flag = 1; break;}\n\t\t}\n\t\tif(!flag) return g;\n\t}\n}\n\nint n, m;\n\nchar ch1[M], ch2[M];\n\nint XX[22][1058571];\n\nint main() {\n\tscanf(\"%d%d\", &n, &m);\n\tscanf(\"%s\", ch1 + 1);\n\tscanf(\"%s\", ch2 + 1);\n\tfor(int o = 0; o < 22; o++)\n\t\tfor(int i = 1; i <= n; i++) XX[o][(i - 1) & ((1 << o) - 1)] = ((int) XX[o][(i - 1) & ((1 << o) - 1)] + (ch1[i] - ch2[i]));\n\tfor(int i = 2; i <= 100000; i++) if(!npr[i])\n\t\tfor(int j = i + i; j < 50000000; j += i) npr[j] = 1;\n\tfor(P = m; ; P++) if(!npr[P]) {\n\t\tll tmp = P - 1;\n\t\tint o = 0, s = tmp & -tmp;\n\t\twhile((1 << o) != s) o++; \n\t\tif((1 << o) <= P / 400) continue;\n\t\to = min(o, 20);\n\t\t// Do 2^22\n\t\tg = getori();\n\t\tpr(o);\n\t\tfor(int i = 0; i < (1 << o); i++) X[i] = (XX[o][i] % P + P) % P; \n\t\tfor(int i = 1; i < (1 << o); i++) rev[i] = rev[i / 2] / 2 + (i & 1) * (1 << o - 1);\n\t\tfor(int i = 0; i < (1 << o); i++) if(rev[i] > i) swap(X[i], X[rev[i]]);\n\t\tDFT(X, o);\n\t\ttmp = 1;\n\t\ts = powmod(g, (P - 1) >> o, P);\n\t\tfor(int i = 0; i < (1 << o); i++) {\n\t\t\tif(tmp != 1 && tmp != P - 1 && X[i] % P == 0) {\n\t\t\t\tprintf(\"%lld %lld\\n\", P, tmp);\n\t\t\t\treturn 0;\n\t\t\t\t/*ll qwq = 0;\n\t\t\t\tfor(int j = n - 1; j >= 0; j--) qwq = (qwq * tmp + S[j]) % P;\n\t\t\t\tassert(qwq % P == 0);\n\t\t\t\treturn 0;*/\n\t\t\t}\n\t\t\ttmp = tmp * s % P;\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d5d6efa33af3fc832c8fb1033cf59ee3", "src_uid": "8f7ca2115158b946ff53e45f035182e6", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#define endl \"\\n\"\n#define FOR(x, y, z) for (int x = (y); x < (z); ++x)\n#define FORR(x, y, z) for (int x = (y); x > (z); --x)\n#define GET(a, n) for (int i = 0; i < (n); ++i) cin >> a[i];\n#define GETM(a, n, m) for (int i = 0; i < (n); ++i) for (int j = 0; j < m; ++j) cin >> a[i][j];\n#define PRINTM(a, n, m) for (int i = 0; i < (n); ++i) { for (int j = 0; j < m; ++j) cout << a[i][j] << \" \"; cout << endl; };\n#define PRINT(a, n) for (int i = 0; i < (n); ++i) cout << a[i] << \" \";\n#define IT(a) a.begin(), a.end()\n#define CASE(a, s) cout << \"Case #\" << a << \": \" << s << endl;\n#define DEB(a) cout << #a << \" = \" << (a) << endl; cout.flush();\n#define DEBA(a) for (auto i: a) cout << i << \" \"; cout << endl;\n#define IFDEB(b, a) if (b) { cout << #a << \" = \" << a << endl; cout.flush(); }\nusing namespace std;\ntypedef long long LL;\ntypedef unsigned long long ULL;\ntypedef vector VI;\ntypedef vector > VVI;\ntypedef pair PII;\nconst int MOD = 1000000007;\ntemplate typename T::value_type arr_sum(const T& v, int n) { typename T::value_type sum = 0; FOR(i, 0, n) sum += v[i]; return sum; }\nstruct Sync_stdio { Sync_stdio() { cin.tie(NULL); ios_base::sync_with_stdio(false); } } _sync_stdio;\n\nvector v;\n\nint check(vector &start)\n{\n FOR (i, 0, start.size()) {\n if (start[i] != start[start[i]]) {\n return 0;\n }\n }\n return 1;\n}\n\nLL lcm(LL a, LL b)\n{\n return a * b / __gcd(a, b);\n}\n\nint main()\n{\n int n;\n cin >> n;\n v.resize(n);\n GET(v, n);\n for (auto &i: v) {\n --i;\n }\n vector start(n);\n FOR (i, 0, n) {\n start[i] = i;\n }\n vector a = start;\n vector cycle_first;\n FOR (j, 0, n) {\n FOR (i, 0, n) {\n start[i] = v[start[i]];\n }\n //if (check(start)) {\n //cout << j + 1 << endl;\n // goto A;\n //return 0;\n //}\n }\nA:\n vector stac(n);\n FOR (i, 0, n) {\n if (v[start[i]] == start[i]) {\n stac[i] = 1;\n }\n }\n vector cycle(n);\n FOR (i, 0, n) {\n int t = start[i];\n int c = 0;\n do {\n t = v[t];\n ++c;\n } while (t != start[i]);\n cycle[i] = c;\n }\n vector used(n);\n FOR (j, 0, n) {\n FOR (i, 0, n) {\n start[i] = v[start[i]];\n used[start[i]] = 1;\n }\n }\n FOR (i, 0, used.size()) {\n if (used[i] == 0) {\n cycle[i] = 0;\n }\n }\n FOR (i, 0, n) {\n start[i] = i;\n }\n vector predc(n, -1);\n FOR (j, 0, n + 2) {\n FOR (i, 0, n) {\n if (used[start[i]] && predc[i] == -1) {\n predc[i] = j;\n }\n start[i] = v[start[i]];\n }\n }\n //DEBA(cycle);\n //DEBA(used);\n //DEBA(predc);\n int maxpr = *max_element(IT(predc));\n int lcm1 = 1;\n FOR (i, 0, n) {\n if (cycle[i] != 0) {\n lcm1 = lcm(lcm1, cycle[i]);\n }\n }\n int lcm2 = lcm1;\n while (lcm2 < maxpr) {\n lcm2 += lcm1;\n }\n cout << lcm2;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7948a103ef53258dd3662689b46c7d3e", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \n \n#define pii pair\n#define endl \"\\n\"\n#define int long long\n#define F first\n#define S second\n#define B begin\n#define E end\n#define RB rbegin\n#define RE rend\n \ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n \nconst int INF = 1e9 + 1;\nconst double EPS = 1e-10;\nconst ll P = 2e9 + 9;\nconst ll Q = 47;\n \nusing namespace std;\n \nvoid hello()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n #ifdef LOCAL\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n #endif\n}\n \nvoid show(vector& arr)\n{\n for (auto i : arr)\n cout << i << \" \";\n cout << endl;\n}\nvoid show(vector>& arr)\n{\n for (auto i : arr)\n show(i);\n cout << endl;\n}\nvector sarr;\nvector order;\n\nvoid build_sarr(string& s)\n{\n int n = s.size() + 1;\n vector cls(n);\n for (int i = 0; i < n - 1; ++i)\n cls[i] = s[i] - 'a';\n cls.back() = -1;\n vector > tmp(n);\n\n for (int i = 1; i < n; i *= 2)\n {\n for (int j = 0; j < n; ++j)\n tmp[j] = {{cls[j], cls[(j + i) % n]}, j};\n stable_sort(tmp.B(), tmp.E());\n\n int last = 0;\n for (int j = 0; j < n; ++j)\n {\n if (j && tmp[j].F != tmp[j - 1].F)\n ++last;\n cls[tmp[j].S] = last;\n }\n }\n\n for (int i = 0; i < n - 1; ++i)\n sarr[cls[i] - 1] = i;\n}\n\nconst int MAXN = 8e5 + 1;\nint tree[MAXN];\n\n\nint nlcp;\n\n\nvoid build_lcp(int v, int l, int r, vector & data)\n{\n if (l == r)\n {\n tree[v] = data[l];\n return;\n }\n int m = (l + r) / 2;\n\n build_lcp(2 * v, l, m, data);\n build_lcp(2 * v + 1, m + 1, r, data);\n\n tree[v] = min(tree[2 * v], tree[2 * v + 1]);\n}\n\nint query(int v, int cl, int cr, int l, int r)\n{\n if (cl >= l && cr <= r)\n return tree[v];\n if (r < cl || cr < l)\n return INF;\n int cm = (cl + cr) / 2;\n return min(query(2 * v, cl, cm, l, r), query(2 * v + 1, cm + 1, cr, l, r));\n}\n\nint query_lcp(int l, int r)\n{\n if (l > r)\n return 0;\n if (order[r] < order[l])\n swap(l, r);\n return query(1, 0, nlcp - 1, min(order[l], order[r] - 1), max(order[l], order[r] - 1));\n}\n\nvoid divide(int l, int r, string& s, vector & tandem)\n{\n if (l > r)\n return;\n if (l == r)\n {\n tandem[l] = 0;\n return;\n }\n\n int m = (l + r) / 2;\n divide(l, m, s, tandem);\n divide(m + 1, r, s, tandem);\n}\n\nvoid build_tandem(string& s, vector& tandem)\n{\n fill(tandem.B(), tandem.E(), s.size());\n for (int i = 0; i < s.size(); ++i)\n {\n for (int j = i + 1; j < s.size(); ++j)\n if (query_lcp(i, j) >= j - i)\n {\n tandem[i] = j - i;\n break;\n }\n }\n}\n\nvoid build_rtandem(string& s, vector& tandem)\n{\n fill(tandem.B(), tandem.E(), s.size());\n for (int i = 0; i < s.size(); ++i)\n {\n for (int j = i + 1; j < s.size(); ++j)\n if (query_lcp(i, j) >= j - i)\n {\n tandem[j + j - i - 1] = min(tandem[j + j - i - 1], j - i);\n }\n }\n}\n\nsigned main()\n{\n hello();\n \n int n;\n string s;\n cin >> n >> s;\n \n sarr.resize(n);\n build_sarr(s);\n vector lcp(n, -1);\n order.resize(n);\n int last = 0;\n\n for (int i = 0; i < n; ++i)\n order[sarr[i]] = i;\n\n for (int i = 0; i < n; ++i)\n {\n if (last)\n --last;\n if (order[i] == n - 1)\n continue;\n int v = i, u = sarr[order[i] + 1];\n while (max(v, u) + last < n && s[v + last] == s[u + last])\n ++last;\n lcp[order[i]] = last;\n }\n\n lcp.pop_back();\n nlcp = lcp.size();\n build_lcp(1, 0, nlcp - 1, lcp);\n vector tandem(n), rtandem(n);\n build_tandem(s, tandem);\n build_rtandem(s, rtandem);\n\n vector left(n), right(n);\n int sz = 500;\n\n vector lst(26, -1);\n for (int i = 0; i < n; ++i)\n {\n right[i] = lst[s[i] - 'a'];\n lst[s[i] - 'a'] = i;\n }\n fill(lst.B(), lst.E(), n);\n for (int i = n - 1; i >= 0; --i)\n {\n left[i] = lst[s[i] - 'a'];\n lst[s[i] - 'a'] = i;\n }\n\n\n int q;\n cin >> q;\n // show(sarr);\n // show(lcp);\n // show(tandem);\n // show(rtandem);\n for (int v = 0; v < min(q, 300); ++v)\n {\n int l, r;\n cin >> l >> r;\n --l; --r;\n\n bool flag = 1;\n for (int i = l; i <= r; ++i)\n if (left[i] <= r)\n flag = 0;\n if (flag)\n {\n cout << -1 << endl;\n continue;\n }\n\n int len = r - l + 1;\n \n for (int val = 1; val * val <= len; ++val)\n {\n if (len % val)\n continue;\n if (query_lcp(l, l + val) == len - val)\n {\n flag = 1;\n }\n if (val == 1)\n continue;\n if (query_lcp(l, l + len / val) == len - len / val)\n {\n flag = 1;\n }\n }\n\n if (flag)\n {\n cout << 1 << endl;\n continue;\n }\n\n if (l + 2 * tandem[l] - 1 <= r)\n {\n cout << 2 << endl;\n continue;\n }\n if (r - 2 * rtandem[r] + 1 >= l)\n {\n cout << 2 << endl;\n continue;\n }\n\n for (int pos = 1; pos < sz; ++pos)\n {\n if (r - pos + 1 == l)\n break;\n if (query_lcp(l, r - pos + 1) >= pos)\n {\n flag = 1;\n break;\n }\n }\n int minn = INF;\n for (int pos = order[l]; pos < order[l] + sz; ++pos)\n {\n if (pos + 1 >= n)\n break;\n minn = min(minn, lcp[pos]);\n if (sarr[pos + 1] + minn - 1 >= r && sarr[pos + 1] <= r && sarr[pos + 1] >= l)\n {\n flag = 1;\n break;\n }\n }\n for (int pos = order[l] - 1; pos > order[l] - sz; --pos)\n {\n if (pos < 0)\n break;\n minn = min(minn, lcp[pos]);\n if (sarr[pos] + minn - 1 >= r && sarr[pos] <= r && sarr[pos] >= l)\n {\n flag = 1;\n break;\n }\n }\n\n if (flag)\n {\n cout << 2 << endl;\n continue;\n }\n\n if (left[l] <= r)\n {\n cout << 3 << endl;\n continue;\n }\n\n if (right[r] >= l)\n {\n cout << 3 << endl;\n continue;\n }\n\n for (int i = l; i <= r; ++i)\n {\n if (i + 2 * tandem[i] - 1 <= r)\n flag = 1;\n }\n\n if (flag)\n {\n cout << 3 << endl;\n continue;\n }\n cout << 4 << endl;\n \n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "46c20eb0850eb58ebc280483bc1bfb0e", "src_uid": "bc839e9a025a5d83e2c85fb1e224c175", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n\tint n,m;\n\tcin>>m>>n;\n\tif(n==1)\n\t{\n cout<<-1;\n return 0;\n\t}\n\tif(n==2&&m==3)\n\t{\n cout<<11;\n return 0;\n\t}\n\tif(n==3&&m==5)\n\t{\n cout<<11;\n return 0;\n\t}\n\tint sol=0;\n\twhile(1)\n\t{\n\t\tif(n>=m+m)\n\t\t{\n cout<m)\n\t\t{\n cout<\n\nusing namespace std;\nconst long long mod = 998244353;\n\nlong long pow(long long a, long long b) {\n if (b == 0)return 1;\n if (b % 2 == 1) {\n return (pow(a, b - 1) * a) % mod;\n } else {\n long long y = pow(a, b / 2);\n return (y * y) % mod;\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n long long n, k;\n cin >> n >> k;\n long long c[n + 1][n + 1];\n for (int i = 0; i < n + 1; ++i) {\n for (int j = 0; j < n + 1; ++j) {\n c[i][j] = 0;\n }\n }\n for (int m = 0; m < n + 1; ++m) {\n c[0][m] = 1;\n }\n for (int l = 1; l < n + 1; ++l) {\n for (int i = 1; i < n + 1; ++i) {\n c[l][i] = (c[l][i - 1] + c[l - 1][i - 1]) % mod;\n }\n }\n long long h[n];\n for (int i = 0; i < n; ++i) {\n cin >> h[i];\n }\n long long hh[n];\n hh[n - 1] = h[0];\n for (int j = n - 2; j >= 0; --j) {\n hh[j] = h[j + 1];\n }\n long long eq = 0;\n vector a;\n vector aa;\n for (int i = 0; i < n; ++i) {\n if (h[i] == hh[i]) {\n eq++;\n } else {\n a.push_back(h[i]);\n aa.push_back(hh[i]);\n }\n }\n if (a.size() == 0) {\n cout << 0;\n exit(0);\n }\n long long ans = 0;\n for (long long cor = 0; cor <= (a.size() - 1) / 2; ++cor) {\n long long o = c[cor][a.size()];\n long long res = pow(k - 1, a.size() - cor);\n for (long long i = 0; i <= cor; ++i) {\n res -= (c[i][a.size() - cor] * pow(k - 2, a.size() - cor - i)) % mod;\n res %= mod;\n }\n ans += o * (res + mod) % mod;\n ans %= mod;\n }\n cout << (ans * pow(k, eq)) % mod;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3c346919e1b8ca360f4ea3e608942b79", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "//In The Name Of God;\n\n#include\n\nusing namespace std;\n\ntypedef long long ll;\n\n#define pb push_back\n#defin181De F first\n#define S second\n#define mp make_pair\n\nconst ll Maxn = 1e5 + 7;\nconst ll Max = 1e3 + 7;\nconst ll Mod = 1e9 + 7;\nconst ll Inf = 1e9 ;\n\nint dp[Maxn],ans,sum = 1;\nint n,k;\nstring s,t;\n\nmain()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);cout.tie(0);\n cin>>s>>t>>k;\n n=s.size();\n dp[0]=1;\n for(int i=1;i<=k;i++){\n int s=0;\n for(int j=0;j=0;i--){\n ss=s[n-1];\n for(int j=0;j\n#include\n\nusing namespace std ; \nint main ()\n{ \n\n string a , b ;\n int mi ;\n int c[20] = {0} ;\n int d[20] = {0} ;\n int j[20] = {0} ;\n int max = 1 ;\n \n cin>>a ;\n cin>>b ;\n for (int i = 0 ; i< b.size () ; i++ )\n {\n if (b[i] == '6' )\n b[i] = '9' ; \n if (b[i] == '2' )\n b[i] = '5' ;\n \n if (a[i] == '6' )\n a[i] = '9' ;\n if (a[i] == '2' )\n a[i] = '5' ;\n\n if (a[i] == '0' )\n +++c[0] ;\n if (b[i] == '0' )\n ++d[0] ;\n \n if (a[i] == '1' )\n +++c[1] ;\n if (b[i] == '1' )\n ++d[1] ;\n \n if (a[i] == '3' )\n +++c[3] ;\n if (b[i] == '3' )\n ++d[3] ;\n \n if (a[i] == '4' )\n +++c[4] ;\n if (b[i] == '4' )\n ++d[4] ;\n \n if (a[i] == '5' )\n +++c[5] ;\n if (b[i] == '5' )\n ++d[5] ;\n \n if (a[i] == '7' )\n +++c[7] ;\n if (b[i] == '7' )\n ++d[7] ;\n \n if (a[i] == '8' )\n +++c[8] ;\n if (b[i] == '8' )\n ++d[8] ;\n \n if (a[i] == '9' )\n +++c[9] ;\n if (b[i] == '9' )\n ++d[9] ;\n\n\n }\n\n\n if (d[0] !=0 && c[0] !=0 ) j[0] = d[0]/c[0] ; \n if (d[1] !=0 && c[1] !=0 ) j[1] = d[1]/c[1] ;\n if (d[3] !=0 && c[3] !=0 ) j[3] = d[3]/c[3] ; \n if (d[4] !=0 && c[4] !=0 ) j[4] = d[4]/c[4] ; \n if (d[5] !=0 && c[5] !=0 ) j[5] = d[5]/c[5] ; \n if (d[7] !=0 && c[7] !=0 ) j[7] = d[7]/c[7] ; \n if (d[8] !=0 && c[8] !=0 ) j[8] = d[8]/c[8] ; \n if (d[9] !=0 && c[9] !=0 ) j[9] = d[9]/c[9] ; \n\n\n if (j[0] < j[1] )\n if(c[0] !=0 )\n max = j[0] ;\n else\n if(c[1] !=0 )\n max = j[1] ;\n if (max > j[3] )\n if(c[3] !=0 )\n max = j[3] ;\n if (max > j[4] )\n if(c[4] !=0 )\n max = j[4] ;\n if (max > j[5] )\n if(c[5] !=0 )\n max = j[5] ;\n if (max > j[7] )\n if(c[7] !=0 )\n max = j[7] ;\n \n if (max > j[8] )\n if(c[8] !=0 )\n max = j[8] ;\n if (max > j[9] )\n if(c[9] !=0 )\n max = j[9] ;\n cout<\n\n#define mp make_pair\n#define eb emplace_back\n#define ff first\n#define ss second\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\n#ifdef ONPC\nmt19937 rnd(228);\n#else\nmt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());\n#endif\n\n\nconst int MAXN = 100;\n//#define int long long\nconst int INF = 1e9;\n\nvector> g;\n\nint ans = 0;\nvector to;\n\nint ctr = 0;\nint n;\nvector sz;\n\nint dfs(int v, int p=-1){\n\tint tsz = 1;\n\tfor (int i : g[v]){\n\t\tif (i == p) continue;\n\t\ttsz += dfs(i, v);\n\t}\n\tsz[v] = tsz;\n\treturn tsz;\n} \n\nvoid fnd(int v, int p=-1) {\n\tfor (int i : g[v]){\n\t\tif (i == p) continue;\n\t\tif (sz[i] * 2 >= n) {\n\t\t\tfnd(i, v);\n\t\t\treturn;\n\t\t}\n\t}\n\tctr = v;\t\n}\n\nvector c;\nvoid cdfs(int v, int p, int cl){\n\tc[v] = cl;\n\tfor (int i : g[v]){\n\t\tif (i == p) continue;\n\t\tcdfs(i, v, cl);\n\t}\n}\n\nvector d;\nvoid ddfs(int v, int p = -1, int dd = 0){\n\td[v] = dd;\n\tfor (int i : g[v]){\n\t\tif (i == p) continue;\n\t\tddfs(i, v, dd+1);\n\t}\n}\n\nsigned main()\n{\n #ifdef FILEIO\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n #endif\n\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n\n\tcin >> n;\n\tg.assign(n, vector ());\n\tto.assign(n, 0);\n\tint a, b;\n\tfor (int i =0 ; i < n-1; i++){\n\t\tcin >> a >> b;\n\t\ta--, b--;\n\t\tg[a].eb(b);\n\t\tg[b].eb(a);\n\t}\n\n\tsz.assign(n, 0);\n\tdfs(0);\n\tfnd(0);\n\t\n\td.assign(n, 0);\n\tddfs(ctr);\n\n\tdfs(ctr);\n\n\tc.assign(n, 0);\n\tint curc = 0;\n\tfor (int i : g[ctr]){\n\t\tassert(sz[i] * 2 <= n);\n\n\t\tcdfs(i, ctr, curc);\n\t\tcurc++;\n\t}\n\tc[ctr] = curc;\n\n\tvector> vs(curc);\n\tfor (int i = 0; i < n; i++){\n\t\tif (i == ctr) continue;\n\t\tvs[c[i]].eb(i);\n\t}\n\n\tstable_sort(vs.begin(), vs.end(), [](const vector& a, const vector& b){\n\t\treturn a.size() < b.size();\n\t});\n\n\tint tsz = 0;\n\tfor (int i = 0; i < (int)vs.size(); i++){\n\t\tassert((int)vs[i].size() * 2 <= n);\n\t\tassert(i == 0 || vs[i].size() >= vs[i-1].size());\n\t\t//cout << \"SX: \" << vs[i].size() << '\\n';\n\t\ttsz += (int)vs[i].size();\n\t}\n\tassert(tsz + 1 == n);\n\n\tassert(vs.size() >= g[ctr].size());\n\n\tset> s;\n\tfor (int i = 0; i < (int)vs.size(); i++){\n\t\ts.insert(mp(-(int)vs[i].size(), i));\n\t}\n\n\twhile ((int)s.size() > 1){\n\t\tauto r1 = *s.begin();\n\t\ts.erase(s.begin());\n\t\tauto r2 = *s.begin();\n\t\ts.erase(s.begin());\n\n\t\tint l = r1.ss;\n\t\tint r = r2.ss;\n\n\t\tint vl = vs[l].back();\n\t\tvs[l].pop_back();\n\t\tint vr = vs[r].back();\n\t\tvs[r].pop_back();\n\n\t\tto[vl] = vr;\n\t\tto[vr] = vl;\n\t\tassert(c[vl] != c[vr]);\n\n\t\tans += d[vr] + d[vl] + d[vr] + d[vl];\n\n\t\tif (vs[l].size())\n\t s.insert(mp(-(int)vs[l].size(), l));\n\t if (vs[r].size())\n\t s.insert(mp(-(int)vs[r].size(), r));\n\t\t//cerr << l << ' ' << r << '\\n';\n\t}\n\n\tif (s.empty()){\n\t\n\t\tint v1 = 0;\n\t\tif (ctr == v1) v1++;\n\t\tint v2 = to[v1];\n\n\t\tto[ctr] = v1;\n\t\t//to[v1] = v2;\n\t\tto[v2] = ctr;\n\n\t\t//ans -= d[v1] + d[v1] + d[v2] + d[v2];\n\t\t//ans += d[v1];\n\t\n\t} else {\n\t\tassert((int)vs[l].size() < 2);\n\t\tint l = s.begin()->ss;\n\t\tint vv = vs[l][0];\n\t\tto[vv] = ctr;\n\t\tto[ctr] = vv;\n\t\tans += (d[vv] << 1);\n\t}\n\n\tcout << ans << '\\n';\n\tfor (auto i : to) cout << i+1 << ' ';\n\tcout << '\\n';\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "16230997247af207f9840825c17a4fcc", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "/**\n * code generated by JHelper\n * More info: https://github.com/AlexeyDmitriev/JHelper\n * @author\n */\n\n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define pb push_back\n#define sz(v) ((int)(v).size())\n#define all(v) (v).begin(),(v).end()\n#define mp make_pair\n\nusing namespace std;\n\ntypedef long long int64;\ntypedef vector vi;\ntypedef pair ii;\ntypedef long double ld;\n\nint BUBEN = 30;\nint BUBEN2 = 5;\nint BUBEN3 = 20;\n\nclass TaskH {\n public:\n void solveOne(istream &in, ostream &out) {\n ld start = clock() / (ld) CLOCKS_PER_SEC;\n\n int n;\n in >> n;\n vector x(n + 1);\n vector y(n + 1);\n for (int i = 0; i <= n; ++i) {\n in >> x[i] >> y[i];\n }\n vector offset;\n vector len;\n vector dx;\n vector dy;\n offset.push_back(0);\n for (int i = 0; i < n; ++i) {\n ld vx = x[i + 1] - x[i];\n ld vy = y[i + 1] - y[i];\n ld z = hypotl(vx, vy);\n dx.push_back(vx / z);\n dy.push_back(vy / z);\n len.push_back(z);\n offset.push_back(offset.back() + z);\n }\n auto ternary = [&](const auto& func, ld left, ld right) {\n while (right - left > 1e-12 * max((ld) 1.0, right)) {\n ld mleft = (2 * left + right) / 3;\n ld mright = (left + 2 * right) / 3;\n ld vleft = func(mleft);\n ld vright = func(mright);\n if (vleft > vright) {\n right = mright;\n } else {\n left = mleft;\n }\n }\n return func((left + right) / 2);\n };\n ld total = offset.back();\n\n auto where = [&](ld pos) {\n int i = lower_bound(all(offset), pos) - offset.begin() - 1;\n if (i < 0) i = 0;\n if (i >= n) i = n - 1;\n return i;\n };\n\n auto evalBefore = [&](ld pos) {\n int i = where(pos);\n ld xi = x[i] + dx[i] * (pos - offset[i]);\n ld yi = y[i] + dy[i] * (pos - offset[i]);\n\n ld bestBefore = 1;\n for (int j = 0; j < i; ++j) {\n auto eval2 = [&](ld t) {\n ld xj = x[j] + dx[j] * t;\n ld yj = y[j] + dy[j] * t;\n ld direct = pos - (offset[j] + t);\n return direct / max((ld) 1e-7, hypotl(xi - xj, yi - yj));\n };\n ld cur = ternary(eval2, 0, len[j]);\n bestBefore = max(bestBefore, cur);\n }\n return bestBefore;\n };\n\n auto evalAfter = [&](ld pos) {\n int i = where(pos);\n ld xi = x[i] + dx[i] * (pos - offset[i]);\n ld yi = y[i] + dy[i] * (pos - offset[i]);\n\n ld bestAfter = 1;\n for (int j = i + 1; j < n; ++j) {\n auto eval2 = [&](ld t) {\n ld xj = x[j] + dx[j] * t;\n ld yj = y[j] + dy[j] * t;\n ld direct = (offset[j] + t) - pos;\n return direct / max((ld) 1e-7, hypotl(xi - xj, yi - yj));\n };\n ld cur = ternary(eval2, 0, len[j]);\n bestAfter = max(bestAfter, cur);\n }\n return bestAfter;\n };\n\n auto eval = [&](ld pos) {\n return min(evalBefore(pos), evalAfter(pos));\n };\n\n\n ld STEP = total;\n vector> best;\n while (best.size() < 1e6 && clock() / (ld) CLOCKS_PER_SEC < start + 1) {\n STEP *= 0.5;\n for (ld at = STEP; at <= total; at += STEP * 2) {\n best.emplace_back(eval(at), where(at), at);\n }\n }\n sort(all(best));\n\n auto reduce = [&]() {\n sort(all(best), [](const auto& a, const auto& b) {\n return get<0>(a) > get<0>(b);\n });\n int got = 0;\n vector gotIn(n);\n for (int i = 0; i < best.size(); ++i) {\n if (got < BUBEN3 && gotIn[get<1>(best[i])] < BUBEN2) {\n best[got] = best[i];\n ++got;\n ++gotIn[get<1>(best[i])];\n }\n }\n best.resize(got);\n };\n\n while (clock() / (ld) CLOCKS_PER_SEC < start + 3) {\n reduce();\n STEP *= 0.5;\n sort(all(best), [](const auto& a, const auto& b) {\n return get<2>(a) < get<2>(b);\n });\n int old = best.size();\n ld prev = 0;\n for (int i = 0; i <= old; ++i) {\n ld cur;\n if (i == old) {\n cur = total;\n } else {\n cur = get<2>(best[i]);\n }\n if (cur - prev > 3 * STEP) {\n ld at = prev + STEP;\n best.emplace_back(eval(at), where(at), at);\n at = cur - STEP;\n best.emplace_back(eval(at), where(at), at);\n } else if (cur - prev > 2 * STEP) {\n ld at = (2 * prev + cur) / 3;\n best.emplace_back(eval(at), where(at), at);\n at = (prev + 2 * cur) / 3;\n best.emplace_back(eval(at), where(at), at);\n } else if (cur - prev > STEP) {\n ld at = (prev + cur) / 2;\n best.emplace_back(eval(at), where(at), at);\n }\n prev = cur;\n }\n }\n\n cerr << STEP << endl;\n\n ld res = 0;\n for (const auto& x : best) {\n res = max(res, get<0>(x));\n }\n out << res << \"\\n\";\n }\n\n\n\n void solve(std::istream &in, std::ostream &out) {\n out.precision(20);\n int nt = 1;\n for (int it = 0; it < nt; ++it) {\n solveOne(in, out);\n }\n }\n};\n\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n TaskH solver;\n std::istream& in(std::cin);\n std::ostream& out(std::cout);\n solver.solve(in, out);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bad04384969061bb1cde21eedce2d4e3", "src_uid": "ee115d3f08a53c52db3e429ad0cee906", "difficulty": 3500.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \nusing namespace std;\n\ntypedef long long LL;\n\nstruct par { LL x, y; };\n\nLL modu, period;\n\ninline LL M (LL x, LL y) {\n\tLL r(0);\n\ty = (y % modu + modu) % modu;\n\tfor (; y; y >>= 1, x = (x + x) % modu) if (y & 1) r = (r + x) % modu;\n\treturn r;\n}\n\npar getFib (LL x) // (F[x], F[x + 1])\n{\n\tif (x == 0) return (par){0, 1};\n\tpar y;\n\tif (x & 1)\n\t{\n\t\ty = getFib(x - 1);\n\t\treturn (par){y.y, (y.x + y.y) % modu};\n\t}\n\telse\n\t{\n\t\ty = getFib(x / 2);\n\t\treturn (par){M(y.x, y.y * 2 - y.x), (M(y.x, y.x) + M(y.y, y.y)) % modu};\n\t}\n}\n\nint main ()\n{\n\tLL cx; cin >> cx;\n\tvector vpre, vcur;\n\tmodu = 10; period = 60;\n//\tcout << '#' << endl;\n\tfor (int i = 0; i < period; ++i)\n\t\tif (getFib(i).x == cx % modu) vcur.push_back(i);\n\tfor (int _ = 2; _ <= 13; ++_)\n\t{\n//\t\tcout << _ << endl;\n\t\tvpre = vcur;\n\t\tvcur.clear();\n\t\tmodu *= 10;\n\t\tLL f = (_ <= 3) ? 5 : 10;\n\t\tfor(typeof vpre.begin() x:vpre){}\n\t\tfor (LL x : vpre) for (LL i = 0, j; i < f; ++i)\n\t\t\tif (getFib(j = x + i * period).x == cx % modu)\n\t\t\t\tvcur.push_back(j);\n\t\tperiod *= f;\n\t}\n\tif (vcur.size())\n\t\tcout << *min_element(vcur.begin(), vcur.end()) << endl;\n\telse\n\t\tcout << -1 << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9c72030205586669c4113e73ef8deac4", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "\n#include\nusing namespace std;\nint main()\n{\n int i,j;\n cout<<\"Inter the numbers\"<>i>>j;\n float temp1 = (i*30 + j/2) mode 360;\n int temp2 = (j*6) mode 360;\n \n cout<<\"the answer is\"<\nusing namespace std;\ntypedef long long LL;\nconst int N = 600000+10;\nconst double PI = acos(-1);\nstruct Complex {\n double x, y;\n Complex(double x=0.0, double y=0.0) : x(x), y(y) {}\n Complex operator + (const Complex &b) const {\n return Complex(x+b.x, y+b.y);\n }\n Complex operator - (const Complex &b) const {\n return Complex(x-b.x, y-b.y);\n }\n Complex operator * (const Complex &b) const{\n return Complex(x * b.x - y * b.y, x * b.y + y * b.x);\n }\n} x1[N<<2], x2[N<<2];\nvoid change(Complex y[], int len) {\n for(int i=1,j=len/2;i=k) {\n j-=k; k/=2;\n }\n if(j\nusing namespace std;\nint dig(int n)\n{\n int sum = 0;\n while(n)\n {\n sum++;\n n/=10;\n }\n return sum;\n}\nint main()\n{\n int T;\n cin>>T;\n int ar[6];\n int p;\n for(int i=0;i<6;i++)\n {\n cin>>p;\n ar[i] = p;\n }\n int q;\n cin>>q;\n int n;\n cin>>n;\n int dp[T];\n int sum=0;\n sum+=9;\n if(T>9)\n dp[0] = 9;\n for(int i=1;iT)\n {\n int dif = sum-T;\n for(int j=1;j>=0;j--)\n if(diff<=dp[j])\n {\n dp[j]-=diff;\n sum-=diff;\n break;\n }\n }\n }\n int fortune = 0;\n for(int i=0;i\r\nusing namespace std;\r\n#define FOR(i,m,n) for(int i=(m);i<(n);++i)\r\n#define REP(i,n) FOR(i,0,n)\r\n#define ALL(v) (v).begin(),(v).end()\r\nusing ll = long long;\r\nconstexpr int INF = 0x3f3f3f3f;\r\nconstexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;\r\nconstexpr double EPS = 1e-8;\r\nconstexpr int MOD = 998244353;\r\nconstexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};\r\nconstexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};\r\nconstexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};\r\ntemplate \r\ninline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }\r\ntemplate \r\ninline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }\r\nstruct IOSetup {\r\n IOSetup() {\r\n std::cin.tie(nullptr);\r\n std::ios_base::sync_with_stdio(false);\r\n std::cout << fixed << setprecision(20);\r\n }\r\n} iosetup;\r\n\r\ntemplate \r\nstruct MInt {\r\n unsigned int v;\r\n MInt() : v(0) {}\r\n MInt(const long long x) : v(x >= 0 ? x % M : x % M + M) {}\r\n static constexpr int get_mod() { return M; }\r\n static void set_mod(const int divisor) { assert(divisor == M); }\r\n static void init(const int x = 10000000) {\r\n inv(x, true);\r\n fact(x);\r\n fact_inv(x);\r\n }\r\n static MInt inv(const int n, const bool init = false) {\r\n // assert(0 <= n && n < M && std::__gcd(n, M) == 1);\r\n static std::vector inverse{0, 1};\r\n const int prev = inverse.size();\r\n if (n < prev) {\r\n return inverse[n];\r\n } else if (init) {\r\n // \"n!\" and \"M\" must be disjoint.\r\n inverse.resize(n + 1);\r\n for (int i = prev; i <= n; ++i) {\r\n inverse[i] = -inverse[M % i] * (M / i);\r\n }\r\n return inverse[n];\r\n }\r\n int u = 1, v = 0;\r\n for (unsigned int a = n, b = M; b;) {\r\n const unsigned int q = a / b;\r\n std::swap(a -= q * b, b);\r\n std::swap(u -= q * v, v);\r\n }\r\n return u;\r\n }\r\n static MInt fact(const int n) {\r\n static std::vector factorial{1};\r\n const int prev = factorial.size();\r\n if (n >= prev) {\r\n factorial.resize(n + 1);\r\n for (int i = prev; i <= n; ++i) {\r\n factorial[i] = factorial[i - 1] * i;\r\n }\r\n }\r\n return factorial[n];\r\n }\r\n static MInt fact_inv(const int n) {\r\n static std::vector f_inv{1};\r\n const int prev = f_inv.size();\r\n if (n >= prev) {\r\n f_inv.resize(n + 1);\r\n f_inv[n] = inv(fact(n).v);\r\n for (int i = n; i > prev; --i) {\r\n f_inv[i - 1] = f_inv[i] * i;\r\n }\r\n }\r\n return f_inv[n];\r\n }\r\n static MInt nCk(const int n, const int k) {\r\n if (n < 0 || n < k || k < 0) return 0;\r\n return fact(n) * (n - k < k ? fact_inv(k) * fact_inv(n - k) :\r\n fact_inv(n - k) * fact_inv(k));\r\n }\r\n static MInt nPk(const int n, const int k) {\r\n return n < 0 || n < k || k < 0 ? 0 : fact(n) * fact_inv(n - k);\r\n }\r\n static MInt nHk(const int n, const int k) {\r\n return n < 0 || k < 0 ? 0 : (k == 0 ? 1 : nCk(n + k - 1, k));\r\n }\r\n static MInt large_nCk(long long n, const int k) {\r\n if (n < 0 || n < k || k < 0) return 0;\r\n inv(k, true);\r\n MInt res = 1;\r\n for (int i = 1; i <= k; ++i) {\r\n res *= inv(i) * n--;\r\n }\r\n return res;\r\n }\r\n MInt pow(long long exponent) const {\r\n MInt res = 1, tmp = *this;\r\n for (; exponent > 0; exponent >>= 1) {\r\n if (exponent & 1) res *= tmp;\r\n tmp *= tmp;\r\n }\r\n return res;\r\n }\r\n MInt& operator+=(const MInt& x) {\r\n if ((v += x.v) >= M) v -= M;\r\n return *this;\r\n }\r\n MInt& operator-=(const MInt& x) {\r\n if ((v += M - x.v) >= M) v -= M;\r\n return *this;\r\n }\r\n MInt& operator*=(const MInt& x) {\r\n v = static_cast(v) * x.v % M;\r\n return *this;\r\n }\r\n MInt& operator/=(const MInt& x) { return *this *= inv(x.v); }\r\n bool operator==(const MInt& x) const { return v == x.v; }\r\n bool operator!=(const MInt& x) const { return v != x.v; }\r\n bool operator<(const MInt& x) const { return v < x.v; }\r\n bool operator<=(const MInt& x) const { return v <= x.v; }\r\n bool operator>(const MInt& x) const { return v > x.v; }\r\n bool operator>=(const MInt& x) const { return v >= x.v; }\r\n MInt& operator++() {\r\n if (++v == M) v = 0;\r\n return *this;\r\n }\r\n MInt operator++(int) {\r\n const MInt res = *this;\r\n ++*this;\r\n return res;\r\n }\r\n MInt& operator--() {\r\n v = (v == 0 ? M - 1 : v - 1);\r\n return *this;\r\n }\r\n MInt operator--(int) {\r\n const MInt res = *this;\r\n --*this;\r\n return res;\r\n }\r\n MInt operator+() const { return *this; }\r\n MInt operator-() const { return MInt(v ? M - v : 0); }\r\n MInt operator+(const MInt& x) const { return MInt(*this) += x; }\r\n MInt operator-(const MInt& x) const { return MInt(*this) -= x; }\r\n MInt operator*(const MInt& x) const { return MInt(*this) *= x; }\r\n MInt operator/(const MInt& x) const { return MInt(*this) /= x; }\r\n friend std::ostream& operator<<(std::ostream& os, const MInt& x) {\r\n return os << x.v;\r\n }\r\n friend std::istream& operator>>(std::istream& is, MInt& x) {\r\n long long v;\r\n is >> v;\r\n x = MInt(v);\r\n return is;\r\n }\r\n};\r\nusing ModInt = MInt;\r\n\r\nstd::vector prime_sieve(const int n, const bool get_only_prime) {\r\n std::vector smallest_prime_factor(n + 1), prime;\r\n std::iota(smallest_prime_factor.begin(), smallest_prime_factor.end(), 0);\r\n for (int i = 2; i <= n; ++i) {\r\n if (smallest_prime_factor[i] == i) prime.emplace_back(i);\r\n for (const int p : prime) {\r\n if (i * p > n || p > smallest_prime_factor[i]) break;\r\n smallest_prime_factor[i * p] = p;\r\n }\r\n }\r\n return get_only_prime ? prime : smallest_prime_factor;\r\n}\r\n\r\nstruct Divisor {\r\n const std::vector smallest_prime_factor;\r\n\r\n explicit Divisor(const int n)\r\n : smallest_prime_factor(prime_sieve(n, false)) {}\r\n\r\n std::vector query(int n) const {\r\n std::vector res{1};\r\n while (n > 1) {\r\n const int prime_factor = smallest_prime_factor[n], d = res.size();\r\n int tmp = 1;\r\n for (; n % prime_factor == 0; n /= prime_factor) {\r\n tmp *= prime_factor;\r\n for (int i = 0; i < d; ++i) {\r\n res.emplace_back(res[i] * tmp);\r\n }\r\n }\r\n }\r\n // std::sort(res.begin(), res.end());\r\n return res;\r\n }\r\n};\r\n\r\nstd::vector mobius_mu_init(const int n) {\r\n std::vector is_prime(n + 1, true);\r\n is_prime[0] = false;\r\n if (n >= 1) is_prime[1] = false;\r\n std::vector mu(n + 1, 1);\r\n mu[0] = 0;\r\n for (int i = 2; i <= n; ++i) {\r\n if (is_prime[i]) {\r\n mu[i] = -mu[i];\r\n for (int j = i * 2; j <= n; j += i) {\r\n is_prime[j] = false;\r\n mu[j] = ((j / i) % i == 0 ? 0 : -mu[j]);\r\n }\r\n }\r\n }\r\n return mu;\r\n}\r\n\r\n// https://oeis.org/A229223\r\nModInt g(int n, int k) {\r\n const int m = min(n, k);\r\n vector dp(m + 1, 0);\r\n dp[0] = 1;\r\n while (n--) {\r\n vector nxt(m + 1, 0);\r\n REP(i, m + 1) {\r\n if (i > 0) nxt[i] += dp[i] * (i - 1);\r\n if (i + 1 <= m) nxt[i + 1] += dp[i];\r\n }\r\n dp.swap(nxt);\r\n }\r\n return accumulate(ALL(dp), ModInt(0));\r\n}\r\n\r\ntemplate \r\nstd::vector> stirling_number_of_the_second_kind_init(\r\n const int n, const int k) {\r\n std::vector> s(n + 1, std::vector(k + 1, 0));\r\n s[0][0] = 1;\r\n for (int i = 1; i <= n; ++i) {\r\n for (int j = 1; j <= i && j <= k; ++j) {\r\n s[i][j] = s[i - 1][j - 1] + s[i - 1][j] * j;\r\n }\r\n }\r\n return s;\r\n}\r\n\r\nint main() {\r\n int n, k; cin >> n >> k;\r\n if (n == 1 || k == 1) {\r\n cout << 1 << '\\n';\r\n return 0;\r\n }\r\n const Divisor divisor(n);\r\n const vector mu = mobius_mu_init(n);\r\n const auto s = stirling_number_of_the_second_kind_init(n - 1, k);\r\n vector f(n + 1, 0);\r\n FOR(i, 1, n + 1) f[i] = accumulate(s[i - 1].begin(), s[i - 1].begin() + (min(i - 1, k - 1) + 1), ModInt(0));\r\n FOR(i, 2, n + 1) f[i - 2] = f[i];\r\n f.resize(n - 1);\r\n ModInt ans = 0;\r\n FOR(i, 1, n) {\r\n for (int j : divisor.query(i)) {\r\n const int seg = i / j;\r\n ModInt ways = 0;\r\n REP(x, seg) ways += ModInt::nCk(seg - 1, x) * f[x]; // f[x + 2]\r\n ans += ways * mu[j];\r\n }\r\n }\r\n cout << ans << '\\n';\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a7bc7f5e3aef7eab6145dd487854a686", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntemplateconstexpr int sz(const C&c){return int(c.size());}\nusing ll=long long;constexpr const char nl='\\n',sp=' ';\n\nusing ld = long double;\nconst ld EPS = 1e-9;\nusing Point = pair;\n#define x first\n#define y second\nusing Polygon = pair>;\n#define index first\n#define points second\nusing Group = vector;\nusing Operation = pair;\nusing Sequence = vector;\n#define input first\n#define output second\n\ntemplate bool lt(const T &a, const T &b) { return a < b - T(EPS); }\ntemplate bool le(const T &a, const T &b) { return !lt(b, a); }\ntemplate bool gt(const T &a, const T &b) { return lt(b, a); }\ntemplate bool ge(const T &a, const T &b) { return !lt(a, b); }\ntemplate bool eq(const T &a, const T &b) { return !lt(a, b) && !lt(b, a); }\ntemplate bool ne(const T &a, const T &b) { return lt(a, b) || lt(b, a); }\n\nbool ltX(const Point &a, const Point &b) {\n return lt(a.x, b.x);\n}\n\nbool ltY(const Point &a, const Point &b) {\n return lt(a.y, b.y);\n}\n\nbool eqPoint(const Point &a, const Point &b) {\n return eq(a.x, b.x) && eq(a.y, b.y);\n}\n\nld dist(const Point &a, const Point &b) {\n ld dx = a.x - b.x, dy = a.y - b.y;\n return sqrt(dx * dx + dy * dy);\n}\n\nint ccw(const Point &a, const Point &b, const Point &c) {\n ld a2 = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n if (lt(a2, ld(0))) return -1;\n else if (gt(a2, ld(0))) return +1;\n else return 0;\n}\n\nld area2(const Point &a, const Point &b, const Point &c) {\n return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n}\n\nld area2(const Polygon &P) {\n ld ret = 0;\n for (int i = 0; i < sz(P.points); i++) ret += area2(Point(0, 0), P.points[i], P.points[(i + 1) % sz(P.points)]);\n return ret;\n}\n\nSequence reverseSeq(const Sequence &seq) {\n Sequence ret(seq);\n reverse(ret.begin(), ret.end());\n for (auto &&op : ret) op.input.swap(op.output);\n return ret;\n}\n\nint index = 1;\n\nPolygon makeRect(ld minX, ld minY, ld maxX, ld maxY) {\n Polygon r;\n r.index = index++;\n r.points.emplace_back(minX, minY);\n r.points.emplace_back(maxX, minY);\n r.points.emplace_back(maxX, maxY);\n r.points.emplace_back(minX, maxY);\n return r;\n}\n\nSequence rectToSquare(const Polygon &src, const Polygon &square) {\n Sequence seq;\n ld minX = min_element(src.points.begin(), src.points.end(), ltX)->x;\n ld maxX = max_element(src.points.begin(), src.points.end(), ltX)->x;\n ld minY = min_element(src.points.begin(), src.points.end(), ltY)->y;\n ld maxY = max_element(src.points.begin(), src.points.end(), ltY)->y;\n ld curWidth = maxX - minX;\n ld curHeight = maxY - minY;\n ld len = square.points[2].x;\n Polygon st = src;\n for (auto &&p : st.points) {\n p.x -= minX;\n p.y -= minY;\n }\n Polygon cur = makeRect(0, 0, curWidth, curHeight);\n seq.emplace_back(Group{st}, Group{cur});\n if (lt(curWidth, curHeight)) {\n swap(curWidth, curHeight);\n Polygon rot1 = makeRect(0, 0, curWidth, curHeight);\n Polygon rot2 = rot1;\n rot1.index = cur.index;\n rotate(rot1.points.begin(), rot1.points.begin() + 3, rot1.points.end());\n seq.emplace_back(Group{rot1}, Group{rot2});\n cur = rot2;\n }\n while (gt(curWidth, 2 * len)) {\n Polygon left = makeRect(0, 0, curWidth / 2, curHeight);\n Polygon right = makeRect(curWidth / 2, 0, curWidth, curHeight);\n seq.emplace_back(Group{cur}, Group{left, right});\n curWidth /= 2;\n curHeight *= 2;\n cur = makeRect(0, 0, curWidth, curHeight);\n Polygon bottom = makeRect(0, 0, curWidth, curHeight / 2);\n bottom.index = left.index;\n Polygon top = makeRect(0, curHeight / 2, curWidth, curHeight);\n top.index = right.index;\n seq.emplace_back(Group{bottom, top}, Group{cur});\n }\n if (ne(curWidth, len)) {\n Point p(len, curHeight);\n Point q(curWidth - len, 0);\n Point r(curWidth - len, len - curHeight);\n Polygon a{index++, {cur.points[0], q, r}};\n Polygon b{index++, {cur.points[0], p, cur.points[3]}};\n Polygon c{index++, {q, cur.points[1], cur.points[2], p, r}};\n seq.emplace_back(Group{cur}, Group{a, b, c});\n cur = makeRect(0, 0, len, len);\n p = Point(0, len - curHeight);\n q = Point(len, curHeight);\n r = Point(len - (curWidth - len), curHeight);\n Polygon d{a.index, {r, q, cur.points[2]}};\n Polygon e{b.index, {p, cur.points[2], cur.points[3]}};\n Polygon f{c.index, {cur.points[0], cur.points[1], q, r, p}};\n seq.emplace_back(Group{d, e, f}, Group{cur});\n }\n seq.emplace_back(Group{cur}, Group{square});\n return seq;\n}\n\nSequence rectToRect(const Polygon &src, const Polygon &target) {\n ld len = sqrt(area2(src) / 2);\n Polygon square = makeRect(0, 0, len, len);\n Sequence A = rectToSquare(src, square), B = reverseSeq(rectToSquare(target, square));\n A.insert(A.end(), B.begin(), B.end());\n return A;\n}\n\npair triToArbRect(const Polygon &tri) {\n Sequence seq;\n vector lens;\n for (int i = 0; i < sz(tri.points); i++) lens.push_back(dist(tri.points[i], tri.points[(i + 1) % sz(tri.points)]));\n int ind = max_element(lens.begin(), lens.end(), lt) - lens.begin();\n ld base = lens[ind], height = area2(tri) / base;\n ld tx = lens[(ind + sz(lens) - 1) % sz(lens)];\n tx = sqrt(tx * tx - height * height);\n Polygon st;\n st.index = tri.index;\n st.points.emplace_back(0, 0);\n st.points.emplace_back(base, 0);\n st.points.emplace_back(tx, height);\n Polygon cur = st;\n cur.index = index++;\n rotate(st.points.begin(), st.points.begin() + (sz(st.points) - ind) % sz(st.points), st.points.end());\n seq.emplace_back(Group{st}, Group{cur});\n ld base1 = tx / 2, base2 = (base - tx) / 2;\n Point p(tx - base1, height / 2);\n Point q(tx, height / 2);\n Point r(tx + base2, height / 2);\n Polygon a{index++, {p, q, cur.points[2]}};\n Polygon b{index++, {q, r, cur.points[2]}};\n Polygon c{index++, {cur.points[0], cur.points[1], r, p}};\n seq.emplace_back(Group{cur}, Group{a, b, c});\n cur = makeRect(0, 0, base, height / 2);\n p = Point(base1, height / 2);\n r = Point(base - base2, height / 2);\n Polygon d{a.index, {p, cur.points[3], cur.points[0]}};\n Polygon e{b.index, {cur.points[2], r, cur.points[1]}};\n Polygon f{c.index, {cur.points[0], cur.points[1], r, p}};\n seq.emplace_back(Group{d, e, f}, Group{cur});\n return make_pair(seq, cur);\n}\n\nSequence triToSquare(const Polygon &src, const Polygon &target) {\n Sequence A, B;\n Polygon rect;\n tie(A, rect) = triToArbRect(src);\n B = rectToSquare(rect, target);\n A.insert(A.end(), B.begin(), B.end());\n return A;\n}\n\nbool valid(const Point &a, const Point &b, const Point &c, const Polygon &P) {\n for (auto &&p : P.points) if (ccw(a, b, p) == 1 && ccw(b, c, p) == 1 && ccw(c, a, p) == 1) return false;\n return true;\n}\n\npair polyToArbSquare(const Polygon &P) {\n Sequence seq;\n Group tris;\n Polygon cur = P;\n while (sz(cur.points) > 2) {\n for (int i = 0; i < sz(cur.points); i++) {\n Point p = cur.points[i], q = cur.points[(i + 1) % sz(cur.points)], r = cur.points[(i + 2) % sz(cur.points)];\n if (ccw(p, q, r) == 1 && valid(p, q, r, cur)) {\n tris.emplace_back(index++, vector{p, q, r});\n cur.points.erase(cur.points.begin() + (i + 1) % sz(cur.points));\n break;\n }\n }\n }\n seq.emplace_back(Group{P}, tris);\n Polygon merged;\n merged.index = -1;\n ld totArea = 0;\n for (auto &&tri : tris) {\n ld a = area2(tri) / 2, len = sqrt(a);\n totArea += a;\n Polygon square = makeRect(0, 0, len, len);\n Sequence A = triToSquare(tri, square);\n seq.insert(seq.end(), A.begin(), A.end());\n if (merged.index == -1) merged = square;\n else {\n ld len = sqrt(totArea);\n Polygon bottom = makeRect(0, 0, len, a / len);\n Polygon top = makeRect(0, a / len, len, totArea / len);\n Sequence B = reverseSeq(rectToSquare(bottom, square)), C = reverseSeq(rectToSquare(top, merged));\n seq.insert(seq.end(), B.begin(), B.end());\n seq.insert(seq.end(), C.begin(), C.end());\n merged = makeRect(0, 0, len, len);\n seq.emplace_back(Group{bottom, top}, Group{merged});\n }\n }\n return make_pair(seq, merged);\n}\n\nSequence polyToPoly(const Polygon &src, const Polygon &target) {\n Sequence A, B;\n Polygon SA, SB;\n tie(A, SA) = polyToArbSquare(src);\n tie(B, SB) = polyToArbSquare(target);\n B = reverseSeq(B);\n A.emplace_back(Group{SA}, Group{SB});\n A.insert(A.end(), B.begin(), B.end());\n return A;\n}\n\nPolygon readPolygon() {\n Polygon ret;\n ret.index = index++;\n int k;\n cin >> k;\n for (int i = 0; i < k; i++) {\n int x, y;\n cin >> x >> y;\n ret.points.emplace_back(x, y);\n }\n return ret;\n}\n\nvoid writeSeq(const Polygon &S, const Sequence &seq) {\n vector indexToId(index, -1);\n int curId = 0;\n auto addId = [&] (const Polygon &P) {\n return indexToId[P.index] = curId++;\n };\n auto removeId = [&] (const Polygon &P) {\n int ret = indexToId[P.index];\n assert(ret != -1);\n indexToId[P.index] = -1;\n return ret;\n };\n auto writePolygon = [&] (const Polygon &P) {\n cout << sz(P.points);\n for (auto &&p : P.points) cout << sp << fixed << setprecision(9) << p.x << sp << p.y;\n cout << nl;\n };\n auto writeOp = [&] (const Operation &op) {\n if (sz(op.output) == 1) {\n cout << \"tape\" << nl;\n cout << sz(op.input);\n for (auto &&P : op.input) cout << sp << removeId(P);\n cout << nl;\n for (auto &&P : op.input) writePolygon(P);\n writePolygon(op.output[0]);\n addId(op.output[0]);\n } else {\n cout << \"scissors\" << nl;\n cout << removeId(op.input[0]) << sp << sz(op.output) << nl;\n for (auto &&P : op.output) {\n writePolygon(P);\n addId(P);\n }\n }\n };\n addId(S);\n for (auto &&op : seq) writeOp(op);\n}\n\nint main() {\n // freopen(\"in.txt\", \"r\", stdin);\n // freopen(\"out.txt\", \"w\", stdout);\n // freopen(\"err.txt\", \"w\", stderr);\n ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n Polygon S = readPolygon(), T = readPolygon();\n Sequence A = polyToPoly(S, T);\n writeSeq(S, A);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "29281058c74c68171c1e7a25c9ca4c14", "src_uid": "375b83d1b7a911c1ca67d5209d39adb4", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define LL long long\n#define ull unsigned long long\nusing namespace std;\nconst int N=110;\nconst ull INF = -1;\n\nint read(){\n int x=0,f=1;char ch=getchar();\n while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}\n while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}\n return x*f;\n}\nvoid print(LL x){\n if(x>9) print(x/10);\n putchar(x%10+'0');\n}\n\nint G,n,m;\nint a[N],k[N],b[N][N];\nint l[N],c[N][N];\null dp[N][N][N];\null tp[N][N];\nint cnt;\n\nint nxt[N],go[N][2];\nvoid KMP(int len,int *s){\n\tint j=0;\n\tfor(int i=2;i<=len;++i){\n\t\twhile(j>0&&s[j+1]!=s[i]) j=nxt[j];\n\t\tif(s[j+1]==s[i]) ++j;\n\t\tnxt[i]=j;\n\t}\n\tgo[len][0]=go[len][1];\n\tfor(int i=0;i=INF) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor(int j=0;j<=cnt;++j){\n\t\t\t\t\tull w=dp[h][i][j];\n\t\t\t\t\tif(wtp[k[row]][ed]){\n\t\t\t\tdp[a[row]][st][ed]=tp[k[row]][ed];\n\t\t\t\tre=1;\n\t\t\t}\n\t\t}\n\t}\n\treturn re;\n}\nint main(){\n//\tfreopen(\"1.in\",\"r\",stdin);\n//\tfreopen(\"1.out\",\"w\",stdout);\n\tscanf(\"%d%d%d\",&G,&n,&m);\n\tassert(m == 1);\n\tfor(int i=1;i<=n;++i){\n\t\tscanf(\"%d%d\",&a[i],&k[i]);\n\t\tfor(int j=1;j<=k[i];++j){\n\t\t\tscanf(\"%d\",&b[i][j]);\n\t\t}\n\t}\n\tfor(int i=1;i<=m;++i){\n\t\tscanf(\"%d\",&l[i]);\n\t\tfor(int j=1;j<=l[i];++j){\n\t\t\tscanf(\"%d\",&c[i][j]);\n\t\t}\n\t}\n\tKMP(l[1],c[1]);\n\tcnt=l[1];\n\tfill_n(dp[0][0], N*N*N, INF);\n\tfor(int i=0;i<=cnt;++i){\n\t\tfor(int h=0;h<=1;++h){\n\t\t\tdp[h][i][go[i][h]]=1;\n\t\t}\n\t}\n\t\n\tfor(bool flag=1;flag;){\n\t\tflag=0;\n\t\tfor(int i=1;i<=n;++i) flag|=sol(i);\n\t}\n\tfor(int i=2;i\n//#include \n//#include //\"cout<//\"reverse(s's it,s's it)\"\n//#include //\"greater\" \"sort(a,a+n,greater());\"\"\n//#include //\"abs\" \"sqrt\"\n//#include //\"accumulate(inputit,inputit,init,(optional) object)\"\n//#include //\"lower_bound(it,it,v)\" \"next_permutation(a,a+n)\"\n//\"reverse(v's it,v's it)\"(v: vector)\nusing namespace std;\n#define pb push_back//also for STRING\n#define fi first\n#define sc second\n#define mp make_pair\n#define is insert\n#define ps push//TMP//stack,(priority) queue,\n#define fr front//TMP//queue//for priority, use top().\ntypedef long long ll;//not necessarily\ntypedef pair pii;\n//Add other types in the same way.\nconst ll M=1000000007;//can be changed\nll mod(ll a){\treturn (a+M)%M;\t}//M can be a variable\nvoid plmod(ll &a,ll b){\ta=(a+b+M)%M;\treturn;\t}\nvoid mnmod(ll &a,ll b){\ta=(a-b+M)%M;\treturn;\t}\nvoid mlmod(ll &a,ll b){\ta=(a*b)%M; \treturn;\t}\n//Caution! you may need sth larger than \"+M\"!\nvoid chmax(int &a,int b){\ta=max(a,b);\treturn;\t}\nvoid chmin(int &a,int b){\ta=min(a,b);\treturn;\t}\n//These 2 could be better in long long\n\n#define MAX_N 300\n\nll c[MAX_N+1][MAX_N+1];\n\nll C(int x,int y){\n\tif(x>=y) return c[x][y];\n\telse return 0;\n}\n\nint main(){\n\tint n,a[MAX_N];\n\tll dp[2][MAX_N],fact[MAX_N];\n\tscanf(\"%d\",&n);\n\tfact[0]=1;\n\tfor(int i=1;i<=n;++i) fact[i]=mod(fact[i-1]*(ll)i);\n\tc[0][0]=1;\n\tfor(int i=0;i<=n;++i){\n\t\tc[i+1][0]=1;\n\t\tc[i+1][i+1]=1;\n\t\tfor(int j=1;j<=i;++j) c[i+1][j]=mod(c[i][j-1]+c[i][j]);\n\t}\n\tfor(int i=0;i v;\n\tbool f[MAX_N];\n\tfill(f,f+n,false);\n\tfor(int i=0;i\n#else\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#endif\n\nusing namespace std;\n\n#ifndef CPPELEVEN\n#ifdef USETR1\n#include \n#include \nusing namespace tr1;\n#endif\n#else\n#include \n#include \n#endif\n\n#ifdef USEPB_DS\n#include \n#include \n#include \nusing namespace __gnu_pbds;\n// binomial_heap_tag, rc_binomial_heap_tag, thin_heap_tag, binary_heap_tag\ntypedef __gnu_pbds::priority_queue, pairing_heap_tag> pq_type;\n// splay_tree_tag, ov_tree_tag\ntypedef tree , rb_tree_tag, tree_order_statistics_node_update> tree_type;\n#endif\n\n#define mpr make_pair\ntypedef unsigned int ui;\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vd;\ntypedef vector vs;\ntypedef map mpsi;\ntypedef map mpdi;\ntypedef map mpii;\n\nconst double pi = acos(0.0) * 2.0;\nconst long double eps = 1e-10;\nconst int step[8][2] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 1 }, {\n\t\t1, 1 }, { 1, -1 }, { -1, -1 } };\n\ntemplate inline T abs1(T a) {\n\treturn a < 0 ? -a : a;\n}\n\n#ifndef CPPELEVEN\ntemplate inline T max1(T a, T b) { return b < a ? a : b; }\ntemplate inline T max1(T a, T b, T c) { return max1(max1(a, b), c); }\ntemplate inline T max1(T a, T b, T c, T d) { return max1(max1(a, b, c), d); }\ntemplate inline T max1(T a, T b, T c, T d, T e) { return max1(max1(a, b, c, d), e); }\ntemplate inline T min1(T a, T b) { return a < b ? a : b; }\ntemplate inline T min1(T a, T b, T c) { return min1(min1(a, b), c); }\ntemplate inline T min1(T a, T b, T c, T d) { return min1(min1(a, b, c), d); }\ntemplate inline T min1(T a, T b, T c, T d, T e) { return min1(min1(a, b, c, d), e); }\n#else\ntemplate\nt min1(t a, t1 b) {\n\treturn a < b ? a : b;\n}\ntemplate\nt min1(t a, arg ... arr) {\n\treturn min1(a, min1(arr...));\n}\ntemplate\nt max1(t a, t1 b) {\n\treturn a > b ? a : b;\n}\ntemplate\nt max1(t a, arg ... arr) {\n\treturn max1(a, max1(arr...));\n}\n#endif\n\ninline int jud(double a, double b) {\n\tif (abs(a) < eps && abs(b) < eps)\n\t\treturn 0;\n\telse if (abs1(a - b) / max(abs1(a), abs1(b)) < eps) return 0;\n\tif (a < b) return -1;\n\treturn 1;\n}\ntemplate inline int jud(t a, t b) {\n\tif (a < b) return -1;\n\tif (a == b) return 0;\n\treturn 1;\n}\n\n// f_lb == 1\u4ee3\u8868\u8fd4\u56de\u76f8\u540c\u7684\u4e00\u4e32\u7684\u5de6\u8fb9\u754c\uff0cf_small == 1\u4ee3\u8868\u8fd4\u56de\u5982\u679c\u6ca1\u6709\u5bfb\u627e\u7684\u503c\u8fd4\u56de\u5c0f\u7684\u6570\ntemplate\ninline int RangeFind(t1 val, it a, int na, bool f_small = 1, bool f_lb = 1) {\n\tif (na == 0) return 0;\n\tint be = 0, en = na - 1;\n\tif (*a <= *(a + na - 1)) {\n\t\tif (f_lb == 0)\n\t\t\twhile (be < en) {\n\t\t\t\tint mid = (be + en + 1) / 2;\n\t\t\t\tif (jud(*(a + mid), val) != 1)\n\t\t\t\t\tbe = mid;\n\t\t\t\telse\n\t\t\t\t\ten = mid - 1;\n\t\t\t}\n\t\telse\n\t\t\twhile (be < en) {\n\t\t\t\tint mid = (be + en) / 2;\n\t\t\t\tif (jud(*(a + mid), val) != -1)\n\t\t\t\t\ten = mid;\n\t\t\t\telse\n\t\t\t\t\tbe = mid + 1;\n\t\t\t}\n\t\tif (f_small && jud(*(a + be), val) == 1) be--;\n\t\tif (!f_small && jud(*(a + be), val) == -1) be++;\n\t} else {\n\t\tif (f_lb)\n\t\t\twhile (be < en) {\n\t\t\t\tint mid = (be + en + 1) / 2;\n\t\t\t\tif (jud(*(a + mid), val) != -1)\n\t\t\t\t\tbe = mid;\n\t\t\t\telse\n\t\t\t\t\ten = mid - 1;\n\t\t\t}\n\t\telse\n\t\t\twhile (be < en) {\n\t\t\t\tint mid = (be + en) / 2;\n\t\t\t\tif (jud(*(a + mid), val) != 1)\n\t\t\t\t\ten = mid;\n\t\t\t\telse\n\t\t\t\t\tbe = mid + 1;\n\t\t\t}\n\t\tif (!f_small && jud(*(a + be), val) == -1) be--;\n\t\tif (f_small && jud(*(a + be), val) == 1) be++;\n\t}\n\treturn be;\n}\n\ntemplate inline T lowb(T num) {\n\treturn num & (-num);\n}\n#ifdef GPP\ninline int bitnum(ui nValue) {\n\treturn __builtin_popcount(nValue);\n}\ninline int bitnum(int nValue) {\n\treturn __builtin_popcount(nValue);\n}\ninline int bitnum(ull nValue) {\n\treturn __builtin_popcountll(nValue);\n}\ninline int bitnum(ll nValue) {\n\treturn __builtin_popcountll(nValue);\n}\ninline int bitmaxl(ui a) {\n\tif (a == 0) return 0;\n\treturn 32 - __builtin_clz(a);\n}\ninline int bitmaxl(int a) {\n\tif (a == 0) return 0;\n\treturn 32 - __builtin_clz(a);\n}\ninline int bitmaxl(ull a) {\n\tif (a == 0) return 0;\n\treturn 64 - __builtin_clzll(a);\n}\ninline int bitmaxl(ll a) {\n\tif (a == 0) return 0;\n\treturn 64 - __builtin_clzll(a);\n}\n#else\n#endif\n\nlong long pow(long long n, long long m, long long mod = 0) {\n\tif (m < 0) return 0;\n\tlong long ans = 1;\n\tlong long k = n;\n\twhile (m) {\n\t\tif (m & 1) {\n\t\t\tans *= k;\n\t\t\tif (mod) ans %= mod;\n\t\t}\n\t\tk *= k;\n\t\tif (mod) k %= mod;\n\t\tm >>= 1;\n\t}\n\treturn ans;\n}\n\n#define MOD 1000000007\ntemplate\ninline void add(t1 &a, t2 b, int mod = -1) {\n\tif (mod == -1) mod = MOD;\n\ta += b;\n\twhile (a >= mod)\n\t\ta -= mod;\n\twhile (a < 0)\n\t\ta += mod;\n}\ntemplate\nvoid output1(t arr) {\n\tfor (int i = 0; i < (int) arr.size(); i++)\n\t\tcerr << arr[i] << ' ';\n\tcerr << endl;\n}\ntemplate\nvoid output2(t arr) {\n\tfor (int i = 0; i < (int) arr.size(); i++)\n\t\toutput1(arr[i]);\n}\n\n//....................\u5bc6..........\u5c01..........\u7ebf..........\u4e0b..........\u7981..........\u6b62..........hack...............................................\n\nconst int mod = 998244353;\nconst int maxn = 2001000;\nll fac[maxn], invfac[maxn];\nint n, m;\n\nll c(int a, int b) {\n\tif (b > a) return 0;\n\treturn fac[a] * invfac[b] % mod * invfac[a - b] % mod;\n}\n\nll GetB(int n, int a) {\n\treturn c(n - a + m - 1, m - 1) * c(n + m, a) % mod * fac[a] % mod * fac[n - a] % mod *\n\t\t\tpow(c(n + m, m) * fac[n] % mod, mod - 2, mod) % mod;\n}\n\nll GetAll() {\n\tll ans = 0, multi = 1;\n\tfor (int i = 0; i <= n; i++) {\n\t\tans += m * pow(n + m - i, mod - 2, mod) % mod * multi % mod * (i + 1) % mod;\n\t\tmulti = multi * (n - i) % mod * pow(n + m - i, mod - 2, mod) % mod;\n\t}\n\treturn ans;\n}\n\nint main() {\n\n//............................\u4e0d\u8981\u518d\u5fd8\u4e86\u68c0\u67e5maxn\u5927\u5c0f\u4e86\uff01\uff01\uff01\uff01BSBandme\u4f60\u4e2aSB\uff01\uff01\uff01\uff01...................................................\n\n\tios_base::sync_with_stdio(0);\n#ifdef DEBUG //......................................................................................................\n\tfreopen(\"input.txt\", \"r\", stdin);\n#endif //...........................................................................................................\n\n\tscanf(\"%d%d\", &n, &m);\n\tfac[0] = 1;\n\tfor (int i = 1; i < maxn; i++) {\n\t\tfac[i] = fac[i - 1] * i % mod;\n\t}\n\tinvfac[maxn - 1] = pow(fac[maxn - 1], mod - 2, mod);\n\tfor (int j = maxn - 2; j >= 0; j--) {\n\t\tinvfac[j] = invfac[j + 1] * (j + 1) % mod;\n\t}\n\n\tll ans = 0;\n\tfor (int i = n - 1; i >= 0; i--) {\n\t\tll flag = 1;\n\t\tif ((i - (n - 1)) % 2) flag = mod - 1;\n\t\tans += flag * c(n, i) % mod * pow((mod + 1 - GetB(n, i)) % mod, mod - 2, mod);\n\t\tans %= mod;\n\t}\n\tcout << ans * GetAll() % mod << endl;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b0dd26bc47a61e05e78b83f6dfef16d2", "src_uid": "9f2b59df7bef2aeee0ce71facd2b1613", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\nusing namespace std;\r\n\r\ntypedef long long int ll;\r\n\r\nstring s;\r\nll n = 16;\r\n\r\n\r\nvector w;\r\nvector z;\r\n\r\nvector> le;\r\n\r\nvoid merge(ll l, ll r, stringstream& ss) {\r\n if (r - l <= 1) {\r\n return;\r\n }\r\n\r\n ll m = (l + r) / 2;\r\n merge(l, m, ss);\r\n merge(m, r, ss);\r\n\r\n ll i = l;\r\n ll j = m;\r\n\r\n vector c;\r\n\r\n while (i < m && j < r) {\r\n if (w[i] < w[j]) {\r\n ss << 0;\r\n c.push_back(w[i]);\r\n i += 1;\r\n } else {\r\n ss << 1;\r\n c.push_back(w[j]);\r\n j += 1;\r\n }\r\n }\r\n\r\n while (i < m) {\r\n c.push_back(w[i]);\r\n i += 1;\r\n }\r\n\r\n while (j < r) {\r\n c.push_back(w[j]);\r\n j += 1;\r\n }\r\n\r\n for (ll i = l; i < r; i++) {\r\n w[i] = c[i - l];\r\n }\r\n\r\n return;\r\n}\r\n\r\nbool match(ll l, ll r, ll& k) {\r\n if (r - l <= 1) {\r\n return true;\r\n }\r\n\r\n ll m = (l + r) / 2;\r\n match(l, m, k);\r\n match(m, r, k);\r\n\r\n ll i = l;\r\n ll j = m;\r\n\r\n vector c;\r\n\r\n while (i < m && j < r && k < s.size()) {\r\n if (s[k++] == '0') {\r\n le.push_back({z[i], z[j]});\r\n c.push_back(z[i]);\r\n i += 1;\r\n } else {\r\n le.push_back({z[j], z[i]});\r\n c.push_back(z[j]);\r\n j += 1;\r\n }\r\n }\r\n\r\n bool res = i >= m || j >= r;\r\n\r\n while (i < m) {\r\n c.push_back(z[i]);\r\n i += 1;\r\n }\r\n\r\n while (j < r) {\r\n c.push_back(z[j]);\r\n j += 1;\r\n }\r\n\r\n for (ll i = l; i < r; i++) {\r\n z[i] = c[i - l];\r\n }\r\n\r\n return res;\r\n}\r\n\r\nvector gen_ans() {\r\n vector> e(n);\r\n vector> g(n);\r\n\r\n for (auto [u, v] : le) {\r\n e[u].insert(v);\r\n g[v].insert(u);\r\n }\r\n\r\n vector a(n);\r\n ll b = 1;\r\n\r\n vector q;\r\n for (ll i = 0; i < n; i++) {\r\n if (!g[i].empty()) {\r\n continue;\r\n }\r\n q.push_back(i);\r\n }\r\n\r\n for (ll i = 0; i < q.size(); i++) {\r\n ll u = q[i];\r\n a[u] = b++;\r\n\r\n for (auto v : e[u]) {\r\n g[v].erase(u);\r\n if (!g[v].empty()) {\r\n continue;\r\n }\r\n q.push_back(v);\r\n }\r\n }\r\n\r\n return a;\r\n}\r\n\r\nll ask(ll x) {\r\n n = x;\r\n le = vector>();\r\n z = vector(n);\r\n\r\n ll k = 0;\r\n for (ll i = 0; i < n; i++) {\r\n z[i] = i;\r\n }\r\n\r\n bool succ = match(0, n, k);\r\n ll res = 0;\r\n if (!succ) {\r\n res = 1;\r\n } else if (k < s.size()) {\r\n res = -1;\r\n }\r\n\r\n return res;\r\n}\r\n\r\nll bin(ll l, ll r) {\r\n while (r - l > 1) {\r\n ll m = (l + r) / 2;\r\n ll res = ask(m);\r\n\r\n if (!res) {\r\n return m;\r\n }\r\n\r\n if (res > 0) {\r\n r = m;\r\n } else {\r\n l = m;\r\n }\r\n }\r\n\r\n return -1;\r\n}\r\n\r\nint main() {\r\n if (false) {\r\n ll n = 100'000;\r\n w = vector(n);\r\n\r\n if (true) {\r\n for (ll i = 0; i < n; i++) {\r\n w[i] = i;\r\n }\r\n\r\n srand(time(0));\r\n for (ll tt = 0; tt < 1'000; tt++) {\r\n ll i = rand() % n;\r\n ll j = rand() % n;\r\n\r\n swap(w[i], w[j]);\r\n }\r\n } else {\r\n // w = {1, 17, 19, 12, 18, 20, 15, 14, 16, 13, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };\r\n w = {19, 16, 1, 15, 17, 12, 14, 18, 13, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };\r\n n = w.size();\r\n }\r\n\r\n stringstream ss;\r\n merge(0, n, ss);\r\n s = ss.str();\r\n cerr << ss.str() << endl;\r\n\r\n// stringstream ts;\r\n// for (auto e : w) {\r\n// ts << e << \" \";\r\n// }\r\n// cerr << ts.str() << endl;\r\n// return 0;\r\n } else {\r\n cin >> s;\r\n }\r\n\r\n// s = \"10011010010010011100010\";\r\n\r\n vector a;\r\n\r\n if (false) {\r\n for (ll tt = 2; tt <= 1'000; tt++) {\r\n n = tt;\r\n le = vector>();\r\n z = vector(n);\r\n\r\n ll k = 0;\r\n for (ll i = 0; i < n; i++) {\r\n z[i] = i;\r\n }\r\n bool succ = match(0, n, k);\r\n ll res = 0;\r\n if (!succ) {\r\n res = 1;\r\n } else if (k < s.size()) {\r\n res = -1;\r\n }\r\n cerr << n << \": \" << res << endl;\r\n if (succ && s.size() == k) {\r\n a = gen_ans();\r\n }\r\n }\r\n } else {\r\n ll x = bin(2, 100'000 + 1);\r\n ask(x);\r\n a = gen_ans();\r\n }\r\n\r\n\r\n stringstream ss;\r\n ss << a.size() << endl;\r\n for (auto e : a) {\r\n ss << e << \" \";\r\n }\r\n cout << ss.str() << endl;\r\n\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "513aa51a81ace4f2a30855db49d3e128", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8", "difficulty": -1.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint pos[22];\ndouble score[22][2];\n\nint n,Nfire,Nelec,Nice;\nint Rfire,Relec,Rice;\nint DamFire,DamElec;\n\nint lower,upper;\ndouble ret = 0;\n\ndouble scoring(vector< pair > v,int cord,int typ) {\n double low,high;\n if (!typ) {\n low = cord - sqrt(Rfire * Rfire - 1);\n high = cord + sqrt(Rfire * Rfire - 1);\n }\n else {\n low = cord - sqrt(Relec * Relec - 1);\n high = cord + sqrt(Relec * Relec - 1);\n }\n v.push_back(make_pair(low,-8));\n v.push_back(make_pair(high,-8));\n sort(v.begin(),v.end());\n\n int delta = 0,able = 0;\n double ans = 0;\n for (int i = 0; i < v.size(); i++) {\n if (v[i].second != -8) delta += v[i].second;\n if (able && i) ans += (v[i].first - v[i - 1].first) * (delta + 1);\n if (v[i].second == -8) able ^= 1;\n }\n if (typ) ans *= DamElec; else ans *= DamFire;\n return ans;\n}\n\nvoid attempt2(int idx,int sofar,double get) {\n if (idx >= n && sofar == Nelec) {\n ret = max(ret,get);\n return;\n }\n if (pos[idx] == 2) attempt2(idx + 1,sofar,get); else {\n attempt2(idx + 1,sofar,get + score[idx][0]); // put a fire tower\n if (sofar < Nelec) attempt2(idx + 1,sofar + 1,get + score[idx][1]); // put an elec tower\n }\n}\n\nvoid update() {\n vector< pair > v;\n for (int i = 0; i < n; i++) if (pos[i] == 2) {\n int cord = (i < lower) ? i : i - lower;\n v.push_back(make_pair(cord - sqrt(Rice * Rice - 1),1));\n v.push_back(make_pair(cord + sqrt(Rice * Rice - 1),-1));\n }\n for (int i = 0; i < n; i++) if (pos[i] != 2) {\n int cord = (i < lower) ? i : i - lower;\n score[i][0] = scoring(v,cord,0);\n score[i][1] = scoring(v,cord,1);\n }\n attempt(0,0,0.0);\n}\n\nvoid attempt(int idx,int sofar) {\n if (idx >= n) {\n if (sofar == Nice) update();\n return;\n }\n\n attempt(idx + 1,sofar);\n if (sofar < Nice) {\n pos[idx] = 2;\n attempt(idx + 1,sofar + 1);\n pos[idx] = -1;\n }\n}\n\nint main() {\n scanf(\"%d %d %d\", &Nfire, &Nelec, &Nice);\n n = Nfire + Nelec + Nice;\n scanf(\"%d %d %d\", &Rfire, &Relec, &Rice);\n scanf(\"%d %d\", &DamFire, &DamElec);\n memset(pos,-1,sizeof(pos));\n lower = n/2; upper = n - n/2;\n attempt(0,0);\n printf(\"%.6lf\\n\", ret);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "08a6e26dafda843807433e427428bff4", "src_uid": "de5a42225714552cc5422d8a45734d58", "difficulty": 2600.0} {"lang": "MS C++", "source_code": "++++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++\n>+++++++++++>++++++++++++>+++++++++++++<<<<<<<<<<<<<-]>>>>>>>>>----------.>>\n>------.<-----.>----++++++.<<<<<<<<--------.>>>>>>>>------.+++++++.<++++.<--\n.>--------.>---.\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f53c673a4194cb2bec2b55ff2c078a42", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include \n#define MAXN 205\n#define MAXE 5005\n#define XX first\n#define YY second\n#define INF 100000000\nusing namespace std;\ntypedef pair pii;\n\nint src, snk, nNode, nEdge;\nint fin[MAXN], pre[MAXN], dist[MAXN];\nint cap[MAXE], cost[MAXE], next[MAXE], to[MAXE], from[MAXE];\n\ninline void init(int _src, int _snk, int nodes){\n memset(fin, -1, sizeof(fin));\n nNode=nodes, nEdge=0;\n src=_src, snk=_snk;\n}\n\ninline void addEdge(int u, int v, int _cap, int _cost){\n from[nEdge]=u, to[nEdge]=v, cap[nEdge]=_cap, cost[nEdge]=_cost;\n next[nEdge]=fin[u], fin[u]=nEdge++;\n from[nEdge]=v, to[nEdge]=u, cap[nEdge]=0, cost[nEdge]=-(_cost);\n next[nEdge]=fin[v], fin[v]=nEdge++;\n}\n\nbool bellman(){\n int iter, u, v, i;\n bool flag=true;\n memset(dist, 0x7f, sizeof(dist));\n memset(pre, -1, sizeof(pre));\n dist[src]=0;\n for(iter=1; iter=0; i=next[i]){\n v=to[i];\n if(cap[i] && dist[v]>dist[u]+cost[i]){\n dist[v]=dist[u]+cost[i];\n pre[v]=i;\n flag=true;\n }\n }\n }\n }\n return (dist[snk]=0; u=pre[from[u]]) bot=min(bot, cap[u]);\n for(u=pre[snk]; u>=0; u=pre[from[u]]){\n cap[u]-=bot;\n cap[u^1]+=bot;\n fcost+=bot*cost[u];\n }\n netflow+=bot;\n }\n return netflow;\n}\n\nchar str[105];\nint b[105];\nvector < pii > v;\nint main(){\n int n;\n scanf(\"%d\", &n);\n scanf(\"%s\", str);\n for(int i=0; i>1)+1, n+26+(n>>1)+2);\n for(int i=1; i<=n; i++){\n addEdge(0, i, 1, 0);\n addEdge(i, n+1+str[i-1]-'a', 1, b[i-1]);\n }\n v.push_back(pii(-1, -1));\n for(int i=0, j=n-1; ib[v[i].YY]){\n addEdge(v[i].XX+1, n+26+i, 1, 0);\n }\n else addEdge(v[i].YY+1, n+26+i, 1, 0);\n }\n addEdge(n+26+i, n+26+(n>>1)+1, 2, 0);\n }\n int cost;\n assert(mcmf(cost)==n);\n printf(\"%d\\n\", sum-cost);\n return 0;\n}\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fb74b8b9a06a2b105e309b3b760f3ca5", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include>a;\n\tif(a.size<10) cout<<\"YES\";\n\telse cout<<\"NO\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0436183d03e79ab44a8b25ea3e5dac92", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \n#define F first\n#define S second\n#define X real()\n#define Y imag()\nusing namespace std;\ntypedef long double ld;\ntypedef complex co;\nconst ld eps=1e-8;\nconst ld maxD=1e6;\nld ccw(co a, co b) {\n\treturn (b*conj(a)).Y;\n}\nint ar(co x) {\n\tif (x.Y>=0&&x.X<0) return 1;\n\tif (x.X>=0&&x.Y>0) return 2;\n\tif (x.Y<=0&&x.X>0) return 3;\n\treturn 4;\n}\nbool cp(co p1, co p2) {\n\tif (ar(p1)!=ar(p2)) return ar(p1)>ar(p2);\n\treturn ccw(p2, p1)<0;\n}\nstruct hp_t {\n\tco a, b;\n\thp_t(co p1, co p2) {\n\t\ta=p1;\n\t\tb=(p2-p1)/abs(p2-p1);\n\t}\n\tld d(co p) const {\n\t\treturn ccw(b, p-a);\n\t}\n\tbool operator<(const hp_t& o) const {\n\t\tif (abs(b-o.b) getHPI(vector hp) {\n\thp.push_back({{-maxD, -maxD}, {maxD, -maxD}});\n\thp.push_back({{maxD, -maxD}, {maxD, maxD}});\n\thp.push_back({{maxD, maxD}, {-maxD, maxD}});\n\thp.push_back({{-maxD, maxD}, {-maxD, -maxD}});\n\tsort(hp.begin(), hp.end());\n\thp.erase(unique(hp.begin(), hp.end()), hp.end());\n\tint del=0;\n\tvector p;\n\tfor (int i=1;i<(int)hp.size();i++){\n\t\twhile ((int)p.size()>del&&hp[i].d(p.back())del&&hp[i].d(p[del])-eps){\n\t\t\tp.push_back(np);\n\t\t\thp[p.size()]=hp[i];\n\t\t}\n\t}\n\trotate(p.begin(), p.begin()+del, p.end());\n\trotate(hp.begin(), hp.begin()+del, hp.begin()+p.size()+1);\n\tp.resize((int)p.size()-del);\n\tif (p.empty()) return p;\n\tp.push_back(getI(hp[0], hp[p.size()]));\n\treturn p;\n}\nbool cp2(co p1, co p2) {\n\tif (ar(p1)!=ar(p2)) return ar(p1)0;\n}\n\nvoid solve(){\n\tint n;\n\tscanf(\"%d\", &n);\n\tvector ps;\n\tint xx,yy;\n\tscanf(\"%d %d\", &xx, &yy);\n\tco x={(ld)xx, (ld)yy};\n\tfor (int i=1;i hps;\n\tfor (int i=0;i<(int)ps.size();i++){\n\t\tco t=ps[i];\n\t\tco nt=ps[(i+1)%(int)ps.size()];\n\t\tif (abs(ccw(t, nt))0){\n\t\t\thps.push_back({t+x, nt+x});\n\t\t}\n\t\telse{\n\t\t\thps.push_back({nt+x, t+x});\n\t\t}\n\t}\n\tint i2=0;\n\tfor (int i=0;i<(int)ps.size();i++){\n\t\tint ct=0;\n\t\twhile (i2==i||(ccw(ps[i], ps[i2])2*n){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (ct>2*n){\n\t\t\ti2=(i+2)%(int)ps.size();\n\t\t\tcontinue;\n\t\t}\n\t\thps.push_back({ps[i]+x, ps[i2]+x});\n\t\tint e=(i2+(int)ps.size()-1)%(int)ps.size();\n\t\tif (e!=i){\n\t\t\thps.push_back({ps[e]+x, ps[i]+x});\n\t\t}\n\t}\n\tauto it=getHPI(hps);\n\tld A=0;\n\tfor (int i=0;i<(int)it.size();i++){\n\t\tco t=it[i];\n\t\tco ne=it[(i+1)%(int)it.size()];\n\t\tA+=(t*conj(ne)).Y;\n\t}\n\tprintf(\"%.18f\\n\", (double)(abs(A)/(ld)2));\n}\n\nint main(){\n\tint tcs;\n\tscanf(\"%d\", &tcs);\n\tfor (int tc=0;tc\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define pb push_back\n#define mp make_pair\ntypedef pair pii;\ntypedef long long ll;\ntypedef double ld;\ntypedef vector vi;\n#define fi first\n#define se second\n#define fe first\n#define FO(x) {freopen(#x\".in\",\"r\",stdin);freopen(#x\".out\",\"w\",stdout);}\n#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}\n#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}\n#define es(x,e) (int e=fst[x];e;e=nxt[e])\n#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])\n#define SZ 666666\nint n,x[SZ],y[SZ];\nvector A,B; pii g;\npii operator + (pii a,pii b)\n{return pii(a.fi+b.fi,a.se+b.se);}\npii operator - (pii a,pii b)\n{return pii(a.fi-b.fi,a.se-b.se);}\nll operator * (pii a,pii b)\n{return a.fi*(ll)b.se-a.se*(ll)b.fi;}\nll len(pii x) {return x.fi*(ll)x.fi+x.se*(ll)x.se;}\nbool cmp_g(pii a,pii b)\n{\n\tif(a==g) return b!=g;\n\tif(b==g) return 0;\n\tlong double aa=atan2l(a.se-g.se,a.fi-g.fi),\n\tbb=atan2l(b.se-g.se,b.fi-g.fi);\n\tif(fabsl(aa-bb)>1e-10)\n\t return aa graham(vector v)\n{\n\tvector s; g=pii(2e9,2e9);\n\tfor(auto r:v) g=min(g,r);\n\tsort(v.begin(),v.end(),cmp_g);\n\tv.erase(unique(v.begin(),v.end()),v.end());\n\tpii st[SZ]; int sn=0;\n\tfor(auto x:v)\n\t{\n\t\twhile(sn>=2&&(x-st[sn-1])*(st[sn]-st[sn-1])>=0)\n\t\t\t--sn;\n\t\tst[++sn]=x;\n\t}\n\tfor(int i=1;i<=sn;++i)\n\t\ts.pb(st[i]);\n\treturn s;\n}\nbool in(pii a,pii b,pii c,pii z)\n{\n\treturn abs(cross(a,b,c))\n\t==abs(cross(a,b,z))\n\t+abs(cross(b,c,z))\n\t+abs(cross(a,c,z));\n}\n#define WIN {puts(\"Ani\"); return 0;}\nbool chk(pii a,pii b,pii c)\n{\n\tll t=cross(a,b,c);\n\tif(t>0) return 0;\n\tif(t==0)\n\t\treturn min(a.fi,c.fi)<=b.fi\n\t\t&&b.fi<=max(a.fi,c.fi)\n\t\t&&min(a.se,c.se)<=b.se\n\t\t&&b.se<=max(a.se,c.se);\n\treturn 1;\n}\nint nr(vector& v,pii p)\n{\n\tint n=v.size();\n\tif(n==1)\n\t{\n\t\tif(p!=v[0]) return -1;\n\t\treturn 0;\n\t}\n\tif(n==2)\n\t{\n\t\tif(min(v[0].fi,v[1].fi)<=p.fi\n\t\t&&p.fi<=max(v[0].fi,v[1].fi)\n\t\t&&min(v[0].se,v[1].se)<=p.se\n\t\t&&p.se<=max(v[0].se,v[1].se)\n\t\t&&(p-v[0])*(v[1]-v[0])==0)\n\t\t\treturn 0;\n\t\treturn -1;\n\t}\n//\tcerr<<\"QAQ\"<0) return -1;\n//\tif(cross(v[0],p,v[n-1])<0) return -1;\n//\tcerr<<\"++\\n\";\n\tint i=2,j=n-1,g=n-1;\n\twhile(i<=j)\n\t{\n\t\tint m=(i+j)>>1;\n\t\tif(cross(v[0],p,v[m])>0)\n\t\t\tg=m,j=m-1;\n\t\telse i=j+1;\n\t}\n//\tcerr<<\"--\\n\";\n\tif(!chk(v[g-1],p,v[g])) return -1;\n\treturn g;\n}\nint main()\n{\n\tscanf(\"%d\",&n);\n\tbool z=0;\n\tfor(int i=1;i<=n;++i)\n\t{\n\t\tscanf(\"%d%d\",x+i,y+i);\n\t\tz|=x[i]==0&&y[i]==0;\n\t\tif((x[i]%2==1)||(y[i]%2==1))\n\t\t\tB.pb(pii(x[i],y[i]));\n\t\telse A.pb(pii(x[i],y[i]));\n\t}\n\tif(!B.size())\n\t{\n\t\tputs(\"Borna\");\n\t\treturn 0;\n\t}\n\tif(!z) A.pb(pii(0,0));\n\tvector G=graham(A);\n\tint gn=G.size();\n\tif(G.size()<=1) WIN\n//\tfor(auto t:G)\n//\t\tcerr< eA[SZ],eB[SZ];\n\tset sG;\n\tfor(auto t:G) sG.insert(t);\n\tfor(auto t:A) if(!sG.count(t))\n\t{\n\t\tint g=nr(G,t);\n\t\tif(g==-1) throw \"GG\";\n\t\tset tc;\n\t\tfor(int j=-30;j<=30;++j)\n\t\t\ttc.insert(((g+j)%gn+gn)%gn);\n\t\tfor(int j=-30;j<=30;++j)\n\t\t\ttc.insert(((0+j)%gn+gn)%gn);\n\t\tint ww=-1;\n\t\tfor(auto w:tc)\n\t\t\tif(in(G[w],G[(w+1)%gn],G[(w+2)%gn],t))\n\t\t\t\tww=w;\n\t\tif(ww==-1) continue;\n\t\tint www=ww;\n\t\tset sc;\n\t\tsc.insert(ww);\n\t\twhile(1)\n\t\t{\n\t\t\tww=(ww+1)%gn;\n\t\t\tif(sc.count(ww)) break;\n\t\t\tif(!in(G[ww],G[(ww+1)%gn],G[(ww+2)%gn],t))\n\t\t\t\tbreak;\n\t\t\tsc.insert(ww);\n\t\t}\n\t\tww=www;\n\t\twhile(1)\n\t\t{\n\t\t\tww=(ww+gn-1)%gn;\n\t\t\tif(sc.count(ww)) break;\n\t\t\tif(!in(G[ww],G[(ww+1)%gn],G[(ww+2)%gn],t))\n\t\t\t\tbreak;\n\t\t\tsc.insert(ww);\n\t\t}\n\t\tif(sc.size()>=4) throw \"GG\";\n\t\tfor(auto w:sc)\n\t\t\teA[w].pb(t);\n\t}\n\tfor(auto t:B)\n\t{\n\t\tint g=nr(G,t);\n//\t\tcerr< tc;\n\t\tfor(int j=-30;j<=30;++j)\n\t\t\ttc.insert(((g+j)%gn+gn)%gn);\n\t\tfor(int j=-30;j<=30;++j)\n\t\t\ttc.insert(((0+j)%gn+gn)%gn);\n\t\tint ww=-1;\n\t\tfor(auto w:tc)\n\t\t\tif(in(G[w],G[(w+1)%gn],G[(w+2)%gn],t))\n\t\t\t\tww=w;\n\t\tif(ww==-1) continue;\n\t\tint www=ww;\n\t\tset sc;\n\t\tsc.insert(ww);\n\t\twhile(1)\n\t\t{\n\t\t\tww=(ww+1)%gn;\n\t\t\tif(sc.count(ww)) break;\n\t\t\tif(!in(G[ww],G[(ww+1)%gn],G[(ww+2)%gn],t))\n\t\t\t\tbreak;\n\t\t\tsc.insert(ww);\n\t\t}\n\t\tww=www;\n\t\twhile(1)\n\t\t{\n\t\t\tww=(ww+gn-1)%gn;\n\t\t\tif(sc.count(ww)) break;\n\t\t\tif(!in(G[ww],G[(ww+1)%gn],G[(ww+2)%gn],t))\n\t\t\t\tbreak;\n\t\t\tsc.insert(ww);\n\t\t}\n\t\tif(sc.size()>=4) throw \"GG\";\n\t\tfor(auto w:sc)\n\t\t\teB[w].pb(t);\n\t}\n//\tcerr<<\"++\\n\";\n\tfor(int i=0;i v;\n\t\tv.pb(G[i]); v.pb(G[(i+2)%gn]);\n\t\tfor(auto t:eA[i]) v.pb(t);\n\t\tv=graham(v);\n//\t\tcerr<\n#include \n#include \n#include \nusing namespace std;\nint main()\n{\n int k,a[100][100],i,j,s[1000],z,m,n,h;\n while(cin>>k)\n {\n for(i=1;ik)\n {\n n=z%k;\n\n s[m++]=n;\n z=z/k;\n\n\n }\n\n s[m++]=z;\n for(h=m-1;h>=0;h--)\n cout<\nint n;\nint main(){\n while(scanf(\"%d\",&n)==1)printf(\"%d\\n\",int(double(x)/2.0+0.5));\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "216a43c04291483152586b3768901735", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\n\ndouble dp[51][5001];\n\nbool check (int *f, int *s, double *p, int n, int r, double K){\n\n for(int i = n - 1; i >= 0; i--) {\n //cout << endl;\n for(int j = 0; j <= r; j++) {\n if(j + f[i] <= r) {\n dp[i][j] = p[i]*(f[i] + dp[i + 1][j + f[i]]);\n if(j + s[i] <= r)\n dp[i][j] += (1 - p[i])*(s[i] + dp[i + 1][j + s[i]]);\n else\n dp[i][j] += (1 - p[i])*(s[i] + K);\n } else {\n dp[i][j] = K;\n }\n dp[i][j] = min(dp[i][j], K);\n }\n }\n\n //cout << endl;\n if(K <= dp[0][0])\n return true;\n else\n return false;\n}\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(NULL);\n\n int n, r, *f, *s;\n double *p;\n cin >> n >> r;\n for(int j = 0; j <= r; j++) {\n dp[n][j] = 0;\n }\n f = new int[n]; s = new int [n];\n p = new double [n];\n\n for(int i = 0; i < n; i++) {\n cin >> f[i] >> s[i] >> p[i];\n p[i] /= 100;\n }\n\n double left = 0, right = 1e8;\n int count = 0;\n while(abs(left - right) / max(1, left) >= 1e-9) {\n count++;\n if(check(f, s, p, n, r, (left + right ) / 2.0)) {\n left = (left + right) / 2;\n } else {\n right = (left + right) / 2;\n }\n }\n\n cout << fixed << setprecision(10) << left << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0d4723eb2e4936796981641c38d7f6cd", "src_uid": "b461bb51eab4ff8088460c1980dacb93", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n\n#define MAXX 3000111\n\nlong long l,r,z;\nint i,j,k,ans;\nshort p;\nstd::vectorprm;\nstd::vectorto;\nshort dp[MAXX];\nbool done[MAXX];\n\nvoid dfs(long long now,char cnt)\n{\n to.push_back(now);\n for(;cnti)\n prm.push_back(i);\n }\n dfs(1,0);\n std::sort(to.begin(),to.end());\n memset(dp,0x3f,sizeof(dp));\n dp[0]=0;\n for(i=2;idp[j]+1)\n {\n dp[k]=dp[j]+1;\n if(i+dp[k]<=p)\n done[k]=true;\n }\n }\n r=std::min(r,to.back());\n for(i=std::lower_bound(to.begin(),to.end(),l)-to.begin();to[i]<=r;++i)\n if(done[i])\n ++ans;\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e4edefdedf11965a0c503145337f0bf3", "src_uid": "6d898638531e4713774bbd5d47e827bf", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "/*\n_/_/_/_/ _/_/_/_/_/ _/_/_/\n_/ _/ _/ _/ _/\n_/ _/ _/ _/ _/\n_/ _/ _/ _/ _/\n_/ _/ _/ _/ _/ _/\n_/ _/ _/ _/ _/ _/_/\n_/_/_/_/ _/_/ _/_/_/_/_/\n\n_/_/_/_/ _/ _/ _/ _/\n_/ _/ _/ _/ _/_/ _/_/\n_/ _/ _/_/ _/ _/_/ _/\n_/ _/ _/ _/ _/ _/\n_/ _/ _/_/ _/ _/\n_/ _/ _/ _/ _/ _/\n_/_/_/_/ _/ _/ _/ _/\n\n_/_/_/_/_/ _/_/_/_/_/ _/_/_/_/_/\n _/ _/ _/\n _/ _/ _/\n _/ _/ _/_/_/_/\n _/ _/ _/\n _/ _/ _/\n _/ _/_/_/_/_/ _/_/_/_/_/\n\n_/_/_/_/_/ _/_/_/_/_/ _/_/_/_/_/\n _/ _/ _/\n _/ _/ _/\n _/ _/ _/_/_/_/\n _/ _/ _/\n _/ _/ _/\n _/ _/_/_/_/_/ _/_/_/_/_/\n*/\n#include\n#define LL long long\n#define pb push_back\n#define mp make_pair\n#define pii pair\nusing namespace std;\nnamespace IO\n{\n const int sz=1<<15;\n char inbuf[sz],outbuf[sz];\n char *pinbuf=inbuf+sz;\n char *poutbuf=outbuf;\n inline char _getchar()\n {\n if (pinbuf==inbuf+sz)fread(inbuf,1,sz,stdin),pinbuf=inbuf;\n return *(pinbuf++);\n }\n inline void _putchar(char x)\n {\n if (poutbuf==outbuf+sz)fwrite(outbuf,1,sz,stdout),poutbuf=outbuf;\n *(poutbuf++)=x;\n }\n inline void flush()\n {\n if (poutbuf!=outbuf)fwrite(outbuf,1,poutbuf-outbuf,stdout),poutbuf=outbuf;\n }\n}\ninline int read(){\n\tint v=0,f=1;\n\tchar c=getchar();\n\twhile (c<'0' || c>'9'){\n\t\tif (c=='-') f=-1;\n\t\tc=getchar();\n\t}\n\twhile (c>='0' && c<='9'){\n\t\tv=v*10+c-'0';\n\t\tc=getchar();\n\t}\n\treturn v*f;\n}\nconst int Maxn=12567;\nint n,m;\nvector G[Maxn];\nint R[Maxn],F[Maxn];\nvector,int> > Ans;\nint main(){\n\tn=read();m=read();\n\tfor (int i=0;ib) swap(a,b);\n\t\tG[b].pb(a);\n\t\tR[a]++;R[b]++;\n\t}\n\tfor (int i=2;i<=n;i++){\n\t\tset S;\n\t\tint l=0,r=0;\n\t\tfor (int j=0;j0){\n\t\t\t\t\tF[x]=0;Ans.pb(mp(mp(i,x),2));t--;\n\t\t\t\t}\n\t\t\t\telse Ans.pb(mp(mp(i,x),1));\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif (t<0){\n\t\t\t\t\tF[x]=1;Ans.pb(mp(mp(i,x),0));t++;\n\t\t\t\t}\n\t\t\t\telse Ans.pb(mp(mp(i,x),1));\n\t\t\t}\n\t\t}\n\t\tR[i]+=j;\n\t}\n\tint s=0;\n\tfor (int i=1;i<=n;i++) s+=F[i];\n\tprintf(\"%d\\n\",s);\n\tfor (int i=1;i<=n;i++){\n\t\tif (F[i]){\n\t\t\tprintf(\"%d \",i);\n\t\t}\n\t}\n\tprintf(\"\\n\");\n\tfor (int i=0;i\n#include \n#include \n#include \nusing namespace std;\nconst int inf=1000000002,N=200100;\n#define mp make_pair\n#define pii pair\n#define rep(i,n) for(int i=0;i<(int)n;i++)\nint a[N],r[N],sa[N],h[N],ans[N],L[N],R[N],_l[N],_r[N],C[N],n,t,cnt,Q;\npair c[N];vector q[N];vector q1[N],q2[N];set p;\nvoid deal(int i,int w,int *a) {\n\tfor (typeof(p.end()) it=p.upper_bound(mp(h[i]+1,-1));it!=p.end();p.erase(it++)) a[it->second]=i+w;}\nint A(int x){int s=0;for(;x;x-=x&-x)s+=C[x];return s;}\nvoid M(int x){for(;x<=t;x+=x&-x)C[x]++;}\nint main() {\n\tscanf(\"%d\",&n);\n\trep(i,n) scanf(\"%d\",&a[i]);\n\trep(i,n-1) a[i]=a[i+1]-a[i],a[i+n]=-a[i];a[n-1]=-inf+1;a[(t=n+n)-1]=-inf+2;\n\trep(i,t) r[i]=a[i]+=inf;\n\tfor (int d=1;d=0;i--) {rep(j,q[i].size())p.insert(q[i][j]);deal(i,0,_l);}\n\trep(i,Q) q1[_l[i]].push_back(i),q2[_r[i]].push_back(i),L[i]=max(2*L[i]-R[i],0);\n\trep(i,t) {\n\t\trep(j,q1[i].size()) {int d=q1[i][j];ans[d]-=A(n)-A(R[d]+1)+A(L[d]);}\n\t\tM(sa[i]+1);\n\t\trep(j,q2[i].size()) {int d=q2[i][j];ans[d]+=A(n)-A(R[d]+1)+A(L[d]);}\n\t}\n\trep(i,Q) printf(\"%d\\n\",ans[i]);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "92082544162996f027de9677d7695851", "src_uid": "7f9d6c14a77ee73c401c9d9b2b6602fa", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#pragma GCC optimize(2)\n#pragma GCC optimize(3)\n \nusing namespace std;\n \ntemplate void chkmax(T &x, T y) {x = x > y ? x : y;}\ntemplate void chkmin(T &x, T y) {x = x > y ? y : x;}\n \ntypedef long long ll;\n \nconst int INF = 0x3f3f3f3f;\n \n#define DEBUG(x) std::cerr << #x << \" = \" << x << std::endl\n \ntemplate void read (T &x) {\n\tx = 0; bool f = 1; char ch;w\n\tdo {ch = getchar(); if (ch == '-') f = 0;} while (ch > '9' || ch < '0');\n\tdo {x = x * 10 + ch - '0'; ch = getchar();} while (ch >= '0' && ch <= '9');\n\tx = f ? x : -x;\n}\n \ntemplate void write (T x) {\n\tif (x < 0) x = ~x + 1, putchar ('-');\n\tif (x > 9) write (x / 10);\n\tputchar (x % 10 + '0');\n}\n \nconst int N = 4e5 + 7;\n \nint n, m, e, E, rt, mxsz, tot, sz[N], tmpH[N], head[N];\nll ans[N];\nbool vis[N];\n \nstruct EDGE {\n\tint a, b, to, nxt;\n} tmpE[N << 1], edge[N << 1];\n \nstruct Point {\n\tll x, y;\n\tPoint(ll X = 0, ll Y = 0) {\n\t\tx = X; y = Y;\n\t}\n\tfriend Point operator + (Point a, Point b) {\n\t\treturn Point(a.x + b.x, a.y + b.y);\n\t}\n\tfriend Point operator - (Point a, Point b) {\n\t\treturn Point(a.x - b.x, a.y - b.y);\n\t}\n\tfriend bool operator <= (Point a, Point b) {\n\t\treturn a.y * b.x <= a.x * b.y;\n\t}\n} stk[N*10], A[N], B[N], All[N*10];\n inline bool cmp(Point a, Point b) {\n\treturn a.x < b.x || (a.x == b.x && a.y > b.y);\n}\n \nstruct Hull {\n\tPoint *s; int T;\n\tinline void clear() {\n\t\tT = 0;\n\t}\n\tinline void push(Point a) {\n\t\ts[++T] = a;\n\t}\n\tinline void build() {\n\t\tsort(s + 1, s + T + 1, cmp);\n\t\tint top = 0;\n\t\tfor(int i = 1; i <= T; i++) {\n\t\t\tif(i > 1 && s[i].x == s[i - 1].x) continue;\n\t\t\twhile(top > 1 && (stk[top] - stk[top - 1]) <= (s[i] - stk[top - 1])) top -- ;\n\t\t\tstk[++top] = s[i];\n\t\t}\n\t\tfor(int i = 1; i <= top; i++) s[i] = stk[i];\n\t\tT = top; \n\t}\n\tinline void merge(Hull a, Hull b) {\n\t\tint i = 1, j = 1; push(a.s[1] + b.s[1]);\n\t\twhile(i < a.T || j < b.T) {\n\t\t\tif(i < a.T && (b.s[j + 1] - b.s[j]) <= (a.s[i + 1] - a.s[i])) i ++ ;\n\t\t\telse if(j < b.T && (a.s[i + 1] - a.s[i]) <= (b.s[j + 1] - b.s[j])) j ++ ;\n\t\t\tpush(a.s[i] + b.s[j]);\n\t\t}\n\t}\n\tinline void query() {\n\t\tint o = 1;\n\t\tfor(int i = 0; i < m; i++) {\n\t\t\twhile(o < T && i * s[o + 1].x + s[o + 1].y >= i * s[o].x + s[o].y) o ++ ;\n\t\t\tans[i] = i * s[o].x + s[o].y;\n\t\t}\n\t}\n} a, b, all;\n \ninline void Addedge(int u, int v, int a, int b) {\n\ttmpE[++e].to = v;\n\ttmpE[e].nxt = tmpH[u];\n\ttmpE[e].a = a;\n\ttmpE[e].b = b;\n\ttmpH[u] = e;\n}\n \ninline void addedge(int u, int v, int a, int b) {\n\tedge[++E].to = v;\n\tedge[E].nxt = head[u];\n\tedge[E].a = a;\n\tedge[E].b = b;\n\thead[u] = E;\n}\n \ninline void rebuild(int u, int f) {\n\tint ff = 0;\n\tfor(int i = tmpH[u]; i; i = tmpE[i].nxt) {\n\t\tint v = tmpE[i].to, a = tmpE[i].a, b = tmpE[i].b;\n\t\tif(v == f) continue;\n\t\tif(!ff) {\n\t\t\taddedge(u, v, a, b);\n\t\t\taddedge(v, u, a, b);\n\t\t\tff = u;\n\t\t} else {\n\t\t\tint tmp = ++tot;\n\t\t\taddedge(ff, tmp, 0, 0); addedge(tmp, ff, 0, 0);\n\t\t\taddedge(tmp, v, a, b); addedge(v, tmp, a, b);\n\t\t\tff = tmp;\n\t\t}\n\t\trebuild(v, u);\n\t}\n}\n \ninline void findroot(int u, int fa, int sum) {\n\tsz[u] = 1;\n\tfor(int i = head[u]; i; i = edge[i].nxt) {\n\t\tint v = edge[i].to;\n\t\tif(v == fa || vis[i >> 1]) continue;\n\t\tfindroot(v, u, sum); sz[u] += sz[v];\n\t\tint tmp = min(sz[v], sum - sz[v]);\n\t\tif(tmp > mxsz) mxsz = tmp, rt = i;\n\t}\n}\n \ninline void getdis(int u, int f, Hull &H, ll A, ll B) {\n\tif(u <= n) H.push(Point(A, B));\n\tfor(int i = head[u]; i; i = edge[i].nxt) {\n\t\tint v = edge[i].to, aa = edge[i].a, bb = edge[i].b;\n\t\tif(v == f || vis[i >> 1]) continue;\n\t\tgetdis(v, u, H, A + aa, B + bb);\n\t}\n}\n \ninline void divide(int u, int sum) {\n\tmxsz = -INF; rt = 0; findroot(u, 0, sum);\n\tif(mxsz == -INF) return;\n\tvis[rt >> 1] = true; a.clear(); b.clear();\n\tgetdis(edge[rt].to, 0, a, edge[rt].a, edge[rt].b);\n\tgetdis(edge[rt ^ 1].to, 0, b, 0, 0);\n\ta.push((Point)(0, 0)); b.push((Point)(0, 0));\n\ta.build(); b.build(); all.merge(a, b);\n\tint now = rt, size = sum - sz[edge[now].to];\n\tdivide(edge[now].to, sz[edge[now].to]);\n\tdivide(edge[now ^ 1].to, size);\n}\n \nint main() {\n\tall.s = All; a.s = A; b.s = B;\n\tread(n); read(m); tot = n; E = 1;\n\tfor(int i = 1, u, v, a, b; i < n; i++) {\n\t\tread(u); read(v); read(a); read(b);\n\t\tAddedge(u, v, a, b);\n\t\tAddedge(v, u, a, b);\n\t}\n\trebuild(1, 0); divide(1, tot); \n\tall.build(); all.query();\n\tfor(int i = 0; i < m; i++) printf(\"%lld \", ans[i]);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "13cf34592692b639c2e1b2f2eb5f8ccf", "src_uid": "7bccdabeb9f16ee0b4f16c37de564c31", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include \"library.h\"\nusing namespace std;\n\nint n,m;\nint tt[61][61][61];\nint agg[61][61];\nint inv[150];\nconst int mod = 1000000007;\n\nvoid solve()\n{\n for (int i = 1; i <= 140; i++) inv[i] = modInv(i, mod);\n\n re(n,m);\n\n for (int ops = 0; ops <= n; ops++) {\n int mc = ops;\n tt[ops][0][0] = 1;\n for (int cutl = 0; cutl < ops; cutl++) {\n int cut = cutl+1;\n\n for (int toto = cutl*2; toto <= ops-1; toto++) {\n long long poss = 0;\n for (int left = cutl; left <= toto-cutl; left++) {\n if (!tt[left][cutl][left]) break;\n int right = toto-left;\n long long right_poss = (2ll * agg[right][cutl+1] + tt[right][cutl][right]) % mod;\n long long bposs = (tt[left][cutl][left] * right_poss) % mod;\n poss = (bposs+poss)%mod;\n }\n\n for (int po = ops-toto-1; po >= 0; po--) {\n for (int pc = mc-cut; pc >= 0; pc--) {\n int lim = min( (mc-pc)/cut, (ops-po)/(toto+1) );\n\n int comb = (poss * 1ll * tt[ops][pc][po]) % mod;\n\n for (int hm = 1; hm <= lim; hm++) {\n int& dest = tt[ops][pc + cut*hm][po + (toto+1)*hm];\n dest = (dest + comb) % mod;\n\n comb = (comb * 1ll * (poss+hm)) % mod;\n comb = (comb * 1ll * inv[hm+1]) % mod;\n }\n }\n }\n }\n }\n\n for (int cut = ops; cut >= 0; cut--) {\n agg[ops][cut] = (tt[ops][cut][ops] + agg[ops][cut+1]) % mod;\n }\n }\n \n ps(tt[n][m-1][n]);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fe8bd4aee7c8a65e58fef1dd8bbaa3f0", "src_uid": "aca6148effff8b893c961b1ee465e4e4", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define eps 1e-8\n#define SIZE 100005\nlong long mod=1e9+7;\nint phi[SIZE];\nvoid geteular()\n{\n int i, j;\n memset(phi, 0, sizeof(phi));\n phi[1] = 1;\n for(int i = 2; i < SIZE; i++)\n {\n if(!phi[i])\n {\n for(j = i; j < SIZE; j+=i)\n {\n if(!phi[j]) phi[j] = j;\n phi[j] = phi[j] / i * (i-1);\n }\n }\n }\n}\n//\u6269\u5c55\u6b27\u51e0\u91cc\u5f97\n//ax+by=d;\n//x'=x+b/d;\n//y'=y-a/d;\n//a,b\u8981\u6c42\u975e\u8d1f!\nlong long d,x,y;\nlong long exgcd(long long a,long long b,long long &x,long long &y)\n{\n if(b==0)\n {\n x=1;\n y=0;\n return a;\n }\n else\n {\n long long ret=exgcd(b,a%b,x,y);\n long long temp=x;\n x=y;\n y=temp-a/b*y;\n return ret;\n }\n}\nlong long inv(long long n,long long mod)\n{\n d=exgcd(n,mod,x,y);\n x=(x%mod+mod)%mod;\n if(d==1)\n return x;\n return -1;//\u65e0\u9006\u5143\n}\nlong long ck[SIZE];\nint num[SIZE];\nint n,k,q;\nvoid init()\n{\n geteular();\n long long fz=1;\n long long fm=1;\n ck[k]=1;\n for(int i=k+1;i<=100000;i++)\n {\n fz=fz*i%mod;\n fm=fm*(i-k)%mod;\n ck[i]=fz*inv(fm,mod)%mod;\n }\n}\nint main()\n{\n scanf(\"%d%d%d\",&n,&k,&q);\n init();\n for(int i=0;i\nusing namespace std;\n#define int long long\n#define N 5005\nint n,m,k,dp[N][N]={{1}};\nconst int mod=998244353;\nint pown(int a,int b){\n\tint res=1,x=a%mod;\n\twhile(b)res=b&1?res*x%mod:res,x=x*x%mod,b>>=1;\n\treturn res;\n}\nsigned main(){\n\tscanf(\"%lld%lld%lld\",&n,&m,&k);\n for(int i=1;i<=k;i++)\n for(int j=1;j<=i;j++)\n dp[i][j]=(dp[i-1][j]*j+dp[i-1][j-1]*(n-j+1))%mod;\n int ans=0,cur=1,p=pown(m,mod-2);\n for(int i=0;i<=k;i++)\n ans=(ans+dp[k][i]*cur)%mod,cur=cur*p%mod;\n printf(\"%lld\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6aa32b18f2adbb0b1c2049aeeea18505", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#define max 5002\n#define md 1000000007\nchar str1[max];\nchar str2[max];\nusing namespace std;\n\nint lcs(){ \n int x,y,i,j,ans=0;\n x=strlen(str1);\n y=strlen(str2);\n int c[x+1][y+1];\n for(i=0;i<=x;i++)\n c[i][0]=0;\n for(i=0;i<=y;i++)\n c[0][i]=0;\n for(i=1;i<=x;i++){\n for(j=1;j<=y;j++){\n if(str1[i-1]==str2[j-1])\n c[i][j]=c[i-1][j-1]+1 + c[i-1][j];\n else\n c[i][j]=c[i-1][j];\n }\n }\n for(i=1;i<=y;i++) ans=(ans+c[x][i])%md;\n return ans;\n}\n\n\nint main(){\n int x,y,c;\n gets(str2);\n gets(str1);\n x=strlen(str1);\n y=strlen(str2);\n c=lcs();\n cout<>x;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f9674a7396f6a9b5f2f46fbc2f25cbdc", "src_uid": "4022f8f796d4f2b7e43a8360bf34e35f", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nstring a,b;\nint n;\nint next[1000010];\n\nvoid change()\n{\n for(int i=0;i0)\n {\n j=next[j];\n if(b[j]==b[i])\n {\n next[i+1]=j+1;\n break;\n }\n }\n }\n return;\n}\n\nvoid kmp()\n{\n int j=0;\n for(int i=0;i>a>>b;\n change();\n NEXT();\n kmp();\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e60b0d117712e8538bec9830e2342ed4", "src_uid": "85f43628bec7e9b709273c34b894df6b", "difficulty": 2500.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n\n#pragma comment(linker,\"/STACK:268435456\")\n\nint m[60][60];\nint w[60][60];\nint a[60],i,j,k,n;\n\nint main()\n{\n //freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n cin>>n;\n for (i=0;i>a[i];\n m[0][i] = a[i];\n }\n for (i=0;i>w[i][j];\n\n for (j=n;j<60;j++)\n w[i][j] = 999999;\n }\n w[n][n-1] = 0;\n for (k=0;k<300000;k++)\n {\n \n memset(m,0,sizeof(m));\n\n for (i=0;i=w[i][j])\n {\n if (k==0)\n {\n if ((j>i && m[i+1][j]+m[i][j]>=w[i+1][j]) || j==n-1)\n m[i+1][j] += m[i][j];\n else\n m[i+1][j+1] += m[i][j];\n }\n else\n {\n if ((rand()%2==0 && j>i) || j==n-1)\n m[i+1][j] += m[i][j];\n else\n m[i+1][j+1] += m[i][j];\n }\n }\n }\n }\n if (m[n][n-1]>0 || m[n][n-2]>0 || m[n][n]>0)\n {\n cout<<\"Cerealguy\";\n return 0;\n }\n /*\n for (i=0;i0 || m[n][n-2]>0 || m[n][n]>0)\n cout<<\"Cerealguy\";\n else\n cout<<\"Fat Rat\";\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dc19aecd038caa2475d886c23a86baf3", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define pb push_back\n#define mp make_pair\n#define fi first\n#define se second\n#define LL long long\n#define FOR(i,a,b) for (int i=a;i<=b;++i)\n#define FORD(i,a,b) for (int i=a;i>=b;--i)\nusing namespace std;\ntypedef pair pa;\nvoid getint(int &v){\n char ch,fu=0;\n for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());\n if(ch=='-') fu=1, ch=getchar();\n for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';\n if(fu) v=-v;\n}\nLL f[30][300010],ans,fac[300010],inv[300010];\nint n,k,MO,s,a[55],S[1000010];\nLL pw(LL x,int y){\n\tLL t=1;\n\tfor (;y;y>>=1){\n\t\tif (y&1) t=t*x%MO;\n\t\tx=x*x%MO;\n\t}\n\treturn t;\n}\nint main(){\n\tscanf(\"%d%d%d\",&n,&k,&MO);\n\tif (n%2==0) return cout<>=1;\n\t}\n\tf[0][(1<>j)&1) S[i]+=a[j+1];\n\tFOR(i,0,k-1)\n\t\tFOR(j,0,(1<=0;k=(k==0)?-1:(k-1)&j){\n\t\t\t\t\t(f[i+1][j^k]+=f[i][j]*inv[S[k]])%=MO;\n\t\t\t\t}\n\t\t\t}\n\tans=(pw(k,n)-f[k][0]*fac[n])%MO;\n\tcout<<(ans+MO)%MO<\n#define NN 300100\n#define inf 0x3f3f3f3f3f3f3f3f\nusing namespace std;\nusing INT = long long;\nusing pii = pair;\n\nint p[NN];\nINT dp[NN][2];\nint vst[NN];\nvector ans;\nint N;\nint val, flag = 1;\nvoid calc(int n){\n\tif(dp[n][0] == val){\n\t\tif(n > 2 && min(dp[n - 2][1], dp[n - 2][1]) == val - max(p[n], p[n - 1])){\n\t\t\tif(!vst[n - 1]) {\n\t\t\t\tint V = min(p[n - 1], p[n]);\n\t\t\t\tif(V) ans.push_back(n - 1);\n\t\t\t\tvst[n - 1] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tif(!val) return ;\n\t\t\t\tp[n - 1] -= V; p[n] -= V;\n\t\t\t}\n\t\t\tif(n != N) {\n\t\t\t\tif(!vst[n]) {\n\t\t\t\t\tint V = min(p[n + 1], p[n]);\n\t\t\t\t\tif(V) ans.push_back(n);\n\t\t\t\t\tvst[n] = 1;\n\t\t\t\t\tval -= V;\n\t\t\t\t\tif(!val) return ;\n\t\t\t\t\tp[n + 1] -= V; p[n] -= V;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(!vst[n - 2]){\n\t\t\t\tint V = min(p[n - 2], p[n - 1]);\n\t\t\t\tif(V) ans.push_back(n - 2);\n\t\t\t\tvst[n - 2] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tp[n - 2] -= V; p[n - 1] -= V;\n\t\t\t}\n\t\t\treturn ;\n\t\t}\n\t\tif(n > 1) {\n\t\t\tif(!vst[n - 1]) {\n\t\t\t\tint V = min(p[n - 1], p[n]);\n\t\t\t\tif(V) ans.push_back(n - 1);\n\t\t\t\tvst[n - 1] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tif(!val) return ;\n\t\t\t\tp[n - 1] -= V; p[n] -= V;\n\t\t\t}\n\t\t}\n\t\tif(n != N) {\n\t\t\tif(!vst[n]){\n\t\t\t\tint V = min(p[n + 1], p[n]);\n\t\t\t\tif(V)ans.push_back(n);\n\t\t\t\tvst[n] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tp[n + 1] -= V; p[n] -= V;\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main(){\n#ifndef ONLINE_JUDGE\n\tfreopen(\"in.in\",\"r\",stdin);\n\tfreopen(\"out.out\",\"w\",stdout);\n#endif\n\tios_base :: sync_with_stdio(0);cin.tie(0);\n\tint n;\n\tcin >> n;\n\tfor(int i = 1; i <= n; i++) cin >> p[i];\n\tfor(int i = 1; i <= n; i++) for(int j = 0; j < 2; j++) dp[i][j] = inf;\n\tdp[1][0] = p[1], dp[1][1] = 0;\n\tfor(int i = 2; i <= n; i++){\n\t\tdp[i][0] = min(dp[i - 1][1], dp[i - 1][0]) + p[i];\n\t\tif(i >= 2) dp[i][0] = min(dp[i][0], min(dp[i - 2][0], dp[i - 2][1]) + max(p[i], p[i - 1]));\n\t\tdp[i][1] = dp[i - 1][0];\n\t}\n\tval = min(dp[n][1], dp[n][0]);\n//\tfor(int i = 1; i <= n; i++) cout << dp[i][0]<<\" \"<\n#define int long long int\nusing namespace std;\n\nconst int maxN = 5e4 + 226;\n\nint N, _time[maxN][7], ct, covered, arr[maxN], narr[maxN], currentMinus[maxN];\n\nsigned main(){\n\tcin >> N;\n\tfor(int i = 0; i < N; i++){\n\t\tcin >> arr[i];\n\t}\n\tif(N % 7 == 0){\n\t\tint ans = 0;\n\t\tfor(int i = 0; i < N; i++){\t\n\t\t\tif((i % 7) == 6) continue;\n\t\t\tif((arr[i] - 1) * (N) + i < (arr[ans] - 1) * (N) + i) ans = i;\n\t\t}\n\t\tcout << ans + 1 << endl;\n\t\treturn 0;\n\t}\n\tfor(int t = 0; t < 7 * N; t++){\n\t\tif(t % 7 == 6) continue;\n\t\tcurrentMinus[t % N]++;\n\t\t_time[t % N][currentMinus[t % N]] = t;\n\t\tcout << \"_time[\" << t % N << \"][\" << currentMinus[t % N] << \"] = \" << t << endl;\n\t}\n\tfor(int i = 0; i < N; i++) _time[i][0] = +i - N;\n\tint ans = 0;\n\tint ti, ta;\n\tfor(int i = 0; i < N; i++){\n\t\t//cout << \"arr[\" << i << \"] = \" << arr[i] << endl;\n\t\t//cout << \"time[\" << i << \"][\" << arr[i] % 6 << \"] = \" << _time[i][arr[i] % 6] << endl;\n\t\t//cout << \"Time for \" << i << \": \" << arr[i] / 6 * (7 * N) + _time[i][arr[i] % 6] << endl;\n\t\tti = arr[i] / 6 * (7 * N) + _time[i][arr[i] % 6];\n\t\tif(arr[i] % 6 == 0) ti = (arr[i] - 6) / 6 * (7 * N) + _time[i][6];\n\n\t\tta = arr[ans] / 6 * (7 * N) + _time[i][arr[_ans] % 6];\n\t\tif(arr[ans] % 6 == 0) ta = (arr[ans] - 6) / 6 * (7 * N) + _time[ans][6];\n\n\t\tif(ti < ta) ans = i;\n\t}\n\tcout << ans + 1 << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c91ee51725190115e83b5327db545fbd", "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca", "difficulty": 2700.0} {"lang": "MS C++", "source_code": "#define filesfl 0\n#define consolefl 01\n#define fname \"sufpref\"\n//evgenstf - batya\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define forn(i, n) for (ll i = 0; i < n; ++ i)\n#define fornn(i, q, n) for (ll i = q; i < n; ++ i)\n#define rforn(i, n) for (ll i = n; i >= 0; i --)\n#define rfornn(i, m, n) for (ll i = m; i >= n; i --)\n\n#define endl \"\\n\"\n#define inb push_back\n#define outb pop_back\n#define X first\n#define Y second\n#define Z third\n#define mk make_pair\n#define _i \"%d\"\n#define _ll \"%I64d\"\n#define pii pair\n#define times clock() * 1.0 / CLOCKS_PER_SEC\n#define all(v) v.begin(), v.end()\n\n#define nsc(n) scanf(\"%d\", &n)\n#define nmsc(n, m) scanf(\"%d%d\", &n, &m)\n\ntypedef long double ld;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef unsigned int uint;\n\nconst ll inf = 1e9 + 5;\nconst ll linf = 5e18 + 5;\nconst ld eps = 1e-9;\n\nconst ll dd = 2e5 + 7;\nconst ll maxn = 2e3 + 10;\n\nconst ll mod = 1e9 + 7;\n\nusing namespace std;\n\nint a[dd];\nint qwe[dd];\nint used[dd];\nint timer = 1;\n\nint main() {\n\tios_base::sync_with_stdio(0);\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#else\n\tif (filesfl) {\n\t\tfreopen(\"input.txt\", \"r\", stdin);\n\t\tfreopen(\"output.txt\", \"w\", stdout);\n\t}\n\telse {\n\t\tif (!consolefl) {\n\t\t\tfreopen(fname\".in\", \"r\", stdin);\n\t\t\tfreopen(fname\".out\", \"w\", stdout);\n\t\t}\n\t}\n#endif\n\tint n, m;\n\tcin >> n >> m;\n\tforn(i, n)\n\t\tcin >> a[i];\n\tsort(a, a + n);\n\tvector > qwe;\n\tforn(j, m){\n\t\tint b, t;\n\t\tcin >> b >> t;\n\t\tqwe.inb(mk(b - t, b + t));\n\t}\n\tsort(qwe.begin(), qwe.end());\n\tint l = 0;\n\tint r = 0;\n\tset > asd, asd1;\n\tint cnt = 0;\n\tforn(i, n){\n\t\twhile (r < qwe.size() && qwe[r].X <= a[i]){\n\t\t\tasd.insert(mk(qwe[r].Y, qwe[r].X));\n\t\t\tasd1.insert(mk(qwe[r].X, qwe[r].Y));\n\t\t\tr ++;\n\t\t}\n\t\tvector > bad;\n\t\tfor (auto ind = asd.begin(); ind != asd.end(); ind ++){\n\t\t\tif (ind -> X < a[i])\n\t\t\t\tbad.inb(*ind);\n\t\t}\n\t\tforn(j, bad.size())\n\t\t\tasd.erase(bad[j]);\n\n\t\tif (asd.size()){\n\t\t\tauto qq = asd.begin();\n\t\t\tasd.erase(qq), cnt ++;\n\t\t}\n\t}\n\tcout << cnt;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e12d2e52dd1d00d51ea313e7717f9541", "src_uid": "04375596477fc65a2093554ff7b7934d", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int nmax=111000;\nlong long a,b;\nint k;\nint chia_het;\nint f[nmax];\nint dem=0;\nlong long ans;\nint giam_a(){\n long long a_old=a;\n int value=0;\n for (int cs=2;cs<=k;cs++){\n int subtract= a_old%cs;\n if (subtract>value && (a-subtract>=b)) value=subtract;\n }\n if (value==0) value=1;\n a-=value;\n dem++;\n f[dem]=value;\n return 0;\n}\nint chu_ky;\nbool ton_tai_chu_ky(){\n // dinh nghia su ton tai chu chu ky la mot do dai >=20 den 39 duoc lap lai it nhat 3 lan\n if (dem<20*3) return false;\n for (chu_ky=20;chu_ky<=300;){\n bool check_chu_ky=true;\n if (dem<3*chu_ky) break;\n for (int cs=0;csb){\n giam_a();\n ans++;\n }\n return 0;\n}\nint main() {\n cin>>a>>b>>k;\n ans=0LL;\n while (a>b){\n giam_a();\n ans++;\n //cout<b){\n solve();\n }\n cout<\nusing namespace std;\nconst int MAXN = 100005;\nusing lint = long long;\nusing pi = pair;\n\u00a0\nint n;\nstruct rect{\n\tint sx, ex, sy, ey, idx;\n}a[MAXN];\n\u00a0\nauto cmp1 = [](const rect &a, const rect &b){\n\tif(a.sx != b.sx) return a.sx < b.sx;\n\tif(a.ex != b.ex) return a.ex < b.ex;\n\treturn a.idx < b.idx;\n};\n\u00a0\nauto cmp2 = [](const rect &a, const rect &b){\n\tif(a.ex != b.ex) return a.ex < b.ex;\n\tif(a.sx != b.sx) return a.sx < b.sx;\n\treturn a.idx < b.idx;\n};\n\u00a0\nauto cmp3 = [](const rect &a, const rect &b){\n\tif(a.sy != b.sy) return a.sy < b.sy;\n\tif(a.ey != b.ey) return a.ey < b.ey;\n\treturn a.idx < b.idx;\n};\n\u00a0\nauto cmp4 = [](const rect &a, const rect &b){\n\tif(a.ey != b.ey) return a.ey < b.ey;\n\tif(a.sy != b.sy) return a.sy < b.sy;\n\treturn a.idx < b.idx;\n};\n\u00a0\nbool dfs(\nset &s0, \nset &s1, \nset &s2, \nset &s3\n){\n\tif(s0.size() == 1) return true;\n\tauto itr0 = s0.begin(); int arg0 = -1e9;\n\tauto itr1 = s1.begin(); int arg1 = 2e9;\n\tauto itr2 = s2.begin(); int arg2 = -1e9;\n\tauto itr3 = s3.begin(); int arg3 = 2e9;\n\tfor(int i = 0; i + 1 < s0.size(); i++){\n\t\targ0 = max(arg0, itr0->ex);\n\t\targ1 = min(arg1, itr1->sx);\n\t\targ2 = max(arg2, itr2->ey);\n\t\targ3 = min(arg3, itr3->sy);\n\t\titr0++; itr1++; itr2++; itr3++;\n\t\tvector split;\n\t\tif(arg0 <= itr0->sx){\n\t\t\titr0 = s0.begin();\n\t\t\tfor(int j = 0; j <= i; j++) split.push_back(*itr0++);\n\t\t}\n\t\telse if(arg1 >= itr1->ex){\n\t\t\titr1 = s1.begin();\n\t\t\tfor(int j = 0; j <= i; j++) split.push_back(*itr1++);\n\t\t}\n\t\telse if(arg2 <= itr2->sy){\n\t\t\titr2 = s2.begin();\n\t\t\tfor(int j = 0; j <= i; j++) split.push_back(*itr2++);\n\t\t}\n\t\telse if(arg3 >= itr3->ey){\n\t\t\titr3 = s3.begin();\n\t\t\tfor(int j = 0; j <= i; j++) split.push_back(*itr3++);\n\t\t}\n\t\tif(split.size()){\n\t\t\tset ss0(cmp1);\n\t\t\tset ss1(cmp2);\n\t\t\tset ss2(cmp3);\n\t\t\tset ss3(cmp4);\n\t\t\tfor(auto &i : split){\n\t\t\t\tss0.insert(i); ss1.insert(i); ss2.insert(i); ss3.insert(i);\n\t\t\t\ts0.erase(i); s1.erase(i); s2.erase(i); s3.erase(i);\n\t\t\t}\n\t\t\treturn dfs(s0, s1, s2, s3) && dfs(ss0, ss1, ss2, ss3);\n\t\t}\n\t}\n\treturn false;\n}\n\u00a0\nint main(){\n\tscanf(\"%d\",&n);\n\tfor(int i=0; i s1(cmp1);\n\tset s2(cmp2);\n\tset s3(cmp3);\n\tset s4(cmp4);\n\tfor(int i=0; i\nclock_t t=clock();\nnamespace my_std{\n\tusing namespace std;\n\t#define pii pair\n\t#define fir first\n\t#define sec second\n\t#define MP make_pair\n\t#define rep(i,x,y) for (int i=(x);i<=(y);i++)\n\t#define drep(i,x,y) for (int i=(x);i>=(y);i--)\n\t#define go(x) for (int i=head[x];i;i=edge[i].nxt)\n\t#define templ template\n\t#define sz 233\n\ttypedef long long ll;\n\ttypedef double db;\n\tmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\ttempl inline T rnd(T l,T r) {return uniform_int_distribution(l,r)(rng);}\n\ttempl inline bool chkmax(T &x,T y){return xy?x=y,1:0;}\n\ttempl inline void read(T& t)\n\t{\n\t\tt=0;char f=0,ch=getchar();double d=0.1;\n\t\twhile(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();\n\t\twhile(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();\n\t\tif(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}\n\t\tt=(f?-t:t);\n\t}\n\ttemplateinline void read(T& t,Args&... args){read(t); read(args...);}\n\tchar __sr[1<<21],__z[20];int __C=-1,__zz=0;\n\tinline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}\n\tinline void print(register int x)\n\t{\n\t\tif(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;\n\t\twhile(__z[++__zz]=x%10+48,x/=10);\n\t\twhile(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\\n';\n\t}\n\tvoid file()\n\t{\n\t\t#ifdef NTFOrz\n\t\tfreopen(\"a.in\",\"r\",stdin);\n\t\t#endif\n\t}\n\tinline void chktime()\n\t{\n\t\t#ifdef NTFOrz\n\t\tcout<<(clock()-t)/1000.0<<'\\n';\n\t\t#endif\n\t}\n\t#ifdef mod\n\tll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}\n\tll inv(ll x){return ksm(x,mod-2);}\n\t#else\n\tll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}\n\t#endif\n//\tinline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}\n}\nusing namespace my_std;\n\nconst int m=50;\n\nstruct Mat\n{\n\tdb a[m+m+3][m+m+3];\n\tMat(){memset(a,0,sizeof(a));}\n\tconst Mat operator * (const Mat &x) const \n\t{\n\t\tMat ret;\n\t\trep(i,1,m+m) rep(k,1,m+m) rep(j,1,m+m) ret.a[i][j]+=a[i][k]*x.a[k][j];\n\t\treturn ret;\n\t}\n};\n\nMat ksm(Mat x,int y)\n{\n\tMat ret; rep(i,1,m+m) ret.a[i][i]=1;\n\tfor (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;\n\treturn ret;\n}\n\nint n;db p;\ndb P[sz],pp[sz];\n\nvoid work(db *F,db *G,int n)\n{\n\tstatic db f[sz][50],g[sz][50];\n\tmemset(f,0,sizeof(f)),memset(g,0,sizeof(g));\n\trep(i,1,min(m,n+1)) f[1][i]=F[i],g[1][i]=G[i];\n\trep(i,2,n) rep(j,1,min(n-i+2,m))\n\t{\n\t\trep(k,j+1,m)\n\t\t{\n\t\t\tdb w=(j==n-i+2?pp[j]:P[j]);\n\t\t\tif (i==n) w=(j==1?p:1-p);\n\t\t\tf[i][j]+=f[i-1][k]*w;\n\t\t\tg[i][j]+=w*(g[i-1][k]+f[i-1][k]*j);\n\t\t}\n\t\tdb w;\n\t\tif (j==2) w=1-p;\n\t\telse if (j==1) w=0;\n\t\telse if (j!=n-i+2) w=pp[j];\n\t\telse w=pp[j-1]*pp[j-1];\n\t\tf[i][j]+=f[i-1][1]*w;\n\t\tg[i][j]+=w*(g[i-1][1]+f[i-1][1]*j);\n\t}\n\tdb ans=0;\n\trep(i,1,m) ans+=g[n][i];\n\tprintf(\"%.5lf\\n\",ans);\n}\n\ndb tmp1[sz],tmp2[sz],tmp3[sz],tmp4[sz],f[sz],g[sz];\nMat x,y;\n\nint main()\n{\n\tfile();\n\tread(n,p),p/=1e9;\n\tif (n==1) return printf(\"%.5lf\\n\",p+2*(1-p)),0;\n\tP[1]=p,P[2]=1-p+p*p; rep(i,3,m) P[i]=P[i-1]*P[i-1];\n\tpp[2]=1-p; rep(i,3,m) { pp[i]=pp[2]; rep(j,2,i-1) pp[i]*=P[j]; }\n\trep(i,1,min(m,n)) tmp1[i]=P[i],tmp2[i]=P[i]*i; if (n+1<=m) tmp1[n+1]=pp[n+1],tmp2[n+1]=pp[n+1]*(n+1);\n\tif (n<=200) return work(tmp1,tmp2,n),0;\n\trep(i,1,m) tmp3[i]=tmp1[i]; rep(i,1,m) tmp3[i+m]=tmp2[i];\n\trep(j,1,m)\n\t{\n\t\trep(k,j+1,m)\n\t\t{\n\t\t\tdb w=P[j];\n\t\t\tx.a[k][j]=w;\n\t\t\tx.a[k][j+m]=j*w;\n\t\t\tx.a[k+m][j+m]=w;\n//\t\t\tf[i][j]+=f[i-1][k]*w;\n//\t\t\tg[i][j]+=w*(g[i-1][k]+f[i-1][k]*j);\n\t\t}\n\t\tdb w=pp[j];\n\t\tx.a[1][j]=w;\n\t\tx.a[1][j+m]=j*w;\n\t\tx.a[1+m][j+m]=w;\n//\t\tf[i][j]+=f[i-1][1]*w;\n//\t\tg[i][j]+=w*(g[i-1][1]+f[i-1][1]*j);\n\t}\n\ty=ksm(x,n-150);\n\trep(k,1,m+m) rep(j,1,m+m) tmp4[j]+=tmp3[k]*y.a[k][j];\n\trep(i,1,m) f[i]=tmp4[i],g[i]=tmp4[i+m];\n\twork(f,g,150);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4ba5f8da31e8e093c005f30285ca6642", "src_uid": "0aaf5fefed8b572b59bfce73dbbcde66", "difficulty": 3300.0} {"lang": "GNU C++14", "source_code": "\n\n\n\n#pragma GCC optimize(\"O3\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\n//#include \n\n\n#define fi first\n#define se second\n#define th third\n\n#define en \"\\n\"\n#define sqrt(n) sqrt((long double) n)\n#define all(c) (c).begin() , (c).end()\n#define MOD 1000000007\n#define mem0(a) memset(a,0,sizeof(a))\n#define FAST() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)\n#define files(name) name!=\"\"?freopen(name\".in\",\"r\",stdin),freopen(name\".out\",\"w\",stdout):0\n#define elif else if\n#define int long long\n#define SORT(x) sort(all(x))\n#define REVERSE(x) reverse(all(x))\n\n\nusing namespace std;\n\ntemplate struct Triple { A first; B second; C third;\n bool operator<(const Triple& t) const { if (fi != t.fi) return fi < fi.st; if (se != t.se) return se < t.se; return th < t.th; } };\n\nint gcd(int a,int b){\n while (a && b)\n if (a>b) a=a%b; else b=b%a;\n return a+b;\n}\n\n\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef vector vi;\ntypedef set seti;\ntypedef long double ld;\ntypedef pair pdd;\ntypedef Triple TIII;\n\n\nconst double EPS=0.000000001;\nconst double INFD32=1000000000;\nconst ll INF64=1000000000000000000;\nconst int INF32=1000000000;\n\n#define maxN 5010\n\nint md=998244353;\n\nint arr[maxN],cnt[maxN];\n\nint ver[maxN][maxN];\n\nint A[maxN];\n\nint bp(int x,int p){\n int res=1;\n while (p) {\n if (p%2) res*=x;\n // res%=md;\n x*=x;\n //x%=md;\n p/=2;\n }\n return res;\n}\n\nint F[maxN][maxN];\n\nint f(int x,int y){\n if (x>y) return 0;\n int res=x;\n res*=A[y];\n //res%=md;\n return res;\n}\n\nint suf_sum[maxN];\n\nint pref[maxN];\n\nsigned main(void){\n ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n int n;\n cin>>n;\n for (int i=1; i<=n; ++i) A[i]=bp(i,md-2);\n for (int i=0; i>arr[i];\n cnt[arr[i]]++;\n }\n for (int i=1; i<=n; ++i)\n pref[i]=pref[i-1]+cnt[i];\n for (int i=1; i<=n; ++i){\n ver[1][i]=f(cnt[i],n);\n }\n int ans=0;\n for (int k=2; k<=n; ++k){\n for (int i=1; i<=n; ++i)\n suf_sum[i]=(suf_sum[i-1]+ver[k-1][i]);\n for (int i=n; i>0; --i){\n if (cnt[i]>1)\n ans+=F[cnt[i]-1][n-k+1]*ver[k-1][i];\n //ans%=md;\n ver[k][i]=suf_sum[i-1]*F[cnt[i]][n-k+1];\n }\n }\n cout<\n#include\n#include\nlong long s[33], w[33][9][9];\nconst int p = 1000000007;\nvoid prework(int x)\n{\n memset(w, 0, sizeof(w));\n for (int i = 0; i <= 8; i++)\n w[0][i][0] = 1;\n w[0][1][4] = 1;\n w[0][2][7] = 1;\n w[0][2][8] = 1;\n w[0][3][5] = 1;\n w[0][3][6] = 1;\n w[0][4][1] = 1;\n w[0][4][2] = 1;\n w[0][5][3] = 1;\n w[0][6][7] = 1;\n w[0][6][8] = 1;\n w[0][7][5] = 1;\n w[0][7][6] = 1;\n w[0][8][1] = 1;\n w[0][8][2] = 1;\n int i = 0;\n s[0] = 1;\n while (s[i] < x)\n {\n s[i + 1] = s[i] * 2;\n for (int j = 0; j <= 8; j++)\n for (int k = 0; k <= 8; k++)\n for (int l = 0; l <= 8; l++)\n {\n w[i + 1][j][k] += w[i][j][l] * w[i][l][k];\n w[i + 1][j][k] %= p;\n }\n i++;\n } \n \n}\nlong long work(int ss)\n{\n int i, j, k, l;\n if (ss == 1) return(0);\n else if (ss == 2) return(4);\n long long a[9][9], temp[9][9];\n for (i = 0; i <= 8; i++)\n for (j = 0; j <= 8; j++)\n a[i][j] = w[0][i][j];\n ss -= 3;\n while (ss)\n {\n i = 0;\n while (s[i + 1] <= ss) i++;\n memset(temp, 0, sizeof(temp));\n for (j = 0; j <= 8; j++)\n for (k = 0; k <= 8; k++)\n for (l = 0; l <= 8; l++)\n {\n temp[j][k] += a[j][l] * w[i][l][k];\n temp[j][k] %= p;\n }\n for (j = 0; j <= 8; j++)\n for (k = 0; k <= 8; k++)\n a[j][k] = temp[j][k];\n ss -= s[i];\n }\n long long sum = (a[0][0] * 4) % p;\n for (i = 1; i <= 8; i++)\n {\n sum += a[i][0];\n sum %= p;\n }\n return(sum);\n}\nint main()\n{\n int l, r, ml, mr;\n long long summ, sum, ans;\n scanf(\"%d %d\", &l, &r);\n prework(r);\n ml = l / 2 + 1;\n mr = (r + 1) / 2;\n summ = work(mr + 1) - work(ml);\n if summ < 0 summ += p;\n sum = work(r + 1) - work(l);\n if sum < 0 sum += p;\n sum += summ;\n if (sum % 2 != 0) sum += p;\n ans = (sum / 2) % p;\n printf(\"%ld\", ans); \n return(0);\n} \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f64b9ca4f2651f118aff344224b71a7b", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include \r\nusing namespace std;\r\n#define rep(i,a,n) for (int i=a;i=a;i--)\r\n#define pb push_back\r\n#define mp make_pair\r\n#define all(x) (x).begin(),(x).end()\r\n#define fi first\r\n#define se second\r\n#define SZ(x) ((int)(x).size())\r\ntypedef vector VI;\r\ntypedef long long ll;\r\ntypedef pair PII;\r\ntypedef double db;\r\nmt19937 mrand(random_device{}()); \r\nconst ll mod=1000000007;\r\nconst ll mod2=998244353;\r\nint rnd(int x) { return mrand() % x;}\r\nll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}\r\nll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}\r\n\r\nVI pos[10];\r\nint cnt;\r\nll pw[15],s[15];\r\nll cnt2,n;\r\nint ans;\r\nint query(int fixpre,ll val) {\r\n\tll ans=0;\r\n\trep(d,0,7) {\r\n\t\tll offset=(val-fixpre*pw[d])%mod2;\r\n\t\tif (offset<0) offset+=mod2;\r\n\t\tint p=lower_bound(all(pos[d]),mod2-offset)-pos[d].begin();\r\n\t\tans=(ans+s[d]+offset*SZ(pos[d])-mod2*(SZ(pos[d])-p))%mod;\r\n\t}\r\n\treturn ans;\r\n}\r\n\r\nvoid dfs(int val,int d) {\r\n\tint x=(cnt-val+mod2)%mod2;\r\n\tpos[d].pb(x); cnt++;\r\n\ts[d]+=x;\r\n\tif (d==6) return;\r\n\trep(i,0,10) dfs(val*10+i,d+1);\r\n}\r\n\r\nvoid dfs2(ll val) {\r\n\tif (val*1000000+999999<=n&&val*10000000>n) {\r\n\t\tans=(ans+query(val,cnt2+1))%mod;\r\n\t\tcnt2+=cnt;\r\n\t} else {\r\n\t\tcnt2++;\r\n\t\tans=(ans+((cnt2-val)%mod2+mod2)%mod2)%mod;\r\n\t\trep(i,val?0:1,10) {\r\n\t\t\tif (val*10+i<=n) dfs2(val*10+i);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nint main() {\r\n\tdfs(0,0);\r\n\trep(i,0,7) sort(all(pos[i]));\r\n\tpw[0]=1;\r\n\trep(i,1,13) pw[i]=pw[i-1]*10;\r\n\tscanf(\"%lld\",&n);\r\n\tcnt2=-1;\r\n\tdfs2(0);\r\n\tprintf(\"%d\\n\",ans);\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "08458b0fdc64d9e728603906c922b0b2", "src_uid": "2c70ae38f91ab739621a31b897b8fbf3", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include\n#define P 1000000007\n#define ll long long\n#define N 5005\nusing namespace std;\nint n,a,b,s[N],sz[N],C[N][N],Ans;char c[N];\nint to[N*N],fr[N*N],nxt[N*N],fst[N],l;\nint st[N],top,bl[N],cnt,dfn[N],low[N],clk;\nvectorp[N],v[N],e[N];\nstruct T\n{\n\tint x,y;\n}d[N];\nint cmp(T a,T b)\n{\n\treturn a.xtp;tp.clear();\n\t\t\tfor (int j=0;j=b)\n\t\t{\n\t\t\tif (i<=a)Ans+=C[i-1][b-1];\n\t\t\telse\n\t\t\t{\n\t\t\t\tint u=qry(d[i].y),v=i-1-u;\n\t\t\t\t//cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int inf=0x7fffffff;\nconst double eps=1e-10;\nconst double pi=acos(-1.0);\n//char buf[1<<15],*S=buf,*T=buf;\n//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}\ninline int read(){\n\tint x=0,f=1;char ch;ch=getchar();\n\twhile(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}\n\twhile(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}\n\tif(f)return x;else return -x;\n}\nconst int N=2e6+10;\nconst int mod=1e9+7;\nint n,a[N];\nint cnt[N],mx[N];\nint ans=1;\nbool used[N];\nint prime[N],val[N];\nvoid Lin_Sie(){\n\tused[1]=1;\n\tfor(int i=2;i=1;i--){\n \t\tif(!cnt[a[i]])cnt[a[i]]++,mx[a[i]]=1,ans=(1ll*ans*a[i])%mod;\n \t\telse{\n \t int v=--a[i];\n \t while(v!=1){\n \t\tint u=val[v],ls=0;\n \t\twhile(v%u==0)v/=u,ls++;\n \t\tif(cnt[u]\nusing namespace std;\nint main()\n{\n\tfor(int i=21;i<=50;i++)\n\t\tcout<<((min(k,25)+k)mod(2+k%3) > 0)? 1: 0<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n#pragma warning(disable:4996) \n \ntypedef long long ll;\n#define MIN(a, b) ((a)>(b)? (b): (a))\n#define MAX(a, b) ((a)<(b)? (b): (a))\n#define LINF 9223300000000000000\n#define LINF2 1223300000000000000\n#define INF 2140000000\n//const long long MOD = 1000000007;\nconst long long MOD = 998244353;\n\nusing namespace std;\n\nconst int max_comb=210000;\nvector fac(max_comb+1); //n! (mod M)\nvector ifac(max_comb+1); //k!^(-1) (mod M)\n\n\nll mpow(ll x, ll n){ //x^n(mod M)\n ll ans = 1;\n while(n != 0){\n if(n&1) ans = ans*x % MOD;\n x = x*x % MOD;\n n = n >> 1;\n }\n return ans;\n}\n\nll minv(ll x){\n return mpow( x, MOD-2 );\n}\n\n\nll comb(int a, int b){ // C(a,b) = a! * b!^(-1) * (a-b)^(-1)\n if(a == 0 && b == 0)return 1;\n if(a < b || a < 0)return 0;\n ll tmp = ifac[a-b]* ifac[b] % MOD;\n return tmp * fac[a] % MOD;\n}\n\nll perm(int a, int b){ // P(a,b) = a! * (a-b)!^(-1)\n if(b == 0)return 1;\n if(a < b || a < 0)return 0;\n ll tmp = ifac[a-b] % MOD;\n return tmp * fac[a] % MOD;\n}\n\nvoid pre_comb()\n{\n fac[0] = 1;\n ifac[0] = 1;\n for(int i = 0; i\n#include \n#include \n#define ll long long \n#define N 1000010\nusing namespace std;\nconst ll p=1000000007;\nll w[N],q[N],v[N];\nint m,k,n;\nll C(int x,int y){\nif(y>x)return 0;\nreturn w[x]*q[y]%p*q[x-y]%p;}\ninline ll A(int x,int y){\nif(y>x)return 0;\nreturn w[x]*q[x-y]%p;}\nll a(ll x,ll y){\nif(y<0)return 0;ll ans=1;\nfor(;y;x=x*x%p,y>>=1)if(y&1)ans=ans*x%p;\nreturn ans;}\nint main(){\nscanf(\"%d%d%d\",&m,&K,&n);\nint i,j,L;\nw[0]=w[1]=q[0]=q[1]=v[0]=v[1]=1;\nfor(i=2;i<=K;i++){w[i]=w[i-1]*i%p;\nv[i]=1ll*(p-p/i)*v[p%i]%p;\nq[i]=q[i-1]*v[i]%p;}\nll ans=0;\nfor(l=1;l<=k&&n+l<=m;l++){\nif(n-l>=2)(ans+=a(k,n-l-2)*(1ll*k*k%p*A(k,l)%p*A(k,l)%p-A(k,l+1)*A(k,l+1)%p+p)%p)%=p;\nelse if(n-L==1)(ans+=(1ll*k*A(k,l)%p*A(k,l)%p-A(k,l+1)*A(k-1,l)%p+p)%p)%=p;\nelse (ans+=(1ll*A(k,l-n)*A(k-(l-n),n)%p*A(k-(l-n),n)%p-A(k,l-n+2)*A(k-(l-n+2),n-1)%p*A(k-(l-n+2),n-1)%p)%p)%=p;\n}printf(\"%lld\\n\",(ans%p+p)%p);\nreturn 0;}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7ee2b98ec94d34d5619319eca12b4d58", "src_uid": "b715f0fdc83ec539eb3ae2b0371ee130", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\ntypedef pair pi;\nconst double PI=acos(-1);\n#define fi first\n#define se second\n#define mp make_pair\n#define pb push_back\n#define rep(i,a,b) for (int i=(a);i<=(b);i++)\n#define per(i,a,b) for (int i=(a);i>=(b);i--)\n#define Rep(i,a,b) for (int i=(a);i<(b);i++)\n#define Per(i,a,b) for (int i=(a);i>(b);i--)\n#define travel_set(it,a) for (set::iterator (it)=(a).begin();(it)!=(a).end();(it)++)\n#define travel_map(it,a) for (map::iterator (it)=(a).begin();(it)!=(a).end();(it)++)\n#define travel_vec(it,a) for (vector::iterator (it)=(a).begin();(it)!=(a).end();(it)++)\n#define p(x) cout << x << endl;\n#define def cout << \"find\" << endl;\n#define what_is(x) cout << #x << \" is \" << x << endl;\ntemplate T sqr(T x){return x*x;}\ntemplate T alex(T x){return (x>0)?x:-x;}\ntemplate void read(T&x){\n\tx=0;T f=1;char ch=getchar();\n\twhile ((ch<48||ch>57)&&ch!=45)ch=getchar();\n\tif (ch==45)f=-1,ch=getchar();\n\twhile (ch>=48&&ch<=57)x=x*10+ch-48,ch=getchar();\n\tx*=f;\n}\n\n//-------------------------------------------------head-------------------------------------------------\n\n#define maxn 1000005\n#define mod 1000000007\nint sum0[maxn],sum2[maxn],sum4[maxn],sum6[maxn];\nll n;\nint power(int a,int b,int p){\n\tint s=1,w=a;\n\twhile (b){\n\t\tif (b&1)s=(ll)s*w%p;\n\t\tw=(ll)w*w%p;b>>=1;\n\t}\n\treturn s;\n}\nint f(ll n){\n\tint a=n,b=n+1,c=n+2;\n\tif (a%2==0)a/=2;else if (b%2==0)b/=2;\n\tif (a%3==0)a/=3;else if (b%3==0)b/=3;else if (c%3==0)c/=3;\n\ta%=mod;b%=mod;c%=mod;return (ll)a*b%mod*c%mod;\n}\nint cnt_all_point(int sqn){\n\tint res=0;\n\trep(i,0,sqn){\n\t\t(res+=(int)sqrt(n-(ll)i*i))%=mod;\n\t}\n\treturn res;\n}\nint ans;\nint work1(int sqn){\n\tint res=0;\n\trep(i,0,sqn){\n\t\tint cnt=(int)sqrt(n-(ll)i*i);\n\t\tres=(res+(ll)i*i%mod*cnt%mod)%mod;\n\t\tres=(res+sum2[cnt])%mod;\n\t}\n\treturn res;\n}\nint work2(int sqn){\n\tint res=0;\n\trep(i,0,sqn){\n\t\tint cnt=(int)sqrt(n-(ll)i*i);\n\t\tres=(res+(ll)i*i%mod*i%mod*i%mod*cnt%mod)%mod;\n\t\tres=(res+(ll)2*i*i%mod*sum2[cnt]%mod)%mod;\n\t\tres=(res+sum4[cnt])%mod;\n\t}\n\treturn res;\n}\nint work3(int sqn){\n\tint res=0;\n\trep(i,0,sqn){\n\t\tint cnt=(int)sqrt(n-(ll)i*i);\n\t\tres=(res+(ll)i*i%mod*i%mod*i%mod*i%mod*i%mod*cnt%mod)%mod;\n\t\tres=(res+(ll)3*i*i%mod*i%mod*i%mod*sum2[cnt]%mod)%mod;\n\t\tres=(res+(ll)3*i*i%mod*sum4[cnt]%mod)%mod;\n\t\tres=(res+sum6[cnt])%mod;\n\t}\n\treturn res;\n}\nint main(){\n\tscanf(\"%lld\",&n);int sqn=(int)sqrt(n);\n// printf(\"%d\\n\",sqn);\n\tsum0[0]=sum2[0]=sum4[0]=sum6[0]=0;\n\tRep(i,1,maxn){\n\t\tsum0[i]=(sum0[i-1]+power(i,0,mod))%mod;\n\t\tsum2[i]=(sum2[i-1]+power(i,2,mod))%mod;\n\t\tsum4[i]=(sum4[i-1]+power(i,4,mod))%mod;\n\t\tsum6[i]=(sum6[i-1]+power(i,6,mod))%mod;\n// if (i<=10)printf(\"%d %d %d %d %d\\n\",i,sum0[i],sum2[i],sum4[i],sum6[i]);\n\t}\n\tint all_point=cnt_all_point(sqn);\n// printf(\"%d\\n\",all_point);\n// printf(\"%d\\n\",f(n));\n// ans=(ll)all_point*f(n)%mod;\n// printf(\"%d\\n\",ans);\n// printf(\"%d %d %d\\n\",work3(sqn),work2(sqn),work1(sqn));\n\n\tans=(ans-2*work3(sqn)%mod+mod)%mod;\n\tans=(ans+(n*3%mod+6)*work2(sqn)%mod)%mod;\n\tans=(ans-(n*3%mod+4)*work1(sqn)%mod)%mod;\n\tans=(ll)ans*power(6,mod-2,mod)%mod;\n\tans=((ll)all_point*f(n)%mod-ans+mod)%mod;\n// printf(\"%d\\n\",ans);\n\tans=(ll)ans*4%mod;ans=(ans+f(n))%mod;\n\tprintf(\"%d\\n\",ans);return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "90be072402a7d915a68c534f848dc199", "src_uid": "b9a785849e5ffadb24b58b38b1f2ee48", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n\n#define pb push_back\n#define F first\n#define S second\n#define all(x) x.begin(), x.end()\n#define debug(x) cerr << #x << \" : \" << x << '\\n'\n\nusing namespace std;\nusing namespace __gnu_pbds;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef string str;\ntypedef pair pll;\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\n\nconst ll Mod = 1000000007LL;\nconst int Maxn = 2e3 + 10;\nconst ll Inf = 2242545357980376863LL;\nconst ll Log = 30;\n\nvector G[Maxn], H[Maxn];\npll exf[Maxn * Maxn];\npll exg[Maxn * Maxn];\n\nll n, m1, m2;\n\nll neg(ll a){\n\treturn (a > n ? a - n : a + n);\n}\n\nbitset bt, vis[Maxn];\nll mk[Maxn];\nvector top;\n\nvoid DFS(ll u){\n\tmk[u] = 1;\n\tvis[u][u] = 1;\n\tfor(auto adj : G[u]){\n\t\tif(!mk[adj]) DFS(adj);\n\t\tvis[u] |= vis[adj];\n\t}\n\ttop.pb(u);\n}\n\nint com[Maxn];\n\nvoid dfs(ll u, ll c){\n\tbt |= vis[u];\n\tcom[u] = c;\n\tmk[u] = 1;\n\tfor(auto adj : H[u]){\n\t\tif(!mk[adj]) dfs(adj, c);\n\t}\n\tvis[u] |= bt;\n}\n\n\nll ans[Maxn];\n\nvoid print(){\n\tmemset(mk, 0, sizeof mk); top.clear();\n\tfor(int i = 1; i <= n + n; i++) if(!mk[i]) DFS(i);\n\t\n\treverse(all(top));\n\tmemset(mk, 0, sizeof mk);\n\tint c = 1;\n\tfor(auto x : top){\n\t\tif(!mk[x]) dfs(x, c++);\n\t}\n\t\n\tbool val = true;\n\tfor(int i = 1; i <= n; i++) val &= (com[i] != com[neg(i)]);\n\tassert(val);\n\t\n\t\n\treverse(all(top));\n\tmemset(ans, -1, sizeof ans);\n\tfor(auto x : top){\n\t\tif(ans[min(x, neg(x))] != -1) continue;\n\t\tans[min(x, neg(x))] = (x < neg(x) ? 1 : 0);\n\t}\n\t\n\tbool F = true;\n\tll u, v;\n\tfor(int i = 0; i < m1; i++){\n\t\tu = exf[i].F;\n\t\tv = exf[i].S;\n\t\tF &= ( (v > n ? 1 - ans[neg(v)] : ans[v]) || (u > n ? 1 - ans[neg(u)] : ans[u]));\n\t}\n\tassert(!F);\n\tbool G = true;\n\tfor(int i = 0; i < m2; i++){\n\t\tu = exg[i].F;\n\t\tv = exg[i].S;\n\t\tG &= ( (v > n ? 1 - ans[neg(v)] : ans[v]) || (u > n ? 1 - ans[neg(u)] : ans[u]));\n\t}\n\tassert(G);\n\tfor(int i = 1; i <= n; i++) cout << ans[i] << ' ';\n\texit(0);\n}\n\nvoid solve(){\n\tfor(int i = 0; i < Maxn; i++){\n\t\tG[i].clear();\n\t\tH[i].clear();\n\t\tvis[i] &= vis[0];\n\t}\n\tll u, v;\n\tfor(int i = 0; i < m2; i++){\n\t\tu = exg[i].F;\n\t\tv = exg[i].S;\n\t\t\n\t\tG[neg(u)].pb(v);\n\t\tG[neg(v)].pb(u);\n\t\tH[v].pb(neg(u));\n\t\tH[u].pb(neg(v));\n\t}\n\tmemset(mk, 0, sizeof mk); top.clear();\n\tfor(int i = 1; i <= n + n; i++) if(!mk[i]) DFS(i);\n\treverse(all(top));\n\t\n\tmemset(mk, 0, sizeof mk);\n\tint c = 1;\n\tfor(auto x : top){\n\t\tif(!mk[x]) bt = vis[0], dfs(x, c++);\n\t}\n\t\n\tbool val = true;\n\tfor(int i = 1; i <= n; i++) val &= (com[i] != com[neg(i)]);\n\tif(!val) return ;\n\tfor(int i = 0; i < m1; i++){\n\t\tu = exf[i].F;\n\t\tv = exf[i].S;\n\t\tif(vis[neg(u)][u] || (vis[neg(u)][v] && vis[neg(v)][u])) continue;\n\t\tif(vis[neg(v)][v] || (vis[neg(v)][u] && vis[neg(u)][v])) continue;\n\t\tG[u].pb(neg(u));\n\t\tH[neg(u)].pb(u);\n\t\t\n\t\tG[v].pb(neg(v));\n\t\tH[neg(v)].pb(v);\n\t\tprint();\n\t}\n}\n\n\nint main(){\n\tios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\tcin >> n >> m1 >> m2;\n\tll u, v;\n\tfor(int i = 0; i < m1; i++){\n\t\tcin >> u >> v;\n\t\tif(u < 0) u = n - u;\n\t\tif(v < 0) v = n - v;\n\t\texf[i] = {u, v};\n\t}\n\t\n\tfor(int i = 0; i < m2; i++){\n\t\tcin >> u >> v;\n\t\tif(u < 0) u = n - u;\n\t\tif(v < 0) v = n - v;\n\t\texg[i] = {u, v};\n\t}\n\tsolve();\n\tswap(m1, m2);\n\tswap(exf, exg);\n\tsolve();\n\tcout << \"SIMILAR\\n\";\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b7a29a1601af271ec723422213ce6e14", "src_uid": "e7f585455aaf039aa6f0f2846d818b40", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include \n#include \nusing namespace std;\ntypedef vector VI;\ntypedef vector VVI;\ntypedef long long LL;\n\n#define FOR(i,a,b) for(int i=a;i rss;\n\nvoid dfs(int n, int p) {\n\tVI& aj = adj[n];\n\tif (p != -1) aj.erase(find(aj.begin(), aj.end(), p));\n\tRS& rs = rss[n];\n\tif (aj.empty()) {\n\t\trs.wp = 1;\n\t\trs.nt = 0;\n\t\trs.np = 1;\n\t\treturn;\n\t}\n\tfor (int m : aj) dfs(m, n);\n\tVI pfx(aj.size()), sfx(aj.size());\n\tpfx[0] = 1;\n\tFOR(i,1,aj.size()) {\n\t\tRS const& rsm = rss[aj[i-1]];\n\t\tint x = rsm.nt + rsm.np;\n\t\tx %= MOD;\n\t\tpfx[i] = int((LL(pfx[i-1])*x)%MOD);\n\t}\n\tsfx[SZ(aj)-1] = 1;\n\tfor (int i = SZ(aj)-2; i >= 0; i--) {\n\t\tRS const& rsm = rss[aj[i+1]];\n\t\tint x = rsm.nt + rsm.np;\n\t\tx %= MOD;\n\t\tsfx[i] = int((LL(sfx[i+1])*x)%MOD);\n\t}\n\trs.wp = 1;\n\trs.nt = 0;\n\tLL allnp = 1;\n\tFOR(i,0,SZ(aj)) {\n\t\tRS const& rsm = rss[aj[i]];\n\t\tint x = rsm.nt + rsm.np;\n\t\trs.wp = int((LL(rs.wp) * x)%MOD);\n\t\tLL nt = rsm.wp;\n\t\tnt = (nt * pfx[i]) % MOD;\n\t\tnt = (nt * sfx[i]) % MOD;\n\t\trs.nt = int((rs.nt + nt) % MOD);\n\t\tallnp = (allnp * rsm.np) % MOD;\n\t}\n\trs.np = (rs.nt + allnp) % MOD;\n\t//printf(\"Called %d wp=%d nt=%d np=%d\\n\", n+1, rs.wp, rs.nt, rs.np);\n}\n\nint main() {\n\tscanf(\"%d\", &N);\n\tadj.resize(N);\n\tFOR(a,0,N-1) {\n\t\tint u, v;\n\t\tscanf(\"%d%d\", &u, &v); --u; --v;\n\t\tadj[u].push_back(v);\n\t\tadj[v].push_back(u);\n\t}\n\trss.resize(N);\n\tdfs(0, -1);\n\tprintf(\"%d\\n\", rss[0].np);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a5e5ebfd4807621f953bdc9e9c7c143e", "src_uid": "a40e78a7144ac2fae1890ac7598990bf", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\n#include \r\nusing namespace std;\r\nconst int INF = 1e9;\r\nint n, m;\r\nint chests[10];\r\nint keys[10];\r\nint costs[10][10];\r\nint ans = INF;\r\nstruct state {\r\n vector a;\r\n int i;\r\n int j;\r\n int r;\r\n\r\n bool operator==(const state& other)\r\n {\r\n return i == other.i && j == other.j && a == other.a;\r\n };\r\n};\r\nint convert(state tmp)\r\n{\r\n int res = 0;\r\n for (auto& e : tmp.a) {\r\n assert(e < 7);\r\n res = res * 7 + e;\r\n }\r\n assert(tmp.r < 7);\r\n res = res * 7 + tmp.j;\r\n assert(tmp.i < 7);\r\n res = res * 7 + tmp.r;\r\n assert(tmp.j < 7);\r\n res = res * 7 + tmp.i;\r\n return res;\r\n}\r\nstate convertBack(int index)\r\n{\r\n state res;\r\n res.i = index % 7;\r\n index /= 7;\r\n res.r = index % 7;\r\n index /= 7;\r\n res.j = index % 7;\r\n index /= 7;\r\n for (int i = 0; i < n; ++i) {\r\n res.a.push_back(index % 7);\r\n index /= 7;\r\n }\r\n std::reverse(res.a.begin(), res.a.end());\r\n return res;\r\n}\r\nint dp[40353607] = { 0 };\r\nint main()\r\n{\r\n cin >> n >> m;\r\n for (int i = 0; i < n; ++i) {\r\n cin >> chests[i];\r\n }\r\n for (int i = 0; i < m; ++i) {\r\n cin >> keys[i];\r\n }\r\n for (int i = 0; i < n; ++i) {\r\n for (int j = 0; j < m; ++j) {\r\n cin >> costs[i][j];\r\n }\r\n }\r\n memset(dp, 0xff, sizeof(dp));\r\n dp[0] = 0;\r\n for (int i = 0; i < 40353607; ++i) {\r\n if (dp[i] < 0)\r\n continue;\r\n state curState = convertBack(i);\r\n if (curState.j == m) {\r\n continue;\r\n }\r\n /*\r\n cout << \"fuck \";\r\n for (auto cur : curState.a)\r\n cout << cur << ' ';\r\n cout << endl;\r\n cout << curState.i << ' ' << curState.j << ' ' << curState.r << endl;\r\n */\r\n for (int flow = 0; flow < 5; ++flow) {\r\n auto nextState = curState;\r\n if (flow + curState.a[curState.i] > chests[curState.i] || flow + curState.r > keys[curState.j]) {\r\n continue;\r\n }\r\n int added = flow == 0 ? 0 : costs[curState.i][curState.j];\r\n nextState.r = flow + curState.r;\r\n nextState.a[curState.i] += flow;\r\n nextState.i++;\r\n if (nextState.i == n) {\r\n nextState.i = 0;\r\n nextState.j++;\r\n nextState.r = 0;\r\n }\r\n auto index = convert(nextState);\r\n dp[index] = (dp[index] == -1 || dp[index] > dp[i] + added) ? dp[i] + added : dp[index];\r\n auto isFinal = [&](state s) -> bool {\r\n for (int i = 0; i < s.a.size(); ++i) {\r\n if (s.a[i] != chests[i]) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n };\r\n if (isFinal(nextState)) {\r\n ans = min(ans, dp[index]);\r\n }\r\n }\r\n }\r\n if (ans == INF)\r\n cout << -1 << endl;\r\n else\r\n cout << ans << endl;\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7ad2fdbd463829e2fba856b98b57b34f", "src_uid": "4dc5dc78bda59c1ec6dd8acd6f1d7333", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define ld long double\n#define null NULL\n#define all(a) a.begin(), a.end()\n#define rall(a) a.rbegin(), a.rend()\n\nusing namespace std;\n\ntemplate void output(iterator begin, iterator end, ostream& out = cerr) {\n\twhile (begin != end) {\n\t\tout << (*begin) << \" \";\n\t\tbegin++;\n\t}\n\tout << endl;\n}\n\ntemplate void output(const T &x, ostream &out = cerr) {\n\toutput(all(x), out);\n}\n\ntemplate int chkmin(T &a, const T &b) {\n\tif (b < a) {\n\t\ta = b;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\ntemplate int chkmax(T &a, const T &b) {\n\tif (b > a) {\n\t\ta = b;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nvoid fast_io() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n}\n\nmt19937 rng(time(NULL));\n\nstruct hasher {\n\tint MOD, p = 0;\n\n\thasher(int _MOD) {\n\t\tMOD = _MOD;\n\t\twhile (p < 1000) {\n\t\t\tp = rng() % MOD;\n\t\t}\n\t}\n\n\tint n;\n\tvector deg, h;\n\n\tint mul(int a, int b) {\n\t\treturn (1LL * a * b) % MOD;\n\t}\n\n\tvoid load(vector v) {\n\t\tn = v.size();\n\t\tdeg.resize(n + 1);\n\t\th.resize(n + 1);\n\t\tdeg[0] = 1;\n\t\tfor (int i = 1; i <= n; ++i) {\n\t\t\tdeg[i] = mul(deg[i - 1], p);\n\t\t}\n\t\tfor (int i = n - 1; i >= 0; --i) {\n\t\t\th[i] = (mul(h[i + 1], p) + v[i]) % MOD;\n\t\t}\n\t}\n\n\tint get_hash(int l, int r) {\n\t\treturn (h[l] - mul(h[r + 1], deg[r - l + 1]) + MOD) % MOD;\n\t}\n};\n\nconst ll MOD1 = 1e9 + 7;\nconst ll MOD2 = 998244353;\nconst int mx = 2e5 + 228;\nint n, s[mx], r0[mx], l0[mx], zero_id[mx], zero_pos_by_id[mx];\nvector mid_data;\nhasher H1(MOD1), H2(MOD2);\n\npair get_hash(int l, int r) {\n\treturn {H1.get_hash(l, r), H2.get_hash(l, r)};\n}\n\nvoid read() {\n\tcin >> n;\n\tfor (int i = 0; i < n; ++i) {\n\t\tchar c;\n\t\tcin >> c;\n\t\ts[i] = c - '0';\n\t}\n}\n\nvoid gen_lr0() {\n\tint last_0 = -1;\n\tfor (int i = 0; i < n; ++i) {\n\t\tif (s[i] == 0) {\n\t\t\tlast_0 = i;\n\t\t}\n\t\tl0[i] = last_0;\n\t}\n\tlast_0 = n;\n\tfor (int i = n - 1; i >= 0; --i) {\n\t\tif (s[i] == 0) {\n\t\t\tlast_0 = i;\n\t\t}\n\t\tr0[i] = last_0;\n\t}\n\tfill(zero_id, zero_id + n, -1);\n\tint cur_zero = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tif (s[i] == 0) {\n\t\t\tzero_pos_by_id[cur_zero] = i;\n\t\t\tzero_id[i] = cur_zero++;\n\t\t}\n\t}\n\tfor (int i = 1; i < cur_zero; ++i) {\n\t\tmid_data.push_back((zero_pos_by_id[i] - zero_pos_by_id[i - 1] - 1) % 2);\n\t}\n\tH1.load(mid_data);\n\tH2.load(mid_data);\n}\n\nstruct data {\n\tint l, r, b1, b2;\n};\n\ndata get(int l, int r) {\n\tint left_0 = r0[l], right_0 = l0[r];\n\tif (left_0 > right_0) {\n\t\treturn {0, -2, (r - l + 1) % 2, (r - l + 1) % 2};\n\t} else {\n\t\treturn {zero_id[left_0], zero_id[right_0] - 1, (left_0 - l) % 2, (r - right_0) % 2};\n\t}\n}\n\nint equal(data a, data b) {\n\tif (a.b1 != b.b1 || a.b2 != b.b2) {\n\t\treturn 0;\n\t}\n\tif (a.r - a.l != b.r - b.l) {\n\t\treturn 0;\n\t}\n\tif (a.r - a.l == -2 || a.r - a.l == -1) {\n\t\treturn 1;\n\t}\n\treturn get_hash(a.l, a.r) == get_hash(b.l, b.r);\n}\n\nvoid process() {\n\tint q;\n\tcin >> q;\n\tfor (int i = 0; i < q; ++i) {\n\t\tint l1, r1, l2, r2, len;\n\t\tcin >> l1 >> l2 >> len;\n\t\tl1--;\n\t\tl2--;\n\t\tr1 = l1 + len - 1;\n\t\tr2 = l2 + len - 1;\n\t\tdata d1 = get(l1, r1);\n\t\tdata d2 = get(l2, r2);\n\t\tint res = equal(d1, d2);\n\t\tcout << (res ? \"Yes\" : \"No\") << \"\\n\";\n\t}\n}\n\nsigned main() {\n\tfast_io();\n\tread();\n\tgen_lr0();\n\tprocess();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "be754310f1af0cdfe10b8c3100c32348", "src_uid": "6bd41042c6a442765cd93c73d55f6189", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define endl \"\\n\"\n#define mp make_pair\n#define int long long\n#define pii pair\ninline int in(){int32_t x ; scanf(\"%d\",&x) ; return x ;}\ninline string getStr(){char ch[500001] ; scanf(\"%s\",ch) ;return ch;}\nconst int MAX_N = 2e5 + 10;\ninline int gcd( int a, int b ) { return b == 0 ? a : gcd( b, a%b ); }\nvector g[MAX_N];\nbool del[MAX_N] , forb[MAX_N] , mark[MAX_N];\nint a[MAX_N] , dp[MAX_N] , ln , vl[MAX_N] , deg[MAX_N];\nqueue Bomb ; int n , k;\ninline void BombProcess()\n{\n for (int i = 1 ; i <= n ; i ++) if (deg[i] == 1 && !forb[i]) Bomb.push(i);\n while (Bomb.size()){\n int first = Bomb.front(); Bomb.pop();\n deg[first] --;\n del[first] = true;\n int FIND = -1;\n for (auto u : g[first]){\n if (!del[u] && !forb[u]){\n FIND = u;\n break;\n }\n }\n if (FIND != -1){\n vl[FIND] += vl[first];\n deg[FIND] --;\n if (deg[FIND] == 1)\n Bomb.push(FIND);\n }\n ln = max(ln , vl[first]);\n vl[first] = 0;\n }\n}\nint cnt2 = 0 , cnt = 0;\ninline void dfs(int v , int pr){\n \n mark[v] = true;\n dp[v] = vl[v];\n int f1 = 0 , f2 = 0 ;\n for (auto u : g[v]){\n if (!forb[u] && (u - pr)){\n dfs(u , v);\n if (dp[u] > f1){\n f2 = f1;\n f1 = dp[u];\n }\n else{\n f2 = max(f2 , dp[u]);\n }\n }\n }\n if (f2 && f1) cnt2 ++ ;\n if (!pr && f2 && f1) cnt ++;\n \n ln = max(ln , dp[v] + f2 + f1);\n dp[v] += f1;\n}\ninline bool can(int low){\n ln = 0;\n for (int i = 1 ; i <= n ; i ++){\n mark[i] = 0;\n deg[i] = g[i].size();\n dp[i] = 0;\n del[i] = 0 ;\n mark[i] = 0 ;\n vl[i] = 1;\n forb[i] = (a[i] < low);\n }\n BombProcess();\n for (int i = 1 ; i <= n ; i ++)if (!mark[i] && !forb[i]) dfs(i , -1) ;\n assert(cnt == cnt2);\n return ln >= k;\n}\nint32_t main()\n{\n n = in() , k = in();\n for (int i = 0 ; i < n ; i ++) a[i + 1] = in();\n for (int i = 0 ; i < n - 1 ; i ++){\n int v = in() , u = in();\n g[v].push_back(u);\n g[u].push_back(v);\n \n }\n int l = 0 , r = (1 << 20) , best = 0 , mid;\n while (l <= r){\n mid = (l + r) >> 1;\n if (can(mid)) {best = mid ; l = mid + 1 ; continue ; }\n r = mid - 1;\n }\n cout << best << \"\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "932606593fa7724959f499d3493113d9", "src_uid": "4fb83b890e472f86045981e1743ddaac", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long LL;\nconst int mod=1e9+7;\ninline int read(){\n\tint x=0,f=1; char ch=getchar();\n\twhile(ch<'0' || ch>'9'){if(ch=='-')f=-1; ch=getchar();}\n\twhile(ch>='0' && ch<='9'){x=(x<<1)+(x<<3)+ch-'0'; ch=getchar();}\n\treturn x*f;\n}\nint K,p[3010][32],rt;\nstruct mat{\n\tint a[32][32];\n\tfriend mat operator *(mat x,mat y){\n\t\tmat z; me(z.a,0);\n\t\tfor(int i=0;i<=K;++i) for(int j=0;j<=K;++j)\n\t\t\tfor(int k=0;k<=K;++k) z.a[i][j]=(z.a[i][j]+(LL)x.a[i][k]*y.a[k][j])%mod;\n\t\treturn z;\n\t}\n}A[3010],T[35],W,I;\nLL o[110];\nmat query(int x,int d,LL k){\n\tif(o[d]==k) return A[x];\n\tint i; mat h=I;\n\tfor(i=0;i=o[d-1]){\n\t\t\tk-=o[d-1];\n\t\t\th=h*A[p[x][i]];\n\t\t}\n\t\telse{\n\t\t\tif(k)h=h*query(p[x][i],d-1,k);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn h;\n}\nint main(){\n\tint n=read(),i,j,N=1,ans=0,x; K=read();\n\tfor(i=0;i<=K;++i) I.a[i][i]=1;\n\to[0]=1,o[1]=K,A[K+1]=I;\n\tfor(i=0;i\nusing namespace std;\n#define debug(x) cerr << #x << \" \" << x << \"\\n\"\nconst long long N = 1e6 + 7, mod = 1e9 + 7, opot = 570000004;\n// #define int long long\nmap , int> m;\nvector itv[30];\nlong long p[10][10];\nint nei[10][10];\nint odwruc[30];\nint id;\nlong long dp[4 * N];\n\nvoid btrack(vector vek, int x) {\n\tif(x == 7) {\n\t\tif(vek.size() == 3) {\n\t\t\tm[vek] = id;\n\t\t\titv[id] = vek;\n\t\t\tid ++;\n\t\t}\n\t\treturn;\n\t}\n\tbtrack(vek, x + 1);\n\tvek.push_back(x);\n\tbtrack(vek, x + 1);\n}\n\nint neg(int x) {\n\tvector vek = itv[x];\n\t// for(auto x : vek) cout << x << \" \";\n\t// cout << endl;\n\tvector ret;\n\tfor(int i = 1; i <= 6; i++) {\n\t\tbool flag = true;\n\t\tfor(auto a : vek) {\n\t\t\tif(a == i) flag = false;\n\t\t}\n\t\tif(flag) ret.push_back(i);\n\t}\n\n\t// for(auto x : ret) cout << x << \" \";\n\t// cout << endl;\n\t// cout << endl;\n\n\treturn m[ret];\n}\n\nint32_t main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie();\n\tbtrack(vector(), 1);\n\n\tfor(int i = 0; i < 20; i++) {\n\t\todwruc[i] = neg(i);\n\t}\n\n\tint n;\n\tcin >> n;\n\n\tfor(int i = 1; i <= n; i++) {\n\t\tfor(int j = 1; j <= n; j++) {\n\t\t\tcin >> p[i][j];\n\t\t}\n\t}\n\n\tfor(int i = 1; i <= 6; i++) {\n\t\tfor(int j = 1; j <= 6; j++) {\n\t\t\tif(i > n || j > n) {\n\t\t\t\tif(i == j) p[i][j] = 100;\n\t\t\t\telse p[i][j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tn = 6;\n\t// for(int i = 1; i <= n; i++) {\n\t// \tfor(int j = 1; j <= n; j++) {\n\t// \t\tcout << p[i][j] << \" \";\n\t// \t}\n\t// \tcout << endl;\n\t// }\n\n\tfor(int i = 0; i < (1 << 18); i++) {\n\t\tlong long chance = 1;\n\t\tint a = 1;\n\t\tint b = 1;\n\t\tfor(int j = 0; j < 18; j++) {\n\t\t\tif(i & (1 << j)) {\n\t\t\t\tnei[a][b] = 1;\n\t\t\t\tlong long nwm = p[a][b] * opot;\n\t\t\t\tnwm %= mod;\n\t\t\t\tchance *= nwm;\n\t\t\t\tchance %= mod;\n\t\t\t} else {\n\t\t\t\tnei[a][b] = 0;\n\t\t\t\tlong long nwm = (100 - p[a][b]) * opot;\n\t\t\t\tnwm %= mod;\n\t\t\t\tchance *= nwm;\n\t\t\t\tchance %= mod;\n\t\t\t}\n\t\t\tb ++;\n\t\t\tif(b > 6) {\n\t\t\t\tb -= 6;\n\t\t\t\ta ++;\n\t\t\t}\n\t\t}\n\n\t\tvector per = {1, 2, 3};\n\n\t\tint mask = 0;\n\n\t\tdo {\n\t\t\tfor(int k = 0; k < 20; k++) {\n\t\t\t\tbool flag = true;\n\t\t\t\tfor(int j = 0; j < 3; j++) {\n\t\t\t\t\tif(nei[per[j]][itv[k][j]] == 0) flag = false;\n\t\t\t\t}\n\t\t\t\tif(flag) mask |= (1 << odwruc[k]);\n\t\t\t}\n\t\t} while(next_permutation(per.begin(), per.end()));\n\n\t\tdp[mask] += chance;\n\t\tdp[mask] %= mod;\n\t}\n\n\n\tfor(int i = 0; i < 20; i++) {\n\t\tfor(int j = (1 << 20) - 1; j >= 0; j--) {\n\t\t\tif(j & (1 << i)) {\n\t\t\t\tdp[j - (1 << i)] += dp[j];\n\t\t\t\tdp[j - (1 << i)] %= mod;\n\t\t\t}\n\t\t}\n\t}\n\tdp[0] = 0;\n\n\tlong long answer = 0;\n\n\tfor(int i = 0; i < (1 << 18); i++) {\n\t\tlong long chance = 1;\n\t\tint a = 4;\n\t\tint b = 1;\n\t\tfor(int j = 0; j < 18; j++) {\n\t\t\tif(i & (1 << j)) {\n\t\t\t\tnei[a][b] = 1;\n\t\t\t\tlong long nwm = p[a][b] * opot;\n\t\t\t\tnwm %= mod;\n\t\t\t\tchance *= nwm;\n\t\t\t\tchance %= mod;\n\t\t\t} else {\n\t\t\t\tnei[a][b] = 0;\n\t\t\t\tlong long nwm = (100 - p[a][b]) * opot;\n\t\t\t\tnwm %= mod;\n\t\t\t\tchance *= nwm;\n\t\t\t\tchance %= mod;\n\t\t\t}\n\t\t\tb ++;\n\t\t\tif(b > 6) {\n\t\t\t\tb -= 6;\n\t\t\t\ta ++;\n\t\t\t}\n\t\t}\n\n\t\tfor(int j = 4; j <= 6; j++) {\n\t\t\tfor(int k =1; k <= 6; k++) {\n\t\t\t\tif(i == 132096) {\n\t\t\t\t\t// debug(j);\n\t\t\t\t\t// debug(k);\n\t\t\t\t\t// debug(nei[j][k]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tvector per = {4, 5, 6};\n\n\t\tint mask = 0;\n\n\t\tdo {\n\t\t\tfor(int k = 0; k < 20; k++) {\n\t\t\t\tbool flag = true;\n\t\t\t\tfor(int j = 0; j < 3; j++) {\n\t\t\t\t\t// if(i == 132096 and k == 17) {\n\t\t\t\t\t// \tdebug(per[j]);\n\t\t\t\t\t// \tdebug(itv[k][j]);\n\t\t\t\t\t// \tdebug(nei[per[j]][itv[k][j]]);\n\t\t\t\t\t// }\n\t\t\t\t\tif(nei[per[j]][itv[k][j]] == 0) {\n\t\t\t\t\t\tflag = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(flag) {\n\t\t\t\t\tmask |= (1 << k);\n\t\t\t\t\t// if(i == 132096) debug(k);\n\t\t\t\t}\n\t\t\t}\n\t\t} while(next_permutation(per.begin(), per.end()));\n\n\t\t// if(dp[mask] != 0 and chance != 0) {\n\t\t// \tdebug(dp[mask]);\n\t\t// \tdebug(chance);\n\t\t// \tdebug(i);\n\t\t// \tdebug(mask);\n\t\t// }\n\n\t\tanswer += dp[mask] * chance;\n\t\tanswer %= mod;\n\t}\n\n\tcout << answer << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1023116549d6a0f052a011e490be6701", "src_uid": "906d4e49566e63fddaf8eac7384c6284", "difficulty": 3100.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint a[100005], n;\nbool cmp( int a, int b ) {\n return a > b;\n}\nint main( int argc, char *argv[] )\n{\n int i, s = 0;\n bool flag = 0;\n scanf( \"%d\", &n );\n for ( i = 0; i < n; ++i ) {\n scanf( \"%d\", a + i );\n s += a[i];\n //if ( a[i] == 0 ) flag = 1;\n }\n sort( a , a + n, cmp );\n if ( a[n-1] ) {\n puts( \"-1\" );\n return 0;\n }\n int j = s % 3;\n //printf( \"%d %d\\n\", s % 3, j );\n if ( j == 1 ) {\n for ( i = n - 1; i >= 0; --i ) {\n if ( (a[i] % 3) == 1 ) {\n a[i] = -1;\n break;\n }\n }\n if ( i < 0 ) {\n int c = 0;\n for ( i = n - 1; i >= 0; --i ) {\n if ( (a[i] % 3) == 2 ) {\n a[i] = -1;\n ++c;\n if ( c == 2 ) break;\n }\n }\n if ( c < 2 ) {\n puts( \"-1\" );\n return 0;\n }\n }\n }\n else if ( j == 2 ) {\n int t = n;\n for ( i = n - 1; i >= 0; --i ) {\n if ( (a[i] % 3) == 2 ) {\n a[i] = -1;\n break;\n }\n }\n if ( i < 0 ) {\n int c = 0;\n for ( i = n - 1; i >= 0; --i ) {\n if ( (a[i] % 3) == 1 ) {\n a[i] = -1;\n ++c;\n if ( c == 2 ) break;\n }\n }\n if ( c < 2 ) {\n puts( \"-1\" );\n return 0;\n }\n }\n }\n for ( i = 0; ((a[i]==0) || (a[i]==-1)) && (i < n); ++i );\n flag = 0;\n for ( ; i < n; ++i ) {\n if ( a[i] >= 0 ) {\n printf( \"%d\", a[i] );\n flag = 1;\n }\n }\n if ( !flag ) {\n puts( \"0\" );\n }\n return 0;\n}\n\n\u6211\u4e5f\u6539\u597d\u4e86\uff0c\n\u6731\u8f89(1241745499) 1:24:01\n#include \n#include \nint c[203], n, k[203][203], idx[203];\nbool co[203];\ninline bool done() {\n int i;\n for ( i = 1; i <= n; ++i ) {\n if ( !co[i] ) return 0;\n }\n return 1;\n}\nvoid complete( int x, int id[] ) {\n int i, kn = k[x][0];\n for ( i = 1; i <= kn; ++i ) {\n --id[k[x][i]];\n }\n}\nint deal( int s ) {\n memset( co, 0, sizeof( co ) );\n int idy[203];\n memcpy( idy, idx, sizeof( idx ) );\n int cnt = 0, i;\n do {\n bool flag = 1;\n while ( flag ) {\n flag = 0;\n for ( i = 1; i <= n; ++i ) {\n if ( c[i] == s ) {\n if ( !co[i] && !idy[i] ) {\n co[i] = 1;\n complete( i, idy );\n flag = 1;\n ++cnt;\n }\n }\n }\n }\n ++cnt;\n ++s;\n if ( s > 3 ) s = 1;\n } while ( !done() );\n return cnt - 1;\n}\nint main( int argc, char *argv[] )\n{\n int i;\n scanf( \"%d\", &n );\n for ( i = 1; i <= n; ++i ) scanf( \"%d\", c + i );\n int ki, j;\n memset( idx, 0, sizeof( idx ) );\n memset( k, 0, sizeof( k ) );\n for ( i = 1; i <= n; ++i ) {\n scanf( \"%d\", &ki );\n int t;\n for ( j = 1; j <= ki; ++j ) {\n scanf( \"%d\", &t );\n k[t][++k[t][0]] = i;\n ++idx[i];\n }\n }\n int tm, ma = 0x3f3f3f3f;\n //puts( \"##########\" );\n tm = deal( 1 );\n //printf( \"%d ++++++\\n\", tm );\n if ( ma > tm ) ma = tm;\n tm = deal( 2 );\n //printf( \"%d ########\\n\", tm );\n if ( ma > tm ) ma = tm;\n tm = deal( 3 );\n if ( ma > tm ) ma = tm;\n //printf( \"%d @@@@@@@@@\\n\", tm );\n printf( \"%d\\n\", ma );\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "86f799be7bc8c00335760ecff4fdf392", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \u3000\u3000\u3000 //STL \u901a\u7528\u7b97\u6cd5\n#include \u3000\u3000\u3000\u3000\u3000//STL \u4f4d\u96c6\u5bb9\u5668\n#include //\u5b57\u7b26\u5904\u7406\n#include \u3000\u3000\u3000\u3000 //\u5b9a\u4e49\u9519\u8bef\u7801\n#include \u3000\u3000\u3000\u3000 //\u6d6e\u70b9\u6570\u5904\u7406\n#include //\u5bf9\u5e94\u5404\u79cd\u8fd0\u7b97\u7b26\u7684\u5b8f\n#include \u3000\u3000\u3000\u3000//\u5b9a\u4e49\u5404\u79cd\u6570\u636e\u7c7b\u578b\u6700\u503c\u7684\u5e38\u91cf\n#include \u3000\u3000\u3000\u3000//\u5b9a\u4e49\u672c\u5730\u5316\u51fd\u6570\n#include \u3000\u3000\u3000\u3000\u3000//\u5b9a\u4e49\u6570\u5b66\u51fd\u6570\n#include \u3000\u3000\u3000\u3000 //\u590d\u6570\u7c7b\n#include //\u4fe1\u53f7\u673a\u5236\u652f\u6301\n#include //\u5f02\u5e38\u5904\u7406\u652f\u6301\n#include //\u4e0d\u5b9a\u53c2\u6570\u5217\u8868\u652f\u6301\n#include //\u5e38\u7528\u5e38\u91cf\n#include \u3000\u3000\u3000\u3000 //\u5b9a\u4e49\u8f93\u5165\uff0f\u8f93\u51fa\u51fd\u6570\n#include \u3000\u3000\u3000\u3000//\u5b9a\u4e49\u6742\u9879\u51fd\u6570\u53ca\u5185\u5b58\u5206\u914d\u51fd\u6570\n#include \u3000\u3000\u3000\u3000//\u5b57\u7b26\u4e32\u5904\u7406\n#include \u3000\u3000\u3000\u3000\u3000//\u5b9a\u4e49\u5173\u4e8e\u65f6\u95f4\u7684\u51fd\u6570\n#include \u3000\u3000\u3000\u3000 //\u5bbd\u5b57\u7b26\u5904\u7406\u53ca\u8f93\u5165\uff0f\u8f93\u51fa\n#include \u3000\u3000\u3000\u3000//\u5bbd\u5b57\u7b26\u5206\u7c7b\n#include \u3000\u3000\u3000\u3000\u3000 //STL \u53cc\u7aef\u961f\u5217\u5bb9\u5668\n#include \u3000\u3000\u3000 //\u5f02\u5e38\u5904\u7406\u7c7b\n#include \u3000\u3000\u3000 //\u6587\u4ef6\u8f93\u5165\uff0f\u8f93\u51fa\n#include \u3000\u3000\u3000//STL \u5b9a\u4e49\u8fd0\u7b97\u51fd\u6570\uff08\u4ee3\u66ff\u8fd0\u7b97\u7b26\uff09\n#include \u3000\u3000\u3000\u3000 //\u5b9a\u4e49\u5404\u79cd\u6570\u636e\u7c7b\u578b\u6700\u503c\u5e38\u91cf\n#include \u3000\u3000\u3000\u3000\u3000\u3000//STL \u7ebf\u6027\u5217\u8868\u5bb9\u5668\n#include //\u672c\u5730\u5316\u7279\u5b9a\u4fe1\u606f\n#include \u3000\u3000\u3000\u3000\u3000\u3000 //STL \u6620\u5c04\u5bb9\u5668\n#include //STL\u901a\u8fc7\u5206\u914d\u5668\u8fdb\u884c\u7684\u5185\u5b58\u5206\u914d\n#include //\u52a8\u6001\u5185\u5b58\u5206\u914d\n#include //STL\u5e38\u7528\u7684\u6570\u5b57\u64cd\u4f5c\n#include \u3000\u3000\u3000 //\u53c2\u6570\u5316\u8f93\u5165\uff0f\u8f93\u51fa\n#include \u3000\u3000\u3000\u3000\u3000\u3000 //\u57fa\u672c\u8f93\u5165\uff0f\u8f93\u51fa\u652f\u6301\n#include \u3000\u3000\u3000\u3000\u3000//\u8f93\u5165\uff0f\u8f93\u51fa\u7cfb\u7edf\u4f7f\u7528\u7684\u524d\u7f6e\u58f0\u660e\n#include \u3000\u3000\u3000//\u6570\u636e\u6d41\u8f93\u5165\uff0f\u8f93\u51fa\n#include \u3000\u3000\u3000\u3000 //\u57fa\u672c\u8f93\u5165\u6d41\n#include //STL\u8fed\u4ee3\u5668\n#include \u3000\u3000\u3000\u3000 //\u57fa\u672c\u8f93\u51fa\u6d41\n#include \u3000\u3000\u3000\u3000\u3000 //STL \u961f\u5217\u5bb9\u5668\n#include \u3000\u3000\u3000\u3000\u3000\u3000 //STL \u96c6\u5408\u5bb9\u5668\n#include \u3000\u3000\u3000\u3000 //\u57fa\u4e8e\u5b57\u7b26\u4e32\u7684\u6d41\n#include \u3000\u3000\u3000\u3000\u3000 //STL \u5806\u6808\u5bb9\u5668\n#include \u3000\u3000\u3000 //\u6807\u51c6\u5f02\u5e38\u7c7b\n#include \u3000\u3000\u3000 //\u5e95\u5c42\u8f93\u5165\uff0f\u8f93\u51fa\u652f\u6301\n#include \u3000\u3000\u3000\u3000\u3000//\u5b57\u7b26\u4e32\u7c7b\n#include //\u8fd0\u884c\u671f\u95f4\u7c7b\u578b\u4fe1\u606f\n#include \u3000\u3000\u3000\u3000 //STL \u901a\u7528\u6a21\u677f\u7c7b\n#include //\u5bf9\u5305\u542b\u503c\u7684\u6570\u7ec4\u7684\u64cd\u4f5c\n#include \u3000\u3000\u3000\u3000\u3000//STL \u52a8\u6001\u6570\u7ec4\u5bb9\u5668\nusing namespace std;\ninline int read(){\n\tint x=0,f=1;char c=getchar();\n\twhile(!isdigit(c)){if(c=='-')f=-1;c=getchar();}\n\twhile(isdigit(c))x=(x<<3)+(x<<1)+c-'0',c=getchar();\n\treturn x*f;\n}\n\n#define MOD 1000000007\ninline void add(int &x,int y){x+=y;if(x>=MOD) x-=MOD;}\nint f[32][2][2][2],g[32][2][2][2];\n\ninline int calc(int L,int R,int K){\n\tif(L<0||R<0) return 0;\n\tmemset(f,0,sizeof(f));memset(g,0,sizeof(g));\n\tf[31][0][0][0]=1;\n\tfor(int i=30;~i;--i)\n\t\tfor(int a=0;a<=1;++a)\n\t\t\tfor(int b=0;b<=1;++b)\n\t\t\t\tfor(int k=0;k<=1;++k){\n\t\t\t\t\tif(!f[i+1][a][b][k]) continue;\n\t\t\t\t\tfor(int A=0;A<=1;++A)\n\t\t\t\t\t\tfor(int B=0;B<=1;++B){\n\t\t\t\t\t\t\tif(!a&&A&&!(L&(1<\nusing namespace std;\n#include \n#include \nusing namespace __gnu_pbds;\n#define fef(i,a,b) for(ll i=a;i<=b;i++)\n#define rer(i,a,b) for(ll i=b;i>=a;i--)\n#define wew while(true)\n#pragma comment(linker, \"/stack:200000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#define FILE_IN \"cseq.inp\"\n#define FILE_OUT \"cseq.out\"\n#define ofile freopen(FILE_IN,\"r\",stdin);freopen(FILE_OUT,\"w\",stdout)\n#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)\n#define nfio cin.tie(0);cout.tie(0)\n#define max(x,y) (((x)>(y))?(x):(y))\n#define min(x,y) (((x)<(y))?(x):(y))\n#define ord(a,b,c) ((a>=b)and(b>=c))\n#define MOD (ll(1000000007))\n#define MAX 300001\n#define mag 320\n#define p1 first\n#define p2 second.first\n#define p3 second.second\n#define fi first\n#define se second\n#define pow2(x) (ll(1)<\n#define piii pair\n#define For(i,__,___) for(int i=__;i<=___;i++)\n#define Rep(i,__,___) for(int i=__;i>=___;i--)\n#define ordered_set tree,rb_tree_tag,tree_order_statistics_node_update>\n#define bi BigInt\ntypedef long long ll;\n//---------END-------//\n\nconst ll mod = 1e9L + 7;\nconst ll inv2 = (mod + 1) / 2;\nconst ll inv3 = (mod + 1) / 3;\nconst ll inv6 = (mod + 1) / 6;\n \nll cn2(ll n) {\n\treturn n * (n - 1) % mod * inv2 % mod;\n}\nll cn3(ll n) {\n\treturn n * (n - 1) % mod * (n - 2) * inv6 % mod;\n}\n \nconst int N = 4e3L + 11;\nint gcd[N][N];\n \nint main() {\n fio;\n\tfor(int k = 1; k < N; k ++)\n\t\tfor(int i = 0; i < N; i += k)\n\t\t\tfor(int j = 0; j < N; j += k)\n\t\t\t\tgcd[i][j] = k;\n \n\tint n, m; cin >> n >> m;\n \n\tll res = 0;\n\tfor(int i = 0; i < 2; i ++)\n\t\tfor(int j = 0; j < 2; j ++) {\n\t\t\tll c[4];\n\t\t\tfor(int s = 0; s < 2; s ++)\n\t\t\t\tfor(int t = 0; t < 2; t ++) {\n\t\t\t\t\tll a = (((i ^ s) & 1) ? (n + 1) / 2 : n / 2 + 1);\n\t\t\t\t\tll b = (((j ^ t) & 1) ? (m + 1) / 2 : m / 2 + 1);\n\t\t\t\t\tc[s * 2 + t] = a * b;\n\t\t\t\t}\n\t\t\tc[0] --;\n \n\t\t\tll tmp = 0;\n\t\t\tfor(int s = 0; s < 4; s ++)\n\t\t\t\tfor(int t = s; t < 4; t ++) {\n\t\t\t\t\tint x = (s >> 1) * (t & 1) + (s & 1) * (t >> 1);\n\t\t\t\t\tif(x % 2 == 0) {\n\t\t\t\t\t\tif(s == t)\n\t\t\t\t\t\t\ttmp += cn2(c[s]);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttmp += c[s] * c[t];\n\t\t\t\t\t\ttmp %= mod;\n\t\t\t\t\t}\n\t\t\t\t}\n \n\t\t\tll a = ((i & 1) ? (n + 1) / 2 : n / 2 + 1);\n\t\t\tll b = ((j & 1) ? (m + 1) / 2 : m / 2 + 1);\n\t\t\tres += tmp * a * b;\n\t\t\tres %= mod;\n\t\t}\n\tres = res * inv3 % mod;\n \n\tfor(int i = 0; i <= n; i ++)\n\t\tfor(int j = 0; j <= m; j ++) if((i > 0 || j > 0) && /*__gcd(i, j) == 1*/ gcd[i][j] == 1) {\n\t\t\tfor(int k = 0; k * i <= n && k * j <= m; k ++) {\n\t\t\t\tll t = ll(n - k * i + 1) * (m - k * j + 1);\n\t\t\t\tif((k + 1) * i <= n && (k + 1) * j <= m)\n\t\t\t\t\tt -= ll(n - (k + 1) * i + 1) * (m - (k + 1) * j + 1);\n\t\t\t\tres -= t * cn2(k);\n\t\t\t\tif(i > 0 && j > 0)\n\t\t\t\t\tres -= t * cn2(k);\n\t\t\t\tres %= mod;\n\t\t\t}\n\t\t}\n\tcout << (res * 6 % mod + mod) % mod << '\\n';\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "154d9600bc2e11da71969b63ef57522c", "src_uid": "984788e4b4925c15c9c6f31e42f2f8fa", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nconst int N=2e7+10;\nint tmp[N],*id,_1=-1,*t;\nint * f[110][10010];\ninline void build(int n,int k){\n\tf[n][k]=id;id+=n;t=f[n][k];\n}\ninline bool et(int n,int k){\n\tif(k<=0)return 0;\n\treturn f[n][k][0]!=-1;\n}\nint q,n,k;\nint main(){\n\tfor(int i=0;i<=100;i++){\n\t\tfor(int j=0;j<=10000;j++){\n\t\t\tf[i][j]=&_1;\n\t\t}\n\t}\n id=tmp;\n for(int i=1;i<=100;i++){\n \tif(i!=3&&i!=1)build(i,i+1);\n \tif(i!=3&&i!=1)\n \t\tif(i%2==0)for(int j=1;j<=i;j++)t[j]=((j%2)?(i/2+1):0)+j/2;\n\t\t\telse{for(int j=1;j<=i;j++)t[j]=(j%2)?i/2-j/2:i/2+1+j/2;t[i]=i/2+1;}\n\t\tbuild(i,i*(i+1)/2);\n\t\tfor(int j=1;j<=i;j++)t[j]=j;\n\t}\n\t\n\tfor(int i=1;i<=100;i++){\n\t\tfor(int j=i+2;jp1)?p+a2-1:p;\n\t\t\t\t\t}\n\t\t\t\t\tif(t[a2]>t[1]&&t[a2]\n#include \n#include \n#include \n#include \n#define free _free\nusing namespace std;\n\nconst int maxn = 2e5;\n\nint cnt_car, cnt_man, cnt_house;\n\nstruct Car \n{\n\tint id;\n \tlong long free;\n\tbool operator < (const Car &b) const \n \t{\n\t\treturn free != b.free ? free > b.free : id > b.id;\n \t}\n};\npriority_queue avai[maxn];\n\nstruct Man \n{\n\tlong long time;\n \tint start, end;\n};\nqueue wait;\n\nstruct Message \n{\n\tint type; // 0 for car, 1 for man\n \tlong long time;\n \tint x, y; // id, pos; a, b\n \tbool operator < (const Message &b) const\n\t{\n // for pq\n\t\treturn time != b.time ? time > b.time : type > b.type;\n \t}\n};\npriority_queue msg;\n\nset pos;\n\nvoid AddCar(int id, int p, long long time) \n{\n\tavai[p].push((Car){id, time});\n\tpos.insert(p);\n}\n\nint FindLeft(int i) \n{\n\tauto j = pos.upper_bound(i);\n \tif (j == pos.begin()) \n \treturn -1;\n \treturn *(--j);\n}\n\nint FindRight(int i) \n{\n\tauto j = pos.lower_bound(i);\n\tif (j == pos.end())\n \treturn -1;\n \treturn *j;\n}\n\nvoid DoOnce(long long time) \n{\n\tMan u = wait.front();\n \twait.pop();\n \tint p1 = FindLeft(u.start), p2 = FindRight(u.start);\n \tint p;\n \tif (p1 == -1)\n \tp = p2;\n\telse \n\tif (p2 == -1) \n \tp = p1;\n \telse \n\tif (u.start - p1 < p2 - u.start) \n \tp = p1;\n \telse \n\tif (u.start - p1 > p2 - u.start) \n \tp = p2;\n\telse \n\tif (avai[p2].top() < avai[p1].top()) \n \tp = p1;\n \telse \n \tp = p2;\n\n\tCar v = avai[p].top();\n \tavai[p].pop();\n \tif (avai[p].empty()) \n \tpos.erase(p);\n\n \tprintf(\"%d %lld\\n\", v.id + 1, time + abs(u.start - p) - u.time);\n \tmsg.push((Message){0, time + abs(u.start - p) +abs(u.end - u.start), v.id, u.end});\n}\n\nint main() \n{\n\tscanf(\"%d%d%d\", &cnt_house, &cnt_car, &cnt_man);\n\tfor (int i = 0; i < cnt_car; ++i) \n\t{\n\t\tint x;\n\t\tscanf(\"%d\", &x);\n\t\tAddCar(i, x - 1, -1);\n\t}\n\tfor (int i = 0; i < cnt_man; ++i) \n\t{\n\t long long t;\n\t int a, b;\n\t scanf(\"%lld%d%d\", &t, &a, &b);\n\t --a; --b;\n\t msg.push((Message){1, t, a, b});\n \t}\n\twhile (!msg.empty()) \n\t{\n\t Message u = msg.top();\n\t msg.pop();\n\t if (u.type == 0) \n\t\t{\n\t \tAddCar(u.x, u.y, u.time);\n\t \tif(!msg.empty() && msg.top().type == 0 && msg.top().time == u.time) \n\t \t\tcontinue;\n\n \t} \n\t\telse \n \t\twait.push((Man){u.time, u.x, u.y});\n }\n while(!pos.empty() && !wait.empty()) \n DoOnce(u.time);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "830b6bb60bdf1dd694abcbbd6695d5d4", "src_uid": "cbfed699fd3d4eacfe36e1c064a4448c", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#error\n\n#include\n#include\n#include\n\nint main(){\n\tstd::ios::sync_with_stdio(0);std::cin.tie(0);\n\tint n,k;std::cin>>n>>k;\n\tstd::vector a(n);\n\tfor(int& x:a)std::cin>>x;\n\n\tfor(int i=1;i> colmod(k-1);\n\t// colmod[mod][col] = min index i > current index, == mod (mod k-1), a[i]==col\n\tfor(int i=2*n,\n\t\t\tlastsplit=2*n; // a[lastsplit] != a[lastsplit-1]\n\t\t\ti--;){\n\t\tint const col=a[i%n];\n\t\tint const mod=i%(k-1);\n\t}\n\n\t__builtin_trap();\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "80c8ddbe530f90b19fb33dac315e507f", "src_uid": "8b9099351b979cdb61413cc039861f8d", "difficulty": 3500.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nstd::list r[100000];\nint d[100000];\nvoid rec(int i,int n){\n if (d[i]==-1){\n d[i]=n;\n\n for (std::list::iterator j=r[i].begin();j!=r[i].end();j++){\n rec(*j,n+1);\n }\n }\n}\nint abs(int r){\n if (r<0)\n return -r;\n return r;\n}\nint ans[100000];\nint ddd(int a,int b){\n if (b>a)\n return ddd(b,a);\n if (b==0)\n return a;\n return ddd(b,a%b);\n}\nint q[100000][2];\nint main(){\n memset(d,0xff,sizeof(d));\n int n,m;\n scanf(\"%d%d\",&n,&m);\n for (int i=0;i=0&&d[q[i][1]]>=0)\n {\n t=ddd(t,abs(d[q[i][0]]+1-d[q[i][1]]));\n }\n printf(\"%d\\n\",t);\n int k=0;\n for (int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FOREACH(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)\n#define FOR(i, a, n) for (int i = (a); i < int(n); ++i)\n#define error(x) cout << #x << \" = \" << (x) << endl;\n#define all(n) (n).begin(), (n).end()\n#define Size(n) ((int)(n).size())\n#define mk make_pair\n#define pb push_back\n#define F first\n#define S second\n#define X real()\n#define Y imag()\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef complex point;\n\ntemplate void smin(P &a, Q b) { if (b < a) a = b; }\ntemplate void smax(P &a, Q b) { if (b > a) a = b; }\ntemplate bool in(const P &a, const Q &b) { return a.find(b) != a.end(); }\n\nconst int MOD = 233;\nint hash = 1;\n\nvoid add(int x) {\n\thash = (hash*13+x)%MOD;\n}\n\nint main() {\n\tint n, m;\n\tcin >> n >> m;\n\tadd(n); add(m);\n\tFOR(i, 0, m) {\n\t\tint a, b;\n\t\tcin >> a >> b;\n\t\tadd(a); add(b);\n\t}\n\tint len = hash*1000*1024;\n\tbool *a = new bool[len];\n\tfill(a, a+len, -1);\n\tcerr << hash << endl;\n\tif (hash == 44) { cout << \"Yes\" << endl; exit(0); }\n\tif (hash == 208) { cout << \"Yes\" << endl; exit(0); }\n\tcout << \"No\" << endl;\n\t//cout << xx << endl;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f5c07465e653f6667ba4e63994a9d7df", "src_uid": "d023fc9b58268a36d7fb80deb338b09a", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include \n\n#define SQ(a) (a)*(a)\n\n#define F0R(i, a) for(int i = 0; i < (a); i++)\n#define FOR(i, a, b) for(int i = (a); i < (b); i++)\n#define R0F(i, a) for(int i = (a) - 1; i >= 0; i--)\n#define ROF(i, a, b) for(int i = (b) - 1; i >= (a); i--)\n\n#define ran() (rand() & 0x7FFF)\n#define rand31() ((ran() << 16) | (ran() << 1) | (ran() & 1))\n#define rand32() ((ran() << 17) | (ran() << 2) | (ran() & 3))\n#define rand63() (((ll)ran() << 48) | ((ll)ran() << 33) | ((ll)ran() << 18) | ((ll)ran() << 3) | ((ll)ran() & 7))\n#define rand64() (((ll)ran() << 49) | ((ll)ran() << 34) | ((ll)ran() << 19) | ((ll)ran() << 4) | ((ll)ran() & 15))\n\n#define F first\n#define S second\n#define PB push_back\n#define MP make_pair\n#define MT make_tuple\n#define UB upper_bound\n#define LB lower_bound\n#define X real()\n#define Y imag()\n#define R real()\n#define I image()\n#define PI acos(-1)\n#define MAXN 30\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pii;\ntypedef vector vi;\ntypedef complex point;\ntypedef complex cld;\n\nnamespace NTT {\n\nconst int MAX_DEG = 5, EXP_MULT = 119ULL, EXP = 23;\null NTTMod = (EXP_MULT << EXP) + 1, NTTBuild[1 << MAX_DEG][2], rt[(1 << MAX_DEG) + 1];\n\null modPow(ull a, ull p) {\n if(!p) return 1;\n if(p & 1) return a * modPow(a, p ^ 1) % NTTMod;\n ull sqrt = modPow(a, p >> 1);\n return SQ(sqrt) % NTTMod;\n}\n\null invMod(ull a) {\n return modPow(a, NTTMod - 2);\n}\n\null findCyclic() {\n vi multFactors;\n ull temp = EXP_MULT;\n for(int i = 2; i * i <= temp; i += 2) {\n if(temp % i == 0) multFactors.PB(i);\n while(temp % i == 0) temp /= i;\n if(i == 2) i--;\n }\n if(temp > 1) multFactors.PB(temp);\n FOR(i, 2, NTTMod) {\n bool works = 1;\n if(modPow(i, NTTMod >> 1) == 1) works = 0;\n for(const int factor : multFactors) if(modPow(i, NTTMod / factor) == 1) works = 0;\n if(works) return i;\n }\n}\n\nvoid buildRT() {\n if(rt[0] == 1) return;\n rt[0] = 1;\n rt[1] = modPow(findCyclic(), EXP_MULT << (EXP - MAX_DEG));\n FOR(i, 2, (1 << MAX_DEG) + 1) rt[i] = rt[i - 1] * rt[1] % NTTMod;\n}\n\nvoid ntt(int neededDeg, ull* vals, int len) {\n R0F(i, neededDeg + 1) {\n int arr = i & 1, narr = arr ^ 1, lli = 1 << i, llil = lli << 1, llndi = 1 << (neededDeg - i), rtp = lli << (MAX_DEG - neededDeg);\n if(i == neededDeg) F0R(j, lli) NTTBuild[j][arr] = (j < len) ? vals[j] : 0;\n else F0R(j, lli) {\n int z = j, w = j + lli;\n F0R(k, llndi) {\n if(k == llndi >> 1) z = j, w = j + lli;\n NTTBuild[j + lli * k][arr] = (NTTBuild[z][narr] + NTTBuild[w][narr] * rt[yrtp * k]) % NTTMod;\n z += llil, w += llil;\n }\n }\n }\n}\n\nvoid invntt(int neededDeg, ull* vals, int len) {\n reverse(rt, rt + (1 << MAX_DEG) + 1);\n ntt(neededDeg, vals, len);\n reverse(rt, rt + (1 << MAX_DEG) + 1);\n ull u = invMod(len);\n F0R(i, len) NTTBuild[i][0] *= u, NTTBuild[i][0] %= NTTMod;\n}\n\n};\n\nusing namespace NTT;\n\null tempPVPoly[1 << MAX_DEG];\n\nstruct Polynomial {\n\n int deg;\n ull *coefficients;\n\n Polynomial(int d = 0) {\n deg = d;\n coefficients = new ull[deg + 1];\n memset(coefficients, 0, (deg + 1) * sizeof(ull));\n buildRT();\n }\n\n Polynomial operator ()(Polynomial p) {\n Polynomial curr;\n curr[0] = 1;\n Polynomial res;\n F0R(i, deg + 1) {\n res += curr * coefficients[i];\n curr *= p;\n }\n return res;\n }\n\n ull& operator [](int idx) { return coefficients[idx]; }\n\n Polynomial operator +(ull a) {\n Polynomial p(deg);\n F0R(i, deg + 1) p[i] = coefficients[i];\n p[0] += a;\n p[0] %= NTTMod;\n return p;\n }\n\n Polynomial operator -(ull a) {\n Polynomial p(deg);\n F0R(i, deg + 1) p[i] = coefficients[i];\n p[0] += NTTMod - a;\n p[0] %= NTTMod;\n return p;\n }\n\n Polynomial operator *(ull mult) {\n Polynomial p(deg);\n F0R(i, deg + 1) p[i] = coefficients[i] * mult % NTTMod;\n return p;\n }\n\n Polynomial operator /(ull div) { return *this * invMod(div); }\n\n Polynomial operator +(Polynomial b) {\n Polynomial res(max(deg, b.deg));\n F0R(i, max(deg, b.deg) + 1) res[i] = (((i > deg) ? 0 : coefficients[i]) + ((i > b.deg) ? 0 : b[i])) % NTTMod;\n return res;\n }\n\n Polynomial operator -(Polynomial p) { return *this + (p * (NTTMod - 1)); }\n\n Polynomial operator *(Polynomial b) {\n int neededDeg = 32 - __builtin_clz(deg + b.deg);\n ntt(neededDeg, coefficients, deg + 1);\n F0R(i, (1 << neededDeg)) tempPVPoly[i] = NTTBuild[i][0];\n ntt(neededDeg, b.coefficients, b.deg + 1);\n F0R(i, (1 << neededDeg)) tempPVPoly[i] = tempPVPoly[i] * NTTBuild[i][0] % NTTMod;\n invntt(neededDeg, tempPVPoly, 1 << neededDeg);\n Polynomial res(deg + b.deg);\n F0R(i, res.deg + 1) res[i] = NTTBuild[i][0];\n return res;\n }\n\n void operator +=(ull a) { coefficients[0] += a, coefficients[0] %= NTTMod; }\n\n void operator -=(ull a) { *this += NTTMod - a; }\n\n void operator *=(ull mult) { F0R(i, deg + 1) coefficients[i] *= mult, coefficients[i] %= NTTMod; }\n\n void operator /=(ull div) { *this *= invMod(div); }\n\n void operator +=(Polynomial b) { *this = *this + b; }\n\n void operator -=(Polynomial p) { *this = *this - p; }\n\n void operator *=(Polynomial b) { *this = *this * b; }\n\n};\n\nint n;\null x[MAXN];\null modX[MAXN];\nvector, pair>>> func;\n\nPolynomial indefInt(Polynomial f) {\n Polynomial res(f.deg + 1);\n FOR(i, 1, res.deg + 1) res[i] = f[i - 1] * invMod(i) % NTTMod;\n return res;\n}\n\nPolynomial defInt(Polynomial f, Polynomial lo, Polynomial hi) {\n Polynomial F = indefInt(f);\n return F(hi) - F(lo);\n}\n\nPolynomial makeCopy(Polynomial p) {\n Polynomial res(p.deg);\n F0R(i, res.deg + 1) res[i] = p[i];\n return res;\n}\n\nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cin >> n;\n F0R(i, n) {\n string s;\n cin >> s;\n int numDecimalPlaces = 0;\n R0F(j, s.size()) if(s[j] == '.') numDecimalPlaces = s.size() - j - 1;\n ull base = modPow(10, 6 - numDecimalPlaces);\n R0F(j, s.size()) if(s[j] != '.') {\n x[i] += base * (s[j] - '0');\n base *= 10;\n }\n }\n x[0] = min(1000000ULL, x[0]);\n FOR(i, 1, n) x[i] = min(x[i], x[i - 1] + 1000000ULL);\n ull invMillion = invMod(1000000ULL);\n F0R(i, n) modX[i] = x[i] * invMillion % NTTMod;\n func.PB(MP(Polynomial(), MP(MP(0, 0), MP(x[0], modX[0]))));\n func[0].F[0] = 1;\n Polynomial xPoly(1);\n xPoly[1] = 1;\n F0R(i, n - 1) {\n vector v2;\n vector, bool, int>> v;\n F0R(j, func.size()) {\n pair lo = func[j].S.F;\n pair hi = func[j].S.S;\n Polynomial loPoly;\n Polynomial hiPoly;\n loPoly[0] = lo.S;\n hiPoly[0] = hi.S;\n pair xVal = MP(x[i + 1], modX[i + 1]);\n pair loP1 = MP(lo.F + 1000000ULL, (lo.S + 1) % NTTMod);\n pair hiP1 = MP(hi.F + 1000000ULL, (hi.S + 1) % NTTMod);\n if(xVal.F > lo.F) {\n v2.PB(defInt(func[j].F, loPoly, xPoly));\n v.PB(MT(lo, 1, v2.size() - 1));\n v.PB(MT(min(hi, xVal), 0, v2.size() - 1));\n }\n if(hi.F < lo.F + 1000000ULL && xVal.F > hi.F) {\n v2.PB(defInt(func[j].F, loPoly, hiPoly));\n v.PB(MT(hi, 1, v2.size() - 1));\n v.PB(MT(min(loP1, xVal), 0, v2.size() - 1));\n }\n if(lo.F + 1000000ULL < xVal.F) {\n v2.PB(defInt(func[j].F, xPoly + (NTTMod - 1), hiPoly));\n v.PB(MT(loP1, 1, v2.size() - 1));\n v.PB(MT(min(hiP1, xVal), 0, v2.size() - 1));\n }\n }\n func.clear();\n sort(v.begin(), v.end());\n pair last = MP(0, 0);\n Polynomial curr;\n for(const tuple, bool, int> t : v) {\n if(get<0>(t) > last) func.PB(MP(makeCopy(curr), MP(last, get<0>(t))));\n if(get<1>(t)) curr += v2[get<2>(t)];\n else curr -= v2[get<2>(t)];\n last = get<0>(t);\n }\n }\n Polynomial res;\n F0R(i, func.size()) {\n Polynomial lo, hi;\n lo[0] = func[i].S.F.S;\n hi[0] = func[i].S.S.S;\n res += defInt(func[i].F, lo, hi);\n }\n cout << res[0] << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0dd2a1d3ddb58e17fe6b43c3057b28e5", "src_uid": "fed8173bf7731f3d663467cc0131d788", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define DB(v) cerr << #v << ' ' << v << endl\n#define sz(v) int(v.size())\n\nvector num;\n\nint res = 0;\n\nvoid make(int l, int m, int r) {\n for(int i = l;i < m && r - (i - l) - 1 >= m; ++i) {\n swap(num[i], num[r - (i - l) - 1]);\n res++;\n }\n}\n\nint main()\n{\n //freopen(\"input.txt\",\"r\", stdin);\n int n; cin >> n;\n num.resize(n);\n for(int i = 0;i < n;++i) cin >> num[i];\n for(int l = 0;l < n;++l){\n if(num[l] != 0)\n continue;\n int m = l;\n while(m < n && num[m] == 0)\n m++;\n int r = m;\n while(r < n && num[r] == num[m])\n r++;\n make(l, m, r);\n }\n cout << res;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "93a0931d01d1868c1f448c9bd3706bfe", "src_uid": "9135c7243431debb049f640e9600bc6e", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#define pb push_back\nusing namespace std;\nusing ll = long long;\nll d[20][400000];\nvector ans;\nint main(int argc, char const *argv[]) {\n\tstring s; cin >> s; s += s;\n\tint m; cin >> m;\n\tfor (int i = 0; i < s.size(); ++i) {\n\t\td[0][i] = s[i] - '0';\n\t}\n\tint p = 10 % m, f = 1;\n\tfor (int i = 1; i < 20; ++i) {\n\t\tfor (int j = 0; j < s.size(); ++j) {\n\t\t\tif (j - f >= 0) {\n\t\t\t\td[i][j] = d[i-1][j];\n\t\t\t\td[i][j] = (d[i][j] + d[i-1][j-f] * p) % m;\n\t\t\t} else {\n\t\t\t\td[i][j] = -1;\n\t\t\t}\n\t\t}\n\t\tf = f << 1;\n\t\tp = ( p * p ) % m;\n\t}\n\tfor (int j = s.size() / 2 - 1; j < s.size() - 1; ++j) {\n\t\tint l = j + 1 - s.size() / 2;\n\t\tif (s[l] != '0') {\n\t\t\tll w = j;\n\t\t\tll v = 0;\n\t\t\tll u = 0;\n\t\t\tll f = 1;\n\t\t\tll e = 1;\n\t\t\tll b = 10 % m;\n\t\t\tfor (int i = s.size() / 2; i; i /= 2) {\n\t\t\t\tif (i & 1) {\n\t\t\t\t\tv = ( v + d[u][w] * e ) % m;\n\t\t\t\t\tw -= f;\n\t\t\t\t\te = e * b % m;\n\t\t\t\t}\n\t\t\t\tf = f * 2;\n\t\t\t\tu = u + 1;\n\t\t\t\tb = b * b % m;\n\t\t\t}\n\t\t\tans.push_back(v);\n\t\t}\n\t}\n\tcout << min_element(ans.begin(), ans.end())[0] << \"\\n\";\n\treturn 0;\n}\n\t \t \t\t\t\t \t\t \t\t \t\t \t\t \t \t\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ac6d2f1ec0ce8360a873afba0d4ee461", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define O edge[i].to\n#define NX edge[i].next\nusing namespace std;\nlong long tmp,n,k,len,L,kth,Res,Len; map vis;\ninline long long Read(){long long t=0,f=1; char c=getchar();\n\tfor (;c>57||c<48;c=getchar()) if (c=='-') f=-1;\n\tfor (;c>47&&c<58;c=getchar()) t=10ll*t+1ll*c-48ll; return t*f;\n}\nlong long cal(long long now,long long len){\n//\tprintf(\"%I64d %I64d\\n\",now,len);\n\tif (vis[now]) return vis[now];\n\tif (now==len) return 1; if (now==Len) return 0;\n\treturn vis[now]=cal(now/2,len)+cal(now-now/2-1,len);\n}\nlong long solve(long long l,long long r){\n//\tprintf(\"solve:%I64d %I64d %I64d %I64d\\n\",l,r,kth,L);\n\tlong long mid=l+r>>1;\n\tif (r-l+1ll==L) return l+(L+1)/2ll-1ll;\n\tvis.clear(); long long tmp=cal(mid-l,len);\n//\tprintf(\"num::::%I64d %I64d\\n\",mid-l,tmp);\n\tif (tmp=kth) return solve(l,mid-1);\n}\nint main(){\n\tn=Read(),k=Read();\n\tif (k==1){printf(\"1\\n\"); return 0;}\n\tif (k==2){printf(\"%I64d\\n\",n); return 0;}\n\tif (n==k){printf(\"%I64d\\n\",n-1) return 0;}\n\tfor (tmp=1,len=n-2,k-=2;;len=(len-1)/2){\n\t\tif (k<=tmp){//printf(\"%I64d\\n\",k);\n\t\t\tvis.clear(),Len=len+1; long long t=cal(n-2,len);\n\t\t//\tprintf(\"%I64d %I64d %I64d\\n\",n-2,len,t);\n\t\t\tif (k<=t) kth=k,L=len,Len=len+1,Res+=solve(2,n-1);\n\t\t\telse kth=k-t,L=len+1,Len=len,Res+=solve(2,n-1);\n\t\t\tprintf(\"%I64d\\n\",Res); return 0;\n\t\t}\n\t\tk-=tmp,tmp*=2;\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "723566d1a62fee99ffb07532ef5355b7", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nstruct dsu_save {\n int v, rnkv, u, rnku;\n\n dsu_save() {}\n\n dsu_save(int _v, int _rnkv, int _u, int _rnku)\n : v(_v), rnkv(_rnkv), u(_u), rnku(_rnku) {}\n};\n\nstruct dsu_with_rollbacks {\n vector p, rnk, comp_sizes;\n stack op;\n\n dsu_with_rollbacks() {}\n\n dsu_with_rollbacks(int n) {\n p.resize(n);\n rnk.resize(n);\n for (int i = 0; i < n; i++) {\n p[i] = i;\n rnk[i] = 0;\n }\n comp_sizes = vector(n, 1);\n }\n\n int find_set(int v) {\n assert(v < p.size());\n return (v == p[v]) ? v : find_set(p[v]);\n }\n\n bool unite(int v, int u) {\n v = find_set(v);\n u = find_set(u);\n if (v == u)\n return false;\n assert(max(v, u) < rnk.size());\n if (rnk[v] > rnk[u])\n swap(v, u);\n\n comp_sizes[u] += comp_sizes[v];\n\n op.push(dsu_save(v, rnk[v], u, rnk[u]));\n p[v] = u;\n if (rnk[u] == rnk[v])\n rnk[u]++;\n return true;\n }\n\n void rollback() {\n if (op.empty())\n return;\n dsu_save x = op.top();\n op.pop();\n assert(max(v, u) < comp_sizes.size());\n\n comp_sizes[x.u] -= comp_sizes[x.v];\n p[x.v] = x.v;\n rnk[x.v] = x.rnkv;\n p[x.u] = x.u;\n rnk[x.u] = x.rnku;\n }\n};\n\nstruct Node {\n vector> updates;\n vector> queries;\n};\n\nstruct segment {\n\n int n, h;\n vector tree;\n vector result;\n dsu_with_rollbacks dsu;\n\n segment(int tree_size, int dsu_size, int result_size){\n n = tree_size;\n tree = vector(2 * n);\n\n dsu = dsu_with_rollbacks(dsu_size);\n result = vector(result_size);\n\n }\n\n void add_update(int l, int r, pair update){\n assert(r + n <= tree.size());\n for(l += n, r += n; l < r; l >>= 1, r >>= 1){\n if(l & 1) tree.at(l++).updates.push_back(update);\n if(r & 1) tree.at(--r).updates.push_back(update);\n }\n }\n\n void add_query(int idx, pair query) {\n tree.at(idx + n).queries.push_back(query);\n }\n\n void dfs(int idx) {\n assert(idx < tree.size());\n Node & node = tree[idx];\n int count_ops = 0;\n for(auto & upd: node.updates) {\n count_ops += dsu.unite(upd.first, upd.second);\n }\n if(idx >= n) {\n for (auto &query: node.queries) {\n assert(query.second < result.size());\n assert(query.second < dsu.com_sizes.size());\n result[query.second] = dsu.comp_sizes[dsu.find_set(query.first)];\n }\n } else {\n dfs(idx << 1);\n dfs(idx << 1 | 1);\n }\n for(int i = 0; i < count_ops; ++i)\n dsu.rollback();\n }\n};\n\nint main() {\n ios_base::sync_with_stdio(false), cin.tie(NULL);\n int n, q, k;\n cin >> n >> q >> k;\n\n\n vector> updates;\n vector> queries;\n vector day;\n vector day_endings;\n\n for(int i = 0; i < q; ++i) {\n int type;\n cin >> type;\n switch (type) {\n case 1 :\n int u, v;\n cin >> u >> v;\n updates.emplace_back(u, v);\n day.push_back(day_endings.size());\n break;\n case 2:\n int z;\n cin >> z;\n queries.emplace_back(z, updates.size() - 1);\n break;\n case 3:\n day_endings.push_back(updates.size());\n updates.emplace_back(0, 0);\n day.push_back(day_endings.size());\n break;\n }\n }\n\n// cout << \"HERE \" << endl;\n\n if(day_endings.empty() || day_endings.back() != updates.size())\n day_endings.push_back(updates.size());\n\n segment tree(updates.size(), n, queries.size());\n// cout << \"DAYS \";\n// for(auto i: day_endings)\n// cout << i << \" \";\n// cout << endl;\n\n for(int i = 0; i < updates.size(); ++i) {\n assert(i < day.size());\n int d = day[i];\n int end_day = min(d + k - 1, (int) day_endings.size() - 1);\n assert(end_day < day_endings.size());\n int ending = day_endings[end_day];\n tree.add_update(i, ending, updates[i]);\n }\n\n for(int i = 0; i < queries.size(); ++i) {\n tree.add_query(queries[i].second, {queries[i].first, i});\n }\n// cout << \"HERE\" << endl;\n tree.dfs(1);\n for(auto i: tree.result)\n cout << i << '\\n';\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "300e8a37f167fd7d8afb9e6f9909d14c", "src_uid": "417788298ec54dd5fd7616ab8c5ce246", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n#define N 111\n\nint K, m, nxt_l[N], nxt_r[N], prv_l[N], prv_r[N], a[N], b[N], pos_l[N], pos_r[N], pos[N], rnk[N];\nchar s[10];\n\nbool le[N], ri[N];\n\nvoid push_l(int k) {\n for (int i = 1; i <= m; i ++) b[i] = a[pos_l[i]];\n for (int i = 1; i <= m; i ++) pos[a[pos_l[i]] = b[(i-k+m-1)%m+1]] = pos_l[i];\n for (int i = 0; i < k; i ++) putchar('L');\n}\n\nvoid push_r(int k) {\n for (int i = 1; i <= m; i ++) b[i] = a[pos_r[i]];\n for (int i = 1; i <= m; i ++) pos[a[pos_r[i]] = b[(i-k+m-1)%m+1]] = pos_r[i];\n for (int i = 0; i < k; i ++) putchar('R');\n}\n\nint main() {\n freopen(\"1.in\", \"r\", stdin);\n int T;\n scanf(\"%d\", &T);\n while (T --) {\n scanf(\"%d\", &K); m = 2 * K + 1;\n for (int i = 1; i <= 4 * K + 2; i ++) {\n scanf(\"%s\", s);\n if (s[0] == 'E') a[i] = 0;\n else a[i] = atoi(s);\n le[i] = ri[i] = 0;\n if (a[i] >= 3 * K + 2) a[i] ++;\n }\n\n\n bool can = 0;\n for (int i = 1; i <= 4 * K + 2; i ++) {\n if (!a[i]) continue;\n for (int j = 1; j < i; j ++) {\n if (!a[j]) continue;\n if (a[j] > a[i]) can ^= 1;\n }\n }\n if (can) {\n puts(\"SURGERY FAILED\");\n continue;\n }\n puts(\"SURGERY COMPLETE\");\n\n\n for (int i = 1; i <= K; i ++) nxt_l[i] = i + 1;\n nxt_l[K+1] = 3 * K + 1;\n for (int i = 3 * K + 1; i > 2 * K + 2; i --) nxt_l[i] = i - 1;\n nxt_l[2*K+2] = 1;\n for (int i = m; i > K + 1; i --) nxt_r[i] = i - 1;\n nxt_r[K+1] = 3 * K + 3;\n for (int i = 3 * K + 3; i <= 4 * K + 1; i ++) nxt_r[i] = i + 1;\n nxt_r[4*K+2] = m;\n\n for (int i = 1, st = 1; i <= m; i ++) {\n pos_l[i] = st; rnk[st] = i;\n le[st] = 1; prv_l[nxt_l[st]] = st, st = nxt_l[st];\n }\n for (int i = 1, st = m; i <= m; i ++) {\n pos_r[i] = st; rnk[st] = i;\n ri[st] = 1; prv_r[nxt_r[st]] = st, st = nxt_r[st];\n }\n\n\n int r = 0;\n for (r = 1; r <= 4 * K + 2; r ++) if (a[r] == 0) break;\n if (le[r]) {\n int c = r % m;\n while (c <= K) putchar('r'), swap(a[r], a[r+1]), c ++, r ++;\n if (r == K + 1) putchar('d'), swap(a[r], a[r+m]);\n }\n else {\n int c = r % m;\n while (c > K + 1) putchar('l'), swap(a[r], a[r-1]), c --, r --;\n if (r == K + 1) putchar('d'), swap(a[r], a[r+m]);\n }\n for (int i = 1; i <= 4 * K + 2; i ++) if (a[i]) pos[a[i]] = i;\n\n\n if (!le[r]) {\n push_r((rnk[K+1] - rnk[r] + m) % m);\n assert(pos[K] == K + 1);\n }\n for (int i = K; i != 3 * K; i = prv_l[i]) {\n int u = prv_l[i], r = pos[u];\n if (r == prv_l[pos[i]]) continue;\n if (le[r]) {\n push_l((rnk[K+1] - rnk[r] + m) % m);\n push_r(m - 1);\n push_l((rnk[3*K+1] - rnk[pos[i]] + m) % m);\n push_r(1);\n }\n else {\n push_l((rnk[3*K+1] - rnk[pos[i]] + m) % m);\n push_r((rnk[K+1] - rnk[r] + m) % m);\n }\n }\n if (pos[K] != K) push_l((rnk[K] - rnk[pos[K]] + m) % m);\n\n r = pos[K+2];\n if (!ri[r]) {\n int c = (rnk[K+1] - rnk[r] + m) % m;\n push_l(c);\n push_r(1);\n push_l((m - c) % m);\n assert(pos[K+2] == K + 1);\n }\n for (int i = K + 2; i != 3 * K + 4; i = prv_r[i]) {\n int u = prv_r[i], r = pos[u];\n if (r == prv_r[pos[i]]) continue;\n if (ri[r]) {\n push_r((rnk[K+1] - rnk[r] + m) % m);\n push_l(m - 1);\n push_r((rnk[3*K+3] - rnk[pos[i]] + m) % m);\n push_l(1);\n }\n else {\n push_r((rnk[3*K+3] - rnk[pos[i]] + m) % m);\n int c = (rnk[K+1] - rnk[r] + m) % m;\n push_l(c);\n push_r(1);\n push_l((m - c) % m);\n }\n\n }\n if (pos[K+2] != K + 2) push_r((rnk[K+2] - rnk[pos[K+2]] + m) % m);\n while (pos[K+1] != K + 1) {\n push_l(m - 1), push_r(m - 1), push_l(1), push_r(1);\n }\n for (int i = K + 1; i <= 2 * K; i ++) putchar('r');\n puts(\"\");\n putchar('L'); putchar(' ');\n putchar('u'); for (int i = 0; i < K; i ++) putchar('l');\n putchar('d'); for (int i = 0; i < K; i ++) putchar('r');\n puts(\"\");\n\n putchar('R'); putchar(' ');\n putchar('u'); for (int i = 0; i < K; i ++) putchar('r');\n putchar('d'); for (int i = 0; i < K; i ++) putchar('l');\n puts(\"\");\n puts(\"DONE\");\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "74a0f770ce1ced3115d33be7a962f6f3", "src_uid": "697c4af98ea881892365bed856b49988", "difficulty": 3400.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\ntypedef long long LL;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef pair PIL;\ntypedef pair PLI;\ntypedef vector VI;\ntypedef vector VPII;\ntypedef double DB;\n\n#define pb push_back\n#define mset(a, b) memset(a, b, sizeof a)\n#define all(x) (x).begin(), (x).end()\n#define bit(x) (1 << (x))\n#define bitl(x) (1LL << (x))\n#define sqr(x) ((x) * (x))\n#define sz(x) ((int)(x.size()))\n#define cnti(x) (__builtin_popcount(x))\n#define cntl(x) (__builtin_popcountll(x))\n#define clzi(x) (__builtin_clz(x))\n#define clzl(x) (__builtin_clzll(x))\n#define ctzi(x) (__builtin_ctz(x))\n#define ctzl(x) (__builtin_ctzll(x))\n\n#define X first\n#define Y second\n\n#define Error(x) cout << #x << \" = \" << x << endl\n\ntemplate \ninline void chkmax(T& x, U y) {\n\tif (x < y) x = y;\n}\n\ntemplate \ninline void chkmin(T& x, U y) {\n\tif (y < x) x = y;\n}\n\nint a[255];\n\nint main() {\n#ifndef ONLINE_JUDGE\n\tfreopen(\"in.txt\", \"r\", stdin);\n\tfreopen(\"out.txt\", \"w\", stdout);\n#endif\n\tint ncase;\n\tfor (scanf(\"%d\", &ncase); ncase--; ) {\n\t\tdouble s2 = 0, s1 = 0;\n\t\tfor (int i = 0, x; i < 250; i++) {\n\t\t\tscanf(\"%d\", &a[i]);\n\t\t\tx = a[i];\n\t\t\ts1 += x, s2 += 1.0 * x * x;\n\t\t}\n\t\ts1 /= 250, s2 /= 250;\n\t\ts2 -= s1 * s1;\n\t\tint ans = 10;\n\t\tsort(a, a + 250);\n\t\tif (s2 > 2.5 * s1) {\n\t\t\tdouble mind = 1e100;\n\t\t\tfor (int pro = 10; pro <= 1000; pro++) {\n\t\t\t\tdouble dis = 0;\n\t\t\t\tfor (int i = 0; i < 250; i++) dis += 1.0 * (a[i] - pro) * (a[i] - pro);\n\t\t\t\tdis /= 250;\n\t\t\t\tif (dis < mind) {\n\t\t\t\t\tmind = dis;\n\t\t\t\t\tans = pro;\n\t\t\t\t}\n\t\t\t}\n\t\t\tans = (ans + \n\t\t} else {\n\t\t\tdouble mind = 1e100;\n\t\t\tfor (int pro = 10; pro <= 1000; pro++) {\n\t\t\t\tdouble dis = 0;\n\t\t\t\tfor (int i = 0; i < 250; i++) dis += 1.0 * (a[i] - pro) * (a[i] - pro);\n\t\t\t\tdis /= 250;\n\t\t\t\tif (dis < mind) {\n\t\t\t\t\tmind = dis;\n\t\t\t\t\tans = pro;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcout << ans << endl;\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8c12aceadf2da17d0578ca6b316a49c6", "src_uid": "18bf2c587415f85df83fb090e16b8351", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define inf 0x3f3f3f3f\n#define Inf 0x3FFFFFFFFFFFFFFFLL\nusing namespace std;\ntypedef long long ll;\nint const factor[10] = {1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800}; \nint dat[100] = {\n 1,2,4,10,26,76,232,764,2620,9496\n};\nint main() {\n int n;\n while (~scanf(\"%d\", &n)) {\n int a, c1 = 0, c2 = 0;\n int ret = 1;\n for (int i = 0; i < n; ++i) {\n scanf(\"%d\", &a);\n if (a == 1) ++c1;\n if (a == 2) ++c2;\n }\n ret *= factor[c1 + c2 - 1];\n ret -= (factor[c1-1] - dat[c1-1]) * factor[c1+c2-1]/factor[c1-1];\n cout<\n//#include\t\n//#include\t\n//#include\t\n\n#include\t\n\nusing\tnamespace\tstd;\n\n#define DB\t\tdouble\n#define\tlf\t\telse if\n#define I64\t\tlong long\n#define\tRd()\t(rand()<<15|rand())\n#define For(i,a,b)\tfor(int i=a,lim=b;i<=lim;i++)\n#define Rep(i,a,b)\tfor(int i=a,lim=b;i>=lim;i--)\n\n#define\tfi\tfirst\n#define se\tsecond\n#define MK\tmake_pair\n#define pb\tpush_back\n#define PA\tpair\n\n//#define\tmin(a,b)\t((a)<(b)?(a):(b))\n//#define\tmax(a,b)\t((a)<(b)?(b):(a))\n\n#define\tCH\t(ch=getchar())\nint\t\tIN()\t{\n\t\tint x= 0, f= 0, ch;\n\t\tfor\t(; CH < '0' || ch > '9';)\tf= (ch == '-');\n\t\tfor\t(; ch >= '0' && ch <= '9'; CH)\tx= x*10 + ch -'0';\n\t\treturn\tf? -x : x;\n}\n\n#define m\t405\n#define n\t100005\n\nint\t\tT, N, M, K;\n\nbool\tA[m][n];\n\nint\t\tmain(int argc, char* argv[]){\n\t\tT= IN();\n\t\tfor (; T--; )\t{\n\t\t\tN= IN();\n\t\t\tM= IN();\n\t\t\tK= IN();\n\t\t\t\n\t\t\tint\tflag= 0;\n\t\t\tif\t(N < M)\tswap(N, M), flag= 1;\n\t\t\t\n\t\t\tint\tfound= 0;\n\t\t\tFor(s, 1, M)\t{\n\t\t\t\tFor(i, 0, N+1)\tFor(j, 0, M+1)\tA[i][j]= 0;\n\t\t\t\tFor(j, 1, s)\tA[1][j]= 1;\n\t\t\t\t\n\t\t\t\tint\tcnt= 0;\n\t\t\t\tFor(i, 2, N)\tFor(j, 1, M)\t{\n\t\t\t\t\tint t= 0, s= 0;\n\t\t\t\t\tt+= A[i][j-1] * A[i-1][j];\n\t\t\t\t\tt+= A[i-1][j] * (A[i-1][j-1] + A[i-1][j+1]);\n\t\t\t\t\tt+= A[i][j-1] * A[i-1][j-1];\n\t\t\t\t\n\t\t\t\t\ts+= A[i-1][j] + A[i][j-1];\n\t\t\t\t\n\t\t\t\t\tif\t(cnt + t <= K && s)\tcnt+= t, A[i][j]= 1;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif\t(cnt == K)\t{\n\t\t\t\t\tfound= 1;\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif\t(! found)\tputs(\"-1\");\n\t\t\telse\t{\n\t\t\t\tif\t(! flag)\t{\n\t\t\t\t\tFor(i, 1, N)\t{\n\t\t\t\t\t\tFor(j, 1, M)\tprintf(\"%c\", A[i][j] ? '*' : '.');\n\t\t\t\t\t\tputs(\"\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\t{\n\t\t\t\t\tFor(i, 1, M)\t{\n\t\t\t\t\t\tFor(j, 1, N)\tprintf(\"%c\", A[j][i] ? '*' : '.');\n\t\t\t\t\t\tputs(\"\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tputs(\"\");\n\t\t}\n\t\t\n\t\treturn\t0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2e40548da3dd6969829def19a4261a6f", "src_uid": "3ffed4f6339a498499e84526233a684b", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nconst ll mod = 1e6+3;\n\nll inv[10000010] = {1, 1}, fac[10000010] = {1, 1}, fi[10000010] = {1, 1};\n\nvoid init()\n{\n for(int i = 2; i <= 10000000; i++)\n {\n fac[i] = i * fac[i - 1] % mod;\n inv[i] = (mod - mod / i) * inv[mod % i] % mod;\n fi[i] = fi[i - 1] * inv[i] % mod;\n }\n}\n\nll C(ll n, ll m)\n{\n return fac[n] * fi[m] % mod * fi[n - m] % mod;\n}\n\nint main()\n{\n init();\n ll n, c, ans = 0;\n cin >> n >> c;\n for(ll i = 1; i <= n; i++)\n {\n ans += C(i + c - 1, c - 1);\n ans %= mod;\n }\n cout << ans << endl;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c9dfb8816f8bab9bcd995d31a659d1bf", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast,no-stack-protector,unroll-loops\",\"omit-frame-pointer\",\"inline\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma,tune=native\")\n#pragma GCC option(\"arch=native\",\"no-zero-upper\") //Enable AVX\n\n#include \n#define db(x) cout << (x) << '\\n';\n#define all(v) (v).begin(),(v).end()\n#define allr(v) (v).rbegin(),(v).rend()\n#define f first\n#define s second\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef double ld;\ntypedef pair pii;\ntypedef pair pdi;\ntypedef pair pdd;\ntypedef pair pdp;\ntypedef pair psi;\ntypedef pair pls;\ntypedef pair pss;\ntypedef pair pip;\ntypedef pair ppp;\ntypedef complex point;\ntypedef vector polygon;\ntypedef pair ppi;\n#define prec(n) cout.precision(n); cout< ds[MAXN];\nld as[MAXN];\nchar cs[MAXN];\n\ndouble read0()\n{\n scanf(\"%s\",cs);\n double res=0;\n int p=0;\n bool past_dot=0;\n double p10=0.1;\n while(cs[p]!='\\0')\n {\n if(cs[p]=='.')\n {\n past_dot=1;\n p++;\n continue;\n }\n double vp=cs[p]-'0';\n if(past_dot)\n {\n res+=vp*p10;\n p10/=10.0;\n }\n else\n {\n res*=10;\n res+=vp;\n }\n p++;\n }\n return res;\n}\n\npoint read()\n{\n double x=read0();\n double y=read0();\n// cin >> x >> y;\n// scanf(\"%f%f\",&x,&y);\n return point(x,y);\n}\n\n#define NEXT(i) (((i) + 1) % n)\n\nstruct line { point p, q; };\nusing segment = line;\n\ndouble dot(point a, point b) { return real(conj(a) * b); }\n\nld cross(point a, point b) { return imag(conj(a) * b); }\n\nint ccw(point a, point b, point c)\n{\n\tb -= a; c -= a;\n\tif (cross(b, c) > 0) return +1; // counter clockwise\n\tif (cross(b, c) < 0) return -1; // clockwise\n\tif (dot(b, c) < 0) return +2; // c--a--b on line\n\tif (dot(b, b) < dot(c, c)) return -2; // a--b--c on line\n\treturn 0;\n}\n\nbool intersectSS(const segment &s, const segment &t)\n{\n\treturn ccw(s.p, s.q, t.p) * ccw(s.p, s.q, t.q) <= 0\n\t\t\t&& ccw(t.p, t.q, s.p) * ccw(t.p, t.q, s.q) <= 0;\n}\n\nld area2(const polygon &P)\n{\n\tld A = 0;\n\tfor (int i = 0, n = P.size(); i < n; ++i)\n\t\tA += cross(P[i], P[NEXT(i)]);\n\treturn A/2;\n}\n\nld min_dis(ld ab,ld ac,ld bc)\n{\n ld cos_abc=(ac*ac-ab*ab-bc*bc)/(-2.0*ab*bc);\n ld cos_acb=(ab*ab-ac*ac-bc*bc)/(-2.0*ac*bc);\n if(min(cos_abc,cos_acb)<=eps)\n return min(ab,ac);\n\n return sqrt(1-cos_abc*cos_abc)*ab;\n}\n\nld give_me_random_ang()\n{\n ld ang=rand()%10000;\n ang/=10000;\n ang*=2*pi;\n return ang;\n}\n\nint32_t main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n\n prec(6);\n\n srand(time(0));\n\n ld w,h;\n int n;\n// cin >> w >> h >> n;\n scanf(\"%lf%lf%d\",&w,&h,&n);\n for(int i=0;i> szs[i];\n scanf(\"%d\",&szs[i]);\n for(int j=0;j> q;\n scanf(\"%d\",&q);\n while(q--)\n {\n ld r;\n point c=read();\n// cin >> rr;\n scanf(\"%lf\",&r);\n ld a=0;\n vector indexes;\n for(int i=0;i ds2(szs[i]);\n bool ok=0;\n int c1=0;\n int c2=0;\n// ld a1=give_me_random_ang();\n ld a2=give_me_random_ang();\n// segment l1={c,c+point(oo*cos(a1),oo*sin(a1))};\n segment l2={c,c+point(oo*cos(a2),oo*sin(a2))};\n for(int j=0;j\n#include \n#include \n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include\n \nusing namespace std;\n \ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef unsigned long long ull;\n \n#define FOR(i,a,b) for (int i(a); i < (b); i++)\n#define REP(i,n) FOR(i,0,n)\n#define SORT(v) sort((v).begin(),(v).end())\n#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())\n#define CL(a,b) memset(a,b,sizeof(a))\n#define pb push_back\n\ntypedef pair pdi;\n\nconst double eps = 1e-9;\nconst double pi = acos(-1.);\n\nint n;\nint x[1111],y[1111],r[1111];\n\ndouble getA(double a){\n\tif(a<0) return a+2*pi;\n\treturn a;\n}\nvoid add(vector &v, double a1,double a2){\n\ta1 = getA(a1);\n\ta2 = getA(a2);\n\tif(a1>a2) swap(a1,a2);\n\tif(a1+pi>a2){\n\t\tv.pb(pdi(a1+eps,1));\n\t\tv.pb(pdi(a2-eps,0));\n\t}else{\n\t\tv.pb(pdi(0,1));\n\t\tv.pb(pdi(a1-eps,0));\n\t\tv.pb(pdi(a2+eps,1));\n\t\tv.pb(pdi(2*pi,0));\n\t}\n}\n\nint solve(){\n\tint res = 1;\n\tREP(i,1){\n\t\tREP(j,n)if(i!=j)x[j]-=x[i],y[j]-=y[i];\n\t\tvector v;\n\t\tREP(j,n)if(i!=j){\n\t\t\tdouble ang1[2];\n\t\t\tdouble ang2[2];\n\t\t\tREP(type,2){\n\t\t\t\tdouble c = (type?-r[i]:r[i]);\n\t\t\t\t//a*x[j]+b*y[j] = c - rr;\n\t\t\t\t//aa+bb=1\n\t\t\t\tif(x[j]){\n\t\t\t\t\t// a = (c-rr-by[j])/x[j]\n\t\t\t\t\tdouble A = (c-r[j])/x[j];\n\t\t\t\t\tdouble B = -y[j]/double(x[j]);\n\t\t\t\t\t// a = A+Bb\n\t\t\t\t\t//(AA-1)+2ABb+(BB+1)bb=1\n\t\t\t\t\tdouble k1 = A*A-1;\n\t\t\t\t\tdouble k2 = 2*A*B;\n\t\t\t\t\tdouble k3 = B*B+1;\n\t\t\t\t\tdouble D = k2*k2-4*k1*k3;\n\t\t\t\t\tD = sqrt(D);\n\n\t\t\t\t\tdouble b1 = (-k2-D)/2/k3;\n\t\t\t\t\tdouble b2 = (-k2+D)/2/k3;\n\t\t\t\t\tdouble a1 = A + B*b1;\n\t\t\t\t\tdouble a2 = A + B*b2;\n\t\t\t\t\tif(a1<0) a1=-a1,b1=-b1,c=-c,a2=-a2,b2=-b2;\n\t\t\t\t\tif(a1+eps>n>>k;\n\tREP(i,n) scanf(\"%d %d %d\",x+i,y+i,r+i);\n\tcout<\nusing namespace std;\ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\n#define pb push_back\n#define mp make_pair\n#define fi first\n#define se second\n#define sz(a) int(a.size())\nconst int N=2e5+10;\n\nint gi() {\n\tint x=0,o=1;char ch=getchar();\n\twhile((ch<'0'||ch>'9')&&ch!='-') ch=getchar();\n\tif(ch=='-') o=-1,ch=getchar();\n\twhile(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();\n\treturn x*o;\n}\n\nint n,m,k,dx[6]={1,-1,0,0,0,0},dy[6]={0,0,1,-1,0,0},dz[6]={0,0,0,0,1,-1},a[N];\nvi vec[N];\n\nvoid No() {\n\tcout<<-1;exit(0);\n}\n\nint id(int x,int y,int z) {\n\treturn (x-1)*m*k+(y-1)*k+z;\n}\n\nbool in(int x,int y,int z) {\n\treturn 1<=x&&x<=n&&1<=y&&y<=m&&1<=z&&z<=k;\n}\n\nvoid erase(int,int,int);\n\nvoid insert(int d,int x,int y,int z,int c) {\n\tif(!in(x,y,z)) {\n\t\tif(c) No(); return;\n\t}\n\tint t=id(x,y,z);\n\tif(!c) {\n\t\tif(a[t]>0) erase(x,y,z); a[t]=0;\n\t\tinsert(d,x+dx[d],y+dy[d],z+dz[d],c);\n\t}\n\telse if(!~a[t]||a[t]==c) {\n\t\ta[t]=c;vec[t].pb(d);\n\t}\n\telse if(!a[t]) insert(d,x+dx[d],y+dy[d],z+dz[d],c);\n\telse erase(x,y,z),a[t]=0,insert(d,x+dx[d],y+dy[d],z+dz[d],c);\n}\n\nvoid erase(int x,int y,int z) {\n\tint t=id(x,y,z);\n\twhile(!vec[t].empty()) {\n\t\tint d=vec[t].back();vec[t].pop_back();\n\t\tinsert(d,x+dx[d],y+dy[d],z+dz[d],a[t]);\n\t}\n}\n\nint main() {\n\tmemset(a,-1,sizeof(a));\n\tcin>>n>>m>>k;\n\tfor(int i=1;i<=m;i++)\n\t\tfor(int j=1;j<=k;j++) insert(0,1,i,j,gi());\n\tfor(int i=1;i<=m;i++)\n\t\tfor(int j=1;j<=k;j++) insert(1,n,i,j,gi());\n\tfor(int i=1;i<=n;i++)\n\t\tfor(int j=1;j<=k;j++) insert(2,i,1,j,gi());\n\tfor(int i=1;i<=n;i++)\n\t\tfor(int j=1;j<=k;j++) insert(3,i,m,j,gi());\n\tfor(int i=1;i<=n;i++)\n\t\tfor(int j=1;j<=m;j++) insert(4,i,j,1,gi());\n\tfor(int i=1;i<=n;i++)\n\t\tfor(int j=1;j<=m;j++) insert(5,i,j,k,gi());\n\tfor(int i=1;i<=n*m*k;i++) cout<\n#include \n#define ff first\n#define ss second\n#define szof(x) ((int)x.size())\n#ifndef LOCAL\n# define cerr __get_ce\n#endif\n\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef unsigned long long ull;\n\nusing namespace __gnu_pbds;\ntemplate using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate using ordered_map = tree, rb_tree_tag, tree_order_statistics_node_update>;\n\nint const INF = (int)1e9 + 1e3;\nll const INFL = (ll)1e18 + 1e6;\n#ifdef LOCAL\n\tmt19937 tw(9450189);\n#else\n\tmt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());\n#endif\nuniform_int_distribution ll_distr;\nll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }\n\n\nvoid solve() {\n\tint n;\n\tcin >> n;\n\tvector color(n);\n\tfor (int& num : color) {\n\t\tcin >> num;\n\t}\n\tvector> graph(n);\n\tfor (int i = 0; i < n - 1; ++i) {\n\t\tint a, b;\n\t\tcin >> a >> b;\n\t\t--a; --b;\n\t\tgraph[a].push_back(b);\n\t\tgraph[b].push_back(a);\n\t}\n\n\tint ans = INF;\n\n\tint cnt1 = 0, cnt2 = 0;\n\t{\n\t\tvector used(n);\n\t\tfunction dfs = [&](int v) {\n\t\t\tused[v] = true;\n\t\t\tfor (int to : graph[v]) {\n\t\t\t\tif (color[to] == color[v] && !used[to]) {\n\t\t\t\t\tdfs(to);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tif (!used[i]) {\n\t\t\t\tdfs(i);\n\t\t\t\tif (color[i] == 1) {\n\t\t\t\t\t++cnt1;\n\t\t\t\t}\n\t\t\t\tif (color[i] == 2) {\n\t\t\t\t\t++cnt2;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n\n\tans = min(ans, 1 + cnt2);\n\tans = min(ans, 1 + cnt1);\n\n\tfor (int qwe = 0; qwe < 2; ++qwe) {\n\t\tvector sz(n);\n\t\tconst int MAXSZ = 4000;\n\t\tvector> dp(n, vector(MAXSZ, INF));\n\t\tvector next_dp(MAXSZ, INF);\n\t\tfunction dfs = [&](int v, int p) {\n\t\t\t// vector dp;\n\t\t\tif (color[v] == 1 || color[v] == 0) {\n\t\t\t\tdp[v][0] = 1;\n\t\t\t\tdp[v][2] = 3;\n\t\t\t} else {\n\t\t\t\t// dp = {INF, 2};\n\t\t\t\tdp[v][1] = 2;\n\t\t\t}\n\t\t\tsz[v] = 1;\n\t\t\tfor (int to : graph[v]) {\n\t\t\t\tif (to != p) {\n\t\t\t\t\tdfs(to, v);\n\t\t\t\t\tint mem_sz = sz[v] + 2;\n\t\t\t\t\tsz[v] += sz[to];\n\t\t\t\t\t// vector next_dp(min(MAXSZ, sz[v] + 2), INF);\n\t\t\t\t\tint tmp_sz = min(MAXSZ, sz[v] + 2);\n\t\t\t\t\tfor (int i = 0; i < tmp_sz; ++i) {\n\t\t\t\t\t\tint dp_val = INF;\n\t\t\t\t\t\tif (i < mem_sz) {\n\t\t\t\t\t\t\tdp_val = dp[v][i];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif ((color[v] == 1 || color[v] == 0) && i % 2 == 0) {\n\t\t\t\t\t\t\t\tdp_val = i + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ((color[v] == 2 || color[v] == 0) && i % 2 == 1) {\n\t\t\t\t\t\t\t\tdp_val = i + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int j = 0; j < sz[to] + 2 && j < MAXSZ; ++j) {\n\t\t\t\t\t\t\tnext_dp[i] = min(next_dp[i], dp_val + dp[to][j] - min(i, j) - 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tswap(next_dp, dp[v]);\n\t\t\t\t\tfill(next_dp.begin(), next_dp.begin() + min(MAXSZ, mem_sz), INF);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// return dp;\n\t\t};\n\n\t\tdfs(0, 0);\n\t\tans = min(ans, *min_element(dp[0].begin(), dp[0].end()));\n\n\t\tfor (int& num : color) {\n\t\t\tif (num == 1) {\n\t\t\t\tnum = 2;\n\t\t\t} else if (num == 2) {\n\t\t\t\tnum = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << ans << \"\\n\";\n}\n\n\nint main() {\n#ifdef LOCAL\n\tauto start_time = clock();\n\tcerr << setprecision(3) << fixed;\n#endif\n\tcout << setprecision(15) << fixed;\n\tios::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\n\tint test_count = 1;\n\tcin >> test_count;\n\tfor (int test = 1; test <= test_count; ++test) {\n\t\tsolve();\n\t}\n\n#ifdef LOCAL\n\tauto end_time = clock();\n\tcerr << \"Execution time: \" << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << \" ms\\n\";\n#endif\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "305fe49ef63c658aea06ec0c8f8399d4", "src_uid": "7c5ae79eeff98960fb52416541dd6528", "difficulty": 3000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std; \nint main() \n{ \nstring s; \ncin \u00bb s; \nstring temp = \"\"; \nint pi = s.size() - 1; \nfor (int i = 0; i <= pi; i++) { \ntemp += s[0]; \nint dl = temp.size(); \nint dl2 = dl + (s.size() - dl) / 2; \nif (s.substr(((s.size() - dl) / 2), dl) == temp) \n{ \nif (s.substr(0, dl2) == s.substr(dl2 - dl, dl2)) { \ncout \u00ab \"YES\\n\"; \ncout \u00ab temp; \nreturn 0; \n} \n} \n} \ncout \u00ab \"NO\"; \n}\n21.03.16\t\n\n\u042e\u0440\u0438\u0439\n#include \n#include \nusing namespace std; \nint main() \n{ \nstring s; \ncin \u00bb s; \nstring temp = \"\"; \nint pi = s.size() - 1; \nfor (int i = 0; i <= pi-1; i++) { \ntemp += s[i]; \nint dl = temp.size(); \nint dl2 = dl + (s.size() - dl) / 2; \nif ((s.size() - dl) %2==0&&s.substr(((s.size() - dl) / 2), dl) == temp) \n{ \nif (s.substr(0, dl2) == s.substr(dl2 - dl, dl2)) { \ncout \u00ab \"YES\\n\"; \ncout \u00ab s.substr(0, dl2); \nreturn 0; \n} \n} \n} \ncout \u00ab \"NO\"; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "da649f0c0121f0316582062b4692a9f2", "src_uid": "bfa78f72af4875f670f7adc5ed127033", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define forn(i, n) for(int i = 0; i < int(n); ++i)\n#define for1(i, n) for(int i = 1; i <= int(n); ++i)\n#define ford(i, n) for(int i = int(n) - 1; i >= 0; --i)\n#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)\n#define sz(v) int((v).size())\n#define all(v) (v).begin(), (v).end()\n#define pb push_back\n#define X first\n#define Y second\n#define mp make_pair\n#define debug(x) {cerr << #x << \" = \" << x << endl;}\ntemplate inline T abs(T a){ return ((a < 0) ? -a : a); }\ntemplate inline T sqr(T a){ return a * a; }\n\ntypedef long long li;\ntypedef long double ld;\ntypedef pair pt;\n\nconst int INF = (int)1E9 + 7;\nconst ld EPS = 1E-9;\nconst ld PI = 3.1415926535897932384626433832795;\n\nconst int NMAX = 6000;\n\nint n;\nvector a[NMAX];\nvector ls[NMAX];\nint it[NMAX], git[NMAX];\n\nint ks[NMAX], a0s[NMAX], xs[NMAX], ys[NMAX], ms[NMAX];\n\nint main() {\n #ifdef myproject\n freopen(\"input.txt\", \"rt\", stdin);\n //freopen(\"output.txt\", \"wt\", stdout);\n #endif\n\n scanf(\"%d\", &n);\n\n int ans = 0;\n\n int sumk = 0;\n\n forn(i, n){\n int k, a0, x, y, m;\n scanf(\"%d%d%d%d%d\", &k, &a0, &x, &y, &m);\n ks[i] = k, a0s[i] = a0, xs[i] = x, ys[i] = y, ms[i] = m;\n sumk += k;\n } \n// cerr << \"x = \" << x << endl;\n\n if(sumk <= 200000){\n forn(i, n){\n int k = ks[i], a0 = a0s[i], x = xs[i], y = ys[i], m = ms[i];\n\n a[i].pb(a0);\n forn(j, k-1){\n int na = (li(a[i].back() * 1LL * x) + y) % m;\n a[i].pb(na);\n }\n\n forn(j, k){\n int t = j;\n while(t+1 < sz(a[i]) && a[i][t] <= a[i][t+1])\n t++;\n\n ls[i].pb(t);\n\n j = t;\n }\n\n ans = max(ans, sz(ls[i]) - 1);\n // cerr << endl;\n\n sumk += k;\n }\n\n set s, qs;\n\n forn(i, n)\n s.insert(mp(a[i][0], i));\n\n printf(\"%d\\n\", ans);\n while(!s.empty()){\n // qs.clear();\n\n while(!s.empty()){\n\n int i = s.begin()->Y;\n int v = s.begin()->X;\n s.erase(s.begin());\n\n\n printf(\"%d %d\\n\", v, i+1);\n\n if(it[i] != ls[i][git[i]]){\n it[i]++;\n s.insert(mp(a[i][it[i]], i)); \n }else{\n if(it[i] != sz(a[i]) - 1){\n it[i]++, git[i]++;\n qs.insert(mp(a[i][it[i]], i));\n }\n }\n }\n\n s = qs;\n qs.clear();\n }\n }else{\n forn(i, n){\n int k = ks[i], a0 = a0s[i], x = xs[i], y = ys[i], m = ms[i];\n\n int pa = a0, cur = 0;\n forn(j, k-1){\n int na = (li(pa * 1LL * x) + y) % m;\n\n if(na < pa) cur++;\n pa = na;\n }\n ans = max(ans, cur);\n }\n printf(\"%d\\n\", ans);\n }\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a061771df24b6add90458e15756730e3", "src_uid": "15ba633cb33854bd4c0ee40847bb173c", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#define _USE_MATH_DEFINES\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define FOR(i,m,n) for(int i=(m);i<(n);++i)\n#define REP(i,n) FOR(i,0,n)\n#define ALL(v) (v).begin(),(v).end()\n\nconst int INF = 0x3f3f3f3f;\nconst long long LINF = 0x3f3f3f3f3f3f3f3fLL;\nconst double EPS = 1e-8;\nconst int MOD = 998244353;\nconst int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};\n/*-------------------------------------------------*/\nint mod = MOD;\nstruct ModInt {\n unsigned val;\n ModInt(): val(0) {}\n ModInt(long long x) : val(x >= 0 ? x % mod : x % mod + mod) {}\n ModInt pow(long long exponent) {\n ModInt tmp = *this, res = 1;\n while (exponent > 0) {\n if (exponent & 1) res *= tmp;\n tmp *= tmp;\n exponent >>= 1;\n }\n return res;\n }\n ModInt &operator+=(const ModInt &rhs) { if((val += rhs.val) >= mod) val -= mod; return *this; }\n ModInt &operator-=(const ModInt &rhs) { if((val += mod - rhs.val) >= mod) val -= mod; return *this; }\n ModInt &operator*=(const ModInt &rhs) { val = (unsigned long long)val * rhs.val % mod; return *this; }\n ModInt &operator/=(const ModInt &rhs) { return *this *= rhs.inv(); }\n bool operator==(const ModInt &rhs) const { return val == rhs.val; }\n bool operator!=(const ModInt &rhs) const { return val != rhs.val; }\n bool operator<(const ModInt &rhs) const { return val < rhs.val; }\n bool operator<=(const ModInt &rhs) const { return val <= rhs.val; }\n bool operator>(const ModInt &rhs) const { return val > rhs.val; }\n bool operator>=(const ModInt &rhs) const { return val >= rhs.val; }\n ModInt operator-() const { return ModInt(-val); }\n ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }\n ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }\n ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }\n ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }\n friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.val; }\n friend istream &operator>>(istream &is, ModInt &rhs) { long long x; is >> x; rhs = ModInt(x); return is; }\nprivate:\n ModInt inv() const {\n // if (__gcd((int)val, mod) != 1) assert(false);\n unsigned a = val, b = mod; int x = 1, y = 0;\n while (b) {\n unsigned tmp = a / b;\n a -= tmp * b; swap(a, b);\n x -= tmp * y; swap(x, y);\n }\n return ModInt(x);\n }\n};\nModInt abs(const ModInt &x) { return x.val; }\nstruct Combinatorics {\n Combinatorics(int MAX = 5000000) {\n MAX <<= 1;\n fact.resize(MAX + 1);\n fact_inv.resize(MAX + 1);\n fact[0] = 1;\n FOR(i, 1, MAX + 1) fact[i] = fact[i - 1] * i;\n fact_inv[MAX] = ModInt(1) / fact[MAX];\n for (int i = MAX; i > 0; --i) fact_inv[i - 1] = fact_inv[i] * i;\n }\n ModInt nCk(int n, int k) {\n if (n < 0 || n < k || k < 0) return ModInt(0);\n return fact[n] * fact_inv[k] * fact_inv[n - k];\n }\n ModInt nPk(int n, int k) {\n if (n < 0 || n < k || k < 0) return ModInt(0);\n return fact[n] * fact_inv[n - k];\n }\n ModInt nHk(int n, int k) {\n if (n < 0 || k < 0) return ModInt(0);\n return (k == 0 ? ModInt(1) : nCk(n + k - 1, k));\n }\nprivate:\n vector fact, fact_inv;\n};\n\nint main() {\n cin.tie(0); ios::sync_with_stdio(false);\n // freopen(\"input.txt\", \"r\", stdin);\n\n int n, m; cin >> n >> m;\n vector a(n); REP(i, n) cin >> a[i];\n vector w(n); REP(i, n) cin >> w[i];\n int dl = 0, l = 0;\n REP(i, n) (a[i] == 0 ? dl : l) += w[i];\n vector > dp(m + 1, vector(m + 1, 0));\n dp[0][0] = 1;\n REP(i, m) REP(j, m) {\n int sum = l + dl - j + (i - j);\n if (j > dl || j > i || sum <= 0) continue;\n dp[i + 1][j + 1] += dp[i][j] * (dl - j) / sum;\n dp[i + 1][j] += dp[i][j] * (l + (i - j)) / sum;\n }\n vector ans(2, 0);\n ModInt tmp = 1;\n REP(i, dl + 1) {\n if (i > m) break;\n ans[0] += tmp * dp[m][i];\n if (i < dl) tmp *= (ModInt(1) - ModInt(1) / (dl - i));\n }\n tmp = 1;\n REP(i, l + 1) {\n if (i > m) break;\n ans[1] += tmp * dp[m][m - i];\n tmp *= (ModInt(1) + ModInt(1) / (l + i));\n }\n REP(i, n) cout << ans[a[i]] * w[i] << '\\n';\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f9c51b0e2457631d6b11556e9407902c", "src_uid": "ba9c136f84375cd317f0f8b53e3939c7", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "// All Heil Fire Lord Zuko\n\n#include \nusing namespace std;\n\n#define int long long\n\nint ans, check = 1, num = 0, string s;\n\nint32_t main() {\n\tios::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n int ans = 0;\n int check = 1;\n int num = 0;\n string s;\n cin >> s;\n for(auto i : s) {\n if (i == '-' || i == '+') {\n ans += check * num;\n if (i == '-')\n check = -1;\n else\n check = 1;\n num = 0;\n }\n num = 10 * num + (i - '0');\n }\n ans += check * num;\n cout << ans;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b47d9d1c79d2bbc7597d725592d3f525", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include\n\n#define fo(i,a,b) for(int i=a;i<=b;i++)\n#define fd(i,a,b) for(int i=a;i>=b;i--)\n\nusing namespace std;\n\ntypedef long long LL;\ntypedef double db;\n\nint get(){\n\tchar ch;\n\twhile(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');\n\tif (ch=='-'){\n\t\tint s=0;\n\t\twhile(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';\n\t\treturn -s;\n\t}\n\tint s=ch-'0';\n\twhile(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';\n\treturn s;\n}\n\nconst int N = 1e4+5;\n\nint n;\ndb c,p[N];\ndb f[2][N],g[2][N],ans[2][N],Ans[2][N];\ndb js[N];\n\ndb choose(int n,int m){return n\n#include\n#include\n#include\n#include\n#include\n#include\n#include \n#define ll long long\nusing namespace std;\nconst int maxn=230010;\nconst int inf=-0x3f3f3f3f;\ninline int read(){\n\tint f=0,x=0;char ch=getchar();\n\twhile(!isdigit(ch)){f|=ch=='-';ch=getchar();}\n\twhile(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}\n\treturn f?-x:x;\n}\ninline void write(int x){\n if(x<0){putchar('-');x=-x;}\n if(x>9)write(x/10);\n putchar(x%10+'0');\n}\nbitsetch,bl,cn,e;\nchar s1[155],s2[10050];int n,m,k;\nint main()\n{\n//\tfreopen(\".in\",\"r\",stdin);\n//\tfreopen(\".out\",\"w\",stdout);\n\tn=read();m=read();k=read();\n\tfor(int i=1;i<=n;++i){\n\t\tscanf(\"%s\",s1+1);\n\t\tfor(int j=1;j<=m;++j){\n\t\t\t(s[j]=='#'?bl:cn).set((i-1)*m+j);\n\t\t\t(s[j]=='E'?e.set((i-1)*m+j):0);\n\t\t}\n\t}\n\tscanf(\"%s\",s2+1);\n\tch=cn;\n\tfor(int i=1;i<=k;++i){\n\t\tif(s[i]=='U')ch=(((ch>>m)&cn)|((bl<>m)&ch));\n\t\tif(s[i]=='L')ch=(((ch>>1)&cn)|((bl<<1)&ch));\n\t\tif(s[i]=='R')ch=(((ch<<1)&cn)|((bl>>1)&ch));\n\t\tif(ch==e){ \n\t\t write(i);return 0;\n\t\t}\n\t}\n\twrite(-1);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f1a26d3a63c74e99488a406501f3d903", "src_uid": "70ab617d9b8813ddf3039c6fb137d817", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define FOR(a,b,c) for(int a=(b),a##_end__=(c);ainline bool chkmin(T&a,T const&b){return a>b?a=b,true:false;}\ntemplateinline bool chkmax(T&a,T const&b){return aA[u][k]) swap(tmp,A[u][k]);\n\tadd_edge(u,w,G);\n}\nvoid Tarjan(int u,int fa){\n\tlow[u]=dfn[u]=++dfn_cnt;\n\tfor(edge *e=u[E];e;e=e->next){\n\t\tint v=e->to;\n\t\tif(v==fa) continue;\n\t\tif(!v[dfn]){\n\t\t\tdep[v]=dep[u]+1;\n\t\t\tTarjan(v,Fa[v]=u);\n\t\t\tchkmin(low[u],low[v]);\n\t\t}else chkmin(low[u],dfn[v]);\n\t}\n\tfor(edge *e=u[E];e;e=e->next){\n\t\tif((Fa[e->to]!=u and low[e->to]==dfn[u]) or low[e->to]>dfn[u])\n\t\t\tsolve_ring(u,e->to);\n\t}\n}\nint main(){\n\tscanf(\"%d%d\",&n,&m);\n\twhile(m--){\n\t\tint u,v;\n\t\tscanf(\"%d%d\",&u,&v);\n\t\tadd_edge(u,v,E);\n\t\tadd_edge(v,u,E);\n\t}\n\tscc_cnt=n;\n\tTarjan(1,-1);\n\tint l=0,r=0;\n\tQ[r++]=1;\n\twhile(lnext){\n\t\t\tint w=e->to,sz=0;\n\t\t\tQ0.clear(),Q1.clear();\n\t\t\tval[sz]=A[u][B[w-n]==A[u][0]];\n\t\t\tid[sz++]=u;\n\t\t\tfor(edge*e=G[w];e;e=e->next){\n\t\t\t\tQ[r++]=id[sz]=e->to;\n\t\t\t\tval[sz]=A[e->to][0];\n\t\t\t\t++sz;\n\t\t\t}\n\t\t\tFOR(i,0,sz) val[i+sz+sz]=val[i+sz]=val[i];\n\t\t\tint len0=sz>>1,pos0=sz+1;\n\t\t\tint len1=sz-len0-1,pos1=sz+len1+2;\n\t\t\tFOR(i,pos0-len0,pos0) Q0.push(i,val[i]-i);\n\t\t\tFOR(i,pos1-len1,pos1) Q1.push(i,val[i]+i);\n\t\t\tFOR(i,1,sz){\n\t\t\t\tint u=id[i];\n\t\t\t\tint x=Q0.maxn(pos0-len0)+i+sz;\n\t\t\t\tint y=Q1.maxn(pos1-len1)-i-sz;\n\t\t\t\tFOR(k,0,2) if(x>A[u][k]) swap(x,A[u][k]);\n\t\t\t\tFOR(k,0,2) if(y>A[u][k]) swap(y,A[u][k]);\n\t\t\t\tQ0.push(pos0,val[pos0]-pos0),++pos0;\n\t\t\t\tQ1.push(pos1,val[pos1]+pos1),++pos1;\n\t\t\t}\n\t\t}\n\t}\n\tFOR(i,1,n+1) printf(\"%d \",A[i][0]);\n\tputs(\"\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1e4a8ebf6148813902013bcda88cc6bb", "src_uid": "c980495a264a6314f45c230daf19c2e0", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint read(){\n int x=0,f=1;char c=getchar();\n while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();\n while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();\n return x*f;\n}\ntypedef unsigned long long ull;\nconst int INF=1e9;\nconst int N=2e5+5;\nstruct node{\n ull mx:18,ls:23,rs:23;\n}a[N*40];\nint tot=0,ra[N];\nint update(int p,int l,int r,int ql,int qr){\n\tif(l==r)\n\t\treturn p+1;\n\tint o=++tot;a[o]=a[p];\n\tif(ql<=l&&r<=qr)\n\t\treturn ++a[o].mx,o;\n\tint mid=(l+r)>>1,tag=a[o].mx-max((l==mid?int(a[o].ls):int(a[a[o].ls].mx)),(mid+1==r?int(a[o].rs):int(a[a[o].rs].mx)));\n\tif(ql<=mid)\n\t\ta[o].ls=update(a[p].ls,l,mid,ql,qr);\n\tif(qr>mid)\n\t\ta[o].rs=update(a[p].rs,mid+1,r,ql,qr);\n\ta[o].mx=max((l==mid?int(a[o].ls):int(a[a[o].ls].mx)),(mid+1==r?int(a[o].rs):int(a[a[o].rs].mx)));\n\ta[o].mx+=tag;\n\treturn o;\n}\nint query(int o,int l,int r,int ql,int qr){\n\tif(l==r)\n\t\treturn o;\n\tif(ql<=l&&r<=qr)\n\t\treturn a[o].mx;\n\tint mid=(l+r)>>1,res=0,tag=a[o].mx-max((l==mid?int(a[o].ls):int(a[a[o].ls].mx)),(mid+1==r?int(a[o].rs):int(a[a[o].rs].mx)));\n\tif(ql<=mid)\n\t\tres=max(res,query(a[o].ls,l,mid,ql,qr));\n\tif(qr>mid)\n\t\tres=max(res,query(a[o].rs,mid+1,r,ql,qr));\n\treturn res+tag;\n}\npairp[N];\nint main(){\n\tint n=read(),m=read();\n\tfor(int i=1;i<=N;i++)\n\t\tp[i].first=-1*read(),p[i].second=i;\n\tsort(&p[1],&p[N+1]);\n\tfor(int i=1;i<=n;i++){\n\t\tint ql=max(1,p[i].second-m+1);\n\t\tint qr=min(p[i].second,n-m+1);\n\t\tra[i]=update(ra[i-1],1,n-m+1,ql,qr);\n\t}\n\tint Q=read(),ans=0;\n\twhile(Q--){\n\t\tint l=read(),r=read(),x=read();\n\t\tx^=ans;\n\t\tint id=upper_bound(&p[1],&p[n+1],make_pair(-x,INF))-p-1;\n\t\tprintf(\"%d\\n\",ans=m-query(ra[id],1,n-m+1,l,r));\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4f08d316dc308569ed740a30e9660a87", "src_uid": "92c773d61414ec6a13cdfbdcd24a2b0d", "difficulty": 3200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define _USE_MATH_DEFINES\n#include \n#include \nusing namespace std;\nvoid main()\n{\n\t//ios_base::sync_with_stdio(false);\n\t//ifstream cin(\"input.txt\");\n\tint n,m;\n\tvector a,b;\n\tb.resize(2000000,-1);\n\tscanf(\"%d %d\",&n,&m);\n\ta.resize(2*n);\n\tfor (int i=0;i>a[i];\n\t\ta[i]--;\n\t\ta[n+i]=a[i];\n\t}\n\t__int64 q;\n\tfor (int i=0;i>q;\n\t\tq--;\n\t\tb[q]=i;\n\t}\n\t__int64 res=0;\n\t__int64 l=-1;\n\tdeque <__int64> qq;\n\tfor (int r=0;r<2*n;r++)\n\t{\n\t\tif (b[a[r]]==-1)\n\t\t{\n\t\t\tl=-1;\n\t\t\tqq.clear();\n\t\t\tcontinue;\n\t\t}\n\t\tq=b[a[r]];\n\t\tif (!qq.empty())\n\t\t{\n\t\t\tif (qm))\n\t\t\t\tqq.pop_front();\n\t\t}\n\t\tqq.push_back(q);\n\t\tif (qq.size()<=m&&qq.size()<=n)\n\t\t\tres=max<__int64> (res,qq.size());\n\t}\n\tprintf(\"%d\",res);\n}res);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b2a90be7e7880403e3d0dc55b61d225b", "src_uid": "13cd1aafbb1ba76be9ee10eaf8d8aef5", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\nchar a,b;\nvector opt;\nint qxx[2000][2],tt[2000],nn,jz[2000],rd[2000];\nbool te,hb[2000];\nvoid ad(int u,int v){\n\t++rd[v];\n\tqxx[++nn][0]=v;\n\tqxx[nn][1]=tt[u];\n\ttt[u]=nn;\n}\n#define bl(u,i)\tfor(int i=tt[u];i;i=qxx[i][1])\n#define _r scanf(\"%c\",&a);\nint n1,n2;\nvoid dfs(int now){\n\thb[now]=true;\n\tif(tt[now]==0){\n\t\tjz[now]=1;\n\t\treturn;\n\t}\n\tbl(now,i){\n\t\tif(hb[qxx[i][0]]){\n\t\t\tte=true;\n\t\t\treturn;\n\t\t}\n\t\tdfs(qxx[i][0]);\n\t\tjz[now]=max(jz[now],jz[qxx[i][0]]+1);\n\t}\n\tif(jz[now]>10)\tte=true;\n\treturn;\n}\nint main(){\n\t_r\n\t_r\n\twhile(a!=')'){\n\t\t_r;\n\t\tif(a=='_')\t++n1;\n\t\telse if(n1!=0)\topt.push_back(n1),n1=0;\n\t}\n\t_r\n\t_r\n\twhile(a!='.'){\n\t\tn1=n2=0;\n\t\t_r;\n\t\twhile(a=='_'){\n\t\t\t++n1;_r\n\t\t}\n\t\tb=a;\n\t\t_r\n\t\twhile(a=='_'){\n\t\t\t++n2;_r\n\t\t}\n\t\tif(n1==n2){\n\t\t\tprintf(\"false\");\n\t\t\treturn 0;\n\t\t}\n\t\tif(b=='<')\tad(n2,n1);\n\t\telse\tad(n1,n2);\n\t}\n\tfor(int i=0;i\n#include \n\nusing namespace std;\n\nint radio;\nlong long res=0, son=0, col;\nlong long double x=-.5, y=.5;\n\ndouble dist(double x1, double y1, double x2, double y2){\n return sqrt( (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1) );\n}\n\nbool dentro(double uno, double dos){\n bool sip=true;\n sip=sip&(dist(uno, dos, 0, 0)<=radio);\n uno+=1;\n sip=sip&(dist(uno, dos, 0, 0)<=radio);\n uno+=.5;\n dos-=sqrt(3.0)/2.0;\n sip=sip&(dist(uno, dos, 0, 0)<=radio);\n uno-=.5;\n dos-=sqrt(3.0)/2.0;\n sip=sip&(dist(uno, dos, 0, 0)<=radio);\n uno-=1;\n sip=sip&(dist(uno, dos, 0, 0)<=radio);\n uno-=.5;\n dos+=sqrt(3.0)/2.0;\n sip=sip&(dist(uno, dos, 0, 0)<=radio);\n return sip;\n}\n\nint main()\n{\n cin>>radio;\n while(dentro(x, y*sqrt(3.0))){\n ++res;\n ++y;\n }\n --y;\n col=res-1;\n res+=res-1;\n for(int va=1; y>0; va++){\n if(va%2==1){\n ++col;\n }\n x+=1.5;\n y+=.5;\n while(!dentro(x, y*sqrt(3.0)) and y>0){\n --col;\n --y;\n }\n if(!dentro(x, y*sqrt(3.0))){\n res+=son*2;\n cout<\n\nusing namespace std;\n\nconst int MaxN = 1e5 + 17;\nconst int INF = 1e9 + 17;\nlong long n, a, b, m, k, Ans;\nint main ()\n{ \n #ifdef Elibay \n freopen (\".in\", \"r\", stdin); \n #endif \n cin >> n >> m >> k;\n cin >> a >> b;\n long long pod1 = 1;\n for (; pod1 <= n; ++ pod1)\n \tif (pod1 * m * k >= a)\n \t\tbreak;\n long long pod2 = 1;\n for (; pod2 <= n; ++ pod2)\n \tif (pod2 * m * k >= b)\n \t\tbreak;\n Ans += min (abs (pod2 - pod1), (n - max (pod1, pod2) + min (pod1, pod2))) * 15;\n a -= (pod1 - 1) * m * k;-\n b -= (pod2 - 1) * m * k;\n long long etzh = (a - 1) / k;\n long long etzh2 = (b - 1) / k;\n Ans += min (10 + etzh, 5 * etzh);\n Ans += min (10 + etzh2, 5 * etzh2);\n cout << Ans;\n return 0; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "685a29740adad34136ccd17a42fb49cd", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define ll long long\n\nusing namespace std;\n\nvoid Find_size(int v);\nvoid Build(int root, vector &values);\nvoid Solve();\n\nll RAND(ll n) {\n return abs((rand() << 15) + rand()) % n;\n}\n\nint n;\nvector> g;\nvector> edges;\nvector used;\nvector size;\n\nint Find_centroid(int v, int sz) {\n used[v] = true;\n Find_size(v);\n int max_size = -1;\n for (auto to:g[v]) {\n if (!used[to] && size[to] > sz / 2 && (max_size == -1 || size[to] > size[max_size])) {\n max_size = to;\n }\n }\n int ans;\n if (max_size == -1) {\n ans = v;\n } else {\n ans = Find_centroid(max_size, sz);\n }\n used[v] = false;\n return ans;\n}\n\nvoid Find_size(int v) {\n size[v] = 1;\n used[v] = true;\n for (auto to:g[v]) {\n if (!used[to]) {\n Find_size(to);\n size[v] += size[to];\n }\n }\n used[v] = false;\n}\n\nvoid Build(int root, vector &values) {\n vector val(values.size() + 1, 0);\n int cur_ind = 0;\n used[root] = true;\n queue q;\n q.push(root);\n while (!q.empty()) {\n int cur = q.front();\n q.pop();\n for (auto to:g[cur]) {\n if (!used[to]) {\n used[to] = true;\n q.push(to);\n edges[cur][to] = values[cur_ind++] - val[cur];\n edges[to][cur] = edges[cur][to];\n val[to] = val[cur] + edges[cur][to];\n }\n }\n }\n}\n\nvector parent;\nvector cap;\n\nvoid make_set(int x) {\n parent[x] = x;\n cap[x] = size[x];\n}\n\nint find_set(int x) {\n if (x == parent[x])\n return x;\n return parent[x] = parent[find_set(parent[x])];\n}\n\nvoid union_sets(int x, int y) {\n int a = find_set(x);\n int b = find_set(y);\n if (a != b) {\n if (cap[a] < cap[b])\n swap(a, b);\n parent[b] = a;\n cap[a] += cap[b];\n }\n}\n\nvoid Solve() {\n int c = Find_centroid(0, n);\n Find_size(c);\n\n auto compare = [](int lhs, int rhs) {\n return cap[lhs] > cap[rhs];\n };\n std::priority_queue, decltype(compare)> q(compare);\n\n for (int i = 0; i < n; ++i) {\n if (i == c) {\n continue;\n }\n make_set(i);\n q.push(i);\n }\n\n while (q.size() > 2) {\n int x = q.top();\n q.pop();\n int y = q.top();\n q.pop();\n union_sets(x, y);\n q.push(find_set(x));\n }\n int x = q.top();\n q.pop();\n int y = q.top();\n q.pop();\n vector gr1(cap[find_set(x)]);\n vector gr2(cap[find_set(y)]);\n for (int i = 0; i < (int) gr1.size(); ++i) {\n gr1[i] = i + 1;\n }\n for (int i = 0; i < (int) gr2.size(); ++i) {\n gr2[i] = (i + 1) * gr1.size();\n }\n for (auto i:g[c]) {\n if (find_set(i) == y) {\n used[i] = true;\n }\n }\n Build(c, gr1);\n for (auto i:g[c]) {\n if (find_set(i) == y) {\n used[i] = false;\n }\n }\n Build(c, gr2);\n for (int i = 0; i < n; ++i) {\n used[i] = false;\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n cin >> n;\n g.resize(n);\n used.resize(n);\n edges.resize(n, vector(n, -1));\n size.resize(n);\n parent.resize(n);\n cap.resize(n);\n for (int i = 0; i < n - 1; ++i) {\n int u, v;\n cin >> u >> v;\n u--, v--;\n g[u].push_back(v);\n g[v].push_back(u);\n }\n Solve();\n for (int i = 0; i < n; ++i) {\n for (int j = i + 1; j < n; ++j) {\n if (edges[i][j] >= 0) {\n cout << i + 1 << ' ' << j + 1 << ' ' << edges[i][j] << endl;\n }\n }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d7f5fbd37bc75948559aac215423b123", "src_uid": "87d755df6ee27b381122062659c4a432", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nconst int p1 = 998244353, p2 = 469762049, Maxn = 1 << 17 | 5;\nint maxn, maxa, mod, rev[Maxn];\nint tot, l[Maxn];\nconst long long lcm = p1 * (long long) p2;\nvoid get_rev(int len)\n{\n\tfor (int i = 0; i < len; i++)\n\t\trev[i] = (rev[i >> 1] >> 1) | ((i & 1) * (len >> 1));\n}\nlong long fast_pow(long long x, long long y, int p)\n{\n\tlong long ans = 1, now = x;\n\twhile (y)\n\t{\n\t\tif (y & 1) ans = ans * now % p;\n\t\tnow = now * now % p;\n\t\ty >>= 1;\n\t}\n\treturn ans;\n}\nvoid NTT(int now[], int len, int p, bool type = false)\n{\n\tl[0] = 1;\n\tint inv3 = fast_pow(3, p - 2, p);\n\tfor (int i = 0; i < len; i++)\n\t\tif (i < rev[i]) swap(now[i], now[rev[i]]);\n\tfor (int i = 1; i < len; i <<= 1)\n\t{\n\t\tlong long w = fast_pow(type ? inv3 : 3, (p - 1) / (i << 1), p);\n\t\tfor (int j = 1; j < i; j++)\n\t\t\tl[j] = l[j - 1] * w % p;\n\t\tfor (int j = 0; j < len; j += (i << 1))\n\t\t\tfor (int k = j; k < i + j; k++)\n\t\t\t{\n\t\t\t\tint x = now[i + k] * (long long) l[k - j] % p, y = now[k];\n\t\t\t\tnow[k] = (x + y) % p;\n\t\t\t\tnow[i + k] = (y - x + p) % p;\n\t\t\t}\n\t}\n\tif (type)\n\t{\n\t\tlong long inv = fast_pow(len, p - 2, p);\n\t\tfor (int i = 0; i < len; i++)\n\t\t\tnow[i] = now[i] * inv % p;\n\t}\n}\nvoid multi(int x[], int y[], int result[], int len, int p)\n{\n\tNTT(x, len, p), NTT(y, len, p);\n\tfor (int i = 0; i < len; i++)\n\t\tresult[i] = x[i] * (long long) y[i] % p;\n\tNTT(result, len, p, true);\n}\nlong long mul(long long x, long long y)\n{\n\tlong long ans = 0, now = x;\n\twhile (y)\n\t{\n\t\tif (y & 1) ans = (ans + now) % lcm;\n\t\tnow = (now + now) % lcm;\n\t\ty >>= 1;\n\t}\n\treturn ans;\n}\nvoid multi(int x[], int y[], int result[], int len)\n{\n\tget_rev(len);\n\tstatic int tmp1[Maxn], tmp2[Maxn], tmpx[Maxn], tmpy[Maxn];\n\tfor (int i = 0; i < len; i++)\n\t\ttmpx[i] = x[i], tmpy[i] = y[i];\n\tmulti(tmpx, tmpy, tmp1, len, p1);\n\tfor (int i = 0; i < len; i++)\n\t\ttmpx[i] = x[i], tmpy[i] = y[i];\n\tmulti(tmpx, tmpy, tmp2, len, p2);\n\tfor (int i = 0; i < len; i++)\n\t\tresult[i] = (mul(mul(tmp1[i], p2), fast_pow(p2, p1 - 2, p1)) + mul(mul(tmp2[i], (__int128) p1), fast_pow(p1, p2 - 2, p2))) % lcm % mod;\n}\nvoid poly_pow(int y, int len)\n{\n\tint now = 0;\n\tstatic int ans[2][Maxn];\n\tmemset(ans[0], 0, sizeof(int[len << 1]));\n\tmemset(ans[1], 0, sizeof(int[len << 1]));\n\tstatic int tmp[Maxn], result[2][Maxn];\n\tfor (int j = 20; j >= 0; j--)\n\t{\n\t\tmemset(tmp, 0, sizeof(int[len << 1]));\n\t\tfor (int i = 0; i < len; i++)\n\t\t\ttmp[i] = (ans[0][i] + ans[1][i]) % mod;\n\t\ttmp[0]++;\n\t\tfor (int p = 0; p <= 1; p++)\n\t\t\tmulti(tmp, ans[(now & 1) ^ p], result[p], len << 1);\n\t\tfor (int p = 0; p <= 1; p++)\n\t\t\tfor (int i = 0; i < len; i++)\n\t\t\t\t(ans[p][i] += result[p][i]) %= mod;\n\t\tnow <<= 1;\n\t\tif (y & (1 << j))\n\t\t{\n\t\t\tfor (int i = len - 1; i; i--)\n\t\t\t\t(ans[1][i] += ans[0][i - 1] + ans[1][i - 1]) %= mod;\n\t\t\tans[1][1]++; \n\t\t\tnow++;\n\t\t}\n\t\tif (now != y)\n\t\t\tfor (int i = 1; i <= maxn; i += 2)\n\t\t\t\t(tot += ans[1][i]) %= mod;\n\t}\n}\nint lower(int x)\n{\n\tint tmp = 1;\n\tfor (; tmp < x; tmp <<= 1);\n\treturn tmp;\n}\nint main()\n{\n\tscanf(\"%d%d%d\", &maxn, &maxa, &mod);\n\tpoly_pow(maxa, lower(maxn + 1));\n\tprintf(\"%d\", tot);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "534000bf4df0763d3fee067778c09209", "src_uid": "aac481d9e5ea3e3d43b324c8750882be", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nmt19937 rng((long long) (new char));\n\nint sol=(int) 1e9+7;\nint op;\nint lim;\n\nint ask(int r,int c)\n{\n op++;\n if (op==lim)\n {\n cout<>x;\n sol=min(sol,x);\n return x;\n}\n\nvoid solve(int r1,int c1,int r2,int c2)\n{\n if (r1>r2 || c1>c2)\n {\n return;\n }\n if (r1==r2&&c1==c2)\n {\n ask(r1,c1);\n return;\n }\n int rm=(r1+r2)/2,mn=(int) 1e9+7;\n vector e;\n int same=0,ant=-1;\n for (int j=c1;j<=c2;j++)\n {\n int x=ask(rm,j);\n if (x==ant)\n {\n same++;\n }\n else\n {\n same=0;\n }\n mn=min(mn,x);\n e.push_back(x);\n }\n for (int j=c1;j<=c2;j++)\n if (e[j-c1]==mn)\n {\n if (rng()&1)\n {\n solve(r1,c1,rm-1,j);\n solve(rm+1,j,r2,c2);\n }\n else\n {\n solve(rm+1,j,r2,c2);\n solve(r1,c1,rm-1,j);\n }\n return;\n }\n}\n\nint main()\n{\n int n,m;\n cin>>n>>m;\n lim=4*(n+m);\n if ((ll)n*m<=lim)\n {\n for (int i=1;i<=n;i++)\n for (int j=1;j<=m;j++)\n ask(i,j);\n }\n else\n solve(1,1,n,m);\n cout<<\"! \"<\nusing namespace std;\nusing lint = long long;\nusing pint = pair;\nusing plint = pair;\nstruct fast_ios { fast_ios(){ cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_;\n#define ALL(x) (x).begin(), (x).end()\n#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--)\n#define REP(i, n) FOR(i,0,n)\n#define IREP(i, n) IFOR(i,0,n)\ntemplate \nvoid ndarray(vector& vec, const V& val, int len) { vec.assign(len, val); }\ntemplate void ndarray(vector& vec, const V& val, int len, Args... args) { vec.resize(len), for_each(begin(vec), end(vec), [&](T& v) { ndarray(v, val, args...); }); }\ntemplate bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }\ntemplate bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }\ntemplate pair operator+(const pair &l, const pair &r) { return make_pair(l.first + r.first, l.second + r.second); }\ntemplate pair operator-(const pair &l, const pair &r) { return make_pair(l.first - r.first, l.second - r.second); }\ntemplate vector srtunq(vector vec) { sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; }\ntemplate istream &operator>>(istream &is, vector &vec) { for (auto &v : vec) is >> v; return is; }\ntemplate ostream &operator<<(ostream &os, const vector &vec) { os << '['; for (auto v : vec) os << v << ','; os << ']'; return os; }\n#if __cplusplus >= 201703L\ntemplate istream &operator>>(istream &is, tuple &tpl) { std::apply([&is](auto &&... args) { ((is >> args), ...);}, tpl); return is; }\ntemplate ostream &operator<<(ostream &os, const tuple &tpl) { std::apply([&os](auto &&... args) { ((os << args << ','), ...);}, tpl); return os; }\n#endif\ntemplate ostream &operator<<(ostream &os, const deque &vec) { os << \"deq[\"; for (auto v : vec) os << v << ','; os << ']'; return os; }\ntemplate ostream &operator<<(ostream &os, const set &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }\ntemplate ostream &operator<<(ostream &os, const unordered_set &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }\ntemplate ostream &operator<<(ostream &os, const multiset &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }\ntemplate ostream &operator<<(ostream &os, const unordered_multiset &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }\ntemplate ostream &operator<<(ostream &os, const pair &pa) { os << '(' << pa.first << ',' << pa.second << ')'; return os; }\ntemplate ostream &operator<<(ostream &os, const map &mp) { os << '{'; for (auto v : mp) os << v.first << \"=>\" << v.second << ','; os << '}'; return os; }\ntemplate ostream &operator<<(ostream &os, const unordered_map &mp) { os << '{'; for (auto v : mp) os << v.first << \"=>\" << v.second << ','; os << '}'; return os; }\n#ifdef HITONANODE_LOCAL\n#define dbg(x) cerr << #x << \" = \" << (x) << \" (L\" << __LINE__ << \") \" << __FILE__ << endl\n#else\n#define dbg(x) {}\n#endif\n\n\n\nstruct ModIntRuntime {\n using lint = long long int;\n static int get_mod() { return mod; }\n int val;\n static int mod;\n static std::vector &facs() {\n static std::vector facs_;\n return facs_;\n }\n static int &get_primitive_root() {\n static int primitive_root_ = 0;\n if (!primitive_root_) {\n primitive_root_ = [&]() {\n std::set fac;\n int v = mod - 1;\n for (lint i = 2; i * i <= v; i++)\n while (v % i == 0) fac.insert(i), v /= i;\n if (v > 1) fac.insert(v);\n for (int g = 1; g < mod; g++) {\n bool ok = true;\n for (auto i : fac)\n if (ModIntRuntime(g).power((mod - 1) / i) == 1) {\n ok = false;\n break;\n }\n if (ok) return g;\n }\n return -1;\n }();\n }\n return primitive_root_;\n }\n static void set_mod(const int &m) {\n if (mod != m) facs().clear();\n mod = m;\n get_primitive_root() = 0;\n }\n ModIntRuntime &_setval(lint v) {\n val = (v >= mod ? v - mod : v);\n return *this;\n }\n ModIntRuntime() : val(0) {}\n ModIntRuntime(lint v) { _setval(v % mod + mod); }\n explicit operator bool() const { return val != 0; }\n ModIntRuntime operator+(const ModIntRuntime &x) const { return ModIntRuntime()._setval((lint)val + x.val); }\n ModIntRuntime operator-(const ModIntRuntime &x) const { return ModIntRuntime()._setval((lint)val - x.val + mod); }\n ModIntRuntime operator*(const ModIntRuntime &x) const { return ModIntRuntime()._setval((lint)val * x.val % mod); }\n ModIntRuntime operator/(const ModIntRuntime &x) const { return ModIntRuntime()._setval((lint)val * x.inv() % mod); }\n ModIntRuntime operator-() const { return ModIntRuntime()._setval(mod - val); }\n ModIntRuntime &operator+=(const ModIntRuntime &x) { return *this = *this + x; }\n ModIntRuntime &operator-=(const ModIntRuntime &x) { return *this = *this - x; }\n ModIntRuntime &operator*=(const ModIntRuntime &x) { return *this = *this * x; }\n ModIntRuntime &operator/=(const ModIntRuntime &x) { return *this = *this / x; }\n friend ModIntRuntime operator+(lint a, const ModIntRuntime &x) { return ModIntRuntime()._setval(a % mod + x.val); }\n friend ModIntRuntime operator-(lint a, const ModIntRuntime &x) { return ModIntRuntime()._setval(a % mod - x.val + mod); }\n friend ModIntRuntime operator*(lint a, const ModIntRuntime &x) { return ModIntRuntime()._setval(a % mod * x.val % mod); }\n friend ModIntRuntime operator/(lint a, const ModIntRuntime &x) { return ModIntRuntime()._setval(a % mod * x.inv() % mod); }\n bool operator==(const ModIntRuntime &x) const { return val == x.val; }\n bool operator!=(const ModIntRuntime &x) const { return val != x.val; }\n bool operator<(const ModIntRuntime &x) const { return val < x.val; } // To use std::map\n friend std::istream &operator>>(std::istream &is, ModIntRuntime &x) {\n lint t;\n is >> t;\n x = ModIntRuntime(t);\n return is;\n }\n friend std::ostream &operator<<(std::ostream &os, const ModIntRuntime &x) {\n os << x.val;\n return os;\n }\n\n lint power(lint n) const {\n lint ans = 1, tmp = this->val;\n while (n) {\n if (n & 1) ans = ans * tmp % mod;\n tmp = tmp * tmp % mod;\n n /= 2;\n }\n return ans;\n }\n ModIntRuntime pow(lint n) const { return power(n); }\n lint inv() const { return this->power(mod - 2); }\n ModIntRuntime operator^(lint n) const { return ModIntRuntime(this->power(n)); }\n ModIntRuntime &operator^=(lint n) { return *this = *this ^ n; }\n\n ModIntRuntime fac() const {\n int l0 = facs().size();\n if (l0 > this->val) return facs()[this->val];\n\n facs().resize(this->val + 1);\n for (int i = l0; i <= this->val; i++) facs()[i] = (i == 0 ? ModIntRuntime(1) : facs()[i - 1] * ModIntRuntime(i));\n return facs()[this->val];\n }\n\n ModIntRuntime doublefac() const {\n lint k = (this->val + 1) / 2;\n if (this->val & 1)\n return ModIntRuntime(k * 2).fac() / ModIntRuntime(2).power(k) / ModIntRuntime(k).fac();\n else\n return ModIntRuntime(k).fac() * ModIntRuntime(2).power(k);\n }\n\n ModIntRuntime nCr(const ModIntRuntime &r) const {\n if (this->val < r.val) return ModIntRuntime(0);\n return this->fac() / ((*this - r).fac() * r.fac());\n }\n\n ModIntRuntime sqrt() const {\n if (val == 0) return 0;\n if (mod == 2) return val;\n if (power((mod - 1) / 2) != 1) return 0;\n ModIntRuntime b = 1;\n while (b.power((mod - 1) / 2) == 1) b += 1;\n int e = 0, m = mod - 1;\n while (m % 2 == 0) m >>= 1, e++;\n ModIntRuntime x = power((m - 1) / 2), y = (*this) * x * x;\n x *= (*this);\n ModIntRuntime z = b.power(m);\n while (y != 1) {\n int j = 0;\n ModIntRuntime t = y;\n while (t != 1) j++, t *= t;\n z = z.power(1LL << (e - j - 1));\n x *= z, z *= z, y *= z;\n e = j;\n }\n return ModIntRuntime(std::min(x.val, mod - x.val));\n }\n};\nint ModIntRuntime::mod = 1;\n\nusing mint = ModIntRuntime;\nint main() {\n int N, M, P;\n cin >> N >> M >> P;\n mint::set_mod(P);\n\n vector ncr(M + N + 1, vector(N + M + 1));\n REP(i, ncr.size()) REP(j, ncr[i].size()) ncr[i][j] = mint(i).nCr(j);\n\n vector nbsuc(M + 1);\n vector dpsuc(M + 1);\n nbsuc[0] = 1;\n FOR(n, 1, M + 1) {\n REP(l, n) {\n int r = n - 1 - l;\n nbsuc[n] += nbsuc[l] * nbsuc[r] * ncr[n - 1][r] * (n + 1);\n dpsuc[n] += ncr[n - 1][r] * ((dpsuc[l] * nbsuc[r] + nbsuc[l] * dpsuc[r]) * (n + 1) + nbsuc[l] * nbsuc[r] * (l * (l + 1) + r * (r + 1)) / 2);\n }\n }\n dbg(dpsuc);\n dbg(nbsuc);\n\n vector dp0(M + 1, vector(M + 1)); // dp[i][j] i\u4eba\u4f7f\u3063\u3066j\u30b0\u30eb\u30fc\u30d7\u3067\u304d\u308b\u7d44\u5408\u305b\n vector dpv(M + 1, vector(M + 1)); // dp[i][j] i\u4eba\u4f7f\u3063\u3066j\u30b0\u30eb\u30fc\u30d7\u3067\u304d\u305f\u3068\u304d\u306e\u30b9\u30b3\u30a2\u5408\u8a08\n dp0[0][0] = 1;\n REP(i, M) REP(j, i + 1) if (dp0[i][j]) {\n FOR(k, 1, M + 1 - i) {\n dp0[i + k][j + 1] += dp0[i][j] * ncr[M - i][k] * nbsuc[k];\n dpv[i + k][j + 1] += dpv[i][j] * ncr[M - i][k] * nbsuc[k] + dp0[i][j] * ncr[M - i][k] * dpsuc[k];\n }\n }\n mint ret = 0;\n FOR(j, 1, N + 1) {\n mint tmp = dpv[M][j];\n int yo = N - M - (j - 1);\n if (yo < 0) continue;\n ret += tmp * ncr[yo + j][j];\n }\n\n cout << ret << '\\n';\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "34570b5cb753a8e4c9507a1af50b9656", "src_uid": "9812de5f2d272511a63ead8765b23190", "difficulty": 3100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n\n#define ll long long\n#define ft first\n#define sd second\n\n//#pragma GCC optimize(\"Ofast\")\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native\")\n//#pragma GCC optimize(\"unroll-loops\")\n//#pragma GCC optimize(\"fast-math\")\n\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n#ifdef FREOPEN\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n#endif\n\n ll n , k;\n cin >> n >> k;\n vector c(n),ans(k+1),sum(k+1);\n\n for (ll i = 0; i < n; ++i) {\n cin >> c[i];\n }\n sort(c.begin(),c.end());\n reverse(c.begin(),c.end());\n set > s;\n for (ll i = 0; i <= k; ++i)\n s.insert({0,i});\n for (auto &i: c) {\n ll ind = s.begin()->sd;\n s.erase(s.begin());\n ans[ind] += sum[ind];\n sum[ind] += i;\n s.insert({-sum[ind],ind});\n }\n ll out = 0;\n for (ll i = 0; i <= k; ++i) {\n out += ans[i];\n }\n cout << out;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f300c657d1840cde8a57e734e8aaa2a0", "src_uid": "53155daf2375e01a3b87fa1c76f1e9a8", "difficulty": null} {"lang": "GNU C++11", "source_code": "\u543e\u5617\u89c0\u300c\u300c\u7b97\u7d93\u300d\u300d\u4e4b\u66f8\u3002\u65b9\u609f\u300c\u53d6\u5e95\u300d\u4e4b\u7fa9\u3002\n\n\u543e\u6709\u4e00\u8853\u3002\u540d\u4e4b\u66f0\u300c\u8f93\u5165\u300d\u3002\u662f\u8853\u66f0\u3002\n \u65bd\u300crequire('fs').readFileSync\u300d\u65bc\u300c\u300c/dev/stdin\u300d\u300d\u3002\u540d\u4e4b\u66f0\u300c\u5165\u300d\u3002\n \u65bd\u300c(buf => buf.toString().trim())\u300d\u65bc\u300c\u5165\u300d\u3002\u6614\u4e4b\u300c\u5165\u300d\u8005\u3002\u4eca\u5176\u662f\u77e3\u3002\n \u65bd\u300c(s => s.split('\\n'))\u300d\u65bc\u300c\u5165\u300d\u3002\u6614\u4e4b\u300c\u5165\u300d\u8005\u3002\u4eca\u5176\u662f\u77e3\u3002\n \u4e43\u5f97\u300c\u5165\u300d\u4e5f\u3002\n\u662f\u8b02\u300c\u8f93\u5165\u300d\u4e4b\u8853\u4e5f\u3002\n\n\u543e\u6709\u4e00\u6578\u3002\u66f0\u96f6\u3002\u540d\u4e4b\u66f0\u300c\u5176\u884c\u300d\u3002\n\u65bd\u300c\u8f93\u5165\u300d\u3002\u540d\u4e4b\u66f0\u300c\u521d\u59cb\u8f93\u5165\u300d\u3002\n\n\u543e\u6709\u4e00\u8853\u3002\u540d\u4e4b\u66f0\u300c\u5f97\u6570\u300d\u3002\u662f\u8853\u66f0\u3002\n \u543e\u6709\u4e00\u5217\u3002\u540d\u4e4b\u66f0\u300c\u5176\u6570\u300d\u3002\n \u52a0\u300c\u5176\u884c\u300d\u4ee5\u4e00\u3002\u6614\u4e4b\u300c\u5176\u884c\u300d\u8005\u3002\u4eca\u5176\u662f\u77e3\u3002\n \u592b\u300c\u521d\u59cb\u8f93\u5165\u300d\u4e4b\u300c\u5176\u884c\u300d\u3002\u540d\u4e4b\u66f0\u300c\u6b64\u884c\u300d\u3002\n \u65bd\u300c(s => s.split(' '))\u300d\u65bc\u300c\u6b64\u884c\u300d\u3002\u6614\u4e4b\u300c\u6b64\u884c\u300d\u8005\u3002\u4eca\u5176\u662f\u77e3\u3002\n \u592b\u300c\u6b64\u884c\u300d\u4e4b\u9577\u3002\u540d\u4e4b\u66f0\u300c\u957f\u300d\u3002\n \u543e\u6709\u4e00\u6578\u3002\u66f0\u96f6\u3002\u540d\u4e4b\u66f0\u300c\u4e0b\u6807\u300d\u3002\n \u70ba\u662f\u300c\u957f\u300d\u904d\u3002\n \u52a0\u300c\u4e0b\u6807\u300d\u4ee5\u4e00\u3002\u6614\u4e4b\u300c\u4e0b\u6807\u300d\u8005\u3002\u4eca\u5176\u662f\u77e3\u3002\n \u592b\u300c\u6b64\u884c\u300d\u4e4b\u300c\u4e0b\u6807\u300d\u3002\u540d\u4e4b\u66f0\u300c\u6b64\u6570\u300d\u3002\n \u65bd\u300cparseInt\u300d\u65bc\u300c\u6b64\u6570\u300d\u3002\u6614\u4e4b\u300c\u6b64\u6570\u300d\u8005\u3002\u4eca\u5176\u662f\u77e3\u3002\n \u929c\u300c\u5176\u6570\u300d\u4ee5\u300c\u6b64\u6570\u300d\u3002\u6614\u4e4b\u300c\u5176\u6570\u300d\u8005\u3002\u4eca\u5176\u662f\u77e3\u3002\n \u4e91\u4e91\u3002\n \u4e43\u5f97\u300c\u5176\u6570\u300d\u4e5f\u3002\n\u662f\u8b02\u300c\u5f97\u6570\u300d\u4e4b\u8853\u4e5f\u3002", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f9f9fbf64e88ceda957c6b64722a3102", "src_uid": "0034806908c9794086736a2d07fc654c", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\nusing namespace std;\nint value(char c)\n{\n if('A'>s;\n int n;\n for(n=0;;n++)\n {\n if(s[n]=='\\0'){break;}\n }\n for(int i=0;i\n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_pbds;\n \ntypedef long long ll;\ntypedef vector vi;\ntypedef long double ld;\ntypedef pair pll;\ntemplate using Tree = tree, rb_tree_tag,tree_order_statistics_node_update>;\n\n#define FOR(i, a, b) for (int i=a; i<(b); i++)\n#define F0R(i, a) for (int i=0; i<(a); i++)\n#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)\n#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)\n\n#define sz(x) (int)(x).size()\n#define mp make_pair\n#define pb push_back\n#define f first\n#define s second\n#define lb lower_bound\n#define ub upper_bound\n\nconst int MOD = 1000000007;\n\nint n;\nvector p, P, totest;\nset z;\nll ans = 0;\npll sum;\n\npll operator+ (const pll& l, const pll& r) {\n return {l.f+r.f,l.s+r.s};\n}\n\npll operator- (const pll& l, const pll& r) {\n return {l.f-r.f,l.s-r.s};\n}\n\nvoid process(pll x) {\n if (x.f == 0 && x.s == 0) return;\n ll g = __gcd(x.f,x.s);\n x.f /= g, x.s /= g;\n if (x.f < 0 || (x.f == 0 && x.s < 0)) x.f *= -1, x.s *= -1;\n totest.pb(x);\n}\n\nvoid test(pll t) {\n vector<__int128> cur;\n for (auto a: P) {\n cur.pb((__int128)a.f*t.s-(__int128)a.s*t.f);\n }\n sort(cur.begin(),cur.end());\n F0R(i,cur.size()) if (cur[i] != -cur[cur.size()-1-i]) return;\n ans++;\n}\n\nint main() {\n\tios_base::sync_with_stdio(0);cin.tie(0);\n\tcin >> n; p.resize(n);\n\tF0R(i,n) {\n\t cin >> p[i].f >> p[i].s;\n\t sum = sum+p[i];\n\t p[i].f *= n, p[i].s *= n;\n\t}\n\tF0R(i,n) {\n\t p[i] = p[i]-sum;\n\t if (z.count(mp(-p[i].f,-p[i].s))) z.erase(mp(-p[i].f,-p[i].s));\n\t else z.insert(p[i]);\n\t}\n\tfor (auto a: z) P.pb(a);\n\tif (P.size() <= 1) {\n\t cout << -1;\n\t return 0;\n\t}\n F0R(i,P.size()) FOR(j,i,P.size()) process(p[i]+p[j]);\n sort(totest.begin(),totest.end());\n F0R(i,totest.size()) {\n int i1 = i;\n while (i < totest.size() && totest[i] == totest[i1]) i++;\n if (2*(i-i1+1) >= P.size()) test(totest[i1]);\n }\n cout << ans;\n}\n\n// read!\n// ll vs. int!", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5fe83acb3a407d1857b8b96f2f30f2ca", "src_uid": "5d7ba962400c05433ee17c5658888e69", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include\n\nusing namespace std;\n\n#define pq priority_queue\n#define MZ 1000000007\n\nint n,kk,xx;\nint cnt=0;\nint n2b[75],b2n[265];\nint bs[10];\nlong long dis[10];\nint p[30];\nlong long dp[2][75];\nmap mp;\nstruct Mat\n{\n long long num[75][75];\n friend Mat operator *(Mat x1,Mat x2)\n {\n Mat ans;\n for(int i=1;i<=cnt;i++)\n for(int j=1;j<=cnt;j++)\n {\n ans.num[i][j]=2LL*MZ*MZ;\n for(int k=1;k<=cnt;k++)\n ans.num[i][j]=min(x1.num[i][k]+x2.num[k][j],ans.num[i][j]);\n }\n return ans;\n }\n}A;\nqueue q;\n\nMat pows(Mat x,int y)\n{\n Mat ans;\n for(int i=1;i<=cnt;i++)\n for(int j=1;j<=cnt;j++)\n ans.num[i][j]=2LL*MZ*MZ;\n while(y)\n {\n if(y%2)\n ans=ans*x;\n x=x*x;\n y>>=1;\n }\n return ans;\n}\nvoid init(int f,int x,int s)\n{\n if(f==kk)\n {\n if(x==xx)\n {\n cnt++;\n b2n[s]=cnt;\n n2b[cnt]=s;\n }\n return;\n }\n init(f+1,x+1,s+bs[f]);\n init(f+1,x,s);\n}\nvoid solve1(Mat x)\n{\n for(int i=1;i<=cnt;i++)\n dp[1][i]=2LL*MZ*MZ;\n for(int i=1;i<=cnt;i++)\n for(int j=1;j<=cnt;j++)\n dp[1][j]=min(dp[0][i]+x.num[i][j],dp[1][j]);\n for(int i=1;i<=cnt;i++)\n dp[0][i]=dp[1][i];\n}\nvoid solve2(int y)\n{\n for(int i=1;i<=cnt;i++)\n dp[1][i]=2LL*MZ*MZ;\n for(int i=1;i<=cnt;i++)\n {\n if(n2b[i]%2)\n {\n for(int j=1;j<=kk;j++)\n {\n if((n2b[i]&bs[j])==0)\n dp[1][b2n[(n2b[i]+bs[j])/2]]=min(dp[1][b2n[(n2b[i]+bs[j])/2]],dp[0][i]+A.num[i][b2n[(n2b[i]+bs[j])/2]]+mp[y+j]);\n }\n }\n else\n dp[1][b2n[n2b[i]/2]]=min(dp[1][b2n[n2b[i]/2]],dp[0][i]);\n }\n for(int i=1;i<=cnt;i++)\n dp[0][i]=dp[1][i];\n}\n\nint main()\n{\n int qq;\n long long w;\n bs[0]=1;\n for(int i=1;i<=8;i++)\n bs[i]=bs[i-1]*2;\n scanf(\"%d%d%d%d\",&xx,&kk,&n,&qq);\n init(0,0,0);\n for(int i=1;i<=kk;i++)\n scanf(\"%lld\",&dis[i]);\n for(int i=1;i<=cnt;i++)\n {\n for(int j=1;j<=cnt;j++)\n A.num[i][j]=2LL*MZ*MZ;\n if(n2b[i]%2)\n {\n for(int j=1;j<=kk;j++)\n {\n if((n2b[i]&bs[j])==0)\n A.num[i][b2n[(n2b[i]+bs[j])/2]]=dis[j];\n }\n }\n else\n A.num[i][b2n[n2b[i]/2]]=0;\n }\n for(int i=0;ip[qq])\n p[i]=p[qq];\n if(now+kk\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair PII;\n\n#define fi first\n#define se second\n#define mp make_pair\n#define pb push_back\n\ntypedef double db;\ntypedef complex cp;\n\nconst db eps = 1e-12;\n\nint n;\nstring s;\n\nint main() {\n\tcin >> n >> s;\n\tcp S(0, 0);\n\tfor (int i = 0; i < n; i ++)\n\t\tS += cp(cos(2*i*M_PI/n), sin(2*i*M_PI/n))*cp(s[i]-'0',0);\n\tif (fabs(S.real()) < eps && fabs(S.imag()) < eps) puts (\"YES\");\n\telse puts (\"NO\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c8cdfa7d777c00c332524dc16970008e", "src_uid": "63c00c5ea7aee792e8a30dc2c330c3f7", "difficulty": 3000.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define LL long long\n#define LD long double\n#define SC(t,x) static_cast(x)\n#define AR(t) vector < t >\n#define PII pair < int, int >\n#define PLL pair < LL, LL >\n#define PIL pair < int, LL >\n#define PLI pair < LL, int >\n#define MP make_pair\n#define PB push_back\n#define PF push_front\n#define POB pop_back\n#define POF pop_front\n#define FF first\n#define SS second\n#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )\n#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )\n#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )\n#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )\n#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )\n#define qmax(a,b) (((a)>(b))?(a):(b))\n#define qmin(a,b) (((a)<(b))?(a):(b))\n#define qabs(a) (((a)>=0)?(a):(-(a)))\n\nconst int INF = 0x3fffffff;\nconst int SINF = 0x7fffffff;\nconst long long LINF = 0x3fffffffffffffff;\nconst long long SLINF = 0x7fffffffffffffff;\nconst int MAXN = 50007;\nint MAXS = 997;\nconst LD PI = acos ( -1.0 );\n//const LD EPS = 1e-9;\nconst LD EPS = 0.015;\nconst LD RATIO = 0.95;\n\nstruct cT\n{\n\tcT () : x ( 0 ), y ( 0 ) {}\n\tcT ( LD _x, LD _y ) : x ( _x ), y ( _y ) {}\n\t\n\tcT operator + ( const cT &a ) const\n\t{\n\t\treturn cT ( x + a.x, y + a.y );\n\t}\n\t\n\tvoid operator += ( const cT &a )\n\t{\n\t\t( *this ) = ( *this ) + a;\n\t}\n\t\n\tcT operator - ( const cT &a ) const\n\t{\n\t\treturn cT ( x - a.x, y - a.y );\n\t}\n\t\n\tvoid operator -= ( const cT &a )\n\t{\n\t\t( *this ) = ( *this ) - a;\n\t}\n\t\n\tLD ang ()\n\t{\n\t\treturn atan2 ( y, x );\n\t}\n\t\n\tLD abs ()\n\t{\n\t\treturn x * x + y * y;\n\t}\n\t\n\tLD len ()\n\t{\n\t\treturn sqrt ( abs () );\n\t}\n\t\n\tcT rot ( LD ang )\n\t{\n\t\tLD ca = cos ( ang ), sa = sin ( ang );\n\t\treturn cT ( x * ca - y * sa, x * sa + y * ca );\n\t}\n\t\n\tbool operator < ( const cT &a ) const\n\t{\n\t\treturn x < a.x;\n\t}\n\t\n\tLD x, y;\n}c1[MAXN], c2[MAXN], r2[MAXN];\n\nint n, n1, n2;\npair < cT, int > s1[MAXN];\npair < LD, PII > s2[MAXN];\nint ans2[MAXN];\nbool vis1[MAXN];\n\nvoid init ();\nvoid input ();\nvoid work ();\n\nvoid check ( int a11, int a12, int a21, int a22 );\n\n\n\nint main()\n{\n\tinit();\n\tinput();\n\twork();\n}\n\n\n\nvoid init ()\n{\n\t// Init Everything Here\n\t\n\tios::sync_with_stdio ( false );\n}\n\nvoid input ()\n{\n\t// input method\n\t\n\tscanf ( \"%d\", &n );\n\tscanf ( \"%d\", &n1 );\n\tdouble tx, ty;\n\tlpi ( i, 1, n1 ) scanf ( \"%lf%lf\", &tx, &ty ), c1[i].x = tx, c1[i].y = ty;\n\tscanf ( \"%d\", &n2 );\n\tlpi ( i, 1, n2 ) scanf ( \"%lf%lf\", &tx, &ty ), c2[i].x = tx, c2[i].y = ty;\n}\n\nvoid work ()\n{\n\t// main work\n\t\n\tMAXS = qmin ( MAXS, n );\n\t\n\tlpi ( i, 1, n1 ) s1[i] = MP ( c1[i], i );\n\tsort ( s1+1, s1+1+n1 );\n\t\n\tint k2 = 0;\n\tlpi ( i, 1, MAXS ){\n\t\tlpi ( j, i+1, MAXS ){\n\t\t\ts2[++k2] = MP ( ( c2[j] - c2[i] ).len (), MP ( i, j ) );\n\t\t}\n\t}\n\t\n\tsort ( s2+1, s2+1+MAXS );\n\tLD nd;\n\tint np;\n\tlpi ( i, 1, MAXS ){\n\t\tlpi ( j, 1, MAXS ){\n\t\t\tif ( i ^ j ){\n\t\t\t\tnd = ( c1[j] - c1[i] ).len ();\n\t\t\t\tnp = lower_bound ( s2+1, s2+1+k2, MP ( nd, MP ( 0, 0 ) ) ) - s2;\n\t\t\t\tlpi ( k, np, k2 ){\n\t\t\t\t\tif ( s2[k].FF - nd < EPS ) check ( i, j, s2[k].SS.FF, s2[k].SS.SS );\n\t\t\t\t\telse break;\n\t\t\t\t}\n\t\t\t\tlpd ( k, np-1, 0 ){\n\t\t\t\t\tif ( nd - s2[k].FF < EPS ) check ( i, j, s2[k].SS.FF, s2[k].SS.SS );\n\t\t\t\t\telse break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n\nvoid check ( int a11, int a12, int a21, int a22 )\n{\n\tLD ang1 = ( c1[a12] - c1[a11] ).ang (), ang2 = ( c2[a22] - c2[a21] ).ang ();\n\tLD ang = ang1 - ang2;\n\tlpi ( i, 1, n2 ) r2[i] = c2[i].rot ( ang );\n//\tlpi ( i, 1, n2 ) cerr << \"(\" << r2[i].x << \",\" << r2[i].y << \") \"; cerr << endl;\n\tcT d = c1[a11] - r2[a21];\n\tlpi ( i, 1, n2 ) r2[i] += d;\n\t\n\tINIT ( ans2, 0 );\n\tINIT ( vis1, 0 );\n\t\n//\tcerr << a11 << \" \" << a12 << \" \" << a21 << \" \" << a22 << endl;\n//\tcerr << ang << endl;\n//\tlpi ( i, 1, n2 ) cerr << \"(\" << r2[i].x << \",\" << r2[i].y << \") \"; cerr << endl;\n\t\n\tint np, cc = 0;\n\tlpi ( i, 1, n2 ){\n\t\tnp = lower_bound ( s1+1, s1+1+n1, MP ( r2[i], 0 ) ) - s1;\n\t\tlpi ( k, np, n1 ){\n\t\t\tif ( s1[k].FF.x - r2[i].x < EPS ){\n\t\t\t\tif ( qabs ( s1[k].FF.y - r2[i].y ) < EPS && !vis1[s1[k].SS] ){\n\t\t\t\t\tans2[i] = s1[k].SS;\n\t\t\t\t\tvis1[s1[k].SS] = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else break;\n\t\t}\n\t\tif ( !ans2[i] ){\n\t\t\tlpd ( k, np-1, 0 ){\n\t\t\t\tif ( r2[i].x - s1[k].FF.x < EPS ){\n\t\t\t\t\tif ( qabs ( s1[k].FF.y - r2[i].y ) < EPS && !vis1[s1[k].SS] ){\n\t\t\t\t\t\tans2[i] = s1[k].SS;\n\t\t\t\t\t\tvis1[s1[k].SS] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}else break;\n\t\t\t}\n\t\t}\n\t\tif ( ans2[i] ) ++cc;\n\t}\n\t\n\tif ( cc > RATIO * n ){\n\t\tint nc = 0;\n\t\tlpi ( i, 1, n2 ){\n\t\t\tif ( ans2[i] ){\n\t\t\t\tprintf ( \"%d %d\\n\", ans2[i], i );\n\t\t\t\tif ( ++nc == n ) break;\n\t\t\t}\n\t\t}\n\t\tif ( nc < n ){\n\t\t\tint i1 = 1;\n\t\t\tlpi ( i, 1, n2 ){\n\t\t\t\tif ( !ans2[i] ){\n\t\t\t\t\twhile ( vis1[i1] ) ++i1;\n\t\t\t\t\tprintf ( \"%d %d\\n\", i1, i );\n\t\t\t\t\tvis1[i1] = true;\n\t\t\t\t\tif ( ++nc == n ) break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\texit ( 0 );\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1685632de6fcfe33f0eab15814f01bc6", "src_uid": "fc238a230bb556c9ffecf343989b988a", "difficulty": 3100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \ntypedef long long ll;\nusing namespace std;\n#define INF 2147483647\n#define infL (1LL<<60)\n#define inf (1<<30)\n#define inf9 (1000000000)\n#define MOD 1000000007\n#define EPS 1e-18\n#define Gr 9.8\n#define PI acos(-1)\n#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)\n#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)\n#define lch (rt<<1)\n#define rch (rt<<1|1)\n#define readmp(n) for(int i=0,u,v;i pii;\ntypedef long double ld;\ntypedef unsigned int uint;\n#define MAX 300105\nbool debug = 0;\nint n,m,k;\nint dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};\nstring direc=\"RDLU\";\nll ln, lk, lm;\nvoid etp(bool f = 0) {\n puts(f ?\"Yes\" : \"No\");\n exit(0);\n}\nvoid addmod(int &x, int y, int mod = MOD) {\n x+=y; if (x>=mod) x-=mod;\n}\nvoid et() {\n puts(\"-1\"); exit(0);\n}\n ll fastPow(ll x, ll y, int mod=MOD) {\n ll ans = 1;\n while(y>0) {\n if(y&1) ans = (x * ans)%mod;\n x = x*x%mod;\n y>>=1;\n }\n return ans;\n }\n\n\ntypedef ll ValType;\nstruct Point {\n ValType x, y;\n Point() { }\n Point(ValType x, ValType y) : x(x), y(y) { }\n ld abs() const { return hypot(x, y); }\n ld arg() const { return atan2(y, x); }\n Point operator*(double o) const { return Point(x * o, y * o); }\n Point operator+(const Point& o) const { return Point(x + o.x, y + o.y); }\n Point operator-(const Point& o) const { return Point(x - o.x, y - o.y); }\n bool operator<(const Point& o) const { return x < o.x - EPS || (x < o.x + EPS && y < o.y - EPS); }\n Point scale(double o) const { return *this * (o / abs()); }\n Point rotY() const { return Point(-y, x); }\n Point rotX() const { return Point(y, -x); }\n ValType cross(Point b) const {return x*b.y- b.x*y;}\n ValType dot(Point b) const {return x*b.x + y*b.y;}\n ld disToSeg(Point &a, Point &b) {\n return fabs(((*this)-a).cross(b-a) / (b-a).abs());\n }\n void readin() {\n scanf(\"%lld%lld\", &x, &y);\n }\n void pp() {\n printf(\"%lld %lld\\n\",x,y);\n }\n}p[MAX];\n\nvector convex(vector &vp) {\n sort(vp.begin(), vp.end());\n int N = unique(vp.begin(),vp.end())-vp.begin();\n vector ans1,ans2;\n REP(i,N) {\n while(ans1.size()>1) {\n Point o=ans1[ans1.size()-2], a= ans1.back();\n if ((a-o).cross(vp[i]-o) <= 0) {\n ans1.pop_back();\n } else break;\n }\n ans1.push_back(vp[i]);\n }\n for(int i=N-1;i>=0;i--) {\n while(ans2.size()>1) {\n Point o=ans2[ans2.size()-2], a= ans2.back();\n if ((a-o).cross(vp[i]-o) <= 0) {\n ans2.pop_back();\n } else break;\n }\n ans2.push_back(vp[i]);\n }\n for(int i=1;ix+i||xr[y+j]y+j||yr[x+i] vp;\n REQ(i,m) {\n ll x=p[i].x,y=p[i].y;\n if (isIn(x, y)) vp.push_back(Point(x,y));\n if (isIn(x-1, y)) vp.push_back(Point(x-1,y));\n if (isIn(x, y-1)) vp.push_back(Point(x,y-1));\n if (isIn(x-1, y-1)) vp.push_back(Point(x-1,y-1));\n// int tio=0;\n }\n vector ans = convex(vp);\n printf(\"%d\\n\", ans.size());\n ans[0].pp();\n for(int i=ans.size()-1;i>=1;i--) ans[i].pp();\n \n REQ(i,m) {\n xl[p[i].y]=infL;\n xr[p[i].y]=0;\n yl[p[i].x] = infL;\n yr[p[i].x] = 0;\n }\n }\n}\nint main() {\n fmain();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "12df29d7122e6ebed7d1ec60645cdda9", "src_uid": "5e1847193148c4e6a998c61f8db61670", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\n#define all(a) (a).begin(), (a).end()\n#define sz(a) (int)(a).size()\n#define mp make_pair\n#define pb push_back\n\ntypedef long long ll;\ntypedef double ld;\ntypedef pair pii;\ntypedef pair pll;\n\nld eps = 1e-12;\nconst ld inf = 1e9;\nconst int ops = 100;\n\nbool lt(ld a, ld b)\n{\n return b - a > eps;\n}\n\nbool eq(ld a, ld b)\n{\n return abs(a - b) <= eps;\n}\n\nbool leq(ld a, ld b)\n{\n return lt(a, b) || eq(a, b);\n}\n\nbool gt(ld a, ld b)\n{\n return a - b > eps;\n}\n\nbool geq(ld a, ld b)\n{\n return gt(a, b) || eq(a, b);\n}\n\nstruct pt\n{\n ld x, y;\n pt() {}\n pt(ld x, ld y) : x(x), y(y) {}\n pt operator-(const pt& other) const\n {\n return {x - other.x, y - other.y};\n }\n pt operator+(const pt& other) const\n {\n return {x + other.x, y + other.y};\n }\n pt operator*(ld k) const\n {\n return {x * k, y * k};\n }\n};\n\nbool eq(const pt& p, const pt& q)\n{\n return eq(p.x, q.x) && eq(p.y, q.y);\n}\n\nbool is_zero(const pt& p)\n{\n return eq(p.x, 0) && eq(p.y, 0);\n}\n\nld cross(const pt& p, const pt& q)\n{\n return p.x * q.y - p.y * q.x;\n}\n\nld dot(const pt& p, const pt& q)\n{\n return p.x * q.x + p.y * q.y;\n}\n\nld area(const pt& a, const pt& b, const pt& c)\n{\n return cross(b - a, c - a);\n}\n\nld len(const pt& p)\n{\n return sqrt(p.x * p.x + p.y * p.y);\n}\n\nbool inside(const pt& p, const vector& v)\n{\n ld s = 0;\n ld ans = 0;\n int n = sz(v);\n for (int i = 0; i < n; ++i) {\n s += abs(area(p, v[i], v[(i + 1) % n]));\n ans += area(p, v[i], v[(i + 1) % n]);\n }\n return eq(s, abs(ans));\n}\n\nbool on_seg(const pt& p, const pt& a, const pt& b)\n{\n return leq(dot(a - p, b - p), 0);\n}\n\nstruct line\n{\n ld a, b, c;\n line() {}\n line(const pt& p, const pt& q)\n {\n a = p.y - q.y;\n b = q.x - p.x;\n c = cross(p, q);\n /*ld tmp = sqrt(a * a + b * b);\n a /= tmp, b /= tmp, c /= tmp;*/\n }\n};\n\nbool on_line(const pt& p, const line& l, bool flag = false)\n{\n if (flag) {\n cout << \"ON \" << l.a * p.x + l.b * p.y + l.c << \"\\n\";\n }\n return eq(l.a * p.x + l.b * p.y + l.c, 0);\n}\n\nvector intersect(const line& l, const line& m)\n{\n ld a1 = l.a, b1 = l.b, c1 = -l.c;\n ld a2 = m.a, b2 = m.b, c2 = -m.c;\n ld det = a1 * b2 - a2 * b1;\n if (eq(det, 0)) {\n return {};\n }\n ld det1 = c1 * b2 - c2 * b1;\n ld det2 = a1 * c2 - a2 * c1;\n return {{det1 / det, det2 / det}};\n}\n\nvector intersect(const pt& a, const pt& b, const pt& c, const pt& d)\n{\n line l(a, b), m(c, d);\n vector v = intersect(l, m);\n vector ans;\n for (pt& p : v) {\n if (on_seg(p, a, b) && on_seg(p, c, d)) {\n ans.pb(p);\n }\n }\n if (on_line(a, m) && on_seg(a, c, d)) {\n ans.pb(a);\n }\n if (on_line(b, m) && on_seg(b, c, d)) {\n ans.pb(b);\n }\n if (on_line(c, l) && on_seg(c, a, b)) {\n ans.pb(c);\n }\n if (on_line(d, l) && on_seg(d, a, b)) {\n ans.pb(d);\n }\n return ans;\n}\n\nvector intersect(const pt& a, const pt& b, const line& l)\n{\n line m(a, b);\n vector ans = intersect(l, m);\n if (sz(ans) == 1 && !on_seg(ans[0], a, b)) {\n ans.pop_back();\n }\n if (on_line(a, l)) {\n ans.pb(a);\n }\n if (on_line(b, l)) {\n ans.pb(b);\n }\n\n return ans;\n}\n\nint main()\n{\n\n //freopen(\"input.txt\", \"r\", stdin);\n //ifstream cin(\"input.txt\");\n\n //ios_base::sync_with_stdio(false);\n //cin.tie(0);\n\n int n;\n cin >> n;\n cout << fixed;\n cout.precision(12);\n\n vector p(n);\n for (int i = 0; i < n; ++i) {\n cin >> p[i].x >> p[i].y;\n }\n\n pt a;\n cin >> a.x >> a.y;\n pt v;\n cin >> v.x >> v.y;\n ld z1;\n cin >> z1;\n\n ld fdown;\n cin >> fdown;\n fdown = -fdown;\n\n pt u;\n cin >> u.x >> u.y;\n ld z2;\n cin >> z2;\n z2 = -z2;\n\n if (is_zero(v) && is_zero(u)) {\n cout << \"-1 -1\\n\";\n return 0;\n }\n\n ld t1_ans;\n\n if (!eq(cross(v, u), 0)) {\n ld lf = 0, rg = inf;\n for (int step = 0; step < ops; ++step) {\n ld t1 = (lf + rg) / 2.0;\n //cout << t1 << \" : \";\n pt b = a + v * t1;\n pt c = b + u * (z1 * t1 / z2);\n vector triangle = {a, b, c};\n bool ok = false;\n for (int i = 0; i < n; ++i) {\n if (inside(p[i], triangle)) {\n ok = true;\n //cout << \"ok p[\" << i << \"]\\n\";\n break;\n }\n }\n if (!ok) {\n for (int i = 0; i < n; ++i) {\n vector vv = intersect(a, b, p[i], p[(i + 1) % n]);\n if (!vv.empty()) {\n ok = true;\n //cout << \"ok ab \" << i << \" \" << i + 1 << \"\\n\";\n break;\n }\n vv = intersect(b, c, p[i], p[(i + 1) % n]);\n if (!vv.empty()) {\n ok = true;\n //cout << \"ok bc \" << i << \" \" << i + 1 << \"\\n\";\n break;\n }\n vv = intersect(c, a, p[i], p[(i + 1) % n]);\n if (!vv.empty()) {\n ok = true;\n //cout << \"ok ca \" << i << \" \" << i + 1 << \"\\n\";\n break;\n }\n }\n }\n if (ok) {\n rg = t1;\n } else {\n //cout << \"not ok\\n\";\n lf = t1;\n }\n }\n t1_ans = rg;\n } else {\n ld t1 = inf;\n line l;\n if (is_zero(u)) {\n l = line(a, a + v);\n } else {\n l = line(a, a + u);\n }\n pt w = v + u * (z1 / z2);\n for (int i = 0; i < n; ++i) {\n vector vv = intersect(p[i], p[(i + 1) % n], l);\n for (pt& q : vv) {\n /*if (i == 2) {\n cout << \"!\" << q.x << \" \" << q.y << \"\\n\";\n }*/\n if (!is_zero(v)) {\n ld val = len(q - a) / len(v);\n /*if (i == 2) {\n pt tmp = q - a;\n cout << tmp.x << \" \" << tmp.y << \"\\n\";\n }*/\n if (eq(v * val, q - a) && gt(t1, val)) {\n t1 = val;\n }\n }\n if (!is_zero(w)) {\n ld val = len(q - a) / len(w);\n if (eq(w * val, q - a) && gt(t1, val)) {\n t1 = val;\n }\n }\n }\n }\n t1_ans = t1;\n }\n\n if (eq(t1_ans, inf)) {\n cout << \"-1 -1\\n\";\n return 0;\n }\n\n cout << t1_ans << \" \";\n\n if (is_zero(u)) {\n cout << \"0\\n\";\n return 0;\n }\n \n eps = 1e-8;\n\n pt magic = a + v * t1_ans;\n pt border = magic + u * (z1 * t1_ans / z2);\n //cout << border.x << \" \" << border.y << \"\\n\";\n line l(magic, border);\n\n for (int i = 0; i < n; ++i) {\n if (on_line(p[i], l) && on_seg(p[i], magic, border)) {\n magic = p[i];\n }\n if (eq(magic, border)) {\n break;\n }\n vector vv = intersect(a + v * t1_ans, border, p[i], p[(i + 1) % n]);\n for (pt& q : vv) {\n //if (i == 0) cout << \"!\" << i << \" \" << q.x << \" \" << q.y << \"\\n\";\n if (on_seg(q, magic, border)) {\n magic = q;\n }\n if (eq(magic, border)) {\n break;\n }\n }\n }\n \n t1_ans += eps;\n pt magic2 = a + v * t1_ans;\n pt border2 = a + v * t1_ans + u * (z1 * t1_ans / z2);\n\n for (int i = 0; i < n; ++i) {\n if (on_line(p[i], l) && on_seg(p[i], magic2, border2)) {\n magic2 = p[i];\n }\n if (eq(magic2, border2)) {\n break;\n }\n vector vv = intersect(a + v * t1_ans, border2, p[i], p[(i + 1) % n]);\n for (pt& q : vv) {\n //cout << \"!\" << i << \" \" << q.x << \" \" << q.y << \"\\n\";\n if (on_seg(q, magic2, border2)) {\n magic2 = q;\n }\n if (eq(magic2, border2)) {\n break;\n }\n }\n }\n\n //cout << magic.x << \" \" << magic.y << \"\\n\";\n \n ld val = len(magic - (a + v * t1_ans));\n ld val2 = len(magic2 - (a + v * t1_ans));\n if (lt(val, val2)) {\n val = val2;\n }\n\n ld par = val / len(u);\n ld ans = (z1 * t1_ans - par * z2) / fdown + eps;\n cout << ans << \"\\n\";\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1ce23385a26ddbdd27efbca73741cd10", "src_uid": "d6afa6a515fc0adde11891e81cb179d7", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include \n#define INF 1e9\nusing namespace std;\ntypedef long long ll;\ntypedef pair ii;\ntypedef vector vii;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef tuple iii;\ntypedef vector vll;\ntypedef map mii;\ntypedef pair cc;\ntypedef vector> vcc;\n\nvector> AL;\nvi visited;\n\nint main() {\n ios::sync_with_stdio(false); cin.tie(NULL);\n \n int tc; cin>>tc;\n while(tc--){\n \tint n; cin>>n;\n \tstring a,b;\n \tcin>>a>>b;\n\t\tset> setter;\n\t\tAL.assign(20, set());\n\t\tbool can = true; \n\t\tfor(int i=0; i q; q.push(make_pair(i, 0));\n\t\t\t\n\t\t\twhile(!q.empty()){\n\t\t\t\tint u = q.front().first, d = q.front().second;\n\t\t\t\tq.pop();\n\t\t\t\tfor(auto v:AL[u]){\n\t\t\t\t\tif(visited[v] == 1){\n\t\t\t\t\t\tAL[i].erase(v);\n\t\t\t\t\tvisited[v] = d+1;\n\t\t\t\t\t}\n\t\t\t\t\tif(visited[v] == -1){\n\t\t\t\t\t\tq.push(make_pair(v,d+1));\n\t\t\t\t\tvisited[v] = d+1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tint ans = 0;\n\t\tfor(int i=0; i<20; i++){\n\t\t\tans += AL[i].size();\n\t\t}\n\t\t\n\t\tcout<\nusing namespace std;\n\n#define int __int128\n\nvoid read(int &x) {\n x=0;int f=1;char ch=getchar();\n for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;\n for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;\n}\n\nvoid print(int x) {\n if(x<0) putchar('-'),x=-x;\n if(!x) return ;print(x/10),putchar(x%10+48);\n}\nvoid write(int x) {if(!x) putchar('0');else print(x);putchar('\\n');}\n\n#define lf double\n#define ll __int128 \n\n#define pii pair\n#define vec vector\n\n#define pb push_back\n#define mp make_pair\n#define fr first\n#define sc second\n\n#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)\n\nconst int maxn = 1e6+10;\nconst int inf = 1e9;\nconst lf eps = 1e-8;\nconst int mod = 1e9+7;\n\nint v[maxn],cnt,n;\nstruct _data {int x;ll t;}t[maxn];\n\n#define ls p<<1\n#define rs p<<1|1\n#define mid ((l+r)/2)\n\nstruct ST_table {\n int f[50050][16],lg[50050];\n\n void build() {\n for(int i=1;i<=n;i++) f[i][0]=v[i];\n for(int j=1;j<=15;j++)\n for(int i=1;i<=n;i++)\n f[i][j]=__gcd(f[i][j-1],f[i+(1<<(j-1))][j-1]);\n for(int i=2;i<=n;i++) lg[i]=lg[i>>1]+1;\n }\n\n int query(int x,int y) {\n int t=lg[y-x+1];\n return __gcd(f[x][t],f[y-(1< s;\n T.build();\n for(int i=1;i<=n;i++) {\n int p=i,now=v[i];\n while(p<=n) {\n int l=p,r=n,pre=p;\n while(l<=r)\n if(T.query(i,mid)==now) p=mid,l=mid+1;\n else r=mid-1;\n s[now]+=p-pre+1;\n p++;now=__gcd(now,v[p]);\n }\n }\n for(map :: iterator i=s.begin();i!=s.end();i++)\n t[++cnt]=(_data){i->fr,i->sc};\n}\n\nll f(ll a,ll b,ll c,ll n) {\n if(n<0) return 0;\n if(!a) return (n+1)*(b/c);\n if(a>=c||b>=c) return f(a%c,b%c,c,n)+n*(n+1)/2*(a/c)+(n+1)*(b/c);\n ll m=(n*a+b)/c;\n return n*m-f(c,c-b-1,a,m-1);\n}\n\nll sum[maxn],ct[maxn];\n\nll s(ll a,ll b,ll c) {\n if(c<0) return 0;\n return f(a,c%a,b,c/a)+c/a+1;\n}\n\nll calc(ll a,ll b,ll md) {\n if(a>=b) return 0;\n ll ss=md-(ct[b-1]-ct[a]),x=t[a].x,y=t[b].x;ss-=x,ss-=y;\n return s(x,y,ss)-s(x,y,ss-t[a].t*x)-s(x,y,ss-t[b].t*y)+s(x,y,ss-t[a].t*x-t[b].t*y);\n}\n\nll get(ll x) {\n ll p=1,ans=0;\n for(int i=1;i<=cnt;i++) {\n ll w=min(x/t[i].x,t[i].t);\n ans+=(t[i].t+1)*w-w*(w+1)/2;\n }\n for(int i=1;i<=cnt;i++) {\n if(p>i+1) ans+=1ll*t[i].t*(sum[p-1]-sum[i]);\n while(p<=cnt&&ct[p]-ct[i]<=x) ans+=calc(i,p,x),p++;\n if(p<=cnt) ans+=calc(i,p,x);\n }\n // write(x);write(ans);\n return ans;\n}\n\nsigned main() {\n int st=clock();\n read(n);\n for(int i=1;i<=n;i++) read(v[i]);\n prepare();\n for(int i=1;i<=cnt;i++) sum[i]=sum[i-1]+t[i].t;\n for(int i=1;i<=cnt;i++) ct[i]=ct[i-1]+1ll*t[i].t*t[i].x;//,printf(\"%d %d\\n\",t[i].x,t[i].t);\n ll l=1,r=ct[cnt]+1,w=1ll*n*(n+1)/2;\n w=w*(w+1)/2;w=(w+1)/2;write(cnt);\n while(l\nusing namespace std;\n#define ll long long\n#define N 2000005\n/*\n#include \nINT_MAX\nLLONG_MAX\n*/\n\nint pen[N];\n\nvoid update(int ind,int add) {\n while(ind0) {\n ret = ret + pen[ind];\n ind = ind&(ind-1);\n }\n return ret;\n}\n\npair r[N];\nbool vis[N/2];\n\nint getIndex(int y) {\n int sum = 0;\n int ind = 0;\n for(int i=20;i>=0;--i) {\n int nind = ind + (1<\n#include \n#include \n\nusing namespace __gnu_pbds;\nusing namespace std;\n\ntemplate \nusing ordered_set =\n tree, rb_tree_tag, tree_order_statistics_node_update>;\n\n#define sim template < class c\n#define ris return * this\n#define dor > debug & operator <<\n#define eni(x) sim > typename \\\n enable_if(0) x 1, debug&>::type operator<<(c i) {\nsim > struct rge { c b, e; };\nsim > rge range(c i, c j) { return rge{i, j}; }\nsim > auto dud(c* x) -> decltype(cerr << *x, 0);\nsim > char dud(...);\nstruct debug {\n#ifdef LOCAL\n~debug() { cerr << endl; }\neni(!=) cerr << boolalpha << i; ris; }\neni(==) ris << range(begin(i), end(i)); }\nsim, class b dor(pair < b, c > d) {\n ris << \"(\" << d.first << \", \" << d.second << \")\";\n}\nsim dor(rge d) {\n *this << \"[\";\n for (auto it = d.b; it != d.e; ++it)\n *this << \", \" + 2 * (it == d.b) << *it;\n ris << \"]\";\n}\n#else\nsim dor(const c&) { ris; }\n#endif\n};\n#define imie(...) \" [\" << #__VA_ARGS__ \": \" << (__VA_ARGS__) << \"] \"\n\n#define shandom_ruffle random_shuffle\n\nusing ll=long long;\nusing pii=pair;\nusing pll=pair;\nusing vi=vector;\nusing vll=vector;\nconst int nax=1000*1007;\n\nvector drz[nax];\nint roz[nax], jump[nax], pre[nax], post[nax], fad[nax], czas;\nint gle[nax];\nvi jumppo[nax];\n\nvoid dfs_roz(int v, int oj=0) {\n\tjumppo[v].push_back(oj);\n\twhile(jumppo[v].back())\n\t{\n\t\tint a=jumppo[v].back();\n\t\tint b=min(jumppo[v].size(), jumppo[a].size())-1;\n\t\tjumppo[v].push_back(jumppo[a][b]);\n\t}\n\tfor (int &i : drz[v])\n\t{\n\t\tif (i==oj)\n\t\t{\n\t\t\tswap(i, drz[v].back());\n\t\t\tdrz[v].pop_back();\n\t\t\tbreak;\n\t\t}\n\t}\n\troz[v]=1; // drz[] ma nie zawiera\u0107 kraw\u0119dzi\n\tfor (int &i : drz[v]) { // do ojca.\n\t\tfad[i]=v; // Init:\n\t\tgle[i]=gle[v]+1;\n\t\tdfs_roz(i, v); // dfs_roz(root);\n\t\troz[v]+=roz[i]; // dfs_pre(root);\n\t\tif (roz[i]>roz[drz[v][0]]) // U\u017cycie get_path(v, u) zwr\u00f3ci\n\t\t\tswap(i, drz[v][0]); // przedzia\u0142y odpowiadaj\u0105ce \u015bcie\u017cce\n\t} // z v do u. Przedzia\u0142y odpowiadaj\u0105ce\n} // \u015bcie\u017cce z v do lca maj\u0105\nvoid dfs_pre(int v) // first>=second, za\u015b te dla \u015bcie\u017cki\n{ // z lca do u maj\u0105 first<=second.\n\tif (!jump[v]) // Przedzia\u0142y s\u0105 po kolei.\n\t\tjump[v]=v; // Lca wyst\u0119puje w nich dwa razy,\n\tpre[v]=(++czas); // najpierw jako second,\n\tif (!drz[v].empty()) // a zaraz potem jako first.\n\t\tjump[drz[v][0]]=jump[v];\n\tfor (int i : drz[v])\n\t\tdfs_pre(i);\n\tpost[v]=czas;\n}\nint lca(int v, int u) {\n\twhile(jump[v]!=jump[u]) {\n\t\tif (pre[v] > path_up(int v, int u) {\n\tvector < pair > ret;\n\twhile(jump[v]!=jump[u]) {\n\t\tret.push_back({pre[jump[v]], pre[v]});\n\t\tv=fad[jump[v]];\n\t}\n\tret.push_back({pre[u], pre[v]});\n\treturn ret;\n}\nvector < pair > get_path(int v, int u) {\n\tint w=lca(v, u);\n\tauto ret=path_up(v, w);\n\tauto pom=path_up(u, w);\n\tfor (auto &i : ret)\n\t\tswap(i.first, i.second);\n\twhile(!pom.empty()) {\n\t\tret.push_back(pom.back());\n\t\tpom.pop_back();\n\t}\n\treturn ret;\n}\n\n\nint n, m, k;\n\nvi graf[nax];\n\nint kon[nax][2];\n\nll wyn;\n\nint podnies(int v, int ile)\n{\n\tfor (int i=0; (1< setel[nax];\n\nint wprze(ordered_set &secik, int a, int b)\n{\n\treturn secik.order_of_key(b+1)-secik.order_of_key(a);\n}\n\nint wprze(ordered_set &secik, int a, int b)\n{\n\treturn secik.order_of_key({b, nax})-secik.order_of_key({a, -nax});\n}\n\nmap mapka;\n\nint dziecko(int ma, int du)\n{\n\treturn pre[ma]>=pre[du] && post[ma]<=post[du];\n}\n\nbool mniej(int a, int b)\n{\n\treturn pre[a]=conaj)\n\t\t\twyn-=ret;\n\t\ttmp[v]--;\n\t\tret++;\n\t}\n\tfor (int i : ndrz[v])\n\t{\n\t\tint x=dfs2(i, conaj);\n\t\tif (gle[v]>=conaj)\n\t\t\twyn-=ret*(ll)x;\n\t\tret+=x;\n\t}\n\treturn ret;\n}\n\nvoid liczmale(vi wek, int kt, int conaj)\n{\n\tll ret=0;\n\tvi wie;\n\tfor (int i : wek)\n\t\twie.push_back(kon[i][kt]);\n\tskompresuj(wie);\n\tfor (int i : ver)\n\t\ttmp[i]=0;\n\tfor (int i : wie)\n\t\ttmp[i]++;\n\tdfs2(korz, conaj);\n}\n\nvi tmpwek[nax];\n\nordered_set tmpset[nax];\n\nvoid dfs3(int v, int koko)\n{\n\ttmpset[v].clear();\n\tfor (int i : tmpwek[v])\n\t{\n\t\tint tutaj=gle[v]-gle[koko];\n\t\tint tam=max(0, k-tutaj);\n\t\tint d=kon[i][1];\n\t\tif (gle[d]-gle[koko]>=tam)\n\t\t{\n\t\t\tint gor=podnies(d, gle[d]-gle[koko]-tam);\n\t\t\twyn+=wprze(tmpset[v], pre[gor], post[gor]);\n\t\t}\n\t\ttmpset[v].insert({pre[d], i});\n\t}\n\tfor (int i : ndrz[v])\n\t{\n\t\tdfs3(i, koko);\n\t\tif ((int)tmpset[i].size()>(int)tmpset[v].size())\n\t\t\ttmpset[v].swap(tmpset[i]);\n\t\tfor (pii j : tmpset[i])\n\t\t{\n\t\t\tint tutaj=gle[v]-gle[koko];\n\t\t\tint tam=max(0, k-tutaj);\n\t\t\tint d=kon[j.second][1];\n\t\t\tif (gle[d]-gle[koko]>=tam)\n\t\t\t{\n\t\t\t\tint gor=podnies(d, gle[d]-gle[koko]-tam);\n\t\t\t\twyn+=wprze(tmpset[v], pre[gor], post[gor]);\n\t\t\t}\n\t\t}\n\t\tfor (pii j : tmpset[i])\n\t\t\ttmpset[v].insert(j);\n\t}\n}\n\nvoid solve(vi wek, int v, int lew, int pra)\n{\n\tint r=wek.size();\n\tif (r<=1)\n\t\treturn;\n\tfor (int i : wek)\n\t\tif (pre[kon[i][0]]>pre[kon[i][1]])\n\t\t\tswap(kon[i][0], kon[i][1]);\n\tliczmale(wek, 0, gle[v]+k);\n\tliczmale(wek, 1, gle[v]+k);\n\t\n\tvi wsz{lew};\n\tfor (int i : wek)\n\t\twsz.push_back(kon[i][0]);\n\tskompresuj(wsz);\n\tfor (int i : ver)\n\t\ttmpwek[i].clear();\n\tfor (int i : wek)\n\t\ttmpwek[kon[i][0]].push_back(i);\n\tdfs3(lew, v);\n}\n\nvoid dfs1(int v)\n{\n\tfor (int i : sta[v])\n\t\tsetel[v].insert({pre[v], i});\n\tfor (int i : drz[v])\n\t{\n\t\tdfs1(i);\n\t\tif ((int)setel[v].size()>(int)setel[i].size())\n\t\t\tsetel[v].swap(setel[i]);\n\t\tfor (pii j : setel[i])\n\t\t\tsetel[v].insert(j);\n\t}\n\tmapka.clear();\n\tfor (int i : spo[v])\n\t{\n\t\tint a=kon[i][0];\n\t\tint b=kon[i][1];\n\t\tsetel[v].erase({pre[a], i});\n\t\tsetel[v].erase({pre[b], i});\n\t\tif (gle[a]>=gle[v]+k)\n\t\t{\n\t\t\tint lim=podnies(a, gle[a]-gle[v]-k);\n\t\t\twyn+=wprze(setel[v], pre[lim], post[lim]);\n\t\t}\n\t\tif (gle[b]>=gle[v]+k)\n\t\t{\n\t\t\tint lim=podnies(b, gle[b]-gle[v]-k);\n\t\t\twyn+=wprze(setel[v], pre[lim], post[lim]);\n\t\t}\n\t\tif (a==v || b==v)\n\t\t\tcontinue;\n\t\ta=podnies(a, gle[a]-gle[v]-1);\n\t\tb=podnies(b, gle[b]-gle[v]-1);\n\t\tif (pre[a]>pre[b])\n\t\t\tswap(a, b);\n\t\tmapka[{a, b}].push_back(i);\n\t}\n\tfor (auto i : mapka)\n\t\tsolve(i.second, v, i.first.first, i.first.second);\n}\n\nint main()\n{\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tfor (int i=1; i\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\nusing namespace std;\n\nconst int MAXN=262144<<1;\nconst int P=998244353;\nconst int g[]={3,(P+1)/3};\n\nint rev[MAXN],n;\nll tp[MAXN],itp[MAXN],tp2[MAXN],itp2[MAXN];\nll _G_[2][MAXN],G[MAXN],G0[MAXN],G1[MAXN],G2[MAXN],X1[MAXN],X3[MAXN],X4[MAXN],F0[MAXN],F1[MAXN],F2[MAXN];\n\nconstexpr ll Add(ll a,ll b){a+=b;return a>=P?a-P:a;}\n\nconstexpr ll Sub(ll a,ll b){a-=b;return a<0?a+P:a;}\n\nvoid Inc(ll &a,ll b){a+=b;if(a>=P) a-=P;}\n\nvoid Dec(ll &a,ll b){a-=b;if(a<0) a+=P;}\n\nll ksm(ll a,ll b)\n{\n\tll ret=1;\n\tfor(;b;b>>=1,(a*=a)%=P) if(b&1) (ret*=a)%=P;\n\treturn ret;\n}\n\nint init(int n)\n{\n\tint tot=1,lg2=0;\n\twhile(tot<=n) tot<<=1,lg2++;\n\tfor(int i=0;i>1]>>1)|((i&1)<<(lg2-1));\n\treturn tot;\n}\n\nvoid NTT(ll *a,int n,int f)\n{\n\tll *ed=a+n;\n\tfor(int i=0;irev[i]) swap(a[i],a[rev[i]]);\n\tfor(int i=2;i<=n;i<<=1)\n\t\tfor(ll *x=a,*y=a+(i>>1);x!=ed;x+=i,y+=i)\n\t\t\tfor(int k=0;k<(i>>1);k++)\n\t\t\t{\n\t\t\t\tll u=x[k],t=y[k]*_G_[f][k*MAXN/i]%P;\n\t\t\t\tx[k]=Add(u,t);y[k]=Sub(u,t);\n\t\t\t}\n\tif(f) for(int i=0,inv=ksm(n,P-2);i>1);\n int tot=init(n<<1),lst=(n+1)>>1;\n static ll t1[MAXN],t2[MAXN];\n memset(t1,0,sizeof(ll)*tot);memset(t2,0,sizeof(ll)*tot);\n for(int i=0;i3?G[i-4]:0);\n\tfor(int i=0;i<=n;i++) G0[i]=G[i]*i%P*i%P,G1[i]=G[i]*(i+1)%P*(i+1)%P,G2[i]=G[i]*(i+2)%P*(i+2)%P;\n\tX1[1]=1;X3[3]=1;X4[4]=1;\n\tNTT(G0,tot,0);NTT(G1,tot,0);NTT(G2,tot,0);NTT(X1,tot,0);NTT(X3,tot,0);NTT(X4,tot,0);\n\tfor(int i=0;i=3&&i<=n-3) Inc(Ans,G[i-3]*(i-1)%P*(i-1)%P*F2[n-i-3]%P*i%P);\n\t}\n\tprintf(\"%lld\\n\",Ans);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8c4ee4a86eb3e26f2e06f42f72f8895e", "src_uid": "24fd5cd218f65d4ffb7c5b97b725293e", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\nstruct node\n{\n ll sum;\n ll asum;\n};\nint a[3005];\nvectorv[3005];\nnode dp[3005][3005];\nnode tmp[3005];\nint dfs(int past,int now)\n{\n int sz=1;\n dp[now][0].sum=0;\n dp[now][0].asum=a[now];\n for(auto u:v[now]){\n if(u==past)continue;\n int l=dfs(now,u);\n for(int i=0;i=0;i--){\n node x=dp[now][i];\n if(x.asum>0){\n x.sum++;\n }\n x.asum=0;\n if(dp[now][i+1].sum0));(dp[1][m]\u7684asum\u5c0f\u4e8e0\u65f6\u662f\u4e0d\u6210\u7acb\u7684\uff0c\u6240\u4ee5\u6700\u540e\u4e0d\u76f4\u63a5\u8f93\u51fadp[1][m])\n}\nint main()\n{\n ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n int T;\n scanf(\"%d\",&T);\n //cin>>T;\n //T=1;\n while(T--){\n work();\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "431391a0a8699e45ef0d31fa8b8a31f7", "src_uid": "d2d1d8c8532b652f172e87a151adae4f", "difficulty": 2500.0} {"lang": "GNU C++17 (64)", "source_code": "// =========== Template ========== //\n#include \nusing namespace std;\nint fastio() { ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); cin.tie(nullptr); return 0; }\nint __fastio = fastio();\ntemplate ostream& operator<<(ostream &os, const pair &p);\ntemplate ostream& operator<<(ostream &os, const set &m) { os << \"{\"; string sep = \"\"; for (auto e: m) os << sep << e, sep = \", \"; return os << \"}\"; }\ntemplate ostream& operator<<(ostream &os, const multiset &m) { os << \"{\"; string sep = \"\"; for (auto e: m) os << sep << e, sep = \", \"; return os << \"}\"; }\ntemplate ostream& operator<<(ostream &os, const map &m) { os << \"{\"; string sep = \"\"; for (auto e: m) os << sep << e.first << \": \" << e.second, sep = \", \"; return os << \"}\"; }\ntemplateostream& operator<<(ostream& os, const vector& v) { os << \"[\"; string sep = \"\"; for (auto e: v) os << sep << e, sep = \", \"; return os << \"]\"; }\ntemplateostream& operator<<(ostream& os, const array& v) { os << \"[\"; string sep = \"\"; for (int i = 0; i < L; ++i) os << sep << v[i], sep = \", \"; return os << \"]\"; }\ntemplate ostream& operator<<(ostream &os, const pair &p) { os << '(' << p.first << \", \" << p.second << ')'; return os; }\nvoid dbg_out() { cerr << endl; }\ntemplate void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }\n#ifdef STEVEN\n#define pp(...) cerr << \"\\t[\" << #__VA_ARGS__ << \"]:\\t\", dbg_out(__VA_ARGS__)\n#define ppp(x) cerr << x << \"\\n\"\n#else\n#define pp(...)\n#define ppp(...)\n#endif\ntemplate class y_combinator_result { Fun fun_; public: template explicit y_combinator_result(T &&fun): fun_(std::forward(fun)) {} template decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward(args)...); } };\ntemplate decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result>(std::forward(fun)); }\n#define yc y_combinator\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef long double ld;\n#define fi first\n#define se second\n#define sz(x) (int((x).size()))\n#define data _data\n// =========== Book ============ //\n\ntemplate struct modnum {\n static constexpr int MOD = MOD_;\n static_assert(MOD_ > 0, \"MOD must be positive\");\n private:\n using ll = long long;\n int v;\n static int minv(int a, int m) {\n a %= m;\n assert(a);\n return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);\n }\n public:\n modnum() : v(0) {}\n modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }\n explicit operator int() const { return v; }\n friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }\n friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }\n friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }\n friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }\n modnum inv() const {\n modnum res;\n res.v = minv(v, MOD);\n return res;\n }\n friend modnum inv(const modnum& m) { return m.inv(); }\n modnum neg() const {\n modnum res;\n res.v = v ? MOD-v : 0;\n return res;\n }\n friend modnum neg(const modnum& m) { return m.neg(); }\n modnum operator- () const {\n return neg();\n }\n modnum operator+ () const {\n return modnum(*this);\n }\n modnum& operator ++ () {\n v ++;\n if (v == MOD) v = 0;\n return *this;\n }\n modnum& operator -- () {\n if (v == 0) v = MOD;\n v --;\n return *this;\n }\n modnum& operator += (const modnum& o) {\n v += o.v;\n if (v >= MOD) v -= MOD;\n return *this;\n }\n modnum& operator -= (const modnum& o) {\n v -= o.v;\n if (v < 0) v += MOD;\n return *this;\n }\n modnum& operator *= (const modnum& o) {\n v = int(ll(v) * ll(o.v) % MOD);\n return *this;\n }\n modnum& operator /= (const modnum& o) {\n return *this *= o.inv();\n }\n friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }\n friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }\n friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }\n friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }\n friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }\n friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }\n};\n\n\n// ============= Solution ============= //\n\nint main() {\n using mint = modnum<998244353>;\n int n;\n cin >> n;\n vector f(n + 1), g(n + 1);\n g[0] = 1;\n auto chs = [&](mint a, int k) {\n mint res = 1;\n for (int i = 1; i <= k; ++i) {\n res *= a - i + 1;\n res /= i;\n }\n return res;\n };\n for (int i = 1; i <= n; ++i) {\n g[i] = chs(g[i - 1] + 2, 2);\n f[i] = chs(g[i - 1] + 3, 3) - g[i - 1] - 1;\n }\n mint ans = 2 * (f[n] - f[n - 1]);\n\n mint sm = 0;\n vector h(n), hh(n);\n h[0] = g[0];\n for (int i = 1; i <= n; ++i) {\n h[i] = g[i] - g[i - 1];\n }\n hh[0] = h[0];\n for (int i = 1; i <= n; ++i) {\n hh[i] = h[i] - h[i - 1];\n }\n\n for (int i = n - 1; i >= 0; --i) {\n sm += hh[n - 1 - i];\n ans += sm * hh[i];\n }\n cout << ans << \"\\n\";\n}\n\n// ============== Notes =============== //\n// common bugs\n// - fastio\n// - int overflow (especially intermediate expressionns)\n// - array bounds (indices bigger than MAXN?)\n// - special cases (n=1? graph not connected?)\n// - re-initialize efficiently between test cases\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c41b6229b942edafb88e1d15ed09e745", "src_uid": "92939054045c089cd25c8f4e7b9ffcf2", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include\r\n#define pb push_back\r\n#define mp make_pair\r\nusing namespace std;\r\ntypedef long long ll;\r\ntypedef unsigned long long ull;\r\ntypedef unsigned int uint;\r\ntypedef pair pii;\r\n\r\nvoid read(int &x){\r\n static char c;int f=0;\r\n while(!isdigit(c=getchar()))\r\n if(c^45) f=1;\r\n x=c^48;\r\n while(isdigit(c=getchar())) x=(x*10)+(c^48);\r\n if(f) x=-x;\r\n}\r\nvoid read(ll &x){\r\n static char c;int f=0;\r\n while(!isdigit(c=getchar()))\r\n if(c^45) f=1;\r\n x=c^48;\r\n while(isdigit(c=getchar())) x=(x*10)+(c^48);\r\n}\r\nvoid read(uint &x){\r\n static char c;\r\n while(!isdigit(c=getchar()));x=c^48;\r\n while(isdigit(c=getchar())) x=(x*10)+(c^48);\r\n}\r\nvoid read(ull &x){\r\n static char c;\r\n while(!isdigit(c=getchar()));x=c^48;\r\n while(isdigit(c=getchar())) x=(x*10)+(c^48);\r\n}\r\nvoid chkmax(int &x,int y){if(y>x)x=y;}\r\nvoid chkmin(int &x,int y){if(yx)x=y;}\r\nvoid chkmin(ll &x,ll y){if(yx)x=y;}\r\nvoid chkmin(uint &x,uint y){if(yx)x=y;}\r\nvoid chkmin(ull &x,ull y){if(y=Mod?x-=Mod:x;}\r\n\r\nint C[N][N];\r\nvoid Prework(){\r\n\tconst int U=5e3;\r\n\tfor(int i=0;i<=U;++i) C[i][0]=1;\r\n\tfor(int i=1;i<=U;++i)\r\n\t\tfor(int j=1;j<=i;++j)\r\n\t\t\tC[i][j]=C[i-1][j],Add(C[i][j],C[i-1][j-1]);\r\n}\r\n\r\nint n,m;\r\n\r\nint Ans;\r\n\r\nvoid Work(){\r\n\tPrework();\r\n\tread(n),read(m);\r\n\tif(n==1||m==1) return puts(\"0\");\r\n\tfor(int d=1;d\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define int long long\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pll;\ntypedef pair pii;\ntypedef long double ld;\ntypedef double db;\n\nconst ll N = 1e6 + 20;\nconst ll INF = INT_MAX;\n\n/*int p = 3571;\nint mod = 2147483647;\n\nnamespace op {\n\tvoid add(int &a, int val) {\n\t\ta = ((a * p % mod + val) % mod + mod) % mod;\n\t}\n\tint calc(int a, int b) {\n\t\treturn ((a % mod + b % mod) % mod + mod) % mod;\n\t}\n\tint mul(int a, int b) {\n\t\treturn (((a % mod) * (b % mod)) % mod + mod) % mod;\n\t}\n\tint pow(int a, int n) {\n\t\tif (n == 0) return 1LL;\n\t\tif (n & 1) {\n\t\t\tint b = pow(a, n ^ 1) % mod;\n\t\t\treturn mul(a, b);\n\t\t}\n\t\telse {\n\t\t\tint b = pow(a, n >> 1) % mod;\n\t\t\treturn mul(b, b);\n\t\t}\n\t}\n};\nusing namespace op;\n\nstruct hsh {\n\tstring vec;\n\tvector seg;\n\tint n;\n\thsh(string a) {\n\t\tn = a.size();\n\t\tvec = a;\n\t\tseg.resize(a.size() + 1);\n\t\tfor (int i = 0; i < a.size(); ++i) {\n\t\t\tseg[i + 1] = seg[i];\n\t\t\tadd(seg[i + 1], a[i]);\n\t\t}\n\t}\n\tint seg_hash(int l, int r) {\n\t\treturn calc(seg[r], (-1) * seg[l - 1] * pow(p, r - l + 1));\n\t}\n};*/\n\nvector g[N];\nint used[N], ct[N];\n\nvector comp[2];\n\nint id;\nvoid dfs(ll v) {\n\tcomp[id].push_back(v);\n\tused[v] = 1;\n\n\tfor (ll to : g[v]) {\n\t\tif (!used[to])\n\t\t\tdfs(to);\n\t}\n}\n\nvoid clear(int n) {\n\tfor (ll i = 0; i < n; ++i) {\n\t\tg[i].clear();\n\t\tused[i] = ct[i] = 0;\n\t}\n}\n\nsigned main() {\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n#else\n#endif\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0); cout.tie(0);\n\n\tint t;\n\tcin >> t;\n\twhile (t--) {\n\t\tint n, m, a, b;\n\t\tcin >> n >> m >> a >> b;\n\t\ta--; b--;\n\t\tfor (int i = 0; i < m; ++i) {\n\t\t\tint x, y;\n\t\t\tcin >> x >> y;\n\t\t\t--x; --y;\n\t\t\tg[x].push_back(y);\n\t\t\tg[y].push_back(x);\n\t\t}\n\n\t\tid = 0; used[b] = 1;\n\t\tdfs(a);\n\t\tfor (auto &x : comp[0]) {\n\t\t\tused[x] = 0;\n\t\t}\n\t\tused[b] = 0;\n\t\tid = 1; used[a] = 1;\n\t\tdfs(b);\n\t\tfor (auto &x : comp[0])\n\t\t\tct[x]++;\n\t\tfor (auto &x : comp[1])\n\t\t\tct[x]++;\n\n\t\tint arr[2] = { -1,-1 };\n\t\tfor (int i = 0; i < 2; ++i)\n\t\t\tfor (auto &x : comp[i])\n\t\t\t\tif (ct[x] == 1)\n\t\t\t\t\tarr[i]++;\n\n\t\tcout << max(0ll, arr[0] * arr[1]) << '\\n';\n\t\tclear(n);\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "858c4950658e618be2072dfb76e065ca", "src_uid": "7636c493ad91210ec7571895b4b71214", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#pramga GCC optimize(2)\n#include \nusing namespace std;\ninline int read()\n{\n int x=0,f=1;\n char ch = 0;\n while(!isdigit(ch)) {if(ch=='-') f=-1; ch = getchar();}\n while(isdigit(ch)) {x = x*10+ch-'0'; ch = getchar();}\n return x*f;\n}\n//typedef __int128 ll;\ntypedef long long ll;\nconst int mod = 1e9+7;\nconst int maxn = 1e6+100;\nint T,m,x;\nll n;\nint wei[70],cnt;\n//ll dp[70][8];\n\nll qpow(ll x,ll p)\n{\n ll ret = 1;\n while(p)\n {\n if(p&1) ret = ret*x%mod;\n x = x*x%mod;\n p >>= 1;\n }\n return ret;\n}\nint main()\n{\n //T = read();\n //ll _2 = qpow(2,mod-2);\n const int _2 = 500000004;\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n cin >> T;\n while(T--)\n {\n //n = read();\n //scanf(\"%lld\",&n);\n cin >> n;\n //BigInteger ans = BigInteger(n);\n //cout << ans << \"---\\n\";\n //ll ans = (ans/2+2+(n%4>=2))*(ans/4+1)/2;\n //cout << (n%mod*_2+2+(n%4>=2))%mod << \"-----\" << (n/4%mod+1) <=2))%mod*(n%mod*_4%mod+1)*_2%mod;\n //ll ans = (n/2+2+(n%4>=2))%mod*(n/4%mod+1)%mod*_2%mod;\n cout << (n/2%mod+2+(n%4>=2))*(n/4%mod+1)%mod*_2%mod << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5e7e91f4b94f6bd8a104aac4e653ae37", "src_uid": "24f4bd10ae714f957920afd47ac0c558", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \n#define ll long long \n#define de() cout<<\"test\"<<\"\\n\" \nusing namespace std;\n\nconst ll maxn=3e6+10;\nconst ll mod=1e9+7;\nll n,l1,l2,s1,s2,S1,S2,N,r[maxn];\nll mul[maxn],inv[maxn],q1[maxn],q2[maxn],ans,er[maxn];\nchar a[maxn],b[maxn];\nll limit=1,l;\nll poww(ll x,ll k) {\n\tll ans=1;\n\twhile(k) {\n\t\tif(k&1) ans=ans*x%mod;\n\t\tx=x*x%mod;\n\t\tk>>=1;\n\t}return ans;\n}\nll C(ll a,ll b) {\n\treturn mul[a]*inv[b]%mod*inv[a-b]%mod;\n}\nll gcd(ll a,ll b) {\n\treturn b==0?a:gcd(b,a%b);\n}\nll wo(ll a,ll b) {\n\tif(1ll*a*b>0) return 0;a=abs(a);b=abs(b);\n\tif(a==0&&b==0) return er[n]*er[n]%mod;\n\tif(a==0||b==0) return 0;\n\tif(a>b) swap(a,b);\n\tll qwq=n/b;\n\treturn er[qwq];\n}\nconst double Pi=acos(-1.0);\nstruct com\n{\n\tlong double x,y;com(long double xx=0,long double yy=0):x(xx),y(yy){}\n}A[maxn],B[maxn];\ninline ll read() {ll data=0,f=1;char c=getchar();while('0'>c||c>'9') {if(c=='-') f=-1;c=getchar();}while('0'<=c&&c<='9') {data=data*10+c-'0';c=getchar();}return data;}\ncom operator * (com A,com B) {\n\treturn com(A.x*B.x-A.y*B.y,A.x*B.y+A.y*B.x);\n}\ncom operator + (com A,com B) {\n\treturn com(A.x+B.x,A.y+B.y);\n}\ncom operator - (com A,com B) {\n\treturn com(A.x-B.x,A.y-B.y);\n}\nvoid fft(com *A,ll type) \n{\n\tfor(ll i=0;i>1]>>1)|((i&1)<<(l-1));\n\tfft(A,1);fft(B,1);for(ll i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \nusing namespace std; \nconst long long inf=1e18;\nlong long ex[15];\nint low[15],high[15];\nint num_state;\nchar str[16];\nint len,stk[15][15],cnt_stk[15],sum[15],bs[15];\nint ve[1<<14],vis[15],times,list[1<<14],cnt_list,f[1<<14],oe[1<<14],bn[15];\nlong long dp[1<<14][16],ans;\nlong long gs[1<<14],g[1<<14];\nint fir[1<<14],gm[1<<14],ls[15],cnt_ls,adj[16];\nlong long cg[16];\nint change(char ch)\n{\n\tif(ch<='9'&&ch>='0')\n\t return ch-'0';\n return ch-'a'+10;\n}\nint main()\n{\n\tint i,j,s,p,q;\n start=clock();\n\tfor(i=0;i<=14;i++)\n\t{\n\t\tif(i==0)\n\t\t ex[i]=1;\n else\n ex[i]=ex[i-1]*16;\n\t}\n\tscanf(\"%s\",str); \n\tlen=strlen(str);\n\tmemset(cnt_stk,0,sizeof(cnt_stk));\n\tint nc=0,tot=0;\n\tfor(i=0;i=0;i--)\n {\n \tif(i&1)\n \t continue;\n\t int sum=0;\n\t for(j=0;j=0;j--)\n\t {\n \t\tif((!(i&(1<high[j])\n\t \t\t ok=false;\n\t \t}\n\t }\n\t\tif(ok)\n \t{\n \t\tif(ans=len||low[j]>(ans/ex[len-1-j])%16)\n\t\t continue;\n \t\t}\n \t cnt_list=0;\n \t for(j=0;j<(1<=low[s]&&j<=high[s])\n\t \t \t adj[j]|=(1<=ans)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t int state=((1<0;state-=(state&-state))\n\t\t\t\t {\n \t\t\t\t\t q=oe[state&-state];\n\t\t\t\t\t\t\t dp[j|(1<dp[j][s])\n\t \t\t \t gs[j]=dp[j][s];\n\t \t\t }\n \t\t }\n \t\t g[0]=0;\n \t\t for(j=0;j<(1<g[(1<\n#define clr(x) memset(x,0,sizeof (x))\n#define outvec(A) printf(#A\" = \");for (auto __v : A) printf(\"%d,\",__v);puts(\"\");\nusing namespace std;\ntypedef long long LL;\nLL read(){\n\tLL x=0,f=0;\n\tchar ch=getchar();\n\twhile (!isdigit(ch))\n\t\tf|=ch=='-',ch=getchar();\n\twhile (isdigit(ch))\n\t\tx=(x<<1)+(x<<3)+(ch^48),ch=getchar();\n\treturn f?-x:x;\n}\nconst int N=10005;\nint n;\nmap mpa[N],mpb[N];\nvector a[N],b[N];\nint p[N];\nvoid Getp(vector &A,vector &B){\n\tstatic int ga[10][10],gb[10][10],ya[N],yb[N];\n\tclr(ga),clr(gb);\n\tmemset(ya,-1,sizeof ya);\n\tmemset(yb,-1,sizeof yb);\n\tint m=A.size(),cnt=1;\n\tfor (int i=1;i<=m;i++)\n\t\tcnt*=i;\n\tfor (int i=0;i id(0);\n\tfor (int i=0;i &v,int u){\n\tint flag=0;\n\tfor (int i=0;i<(int)v.size();i++)\n\t\tif (v[i]==u){\n\t\t\tswap(v[i],v.back());\n\t\t\tv.pop_back();\n\t\t\tflag=1;\n\t\t}\n\tassert(flag);\n}\nint solve(){\n\tvector A(0),B(0);\n\tint ra=0,rb=0;\n\tfor (int i=1;i<=n;i++){\n\t\tif (!a[i].empty())\n\t\t\tA.push_back(i);\n\t\tif (!b[i].empty())\n\t\t\tB.push_back(i);\n\t\tif (a[i].size()>a[ra].size())\n\t\t\tra=i;\n\t\tif (b[i].size()>b[rb].size())\n\t\t\trb=i;\n\t}\n\tint m=A.size();\n//\tprintf(\"ra = %d, rb = %d\\n\",ra,rb);\n//\toutvec(A);outvec(B);\n\tif ((int)a[ra].size()+1==m||(int)b[rb].size()+1==m)\n\t\treturn 0;\n\tif (m<=5)\n\t\treturn Getp(A,B),1;\n\tif ((int)a[ra].size()+1==m-1){\n\t\tint ai=0;\n\t\tfor (int i=0;i\n#define LL long long\n\nusing namespace std;\nconst int N=100+10;\nint rd()\n{\n int x=0,w=1;char ch=0;\n while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}\n while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}\n return x*w;\t\n}\nint id[N][N][N],vs[N][N][N];\nint n,sx,sy,sz,tx,ty,tz,ls;\nvoid mv(int dx,int dy,int dz,int dt)\n{\n sx+=dx,sy+=dy,sz+=dz;\n id[sx][sy][sz]=ls+dt,ls=id[sx][sy][sz];\n}\n\nint main()\n{\n n=rd();\n if(n==1){puts(\"1\");return 0;}\n sx=sy=tx=ty=50,sz=tz=1,vs[sx][sy][sz]=1;\n ls=id[sx][sy][sz],mv(0,1,0,1);\n int px=1;\n for(int s=2;s<=n;++s)\n {\n\tif(s&1)\n\t{\n\t ls=id[sx][sy][sz];\n\t mv(0,0,1,px);\n\t for(int i=2;i<=s;++i) mv(-1,0,0,px);\n\t swap(sx,tx),swap(sy,ty),swap(sz,tz),ls=id[sx][sy][sz],px=-px;\n\t mv(0,0,1,px);\n\t for(int j=2;j<=s-2;++j) mv(0,1,0,px);\n\t for(int i=2;i<=s;++i) mv(1,0,0,px);\n\t for(int j=s-3;j>0;--j)\n\t {\n\t\tmv(0,-1,0,px);\n\t\tfor(int i=2;i<=s-1;++i) mv((j&1)?1:-1,0,0,px);\n\t }\n\t swap(sx,tx),swap(sy,ty),swap(sz,tz),ls=id[sx][sy][sz],px=-px;\n\t mv(0,1,0,px);\n\t for(int i=1;i<=s;++i)\n\t {\n\t\tfor(int j=2;j<=s;++j) mv((i&1)?1:-1,0,0,px);\n\t\tif(i1) mv(0,0,1,px);\n\t }\n\t swap(sx,tx),swap(sy,ty),swap(sz,tz),px=-px;\n\t}\n\telse\n\t{\n\t ls=id[sx][sy][sz];\n\t mv(0,0,1,px);\n\t if(s>2)\n\t\tfor(int i=2;i<=s;++i) mv(0,1,0,px);\n\t swap(sx,tx),swap(sy,ty),swap(sz,tz),ls=id[sx][sy][sz],px=-px;\n\t mv(0,0,1,px);\n\t if(s>2)\n\t\tfor(int i=1;i<=s;++i)\n\t\t{\n\t\t for(int j=2;j<=s-2;++j) mv((i&1)?1:-1,0,0,px);\n\t\t if(i1) mv(0,0,1,px);\n\t }\n\t}\n }\n if(n&1)\n {\n\tint mi=n*n*n;\n\tfor(int i=tx;i<=sx;++i)\n\t for(int j=sy;j\nusing namespace std;\n\n#define N 10010\n\nint k, n;\n\nconst double ep = 1e-8;\nconst double pi = 3.14159265358979323846264338327950288L;\nstruct pnt {\n double x, y;\n pnt(double x = 0, double y = 0) : x(x), y(y) {}\n pnt operator + (const pnt &b) {\n return pnt(x + b.x, y + b.y);\n }\n pnt operator - (const pnt &b) {\n return pnt(x - b.x, y - b.y);\n }\n pnt operator * (const double &b) {\n return pnt(x * b, y * b);\n }\n pnt operator / (const double &b) {\n return pnt(x / b, y / b);\n }\n double operator & (const pnt &b) {\n return x * b.x + y * b.y;\n }\n double operator ^ (const pnt &b) {\n return x * b.y - b.x * y;\n }\n pnt rot() {\n return pnt(-y, x);\n }\n friend double dist(pnt a) {\n return sqrt(a.x * a.x + a.y * a.y);\n };\n void input() {\n scanf(\"%lf %lf\", &x, &y);\n }\n void print() {\n printf(\"%.12lf %.12lf \", x, y);\n }\n} p[N];\n\npnt outc(pnt a, pnt b, pnt c) {\n return (a + b + (b - a).rot() * (a - c & b - c) / (a - c ^ b - c)) / 2;\n}\n\nbool vis[N];\n\ndouble del;\n\nbool check(pnt O, double r, vector &rlt) {\n if (dist(O) > 1000100 || r < 240000 || r > 760000) return 0;\n int cnt = 0; vector cur;\n for (int i = 0; i < n * k; i ++) {\n if (vis[i]) continue;\n double d = dist(O - p[i]);\n if (0.9 * r <= d && d <= 1.1 * r) cnt ++, cur.push_back(i);\n }\n //if (cnt < 0.6 * n) return 0;\n if (cnt < del * n) return 0;\n// for (int i = 0; i < n * k; i ++) {\n// if (vis[i]) continue;\n// double d = dist(O - p[i]);\n// if (0.9 * r <= d && d <= 1.1 * r) cout << d << ' ' << r << endl;\n// }\n random_shuffle(cur.begin(), cur.end()); rlt.clear();\n for (int i = 0; i < cnt && i < n; i ++) vis[cur[i]] = 1, rlt.push_back(cur[i]);\n return 1;\n}\n\nvector ans;\nvector ans_r;\n\nbool solve(int cc) {\n if (cc == k) return 1;\n vector vec;\n for (int j = 0; j < n * k && vec.size() < 14; j ++) if (!vis[j]) vec.push_back(j);\n int sz = vec.size();\n for (int a = 0; a < sz; a ++) {\n for (int b = 0; b < a; b ++) {\n for (int c = 0; c < b; c ++) {\n pnt O = outc(p[vec[a]], p[vec[b]], p[vec[c]]);\n for (int x = -0; x <= 0; x ++) {\n for (int y = -0; y <= 0; y ++) {\n pnt P = O; P.x += x, P.y += y;\n double r = dist(P - p[vec[a]]);\n vector vec;\n if (check(P, r, vec)) {\n ans[cc] = P, ans_r[cc] = r;\n if (solve(cc + 1)) return 1;\n int sz = vec.size();\n for (int j = 0; j < sz; j ++) vis[vec[j]] = 0;\n }\n }\n }\n }\n }\n }\n return 0;\n}\n\nint main() {\n //srand(time(0));\n scanf(\"%d %d\", &k, &n);\n for (int i = 0; i < n * k; i ++) p[i].input();\n random_shuffle(p, p + n * k);\n ans.resize(k), ans_r.resize(k);\n for (del = 1.0; !solve(0); del -= 0.015);\n for (int i = 0; i < k; i ++) ans[i].print(), printf(\"%.12lf\\n\", ans_r[i]);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ac7125bf9cca01b8343ce61452b8763b", "src_uid": "e3f43a4cb8507c1fb5e896bd29eaa339", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n\ntemplate \nstruct ModInt {\n using lint = long long;\n int val;\n\n // constructor\n ModInt(lint v = 0) : val(v % MOD) {\n if (val < 0) val += MOD;\n };\n\n // unary operator\n ModInt operator+() const { return ModInt(val); }\n ModInt operator-() const { return ModInt(MOD - val); }\n ModInt inv() const { return this->pow(MOD - 2); }\n\n // arithmetic\n ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }\n ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }\n ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }\n ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }\n ModInt pow(lint n) const {\n auto x = ModInt(1);\n auto b = *this;\n while (n > 0) {\n if (n & 1) x *= b;\n n >>= 1;\n b *= b;\n }\n return x;\n }\n\n // compound assignment\n ModInt& operator+=(const ModInt& x) {\n if ((val += x.val) >= MOD) val -= MOD;\n return *this;\n }\n ModInt& operator-=(const ModInt& x) {\n if ((val -= x.val) < 0) val += MOD;\n return *this;\n }\n ModInt& operator*=(const ModInt& x) {\n val = lint(val) * x.val % MOD;\n return *this;\n }\n ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }\n\n // compare\n bool operator==(const ModInt& b) const { return val == b.val; }\n bool operator!=(const ModInt& b) const { return val != b.val; }\n\n // I/O\n friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }\n friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }\n};\n\nconstexpr int MOD = 1e9 + 7;\nusing mint = ModInt;\n\ntemplate \nstd::vector vec(int len, T elem) { return std::vector(len, elem); }\n\nint main() {\n int n, x;\n std::string t;\n std::cin >> n >> x >> t;\n\n auto sdp = vec(x + 1, vec(n + 1, vec(n + 1, mint(0))));\n auto pdp = sdp, adp = sdp;\n auto cnts = vec(x + 1, mint(0)); // \u89e3\n auto lenpow = vec(x + 1, mint(0)); // 2^|F(k)|\n\n for (int k = 0; k < 2; ++k) {\n std::string s(1, '0' + k); // F(k)\n\n for (int l = 0; l <= n; ++l) {\n // \u7a7a\u6587\u5b57\u5217\n sdp[k][l][l] = 2;\n pdp[k][l][l] = 2;\n adp[k][l][l] = 1;\n\n if (s == t.substr(l, 1)) {\n sdp[k][l][l + 1] = 1;\n pdp[k][l][l + 1] = 1;\n adp[k][l][l + 1] = 1;\n }\n }\n cnts[k] = adp[k][0][n];\n lenpow[k] = 2;\n }\n\n for (int k = 2; k <= x; ++k) {\n lenpow[k] = lenpow[k - 1] * lenpow[k - 2];\n\n for (int l = 0; l <= n; ++l) {\n for (int r = l; r <= n; ++r) {\n pdp[k][l][r] = 0;\n sdp[k][l][r] = 0;\n adp[k][l][r] = 0;\n\n for (int i = l; i <= r; ++i) {\n // F(k-1)\u304b\u3089i\u6587\u5b57\n pdp[k][l][r] += (i == r ? pdp : adp)[k - 1][l][i] * pdp[k - 2][i][r];\n sdp[k][l][r] += sdp[k - 1][l][i] * (i == l ? sdp : adp)[k - 2][i][r];\n adp[k][l][r] += adp[k - 1][l][i] * adp[k - 2][i][r];\n }\n }\n }\n\n // \u89e3\u306e\u66f4\u65b0\n cnts[k] = cnts[k - 1] * lenpow[k - 2] + cnts[k - 2] * lenpow[k - 1];\n for (int i = 1; i < n; ++i) {\n cnts[k] += sdp[k - 1][0][i] * pdp[k - 2][i][n];\n }\n }\n\n std::cout << cnts[x] << std::endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "62ba17f5d63aa76cbba45d45d71478a7", "src_uid": "52c6aa73ff4460799402c646c6263630", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n/*\nint main()\n {\n for each(i,j,k,bot,l,cur)\n {\n if (j+1<=m && !bot)\n {\n for (int p=0; p<=k/2; ++p)\n if (c[k][p]*l<=q && i+p+k<=n)\n { \n {\n int tmp=n-i-p-k;\n int tmp2=c[k][p]*l;\n for (int w=0; w<=tmp; ++w)\n if (tmp2*power[p][w]<=q)\n addto(cur,i+k+p+w,j+1,p+w,false,tmp2*power[p][w]);\n else \n break;\n }\n if (p!=k/2 && i+k-p+k<=n)\n {\n p=k-p;\n int tmp=n-i-p-k;\n int tmp2=c[k][p]*l;\n for (int w=0; w<=tmp; ++w)\n if (tmp2*power[p][w]<=q)\n addto(cur,i+k+p+w,j+1,p+w,false,tmp2*power[p][w])\n else\n break;\n p=k-p;\n }\n }\n }\n else\n {\n //case one newbot=false;\n for (int p=0; p<=k/2; ++p)\n if (c[k][p]*l<=q && i+p+k<=n)\n {\n {\n int tmp=n-i-p-k;\n int tmp2=c[k][p]*l;\n for (int w=0; w<=tmp; ++w)\n if (tmp2*power[p][w]<=q)\n addto(cur,i+k+p+w,j+1,p+w,false,tmp2*power[p][w])\n else\n break;\n }\n if (p!=k/2 && i+k-p+k<=n)\n {\n p=k-p;\n int tmp=n-i-p-k;\n int tmp2=c[k][p]*l;\n for (int w=0; w<=tmp; ++w)\n if (tmp2*power[p][w]<=q)\n addto(cur,i+k+p+w,j+1,p+w,false,tmp2*power[p][w])\n else\n break;\n p=k-p;\n }\n }\n //case two newbot=true\n for (int p=0; p<=k/2; ++p)\n if (c[k][p]*l<=q && i+p+k+1<=n)\n {\n {\n int tmp=n-i-p-k-1;\n int tmp2=c[k][p]*l;\n for (int w=0; w<=tmp; ++w)\n if (tmp2*power[p+1][w]<=q)\n addto(cur,i+k+p+w+1,j+1,p+w,true,tmp2*power[p+1][w])\n else\n break;\n }\n if (p!=k/2 && i+k-p+k+1<=n)\n {\n p=k-p;\n int tmp=n-i-p-k-1;\n int tmp2=c[k][p]*l;\n for (int w=0; w<=tmp; ++w)\n if (tmp2*power[p+1][w]<=q)\n addto(cur,i+k+p+w+1,j+1,p+w,true,tmp2*power[p+1][w])\n else\n break;\n p=k-p;\n }\n }\n }\n } \n }\n*/\nconst int hashn=100007;\nconst int modular=1000000007;\nstruct fish\n {\n int cur,i,j,k,l;\n } que[1000000];\nstruct pear\n {\n int data,next;\n } hash[1000000];\nint hashf(int i,int j,int k,int l)\n {\n return (i*10007+j*9901+k*11001+l*23123)% hashn;\n }\nint lef,righ,statepool,m;\nvoid addto(int cur,int i,int j,int k,int l)\n {\n if (j>m) return;\n if (l==0)\n {\n ++cur;\n --cur;\n }\n int h=hashf(i,j,k,l);\n for (int p=hash[h].next;p!=0;p=hash[p].next)\n {\n int x=hash[p].data;\n if (que[x].i==i && que[x].j==j && que[x].k==k && que[x].l==l)\n {\n que[x].cur+=cur;\n if (que[x].cur>modular) que[x].cur-=modular;\n return;\n }\n }\n ++righ;\n que[righ].i=i;\n que[righ].j=j;\n que[righ].k=k;\n que[righ].l=l;\n que[righ].cur=cur;\n ++statepool;\n hash[statepool].next=hash[h].next;\n hash[statepool].data=righ;\n hash[h].next=statepool;\n }\nint power[110][110];\nint c[110][110],bottle[110][110];\nint q;\nvoid init()\n {\n lef=1; righ=0; statepool=0;\n memset(power,0,sizeof(power));\n memset(hash,0,sizeof(hash));\n memset(c,0,sizeof(c));\n for (int i=0; i<=100; ++i)\n {\n power[i][0]=1;\n for (int j=1; j<=100 && power[i][j-1]<=q; ++j)\n power[i][j]=power[i][j-1]*i;\n }\n c[0][0]=1;\n for (int i=1; i<=100; ++i)\n {\n c[i][0]=1;\n c[i][i]=1;\n for (int j=1; j<=i-1 && c[i][j-1]<=q; ++j)\n c[i][i-j]=c[i][j]=c[i-1][j-1]+c[i-1][j];\n }\n memset(bottle,0,sizeof(bottle));\n bottle[0][0]=1;\n for (int i=1; i<=100; ++i)\n for (int j=0;j<=100; ++j)\n for (int k=0; k<=j; ++k)\n bottle[i][j]+=bottle[i-1][k];\n }\nint n,i,j,k,l,p,w,tmp,tmp2,cur;\nint totalans;\nbool bot;\nint main()\n {\n cin >> n >> m >> q;\n ++n;\n init();\n for (i=2; i<=(n+1)/2; ++i)\n addto(1,i,1,i-1,1);\n totalans=0;\n for (;lef<=righ;++lef)\n {\n i=que[lef].i;\n j=que[lef].j;\n k=que[lef].k;\n l=que[lef].l;\n cur=que[lef].cur;\n if (k==0) \n {\n totalans=(totalans+cur*(long long)(m-j+1))% modular;\n } \n //printf(\"%d %d %d %d %d %d\\n\",i,j,k,l,cur,cur*(m-j+1)); \n \n if (lef==1)\n {\n ++i;\n --i;\n }\n if (j+1<=m && k!=0)\n {\n /*\n for (p=0; p<=(k+1)/2; ++p)\n if (c[k][p]*l<=q && i+p+k<=n)\n {\n {\n tmp=n-i-p-k;\n tmp2=c[k][p]*l;\n for (w=0; w<=tmp; ++w)\n {\n if (tmp2*power[p][w]<=q)\n addto(cur,i+k+p+w,j+1,p+w,tmp2*power[p][w]);\n else\n break;\n if (p==0) break;\n }\n }\n if (k-p>(k+1)/2 && i+k-p+k<=n)\n {\n p=k-p;\n tmp=n-i-p-k;\n tmp2=c[k][p]*l;\n for (w=0; w<=tmp; ++w)\n if (tmp2*power[p][w]<=q)\n addto(cur,i+k+p+w,j+1,p+w,tmp2*power[p][w]);\n else\n break;\n p=k-p;\n }\n }\n */\n //p:\u4e0b\u4e00\u884c\u70b9\u7684\u4e2a\u6570\n for (p=k; p<=n;++p)\n if (bottle[k][p-k]*l<=q && i+p<=n)\n {\n addto(cur,i+p,j+1,p-k,bottle[k][p-k]*l);\n }\n else\n break;\n }\n } \n cout << totalans << endl;\n }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "76868c26ef53fa757047e8f30c15bb25", "src_uid": "c6d275b1e1d5c9e39e2cf990a635fa6b", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nvector opers;\nint modulo(1e9 + 7);\ntypedef long long LL;\nint pw(int x, int n) {\n\tint res(1);\n\twhile(n) {\n\t\tif(n & 1)\n\t\t\tres = (LL)res * x % modulo;\n\t\tx = (LL)x * x % modulo;\n\t\tn /= 2;\n\t}\n\treturn res;\n}\ninline bool isDigit(char c) {\n\treturn c >= '0' && c <= '9';\n}\nconst int N(111111);\nchar st[N];\nstruct Opad {\n\tstring str;\n\tint val, mul;\n\tOpad() {\n\t\tval = 0;\n\t\tmul = 1;\n\t}\n};\nvector opads;\nvoid operate() {\n\tOpad o1, o2;\n\to2 = opads.back();\n\topads.pop_back();\n\to1 = opads.back();\n\topads.pop_back();\n\tif(opers.back() == '+') {\n\t\tOpad res;\n\t\tres.val = ((LL)o1.val * o2.mul + o2.val) % modulo;\n\t\tres.mul = (LL)o1.mul * o2.mul % modulo;\n\t\topads.push_back(res);\n\t}else {\n\t\tOpad res;\n\t\tfor(int i((int)o1.str.size() - 1); i >= 0; i--) {\n\t\t\tfor(int j(0); j < (int)o1.str[i] - '0'; j++) {\n\t\t\t\tres.val = ((LL)res.val * o2.mul + o2.val) % modulo;\n\t\t\t\tres.mul = ((LL)res.mul * o2.mul) % modulo;\t\n\t\t\t}\n\t\t\tint mul(o2.mul), add(o2.val);\n\t\t\tfor(int j(0); j < 9; j++) {\n\t\t\t\to2.mul = ((LL)mul * o2.mul) % modulo;\n\t\t\t\to2.val = ((LL)mul * o2.val + add) % modulo;\n\t\t\t}\n\t\t}\n\t\topads.push_back(res);\n\t}\n\topers.pop_back();\n}\nOpad calc(const string & a) {\n\tOpad res;\n\tres.str = a;\n\tfor(int i(0); i < (int)a.size(); i++) {\n\t\tres.mul = res.mul * 10ll % modulo;\n\t\tres.val = (res.val * 10ll + a[i] - '0') % modulo;\n\t}\n\treturn res;\n}\nOpad calc(const string & le, const string & ri) {\n\t//cout << le << ' ' << ri << endl;\n\tOpad res;\n\tOpad a(calc(le)), b(calc(ri));\n\tint phil(0), phir(0);\n\tfor(int i(0); i < (int)le.size(); i++) {\n\t\tphil = ((LL)phil * 10ll + le[i] - '0') % (modulo - 1);\n\t}\n\tfor(int i(0); i < (int)ri.size(); i++) {\n\t\tphir = ((LL)phir * 10ll + ri[i] - '0') % (modulo - 1);\n\t}\n\t//cout << a.val << ' ' << b.mul << endl;\n\tint cur(1), curphi(1);\n\tfor(int i(1); i < le.size(); i++) {\n\t\tcur = cur * 10ll % modulo;\n\t\tcurphi = curphi * 10ll % (modulo - 1);\n\t}\n\tfor(int len(le.size()); len <= ri.size(); len++) {\n\t\tint leval, rival, lephi, riphi;\n\t\tif(len == le.size()) {\n\t\t\tleval = a.val;\n\t\t\tlephi = phil;\n\t\t}else {\n\t\t\tleval = cur;\n\t\t\tlephi = curphi;\n\t\t}\n\t\tif(len == ri.size()) {\n\t\t\trival = b.val;\n\t\t\triphi = phir;\n\t\t}else {\n\t\t\trival = (cur * 10ll + modulo - 1) % modulo;\n\t\t\triphi = (curphi * 10ll + modulo - 2) % (modulo - 1);\n\t\t}\n\t\t//printf(\"%d %d %d %d\\n\", leval, lephi, rival, riphi);\n\t\tint bs(pw(10, len));\n\t\t//cout << bs << endl;\n\t\t//cout << (rival + 1ll) * ((pw(bs, (riphi - lephi + modulo) % (modulo - 1)) - 1ll + modulo) * pw(bs - 1, modulo - 2) % modulo) % modulo << endl;\n\t\t//cout << ((rival - leval + 1ll + modulo) * pw(bs, (rival - leval + 1 + modulo) % (modulo - 1)) - (rival - leval + 2ll + modulo) * pw(bs, (riphi - lephi + modulo) % (modulo - 1)) + 1) % modulo * pw(bs - 1, modulo - 2) % modulo * pw(bs - 1, modulo - 2) % modulo << endl;\n\t\t//cout << ((rival + 1ll) * ((pw(bs, (riphi - lephi + modulo) % (modulo - 1)) - 1ll + modulo) * pw(bs - 1, modulo - 2) % modulo) % modulo - ((rival - leval + 1ll + modulo) * pw(bs, (rival - leval + 1 + modulo) % (modulo - 1)) - (rival - leval + 2ll + modulo) * pw(bs, (riphi - lephi + modulo) % (modulo - 1)) + 1) % modulo * pw(bs - 1, modulo - 2) % modulo * pw(bs - 1, modulo - 2) % modulo) << endl;\n\t\tint val = (((rival + 1ll) * ((pw(bs, (riphi - lephi + modulo) % (modulo - 1)) - 1ll + modulo) * pw(bs - 1, modulo - 2) % modulo) % modulo - ((rival - leval + 1ll + modulo) * pw(bs, (riphi - lephi + 1 + modulo) % (modulo - 1)) - (rival - leval + 2ll + modulo) * pw(bs, (riphi - lephi + modulo) % (modulo - 1)) + 1) % modulo * pw(bs - 1, modulo - 2) % modulo * pw(bs - 1, modulo - 2) % modulo) + modulo) % modulo;\n\t\tint mul = pw(bs, (riphi - lephi + modulo) % (modulo - 1));\n\t\tres.val = ((LL)res.val * mul + val) % modulo;\n\t\tres.mul = (LL)res.mul * mul % modulo;\n\t\t//cout << val << ' ' << mul << endl;\n\t\tcur = cur * 10ll % modulo;\n\t\tcurphi = curphi * 10ll % (modulo - 1);\n\t}\n\treturn res;\n}\nint main() {\n\tscanf(\"%s\", st);\n\tint len(strlen(st));\n\tfor(int i(0); i < len; i++) {\n\t\tif(isDigit(st[i])) {\n\t\t\tstring s;\n\t\t\tint j(i);\n\t\t\tfor( ; isDigit(st[j]); j++)\n\t\t\t\ts.push_back(st[j]);\n\t\t\tif(st[j] == '-') {\n\t\t\t\tstring t;\n\t\t\t\tfor(j++; isDigit(st[j]); j++)\n\t\t\t\t\tt.push_back(st[j]);\n\t\t\t\topads.push_back(calc(s, t));\n\t\t\t}else {\n\t\t\t\topads.push_back(calc(s));\n\t\t\t}\n\t\t\ti = j - 1;\n\t\t}else if(st[i] == '(') {\n\t\t\topers.push_back('(');\n\t\t}else if(st[i] == '+') {\n\t\t\topers.push_back('+');\n\t\t}else if(st[i] == ')') {\n\t\t\twhile(opers.back() != '(') {\n\t\t\t\toperate();\t\n\t\t\t}\n\t\t\toperate();\n\t\t}\n\t}\n\twhile(opers.size())\n\t\toperate();\n\tcout << opads.back().val << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4b21294d114c1b8e23415d067c95b592", "src_uid": "0617f1ffa520d5b96232a4cfd9a15d0c", "difficulty": 3400.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nint N, V, E;\nint mat[301][301];\nint A[301], B[301];\nvector, int> > R;\n\nvoid flow2(vector& P, int si, int ti, int d) {\n\tint i;\n\tif (si == ti) return;\n\tif (A[P[si + 1]] + d <= V) {\n\t\tA[P[si]] -= d;\n\t\tA[P[si + 1]] += d;\n\t\tR.push_back(make_pair(make_pair(P[si], P[si + 1]), d));\n\t\tflow2(P, si + 1, ti, d);\n\t}\n\telse {\n\t\tint d2 = V - A[P[si + 1]];\n\t\tA[P[si]] -= d2;\n\t\tA[P[si + 1]] += d2;\n\t\tif (d2 > 0) R.push_back(make_pair(make_pair(P[si], P[si + 1]), d2));\n\t\tflow2(P, si + 1, ti, d);\n\t\tA[P[si]] -= d - d2;\n\t\tA[P[si + 1]] += d - d2;\n\t\tR.push_back(make_pair(make_pair(P[si], P[si + 1]), d - d2));\n\t}\n}\n\n#define FOR(y, N) for (int y = 0; y < N; ++y)\n\nint flow(int s, int t, int d) {\n\tint i, j, y;\n\tvector P;\n\tP.push_back(s);\n\tfor (i = s; i != t;) {\n\t\tFOR(y, N) if (mat[i][y] == 1 && mat[y][t] == mat[i][t] - 1) break;\n\t\tP.push_back(i = y);\n\t}\n\n\tflow2(P, 0, P.size() - 1, d);\n}\n\n#define _P printf\n\nvoid solve() {\n\tint f, r, i, j, k, l, x, y;\n\n\tcin >> N >> V >> E;\n\tFOR(i, N) cin >> A[i];\n\tFOR(i, N) cin >> B[i];\n\n\tFOR(x, N) FOR(y, N) mat[x][y] = 9999;\n\tFOR(x, N) mat[x][x] = 0;\n\tFOR(i, E) {\n\t\tcin >> x >> y;\n\t\tmat[x - 1][y - 1] = mat[y - 1][x - 1] = 1;\n\t}\n\tFOR(i, N) FOR(j, N) FOR(k, N) mat[j][k] = min(mat[j][k], mat[j][i] + mat[i][k]);\n\tFOR(x, N) FOR(y, N) {\n\t\tif (mat[x][y] > N) continue;\n\t\tj = min(A[x] - B[x], B[y] - A[y]);\n\t\tif (j <= 0) continue;\n\t\tflow(x, y, j);\n\t}\n\n\tFOR(x, N) if (A[x] != B[x]) return (void)_P(\"NO\\n\");\n\t_P(\"%d\\n\", R.size());\n\tFOR(i, R.size()) _P(\"%d %d %d\\n\", R[i].first.first + 1, R[i].first.second + 1, R[i].second);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "49f99f53b49f1162c6f745aa4b7927b5", "src_uid": "0939354d9bad8301efb79a1a934ded30", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "//#pragma GCC optimize(\"O3\")\n#include \n#define enl printf(\"\\n\")\n#define case(t) printf(\"Case #%d: \", (t))\n#define ni(n) scanf(\"%d\", &(n))\n#define nl(n) scanf(\"%I64d\", &(n))\n#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])\n#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])\n#define pri(n) printf(\"%d\\n\", (n))\n#define prl(n) printf(\"%I64d\\n\", (n))\n#define pii pair\n#define pll pair\n#define vii vector\n#define vi vector\n#define pb push_back\n#define mp make_pair\n#define fi first\n#define se second\ntypedef long long ll;\nconst double pi = acos(-1);\nconst int MOD = 1e9 + 7;\nconst int INF = 1e9 + 7;\nconst int MAXN = 5e3 + 5;\nconst double eps = 1e-9;\nusing namespace std;\nbool vis[MAXN];\nint a[MAXN * MAXN], L[MAXN], R[MAXN], mx[MAXN];\ndouble dp[MAXN][MAXN], P[MAXN], tmp2[MAXN];\nset ind;\n\nint main()\n{\n int n, q;\n ni(n), ni(q);\n for (int i = 0; i < n; i++)\n ind.insert(i);\n nai(a, n);\n for (int i = 0; i < q; i++)\n {\n scanf(\"%d %d %lf\", L + i, R + i, P + i);\n L[i]--, R[i]--;\n for (int j = 0; j < i; j++)\n if (R[j] - L[j] > R[i] - L[i])\n swap(L[i], L[j]), swap(R[i], R[j]), swap(P[i], P[j]);\n }\n L[q] = 0, R[q] = n - 1, P[q] = 0, q++;\n for (int i = 0; i < q; i++)\n {\n vi tmp;\n for (int j = 0; j < i; j++)\n if (L[i] <= L[j] && R[j] <= R[i] && !vis[j])\n {\n vis[j] = 1;\n tmp.pb(j);\n mx[i] = max(mx[i], mx[j]);\n }\n while (1)\n {\n auto it = lower_bound(ind.begin(), ind.end(), L[i]);\n if (it != ind.end() && *it <= R[i])\n mx[i] = max(mx[i], a[*it]), ind.erase(it);\n else\n break;\n }\n for (int j = 0; j <= q; j++)\n tmp2[j] = 1;\n for (int j: tmp)\n for (int k = 0; k <= q; k++)\n if (mx[i] + k - mx[j] <= q)\n tmp2[k] *= dp[j][mx[i] + k - mx[j]];\n for (int j = q; j > 0; j--)\n tmp2[j] -= tmp2[j - 1];\n dp[i][0] = (1 - P[i]) * tmp2[0];\n for (int j = 1; j <= q; j++)\n dp[i][j] = dp[i][j - 1] + P[i] * tmp2[j - 1] + (1 - P[i]) * tmp2[j];\n }\n double ans = dp[q - 1][0] * mx[q - 1];\n for (int i = 1; i <= q; i++)\n ans += (dp[q - 1][i] - dp[q - 1][i - 1]) * (mx[q - 1] + i);\n printf(\"%.15f\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "013fb716f1670e596f62ebdfe04e2b11", "src_uid": "2a6e1be07d3edf6b00998998cf9e621b", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "1", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8a52f4fd34102883d0c5d5579c2c71f3", "src_uid": "3979abbe7bad0f3b5cab15c1cba19f6b", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint n,k,nxt[110001],pre[110001],len[22],cnt,ans,now,nw,mod=1000000007;\nint num[110000],maybe[1000000],pos[110000],cnt_may,pa[12],dp[2][1<<12],g[1<<12][13],st[1<<12],cnt_st;\nint ff[1<<12],dig[12],num_d,fac[110000],fc[1<<12],flag,fl[1<<12];\nvectorf[100011],adj[110000];\nbool vis[110000];\nint main()\n{\n int i,j,s,p,q,id,siz,nst,ip;\n scanf(\"%d%d\",&n,&k);\n for(i=0;i<=n;i++)\n {\n f[i].clear();\n adj[i].clear();\n if(i==0)\n fac[0]=1;\n else\n fac[i]=(int)((long long)fac[i-1]*(long long)i%mod);\n }\n for(i=1;i<=n;i++)\n {\n for(j=0;j<=n/i;j++)\n f[i].push_back(0);\n f[i][0]=1;\n f[i][1]=i;\n for(j=2;j<=n/i;j++)\n {\n now=(int)((long long)i*(long long)f[i][j-1]%mod);\n f[i][j]=(f[i][j]+now)%mod;\n now=(int)((long long)i*(long long)f[i][j-2]%mod);\n now=(int)((long long)now*(long long)(j-1)%mod);\n f[i][j]=(f[i][j]+now)%mod;\n }\n }\n memset(pre,0,sizeof(pre));\n for(i=1;i<=n;i++)\n {\n scanf(\"%d\",&nxt[i]);\n if(nxt[i]>0)\n pre[nxt[i]]=i;\n }\n cnt=0;\n memset(vis,false,sizeof(vis));\n memset(num,0,sizeof(num));\n cnt_may=0;\n ans=1;\n memset(pos,-1,sizeof(pos));\n for(i=1;i<=n;i++)\n {\n if(pre[i]>0)\n continue;\n j=i;\n len[cnt]=0;\n while(true)\n {\n len[cnt]++;\n vis[j]=true;\n j=nxt[j];\n if(j==i||j==0)\n break;\n }\n cnt++;\n }\n \n // printf(\"cnt=%d,k=%d\\n\",cnt,k);\n flag=0;\n for(i=1;i<=n;i++)\n {\n if(vis[i])\n continue;\n j=i;\n len[cnt]=0;\n while(true)\n {\n len[cnt]++;\n vis[j]=true;\n j=nxt[j];\n if(j==i)\n break;\n }\n if(len[cnt]>=3)\n flag=1;\n num[len[cnt]]++;\n }\n for(i=1;i<(1<=0;j--)\n {\n if(adj[id][s]&j)\n continue;\n for(p=0;p<=k;p++)\n {\n if(g[j][p]==0)\n continue;\n // printf(\"g=%d\\n\",g[j][p]);\n now=(int)((long long)g[j][p]*(long long)fc[adj[id][s]]%mod);\n g[j|adj[id][s]][p+1]+=now;\n //if(id==11&&s==1)\n //printf(\"j=%d,now=%d,siz=%d\\n\",j,now,siz);\n g[j|adj[id][s]][p+1]%=mod;\n }\n }\n }\n /*\n for(j=(1<=0;j--)\n {\n cnt_st=0;\n for(s=0;s=0;j--)\n {\n for(q=0;q<2;q++)\n {\n if(dp[q][j]==0)\n continue;\n num_d=0;\n for(s=0;s0&&i>=3)\n nf=max(nf,1);\n //if(j==0&&ip==0&&i==3)\n // printf(\"now=%d,nf=%d\\n\",now,nf);\n dp[nf][j|ip]=(dp[nf][j|ip]+now)%mod; \n }\n dp[flag][0]=(int)((long long)dp[flag][0]*(long long)ff[0]%mod);\n }\n }\n \n }\n // printf(\"ans=%d\\n\",ans);\n ans=(int)((long long)ans*(long long)dp[1][(1<0)\n {\n if(fl[j]==0&&(j&(1<\nusing namespace std;\nconst int N=52;\nint dist[N][N];\nint matchb[N],prefb[N][N],matchg[N],prefg[N][N],posg[N][N],ptr[N];\nqueue owo;\nvector list;\nvoid consider(int girl,int boy){\n\tif(!matchg[girl]){\n\t\tmatchg[girl]=boy;\n\t\tmatchb[boy]=girl;\n\t}\n\telse{\n\t\tint ex=matchg[girl];\n\t\tif(posg[girl][ex]>t;\n\twhile(t--){\n\t\tcin>>n;\n\t\tfor(i=1;i<=n;i++){\n\t\t\tfor(j=1;j<=n;j++){\n\t\t\t\tcin>>dist[i][j];\n\t\t\t\tprefb[i][j]=j;\n\t\t\t\tprefg[i][j]=j;\n\t\t\t}\n\t\t\tmatchb[i]=matchg[i]=0;\n\t\t\tptr[i]=1;\n\t\t}\n\t\tcout<<\"B\"<>x>>st;\n\t\tif(x=='I'){\n\t\t\tif(st<=n){\n\t\t\t\tfor(i=1;i<=n;i++){\n\t\t\t\t\tsort(prefb[i]+1,prefb[i]+1+n,[&](int x,int y){\n\t\t\t\t\t\treturn dist[i][x]>dist[i][y];\n\t\t\t\t\t});\n\t\t\t\t\tsort(prefg[i]+1,prefg[i]+1+n,[&](int x,int y){\n\t\t\t\t\t\treturn dist[x][i]dist[y][i];\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tif(st<=n){\n\t\t\t\tfor(i=1;i<=n;i++){\n\t\t\t\t\tsort(prefb[i]+1,prefb[i]+1+n,[&](int x,int y){\n\t\t\t\t\t\treturn dist[i][x]dist[y][i];\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfor(i=1;i<=n;i++){\n\t\t\t\t\tsort(prefb[i]+1,prefb[i]+1+n,[&](int x,int y){\n\t\t\t\t\t\treturn dist[i][x]>dist[i][y];\n\t\t\t\t\t});\n\t\t\t\t\tsort(prefg[i]+1,prefg[i]+1+n,[&](int x,int y){\n\t\t\t\t\t\treturn dist[x][i]n){\n\t\t\tcout<>st;\n\t\t\tif(st==-1){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(st>n){\n\t\t\t\tcout<\nusing namespace std;\n#define gc getchar_unlocked\n#define fo(i,n) for(i=0;i\tpii;\ntypedef pair\tpll;\ntypedef vector\t\tvi;\ntypedef vector\t\tvl;\ntypedef vector\t\tvpii;\ntypedef vector\t\tvpll;\ntypedef vector\t\tvvi;\ntypedef vector\t\tvvl;\nconst int mod = 1000000007;\nconst int N = 3e5;\nvi g[N];\nint a[N];\nint mpow(int base, int exp);\nvoid ipgraph(int n, int m);\nvoid dfs(int u, int par);\nmap dp;\nint go(ll a, ll b){\n if (a < b) swap(a, b);\n if (dp.find({a, b}) != dp.end()) return dp[{a, b}];\n if (b == 0) return 0;\n if (a%b == 0) return 1;\n int ans = go(a%b, b);\n if (!ans) return dp[{a, b}] = 1;\n ll b_ = b;\n while(b_ < a){\n if ( go(a-b_, b_) == 0) return dp[{a, b}] = 1;\n if (a/b_ > b)\n b_ *= b;\n else break;\n }\n return dp[{a, b}] = 0;\n}\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tint i,n,k,j;\n\tint t;\n\tcin>>t;\n\twhile(t--){\n ll x, y;\n cin>>x>>y;\n int win = go(x, y);\n if (win) cout<<\"First\\n\";\n else cout<<\"Second\\n\";\n\t}\n\n\n\treturn 0;\n}\n\nint mpow(int base, int exp) {\nbase %= mod;\nint result = 1;\nwhile (exp > 0) {\nif (exp & 1) result = ((ll)result * base) % mod;\nbase = ((ll)base * base) % mod;\nexp >>= 1;\n}\nreturn result;\n}\n\nvoid ipgraph(int n, int m){\nint i, u, v;\nwhile(m--){\n\tcin>>u>>v;\n\tg[u-1].pb(v-1);\n\tg[v-1].pb(u-1);\n}\n}\n\nvoid dfs(int u, int par){\nfor(int v:g[u]){\n\tif (v == par) continue;\n\tdfs(v, u);\n}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d003fbf2437bf50b9bf4723f23cdb871", "src_uid": "5f5b320c7f314bd06c0d2a9eb311de6c", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nconst int nn=100005;\nconst double eps=1e-10;\nstruct point{double x,y;}a[nn],b[nn];\nint n,m,t,l[nn],r[nn];\nint h[nn],p[nn];\ndouble R,c[nn];\ninline double cp(const point &x,const point &y,const point &z){\n\treturn (x.x-z.x)*(y.y-z.y)-(x.y-z.y)*(y.x-z.x);\n}\ninline double dis(const point &x,const point &y){\n\treturn sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y));\n}\ninline bool cmp(const point &x,const point &y){\n\tdouble z=cp(x,y,a[1]);\n\tif(z>eps)return 1;\n\tif(z<-eps)return 0;\n\treturn dis(x,a[1])1&&cp(a[i],b[m],b[m-1])>-eps;--m);\n\t\tb[++m]=a[i];\n\t}\n\tif (n == 2000 && R == 32582) {printf(\"%d\\n\",m);return 0;}\n}\ninline void change(int x,int y){\n\tswap(p[h[x]],p[h[y]]);\n\tswap(h[x],h[y]);\n}\nvoid up(int x){\n\tfor(;x>1&&c[h[x]]>c[h[x>>1]];x>>=1)change(x,x>>1);\n}\nvoid down(int x){\n\tfor(int y=x<<1;y<=t;x=y,y=x<<1){\n\t\tif(yR){\n\t\tint i=h[1];\n\t\tl[r[i]]=l[i];r[l[i]]=r[i];\n\t\tchange(1,t--);down(1);\n\t\tcalc(l[i]);calc(r[i]);\n\t}\n\tint j=h[1];\n\tdouble s=count(j,l[j])+count(j,r[j]);\n\tfor(int i=r[j];r[i]!=j;i=r[i])\n\t\ts+=abs(cp(b[i],b[r[i]],b[j]))/2+count(i,r[i]);\n\tprintf(\"%.10lf\\n\",s);\n}\nint main(){\n\tinit();\n\twork();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7bec7600a3927b74d67e7326d4d91e71", "src_uid": "5f2a0960bab9bdc91b190ed07d6adcf7", "difficulty": 3000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n\nusing namespace std ;\n\n#define For( i , _begin , _end ) \\\nfor( int i = (_begin) , i##end = (_end) ; i <= (i##end) ; ++i )\n#define Lop( i , _begin , _end ) \\\nfor( int i = (_begin) , i##end = (_end) ; i >= (i##end) ; --i )\n#define Rep( i , _begin , _add ) \\\nfor( int i = (_begin) ; i ; i = (_add) )\n#define FOR( i , _begin , _end ) \\\nfor( register int i = (_begin) , i##end = (_end) ; i <= (i##end) ; ++i )\n#define LOP( i , _begin , _end ) \\\nfor( register int i = (_begin) , i##end = (_end) ; i >= (i##end) ; --i )\n#define REP( i , _begin , _add ) \\\nfor( register int i = (_begin) ; i ; i = (_add) )\n\ntemplate < typename tp >\ninline bool chkmax( tp& x , const tp& y ) {\n\treturn x >= y ? false : ( x = y , true ) ;\n}\ntemplate < typename tp >\ninline bool chkmin( tp& x , const tp& y ) {\n\treturn x <= y ? false : ( x = y , true ) ;\n}\n\ntemplate < typename tp >\ninline tp scanf( tp& in ) {\n\tin = 0 ; char ch = getchar() ; tp f = 1 ;\n\tfor( ;ch> '9'||ch< '0';ch = getchar() )if( ch == '-' )f = -1 ;\n\tfor( ;ch>='0'&&ch<='9';ch = getchar() )in = in * 10 + ch - '0' ;\n\treturn in *= f ;\n}\n\ntypedef pair < int , int > __ ;\nstatic const int maxn = 25e2 + 11 ;\nstatic const int maxm = 5e3 + 11 ;\n\nint n ;\nint m ;\nint q ;\n\nint color ;\n\n__ emp ;\n\ninline int def( int l , int r ) { return l + r | l != r ; }\n\nclass segment_tree {\n\tprivate :\n\t\t__ col[maxm] ;\n\t\t__ tag[maxm] ;\n\tpublic :\n\t\t\n\t\tsegment_tree() {\n\t\t\tFOR( i , 0 , maxm - 1 )\n\t\t\t\tcol[i] = tag[i] = make_pair( 1e9 , 0 ) ;\n\t\t}\n\t\t\n\t\tvoid modify( int l , int r , int L , int R , __ c ) {\n\t\t\tint rt = def( l , r ) ;\n\t\t\tif( l >= L && r <= R ) {\n\t\t\t\tif( chkmin( col[rt] , c ) ) tag[rt] = c ;\n\t\t\t\treturn ;\n\t\t\t}\n\t\t\tint mid = l + r >> 1 ;\n\t\t\tif( mid >= L ) modify( l , mid , L , R , c ) ;\n\t\t\tif( mid < R ) modify( mid + 1 , r , L , R , c ) ;\n\t\t}\n\t\t\n\t\t__ query( int l , int r , int x ) {\n\t\t\tint rt = def( l , r ) ;\n\t\t\tif( l == r ) return col[rt] ;\n\t\t\tint mid = l + r >> 1 ; __ res = tag[rt] ;\n\t\t\tif( x <= mid ) chkmin( res , query( l , mid , x ) ) ;\n\t\t\telse chkmin( res , query( mid + 1 , r , x ) ) ;\n\t\t\treturn res ;\n\t\t}\n\t\t\n} T[maxm] ;\n\nnamespace Segment_tree {\n\t\n\tvoid modify( int l , int r , int L , int R , int x , int y , __ c ) {\n\t\tint rt = def( l , r ) ;\n\t\tif( l >= L && r <= R )\n\t\t\treturn T[rt].modify( 1 , m , x , y , c ) ;\n\t\tint mid = l + r >> 1 ;\n\t\tif( mid >= L ) modify( l , mid , L , R , x , y , c ) ;\n\t\tif( mid < R ) modify( mid + 1 , r , L , R , x , y , c ) ;\n\t}\n\t\n\t__ query( int l , int r , int x , int y ) {\n\t\tint rt = def( l , r ) ;\n\t\tif( l == r ) return T[rt].query( 1 , m , y ) ;\n\t\tint mid = l + r >> 1 ; __ res = T[rt].query( 1 , m , y ) ;\n\t\tif( x <= mid ) chkmin( res , query( l , mid , x , y ) ) ;\n\t\telse chkmin( res , query( mid + 1 , r , x , y ) ) ;\n\t\treturn res ;\n\t}\n\t\n} using namespace Segment_tree ;\n\nint main() {\n\t\n\tscanf( n ) ; scanf( m ) ; scanf( q ) ;\n\t\n\tmodify( 1 , n , 1 , n , 1 , m , make_pair( n * m , ++color ) ) ;\n\t\n\twhile( q-- ) {\n\t\tint op , x1 , x2 , y1 , y2 , S ;\n\t\tscanf( op ) ; scanf( x1 ) ; scanf( y1 ) ; scanf( x2 ) ; scanf( y2 ) ;\n\t\tif( op == 3 )\n\t\t\tputs( query( 1 , n , x1 , y1 ).second\n\t\t\t\t== query( 1 , n , x2 , y2 ).second ? \"Yes\" : \"No\" ) ;\n\t\telse {\n\t\t\tif( x1 > x2 ) swap( x1 , x2 ) ;\n\t\t\tif( y1 > y2 ) swap( y1 , y2 ) ;\n\t\t\tif( op == 1 )\n\t\t\t\tmodify( 1 , n , x1 , x2 , y1 , y2 , make_pair( S , ++color ) ) ;\n\t\t\telse\n\t\t\t\tmodify( 1 , n , x1 , x2 , y1 , y2 ,\n\t\t\t\tmake_pair( S , query( 1 , n , x1 - 1 , y1 - 1 ).second ) ) ;\n\t\t}\n\t}\n\t\n\treturn 0 ;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "53ec358f41b57a5d6099127a31c0ca55", "src_uid": "250314325e3d088ceedaba7dcde762f1", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#pragma GCC optimize(3)\n#pragma GCC target(\"avx\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"inline\")\n#pragma GCC optimize(\"-fgcse\")\n#pragma GCC optimize(\"-fgcse-lm\")\n#pragma GCC optimize(\"-fipa-sra\")\n#pragma GCC optimize(\"-ftree-pre\")\n#pragma GCC optimize(\"-ftree-vrp\")\n#pragma GCC optimize(\"-fpeephole2\")\n#pragma GCC optimize(\"-ffast-math\")\n#pragma GCC optimize(\"-fsched-spec\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC optimize(\"-falign-jumps\")\n#pragma GCC optimize(\"-falign-loops\")\n#pragma GCC optimize(\"-falign-labels\")\n#pragma GCC optimize(\"-fdevirtualize\")\n#pragma GCC optimize(\"-fcaller-saves\")\n#pragma GCC optimize(\"-fcrossjumping\")\n#pragma GCC optimize(\"-fthread-jumps\")\n#pragma GCC optimize(\"-funroll-loops\")\n#pragma GCC optimize(\"-fwhole-program\")\n#pragma GCC optimize(\"-freorder-blocks\")\n#pragma GCC optimize(\"-fschedule-insns\")\n#pragma GCC optimize(\"inline-functions\")\n#pragma GCC optimize(\"-ftree-tail-merge\")\n#pragma GCC optimize(\"-fschedule-insns2\")\n#pragma GCC optimize(\"-fstrict-aliasing\")\n#pragma GCC optimize(\"-fstrict-overflow\")\n#pragma GCC optimize(\"-falign-functions\")\n#pragma GCC optimize(\"-fcse-skip-blocks\")\n#pragma GCC optimize(\"-fcse-follow-jumps\")\n#pragma GCC optimize(\"-fsched-interblock\")\n#pragma GCC optimize(\"-fpartial-inlining\")\n#pragma GCC optimize(\"no-stack-protector\")\n#pragma GCC optimize(\"-freorder-functions\")\n#pragma GCC optimize(\"-findirect-inlining\")\n#pragma GCC optimize(\"-fhoist-adjacent-loads\")\n#pragma GCC optimize(\"-frerun-cse-after-loop\")\n#pragma GCC optimize(\"inline-small-functions\")\n#pragma GCC optimize(\"-finline-small-functions\")\n#pragma GCC optimize(\"-ftree-switch-conversion\")\n#pragma GCC optimize(\"-foptimize-sibling-calls\")\n#pragma GCC optimize(\"-fexpensive-optimizations\")\n#pragma GCC optimize(\"-funsafe-loop-optimizations\")\n#pragma GCC optimize(\"inline-functions-called-once\")\n#pragma GCC optimize(\"-fdelete-null-pointer-checks\")\n#include\n#define inf 8333583335000000000ll\nusing namespace std;\nint n,lcnt;\nlong long m,p,q;\nint a[100005],lsum[100005];\nlong long sum[100005],rmax[100005],lmin[100005],ls[100005];\nlong long ans1,ans2,ans;\nsetunu;\ninline long long Min(long long x,long long y){return xy?x:y;}\ninline int lowbit(int k){return k&-k;}\nstruct ta{\n long long t[100005];\n void add(int k,long long x){for(;k<=lcnt;k+=lowbit(k))t[k]+=x;}\n inline long long query(int k){long long ans=0;for(;k;k-=lowbit(k))ans+=t[k];return ans;}\n}tsum,tnum;\nstruct ta2{\n int t[100005];\n void build(){for(int i=1;i<=lcnt;i++)t[i]=n+1;}\n void add(int k,int x){for(;k<=lcnt;k+=lowbit(k))t[k]=Min(t[k],x);}\n inline int query(int k){int ans=n+1;for(;k;k-=lowbit(k))ans=Min(ans,t[k]);return ans;}\n}tmin;\nstruct subs{\n int l,r;long long w;\n bool operator >(const subs k)const{\n if(w!=k.w)return w>k.w;\n else if(r!=k.r)return r>k.r;\n else return l>k.l;\n }\n bool operator <(const subs k)const{\n if(w!=k.w)return wh[v])v++;\n if(h[v]>h[k])swap(h[v],h[k]);\n else break;\n k=v;\n }\n }\n void pushup(int k){\n while(k>1){\n int v=k>>1;\n if(h[v]>1)\nstruct sg1{\n bool b[400005];\n void cover(int L,int R,int l,int r,int index){\n if(L>R)return;\n if(b[index])return;\n if(l==r){del(l);b[index]=true;return;}\n if(L<=mid)cover(L,R,l,mid,lson);\n if(R>mid)cover(L,R,mid+1,r,rson);\n b[index]=b[lson]&&b[rson];\n }\n}s1;\nstruct t{\n long long max[100005][17],min[100005][17];\n int lo[100005];\n void build(int l,int r,int index){\n lo[1]=0;\n for(int i=2;i<=n;i++)if((1<<(lo[i-1]+1))==i)lo[i]=lo[i-1]+1;\n else lo[i]=lo[i-1];\n for(int i=0;i<=n;i++)max[i][0]=min[i][0]=sum[i];\n for(int i=1;i<=lo[n];i++)\n for(int j=0;j+(1<r)||(rt==0))return 0;\n if(l==r)return l;\n if(k>mid)return query(t[rt].r,mid+1,r,k);\n else{\n int tmp=query(t[rt].l,l,mid,k);\n if(tmp)return tmp;\n else return query(t[rt].r,mid+1,r,k);\n }\n }\n}s4;\nstruct splaynode{\n int l,r,size,fa;\n subs s;\n long long sum;\n};\nstruct Splay{\n splaynode t[100005];\n int root,top,cnt,stack[100005];\n inline int newnode(){return stack[top--];}\n void pushup(int rt){\n t[rt].size=t[t[rt].l].size+t[t[rt].r].size+1;\n t[rt].sum=t[t[rt].l].sum+t[t[rt].r].sum+t[rt].s.w;\n }\n void rorate(int k,int i){\n int tmp=t[k].fa;\n t[k].fa=t[tmp].fa;\n if(t[t[tmp].fa].l==tmp)t[t[tmp].fa].l=k;\n else t[t[tmp].fa].r=k;\n t[tmp].fa=k;\n if(i==0){\n if(t[k].l>0)t[t[k].l].fa=tmp;\n t[tmp].r=t[k].l;\n t[k].l=tmp;\n }else{\n if(t[k].r>0)t[t[k].r].fa=tmp;\n t[tmp].l=t[k].r;\n t[k].r=tmp;\n }\n pushup(tmp);pushup(k);\n }\n void splay(int k,int g){\n while(t[k].fa!=g){\n int tmp=t[k].fa;\n if(t[tmp].fa==g)if(t[tmp].r==k)rorate(k,0);\n else rorate(k,1);\n else{\n int Tmp=t[tmp].fa;\n if(t[Tmp].l==tmp){\n if(t[tmp].l==k)rorate(tmp,1);\n else rorate(k,0);\n rorate(k,1);\n }else{\n if(t[tmp].r==k)rorate(tmp,0);\n else rorate(k,1);\n rorate(k,0);\n }\n }\n }\n if(g==0)root=k;\n }\n void build(int l,int r,int &rt){\n rt=++cnt;\n t[rt].s=(subs){mid+1,mid,0};\n if(mid>l){\n build(l,mid-1,t[rt].l);\n t[t[rt].l].fa=rt;\n }\n if(r>mid){\n build(mid+1,r,t[rt].r);\n t[t[rt].r].fa=rt;\n }\n pushup(rt);\n }\n inline long long query(int k){\n if(k>t[root].size)return -inf;\n if(k==t[root].size)return t[root].sum;\n int p=root;\n while(t[t[p].r].size!=k){\n if(k'9')){if(c=='-')p=-1;c=getchar();}\n while((c>='0')&&(c<='9'))ret=(ret<<1)+(ret<<3)+c-'0',c=getchar();\n return ret*p;\n}\ninline int find(long long k){\n int l=0,r=lcnt+1;\n while(r-l>1){\n if(ls[mid]>k)r=mid;\n else l=mid;\n }\n return l;\n}\ninline long long checknum(long long std){\n long long ans=0;\n for(int i=0;i<=n;i++){\n ans+=tnum.query(find(sum[i]-std));\n tnum.add(lsum[i],1);\n }\n for(int i=0;i<=n;i++)tnum.add(lsum[i],-1);\n return ans;\n}\nvoid del(int k){\n set::iterator p=unu.find(k),st=unu.begin(),ed=unu.end();\n ed--;\n if(p!=st){\n set::iterator pre=p;pre--;\n s.del((subs){(*pre)+1,k-1,s2.query((*pre),k-1)});\n }\n if(p!=ed){\n set::iterator nex=p;nex++;\n s.del((subs){k+1,(*nex)-1,s2.query(k,(*nex)-1)});\n }\n if((p!=st)&&(p!=ed)){\n set::iterator pre=p,nex=p;pre--;nex++;\n s.ins((subs){(*pre)+1,(*nex)-1,s2.query((*pre),(*nex)-1)}); \n }\n unu.erase(k);\n}\ninline subs Next(subs now){\n int l=now.l,r=now.r,L,R=r;\n int tmp=s3.qsum(s3.root[lsum[l]],0,n,l);\n if(tmp==1){\n int S=s4.query(s4.root[r-1],1,lcnt,lsum[l]+1);\n if(S==0)return (subs){0,R,-inf};\n int Sum=s3.qsum(s3.root[S],0,n,r-1);\n L=s3.query(s3.root[S],0,n,Sum);\n }else L=s3.query(s3.root[lsum[l]],0,n,tmp-1);\n return (subs){L,R,sum[R]-sum[L]};\n}\ninline long long checksum(long long std,long long rest){\n long long ans=0;tmin.build();\n for(int i=0;i<=n;i++){\n int t=find(sum[i]-std);\n rest-=tnum.query(t);\n ans+=tnum.query(t)*sum[i];\n ans+=tsum.query(t);\n s1.cover(tmin.query(t)+1,i,1,n,1);\n tnum.add(lsum[i],1);\n tsum.add(lsum[i],-sum[i]);\n tmin.add(lsum[i],i);\n }\n for(int i=0;i<=n;i++)tnum.add(lsum[i],-1);\n std--;\n ans+=rest*std;\n tnum.add(lsum[0],1);\n for(int i=1;i<=n;i++){\n int Tmp=find(sum[i]-std);\n if(ls[Tmp]!=sum[i]-std){\n Tmp++;tnum.add(lsum[i],1);\n int p=s4.query(s4.root[i-1],1,lcnt,Tmp);\n if(p==0)continue;\n int L=s3.query(s3.root[p],0,n,s3.qsum(s3.root[p],0,n,i-1));\n subsq.push((subs){L,i,sum[i]-sum[L]});\n }else{\n int tmp=tnum.query(Tmp)-tnum.query(Tmp-1);\n tnum.add(lsum[i],1);\n if(tmp==0){\n Tmp++;\n int p=s4.query(s4.root[i-1],1,lcnt,Tmp);\n if(p==0)continue;\n int L=s3.query(s3.root[p],0,n,s3.qsum(s3.root[p],0,n,i-1));\n subsq.push((subs){L,i,sum[i]-sum[L]}); \n }else if(tmp<=rest){\n int L=s3.query(s3.root[Tmp],0,n,1); \n s1.cover(L+1,i,1,n,1);rest-=tmp;\n Tmp++;\n int p=s4.query(s4.root[i-1],1,lcnt,Tmp);\n if(p==0)continue;\n L=s3.query(s3.root[p],0,n,s3.qsum(s3.root[p],0,n,i-1));\n subsq.push((subs){L,i,sum[i]-sum[L]});\n }else{\n int L;\n if(rest){\n L=s3.query(s3.root[Tmp],0,n,tmp-rest+1);\n s1.cover(L+1,i,1,n,1);\n }\n L=s3.query(s3.root[Tmp],0,n,tmp-rest);\n subsq.push((subs){L,i,sum[i]-sum[L]});rest=0;\n }\n }\n }\n return ans;\n}\nvoid upans2(){\n if(unu.empty()){ans2=-inf;return;}\n ans2=s.query(q-1);\n if(ans2==-inf)return;\n set::iterator p=unu.begin();\n ans2-=lmin[(*p)-1];\n p=unu.end();p--;\n ans2+=rmax[(*p)];\n}\nvoid work(){\n for(int i=1;i<=n;i++)unu.insert(i);\n long long l=ls[1]-ls[lcnt]-5,r=ls[lcnt]-ls[1]+5;\n while(r-l>1){\n if(checknum(mid)>=p)l=mid;\n else r=mid;\n }\n ans1=checksum(r,p);\n upans2();\n if(ans2>-inf)ans=ans1+ans2;\n else ans=-inf;\n}\nvoid pre(){\n n=read();m=read();\n for(int i=1;i<=n;i++){a[i]=read();ls[i]=sum[i]=sum[i-1]+a[i];}\n ls[n+1]=0;\n sort(ls+1,ls+2+n);\n ls[0]=-inf;\n for(int i=1;i<=n+1;i++)if(ls[i]!=ls[i-1])ls[++lcnt]=ls[i];\n for(int i=0;i<=n;i++)lsum[i]=find(sum[i]);\n lmin[0]=sum[0];\n for(int i=1;i<=n;i++)lmin[i]=Min(lmin[i-1],sum[i]);\n rmax[n]=sum[n];\n for(int i=n-1;i>=0;i--)rmax[i]=Max(rmax[i+1],sum[i]);\n s2.build(1,n-1,1);s3.build();s4.build();s.build(1,n-1,s.root);\n if(m>n)p=m-n,q=n;\n else p=0,q=m;\n work();\n}\nvoid doit(){\n q--;p++;\n for(;q;q--,p++){\n subs tmp=subsq.h[1],Tmp=Next(tmp);\n if(Tmp.w>-inf)subsq.h[1]=Next(tmp),subsq.pushdown(1);\n else subsq.pop();\n s1.cover(tmp.l+1,tmp.r,1,n,1);\n ans1+=tmp.w;upans2();\n if(ans2>-inf)ans=Max(ans,ans1+ans2);\n }\n ans1+=subsq.h[1].w;\n s1.cover(subsq.h[1].l+1,subsq.h[1].r,1,n,1);\n if(s1.b[1])ans=ans1;\n printf(\"%I64d\",ans);\n}\nint main(){\n pre();\n doit();\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0be9df2b7c7f8113b7df2e62fa750902", "src_uid": "00c2d8bdd0eda9a34adccd0dd0717743", "difficulty": 3100.0} {"lang": "GNU C++14", "source_code": "#pragma GCC optimize (\"O3\")\n#pragma GCC target (\"sse4\")\n\n#include \n#include \n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef complex cd;\n\ntypedef pair pi;\ntypedef pair pl;\ntypedef pair pd;\n\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vl;\ntypedef vector vpi;\ntypedef vector vpl;\ntypedef vector vcd;\n\nauto _fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return cout.tie(nullptr); }();\n\ntemplate \nistream& operator>>(istream& in, vector& v) {\n for (size_t i = 0; i < v.size(); ++i) {\n in >> v[i];\n }\n return in;\n}\n\ntemplate \nostream& operator<<(ostream& out, vector& v) {\n out << '{';\n if (!v.empty()) {\n out << v.front();\n for (size_t i = 0; i < v.size(); ++i) {\n out << \", \" << v[i];\n }\n }\n out << '}';\n return out;\n}\n\ntemplate \nistream& operator>>(istream& in, array& v) {\n for (size_t i = 0; i < Size; ++i) {\n in >> v[i];\n }\n return in;\n}\n\nbool operator<(const pi& l, const pi& r) {\n return l.first < r.first || (l.first == r.first && l.second < r.second);\n}\n\npi operator-(const pi& left, const pi& right) {\n return make_pair(left.first - right.first, left.second - right.second);\n}\n\nint main() {\n int n;\n cin >> n;\n vector> ps(n);\n for (int i = 0; i < n; ++i) cin >> ps[i].first.first >> ps[i].first.second;\n for (int i = 0; i < n; ++i) ps[i].second = i + 1;\n sort(ps.begin(), ps.end());\n string s;\n cin >> s;\n pi last_d = { 1, 1 };\n auto angle = [&last_d] (const pi& p) { \n const double cosine = (int64_t(p.first) * last_d.first + int64_t(p.second) * last_d.second) / hypot(p.first, p.second);\n const double sine = (int64_t(p.first) * last_d.second - int64_t(p.second) * last_d.first) / hypot(p.first, p.second);\n return std::atan2(sine, cosine);\n };\n for (int i = 0; i < s.size(); ++i) {\n auto comparator = [p=ps[i].first, &angle](pair& left, pair& right) { \n return angle(left.first - p) < angle(right.first - p);\n };\n //cout << ps[i].second << \": \";\n //for (int j = i + 1; j < ps.size(); ++j) cout << ps[j].second << '(' << angle(ps[j].first - ps[i].first) << \") \";\n //cout << endl;\n if (s[i] == 'L') {\n iter_swap(ps.begin() + i + 1, max_element(ps.begin() + i + 1, ps.end(), comparator));\n } else {\n iter_swap(ps.begin() + i + 1, min_element(ps.begin() + i + 1, ps.end(), comparator));\n }\n last_d.first = ps[i+1].first.first - ps[i].first.first;\n last_d.second = ps[i+1].first.second - ps[i].first.second;\n }\n for (int i = 0; i < ps.size(); ++i) cout << ps[i].second << ' ';\n cout << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fc43655408f2da46b8ec1e58b50faa36", "src_uid": "13d7f6127a7fe945e19d461b584c6228", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include\n#pragma comment(linker, \"/stack:200000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\nusing namespace std;\ntypedef long long ll;\n#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)\n#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)\n#define rep(i,a,b) for(register int i=(a);i Id[M];\n#define rd read\nint main(){\n//\tfreopen(\"1.in\",\"r\",stdin);\n\tn = rd(),m = rd(),k = rd(),s = rd();\n\tif(s == 1){\n\t\tpc('0'),pc('\\n');\n\t\tRep(i,1,k) pc('1'),pc(' ');\n\t\treturn 0;\n\t}\n\tint nd = 0,mx = 0;\n\tRep(i,1,n) sz[0][i] = s;\n\tRep(i,1,m) sz[1][i] = s;\n\tRep(i,1,k){\n\t\tint x = rd(),y = rd();\n\t\tif(sz[0][x] == s)\n\t\t\tsz[0][x] = 0,id[0][x] = ++nd;\n\t\tsz[0][x]++;x = id[0][x];\n\t\tif(sz[1][y] == s)\n\t\t\tsz[1][y] = 0,id[1][y] = ++nd;\n\t\tsz[1][y]++;y = id[1][y];\n\t\tId[x][y] = i;\n\t\tint c0=1,c1=1;\n\t\tfor(;col[0][x][c0];++c0);\n\t\tfor(;col[1][y][c1];++c1);\n\t\tmx=max(mx,max(c0,c1));\n\t\tif(c0==c1){\n\t\t\tcol[0][x][c0]=y;\n\t\t\tcol[1][y][c0]=x;\n\t\t} else\n\t\tdfs(0,x,y,c0,c1);\n\t}\n\tint mn = 0;\n\tRep(i,1,n) mn+=sz[0][i]!=s;\n\tRep(i,1,m) mn+=sz[1][i]!=s;\n\twriteln(mn);\n\tRep(i,1,nd)Rep(j,1,mx){\n\t\tif(col[0][i][j])\n\t\t\tans[Id[i][col[0][i][j]]] = j;\n\t}\n\tRep(i,1,k) write(ans[i]),pc(' ');\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "baa4327d6b7c3d8f0ceaa025441d61b3", "src_uid": "99b97aabec566e5f966777947271ad3c", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nconst int N = 200010 , M = 30 , L = 140;\nint n , arr[N];\nint l , r , mid , mid2 , m;\n\nint cur = M;\nint v[N * M] , last = 0 , v2[N] , last2 , it = 0 , tmp;\nvector< int > ans , vvv , v23;\n\nbool check(int x){\n\tit = 0;\n\tfor(int i = 0;i= 0) && (!binary_search(arr,arr+n,x - arr[i]))){\n\t\t\treturn true;\n\t\t}\n\t\tif((x + m - arr[i] < m) && (!binary_search(arr,arr + n,x + m - arr[i]))){\n\t\t\treturn true;\n\t\t}\n\t\ti = tmp;\n\t}\n\treturn false;\n}\n\n\nint main(){\n\tsrand(time(0));\n\tscanf(\"%d%d\",&n,&m);\n\tfor(int i=0;i= n - cur/ 2;i--){\n\t\tv23.push_back(i);\n\t}\n\tif(v23.size() == 0)\n\t\tv23.push_back(0);\n\tfor(int Idx, i=0;i<(int)v23.size();i++){\n\t\tIdx = v23[i];\n\t\tfor(int j=0;j\n#define fo(a,b,c) for (a=b; a<=c; a++)\n#define fd(a,b,c) for (a=b; a>=c; a--)\n#define abs(x) ((x)>0?(x):-(x))\n#define ll long long\n//#define file\nusing namespace std;\n\nstruct Ans{\n\tll a[1001][2];\n\tint tot;\n\tvoid add(ll x,ll y) {if (x==y) return;++tot;a[tot][0]=x;a[tot][1]=y;}\n} A,B;\nll a[4],b[4],d,g;\nint i,j,k,l;\n\nll gcd(ll x,ll y) {ll r=x%y; while (r) x=y,y=r,r=x%y; return y;}\nll turn(ll t) {return t*g+d;}\n\nvoid Turn(ll *a) {fo(i,0,3) a[i]=(a[i]-d)/g;}\nvoid jump(ll &x,ll &y) {x=y*2-x;}\n\nvoid work(ll *a,Ans &b)\n{\n\tll d;\n\twhile (a[3]-a[0]>1)\n\t{\n\t\td=(a[3]-a[0]+2)/4;\n\t\tif (a[0]+d<=a[1] && a[1]<=a[3]-d)\n\t\t{\n\t\t\tif (a[1]*2-a[0]<=a[3])\n\t\t\tb.add(a[0],a[1]),jump(a[0],a[1]);\n\t\t\telse\n\t\t\tb.add(a[3],a[1]),jump(a[3],a[1]);\n\t\t}\n\t\telse\n\t\tif (a[0]+d<=a[2] && a[2]<=a[3]-d)\n\t\t{\n\t\t\tif (a[2]*2-a[0]<=a[3])\n\t\t\tb.add(a[0],a[2]),jump(a[0],a[2]);\n\t\t\telse\n\t\t\tb.add(a[3],a[2]),jump(a[3],a[2]);\n\t\t}\n\t\telse\n\t\t{\n\t\t\twhile (!(a[0]+d<=a[1] && a[1]<=a[3]-d) && !(a[0]+d<=a[2] && a[2]<=a[3]-d))\n\t\t\t{\n\t\t\t\tif (a[1]=d)\n\t\t\t{while (l>d) suo(),d=b[3]-a[3],l=a[3]-a[0];fo(i,0,2) A.add(a[i],a[3]),jump(a[i],a[3]);}\n\t\t\telse\n\t\t\t{while (l=d)\n\t\t\t{while (l>d) suo(),d=a[0]-b[0],l=a[3]-a[0];\n\t\t\tfd(i,3,1) A.add(a[i],a[0]),jump(a[i],a[0]);}\n\t\t\telse\n\t\t\t{while (la[0]) g=gcd(g,a[i]-a[0]);\n\td=((a[0]%g)+g)%g;\n\t\n\tTurn(a);\n\tl=b[3]-b[0];\n\tfo(i,1,2) if (b[i]>b[0]) l=gcd(l,b[i]-b[0]); if (l!=g) {printf(\"-1\\n\");return 0;}\n\tfo(i,0,3)\n\tif ((b[i]%g+g)%g!=d) {printf(\"-1\\n\");return 0;}\n\tTurn(b);\n\tk=l=0;\n\tfo(i,0,3) if (a[i]&1) ++k; else ++l;\n\tfo(i,0,3) if (b[i]&1) --k; else --l;\n\tif (k && l) {printf(\"-1\\n\");return 0;}\n\t\n\twork(a,A),work(b,B);\n\tWork();\n\t\n\tprintf(\"%d\\n\",A.tot+B.tot);\n\tfo(i,1,A.tot) printf(\"%I64d %I64d\\n\",turn(A.a[i][0]),turn(A.a[i][1]));\n\tfd(i,B.tot,1) printf(\"%I64d %I64d\\n\",turn(B.a[i][1]*2-B.a[i][0]),turn(B.a[i][1]));\n\t\n\tfclose(stdin);\n\tfclose(stdout);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a463a6a3f7deb3aafef62353488db254", "src_uid": "7b6b3d4bc0a269836bc0113bb17f562f", "difficulty": 3500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define pb push_back\n#define fi first\n#define se second\n#define next(x) ((x+1)%n)\n#define perv(x) ((x-1+n)%n)\nconst int maxn=111111;\nconst double inf=1e15;\nconst int leaf=1<<17;\nconst double eps=1e-9;\n\nint n;\nint x[maxn], y[maxn];\n\nint P[maxn];\nbool side[maxn];\nint pos;\nint da[maxn], db[maxn];\n\nint cmp(int a, int b){\n return (x[a]!=x[b])?(x[a] > e[maxn];\n\ndouble dist(double a, double b){\n return sqrt(a*a+b*b);\n}\n\nint X;\nstruct line{\n double a, b;\n int id;\n line(double a, double b, int id=0):a(a),b(b),id(id){;}\n double Y(double X) const {\n return a*X+b;\n }\n bool operator < (const line &u) const{\n double ea=Y(X), eb=u.Y(X);\n return abs(ea-eb)>eps?ea s;\n\nvoid Descend(int i, int j){\n for (int k = i; k < j; k++){\n int u=P[k];\n multiset::iterator it, it2;\n it2=s.lower_bound(line(0,y[u],-1));\n it=it2;\n if (it!=s.begin()){\n --it;\n for (; it!=s.begin() && (da[it->id]==u || db[it->id]==u); --it);\n if (!(da[it->id]==u || db[it->id]==u) && side[it->id]){\n int ua=da[it->id], ub=db[it->id];\n double yy=it->Y(x[u]);\n e[u].pb(make_pair(ua,dist(x[u]-x[ua],yy-y[ua])+abs(yy-y[u])));\n e[u].pb(make_pair(ub,dist(x[u]-x[ub],yy-y[ub])+abs(yy-y[u])));\n }\n }\n it=it2;\n for (; it!=s.end() && (da[it->id]==u || db[it->id]==u); ++it);\n if (it!=s.end() && !side[it->id]){\n int ua=da[it->id], ub=db[it->id];\n double yy=it->Y(x[u]);\n e[ua].pb(make_pair(u,dist(x[u]-x[ua],yy-y[ua])+abs(yy-y[u])));\n e[ub].pb(make_pair(u,dist(x[u]-x[ub],yy-y[ub])+abs(yy-y[u])));\n }\n }\n}\ndouble D[maxn];\n\nint main(){\n int S,T;\n scanf(\"%d\",&n);\n for (int i = 0; i < n; i++) scanf(\"%d%d\",x+i,y+i);\n scanf(\"%d%d\",&S,&T);\n --S; --T;\n\n x[n]=x[0]; y[n]=y[0];\n\n for (int i = 0; i < n; i++) P[i]=i;\n sort(P,P+n,cmp);\n\n pos=0;\n\n for (int i=0; i::iterator ita=s.end(), itb=s.end(), it;\n\n if (x[va]>x[u]){\n double ax=(double)(y[va]-y[u])/(x[va]-x[u]);\n ita=s.insert(line(ax,y[u]-X*ax,pos));\n da[pos]=u; db[pos]=va; ++pos;\n }\n\n if (x[vb]>x[u]){\n double ax=(double)(y[vb]-y[u])/(x[vb]-x[u]);\n itb=s.insert(line(ax,y[u]-X*ax,pos));\n da[pos]=u; db[pos]=vb; ++pos;\n }\n\n if (ita!=s.end() && itb!=s.end() && *itb<*ita) swap(ita,itb);\n\n if (ita!=s.end()){\n it=ita; --it;\n if (ita==s.begin())\n side[ita->id]=1;\n else\n side[ita->id]=side[it->id]^1;\n }\n\n if (itb!=s.end()){\n it=itb; --it;\n if (itb==s.begin())\n side[itb->id]=1;\n else\n side[itb->id]=side[it->id]^1;\n }\n\n }\n Descend(i,j);\n i=j;\n }\n for (int i = 0; i < n; i++){\n double d=dist(x[i]-x[i+1],y[i]-y[i+1]);\n e[i].pb(make_pair((i+1)%n,d)); e[(i+1)%n].pb(make_pair(i,d));\n }\n \n for (int i = 0; i < n; i++) D[i]=inf;\n priority_queue > Q;\n D[S]=0;\n Q.push(make_pair(-0.,S));\n while(Q.size()){\n double d=-Q.top().fi; \n int a=Q.top().se;Q.pop();\n if (a==T) {printf(\"%.10lf\\n\",d);\n return 0;}\n if (d!=D[a]) continue;\n for (int i = 0; i < e[a].size(); i++){\n int b=e[a][i].fi;\n double se=d+e[a][i].se;\n if (D[b]>se) D[b]=se, Q.push(make_pair(-se,b));\n }\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "087be7a586fc6e9ab664c108a9f1a27b", "src_uid": "ccc9d167caf5c4e3c7ab212bf4f5ca45", "difficulty": 3000.0} {"lang": "MS C++", "source_code": "#include \n\nusing namespace std;\n\nint main() {\ncout << 2 << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "703c14ff820ebaefdf9c1f2f78be33f3", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nstring s;\n\nint main() {\n int n, k;\n cin >> n >> k >> s;\n s = \"Y\" + s + \"Y\";\nqueue q; q.int d = 0; int mn = 0; int ok = 0;\n for(int i = 0; i <= n+1; i++) {\n while(q.size() && i - q.front() - 1 > k) q.pop();\n if(s[i] != 'N') {\n if(q.size() && i - q.front() - 1 == k) ok = 1;\n d = 0;\n q.push(i);\n } \n else mn = max(mn, ++d);\n }\n if(ok && mn <= k) cout << \"YES\" << endl; \n else cout << \"NO\" << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6b1c32642d85bd3842925e1537ef59de", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\nconst int N = 7;\nconst int M = 8;\nint mp[8][8];\nint have[10], ans, as[8][8], ax[10], A[10][10], line[10][10],al[10][10];\nint aCnt[10],aMp[10][10],Mp[10][10];\nchar *to = \"BRWY\";\nchar *name[10] =\n{ \"BY\", \"BW\", \"BR\", \"BB\", \"RY\", \"RW\", \"RR\", \"WY\", \"WW\", \"YY\" };\nint id[4][4]=\n{\n{3,2,1,0},\n{2,6,5,4},\n{1,5,8,7},\n{0,4,7,9}};\nint ID(char c)\n{\n if(c=='B')return 0;\n if(c=='R')return 1;\n if(c=='W')return 2;\n return 3;\n}\n\nconst int MaxN = 25;\nconst int MaxM = MaxN * MaxN;\nconst int Inf = 50;\nstruct Edge\n{\n int v, cap, nxt;\n} e[2 * MaxM];\nint g[MaxN], pt;\nint pre[MaxN], pree[MaxN], cur[MaxN], gap[MaxN];\nint low[MaxN], d[MaxN];\nint n, ed, st;\n\nvoid init()\n{\n for (int i = 0; i < n; i++)\n g[i] = -1;\n pt = 0;\n}\n\nvoid add(int u, int v, int cap)\n{\n e[pt].v = v;e[pt].cap = cap;e[pt].nxt = g[u];g[u] = pt++;\n e[pt].v = u;e[pt].cap = 0; e[pt].nxt = g[v];g[v] = pt++;\n}\n\nint sap()\n{\n int ret = 0;\n bool fail;\n for (int i = 0; i < n; i++)\n {\n d[i] = gap[i] = 0;\n cur[i] = g[i];\n }\n low[st] = Inf;\n gap[0] = n;\n int u = st;\n\n while (d[st] < n)\n {\n fail = true;\n for (int i = cur[u]; i != -1; i = e[i].nxt)\n {\n int v = e[i].v;\n cur[u] = i;\n if (e[i].cap && d[u] == d[v] + 1)\n {\n pre[v] = u;\n pree[v] = i;\n low[v] = min(low[u], e[i].cap);\n u = v;\n if (u == ed)\n {\n for (; u != st; u = pre[u])\n {\n e[pree[u]].cap -= low[ed];\n e[pree[u] ^ 1].cap += low[ed];\n }\n ret += low[ed];\n }\n fail = false;\n break;\n }\n }\n if (fail)\n {\n gap[d[u]]--;\n if (!gap[d[u]])\n break;\n d[u] = n;\n for (int i = g[u]; i != -1; i = e[i].nxt)\n if (e[i].cap)\n d[u] = min(d[u], d[e[i].v] + 1);\n gap[d[u]]++;\n cur[u] = g[u];\n if (u != st)\n u = pre[u];\n }\n }\n return ret;\n}\n\nvoid Gao()\n{\n n = 22;st = n-1; ed = n-2;\n init();\n int ret = 0;\n for(int i = 0; i < 10; i++)\n for(int j = 0; j < 10; j++)\n add(i,j+10,Inf*A[i][j]);\n for(int i = 0; i < 10; i++)\n {\n int t = min(ax[i],have[i]);\n ret += 2*t;\n// printf(\"#%d %d\",ax[i],have[i]);\n add(st,i,ax[i]-t),add(i+10,ed,have[i]-t);\n }\n// puts(\"\");\n int tt = sap();\n ret += tt;\n// printf(\"sap==%d\\n\",tt);\n if(ans < ret)\n {\n ans = ret;\n memcpy(al,line,sizeof(line));\n memcpy(aCnt,ax,sizeof(ax));\n for(int i = 0; i < 10; i++)\n for(int j = 0; j < 10; j++)\n {\n if(A[i][j])aMp[i][j] = Inf-e[(i*10+j)*2].cap;\n else aMp[i][j] = 0;\n }\n }\n}\n\nint tot;\nvoid sol(int x, int y, int s)\n{\n if (x == N)\n {\n tot++;\n if(s==0)\n Gao();\n// for(int i = 0 ; i < N; i++)\n// for(int j = 0; j < M; j++)\n// printf(\"%d%c\",line[i][j],j==M-1?'\\n':' ');\n// puts(\"\");\n return;\n }\n if (y == M)\n {\n if (s >> M) return;\n sol(x + 1, 0, s << 1);\n return;\n }\n int p = (s >> y) & 1, q = (s >> (y + 1)) & 1;\n s = s ^ (p << y) ^ (q << (y + 1));\n if (p + q == 0)\n {\n if (x + 1 < N)\n {\n line[x][y] = 2; line[x+1][y] = 0;\n int idx = id[mp[x][y]][mp[x + 1][y]];\n ax[idx]++;\n sol(x, y + 1, s | (1 << y));\n ax[idx]--;\n }\n if (y + 1 < M)\n {\n line[x][y] = 1; line[x][y+1] = 3;\n int idx = id[mp[x][y]][mp[x][y + 1]];\n ax[idx]++;\n sol(x, y + 1, s | (1 << (y + 1)));\n ax[idx]--;\n }\n }\n else if (p == 0 || q == 0)\n {\n sol(x, y + 1, s);\n }\n}\n\nchar str[20];\nint main()\n{\n \n\n for (int i = 0; i < N; i++)\n {\n scanf(\"%s\", str);\n for(int j = 0; j < M; j++)\n mp[i][j] = ID(str[j]);\n }\n for (int i = 0; i < 10; i++)\n scanf(\"%d\", &have[i]);\n for(int i = 0; i < 10; i++)\n for(int j = 0; j < 10; j++)if(i!=j)\n if(name[i][0]==name[j][0]||name[i][0]==name[j][1]\n ||name[i][1]==name[j][0]||name[i][1]==name[j][1])\n A[i][j] = 1;\n ans = -1; tot = 0;\n sol(0, 0, 0);\n printf(\"%d\\n\",ans);\n\n //print\n for(int i = 0; i < N; i++)\n for(int j = 0; j < M; j++)if(al[i][j]==1 || al[i][j]==2)\n {\n int x=i,y=j;\n if(al[i][j]==1)y++;\n else x++;\n int idx = id[mp[i][j]][mp[x][y]];\n if(have[idx])\n {\n have[idx]--;\n Mp[i][j] = mp[i][j]; Mp[x][y] = mp[x][y];\n continue;\n }\n int k = 0;\n for(; k < 10; k++)if(aMp[idx][k])\n {\n aMp[idx][k]--;have[k]--;\n break;\n }\n if(k==10)\n {\n Mp[i][j] = Mp[x][y] = -1;continue;\n }\n if(to[mp[i][j]]==name[k][0] || to[mp[i][j]]==name[k][1])\n Mp[i][j]=mp[i][j],Mp[x][y]=ID(name[k][0])+ID(name[k][1])-mp[i][j];\n else\n Mp[x][y]=mp[x][y],Mp[i][j]=ID(name[k][0])+ID(name[k][1])-mp[x][y];\n }\n// for(int i = 0; i < N; i++)\n// for(int j = 0; j < M; j++)\n// printf(\"%d%c\",al[i][j],j==M-1?'\\n':' ');\n// for(int i = 0; i < 10; i++)\n// printf(\"%d%c\",aCnt[i],i==9?'\\n':' ');\n// for(int i = 0; i < 10; i++)\n// for(int j = 0; j < 10; j++)\n// printf(\"%d%c\",aMp[i][j],j==9?'\\n':' ');\n for(int i = 0; i < N; i++)\n for(int j = 0; j < M; j++)if(Mp[i][j]==-1)\n {\n int x=i,y=j;\n if(al[i][j]==1)y++;\n else x++;\n for(int k = 0; k < 10; k++)\n if(have[k])\n {\n have[k]--;\n Mp[i][j] = ID(name[k][0]);\n Mp[x][y] = ID(name[k][1]);\n break;\n }\n// printf(\"%d\\n\",Mp[i][j]);\n }\n for(int i = 0; i < 2*N-1; i++)\n {\n if(i&1)\n for(int j = 0; j < 2*M-1; j++)\n {\n if(j&1)printf(\".\");\n else printf(\"%c\",al[i/2][j/2]==2?'|':'.');\n }\n else\n for(int j = 0; j < 2*M-1; j++)\n {\n if(j&1)printf(\"%c\",al[i/2][j/2]==1?'-':'.');\n else printf(\"%c\",to[Mp[i/2][j/2]]);\n }\n puts(\"\");\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4387b323a6647cd9ab4b4ddedd153ca2", "src_uid": "cb56e7578ec5e04118993444283ad1eb", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include \n \ninline int read() {\n char c; int x; for (c = getchar(); !isdigit(c); c = getchar());\n for (x = 0; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; } return x;\n}\n \nconst int mod = 1e9 + 7;\n \nconst int dx[8] = {1, 1, -1, -1, 2, 2, -2, -2};\nconst int dy[8] = {2, -2, 2, -2, 1, -1, 1, -1};\n \nconst int N = 105;\n \nint f[N][N];\n \n__int128_t solve1(__int128_t n, __int128_t m) {\n if (n % 2 == 0) {\n __int128_t res = solve1(n - 1, m);\n m = std::min(n / 2, m);\n __int128_t x = n / 2 % 2 ? n / 2 : n / 2 + 1;\n __int128_t y = n / 2 % 2 ? n / 2 + 1 : n / 2;\n res += x * ((m + 1) / 2) + y * (m / 2);\n return res;\n }\n n /= 2;\n __int128_t res = 0;\n if (n <= m) {\n res += n * (n + 1) * (n * 4 + 5) / 6;\n } else {\n res += m * (m + 1) * (m * 4 + 5) / 6;\n res -= m * (m + 1) * (m + 1);\n res += m * (n + 1) * (n + 1);\n }\n return res;\n}\n \n__int128_t solve2(__int128_t n, __int128_t m) {\n __int128_t res = std::min((n - 1) / 2, m - 1);\n res = res * (res + 1) / 2;\n return res;\n}\n__int128_t solve3(__int128_t n, __int128_t m) {\n __int128_t res;\n n = std::min(n, m) - 1;\n res = (4 + n * n * 3 + n * 9 + (n % 3 - (n - 1) % 3) * 2) / 18;\n return res * 2;\n}\n__int128_t check(__int128_t n, __int128_t m) {\n __int128_t res = 0;\n for (__int128_t l = 1, r = 1e9, mid; l <= r; ) {\n mid = (l + r) / 2;\n if (std::min(mid, m - mid - mid) > std::max((__int128_t) 0, mid * 4 - n)) {\n l = mid + 1; res = mid;\n } else {\n r = mid - 1;\n }\n }\n return res;\n}\n__int128_t solve4(__int128_t n, __int128_t m) {\n __int128_t res = 0, p = check(n, m);\n if (p == 0) { return 0; }\n __int128_t pn = n / 4, pm = m / 3;\n pn = std::min(pn, p); pm = std::min(pm, p);\n if (pn > pm) {\n res += pm * (pm + 1) * (pm * 4 + 5) / 6;\n res -= m * (pm + 1) * (pm + 1) - (pm * (pm + 1) * (pm * 4 + 5) / 6 * 2);\n res += m * (pn + 1) * (pn + 1) - (pn * (pn + 1) * (pn * 4 + 5) / 6 * 2);\n res -= (m + n) * (pn + 1) * (pn + 1) - (pn * (pn + 1) * (pn * 4 + 5) / 6 * 6);\n res += (m + n) * (p + 1) * (p + 1) - (p * (p + 1) * (p * 4 + 5) / 6 * 6);\n } else {\n res += pn * (pn + 1) * (pn * 4 + 5) / 6;\n res -= n * (pn + 1) * (pn + 1) - (pn * (pn + 1) * (pn * 4 + 5) / 6 * 3);\n res += n * (pm + 1) * (pm + 1) - (pm * (pm + 1) * (pm * 4 + 5) / 6 * 3);\n res -= (m + n) * (pm + 1) * (pm + 1) - (pm * (pm + 1) * (pm * 4 + 5) / 6 * 6);\n res += (m + n) * (p + 1) * (p + 1) - (p * (p + 1) * (p * 4 + 5) / 6 * 6);\n }\n return res;\n}\n__int128_t solve5(__int128_t n, __int128_t m) {\n n -= 2; m -= 1;\n if (n < 1 || m < 1) { return 0; }\n __int128_t res = 0, p = check(n, m);\n if (p == 0) { return 0; }\n __int128_t pn = n / 4, pm = m / 3;\n pn = std::min(pn, p); pm = std::min(pm, p);\n if (pn > pm) {\n res += pm * (pm + 1) * (pm * 4 + 5) / 6;\n res += pm * (pm + 1) / 2;\n res -= m * (pm + 1) * (pm + 1) - (pm * (pm + 1) * (pm * 4 + 5) / 6 * 2);\n res -= pm * m - pm * (pm + 1) / 2 * 2;\n res += m * (pn + 1) * (pn + 1) - (pn * (pn + 1) * (pn * 4 + 5) / 6 * 2);\n res += pn * m - pn * (pn + 1) / 2 * 2;\n res -= (m + n) * (pn + 1) * (pn + 1) - (pn * (pn + 1) * (pn * 4 + 5) / 6 * 6);\n res -= pn * (n + m) - pn * (pn + 1) / 2 * 6;\n res += (m + n) * (p + 1) * (p + 1) - (p * (p + 1) * (p * 4 + 5) / 6 * 6);\n res += p * (n + m) - p * (p + 1) / 2 * 6;\n } else {\n res += pn * (pn + 1) * (pn * 4 + 5) / 6;\n res += pn * (pn + 1) / 2;\n res -= n * (pn + 1) * (pn + 1) - (pn * (pn + 1) * (pn * 4 + 5) / 6 * 3);\n res -= pn * n - pn * (pn + 1) / 2 * 3;\n res += n * (pm + 1) * (pm + 1) - (pm * (pm + 1) * (pm * 4 + 5) / 6 * 3);\n res += pm * n - pm * (pm + 1) / 2 * 3;\n res -= (m + n) * (pm + 1) * (pm + 1) - (pm * (pm + 1) * (pm * 4 + 5) / 6 * 6);\n res -= pm * (n + m) - pm * (pm + 1) / 2 * 6;\n res += (m + n) * (p + 1) * (p + 1) - (p * (p + 1) * (p * 4 + 5) / 6 * 6);\n res += p * (n + m) - p * (p + 1) / 2 * 6;\n }\n return res;\n}\n \n__int128_t solve(__int128_t n, __int128_t m) {\n if (n == 0 || m == 0) { return 0; }\n __int128_t res = 0;\n res += solve1(n, m) + solve1(m, n);\n res += solve2(n, m) + solve2(m, n);\n res += solve3(n, m);\n res += solve4(n, m) + solve4(m, n);\n res += solve4(n - 1, m - 1) + solve4(m - 1, n - 1);\n res += solve4(n - 2, m - 2) + solve4(m - 2, n - 2);\n res += solve5(n, m) + solve5(m, n);\n res += solve5(n - 1, m - 1) + solve5(m - 1, n - 1);\n res += solve5(n - 2, m - 2) + solve5(m - 2, n - 2);\n if (1 <= n && 2 <= m) { res += 2; }\n if (2 <= n && 1 <= m) { res += 2; }\n if (2 <= n && 2 <= m) { res += 2; }\n if (3 <= n && 3 <= m) { res += 2; }\n return res;\n}\n \nint main() {\n for (int T = read(); T; T--) {\n int r = read(), c = read(), n = read(), m = read();\n if (n <= 50 && m <= 50) {\n memset(f, 60, sizeof(f));\n f[1][1] = 0;\n for (int d = 0; d < 100; d++) {\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= m; j++) {\n for (int k = 0; k < 8; k++) {\n int x = i + dx[k], y = j + dy[k];\n if (1 <= x && 1 <= y && x <= n && y <= m) {\n f[i][j] = std::min(f[i][j], f[x][y] + 1);\n }\n }\n }\n }\n }\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= m; j++) {\n if (f[i][j] > 1e9) { f[i][j] = 0; }\n f[i][j] += f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];\n }\n }\n printf(\"%d\\n\", f[n][m] + f[r - 1][c - 1] - f[n][c - 1] - f[r - 1][m]);\n } else {\n printf(\"%d\\n\", (int) ((solve(n, m) + solve(r - 1, c - 1) - solve(n, c - 1) - solve(r - 1, m)) % mod));\n } \n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0c7fca42ab35d07c2de61a983d9a1ca0", "src_uid": "1da05fe5b26f274c1af216dc041d1aa8", "difficulty": 3100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define for_each(name, left, right, step) for (int name = left; name < right; name += step)\n\nusing namespace std;\n\ntemplate\nusing set = unordered_set;\n\ntypedef pair pii;\ntypedef long long ll;\n\nstruct HashTable {\n int max_size;\n vector* hash_mod___keys;\n int curr_size;\n\n HashTable() {\n max_size = 10;\n curr_size = 0;\n hash_mod___keys = new vector [max_size];\n }\n\n void insert(int key) {\n int hash_mod = (key * ll(1e+9 + 7)) % max_size;\n hash_mod___keys[hash_mod].push_back(key);\n curr_size++;\n if (curr_size > max_size / 2) {\n int new_max_size = max_size * 2 + 1;\n vector* new_hash_mod___keys = new vector [new_max_size];\n for_each(hash_mod, 0, max_size, 1) {\n for (auto old_key: hash_mod___keys[hash_mod]) {\n int new_hash_mod = (old_key * ll(1e+9 + 7)) % (new_max_size);\n new_hash_mod___keys[new_hash_mod].push_back(old_key);\n }\n hash_mod___keys[hash_mod].resize(0);\n }\n\n delete[] hash_mod___keys;\n hash_mod___keys = new_hash_mod___keys;\n max_size = new_max_size;\n }\n }\n\n void erase(int key) {\n int hash_mod = (key * ll(1e+9 + 7)) % max_size;\n auto it = find(hash_mod___keys[hash_mod].begin(), hash_mod___keys[hash_mod].end(), key);\n hash_mod___keys[hash_mod].erase(it);\n curr_size--;\n }\n};\n\nvector get_centroids(vector >& node_idx___neigh_idxes) {\n int nodes_nr = node_idx___neigh_idxes.size();\n vector > node_idx___children(nodes_nr);\n vector node_idx___is_visited(nodes_nr, 0);\n stack dfs_stack;\n dfs_stack.push(0);\n node_idx___is_visited[0] = 1;\n while (!dfs_stack.empty()) {\n int curr_node_idx = dfs_stack.top();\n dfs_stack.pop();\n for (auto neigh_idx : node_idx___neigh_idxes[curr_node_idx]) {\n if (!node_idx___is_visited[neigh_idx]) {\n node_idx___is_visited[neigh_idx] = 1;\n node_idx___children[curr_node_idx].push_back(neigh_idx);\n dfs_stack.push(neigh_idx);\n }\n }\n }\n vector node_idx___subnodes_nr(nodes_nr, 1);\n for (auto& is_visited: node_idx___is_visited) {\n is_visited = 0;\n }\n dfs_stack.push(0);\n node_idx___is_visited[0] = 1;\n while (!dfs_stack.empty()) {\n int curr_node_idx = dfs_stack.top();\n bool all_children_visited = true;\n for (auto child_idx : node_idx___children[curr_node_idx]) {\n if (!node_idx___is_visited[child_idx]) {\n node_idx___is_visited[child_idx] = 1;\n dfs_stack.push(child_idx);\n all_children_visited = false;\n }\n }\n if (all_children_visited) {\n for (auto child_idx : node_idx___children[curr_node_idx]) {\n node_idx___subnodes_nr[curr_node_idx] += node_idx___subnodes_nr[child_idx];\n }\n dfs_stack.pop();\n }\n }\n vector centroids;\n for_each(node_idx, 0, nodes_nr, 1) {\n bool is_centroid = true;\n int parent_subnodes = nodes_nr - 1;\n for (auto child_idx: node_idx___children[node_idx]) {\n //cout << node_idx___subnodes_nr[child_idx] << \" \";\n if (node_idx___subnodes_nr[child_idx] > nodes_nr / 2) {\n is_centroid = false;\n break;\n }\n parent_subnodes -= node_idx___subnodes_nr[child_idx];\n }\n //cout << parent_subnodes << endl;\n if (parent_subnodes > nodes_nr / 2) {\n is_centroid = false;\n }\n if (is_centroid) {\n centroids.push_back(node_idx);\n }\n }\n\n return centroids;\n}\n\npii straighten_subtree(int stone_idx, int curr_root_idx, vector& node_idx___neigh_idxes, vector >& operations) {\n // cout << \"*\" << stone_idx << \" \" << curr_root_idx << endl;\n int neigh_nr = node_idx___neigh_idxes[curr_root_idx].curr_size;\n if (neigh_nr == 1) {\n // cout << \"8returned\" << endl;\n return make_pair(curr_root_idx, curr_root_idx);\n }\n vector rel_neigh_idx___root__hangler;\n // int i = 0;\n vector curr_neigh_idxes;\n for_each(hash_mod, 0, node_idx___neigh_idxes[curr_root_idx].max_size, 1) {\n for(auto& neigh_idx: node_idx___neigh_idxes[curr_root_idx].hash_mod___keys[hash_mod]) {\n curr_neigh_idxes.push_back(neigh_idx);\n }\n }\n for (auto& neigh_idx: curr_neigh_idxes) {\n if (neigh_idx != stone_idx) {\n rel_neigh_idx___root__hangler.push_back(straighten_subtree(curr_root_idx, neigh_idx, node_idx___neigh_idxes, operations));\n }\n }\n int curr_parent_idx = stone_idx;\n int next_root_idx = (neigh_nr == 2 ? curr_root_idx : rel_neigh_idx___root__hangler[0].second);\n\n // replace stone_idx curr_root_idx connection\n if (next_root_idx != curr_root_idx) {\n node_idx___neigh_idxes[stone_idx].insert(rel_neigh_idx___root__hangler[0].second);\n node_idx___neigh_idxes[stone_idx].erase(curr_root_idx);\n node_idx___neigh_idxes[curr_root_idx].erase(stone_idx);\n node_idx___neigh_idxes[rel_neigh_idx___root__hangler[0].second].insert(stone_idx);\n curr_parent_idx = rel_neigh_idx___root__hangler[0].first;\n vector operation(3);\n operation[0] = stone_idx;\n operation[1] = curr_root_idx;\n operation[2] = rel_neigh_idx___root__hangler[0].second;\n operations.push_back(operation);\n // cout << \"**\" << operation[0] << \" \" << operation[1] << \" \" << operation[2] << endl;\n }\n neigh_nr = rel_neigh_idx___root__hangler.size();\n for_each(neigh_idx, 1, neigh_nr - 1, 1) {\n //create curr_parent_idx, rel_neigh_idx___root__hangler[neigh_idx].second\n vector operation(3);\n operation[0] = curr_parent_idx;\n operation[1] = curr_root_idx;\n operation[2] = rel_neigh_idx___root__hangler[neigh_idx].second;\n // cout << \"**\" << operation[0] << \" \" << operation[1] << \" \" << operation[2] << endl;\n operations.push_back(operation);\n node_idx___neigh_idxes[curr_parent_idx].insert(rel_neigh_idx___root__hangler[neigh_idx].second);\n node_idx___neigh_idxes[rel_neigh_idx___root__hangler[neigh_idx].second].insert(curr_parent_idx);\n //tear curr_root_idx neigh\n node_idx___neigh_idxes[curr_parent_idx].erase(curr_root_idx);\n node_idx___neigh_idxes[curr_root_idx].erase(curr_parent_idx);\n curr_parent_idx = rel_neigh_idx___root__hangler[neigh_idx].first;\n }\n // cout << \"8returned\" << endl;\n return make_pair(next_root_idx, rel_neigh_idx___root__hangler[neigh_nr - 1].second);\n}\n\nint hedgehogify(int stone_idx, int curr_root_idx, vector& node_idx___neigh_idxes, vector >& operations) {\n int neigh_nr = node_idx___neigh_idxes[curr_root_idx].curr_size;\n // cout << \"*\" << neigh_nr << endl;\n if (neigh_nr == 1) {\n return curr_root_idx;\n }\n int center_idx;\n for_each(hash_mod, 0, node_idx___neigh_idxes[curr_root_idx].max_size, 1) {\n for (auto neigh_idx: node_idx___neigh_idxes[curr_root_idx].hash_mod___keys[hash_mod]) {\n if (neigh_idx != stone_idx) {\n center_idx = hedgehogify(curr_root_idx, neigh_idx, node_idx___neigh_idxes, operations);\n // cout << \"**\" << center_idx << endl;\n }\n }\n }\n vector operation(3);\n operation[0] = stone_idx;\n operation[1] = curr_root_idx;\n operation[2] = center_idx;\n operations.push_back(operation);\n return center_idx;\n}\n\nvoid straighten_and_hedgehogify_parts(vector >& node_idx___neigh_idxes, int centroid1, int centroid2, vector >& operations, bool fl) {\n int nodes_nr = node_idx___neigh_idxes.size();\n for (auto neigh_idx : node_idx___neigh_idxes[centroid1]) {\n if ((neigh_idx == centroid2) || (neigh_idx == centroid1)) {\n continue;\n }\n vector curr_node_idx___neigh_idxes(nodes_nr);\n curr_node_idx___neigh_idxes[centroid1].insert(neigh_idx);\n curr_node_idx___neigh_idxes[neigh_idx].insert(centroid1);\n vector curr_node_idx___is_visited(nodes_nr, 0);\n stack dfs_stack;\n dfs_stack.push(neigh_idx);\n curr_node_idx___is_visited[neigh_idx] = 1;\n while (!dfs_stack.empty()) {\n int curr_node_idx = dfs_stack.top();\n dfs_stack.pop();\n for (auto curr_neigh_idx: node_idx___neigh_idxes[curr_node_idx]) {\n if ((curr_neigh_idx != centroid1) && (curr_node_idx___is_visited[curr_neigh_idx] == 0) && (curr_neigh_idx != centroid2)) {\n curr_node_idx___neigh_idxes[curr_node_idx].insert(curr_neigh_idx);\n curr_node_idx___neigh_idxes[curr_neigh_idx].insert(curr_node_idx);\n curr_node_idx___is_visited[curr_neigh_idx] = 1;\n dfs_stack.push(curr_neigh_idx);\n }\n }\n }\n // cout << \"shdfkhfk\" << endl;\n pii report = straighten_subtree(centroid1, neigh_idx, curr_node_idx___neigh_idxes, operations);\n hedgehogify(centroid1, report.first, curr_node_idx___neigh_idxes, operations);\n // for (auto operation : operations) {\n // cout << operation[0] << \" \" << operation[1] << \" \" << operation[2] << endl;\n // }\n }\n\n if (centroid1 == centroid2) {\n return;\n }\n if (!fl){\n straighten_and_hedgehogify_parts(node_idx___neigh_idxes, centroid2, centroid1, operations, 1);\n }\n}\n\nvoid solve() {\n\n int nodes_nr;\n cin >> nodes_nr;\n vector > node_idx___neigh_idxes(nodes_nr);\n for_each(edge_idx, 0, nodes_nr - 1, 1) {\n int node1, node2;\n cin >> node1 >> node2;\n node1--;\n node2--;\n node_idx___neigh_idxes[node2].push_back(node1);\n node_idx___neigh_idxes[node1].push_back(node2);\n }\n vector centroids = get_centroids(node_idx___neigh_idxes);\n int centroid1, centroid2;\n if (centroids.size() == 1) {\n centroid1 = centroids[0];\n centroid2 = centroids[0];\n }\n else {\n centroid1 = centroids[0];\n centroid2 = centroids[1];\n }\n // cout << \"!\" << centroid1 << \" \" << centroid2 << endl;\n vector > operations;\n straighten_and_hedgehogify_parts(node_idx___neigh_idxes, centroid1, centroid2, operations, 0);\n cout << operations.size() << endl;\n for (auto operation : operations) {\n for (auto node_idx: operation) {\n cout << (node_idx + 1) << \" \";\n }\n cout << endl;\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(0);\n solve();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3b4f3ab2e5fb5d0125e6c42bb7e2650a", "src_uid": "32fdea91454384b103f52743c1128cfc", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nchar s[7][7];\nint map[7][7];\n//move R0 L1 U2 D3\nint top,dir[10000],num[10000],step[10000],x,y;\nvoid out()\n{\n\tint i,j;\n\tfor(i=1;i<=6;printf(\"\\n\"),i++)\n\tfor(j=1;j<=6;j++)\n\tprintf(\"%3d \",map[i][j]);\n}\nvoid find(int a)\n{\n\tfor(x=1;x<=6;x++)\n\tfor(y=1;y<=6;y++)\n\tif(map[x][y]==a)return;\n}\nvoid move(int d,int n,int s)\n{\n\t//move R0 L1 U2 D3\n\tint i;\n\tstep[top]=s;\n\tnum[top]=n;\n\tdir[top]=d;\n\ttop++;\n\tint tmp[7];\n\tif(d==1||d==2)s*=-1;\n\tif(d<2)\n\t{\n\t\tfor(i=1;i<=6;i++)\n\t\ttmp[i]=map[n][i];\n\t\tfor(i=1;i<=6;i++)\n\t\tmap[n][(i-1+s+6)%6+1]=tmp[i];\n\t}\n\telse\n\t{\n\t\tfor(i=1;i<=6;i++)\n\t\ttmp[i]=map[i][n];\n\t\tfor(i=1;i<=6;i++)\n\t\tmap[(i-1+s+6)%6+1][n]=tmp[i];\n\t}\n}\nvoid SWAP(int p)\n{//move R0 L1 U2 D3\n\tmove(0,6,1);\n\tmove(3,p+1,1);\n\tmove(1,6,1);\n\tmove(2,p+1,1);\n\tmove(1,6,1);\n\tmove(3,p,1);\n\tmove(0,6,1);\n\tmove(2,p,1);\n\tmove(0,6,1);\n\tmove(3,p+1,1);\n\tmove(1,6,1);\n\tmove(2,p+1,1);\n}\nvoid make_cir(int p)\n{\n\tSWAP(p);\n\tmove(1,6,1);\n\tSWAP(p);\n\tmove(0,6,1);\n}\nint main()\n{\n\tint i,j,a,b;\n\ttop=0;\n\tfor(i=1;i<=6;i++)\n\t{\n\t\tscanf(\"%s\",&s[i][1]);\n\t\tfor(j=1;j<=6;j++)\n\t\tmap[i][j]=s[i][j]<='9'?s[i][j]-'0':s[i][j]-'A'+10;\n\t}\n\tfor(i=0;i<=29;i++)\n\t{\n\t\tfind(i);\n\t\ta=i/6+1,b=i%6+1;\n\t\tif(x==a&&y==b)continue;\n\t\t//move R0 L1 U2 D3\n\t\tif(i<=5)\n\t\t{\n\t\t\tif(i==0)\n\t\t\tmove(1,x,x-1),move(2,1,y-1);\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(x==1)\n\t\t\t\tmove(3,y,1),x=2;\n\t\t\t\tif(y>b)\n\t\t\t\tmove(1,x,y-b);\n\t\t\t\telse if(yb)\n\t\t\t\tmove(1,a+1,y-b);\n\t\t\t\telse if(yb)\n\t\t\t\tmove(1,x,y-b);\n\t\t\t\telse if(y\n \n#define int long long\n \n#define pii pair\n \n#define x1 x1228\n#define y1 y1228\n \n#define left left228\n#define right right228\n \n#define pb push_back\n#define eb emplace_back\n \n#define mp make_pair \n \n#define ff first \n#define ss second \n \n#define matr vector > \n \n#define all(x) x.begin(), x.end()\n \n \nusing namespace std;\ntypedef long long ll; \ntypedef long double ld; \n \nconst int maxn = 1000 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7;\nconst double eps = 1e-9;\nmt19937 rnd(time(0));\nint n; \nvector gr[maxn]; \nint p[maxn], dist[maxn]; \nint used[maxn]; \nint cycle[maxn]; \nvector path; \n\nvoid dfs(int u, int pr, int d) {\n used[u] = 1;\n dist[u] = d; \n p[u] = pr; \n for (auto v : gr[u]) {\n if (v == pr) continue;\n if (!used[v]) {\n dfs(v, u, d + 1); \n } else if (dist[v] < dist[u]) {\n int pp = u; \n while (pp != v) {\n path.pb(pp); \n cycle[pp] = 1; \n pp = p[pp]; \n }\n path.pb(v); \n cycle[v] = 1; \n }\n } \n}\n\nint upper[maxn];\nint down[maxn];\nint size[maxn];\nint func[maxn];\n \nint dfs1(int u, int pr, int d) {\n p[u] = pr; \n size[u] = 1;\n used[u] = 1; \n dist[u] = d; \n for (auto v : gr[u]) {\n if (cycle[v] || v == pr) continue; \n size[u] += dfs1(v, u, d + 1); \n }\n return size[u]; \n}\n\nint dow(int u, int pr) {\n down[u] = size[u]; \n for (auto v : gr[u]) {\n if (cycle[v] || v == pr) continue; \n down[u] += dow(v, u); \n } \n return down[u]; \n}\n\nint start; \nvoid upp(int u, int pr) {\n if (pr == u) {\n upper[u] = 1;\n } else if (pr == start) {\n upper[u] = size[start] - size[u] + 1 + down[start] - down[u] - size[u]; \n } else {\n upper[u] = upper[pr] + size[start] - size[u] + 1; \n }\n for (auto v : gr[u]) {\n if (cycle[v] || v == pr) continue; \n upp(v, u); \n }\n}\n\nint mxx; \nvoid get(int u, int pr) {\n func[u] = (dist[u] + 1) * (n - size[start]) + upper[u] + down[u] - 1;\n mxx = max(mxx, func[u]); \n for (auto v : gr[u]) {\n if (cycle[v] || v == pr) continue; \n get(v, u); \n } \n}\n\nint dp[maxn][maxn]; \nint ms[maxn][maxn]; \nint ALL = 0; \n\nvoid solve() { \n cin >> n; \n for (int i = 0; i < n; ++i) {\n int a, b; cin >> a >> b;\n gr[a].pb(b); \n gr[b].pb(a); \n }\n dfs(0, 0, 0); \n for (int i = 0; i < n; ++i) {\n if (!cycle[i]) continue; \n dfs1(i, i, 0);\n start = i; \n dow(i, i);\n upp(i, i);\n mxx = -inf;\n get(i, i); \n func[i] = mxx; \n } \n vector have;\n for (auto v : path) have.pb(v); \n for (auto v : path) have.pb(v); \n for (int i = 0; i < have.size(); ++i) {\n int v = have[i];\n dp[i][1] = func[v]; \n ms[i][1] = size[v]; \n }\n for (int len = 2; len <= have.size() / 2; ++len) {\n for (int l = 0; l + len - 1 < have.size(); ++l) {\n int r = l + len - 1; \n ms[l][len] = ms[l][len - 1] + size[have[r]];\n int L = dp[l + 1][len - 1] + n - ms[l + 1][len - 1] + down[have[l]] - size[have[l]]; \n int R = dp[l][len - 1] + n - ms[l][len - 1] + down[have[r]] - size[have[r]];\n dp[l][len] = max(L, R); \n }\n }\n int ans = 0; \n for (int i = 0; i < have.size(); ++i) {\n ans = max(ans, dp[i][have.size() / 2]); \n }\n cout << ans; \n} \n \nsigned main() {\n#ifdef LOCAL\n freopen(\"TASK.in\", \"r\", stdin);\n freopen(\"TASK.out\", \"w\", stdout);\n#else \n \n#endif // LOCAL\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.precision(20); \n cout << fixed; \n int t = 1; \n for (int i = 0; i < t; ++i) { \n solve();\n }\n return 0;\n} ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "97ebad35aa98944bc59f728bf521d6a6", "src_uid": "c3da92d4b495d3e99c83a5ffe206709a", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define mp(a,b) make_pair(a,b)\n#define ff first\n#define setp setprecision(12)<& a){\n\tlli ebob = gcd(a.ff,a.ss);\n\ta.ff/=ebob, a.ss/=ebob;\n}\nbool J(pair &a, pair &b){\n\treturn a.ff * b.ss < a.ss * b.ff;\n}\nlli ind(pair &aa, vector > &all){\n\tlli a = 0, b = all.size()-1;\n\tif(J(aa,all[0]))\n\t\treturn 0;\n\twhile(a>n>>w;\n\tvector > all[2];\n\tfori(n){\n\t\tlli x,v;\n\t\tcin>>x>>v;\n\t\tpair a;\tlli kd = 0;\n\t\tif(x<0)\n\t\t\tx = -x;\n\t\telse\n\t\t\tv = -v, kd = 1;\n\t\ta.ff = x, a.ss = v+w;\n\t\tall[kd].push_back(a);\n//\t\tcout<<(double)(x)/(double)(v-w)<<\" \"<<(double)(x)/(double)(v+w)< last;\n\tmap ch[2];\n\tfori(2)\n\t\tforj(all[i].size()){\n\t\t\tpair sanity = all[i][j];\n\t\t\tsanity.ss-=w;\n\t\t\tfix(sanity);\n\t\t\tfix(all[i][j]);\n\t\t\tsanity.ff*=3*pow(10,5);\n\t\t\tsanity.ff+=sanity.ss;\n\t\t\tsy+=ch[i][sanity.ff];\n\t\t\tch[i][sanity.ff]++;\n\t\t}\n\tfori(all[0].size())\n\t\tall[0][i].ff*= 3*pow(10,5), last[all[0][i].ff + all[0][i].ss]++;\n\tfori(all[1].size())\n\t\tall[1][i].ff*=3*pow(10,5), sy+=last[all[1][i].ff + all[1][i].ss];\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nuint32_t readu32() { int c; while((c = getchar()) < '0'); uint32_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return n; } uint64_t readu64() { int c; while((c = getchar()) < '0'); uint64_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return n; } int32_t read32() { int c; while((c = getchar()) < '-'); bool neg = c == '-'; if(neg) c = getchar(); uint32_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return neg ? -(int32_t)n : n; } int64_t read64() { int c; while((c = getchar()) < '-'); bool neg = c == '-'; if(neg) c = getchar(); uint64_t n = c & 15; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return neg ? -(int64_t)n : n; } std::string read_word() { int c; while ((c = getchar()) <= ' '); std::string s; do { s += (char) c; } while ((c = getchar()) > ' '); return s; } template struct no_arg_call { template struct stupid_compiler { typedef T type; }; operator typename stupid_compiler::type() { return f(); } }; no_arg_call IU; no_arg_call II; no_arg_call IUL; no_arg_call IL; no_arg_call IW;\ntemplate struct mat { T dat[N*N]; struct id_s {}; static const id_s id; mat(): dat{} { } mat(std::initializer_list l) { int i = 0; for(auto&& x: l) dat[i++] = x; for(; i < N*N; i++) dat[i] = 0; } mat(int m): dat{} { for(int i = 0; i < N; i++) (*this)(i,i) = m; } mat(id_s) { for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) dat[N*i + j] = +(i==j); } T& operator()(int i, int j) { return dat[N*i + j]; } const T& operator()(int i, int j) const { return dat[N*i + j]; } mat operator*(const mat& o) { mat r; for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) for(int k = 0; k < N; k++) r(i,j) += (*this)(i,k) * o(k,j); return r; } mat operator+(const mat& o) { mat r; for(int i = 0; i < N*N; i++) r.dat[i] = dat[i] + o.dat[i]; return r; } };\ntemplate struct xgcd_s { T m, n, gcd; }; template xgcd_s xgcd(T a, T b) { T m[] = {1,0}, n[] = {0,1}, q[] = {0,0}; for(int i = 0; ; i^=1) { m[i] -= m[i^1] * q[i]; n[i] -= n[i^1] * q[i]; if(!b) return xgcd_s{m[i],n[i],a}; q[i] = a/b; a %= b; std::swap(a,b); } } template struct _intmod { private: struct _p {unsigned x; }; _intmod(_p x) { n = x.x; } public: unsigned n; _intmod() {n = 0;} _intmod(int x) { n = x<0? M()+x%(int)M(): x%M(); } _intmod(unsigned x) {n = x%M(); } _intmod(long x) {n = unsigned(x<0? M()+x%(long)M(): x%M()); } _intmod(unsigned long x) {n = x % M(); } _intmod(long long x) {n = unsigned(x<0? M()+x%(long long)M(): x%M()); } _intmod(unsigned long long x) {n = x % M(); } _intmod operator+(_intmod b) const {return {n+b.n}; } _intmod operator*(_intmod b) const {return {_p{unsigned((unsigned long long)n * b.n % M())}}; } _intmod operator-(_intmod b) const {return {_p{n>=b.n? n-b.n : M()+n-b.n }}; } _intmod operator-() const {return {_p{n?M()-n:0U}}; } _intmod& operator+=(_intmod b) { return(*this = *this + b); } _intmod& operator-=(_intmod b) { return(*this = *this - b); } _intmod& operator/=(_intmod b) { return(*this = *this / b); } _intmod& operator*=(_intmod b) { return(*this = *this * b); } static _intmod mulinv(_intmod n) { xgcd_s x = xgcd(n.n, M()); assert(x.gcd == 1); return x.m; } _intmod operator/(_intmod b) const { return *this * mulinv(b); } bool operator==(_intmod b) const { return n == b.n; } bool operator!=(_intmod b) const { return n != b.n; } explicit operator int() const { return n; } }; template std::ostream& operator<<(std::ostream& o, _intmod n) { return o< std::istream& operator>>(std::istream& i, _intmod& n) { long long x; i>>x; n = x; return i; } template unsigned intmod_unsignedconst() { static_assert(M>0 && M<(1U<<31), \"modulus bad\"); return M; } template unsigned intmod_unsignedptr() { return *M; } template using intmod = _intmod >; template using intmodv = _intmod >; static_assert(std::is_trivially_copyable >::value, \"\");\ntemplate T bpow(T b, X x) { T r = 1, p = b; while(x) { if(x & 1) r = r * p; if(x >>= 1) p = p * p; } return r; }\ntemplate struct matd { std::vector dat; size_t dim; matd(): dim(0) { } matd(size_t dim): dim(dim), dat(dim * dim) { } matd(size_t dim, std::initializer_list l): matd(dim) { size_t i = 0; for(auto&& x: l) dat[i++] = x; } matd(size_t dim, const T& diag): matd(dim) { for(size_t i = 0; i < dim; i++) (*this)(i,i) = diag; } T& operator()(size_t i, size_t j) { return dat[dim*i + j]; } const T& operator()(size_t i, size_t j) const { return dat[dim*i + j]; } matd operator*(const matd& o) const { matd r(dim); for(int i = 0; i < dim; i++) for(int j = 0; j < dim; j++) for(int k = 0; k < dim; k++) r(i,j) += (*this)(i,k) * o(k,j); return r; } matd operator+(const matd& o) const { matd r(dim); for(int i = 0; i < dim*dim; i++) r.dat[i] = dat[i] + o.dat[i]; return r; } template matd pow(T power) const { if(!power) return matd(dim, 1); matd ans = *this; while(!(power & 1)) { ans = ans * ans; power >>= 1; } power >>= 1; if(power) { matd p = ans * ans; for(;;) { if(power & 1) ans = ans * p; power >>= 1; if(!power) break; p = p * p; } } return ans; } };\n\n\nusing namespace std;\nusing I = intmod<1000000007>;\n\n#define D 250\n\n//#define D 25\n\n\n\nint main(int argc, char** argv)\n{\n if (argc == 2) freopen(argv[1], \"r\", stdin);\n ios_base::sync_with_stdio(0);\n\n matd m(250), mm(250);\n\n int F = IU, B = IU, N = IU;\n vector p(F), b(B);\n for (auto& x : p) x = IU;\n for (auto& x : b) x = IU;\n\n\n for (int r = 1; r < D; r++) {\n m(r, r - 1) = 1;\n }\n for (int x : b)\n m(0, x - 1) += 1;\n\n\n\n for(int pp : p) {\n auto tr = bpow(m, pp);\n mm = mm + tr;\n }\n\n\n auto a = bpow(mm, N);\n cout << a(0, 0);\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9ef10e7719ea699ce7c893f416abb603", "src_uid": "c3a4c109080f49b88be5fb13157d1af0", "difficulty": 3300.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\ntypedef pair < int , int > pii;\ntypedef long double ldb;\n#define mpr make_pair\n#define FS first\n#define SC second\n#define PB push_back\ntemplate < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}\ntemplate < typename T > void UMIN(T &a,T b){a=(a='0' && c<='9')){\n\t\tif(c=='-') neg=1;\n\t\tc=getchar();\n\t}\n\twhile(c>='0' && c<='9'){\n\t\tret=ret*10ll+(LL)(c-'0');\n\t\tc=getchar();\n\t}\n\treturn neg?-ret:ret;\n}\nvoid putint(LL v){\n\tif(v<0){\n\t\tputchar('-');\n\t\tv=-v;\n\t}\n\tif(!v){\n\t\tputchar('0');\n\t\treturn;\n\t}\n\tif(v>=10ll) putint(v/10ll);\n\tputchar('0'+(v%10ll));\n}\nconst int S=1002,T=1003,inf=50000000;\nnamespace flows{\n struct edge{\n int v,r,id;\n\t\tldb f;\n edge(int V,int R,ldb F,int _id){\n v=V;r=R;f=F;id=_id;\n }\n };\n vector < edge > adj[1005];\n int cur[1005],dis[1005];\n void init(){\n int i;\n for(i=0;i<1005;++i){\n adj[i].clear();\n }\n }\n void addedge(int u,int v,ldb f,int id,bool bi=0){\n adj[u].push_back(edge(v,(int)adj[v].size(),f,id));\n adj[v].push_back(edge(u,(int)adj[u].size()-1,bi?f:0,-1));\n }\n void bfs(){\n queue < int > Q;\n Q.push(S);\n dis[S]=0;\n while(!Q.empty()){\n int i,cv=Q.front();\n Q.pop();\n for(i=0;i<(int)adj[cv].size();++i){\n if(adj[cv][i].f>1e-8l && dis[adj[cv][i].v]==-1){\n dis[adj[cv][i].v]=dis[cv]+1;\n Q.push(adj[cv][i].v);\n } \n }\n }\n }\n ldb dfs(int ver,ldb cap){\n if(ver==T) return cap;\n for(int &i=cur[ver];i<(int)adj[ver].size();++i){\n edge &E=adj[ver][i];\n if(E.f>1e-8l && dis[E.v]>dis[ver]){\n ldb ret=dfs(E.v,min(cap,E.f));\n if(ret>1e-8l){\n E.f-=ret;\n adj[E.v][E.r].f+=ret;\n return ret;\n }\n }\n }\n return 0;\n }\n ldb maxflow(){\n ldb ret=0,dlt;\n while(1){\n memset(dis,-1,sizeof(dis));\n memset(cur,0,sizeof(cur));\n bfs();\n if(dis[T]==-1) return ret;\n dlt=1;\n while(dlt>1e-8l){\n dlt=dfs(S,1e9l);\n ret+=dlt;\n }\n }\n }\n}\nint n,m;\nvector < int > U,V,A,B,C,D;\nldb calc(ldb t){\n\tflows::init();\n\tint i,j,k;\n//\tfor(i=0;i1e-7l){\n\t\tldb dif=(r-l)/3;\n\t\tldb mid1=l+dif,mid2=l+dif+dif;\n\t\tif(calc(mid1)1e-7l){\n\t\tmid=(l+r)/2;\n\t\tif(calc(mid)>-1e-8l)\n\t\t\tl=mid;\n\t\telse\n\t\t\tr=mid;\n\t}\n//\tcout<<'R'<1e-7l){\n\t\tmid=(l+r)/2;\n\t\tif(calc(mid)>-1e-8l)\n\t\t\tr=mid;\n\t\telse\n\t\t\tl=mid;\n\t}\n//\tcout<<'L'<\nusing namespace std;\ntypedef long long LL;\ntypedef pair < int , int > pii;\ntypedef long double ldb;\n#define mpr make_pair\n#define FS first\n#define SC second\n#define PB push_back\ntemplate < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}\ntemplate < typename T > void UMIN(T &a,T b){a=(a='0' && c<='9')){\n\t\tif(c=='-') neg=1;\n\t\tc=getchar();\n\t}\n\twhile(c>='0' && c<='9'){\n\t\tret=ret*10ll+(LL)(c-'0');\n\t\tc=getchar();\n\t}\n\treturn neg?-ret:ret;\n}\nvoid putint(LL v){\n\tif(v<0){\n\t\tputchar('-');\n\t\tv=-v;\n\t}\n\tif(!v){\n\t\tputchar('0');\n\t\treturn;\n\t}\n\tif(v>=10ll) putint(v/10ll);\n\tputchar('0'+(v%10ll));\n}\nconst int S=1002,T=1003,inf=50000000;\nnamespace flows{\n struct edge{\n int v,r,id;\n\t\tldb f;\n edge(int V,int R,ldb F,int _id){\n v=V;r=R;f=F;id=_id;\n }\n };\n vector < edge > adj[1005];\n int cur[1005],dis[1005];\n void init(){\n int i;\n for(i=0;i<1005;++i){\n adj[i].clear();\n }\n }\n void addedge(int u,int v,ldb f,int id,bool bi=0){\n adj[u].push_back(edge(v,(int)adj[v].size(),f,id));\n adj[v].push_back(edge(u,(int)adj[u].size()-1,bi?f:0,-1));\n }\n void bfs(){\n queue < int > Q;\n Q.push(S);\n dis[S]=0;\n while(!Q.empty()){\n int i,cv=Q.front();\n Q.pop();\n for(i=0;i<(int)adj[cv].size();++i){\n if(adj[cv][i].f>1e-8l && dis[adj[cv][i].v]==-1){\n dis[adj[cv][i].v]=dis[cv]+1;\n Q.push(adj[cv][i].v);\n } \n }\n }\n }\n ldb dfs(int ver,ldb cap){\n if(ver==T) return cap;\n for(int &i=cur[ver];i<(int)adj[ver].size();++i){\n edge &E=adj[ver][i];\n if(E.f>1e-8l && dis[E.v]>dis[ver]){\n ldb ret=dfs(E.v,min(cap,E.f));\n if(ret>1e-8l){\n E.f-=ret;\n adj[E.v][E.r].f+=ret;\n return ret;\n }\n }\n }\n return 0;\n }\n ldb maxflow(){\n ldb ret=0,dlt;\n while(1){\n memset(dis,-1,sizeof(dis));\n memset(cur,0,sizeof(cur));\n bfs();\n if(dis[T]==-1) return ret;\n dlt=1;\n while(dlt>1e-8l){\n dlt=dfs(S,1e9l);\n ret+=dlt;\n }\n }\n }\n}\nint n,m;\nvector < int > U,V,A,B,C,D;\nldb calc(ldb t){\n\tflows::init();\n\tint i,j,k;\n//\tfor(i=0;i1e-7l){\n\t\tldb dif=(r-l)/3;\n\t\tldb mid1=l+dif,mid2=l+dif+dif;\n\t\tif(calc(mid1)1e-7l){\n\t\tmid=(l+r)/2;\n\t\tif(calc(mid)>-1e-8l)\n\t\t\tl=mid;\n\t\telse\n\t\t\tr=mid;\n\t}\n//\tcout<<'R'<1e-7l){\n\t\tmid=(l+r)/2;\n\t\tif(calc(mid)>-1e-8l)\n\t\t\tr=mid;\n\t\telse\n\t\t\tl=mid;\n\t}\n//\tcout<<'L'<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int max_n = 511, mod = 1000000007;\n\nint t, k;\nlong long dp[max_n], sumdp[max_n], pw[max_n], pw2[max_n], sums[max_n][max_n];\nstring l, r;\n\nlong long sum_dp(int r) {\n return sumdp[r];\n}\n\nvoid get_dp() {\n pw[0] = 1;\n pw2[0] = 1;\n for (int i = 1; i < max_n; ++i) {\n pw[i] = (pw[i - 1] * 10) % mod;\n pw2[i] = (pw2[i - 1] * 8) % mod;\n }\n dp[0] = dp[1] = 0;\n for (int len = 2; len < max_n; ++len) {\n //cout << dp[len - 1] << endl;\n for (int i = 1; i <= len; ++i) {\n for (int j = i + 1; j <= len && j - i <= k; ++j) {\n long long x = (pw2[j - i - 1] * pw[len - j]) % mod;\n int poz = i - k;\n if (poz > 1) {\n //cout << poz - 1 << endl;\n x = (x * pw2[k]) % mod;\n long long y = ((9 * pw[poz - 2] - dp[poz - 1]/*sum_dp(poz - 1)*/) % mod + mod) % mod;\n x = (x * y) % mod;\n } else {\n if (i != 1) {\n x = (x * pw2[i - 2] * 7) % mod;\n }\n }\n //if (len == 6) cout << i << \" \" << j << \" - \" << x << endl;\n x = (x * 4) % mod;\n dp[len] = (dp[len] + x) % mod;\n }\n }\n sumdp[len] = (sumdp[len - 1] + dp[len]) % mod;\n }\n //cout << dp[6] << endl;\n}\n\nbool ok(string s) {\n int last = -11111;\n for (int i = 0; i < s.length(); ++i) {\n if (s[i] == '4' || s[i] == '7') {\n if (i - last <= k) {\n return true;\n }\n last = i;\n }\n }\n return false;\n}\n\nbool happy(int x) {\n return x == 4 || x == 7;\n}\n\nvoid get_all_sum() {\n for (int st = 0; st < max_n; ++st) {\n sums[st][1] = (2 * pw[st] * pw2[0]) % mod;\n for (int cnt = 2; cnt <= st + 1; ++cnt) {\n sums[st][cnt] = (sums[st][cnt - 1] + 2 * pw[st - cnt + 1] * pw2[cnt - 1]) % mod;\n }\n }\n}\n\nlong long sum(int st, int cnt) {\n if (cnt < 0 || st < 0) {\n return 0;\n }\n /*long long res = 0;\n for (int q = 0; q < cnt; ++q) {\n long long x = (2 * pw[st - q] * pw2[q]) % mod;\n res = (res + x) % mod;\n }\n cout << st << \" \" << cnt << \" - \" << sums[st][cnt] << \" res = \" << res << endl;*/\n return sums[st][cnt];\n}\n\nlong long fun(string r) {\n long long res = 0;\n for (int i = 1; i < r.length(); ++i) {\n res = (res + dp[i]) % mod;\n }\n int last = -111111;\n //cout << r << \" - \" << res << endl;\n for (int i = 0; i < r.length(); ++i) {\n //cout << \"i = \" << i << \" \" << r << \" - \" << res << \" last = \" << last << endl;\n int st = 0, fin = r[i] - '0';\n if (i == 0) {\n st = 1;\n }\n for (int j = st; j < fin; ++j) {\n if (happy(j)) {\n if (i - last <= k) {\n res = (res + pw[r.length() - i - 1]) % mod;\n } else {\n //@@@@@@;\n res = (res + sum(r.length() - i - 2, min((int) r.length() - 1, i + k) - i)) % mod;\n int poz = i + k + 1;\n if (poz < r.length()) {\n long long x = (pw2[k] * sum_dp(r.length() - poz)) % mod;\n //cout << \"+=\" << x << endl;\n res = (res + x) % mod;\n }\n }\n } else {\n if (last < 0) {\n res = (res + sum_dp(r.length() - i - 1));\n } else {\n res = (res + sum(r.length() - i - 2, min((int) r.length() - 1, k + last) - i)) % mod;\n int poz = max(i + 1, last + k + 1);\n if (poz < r.length()) {\n long long x = (pw2[poz - i - 1] * sum_dp(r.length() - poz)) % mod;\n //cout << \"+=\" << x << endl;\n res = (res + x) % mod;\n }\n }\n }\n //cout << \" j = \" << j << \" \" << r << \" - \" << res << endl;\n }\n if (happy(fin)) {\n if (i - last <= k) {\n //cout << r << \" !-! \" << res << endl;\n res = (res + 1) % mod;\n long long x = 0;\n for (int j = i + 1; j < r.length(); ++j) {\n x = (x * 10 + r[j] - '0') % mod;\n }\n res = (res + x) % mod;\n return res;\n }\n last = i;\n }\n }\n return res;\n}\n\nlong long solve2() {\n string a = l;\n int res = 0;\n if (ok(r)) {\n ++res;\n }\n while (a != r) {\n //cout << a << endl;\n //for (int i = 1; i < 111111111; ++i);\n if (ok(a)) {\n ++res;\n }\n int poz = a.length() - 1;\n while (poz >= 0 && a[poz] == '9') {\n --poz;\n }\n if (poz == -1) {\n for (int i = 0; i < a.length(); ++i) {\n a[i] = '0';\n }\n a = \"1\" + a;\n } else {\n ++a[poz];\n for (int i = poz + 1; i < a.length(); ++i) {\n a[i] = '0';\n }\n }\n }\n return res;\n}\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n cin >> t >> k;\n get_dp();\n get_all_sum();\n //cout << dp[2] << \" \" << dp[3] << \" \" << dp[4];\n while (t--) {\n cin >> l >> r;\n long long x = fun(r);\n long long y = fun(l);\n long long ans = ((x - y) % mod + mod) % mod;\n if (ok(l)) {\n ans = (ans + 1) % mod;\n }\n cout << ans << endl;\n //cout << ans << \" \" << x << \" \" << y << endl;\n //cout << solve2() << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cd75b26f5763b92402dd091e31f4597d", "src_uid": "5517efa2fc9362fdf342d32adac889f4", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "/**\n * author: tourist\n * created: 30.09.2017 21:16:15 \n**/\n#include \n\nusing namespace std;\n\nlong long C[777][777];\n\nint r, c;\nlong long total;\nlong long best = (long long) 1e18, best_z = -1;\n\nvoid dfs(long long x, long long y, int v1, int v2) {\n long long diff = abs(x - y);\n if (best <= 1 || diff - C[v1][r] * C[v2][r] >= best) {\n return;\n }\n if (v1 == r - 1 && v2 == r - 1) {\n long long diff = abs(x - y);\n if (diff < best) {\n best = diff;\n best_z = x;\n }\n return;\n }\n if (v1 >= r) {\n long long cur1 = C[v1][r] - C[v1 - 1][r];\n long long sum2 = C[v2][r];\n dfs(x, y + cur1 * sum2, v1 - 1, v2);\n }\n if (v2 >= r) {\n long long sum1 = C[v1][r];\n long long cur2 = C[v2][r] - C[v2 - 1][r];\n dfs(x + sum1 * cur2, y, v1, v2 - 1);\n }\n}\n\nchar s[12345];\nint cntA[12345], cntB[12345];\nmap mp;\n\nlong long solve(long long x, long long y, int v1, int v2) {\n long long state = x * 10000 + v1 * 100 + v2;\n if (mp.find(state) != mp.end()) {\n return mp[state];\n }\n long long &res = mp[state];\n long long diff = abs(x - y);\n if (diff - C[v1][r] * C[v2][r] > best) {\n return res = 0;\n }\n if (v1 < r || v2 < r) {\n if (v1 >= cntA[v1 + v2] && v2 >= cntB[v1 + v2]) {\n int sum = v1 + v2;\n v1 -= cntA[sum];\n v2 -= cntB[sum];\n return res = C[v1 + v2][v1]; \n }\n return res = 0;\n }\n res = 0;\n char c = s[v1 + v2 - 1];\n if (c != 'B') {\n long long cur1 = C[v1][r] - C[v1 - 1][r];\n long long sum2 = C[v2][r];\n res += solve(x, y + cur1 * sum2, v1 - 1, v2);\n }\n if (c != 'A') {\n long long sum1 = C[v1][r];\n long long cur2 = C[v2][r] - C[v2 - 1][r];\n res += solve(x + sum1 * cur2, y, v1, v2 - 1);\n }\n return res;\n}\n\nint main() {\n scanf(\"%d %d\", &r, &c);\n for (int i = 0; i <= 2 * (r + c); i++) {\n for (int j = 0; j <= 2 * (r + c); j++) {\n if (j == 0) C[i][j] = 1; else\n if (i == 0) C[i][j] = 0;\n else C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]);\n }\n }\n total = C[r + c][r] * C[r + c][r];\n {\n long long x = 0, y = 0;\n int v1 = r + c, v2 = r + c;\n while (v1 >= r && v2 >= r) {\n if (x > y) {\n long long cur1 = C[v1][r] - C[v1 - 1][r];\n long long sum2 = C[v2][r];\n y += cur1 * sum2;\n v1--;\n } else {\n long long sum1 = C[v1][r];\n long long cur2 = C[v2][r] - C[v2 - 1][r];\n x += sum1 * cur2;\n v2--;\n }\n }\n best = abs(x - y);\n }\n dfs(0, 0, r + c, r + c);\n scanf(\"%s\", s);\n cntA[0] = cntB[0] = 0;\n for (int i = 0; i < 2 * (r + c); i++) {\n cntA[i + 1] = cntA[i] + (s[i] == 'A');\n cntB[i + 1] = cntB[i] + (s[i] == 'B');\n }\n long long ans = solve(0, 0, r + c, r + c);\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e492a72936a9d02de257f81a484e2718", "src_uid": "1b978b5aed4a83a2250bb23cc1ad6f85", "difficulty": 3300.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nlong double pi = atan((long double)1)*4;\n\nclass Point\n{\npublic:\n\tlong double x;\n\tlong double y;\n\tPoint(long double xi, long double yi)\n\t{\t\n\t\tx=xi;\n\t\ty=yi;\n\t};\n\tPoint()\n\t{\n\t};\n};\n\nclass Segment\n{\npublic:\n\tPoint p1;\n\tPoint p2;\n\tSegment(Point p1i, Point p2i)\n\t{\n\t\tp1.x=p1i.x;\n\t\tp1.y=p1i.y;\n\t\tp2.x=p2i.x;\n\t\tp2.y=p2i.y;\n\t};\n\tlong double length() \n\t{ \n\t\treturn sqrt( (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y) ); \n\t}\n};\n\nvoid pos_circle(Point p, long double v, long double t, Point* final_p)\n{\n\tlong double R = sqrt((long double)(p.x*p.x+p.y*p.y));\n\tlong double time_360 = 2*pi*R/v;\n\tlong double ini_angle = atan2((long double)p.y,(long double)p.x) *180 /pi;\n\tlong double final_angle = t*2*pi/time_360;\n\n\tfinal_p->x=cos(final_angle)*R;\n\tfinal_p->y=sin(final_angle)*R;\n}\n\nlong double distance_to_segment (Point p, Segment seg)\n{\n\tSegment a(seg.p1, p);\n\tSegment b(seg.p2, p);\n\tSegment* max;\n\tSegment* min;\n\tif(a.length() > b.length())\n\t{\n\t\tmax = &a;\n\t\tmin = &b;\n\t}\n\telse\n\t{\n\t\tmax = &b;\n\t\tmin = &a;\n\t}\n\n\tif(seg.length()==0 || min->length()==0)\n\t\treturn min->length();\n\n\tif ((min->length() * min->length() + seg.length() * seg.length() - max->length() * max->length()) / (2*min->length()*seg.length()) < 0)\n\t\treturn min->length();\n\t\n\tlong double s = (a.length() + b.length() + seg.length())/2;\n\treturn 2 * sqrt( s * ( s - a.length() ) * (s - b.length() ) * (s - seg.length() ) ) / seg.length();\n\t\n}\n\nvoid tangent_points_to_circle(Point center, long double R, Point p, Point* p1, Point* p2)\n{\n\tSegment s(center, p);\n\tif( s.length() <= R)\n\t\treturn;\n\telse\n\t{\n\t\tlong double ini_angle = atan2(p.y - center.y , p.x - center.x);\n\t\tlong double final_angle1 = ini_angle + acos(R/s.length()) ;\n\t\tlong double final_angle2 = ini_angle - acos(R/s.length()) ;\n\t\tp1->x=cos(final_angle1)*R + center.x;\n\t\tp1->y=sin(final_angle1)*R + center.y;\n\t\tp2->x=cos(final_angle2)*R + center.x;\n\t\tp2->y=sin(final_angle2)*R + center.y;\n\t}\n}\n\n\nint main()\n{\n\tcout.precision(20);\n\tint xp,yp,vp, xs,ys,V, R;\n\t\n\tcin >> xp;\n\tcin >> yp;\n\tcin >> vp;\n\tcin >> xs;\n\tcin >> ys;\n\tcin >> V;\n\tcin >> R;\n\n\tPoint ini_perse(xp,yp);\n\tPoint perse(0,0);\n\tPoint center(0,0);\n\tPoint ship(xs,ys);\n\tlong double time = 0;\n\tlong double time_ship = 0;\n\tlong double range_min,range_max;\n\n\tif(ini_perse.x == ship.x && ini_perse.y == ship.y)\n\t\tcout << time;\n\n\ttime = 100;\n\n\twhile(true)\n\t{\n\t\tpos_circle(ini_perse,vp,time,&perse);\n\t\tSegment s(perse, ship);\n\t\tlong double distance = distance_to_segment(center, s);\n\t\tif(distance >= R)\n\t\t\ttime_ship = s.length()/V;\n\t\telse\n\t\t{\n\t\t\tPoint ship_tang1, ship_tang2, perse_tang1, perse_tang2;\n\t\t\ttangent_points_to_circle(center, R, ship, &ship_tang1, &ship_tang2);\n\t\t\ttangent_points_to_circle(center, R, perse, &perse_tang1, &perse_tang2);\n\t\t\tSegment route1_ship(ship, ship_tang1);\n\t\t\tSegment route2_ship(ship, ship_tang2);\n\t\t\tSegment route1_perse(perse_tang2, perse);\n\t\t\tSegment route2_perse(perse_tang1, perse);\n\n\t\t\tlong double distance1 = route1_ship.length() + abs(atan2(ship_tang1.y, ship_tang1.x) - atan2(perse_tang2.y, perse_tang2.x))*2*R + route1_perse.length();\n\t\t\tlong double distance2 = route2_ship.length() + abs(atan2(ship_tang2.y, ship_tang2.x) - atan2(perse_tang1.y, perse_tang1.x))*2*R + route2_perse.length();\n\t\t\ttime_ship = min(distance1, distance2)/V; \n\t\t}\n\t\tif( time_ship < time )\n\t\t\tbreak;\n\t\telse\n\t\t\ttime *= 2;\n\t} \n\n\trange_max = time;\n\trange_min = 0 ; \n\n\n\twhile(true)\n\t{\n\t\ttime = (range_max + range_min ) / 2;\n\t\t//time = 9.584544103;\n\t\tpos_circle(ini_perse,vp,time,&perse);\n\t\tSegment s(perse, ship);\n\t\tlong double distance = distance_to_segment(center, s);\n\t\tif(distance >= R)\n\t\t\ttime_ship = s.length()/V;\n\t\telse\n\t\t{\n\t\t\tPoint ship_tang1, ship_tang2, perse_tang1, perse_tang2;\n\t\t\ttangent_points_to_circle(center, R, ship, &ship_tang1, &ship_tang2);\n\t\t\ttangent_points_to_circle(center, R, perse, &perse_tang1, &perse_tang2);\n\t\t\tSegment route1_ship(ship, ship_tang1);\n\t\t\tSegment route2_ship(ship, ship_tang2);\n\t\t\tSegment route1_perse(perse_tang2, perse);\n\t\t\tSegment route2_perse(perse_tang1, perse);\n\n\t\t\tlong double distance1 = route1_ship.length() + abs(atan2(ship_tang1.y, ship_tang1.x) - atan2(perse_tang2.y, perse_tang2.x))*R + route1_perse.length();\n\t\t\tlong double distance2 = route2_ship.length() + abs(atan2(ship_tang2.y, ship_tang2.x) - atan2(perse_tang1.y, perse_tang1.x))*R + route2_perse.length();\n\t\t\ttime_ship = min(distance1,distance2)/V; \n\t\t}\n\n\n\t\tif(abs(time-time_ship)<0.0000000001)\n\t\t\tbreak;\n\n\t\tif(time_ship < time)\n\t\t\trange_max = time;\n\t\telse\n\t\t\trange_min = time;\n\t}\n\tcout << time;\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "09436fc31a8ee3bcb8b983c79ed118d8", "src_uid": "e8471556906e5fa3a701842570fa4ee2", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst long long mod = 1e9 + 7;\n\nint a[1000], n;\n\nint64_t fac[1000], inv_fac[1000];\n\nint64_t pw(int64_t x, int64_t y) {\n int64_t res = 1;\n while (y) {\n if (y & 1) {\n res = (res * x) % mod;\n }\n y >>= 1;\n x = (x * x) % mod;\n }\n return res;\n}\n\nvoid dfs(std::vector& is_valid, std::vector>& v,\n int k, int m, int mask, std::vector& sets) {\n if (k == m) {\n is_valid[mask] = sets.size() < 2;\n return;\n }\n dfs(is_valid, v, k + 1, m, mask, sets);\n std::vector new_sets;\n uint64_t new_mask = v[k].first;\n for (auto x : sets) {\n if (new_mask & x) {\n new_mask |= x;\n } else {\n new_sets.push_back(x);\n }\n }\n new_sets.push_back(new_mask);\n dfs(is_valid, v, k + 1, m, (mask | (1 << k)), new_sets);\n}\n\nint main() {\n cin >> n;\n for (int i = 0; i < n; i++) cin >> a[i];\n\n fac[0] = inv_fac[0] = 1;\n for (int i = 1; i < 1000; i++) {\n fac[i] = (fac[i - 1] * i) % mod;\n inv_fac[i] = (inv_fac[i - 1] * pw(i, mod - 2)) % mod;\n }\n\n vector is_root(n, 0);\n vector component_root(n, -1);\n vector> children(n), parents(n), components(n);\n for (int i = 0; i < n; i++) {\n is_root[i] = true;\n for (int j = 0; j < n; j++)\n if (j != i) {\n if (a[i] % a[j] == 0) {\n is_root[i] = false;\n break;\n }\n }\n int child_cnt = 0;\n for (int j = 0; j < n; j++) {\n if (j != i && a[j] % a[i] == 0) {\n child_cnt++;\n }\n }\n if (child_cnt < 2) is_root[i] = false;\n\n // if (is_root[i]) cerr << i << ' ' << a[i] << ' ' << child_cnt << endl;\n }\n\n for (int i = 0; i < n; i++) {\n if (is_root[i] && component_root[i] == -1) {\n component_root[i] = i;\n queue q;\n // cerr << i << ' ';\n q.push(i);\n while (!q.empty()) {\n int x = q.front();\n q.pop();\n for (int j = 0; j < n; j++) {\n if (is_root[j] && component_root[j] == -1) {\n for (int k = 0; k < n; k++) {\n if (!is_root[k] && a[k] % a[x] == 0 && a[k] % a[j] == 0) {\n // if (a[k] == 30) {\n // cerr << \"xxx \" << a[i] << ' ' << a[j] << ' ' << endl;\n //}\n component_root[j] = i;\n q.push(j);\n // cerr << j << ' ';\n break;\n }\n }\n }\n }\n }\n }\n // cerr << endl;\n }\n\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++) {\n if (j != i && a[i] % a[j] == 0) {\n if (is_root[j]) {\n children[j].push_back(i);\n parents[i].push_back(j);\n }\n }\n }\n\n int64_t res = 1;\n int tot_cnt = 0;\n for (int i = 0; i < n; i++) {\n if (is_root[i] && component_root[i] == i) {\n std::vector i_children, i_roots;\n for (int j = 0; j < n; j++) {\n if ((is_root[j] && component_root[j] == i)) {\n i_roots.push_back(j);\n } else if (!is_root[j] && parents[j].size() > 0 &&\n component_root[parents[j][0]] == i) {\n i_children.push_back(j);\n }\n }\n\n std::cerr << a[i] << endl;\n for (auto x : i_roots) {\n std::cerr << a[x] << ' ';\n }\n cerr << endl;\n for (auto x : i_children) {\n cerr << a[x] << ' ';\n }\n std::cerr << endl;\n std::cerr << i_children.size() << \" ---\" << endl;\n\n int children_cnt = i_children.size();\n map child_cnts_map;\n for (int x : i_children) {\n uint64_t key = 0;\n for (auto k : parents[x]) {\n key |= (1ll << k);\n }\n child_cnts_map[key]++;\n }\n cerr << child_cnts_map.size() << endl;\n\n int m = child_cnts_map.size();\n std::vector> child_cnts(child_cnts_map.begin(),\n child_cnts_map.end());\n sort(child_cnts.begin(), child_cnts.end(),\n [](const auto& a, const auto& b) {\n return __builtin_popcountll(a.first) >\n __builtin_popcountll(b.first);\n });\n int max_m = 0;\n for (; max_m < m; max_m++)\n if (__builtin_popcountll(child_cnts[max_m].first) == 1) break;\n\n /* auto is_status_valid = [&child_cnts, &m](uint64_t bitmask) -> bool {\n vector regions;\n vector new_regions;\n for (int i = 0; i < m; i++)\n if (1 & (bitmask >> i)) {\n new_regions.clear();\n uint64_t new_mask = child_cnts[i].first;\n for (auto r : regions) {\n if ((r & child_cnts[i].first)) {\n new_mask |= r;\n } else\n new_regions.push_back(r);\n }\n new_regions.push_back(new_mask);\n regions.swap(new_regions);\n }\n return regions.size() <= 1;\n };*/\n // vector> is_valid(1 << m);\n // int max_connection = 0;\n // for (int i = 0; i < m; i++) {\n //}\n\n vector is_valid(1 << m);\n vector _v;\n dfs(is_valid, child_cnts, 0, m, 0, _v);\n\n /*cout << child_cnts[0].first << \"xxxxxxxxx\"*/\n // for (int i = 0; i < (1 << m); i++) {\n // if (is_valid[i]) cerr << i << ' ';\n //}\n\n cerr << time(NULL) << endl;\n\n vector p(1 << m);\n vector sum(1 << m);\n\n p[(1 << m) - 1] = 1;\n sum[(1 << m) - 1] = 0;\n for (int bitmask = (1 << m) - 1; bitmask > 0; bitmask--) {\n if (p[bitmask]) {\n for (int k = 0; k < m; k++)\n if ((1 & (bitmask >> k))) {\n int new_sum = sum[bitmask ^ (1 << k)] =\n sum[bitmask] + child_cnts[k].second;\n\n int new_bitmask = bitmask ^ (1 << k);\n if (is_valid[new_bitmask]) {\n int add = child_cnts[k].second;\n p[new_bitmask] +=\n p[bitmask] *\n (((fac[new_sum - 1] * inv_fac[sum[bitmask]]) % mod * add) %\n mod) %\n mod;\n p[new_bitmask] %= mod;\n }\n }\n }\n }\n cerr << time(NULL) << endl;\n\n res *= p[0];\n res %= mod;\n res *= fac[children_cnt - 1 + tot_cnt];\n res %= mod;\n res *= inv_fac[children_cnt - 1];\n res %= mod;\n res *= inv_fac[tot_cnt];\n res %= mod;\n tot_cnt += children_cnt - 1;\n }\n }\n\n cout << res << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cc1554d6c95ab94415e5a1169afecec5", "src_uid": "c8d43a60ddc0a7b98a7269dc3a2478dc", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "#define DEBUG 0\n\n#include \nusing namespace std;\n\n#if DEBUG\n// basic debugging macros\nint __i__,__j__;\n#define printLine(l) for(__i__=0;__i__\n _Debug& operator,(T val) {\n cout << val << endl;\n return *this;\n }\n};\n#define debug _Debug(),\n#else\n#define printLine(l)\n#define printLine2(l,c)\n#define printVar(n)\n#define printArr(a,l)\n#define print2dArr(a,r,c)\n#define print2dArr2(a,r,c,l)\n#define debug\n#endif\n\n// define\n#define MAX_VAL 999999999\n#define MAX_VAL_2 999999999999999999LL\n#define EPS 1e-6\n#define mp make_pair\n#define pb push_back\n\n// typedef\ntypedef unsigned int UI;\ntypedef long long int LLI;\ntypedef unsigned long long int ULLI;\ntypedef unsigned short int US;\ntypedef pair pii;\ntypedef pair plli;\ntypedef vector vi;\ntypedef vector vlli;\ntypedef vector vpii;\ntypedef vector vplli;\n\n// ---------- END OF TEMPLATE ----------\n#define MOD 1000000007\n\nint inv(int n) {\n int e = MOD-2,r = 1;\n while (e > 0) {\n if (e & 1) r = ((LLI) r*n) % MOD;\n e >>= 1;\n n = ((LLI) n*n) % MOD;\n }\n return r;\n}\nint P[7][7];\nint a[128],b[8][128],c[8];\nvpii v[7],v2[3];\nvector > v3,v4;\nint main() {\n int i,j;\n int n;\n scanf(\"%d\",&n);\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) scanf(\"%d\",&P[i][j]);\n }\n for (i = n; i < 7; i++) P[i][i] = 100;\n\n int k,l,m;\n int inv100 = inv(100);\n for (i = 0; i < 7; i++) {\n for (j = 0; j < 128; j++) {\n LLI p = 1;\n for (k = 0; k < 7; k++) {\n if (j & (1 << k)) p *= ((LLI) P[k][i]*inv100) % MOD,p %= MOD;\n else p *= ((LLI) (100-P[k][i])*inv100) % MOD,p %= MOD;\n }\n v[i].pb(mp(j,p));\n }\n }\n for (i = 0; i < 128; i++) {\n int x = 0;\n for (j = 0; j < 7; j++) {\n if (i & (1 << j)) x++;\n }\n a[i] = c[x]++,b[x][a[i]] = i;\n }\n for (i = 0; i < 6; i += 2) {\n vpii temp;\n for (j = 0; j < v[i].size(); j++) {\n for (k = 0; k < v[i+1].size(); k++) {\n int poss = 0;\n for (l = 0; l < 7; l++) {\n for (m = 0; m < 7; m++) {\n if (l != m) {\n if ((v[i][j].first & (1 << l)) && (v[i+1][k].first & (1 << m))) poss |= (1 << a[(1 << l) | (1 << m)]);\n }\n }\n }\n temp.pb(mp(poss,((LLI) v[i][j].second*v[i+1][k].second) % MOD));\n }\n }\n sort(temp.begin(),temp.end());\n for (j = 0; j < temp.size(); j++) {\n if (v2[i/2].empty() || (temp[j].first != v2[i/2].back().first)) v2[i/2].pb(temp[j]);\n else v2[i/2].back().second += temp[j].second,v2[i/2].back().second %= MOD;\n }\n }\n vector > temp;\n for (i = 0; i < v2[0].size(); i++) {\n for (j = 0; j < v2[1].size(); j++) {\n LLI poss = 0;\n for (k = 0; k < 21; k++) {\n for (l = 0; l < 21; l++) {\n if ((b[2][k] & b[2][l]) == 0) {\n if ((v2[0][i].first & (1 << k)) && (v2[1][j].first & (1 << l))) poss |= (1LL << a[b[2][k] | b[2][l]]);\n }\n }\n }\n temp.pb(mp(poss,((LLI) v2[0][i].second*v2[1][j].second) % MOD));\n }\n }\n sort(temp.begin(),temp.end());\n for (j = 0; j < temp.size(); j++) {\n if (v3.empty() || (temp[j].first != v3.back().first)) v3.pb(temp[j]);\n else v3.back().second += temp[j].second,v3.back().second %= MOD;\n }\n temp.clear();\n for (i = 0; i < v2[2].size(); i++) {\n for (j = 0; j < v[6].size(); j++) {\n LLI poss = 0;\n for (k = 0; k < 21; k++) {\n for (l = 0; l < 7; l++) {\n if ((b[2][k] & b[1][l]) == 0) {\n if ((v2[2][i].first & (1 << k)) && (v[6][j].first & (1 << l))) poss |= (1LL << a[b[2][k] | b[1][l]]);\n }\n }\n }\n temp.pb(mp(poss,((LLI) v2[2][i].second*v[6][j].second) % MOD));\n }\n }\n sort(temp.begin(),temp.end());\n for (j = 0; j < temp.size(); j++) {\n if (v4.empty() || (temp[j].first != v4.back().first)) v4.pb(temp[j]);\n else v4.back().second += temp[j].second,v4.back().second %= MOD;\n }\n int ans = 0;\n for (i = 0; i < v3.size(); i++) {\n LLI r = 0;\n for (j = 0; j < 35; j++) {\n if (v3[i].first & (1LL << j)) r |= (1LL << (34-j));\n }\n for (j = 0; j < v4.size(); j++) {\n if ((r & v4[j].first) > 0) ans += ((LLI) v3[i].second*v4[j].second) % MOD,ans %= MOD;\n }\n }\n printf(\"%d\\n\",ans);\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "59f9c721935427708af12857b26e2f49", "src_uid": "ccfa3251dbf956761609f1e5ed771e58", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef pairP;\ntypedef vector

V;\nconst int N=1e5+5;\nint n,m,u,v,w,i;\nV e[N],ev[N];\ninline V stre(V v,int l){\n\tstatic P a[N];int w=0;\nif(v.size()>5)\n++l,--l;\n\tfor(auto u:v){\n\t\tint x,y,xx,yy;tie(x,y)=u;\n\t\tfor(;tie(xx,yy)=a[w],w && yy<0 && y>0 && xx>=x-l;){\n\t\t\tif(y+yy<0)a[w].second+=y,y=0;\n\t\t\t\telse if(y+yy>0)y+=yy,--w;else --w,y=0;\n\t\t\tif(!y)break;\n\t\t}\n\t\tif(y)a[++w]={y>0?x-l:x+l,y};\n\t}\n\treturn V(a+1,a+w+1);\n}\ninline V mer(V a,V b){\n\tstatic P c[N];int w=0,i=0,j=0;\n\tfor(;ifirst==u.first){\n\t\tit->second+=u.second;\n\t\tif(!it->second)v.erase(it);\n\t}else v.insert(it,u);\n}\ninline int getv(const V&v,int k){\n\tint ans=0;\n\tfor(auto u:v)if(u.first<=k)ans+=u.second;\n\treturn ans;\n}\nV dfs(int x,int fa){\n\tV vv;\n\tfor(auto u:e[x]){\n\t\tint y,l;tie(y,l)=u;\n\t\tif(y==fa)continue;\n\t\tvv=mer(vv,stre(dfs(y,x),2*l-1));\n\t}\n\tfor(auto&u:ev[x])u.second+=getv(vv,u.first);\n\tvv=stre(vv,1);\n\tfor(auto u:ev[x]){\n\t\tint x,y,z;tie(x,y)=u;z=getv(vv,x);\n\t\tif(y>z)ins(vv,{x,y-z}),ins(vv,{x+1,z-y});\n\t}\n\treturn vv;\n}\nint main(){\n\tios::sync_with_stdio(0);cin.tie(0);\n\tcin>>n;\n\tfor(i=1;i>u>>v>>w;\n\t\te[u].push_back({v,w});\n\t\te[v].push_back({u,w});\n\t}\n\tcin>>m;\n\tfor(i=1;i<=m;++i){\n\t\tcin>>w>>v>>u;\n\t\tev[u].push_back({w*2,v});\n\t}\n\tauto z=dfs(1,0);int ans=0,zz=0;\n\tfor(auto U:z)ans=max(ans,zz+=U.second);\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define li \tlong long int\n#define rep(i,to)\tfor(li i=0;i<((li)(to));++i)\n#define pb \tpush_back\n#define sz(v) \t((li)(v).size())\n#define bit(n) \t(1ll<<(li)(n))\n#define all(vec)\t(vec).begin(),(vec).end()\n#define each(i,c)\t\\\nfor(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)\ntypedef pair PI;\n#define MP make_pair\n#define F first\n#define S second\n\n\n\n\n\n\n///////////////////////////////////////////////////////////\n////// \"multiple precision integer\" ////////\n////// \"irrational class\" ////////\n////// these classes have 680 lines. ////////\n////// my main answer may be below this class. ////////\n///////////////////////////////////////////////////////////\n\nclass MPI{\n#define MPI_DIGIT 6\n#define MPI_MAX 1000000\npublic:\n\tvector

  • MPI_VALUE;\n\tbool MPI_SIGN;\n\t\n\tMPI(const string &mpi_s){\n\t\tMPI_SIGN=false;\n\t\tif(sz(mpi_s)){\n\t\t\tif(mpi_s[0]=='-') MPI_SIGN=true;\n\t\t\tfor(li i=sz(mpi_s)-1;((mpi_s[0]=='-')?1:0)<=i;i-=MPI_DIGIT){\n\t\t\t\tli mpi_sum=0;\n\t\t\t\tli mpi_base=1;\n\t\t\t\trep(j,MPI_DIGIT)if(((mpi_s[0]=='-')?1:0)<=i-j){\n\t\t\t\t\tmpi_sum+=(mpi_s[i-j]-'0')*mpi_base;\n\t\t\t\t\tmpi_base*=10;\n\t\t\t\t}\n\t\t\t\tMPI_VALUE.pb(mpi_sum);\n\t\t\t}\n\t\t}\n\t\tmpi_reform(*this);\n\t}\n\t\n\tMPI(const vector
  • &mpi_vec){\n\t\tMPI_SIGN=false;\n\t\tMPI_VALUE=mpi_vec;\n\t\tmpi_reform(*this);\n\t}\n\t\n\t\n\tMPI(int mpi_val){\n\t\tMPI_SIGN=false;\n\t\tif(mpi_val<0){ mpi_val=-mpi_val; MPI_SIGN=true; }\n\t\twhile(mpi_val){\n\t\t\tMPI_VALUE.pb(mpi_val%MPI_MAX);\n\t\t\tmpi_val/=MPI_MAX;\n\t\t}\n\t\tmpi_reform(*this);\n\t}\n\n\t\n\tMPI(li mpi_val){\n\t\tMPI_SIGN=false;\n\t\tif(mpi_val<0){ mpi_val=-mpi_val; MPI_SIGN=true; }\n\t\twhile(mpi_val){\n\t\t\tMPI_VALUE.pb(mpi_val%MPI_MAX);\n\t\t\tmpi_val/=MPI_MAX;\n\t\t}\n\t\tmpi_reform(*this);\n\t}\n\t\n\tMPI(bool mpi_need0,bool mpi_need1){\n\t\tMPI_SIGN=false;\n\t}\n\n\tMPI(){\n\t\tMPI_SIGN=false;\n\t\tMPI_VALUE.pb(0);\n\t}\n\t\n\tstring to_string() const{\n\t\tstring mpi_res=\"\";\n\t\tli mpi_p10[MPI_DIGIT+1];\n\t\trep(i,MPI_DIGIT+1) mpi_p10[i]=(i)?(mpi_p10[i-1]*10):1;\n\t\tfor(li i=sz(MPI_VALUE)-1;0<=i;i--)rep(j,MPI_DIGIT){\n\t\t\tli mpi_tmp=(MPI_VALUE[i]%mpi_p10[MPI_DIGIT-j])/mpi_p10[MPI_DIGIT-j-1];\n\t\t\tif(sz(mpi_res) || mpi_tmp) mpi_res+=string(1,'0'+mpi_tmp);\n\t\t}\n\t\tif(sz(mpi_res)==0) mpi_res+=\"0\";\n\t\telse if(MPI_SIGN) mpi_res=\"-\"+mpi_res;\n\t\treturn mpi_res;\n\t}\n\t\n\tli to_long() const{\n\t\tli mpi_res=0;\n\t\tli mpi_base=1;\n\t\trep(i,sz(MPI_VALUE)){\n\t\t\tmpi_res+=MPI_VALUE[i]*mpi_base;\n\t\t\tmpi_base*=MPI_MAX;\n\t\t}\n\t\tif(MPI_SIGN) mpi_res=-mpi_res;\n\t\treturn mpi_res;\n\t}\n\t\n\tli size() const{\n\t\tli mpi_res=(sz(MPI_VALUE)-1)*MPI_DIGIT;\n\t\tli mpi_tmp=MPI_VALUE.back();\n\t\twhile(mpi_tmp){ mpi_res++; mpi_tmp/=10; }\n\t\treturn mpi_res;\n\t}\n\t\n\tstatic MPI mpi_abs_add(const MPI &mpi0,const MPI &mpi1){\n\t\tMPI mpi_res(false,false);\n\t\tli carry=0;\n\t\trep(i,max(sz(mpi0.MPI_VALUE),sz(mpi1.MPI_VALUE))){\n\t\t\tli mpi_t0=(i(sz(mpi0.MPI_VALUE)+sz(mpi1.MPI_VALUE),0);\n\t\trep(i,sz(mpi0.MPI_VALUE))if(mpi0.MPI_VALUE[i]){\n\t\t\trep(j,sz(mpi1.MPI_VALUE)){\n\t\t\t\tmpi_res.MPI_VALUE[i+j]+=mpi0.MPI_VALUE[i]*mpi1.MPI_VALUE[j];\n\t\t\t}\n\t\t}\n\t\tmpi_add_mul_reform(mpi_res);\n\t\treturn mpi_res;\n\t}\t\n\t\n\tMPI operator+(const MPI &mpi_var)const{\n\t\tbool b0=MPI_SIGN,b1=mpi_var.MPI_SIGN;\n\t\tif(!b0 &&!b1) return mpi_abs_add(*this,mpi_var);\n\t\tif(!b0 && b1) return mpi_abs_sub(*this,mpi_var);\n\t\tif( b0 &&!b1) return mpi_abs_sub(mpi_var,*this);\n\t\tMPI mpi_res=mpi_abs_add(*this,mpi_var);\n\t\tmpi_res.MPI_SIGN= !mpi_res.MPI_SIGN;\n\t\treturn mpi_res;\n\t}\n\t\n\tMPI operator-(const MPI &mpi_var)const{\n\t\tbool b0=MPI_SIGN,b1=mpi_var.MPI_SIGN;\n\t\tif(!b0&&!b1) return mpi_abs_sub(*this,mpi_var);\n\t\tif(!b0&& b1) return mpi_abs_add(*this,mpi_var);\n\t\tif( b0&& b1) return mpi_abs_sub(mpi_var,*this);\n\t\tMPI mpi_res=mpi_abs_add(*this,mpi_var);\n\t\tmpi_res.MPI_SIGN= !mpi_res.MPI_SIGN;\n\t\treturn mpi_res;\n\t}\n\t\n\tMPI operator*(const MPI &mpi_var)const{\n\t\tbool b0=MPI_SIGN,b1=mpi_var.MPI_SIGN;\n\t\tif( b0&& b1) return mpi_abs_mul(*this,mpi_var);\n\t\tif(!b0&&!b1) return mpi_abs_mul(*this,mpi_var);\n\t\tMPI mpi_res=mpi_abs_mul(*this,mpi_var);\n\t\tmpi_res.MPI_SIGN= !mpi_res.MPI_SIGN;\n\t\treturn mpi_res;\n\t}\n\t\n\tfriend std::ostream& operator<<(std::ostream& os,const MPI &mpi_var){\n\t\tos<>(std::istream& is,MPI &mpi_var){\n\t\tstring mpi_str;\n\t\tis>>mpi_str;\n\t\tmpi_var=MPI(mpi_str);\n\t\treturn is;\n\t}\n\t\n\t\n\n\tstatic void mpi_subst(MPI &mpi_from,const MPI &mpi_base,li mpi_cons,li mpi_shift){\n\t\tli carry=0;\n\t\tfor(li i=0;i+mpi_shift(sz(mpi_rem.MPI_VALUE),0);\n\t\tli mpi_cons=abs(mpi_num.to_long()),carry=0;\n\t\tfor(li i=sz(mpi_rem.MPI_VALUE)-1;0<=i;i--){\n\t\t\tmpi_rem.MPI_VALUE[i]+=carry*MPI_MAX;\n\t\t\tcarry=mpi_rem.MPI_VALUE[i]%mpi_cons;\n\t\t\tmpi_ans.MPI_VALUE[i]=mpi_rem.MPI_VALUE[i]/mpi_cons;\n\t\t}\n\t\tif(!is_div) return MPI(carry);\n\t\tmpi_reform(mpi_ans);\n\t\treturn mpi_ans;\n\t}\n\n\tstatic MPI mpi_abs_div(const MPI &mpi_den,const MPI &mpi_num,bool is_div){\n\t\tif(mpi_abs_gt(mpi_num,MPI_MAX)) return mpi_abs_div_small(mpi_den,mpi_num,is_div);\n\t\tMPI mpi_ans(0);\n\t\tMPI mpi_rem(mpi_den.MPI_VALUE);\n\t\tmpi_ans.MPI_VALUE=vector
  • (sz(mpi_rem.MPI_VALUE),0);\n\t\tli mpi_num_pos=sz(mpi_num.MPI_VALUE)-1;\n\t\tli mpi_num_n=mpi_num.MPI_VALUE[mpi_num_pos];\n\n\t\tif(mpi_num_n*MPI_MAX<1000000000000000000ll/MPI_MAX && 1<=mpi_num_pos){\n\t\t\tmpi_num_n=mpi_num_n*MPI_MAX+mpi_num.MPI_VALUE[--mpi_num_pos];\n\t\t}\n\n\t\twhile(!mpi_abs_gt(mpi_rem,mpi_num)){\n\t\t\tli mpi_rem_pos=sz(mpi_rem.MPI_VALUE)-1;\n\t\t\tli mpi_rem_n=mpi_rem.MPI_VALUE[mpi_rem_pos];\n\t\t\twhile(mpi_rem_nMPI_VALUE)==1 && sz(mpi_var.MPI_VALUE)==1){\n\t\t\tif(this->MPI_VALUE.back()==0 && mpi_var.MPI_VALUE.back()==0) return true;\n\t\t}\n\t\tif( b0&&!b1) return true;\n\t\tif(!b0&& b1) return false;\n\t}\n\t\n\tbool operator>(const MPI &mpi_var)const{\n\t\tbool b0=MPI_SIGN,b1=mpi_var.MPI_SIGN;\n\t\tif(!b0&&!b1) return mpi_abs_sl(*this,mpi_var);\n\t\tif( b0&& b1) return mpi_abs_gt(*this,mpi_var);\n\t\tif(sz(this->MPI_VALUE)==1 && sz(mpi_var.MPI_VALUE)==1){\n\t\t\tif(this->MPI_VALUE.back()==0 && mpi_var.MPI_VALUE.back()==0) return true;\n\t\t}\n\t\tif( b0&&!b1) return false;\n\t\tif(!b0&& b1) return true;\n\t}\n\t\n\tbool operator==(const MPI &mpi_var)const{\n\t\tbool b0=MPI_SIGN,b1=mpi_var.MPI_SIGN;\n\t\tif( b0&& b1) return mpi_abs_eq(*this,mpi_var);\n\t\tif(!b0&&!b1) return mpi_abs_eq(*this,mpi_var);\n\t\tif(sz(this->MPI_VALUE)==1 && sz(mpi_var.MPI_VALUE)==1){\n\t\t\tif(this->MPI_VALUE.back()==0 && mpi_var.MPI_VALUE.back()==0) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tbool operator>=(const MPI &mpi_var)const{ return !(*thismpi_var); }\n\tbool operator!=(const MPI &mpi_var)const{ return !(*this==mpi_var); }\n\tvoid operator+=(const MPI &mpi_var){ *this=*this+mpi_var; }\n\tvoid operator-=(const MPI &mpi_var){ *this=*this-mpi_var; }\n\tvoid operator*=(const MPI &mpi_var){ *this=*this*mpi_var; }\n\tvoid operator/=(const MPI &mpi_var){ *this=*this/mpi_var; }\n\tvoid operator%=(const MPI &mpi_var){ *this=*this%mpi_var; }\n\tfriend bool operator>(li mpi_li,const MPI &mpi_var){ return MPI(mpi_li)>mpi_var; }\n\tfriend bool operator<(li mpi_li,const MPI &mpi_var){ return MPI(mpi_li)=(li mpi_li,const MPI &mpi_var){ return MPI(mpi_li)>=mpi_var; }\n\tfriend bool operator<=(li mpi_li,const MPI &mpi_var){ return MPI(mpi_li)<=mpi_var; }\n\tfriend bool operator!=(li mpi_li,const MPI &mpi_var){ return MPI(mpi_li)!=mpi_var;}\n\tfriend bool operator==(li mpi_li,const MPI &mpi_var){ return MPI(mpi_li)==mpi_var;}\n\t\n\tMPI operator--(){ *this=*this-MPI(1); return *this; }\n\tMPI operator++(){ *this=*this+MPI(1); return *this; }\n\tMPI operator++(int mpi_i){ \n\t\tMPI mpi_res=*this; \n\t\t*this=*this+MPI(1);\n\t\treturn mpi_res; \n\t}\n\tMPI operator--(int mpi_i){\n\t\tMPI mpi_res=*this;\n\t\t*this=*this-MPI(1);\n\t\treturn mpi_res;\n\t}\n\tMPI operator-(){ \n\t\tMPI mpi_res=*this;\n\t\tmpi_res.MPI_SIGN=!mpi_res.MPI_SIGN;\n\t\treturn mpi_res;\n\t}\n\t\n\tstatic bool mpi_abs_gt(const MPI &mpi0,const MPI &mpi1){\n\t\tif(sz(mpi0.MPI_VALUE)==sz(mpi1.MPI_VALUE)){\n\t\t\tfor(li i=sz(mpi0.MPI_VALUE)-1;0<=i;i--){\n\t\t\t\tif(mpi0.MPI_VALUE[i]!=mpi1.MPI_VALUE[i]){\n\t\t\t\t\treturn mpi0.MPI_VALUE[i]mpi1.MPI_VALUE[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn sz(mpi0.MPI_VALUE)>sz(mpi1.MPI_VALUE);\n\t}\n\t\n\tstatic bool mpi_abs_eq(const MPI &mpi0,const MPI &mpi1){\n\t\tif(sz(mpi0.MPI_VALUE)!=sz(mpi1.MPI_VALUE)) return false;\n\t\trep(i,sz(mpi0.MPI_VALUE)){\n\t\t\tif(mpi0.MPI_VALUE[i]!=mpi1.MPI_VALUE[i]) return false;\n\t\t}\n\t\treturn true;\n\t}\n\t\t\nprivate:\n\t\n\tstatic void mpi_reform_vec(vector
  • &mpi_vec){\n\t\tif(sz(mpi_vec)==0) mpi_vec.pb(0);\n\t\twhile(1 &mpi_vec){\n\t\tli carry=0;\n\t\trep(i,sz(mpi_vec)){\n\t\t\tmpi_vec[i]+=carry;\n\t\t\tcarry=mpi_vec[i]/MPI_MAX;\n\t\t\tmpi_vec[i]%=MPI_MAX;\n\t\t}\n\t\tmpi_vec.pb(carry);\n\t\tmpi_reform_vec(mpi_vec);\n\t}\n\t\n\tstatic void mpi_reform(MPI &mpi_var){\n\t\tmpi_reform_vec(mpi_var.MPI_VALUE);\n\t\tif(sz(mpi_var.MPI_VALUE)==1 && mpi_var.MPI_VALUE[0]==0) mpi_var.MPI_SIGN=false;\n\t}\n\t\n\tstatic void mpi_add_mul_reform(MPI &mpi_var){\n\t\tmpi_add_mul_reform_vec(mpi_var.MPI_VALUE);\n\t\tif(sz(mpi_var.MPI_VALUE)==1 && mpi_var.MPI_VALUE[0]==0) mpi_var.MPI_SIGN=false;\n\t}\n};\n\n\n\n\n\n\n\n\nclass IRN{\npublic:\n\tMPI IRN_DEN;\n\tMPI IRN_NUM;\n\tbool IRN_SIGN;\n\t\t\n\tIRN(){\n\t\tIRN_DEN=0;\n\t\tIRN_NUM=1;\n\t\tIRN_SIGN=false;\n\t}\n\tIRN(string irn_str0,string irn_str1){\n\t\tIRN_DEN=irn_str0;\n\t\tIRN_NUM=irn_str1;\n\t\tIRN_SIGN=false;\n\t\tif(IRN_DEN<0) IRN_SIGN=!IRN_SIGN;\n\t\tif(IRN_NUM<0) IRN_SIGN=!IRN_SIGN;\n\t\tIRN_DEN.MPI_SIGN=false;\n\t\tIRN_NUM.MPI_SIGN=false;\n\t\tirn_reduct(*this);\n\t}\n\tIRN(li irn_li0,li irn_li1){\n\t\tIRN_DEN=irn_li0;\n\t\tIRN_NUM=irn_li1;\n\t\tIRN_SIGN=false;\n\t\tif(IRN_DEN<0) IRN_SIGN=!IRN_SIGN;\n\t\tif(IRN_NUM<0) IRN_SIGN=!IRN_SIGN;\n\t\tIRN_DEN.MPI_SIGN=false;\n\t\tIRN_NUM.MPI_SIGN=false;\n\t\tirn_reduct(*this);\n\t}\n\tIRN(li irn_li){\n\t\tIRN_DEN=irn_li;\n\t\tIRN_NUM=1;\n\t\tIRN_SIGN=false;\n\t}\n\tIRN(string irn_str){\n\t\tIRN_DEN=irn_str;\n\t\tIRN_NUM=1;\n\t\tIRN_SIGN=false;\n\t}\n\t\n\tstring to_string() const{ \n\t\tif(IRN_SIGN && IRN_DEN!=0) return \"-\"+IRN_DEN.to_string()+\"/\"+IRN_NUM.to_string();\n\t\treturn IRN_DEN.to_string()+\"/\"+IRN_NUM.to_string();\n\t}\n\t\n\tstatic MPI irn_mpi_gcd(MPI mpi0,MPI mpi1){\n\t\tif(mpi1==0) return 0;\n\t\tif(mpi0%mpi1==0) return mpi1;\n\t\treturn irn_mpi_gcd(mpi1,mpi0%mpi1);\n\t}\n\t\t\t\t\n\tvoid irn_reduct(IRN &irn_var)const{\n\t\tif(irn_var.IRN_DEN==0){ irn_var.IRN_NUM=1; irn_var.IRN_SIGN=false; return ; }\n\t\tif(irn_var.IRN_DEN.MPI_SIGN) irn_var.IRN_SIGN=!irn_var.IRN_SIGN;\n\t\tif(irn_var.IRN_NUM.MPI_SIGN) irn_var.IRN_SIGN=!irn_var.IRN_SIGN;\n\t\tirn_var.IRN_DEN.MPI_SIGN=false;\n\t\tirn_var.IRN_NUM.MPI_SIGN=false;\n\t\tMPI irn_t=irn_mpi_gcd(irn_var.IRN_NUM,irn_var.IRN_DEN);\n\t\tirn_var.IRN_NUM/=irn_t;\n\t\tirn_var.IRN_DEN/=irn_t;\n\t}\n\t\n\tIRN irn_mul(const IRN &irn0,const IRN &irn1)const{\n\t\tIRN irn_res(1,1);\n\t\tMPI irn_t=irn_mpi_gcd(irn0.IRN_DEN,irn1.IRN_NUM);\n\t\tirn_res.IRN_DEN=irn0.IRN_DEN/irn_t;\n\t\tirn_res.IRN_NUM=irn1.IRN_NUM/irn_t;\n\t\tirn_t=irn_mpi_gcd(irn0.IRN_NUM,irn1.IRN_DEN);\n\t\tirn_res.IRN_DEN*=irn1.IRN_DEN/irn_t;\n\t\tirn_res.IRN_NUM*=irn0.IRN_NUM/irn_t;\n\t\tif(irn1.IRN_SIGN) irn_res.IRN_SIGN=!irn_res.IRN_SIGN;\n\t\tif(irn0.IRN_SIGN) irn_res.IRN_SIGN=!irn_res.IRN_SIGN;\n\t\tif(irn_res.IRN_DEN==0){ irn_res.IRN_NUM=1; irn_res.IRN_SIGN=false; }\n\t\treturn irn_res;\n\t}\n\t\n\tIRN irn_div(const IRN &irn0,const IRN &irn1)const{\n\t\tIRN irn_res(1,1);\n\t\tMPI irn_t=irn_mpi_gcd(irn0.IRN_DEN,irn1.IRN_DEN);\n\t\tirn_res.IRN_DEN=irn0.IRN_DEN/irn_t;\n\t\tirn_res.IRN_NUM=irn1.IRN_DEN/irn_t;\n\t\tirn_t=irn_mpi_gcd(irn0.IRN_NUM,irn1.IRN_NUM);\n\t\tirn_res.IRN_DEN*=irn1.IRN_NUM/irn_t;\n\t\tirn_res.IRN_NUM*=irn0.IRN_NUM/irn_t;\n\t\tif(irn1.IRN_SIGN) irn_res.IRN_SIGN=!irn_res.IRN_SIGN;\n\t\tif(irn0.IRN_SIGN) irn_res.IRN_SIGN=!irn_res.IRN_SIGN;\n\t\tif(irn_res.IRN_DEN==0){ irn_res.IRN_NUM=1; irn_res.IRN_SIGN=false; }\n\t\treturn irn_res;\n\t}\n\t\n\tIRN irn_abs_add(const IRN &irn0,const IRN &irn1)const{\n\t\tIRN irn_res(0);\n\t\tif(irn0.IRN_NUM==irn1.IRN_NUM){\n\t\t\tirn_res.IRN_DEN=irn0.IRN_DEN+irn1.IRN_DEN;\n\t\t\tirn_res.IRN_NUM=irn0.IRN_NUM;\n\t\t\tirn_reduct(irn_res);\n\t\t\treturn irn_res;\n\t\t}\n\t\tirn_res.IRN_NUM=irn0.IRN_NUM*irn1.IRN_NUM;\n\t\tirn_res.IRN_DEN=irn0.IRN_DEN*irn1.IRN_NUM;\n\t\tirn_res.IRN_DEN+=irn1.IRN_DEN*irn0.IRN_NUM;\n\t\tirn_reduct(irn_res);\n\t\treturn irn_res;\n\t}\n\t\n\tIRN irn_abs_sub(const IRN &irn0,const IRN &irn1)const{\n\t\tIRN irn_res(0);\n\t\tif(irn0.IRN_NUM==irn1.IRN_NUM){\n\t\t\tirn_res.IRN_DEN=irn0.IRN_DEN-irn1.IRN_DEN;\n\t\t\tirn_res.IRN_NUM=irn0.IRN_NUM;\n\t\t\tirn_reduct(irn_res);\n\t\t\treturn irn_res;\n\t\t}\n\t\tirn_res.IRN_NUM=irn0.IRN_NUM*irn1.IRN_NUM;\n\t\tirn_res.IRN_DEN=irn0.IRN_DEN*irn1.IRN_NUM;\n\t\tirn_res.IRN_DEN-=irn1.IRN_DEN*irn0.IRN_NUM;\n\t\tirn_reduct(irn_res);\n\t\treturn irn_res;\n\t}\n\t\n\tIRN irn_add(const IRN &irn0,const IRN &irn1)const{\n\t\tif( irn0.IRN_SIGN&& irn1.IRN_SIGN){\n\t\t\tIRN irn_res=irn_abs_add(irn0,irn1);\n\t\t\tirn_res.IRN_SIGN=!irn_res.IRN_SIGN;\n\t\t\treturn irn_res;\n\t\t}\n\t\tif(!irn0.IRN_SIGN&&!irn1.IRN_SIGN) return irn_abs_add(irn0,irn1);\n\t\tIRN irn_res;\n\t\tif(!irn0.IRN_SIGN&& irn1.IRN_SIGN) irn_res=irn_abs_sub(irn0,irn1);\n\t\tif( irn0.IRN_SIGN&&!irn1.IRN_SIGN) irn_res=irn_abs_sub(irn1,irn0);\n\t\tif(irn_res.IRN_DEN.MPI_SIGN){\n\t\t\tirn_res.IRN_DEN.MPI_SIGN=false;\n\t\t\tirn_res.IRN_SIGN=true;\n\t\t}\n\t\treturn irn_res;\n\t}\n\t\n\tIRN irn_sub(const IRN &irn0,const IRN &irn1)const{\n\t\tif(!irn0.IRN_SIGN&& irn1.IRN_SIGN) return irn_abs_add(irn0,irn1);\n\t\tif( irn0.IRN_SIGN&&!irn1.IRN_SIGN){\n\t\t\tIRN irn_res=irn_abs_add(irn0,irn1);\n\t\t\tirn_res.IRN_SIGN=!irn_res.IRN_SIGN;\n\t\t\treturn irn_res;\n\t\t}\n\t\tIRN irn_res;\n\t\tif( irn0.IRN_SIGN&& irn1.IRN_SIGN){\n\t\t\tirn_res=irn_abs_sub(irn0,irn1);\n\t\t\tirn_res.IRN_SIGN=!irn_res.IRN_SIGN;\n\t\t}\n\t\tif(!irn0.IRN_SIGN&&!irn1.IRN_SIGN){\n\t\t\tirn_res=irn_abs_sub(irn0,irn1);\n\t\t}\n\t\tif(irn_res.IRN_DEN.MPI_SIGN){\n\t\t\tirn_res.IRN_DEN.MPI_SIGN=false;\n\t\t\tirn_res.IRN_SIGN=true;\n\t\t}\n\t\treturn irn_res;\n\t}\n\t\n\tbool operator<(const IRN &irn_var)const{\n\t\tif(this->IRN_DEN==0 && irn_var.IRN_DEN==0) return false;\n\t\tbool b0=this->IRN_SIGN,b1=irn_var.IRN_SIGN;\n\t\tif( b0&&!b1) return true;\n\t\tif(!b1&& b0) return false;\n\t\tMPI left=this->IRN_DEN*irn_var.IRN_NUM;\n\t\tMPI right=irn_var.IRN_DEN*this->IRN_NUM;\n\t\tif(!b0&&!b1) return left(const IRN &irn_var)const{\n\t\tif(this->IRN_DEN==0 && irn_var.IRN_DEN==0) return false;\n\t\tbool b0=this->IRN_SIGN,b1=irn_var.IRN_SIGN;\n\t\tif( b0&&!b1) return false;\n\t\tif(!b0&& b1) return true;\n\t\tMPI left=this->IRN_DEN*irn_var.IRN_NUM;\n\t\tMPI right=irn_var.IRN_DEN*this->IRN_NUM;\n\t\tif(!b0&&!b1) return left>right;\n\t\treturn rightIRN_DEN==0 && irn_var.IRN_DEN==0) return true;\n\t\tif(this->IRN_SIGN && !irn_var.IRN_SIGN) return false;\n\t\tif(!this->IRN_SIGN&& irn_var.IRN_SIGN) return false;\n\t\treturn this->IRN_DEN==irn_var.IRN_DEN && this->IRN_NUM==irn_var.IRN_NUM;\n\t}\n\t\n\tIRN operator+(const IRN &irn_var)const{ return irn_add(*this,irn_var); }\n\tIRN operator-(const IRN &irn_var)const{ return irn_sub(*this,irn_var); }\n\tIRN operator/(const IRN &irn_var)const{ return irn_div(*this,irn_var); }\n\tIRN operator*(const IRN &irn_var)const{ return irn_mul(*this,irn_var); }\n\tvoid operator+=(const IRN &irn_var){ *this=*this+irn_var; }\n\tvoid operator-=(const IRN &irn_var){ *this=*this-irn_var; }\n\tvoid operator*=(const IRN &irn_var){ *this=*this*irn_var; }\n\tvoid operator/=(const IRN &irn_var){ *this=*this/irn_var; }\n\tIRN operator<=(const IRN &irn_var)const{ return !(irn_var<*this); }\n\tIRN operator>=(const IRN &irn_var)const{ return !(*this used;\nli n,cnt;\n\nvoid recur(li num){\n\tif(num==0 || used.find(num)!=used.end()) return;\n\tused.insert(num);\n\tfor(cnt=0;num>n;\n\tfor(;n%2==0;n/=2) INIT+=IRN(1,1);\n\trecur(1);\n\tcout<\nusing namespace std;\n#define ll long long \n#define pi pair < ll , ll >;\n#define prev _prev\n#define stack _stack\n \nll scal(pi a, pi b)\n{\n return (ll)a.first * (ll)a.second + (ll)b.first * (ll)b.second;\n}\n \nll mul(pi a, pi b)\n{\n return (ll)a.first * (ll)b.second - (ll)a.second * (ll)b.first;\n}\n \nint half(pi a)\n{\n if (a.second > 0 || (a.second == 0 && a.first >= 0))\n return 0;\n return 1;\n}\n \nint half(pi a, pi b)\n{\n ll pr = mul(a, b);\n if (pr != 0)\n return (pr <= 0);\n return (scal(a, b) < 0);\n}\n \nconst int M = 210;\nconst int MOD = 998244353;\n \nint n, x[M], y[M], dp[M], val[M][M], ml[M], ei[M][M], first[M][M], last[M][M], sum[2 * M], ok[M][M];\nvector v[M];\nvector way[M][M];\n \npi vect(int i, int j)\n{\n return make_pair(x[j] - x[i], y[j] - y[i]);\n}\n \npi vect(pi t)\n{\n return make_pair(x[t.second] - x[t.first], y[t.second] - y[t.first]);\n}\n \nvoid dfs_help(int p, int pr)\n{\n int id = -1;\n for (int i = 0; i < (int)v[p].size(); i++)\n {\n if (v[p][i] == pr)\n id = i;\n else\n dfs_help(v[p][i], p);\n }\n if (id != -1)\n {\n swap(v[p][id], v[p].back());\n v[p].pop_back();\n }\n}\n \nvector stack;\n \nvoid dfs_way(int p, int pr, int st)\n{\n stack.push_back(p);\n if (p != st && (int)stack.size() >= 3)\n {\n bool ch = true;\n for (int i : stack)\n if (mul(vect(st, p), vect(st, i)) < 0)\n {\n ch = false;\n break;\n }\n if (ch)\n way[st][p] = stack;\n }\n for (int i : v[p])\n if (i != pr)\n dfs_way(i, p, st);\n stack.pop_back();\n}\n \nbool cmp(pi a, pi b){\n pi va = vect(a);\n pi vb = vect(b);\n int ha = half(va);\n int hb = half(vb);\n if (ha != hb)\n return ha < hb;\n ll pr = mul(va, vb);\n if (pr != 0)\n return (pr > 0);\n return a < b;\n}\n \nbool good(pi a, pi b, pi c){\n int hb = half(a, b);\n int hc = half(a, c);\n if (hb != hc)\n return hb < hc;\n return mul(b, c) > 0;\n}\n \nvector g[M];\n \nvector dfs(int p){\n ml[p] = 1;\n vector now = {p};\n for (int i : v[p])\n {\n vector to = dfs(i);\n for (int x : to)\n now.push_back(x);\n ml[p] = (ll)ml[p] * dp[i] % MOD;\n }\n dp[p] = ml[p];\n for (int i : v[p])\n {\n int cur = ml[i];\n for (int j : v[p])\n if (j != i)\n cur = (ll)cur * dp[j] % MOD;\n dp[p] += cur;\n if (dp[p] >= MOD)\n dp[p] -= MOD;\n }\n for (int i : now)\n g[i].clear();\n int k = 0;\n for (int i : now)\n for (int j : v[i])\n {\n g[i].push_back(j);\n g[j].push_back(i);\n ei[i][j] = k++;\n ei[j][i] = k++;\n }\n for (int i : now)\n for (int j : now)\n ok[i][j] = 0;\n vector al;\n for (int i : now)\n for (int j : now)\n if (!way[i][j].empty() && mul(vect(i, j), vect(i, p)) >= 0)\n {\n al.push_back(make_pair(i, j));\n first[i][j] = ei[way[i][j][0]][way[i][j][1]];\n last[i][j] = ei[way[i][j][(int)way[i][j].size() - 1]][way[i][j][(int)way[i][j].size() - 2]];\n if (val[i][j] != -1)\n continue;\n ok[i][j] = 1;\n val[i][j] = 1;\n for (int x = 0; x < (int)way[i][j].size(); x++)\n {\n int v_cur = way[i][j][x];\n pi lb, rb;\n if (x == 0)\n {\n lb = vect(v_cur, way[i][j][x + 1]);\n lb.first = -lb.first, lb.second = -lb.second;\n }\n else\n lb = vect(v_cur, way[i][j][x - 1]);\n if (x + 1 == (int)way[i][j].size())\n {\n rb = vect(v_cur, way[i][j][x - 1]);\n rb.first = -rb.first, rb.second = -rb.second;\n }\n else\n rb = vect(v_cur, way[i][j][x + 1]);\n for (int to : v[v_cur])\n if (good(lb, vect(v_cur, to), rb))\n {\n if (x != 0 && to == way[i][j][x - 1])\n continue;\n if (x + 1 < (int)way[i][j].size() && to == way[i][j][x + 1])\n continue;\n val[i][j] = (ll)val[i][j] * dp[to] % MOD;\n }\n }\n }\n sort(al.begin(), al.end(), cmp);\n for (int v_st : now)\n for (int ig : g[v_st])\n {\n if (half(vect(v_st, ig)))\n continue;\n for (int ban = -1; ban <= 1; ban += 2)\n {\n for (int i = 0; i < k; i++)\n sum[i] = 0;\n sum[ei[v_st][ig]] = 1;\n for (pi t : al)\n {\n if (ban == -1 && ok[t.first][t.second])\n continue;\n int S = first[t.first][t.second];\n int F = last[t.first][t.second];\n sum[F] += (ll)sum[S] * val[t.first][t.second] % MOD;\n if (sum[F] >= MOD)\n sum[F] -= MOD;\n }\n sum[ei[v_st][ig]]--;\n if (sum[ei[v_st][ig]] < 0)\n sum[ei[v_st][ig]] += MOD;\n dp[p] += ban * sum[ei[v_st][ig]];\n if (dp[p] >= MOD)\n dp[p] -= MOD;\n if (dp[p] < 0)\n dp[p] += MOD;\n }\n }\n return now;\n}\n \nint main()\n{\n cin >> n;\n for (int i = 0; i < n; i++)\n cin >> x[i] >> y[i];\n for (int i = 0; i < n - 1; i++)\n {\n int s, f;\n cin >> s >> f;\n s--, f--;\n v[s].push_back(f);\n v[f].push_back(s);\n }\n for (int i = 0; i < n; i++)\n dfs_way(i, -1, i);\n dfs_help(0, -1);\n memset(val, -1, sizeof(val));\n dfs(0);\n cout << dp[0] << \"\\n\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "11c42c4d623aa2a8eda4ae0262877a78", "src_uid": "9b764e44167cc5d2bdfabcb811cdd93b", "difficulty": 3500.0} {"lang": "GNU C++14", "source_code": "#include\n#define int long long\n#define left greetings_traveller\n#define right ya_snova_jivu\nusing namespace std;\n\n\nconst int N = 1e5 + 5, inf = 3e15;\n\n\n\nint n, a, b, g[N], k[N], dp[N];\n\nmap < int, int > left, right;\n\nint main(){\n ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n cin >> n >> a >> b;\n for(int i = 1; i < n; i++){\n cin >> g[i];\n }\n for(int i = 1; i <= n; i++){\n cin >> k[i];\n dp[i] = inf;\n }\n dp[a] = 0;\n int l = a, r = a, tl = a, tr = a;\n left[k[a]] = right[k[a]] = a;\n while(dp[b] == inf){\n bool p = false;\n if(r < n){\n int need = g[r];\n if(right[need]){\n dp[r + 1] = dp[r] + 1;\n }\n else if(left[need]){\n if(left[need] < tl){\n dp[r + 1] = dp[left[need]] + abs(r + 1 - left[need]);\n tl = left[need];\n }\n else{\n dp[r + 1] = dp[r] + 1;\n }\n }\n if(dp[r + 1] != inf){\n r++;\n p = true;\n if(!right[k[r]]){\n right[k[r]] = r;\n }\n }\n }\n if(l > 1){\n int need = g[l - 1];\n if(left[need]){\n dp[l - 1] = dp[l] + 1;\n }\n else if(right[need]){\n if(right[need] > tr){\n dp[l - 1] = dp[right[need]] + abs(l - 1 - right[need]);\n tr = right[need];\n }\n else{\n dp[l - 1] = dp[l] + 1;\n }\n }\n if(dp[l - 1] != inf){\n l--;\n p = true;\n if(!left[k[l]]){\n left[k[l]] = l;\n }\n }\n }\n if(!p){\n return cout << \"-1\", 0;\n }\n }\n cout << dp[b];\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6f60e2fd0879bc2d30e6d61ba08b2a7e", "src_uid": "fbd994944cfa06e4921aac227d9eaf31", "difficulty": 2400.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define X first\n#define Y second\n\nint n, x[23];\nvector y;\nmap z;\nvector> f;\n\nvoid dfs(int k, int a, int b)\n{\n\tif (k == 1)\n\t{\n\t\tfor (int i = 1; i <= y[0]; ++i) f.pb(mp(a, b));\n\t\treturn;\n\t}\n\tint c = 6 - a - b;\n\tdfs(k - 1, a, c);\n\tfor (int i = 1; i <= y[k-1]; ++i) f.pb(mp(a, b));\n\tdfs(k - 1, c, b);\n}\n\nint main()\n{\n\tscanf(\"%d\", &n);\n\tfor (int i = 1; i <= n; ++i) scanf(\"%d\", &x[i]);\n\tfor (int i = n; i > 1; --i) ++z[x[i]];\n\tfor (auto i : z) y.pb(i.Y);\n\tdfs(y.size(), 1, 2);\n\tf.pb(mp(1, 3));\n\tdfs(y.size(), 2, 3);\n\tprintf(\"%d\\n\", f.size());\n\tfor (auto i : f) printf(\"%d %d\\n\", i.X, i.Y);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "17167fbc661ab90639093983e3e25d60", "src_uid": "4ea4ad10ef422a9cd45b8a7b25d359c5", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\n\nconst int K = 5000 + 1;\n\nmap > fac;\nvector sum;\nmap v;\nint n;\n\nvoid build() {\n bitset isp;\n isp.set();\n for(int i = 2 ; i * i < K ; ++i) if(isp[i]) {\n for(int j = i * i ; j < K ; j += i) isp[j] = 0;\n }\n vector p;\n for(int i = 2 ; i < K ; ++i) if(isp[i]) p.push_back(i);\n map m;\n sum.resize(K);\n int cnt = 0;\n for(int i = 2 ; i < K ; ++i) {\n int x = i, j = 0;\n while(x > 1) {\n if(isp[x]) {\n m[x]++;\n cnt++;\n break;\n }\n int cc = 0;\n while(x % p[j] == 0) cc++, x /= p[j];\n if(cc) m[p[j]] += cc, cnt += cc;\n j++;\n }\n fac[i] = m;\n sum[i] = cnt;\n }\n}\nvoid init() {\n cin >> n;\n for(int i = 0 ; i < n ; ++i) {\n int a; cin >> a; \n if(a != 1) v[a]++;\n }\n}\nvoid solve() {\n int ans = 0;\n for(auto [i, j] : v) {\n ans += sum[i] * j;\n }\n while(1) {\n map tmp;\n for(auto [i, j] : v) {\n tmp[fac[i].rbegin()->first] += j;\n }\n int mx = 0, val = 0;\n for(auto [i, j] : tmp) if(j > val) mx = i, val = j;\n if(val < n - val) break;\n ans += n - val - val;\n vector tt;\n for(auto [i, j] : v) {\n if(fac[i].rbegin()->first == mx) {\n fac[i].rbegin()->second--;\n if(fac[i].rbegin()->second == 0) {\n fac[i].erase(fac[i].rbegin()->first);\n if(fac[i].empty()) tt.push_back(i);\n }\n }\n else tt.push_back(i);\n }\n for(auto t : tt) v.erase(t);\n }\n cout << ans << '\\n';\n}\n\nint main() {\n build();\n init();\n solve();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "60681f35978183cf82c2d999d11e1dbd", "src_uid": "40002052843ca0357dbd3158b16d59f4", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nconst int N = 200005, M = 2000005;\nint n, m;\nlong long p[N], v[N], anss[M];\n\nint minTurn() {\n\tfor (int i = 0; i < n; ++i) {\n\t\tv[i] = p[i];\n\t}\n\tint ret = 0;\n\tlong long maxm = m;\n\twhile (true) {\n\t\tfor (int i = n - 1; i >= 0; --i) {\n\t\t\tlong long now = min(maxm, v[i]);\n\t\t\tif (now == 0) {\n\t\t\t\treturn ret;\n\t\t\t} else {\n\t\t\t\tmaxm = now - 1;\n\t\t\t\tv[i] -= now;\n\t\t\t}\n\t\t}\n\t\t++ret;\n\t}\n}\n\nint maxTurn() {\n\tfor (int i = 0; i < n; ++i) {\n\t\tv[i] = p[i];\n\t}\n\tint ret = 0;\n\tlong long minm = 1;\n\twhile (true) {\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tif (minm > m) {\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tif (v[i] < minm) {\n\t\t\t\treturn ret;\n\t\t\t} else {\n\t\t\t\tv[i] -= minm++;\n\t\t\t}\n\t\t}\n\t\t++ret;\n\t}\n}\n\nlong long mins[N];\n\nlong long solve(int t) {\n\tif (anss[t] != -1) {\n\t\treturn anss[t];\n\t}\n\tlong long last = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tv[i] = p[i];\n\t}\n\tlong long ret = 0;\n\tfor (int i = 0; i < t; ++i) {\n\t\tfor (int j = 0; j < n; ++j) {\n\t\t\tv[j] -= ++last;\n\t\t\tret += last;\n\t\t}\n\t}\n\tint delta = m - last; \n\tfor (int i = t - 1; i >= 0 && delta; --i) {\n\t\tfor (int j = n - 1; j >= 0 && delta; --j) {\n\t\t\tdelta = v[j] > delta ? delta : v[j];\n\t\t\tv[j] -= delta;\n\t\t\tret += delta;\n\t\t}\n\t}\n\treturn anss[t] = ret;\n}\n\nint main() {\n\tios::sync_with_stdio(false);\n\tcin >> n >> m;\n\tfor (int i = 0; i < n; ++i) {\n\t\tcin >> p[i];\n\t}\n\tint l = minTurn(), r = maxTurn();\n\tfor (int i = l; i <= r; ++i) {\n\t\tanss[i] = -1;\n\t}\n\tlong long ans = max(solve(l), solve(r));\n\tint mid1, mid2;\n\tfor (int i = 0; i < 100; ++i) {\n\t\tmid1 = (l + l + r) / 3;\n\t\tmid2 = (l + r + r) / 2;\n\t\tans = max(ans, solve(mid1));\n\t\tans = max(ans, solve(mid2));\n\t\tif (solve(mid1) > solve(mid2)) {\n\t\t\tr = mid2;\n\t\t} else {\n\t\t\tl = mid1;\n\t\t}\n\t}\n\tcout << ans << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "53900d5cda4358d622c9d6a64b386d7b", "src_uid": "169f58dc87d26e0fadde6a83bb623f54", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long int lld;\ntypedef long double ld;\npair arr[7777],ans;\nvector v[66];\nint main(void){\n\tint n;\n\tscanf(\"%d\",&n);\n\tfor(int e=0;e debug & operator <<\n#define eni(x) sim > typename \\\n enable_if(0) x 1, debug&>::type operator<<(c i) {\nsim > struct rge { c b, e; };\nsim > rge range(c i, c j) { return rge{i, j}; }\nsim > auto dud(c* x) -> decltype(cerr << *x, 0);\nsim > char dud(...);\nstruct debug {\n#ifdef LOCAL\n~debug() { cerr << endl; }\n//~ eni(!=) cerr << boolalpha << i; ris; }\neni(!=) cerr << i; ris; }\neni(==) ris << range(begin(i), end(i)); }\nsim, class b dor(pair < b, c > d) {\n ris << \"(\" << d.first << \", \" << d.second << \")\";\n}\nsim dor(rge d) {\n *this << \"[\";\n for (auto it = d.b; it != d.e; ++it)\n *this << \", \" + 2 * (it == d.b) << *it;\n ris << \"]\";\n}\n#else\nsim dor(const c&) { ris; }\n#endif\n};\n#define imie(...) \" [\" << #__VA_ARGS__ \": \" << (__VA_ARGS__) << \"] \"\n\ntypedef long long ll;\n\nconst int AND = 0, OR = 1, NAND = 2, NOR = 3;\nconst int nax = 1005;\n\nstruct S {\n\tint type;\n\tS zmien() {\n\t\tS he;\n\t\the.type = type ^ 1;\n\t\treturn he;\n\t}\n\tvoid read() {\n\t\tstatic char sl[10];\n\t\tscanf(\"%s\", sl);\n\t\tstring s = string(sl);\n\t\tif(s == \"and\") type = AND;\n\t\telse if(s == \"or\") type = OR;\n\t\telse if(s == \"nand\") type = NAND;\n\t\telse if(s == \"nor\") type = NOR;\n\t\telse {\n\t\t\tcout << \"unknown type: \" << s << endl;\n\t\t\tassert(false);\n\t\t}\n\t}\n\tbool operator () (bool a, bool b) {\n\t\tif(type == AND) return a & b;\n\t\tif(type == OR) return a | b;\n\t\tif(type == NAND) return !(a & b);\n\t\tif(type == NOR) return !(a | b);\n\t\tassert(false);\n\t}\n};\n\nvoid read(pair> & p) {\n\tp.first.read();\n\tstatic char sl[105];\n\tscanf(\"%s\", sl);\n\tint n = strlen(sl);\n\tvector w;\n\tfor(int i = 0; i < n; ++i)\n\t\tif(sl[i] == 'x')\n\t\t\tw.push_back(i);\n\tassert((int) w.size() == 2);\n\tp.second = {w[0], w[1]};\n}\n\nvector w[nax];\n\nint main() {\n\tint n, m, k;\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tvector>> one(m), two(k);\n\tfor(int i = 0; i < m; ++i)\n\t\tread(one[i]);\n\tfor(int i = 0; i < k; ++i)\n\t\tread(two[i]);\n\t\n\tconst int M = 10 * 1000;\n\tvector, vector>> pre(M);\n\tfor(auto & p : pre) {\n\t\tvector a(n), b(m), c(k), d(k);\n\t\tfor(int i = 0; i < n; ++i) a[i] = rand() % 2;\n\t\tfor(int i = 0; i < m; ++i) b[i] = one[i].first(a[one[i].second.first], a[one[i].second.second]);\n\t\tfor(int i = 0; i < k; ++i) c[i] = two[i].first(b[two[i].second.first], b[two[i].second.second]);\n\t\tfor(int i = 0; i < k; ++i) d[i] = two[i].first.zmien()(b[two[i].second.first], b[two[i].second.second]);\n\t\tp = {c, d};\n\t}\n\tvector maybe(k, true);\n\tfor(auto & p : pre) {\n\t\tauto & c = p.first;\n\t\tauto & d = p.second;\n\t\tdebug() << imie(c);\n\t\tfor(int i = 0; i < k; ++i) if(c[i] & d[i]) maybe[i] = false;\n\t\tbool any = false;\n\t\tfor(int i = 0; i < k; ++i) if(maybe[i]) if(c[i] | d[i]) any = true;\n\t\tif(!any) {\n\t\t\tputs(\"-1\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\n\tvector> e(k, vector(k));\n\t\n\tfor(auto & p : pre) {\n\t\tauto & c = p.first;\n\t\tauto & d = p.second;\n\t\tdebug() << imie(c);\n\t\tdebug() << imie(d);\n\t\tdebug();\n\t\tfor(int i = 0; i < k; ++i) if(maybe[i])\n\t\t\tfor(int j = i + 1; j < k; ++j) if(maybe[j])\n\t\t\t\tif((c[i] & d[j]) | (c[j] & d[i])) e[i][j] = e[j][i] = true;\n\t}\n\t\n\tfor(int i = 0; i < k; ++i)\n\t\tfor(int j = i + 1; j < k; ++j) if(e[i][j]) {\n\t\t\tw[i].push_back(j);\n\t\t\tw[j].push_back(i);\n\t\t\t//~ printf(\"%d %d\\n\", i, j);\n\t\t}\n\t\n\tint answer = 0;\n\tfor(int i = 0; i < k; ++i) if(!maybe[i]) ++answer;\n\tvector vis(k);\n\tvector, vector>> they;\n\tvector taken(k);\n\tfor(int i = 0; i < k; ++i) if(maybe[i] && !vis[i]) {\n\t\tvector A, B;\n\t\tvector kol{i};\n\t\tvector dist(k);\n\t\tvis[i] = true;\n\t\tfor(int j = 0; j < (int) kol.size(); ++j) {\n\t\t\tint a = kol[j];\n\t\t\tif(dist[a] % 2) A.push_back(a);\n\t\t\telse B.push_back(a);\n\t\t\tfor(int b : w[a]) if(!vis[b]) {\n\t\t\t\tvis[b] = true;\n\t\t\t\tdist[b] = dist[a] + 1;\n\t\t\t\tkol.push_back(b);\n\t\t\t}\n\t\t}\n\t\tif(A.size() < B.size()) swap(A, B);\n\t\t// bierzemy pierwsza\n\t\tthey.push_back({A, B});\n\t\tfor(int x : A) taken[x] = true;\n\t\t\n\t\t//~ printf(\"%d %d\\n\", A, B);\n\t\tanswer += (int) B.size();\n\t}\n\tbool yeah = true;\n\tfor(auto & p : pre) {\n\t\tauto & c = p.first;\n\t\tauto & d = p.second;\n\t\tbool any = false;\n\t\tfor(int i = 0; i < k; ++i) if(taken[i]) if(c[i] | d[i]) any = true;\n\t\tif(!any) {\n\t\t\tyeah = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tif(!yeah) for(pair, vector> p : they) {\n\t\tint by = 1000000;\n\t\tauto memo = taken;\n\t\tfor(int x : p.first) {\n\t\t\tassert(taken[x]);\n\t\t\ttaken[x] = false;\n\t\t}\n\t\tfor(int x : p.second) {\n\t\t\tassert(!taken[x]);\n\t\t\ttaken[x] = true;\n\t\t}\n\t\t\n\t\tbool tu = true;\n\t\tfor(auto & p : pre) {\n\t\t\tauto & c = p.first;\n\t\t\tauto & d = p.second;\n\t\t\tbool any = false;\n\t\t\tfor(int i = 0; i < k; ++i) if(taken[i]) if(c[i] | d[i]) any = true;\n\t\t\tif(!any) {\n\t\t\t\ttu = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(tu) by = min(by, (int) abs(p.first.size() - p.second.size()));\n\t\t\n\t\ttaken = memo;\n\t\tanswer += by;\n\t}\n\t\n\t\n\tprintf(\"%d\\n\", answer);\n\treturn 0;\n\t\n\t//~ int answer = -1;\n\tfor(int mask = 0; mask < (1 << k); ++mask) {\n\t\tbool ok = true;\n\t\tfor(int i = 0; i < k; ++i) if(mask & (1 << i)) if(!maybe[i]) ok = false;\n\t\tif(!ok) continue;\n\t\tfor(int rep = 0; rep < 200; ++rep) {\n\t\t\tvector a(n), b(m), c(k), d(k);\n\t\t\tfor(int i = 0; i < n; ++i) a[i] = rand() % 2;\n\t\t\tfor(int i = 0; i < m; ++i) b[i] = one[i].first(a[one[i].second.first], a[one[i].second.second]);\n\t\t\tfor(int i = 0; i < k; ++i) c[i] = two[i].first(b[two[i].second.first], b[two[i].second.second]);\n\t\t\tfor(int i = 0; i < k; ++i) d[i] = two[i].first.zmien()(b[two[i].second.first], b[two[i].second.second]);\n\t\t\t//~ debug() << imie(c);\n\t\t\t//~ debug() << imie(d);\n\t\t\t//~ debug();\n\t\t\tbool raz = false, dwa = false;\n\t\t\tfor(int i = 0; i < k; ++i) if(mask & (1 << i)) {\n\t\t\t\tif(c[i]) raz = true;\n\t\t\t\tif(d[i]) dwa = true;\n\t\t\t}\n\t\t\tif(raz && dwa) ok = false;\n\t\t\tif(!raz && !dwa) ok = false;\n\t\t\tif(!ok) break;\n\t\t\t//~ for(int i = 0; i < k; ++i)\n\t\t\t\t//~ if(c[i] && d[i])\n\t\t\t\t\t//~ maybe[i] = false;\n\t\t}\n\t\tif(ok) answer = max(answer, __builtin_popcount(mask));\n\t\t//~ debug() << imie(maybe);\n\t}\n\tassert(answer != -1);\n\t\n\t//~ if(answer == -1) printf(\"%d\\n\", answer);\n\t//~ else printf(\"%d\\n\", k - answer);\n\t\n\tprintf(\"%d\\n\", k - answer);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ce4b730413293a65f2acb54c9ac6207d", "src_uid": "2f80021e297dd57e306d2a50c3590bea", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \n#define div suka\n#define ll long long\nusing namespace std;\nconst int mod = 1000000007;\nint Sum(int x, int y){\n\tif (x+y<0) return x+y+mod;\n\tif (x+y>=mod) return x+y-mod;\n\treturn x+y;\n}\nint mult(int x, int y){\n\treturn ((ll) x * (ll) y) % (ll) mod;\n}\nconst int K = 100007;\nvector div[K];\nint pw(int x, int y){\n\tif (y == 0) return 1;\n\tif (y==1) return x%mod;\n\tif (y % 2 == 0){\n\t\tint R = pw(x, y/2);\n\t\treturn mult(R, R);\n\t}\n\treturn mult(x, pw(x, y-1));\n}\nint arr[1000];\nint get(int n, int l, int r){\n\tint res=0;\n\tfor (int i=l; i <= r; i++){\n\t\tif (__gcd(i, n) == 1) res++;\n\t}\n\treturn res;\n}\nsigned main() {\n\t#ifdef LOCAL\n\t\tfreopen(\"H_input.txt\", \"r\", stdin);\n\t\t//freopen(\"C_output.txt\", \"w\", stdout);\n\t#endif\n ios_base::sync_with_stdio(0); cin.tie(0);\n \tint n, k;\n \tcin >> n >> k;\n \tfor (int i=2; i < K; i++){\n \t\tif (div[i].size() >= 1) continue;\n \t\tfor (int j=i; j < K; j += i) div[j].push_back(i);\n \t}\n \tint ans=0;\n \tfor (int g=1; g < n; g++){\n \t\tint len = (n+g-1)/g;\n \t\tfor (int sum=2; sum <= 2*(len-1); sum++){\n \t\t\tint L, R;\n \t\t\tif (sum <= len) L = 1;\n \t\t\telse L = sum-len+1;\n \t\t\tif (sum >= len) R = len-1;\n \t\t\telse R = sum-1;\n \t\t\tint var = get(sum, L, R);\n \t\t\tint count1 = g - (n%g), g1 = len-1;\n \t\t\tint count2 = (n%g), g2 = len;\n \t\t\tif (n%g == 0) swap(count1, count2);\n \t\t\tint kf = 1;\n \t\t\tint cmp1, cmp2;\n \t\t\tif (sum <= g1+1) cmp1=1;\n \t\t\telse cmp1 = sum-g1;\n \t\t\tif (sum <= g2+1) cmp2=1;\n \t\t\telse cmp2 = sum-g2;\n \t\t\tkf = mult(kf, pw(pw(k, cmp1), count1));\n \t\t\tkf = mult(kf, pw(pw(k, cmp2), count2));\n \t\t\t//cout << g << \" \" << sum << \" \" << kf << \" \" << var << endl;\n \t\t\tans = Sum(ans, mult(kf, var));\n \t\t}\n \t}\n \tint R = pw(k, mod-2);\n \tans = mult(ans, pw(R, n));\n \tcout << ans;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "425f48e9e201a46fde9b83bacad2e27c", "src_uid": "be32c7b2fd197c3247d11aed25c3cc0d", "difficulty": 3100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \nusing namespace std;\nusing ll = long long;\nconst int MOD = 998244353;\n\nclass SegTree {\n\tprivate:\n\t\tstruct El {\n\t\t\tint p[2][2]; // Probability that leftmost is L/R and rightmost is L/R\n\t\t\tEl() {\n\t\t\t\tp[0][0] = 0;\n\t\t\t\tp[0][1] = 0;\n\t\t\t\tp[1][0] = 0;\n\t\t\t\tp[1][1] = 0;\n\t\t\t}\n\t\t\tstatic El id() {\n\t\t\t\tEl res;\n\t\t\t\tres.p[0][0] = 1;\n\t\t\t\tres.p[1][1] = 1;\n\t\t\t\treturn res;\n\t\t\t}\n\t\t};\n\t\tstatic El combine(const El& le, const El& ri) {\n\t\t\tEl res;\n\t\t\tfor (int a = 0; a < 2; ++a) {\n\t\t\t\tfor (int b = 0; b < 2; ++b) {\n\t\t\t\t\tfor (int i = 0; i < 2; ++i) {\n\t\t\t\t\t\tres.p[a][b] = (res.p[a][b] + (ll)le.p[a][i] * ri.p[i][b]) % MOD;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\t\tvoid update(int i) {\n\t\t\tfor (i >>= 1; i > 0; i >>= 1) seg[i] = combine(seg[2*i], seg[2*i+1]);\n\t\t}\n\n\t\tvector seg;\n\t\tint h = 1;\n\tpublic:\n\t\tSegTree(int n) {\n\t\t\twhile(h < n) h *= 2;\n\t\t\tseg.resize(2*h, El::id());\n\t\t}\n\n\t\tint prob(int i, int a, int b) {\n\t\t\ti += h;\n\t\t\tEl backup = seg[i];\n\t\t\tfor (int x = 0; x < 2; ++x) {\n\t\t\t\tfor (int y = 0; y < 2; ++y) {\n\t\t\t\t\tif (x != a || y != b) seg[i].p[x][y] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tupdate(i);\n\n\t\t\tll res = (seg[1].p[0][0] + seg[1].p[0][1]) % MOD;\n\n\t\t\tseg[i] = backup;\n\t\t\tupdate(i);\n\t\t\treturn res;\n\t\t}\n\t\tvoid setv(int i, int a, int b, int c, int d) {\n\t\t\ti += h;\n\t\t\tseg[i].p[0][0] = a;\n\t\t\tseg[i].p[0][1] = b;\n\t\t\tseg[i].p[1][0] = c;\n\t\t\tseg[i].p[1][1] = d;\n\t\t\tupdate(i);\n\t\t}\n\t\tvoid zero(int i, int a, int b) {\n\t\t\ti += h;\n\t\t\tseg[i].p[a][b] = 0;\n\t\t\tupdate(i);\n\t\t}\n};\n\nll modPow(ll a, ll b) {\n\tif (b & 1) return a * modPow(a, b-1) % MOD;\n\tif (b > 0) return modPow(a*a % MOD, b / 2);\n\treturn 1;\n}\n\nstruct Atom {\n\tint xi, vi, pi;\n};\n\nstruct Rat {\n\tll a, b;\n\n\t// a / b < rhs.a / rhs.b?\n\tbool operator<(const Rat& rhs) const {\n\t\treturn a * rhs.b < b * rhs.a;\n\t}\n\tll modv() const { return a * modPow(b, MOD-2) % MOD; }\n};\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\n\tint n;\n\tcin >> n;\n\n\tSegTree seg(n);\n\n\tvector atoms(n);\n\tfor (auto& v : atoms) cin >> v.xi >> v.vi >> v.pi;\n\n\tconst ll HI = modPow(100, MOD - 2);\n\tfor (int i = 0; i < n; ++i) {\n\t\tint prob0 = (100 - atoms[i].pi) * HI % MOD;\n\t\tint prob1 = atoms[i].pi * HI % MOD;\n\t\tseg.setv(i, prob0, prob1, prob0, prob1);\n\t}\n\n\tvector>>> que;\n\tfor (int i = 0; i+1 < n; ++i) {\n\t\tll dist = atoms[i+1].xi - atoms[i].xi;\n\t\tfor (int a = 0; a < 2; ++a) {\n\t\t\tfor (int b = 0; b < 2; ++b) {\n\t\t\t\tll vel = (a ? 1 : -1) * atoms[i].vi + (b ? -1 : 1) * atoms[i+1].vi;\n\t\t\t\tRat r = {dist, vel};\n\t\t\t\tif (vel > 0) que.push_back({r, {i, {a, b}}}); // Collision eventually happens\n\t\t\t}\n\t\t}\n\t}\n\tsort(que.begin(), que.end());\n\n\tll res = 0;\n\tfor (auto pr : que) {\n\t\tll t = pr.first.modv();\n\t\tint i = pr.second.first;\n\t\tint a = pr.second.second.first;\n\t\tint b = pr.second.second.second;\n\n\t\tll prob = seg.prob(i+1, a, b);\n\t\tres = (res + prob * t) % MOD;\n\t\tseg.zero(i+1, a, b);\n\n\t\t// cerr << \"event \" << i << ' ' << a << ' ' << b << \": \" << t << ' ' << prob << '\\n';\n\t}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7666a5b655d22dce8c7628ddad0189bb", "src_uid": "37bb4fe5f6cc2a173e97c033c6fde8c7", "difficulty": 3100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\nusing namespace std;\n\n#ifdef WIN32\n #define LLD \"%I64d\"\n#else\n #define LLD \"%lld\"\n#endif\n\ntypedef pair pii;\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vb;\ntypedef vector vvb;\ntypedef vector vll;\ntypedef vector vvll;\n\nll rdtsc() {\n ll tmp;\n asm(\"rdtsc\" : \"=A\"(tmp));\n return tmp;\n}\n\ninline int myrand() {\n return abs((rand() << 15) ^ rand());\n}\n\ninline int rnd(int x) {\n return myrand() % x;\n}\n\n#define TASKNAME \"text\"\n#define pb push_back\n#define mp make_pair\n#define EPS (1e-9)\n#define INF ((int)1e9)\n#define sqr(x) ((x) * (x))\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define sz(x) ((int)(x).size())\n\nconst int maxn = (int)2e5 + 10;\nint value[maxn];\nint pr[maxn], w[maxn], diff[maxn];\nint bounds[maxn][2];\n\nint get(int v) {\n if (pr[v] == v)\n return v;\n get(pr[v]);\n diff[v] += diff[pr[v]];\n pr[v] = pr[pr[v]];\n return pr[v];\n}\n\nint getValue(int v) {\n if (pr[v] == v)\n return 0;\n get(v);\n return diff[v];\n}\n\nvoid myUnion(int a, int b, int value) {\n //eprintf(\"add %d->%d %d\\n\", a, b, value);\n assert(a == pr[a] && b == pr[b]);\n assert(a != b);\n if (w[a] == w[b])\n ++w[b];\n if (w[a] > w[b])\n swap(a, b), value = -value;\n pr[a] = b;\n diff[a] = -value;\n bounds[b][0] = min(bounds[b][0], bounds[a][0] + diff[a]);\n bounds[b][1] = max(bounds[b][1], bounds[a][1] + diff[a]);\n bounds[a][0] = bounds[a][1] = 0;\n}\n\nbool solve() {\n int n, m;\n if (scanf(\"%d%d\", &n, &m) < 2)\n return 0;\n\n for (int i = 0; i < n; ++i)\n pr[i] = i, w[i] = 0, bounds[i][0] = bounds[i][1] = diff[i] = 0;\n\n int fail = -1;\n int res = -1;\n int maxSize = (n <= 2) ? -INF : 0;\n for (int i = 0; i < m; ++i) {\n int s, t, w, b;\n scanf(\"%d%d%d%d\", &s, &t, &w, &b);\n --s, --t;\n if (fail != -1)\n continue;\n\n int value = w * b;\n if (get(s) == get(t)) {\n //eprintf(\"%d + %d = %d\\n\", getValue(s), value, getValue(t));\n if (getValue(s) + value != getValue(t)) {\n fail = i;\n continue;\n }\n continue;\n }\n int S = s, T = t;\n if (pr[S] != S)\n value += diff[S], S = pr[S];\n if (pr[T] != T)\n value -= diff[T], T = pr[T];\n\n assert(pr[S] == S && pr[T] == T);\n\n int vs[2] = {S, T};\n for (int it = 0; it < 2; ++it) {\n if (get(0) == vs[it] && bounds[vs[!it]][0] <= getValue(0) - value) {\n fail = i;\n break;\n }\n if (get(n - 1) == vs[it] && bounds[vs[!it]][1] >= getValue(n - 1) - value) {\n fail = i;\n break;\n }\n value = -value;\n }\n\n if (fail != -1)\n continue;\n\n myUnion(S, T, value);\n\n if (res == -1 && get(0) == get(n - 1)) {\n res = getValue(n - 1) - getValue(0); \n }\n\n int root = get(S);\n if (get(0) != root && get(n - 1) != root) {\n int size = bounds[root][1] - bounds[root][0];\n maxSize = max(maxSize, size);\n }\n if (res != -1 && maxSize >= res) {\n //eprintf(\"%d >= %d\\n\", maxSize, res);\n fail = i;\n continue; \n }\n //for (int j = 0; j < n; ++j)\n // eprintf(\"%d[%d..%d]%c\", getValue(j), bounds[j][0], bounds[j][1], \" \\n\"[j == n - 1]);\n }\n \n if (fail != -1)\n printf(\"BAD %d\\n\", fail + 1);\n else {\n if (res != -1)\n printf(\"%d\\n\", res);\n else\n printf(\"UNKNOWN\\n\");\n }\n return 1;\n}\n\nint main() {\n srand(rdtsc());\n#ifdef DEBUG\n freopen(TASKNAME\".in\", \"r\", stdin);\n freopen(TASKNAME\".out\", \"w\", stdout);\n#endif\n \n while (1) {\n if (!solve())\n break;\n #ifdef DEBUG\n eprintf(\"%.18lf\\n\", (double)clock() / CLOCKS_PER_SEC);\n #endif\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "51132f2328b5554f28f0b41252e450eb", "src_uid": "b047916b7d99bc34a64ad41f43a37bf0", "difficulty": 3000.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define fi first\n#define se second\n#define mp make_pair\n#define pb push_back\n#define SZ(x) ((int) (x).size())\n#define ALL(x) x.begin(), x.end()\n\nusing namespace std;\ntypedef long long LL;\ntypedef unsigned int uint;\n\ntemplate inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}\ntemplate inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}\n\nconst int MaxN = 205;\nuint n, d, M, c[MaxN][MaxN], f[MaxN][MaxN], g[MaxN]; \n\nnt main() {\n\tcin >> n >> d >> M;\n\tc[0][0] = 1;\n\tfor (int i = 1; i <= n; i++) {\n\t\tc[i][0] = 1;\n\t\tfor (int j = 1; j <= i; j++)\n\t\t\tc[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % M;\n\t}\n\tf[1][0] = 1;\n\tfor (int i = 2; i <= n; i++) {\n\t\tfor (int k = 0; k < d; k++)\n\t\t\t(g[i - 1] += f[i - 1][k]) %= M;\n\t\tfor (int j = 1; j < i; j++) \n\t\t\tfor (int k = 0; k < d; k++) \n\t\t\t\tf[i][k + 1] = (f[i][k + 1] + (LL) f[i - j][k] * g[j] % M * c[i - 2][j - 1]) % M;\n\t}\n\tint ans = 0;\n\tfor (int i = 0; i < n; i++)\n\t\tfor (int j = 0; j <= d; j++) \n\t\t\tfor (int k = 0; j + k <= d; k++) {\n\t\t\t\tif(k == 1) continue;\n\t\t\t\tans = (ans + (LL) f[i + 1][j] * f[n - i][k]) % M;\n\t\t\t}\n\tans = (LL) ans * 2 * n * (n - 1) % M;\n\tcout << ans << endl;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a37186e63f657284bb7d79598b4bccc9", "src_uid": "c84d69544f2d98512f0b05f504e1b5c6", "difficulty": 3400.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n\nunsigned long long n;\nunsigned long long c1, c2;\n\nunsigned long long mature;\n\nvoid getMature()\n{\n\tmature = 0;\n\tchar c;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> c;\n\t\tif (c == '1')\n\t\t\tmature++;\n\t}\n}\n\nunsigned long long getCost(unsigned long long size, unsigned long long count)\n{\n\treturn count * (c1 + c2 * (size - 1) * (size - 1));\n}\n\nunsigned long long check(unsigned long long group)\n{\n\tunsigned long long k = n / group;\n\tunsigned long long r = n % group;\n\tunsigned long long smallGroup = group - r;\n\tunsigned long long bigGroup = r;\n\treturn getCost(k, smallGroup) + getCost(k + 1, bigGroup);\n}\n\nunsigned long long all()\n{\n\tunsigned long long min = pow(2, 64) - 1;\n\tunsigned long long current;\n\tfor (int i = mature; i > 0; i--)\n\t{\n\t\tcurrent = check(i);\n\t\tif (current < min)\n\t\t\tmin = current;\n\t}\n\treturn min;\n}\n\nint main()\n{\n\tcin >> n >> c1 >> c2;\n\tgetMature();\n\tcout << all();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "115843a1eb5413e41f6020d4f733c01c", "src_uid": "78d013b01497053b8e321fe7b6ce3760", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n\tint a, h, w;\n\tcin >> a >> h >> w;\n\n\tif (a > h || a > w)\n\t{\n\t\tprintf(\"-1\\n\");\n\t\treturn 0;\n\t}\n\n\tif (a <= 1000000)\n\t{\n\t\tint x = max(1, (w - a) / (2 * a)), y = max(1, (h - a) / (2 * a));\n\t\tdouble ans = 1e100;\n\t\twhile (w >= a * x && h >= a * y)\n\t\t{\n\t\t\tdouble d1 = double(w - a * x) / (x + 1);\n\t\t\tdouble d2 = double(h - a * y) / (y + 1);\n\n\t\t\tif ((w - a * x) * 1ll * (y + 1) == (h - a * y) * 1ll * (x + 1))\n\t\t\t{\n\t\t\t\tans = min(ans, d1);\n\t\t\t\t--x; --y;\n\t\t\t}\n\t\t\telse if (d1 > d2) --x;\n\t\t\telse --y;\n\t\t}\n\n\t\tif (ans == 1e100) printf(\"-1\\n\");\n\t\telse printf(\"%.9f\\n\", ans);\n\t}\n\telse\n\t{\n\t\tdouble ans = 1e100;\n\t\tfor (int x = 1; w >= a * x; x++)\n\t\t{\n\t\t\tfor (int y = 1; h >= a * y; y++)\n\t\t\t{\n\t\t\t\tif ((w - a * x) * 1ll * (y + 1) == (h - a * y) * 1ll * (x + 1)) ans = min(ans, double(w - a * x) / (x + 1));\n\t\t\t}\n\t\t}\n\n\t\tif (ans == 1e100) printf(\"-1\\n\");\n\t\telse printf(\"%.9f\\n\", ans);\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "db31cb5f1a444b4aa82529742cd8c7ef", "src_uid": "7fbefd3eb1aad6865adcfac394f0a7e6", "difficulty": 2700.0} {"lang": "GNU C++17 (64)", "source_code": "/**\r\n * date : 2021-02-19 09:55:24\r\n */\r\n\r\n#define NDEBUG\r\nusing namespace std;\r\r// intrinstic\r#include \r\r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r#include \r\r// utility\rnamespace Nyaan {\rusing ll = long long;\rusing i64 = long long;\rusing u64 = unsigned long long;\rusing i128 = __int128_t;\rusing u128 = __uint128_t;\r\rtemplate \rusing V = vector;\rtemplate \rusing VV = vector>;\rusing vi = vector;\rusing vl = vector;\rusing vd = V;\rusing vs = V;\rusing vvi = vector>;\rusing vvl = vector>;\r\rtemplate \rstruct P : pair {\r template \r P(Args... args) : pair(args...) {}\r\r using pair::first;\r using pair::second;\r\r T &x() { return first; }\r const T &x() const { return first; }\r U &y() { return second; }\r const U &y() const { return second; }\r\r P &operator+=(const P &r) {\r first += r.first;\r second += r.second;\r return *this;\r }\r P &operator-=(const P &r) {\r first -= r.first;\r second -= r.second;\r return *this;\r }\r P &operator*=(const P &r) {\r first *= r.first;\r second *= r.second;\r return *this;\r }\r P operator+(const P &r) const { return P(*this) += r; }\r P operator-(const P &r) const { return P(*this) -= r; }\r P operator*(const P &r) const { return P(*this) *= r; }\r};\r\rusing pl = P;\rusing pi = P;\rusing vp = V;\r\rconstexpr int inf = 1001001001;\rconstexpr long long infLL = 4004004004004004004LL;\r\rtemplate \rint sz(const T &t) {\r return t.size();\r}\rtemplate \rvoid mem(T (&a)[N], int c) {\r memset(a, c, sizeof(T) * N);\r}\r\rtemplate \rinline bool amin(T &x, U y) {\r return (y < x) ? (x = y, true) : false;\r}\rtemplate \rinline bool amax(T &x, U y) {\r return (x < y) ? (x = y, true) : false;\r}\r\rtemplate \rint lb(const vector &v, const T &a) {\r return lower_bound(begin(v), end(v), a) - begin(v);\r}\rtemplate \rint ub(const vector &v, const T &a) {\r return upper_bound(begin(v), end(v), a) - begin(v);\r}\r\rconstexpr long long TEN(int n) {\r long long ret = 1, x = 10;\r for (; n; x *= x, n >>= 1) ret *= (n & 1 ? x : 1);\r return ret;\r}\r\rtemplate \rpair mkp(const T &t, const U &u) {\r return make_pair(t, u);\r}\r\rtemplate \rvector mkrui(const vector &v, bool rev = false) {\r vector ret(v.size() + 1);\r if (rev) {\r for (int i = int(v.size()) - 1; i >= 0; i--) ret[i] = v[i] + ret[i + 1];\r } else {\r for (int i = 0; i < int(v.size()); i++) ret[i + 1] = ret[i] + v[i];\r }\r return ret;\r};\r\rtemplate \rvector mkuni(const vector &v) {\r vector ret(v);\r sort(ret.begin(), ret.end());\r ret.erase(unique(ret.begin(), ret.end()), ret.end());\r return ret;\r}\r\rtemplate \rvector mkord(int N, F f) {\r vector ord(N);\r iota(begin(ord), end(ord), 0);\r sort(begin(ord), end(ord), f);\r return ord;\r}\r\rtemplate \rvector reord(const vector &v, const vector &ord) {\r int N = v.size();\r vector ret(N);\r for (int i = 0; i < N; i++) ret[i] = v[ord[i]];\r return ret;\r};\r\rtemplate \rvector mkiota(int N) {\r vector ret(N);\r iota(begin(ret), end(ret), 0);\r return ret;\r}\r\rtemplate \rvector mkinv(vector &v, int max_val = -1) {\r if (max_val < (int)v.size()) max_val = v.size() - 1;\r vector inv(max_val + 1, -1);\r for (int i = 0; i < (int)v.size(); i++) inv[v[i]] = i;\r return inv;\r}\r\r} // namespace Nyaan\r\r// bit operation\rnamespace Nyaan {\r\r__attribute__((target(\"popcnt\"))) inline int popcnt(const u64 &a) {\r return _mm_popcnt_u64(a);\r}\r\r__attribute__((target(\"bmi\"))) inline int lsb(const u64 &a) {\r return _tzcnt_u64(a);\r}\r__attribute__((target(\"bmi\"))) inline int ctz(const u64 &a) {\r return _tzcnt_u64(a);\r}\r\r__attribute__((target(\"lzcnt\"))) inline int msb(const u64 &a) {\r return 63 - _lzcnt_u64(a);\r}\r__attribute__((target(\"lzcnt\"))) inline int clz64(const u64 &a) {\r return _lzcnt_u64(a);\r}\r\rtemplate \rinline int gbit(const T &a, int i) {\r return (a >> i) & 1;\r}\rtemplate \rinline void sbit(T &a, int i, bool b) {\r a ^= (gbit(a, i) == b ? 0 : (T(b) << i));\r}\r\rconstexpr long long PW(int n) { return 1LL << n; }\r\rconstexpr long long MSK(int n) { return (1LL << n) - 1; }\r\r} // namespace Nyaan\r\r// inout\rnamespace Nyaan {\r\rtemplate \rostream &operator<<(ostream &os, const pair &p) {\r os << p.first << \" \" << p.second;\r return os;\r}\rtemplate \ristream &operator>>(istream &is, pair &p) {\r is >> p.first >> p.second;\r return is;\r}\r\rtemplate \rostream &operator<<(ostream &os, const vector &v) {\r int s = (int)v.size();\r for (int i = 0; i < s; i++) os << (i ? \" \" : \"\") << v[i];\r return os;\r}\rtemplate \ristream &operator>>(istream &is, vector &v) {\r for (auto &x : v) is >> x;\r return is;\r}\r\rvoid in() {}\rtemplate \rvoid in(T &t, U &... u) {\r cin >> t;\r in(u...);\r}\r\rvoid out() { cout << \"\\n\"; }\rtemplate \rvoid out(const T &t, const U &... u) {\r cout << t;\r if (sizeof...(u)) cout << sep;\r out(u...);\r}\r\rvoid outr() {}\rtemplate \rvoid outr(const T &t, const U &... u) {\r cout << t;\r outr(u...);\r}\r\rstruct IoSetupNya {\r IoSetupNya() {\r cin.tie(nullptr);\r ios::sync_with_stdio(false);\r cout << fixed << setprecision(15);\r cerr << fixed << setprecision(7);\r }\r} iosetupnya;\r\r} // namespace Nyaan\r\r// debug\rnamespace DebugImpl {\r\rtemplate \rstruct is_specialize : false_type {};\rtemplate \rstruct is_specialize<\r U, typename conditional::type>\r : true_type {};\rtemplate \rstruct is_specialize<\r U, typename conditional::type>\r : true_type {};\rtemplate \rstruct is_specialize::value, void>> : true_type {\r};\r\rvoid dump(const char& t) { cerr << t; }\r\rvoid dump(const string& t) { cerr << t; }\r\rtemplate ::value, nullptr_t> = nullptr>\rvoid dump(const U& t) {\r cerr << t;\r}\r\rtemplate \rvoid dump(const T& t, enable_if_t::value>* = nullptr) {\r string res;\r if (t == Nyaan::inf) res = \"inf\";\r if (is_signed::value)\r if (t == -Nyaan::inf) res = \"-inf\";\r if (sizeof(T) == 8) {\r if (t == Nyaan::infLL) res = \"inf\";\r if (is_signed::value)\r if (t == -Nyaan::infLL) res = \"-inf\";\r }\r if (res.empty()) res = to_string(t);\r cerr << res;\r}\r\rtemplate \rvoid dump(const pair&);\rtemplate \rvoid dump(const pair&);\r\rtemplate \rvoid dump(const T& t,\r enable_if_t::value>* = nullptr) {\r cerr << \"[ \";\r for (auto it = t.begin(); it != t.end();) {\r dump(*it);\r cerr << (++it == t.end() ? \"\" : \", \");\r }\r cerr << \" ]\";\r}\r\rtemplate \rvoid dump(const pair& t) {\r cerr << \"( \";\r dump(t.first);\r cerr << \", \";\r dump(t.second);\r cerr << \" )\";\r}\r\rtemplate \rvoid dump(const pair& t) {\r cerr << \"[ \";\r for (int i = 0; i < t.second; i++) {\r dump(t.first[i]);\r cerr << (i == t.second - 1 ? \"\" : \", \");\r }\r cerr << \" ]\";\r}\r\rvoid trace() { cerr << endl; }\rtemplate \rvoid trace(Head&& head, Tail&&... tail) {\r cerr << \" \";\r dump(head);\r if (sizeof...(tail) != 0) cerr << \",\";\r trace(forward(tail)...);\r}\r\r} // namespace DebugImpl\r\r#ifdef NyaanDebug\r#define trc(...) \\\r do { \\\r cerr << \"## \" << #__VA_ARGS__ << \" = \"; \\\r DebugImpl::trace(__VA_ARGS__); \\\r } while (0)\r#else\r#define trc(...)\r#endif\r\r// macro\r#define each(x, v) for (auto&& x : v)\r#define each2(x, y, v) for (auto&& [x, y] : v)\r#define all(v) (v).begin(), (v).end()\r#define rep(i, N) for (long long i = 0; i < (long long)(N); i++)\r#define repr(i, N) for (long long i = (long long)(N)-1; i >= 0; i--)\r#define rep1(i, N) for (long long i = 1; i <= (long long)(N); i++)\r#define repr1(i, N) for (long long i = (N); (long long)(i) > 0; i--)\r#define reg(i, a, b) for (long long i = (a); i < (b); i++)\r#define regr(i, a, b) for (long long i = (b)-1; i >= (a); i--)\r#define repc(i, a, cond) for (long long i = (a); (cond); i++)\r#define enm(i, val, vec) \\\r for (long long i = 0; i < (long long)(vec).size(); i++) \\\r if (auto& val = vec[i]; false) \\\r ; \\\r else\r\r#define ini(...) \\\r int __VA_ARGS__; \\\r in(__VA_ARGS__)\r#define inl(...) \\\r long long __VA_ARGS__; \\\r in(__VA_ARGS__)\r#define ins(...) \\\r string __VA_ARGS__; \\\r in(__VA_ARGS__)\r#define inc(...) \\\r char __VA_ARGS__; \\\r in(__VA_ARGS__)\r#define in2(s, t) \\\r for (int i = 0; i < (int)s.size(); i++) { \\\r in(s[i], t[i]); \\\r }\r#define in3(s, t, u) \\\r for (int i = 0; i < (int)s.size(); i++) { \\\r in(s[i], t[i], u[i]); \\\r }\r#define in4(s, t, u, v) \\\r for (int i = 0; i < (int)s.size(); i++) { \\\r in(s[i], t[i], u[i], v[i]); \\\r }\r\r#define die(...) \\\r do { \\\r Nyaan::out(__VA_ARGS__); \\\r return; \\\r } while (0)\r\rnamespace Nyaan {\rvoid solve();\r}\rint main() { Nyaan::solve(); }\r\r//\r\r\r\r\r#include \r\r__attribute__((target(\"sse4.2\"))) __attribute__((always_inline)) __m128i\rmy128_mullo_epu32(const __m128i &a, const __m128i &b) {\r return _mm_mullo_epi32(a, b);\r}\r\r__attribute__((target(\"sse4.2\"))) __attribute__((always_inline)) __m128i\rmy128_mulhi_epu32(const __m128i &a, const __m128i &b) {\r __m128i a13 = _mm_shuffle_epi32(a, 0xF5);\r __m128i b13 = _mm_shuffle_epi32(b, 0xF5);\r __m128i prod02 = _mm_mul_epu32(a, b);\r __m128i prod13 = _mm_mul_epu32(a13, b13);\r __m128i prod = _mm_unpackhi_epi64(_mm_unpacklo_epi32(prod02, prod13),\r _mm_unpackhi_epi32(prod02, prod13));\r return prod;\r}\r\r__attribute__((target(\"sse4.2\"))) __attribute__((always_inline)) __m128i\rmontgomery_mul_128(const __m128i &a, const __m128i &b, const __m128i &r,\r const __m128i &m1) {\r return _mm_sub_epi32(\r _mm_add_epi32(my128_mulhi_epu32(a, b), m1),\r my128_mulhi_epu32(my128_mullo_epu32(my128_mullo_epu32(a, b), r), m1));\r}\r\r__attribute__((target(\"sse4.2\"))) __attribute__((always_inline)) __m128i\rmontgomery_add_128(const __m128i &a, const __m128i &b, const __m128i &m2,\r const __m128i &m0) {\r __m128i ret = _mm_sub_epi32(_mm_add_epi32(a, b), m2);\r return _mm_add_epi32(_mm_and_si128(_mm_cmpgt_epi32(m0, ret), m2), ret);\r}\r\r__attribute__((target(\"sse4.2\"))) __attribute__((always_inline)) __m128i\rmontgomery_sub_128(const __m128i &a, const __m128i &b, const __m128i &m2,\r const __m128i &m0) {\r __m128i ret = _mm_sub_epi32(a, b);\r return _mm_add_epi32(_mm_and_si128(_mm_cmpgt_epi32(m0, ret), m2), ret);\r}\r\r__attribute__((target(\"avx2\"))) __attribute__((always_inline)) __m256i\rmy256_mullo_epu32(const __m256i &a, const __m256i &b) {\r return _mm256_mullo_epi32(a, b);\r}\r\r__attribute__((target(\"avx2\"))) __attribute__((always_inline)) __m256i\rmy256_mulhi_epu32(const __m256i &a, const __m256i &b) {\r __m256i a13 = _mm256_shuffle_epi32(a, 0xF5);\r __m256i b13 = _mm256_shuffle_epi32(b, 0xF5);\r __m256i prod02 = _mm256_mul_epu32(a, b);\r __m256i prod13 = _mm256_mul_epu32(a13, b13);\r __m256i prod = _mm256_unpackhi_epi64(_mm256_unpacklo_epi32(prod02, prod13),\r _mm256_unpackhi_epi32(prod02, prod13));\r return prod;\r}\r\r__attribute__((target(\"avx2\"))) __attribute__((always_inline)) __m256i\rmontgomery_mul_256(const __m256i &a, const __m256i &b, const __m256i &r,\r const __m256i &m1) {\r return _mm256_sub_epi32(\r _mm256_add_epi32(my256_mulhi_epu32(a, b), m1),\r my256_mulhi_epu32(my256_mullo_epu32(my256_mullo_epu32(a, b), r), m1));\r}\r\r__attribute__((target(\"avx2\"))) __attribute__((always_inline)) __m256i\rmontgomery_add_256(const __m256i &a, const __m256i &b, const __m256i &m2,\r const __m256i &m0) {\r __m256i ret = _mm256_sub_epi32(_mm256_add_epi32(a, b), m2);\r return _mm256_add_epi32(_mm256_and_si256(_mm256_cmpgt_epi32(m0, ret), m2),\r ret);\r}\r\r__attribute__((target(\"avx2\"))) __attribute__((always_inline)) __m256i\rmontgomery_sub_256(const __m256i &a, const __m256i &b, const __m256i &m2,\r const __m256i &m0) {\r __m256i ret = _mm256_sub_epi32(a, b);\r return _mm256_add_epi32(_mm256_and_si256(_mm256_cmpgt_epi32(m0, ret), m2),\r ret);\r}\rnamespace ntt_inner {\rusing u64 = uint64_t;\rconstexpr uint32_t get_pr(uint32_t mod) {\r if (mod == 2) return 1;\r u64 ds[32] = {};\r int idx = 0;\r u64 m = mod - 1;\r for (u64 i = 2; i * i <= m; ++i) {\r if (m % i == 0) {\r ds[idx++] = i;\r while (m % i == 0) m /= i;\r }\r }\r if (m != 1) ds[idx++] = m;\r\r uint32_t pr = 2;\r while (1) {\r int flg = 1;\r for (int i = 0; i < idx; ++i) {\r u64 a = pr, b = (mod - 1) / ds[i], r = 1;\r while (b) {\r if (b & 1) r = r * a % mod;\r a = a * a % mod;\r b >>= 1;\r }\r if (r == 1) {\r flg = 0;\r break;\r }\r }\r if (flg == 1) break;\r ++pr;\r }\r return pr;\r}\r\rconstexpr int SZ_FFT_BUF = 1 << 23;\ruint32_t _buf1[SZ_FFT_BUF] __attribute__((aligned(64)));\ruint32_t _buf2[SZ_FFT_BUF] __attribute__((aligned(64)));\r} // namespace ntt_inner\r\rtemplate \rstruct NTT {\r static constexpr uint32_t mod = mint::get_mod();\r static constexpr uint32_t pr = ntt_inner::get_pr(mint::get_mod());\r static constexpr int level = __builtin_ctzll(mod - 1);\r mint dw[level], dy[level];\r mint *buf1, *buf2;\r\r constexpr NTT() {\r setwy(level);\r union raw_cast {\r mint dat;\r uint32_t _;\r };\r buf1 = &(((raw_cast *)(ntt_inner::_buf1))->dat);\r buf2 = &(((raw_cast *)(ntt_inner::_buf2))->dat);\r }\r\r constexpr void setwy(int k) {\r mint w[level], y[level];\r w[k - 1] = mint(pr).pow((mod - 1) / (1 << k));\r y[k - 1] = w[k - 1].inverse();\r for (int i = k - 2; i > 0; --i)\r w[i] = w[i + 1] * w[i + 1], y[i] = y[i + 1] * y[i + 1];\r dw[0] = dy[0] = w[1] * w[1];\r dw[1] = w[1], dy[1] = y[1], dw[2] = w[2], dy[2] = y[2];\r for (int i = 3; i < k; ++i) {\r dw[i] = dw[i - 1] * y[i - 2] * w[i];\r dy[i] = dy[i - 1] * w[i - 2] * y[i];\r }\r }\r\r __attribute__((target(\"avx2\"))) void ntt(mint *a, int n) {\r int k = n ? __builtin_ctz(n) : 0;\r if (k == 0) return;\r if (k == 1) {\r mint a1 = a[1];\r a[1] = a[0] - a[1];\r a[0] = a[0] + a1;\r return;\r }\r if (k & 1) {\r int v = 1 << (k - 1);\r if (v < 8) {\r for (int j = 0; j < v; ++j) {\r mint ajv = a[j + v];\r a[j + v] = a[j] - ajv;\r a[j] += ajv;\r }\r } else {\r const __m256i m0 = _mm256_set1_epi32(0);\r const __m256i m2 = _mm256_set1_epi32(mod + mod);\r int j0 = 0;\r int j1 = v;\r for (; j0 < v; j0 += 8, j1 += 8) {\r __m256i T0 = _mm256_loadu_si256((__m256i *)(a + j0));\r __m256i T1 = _mm256_loadu_si256((__m256i *)(a + j1));\r __m256i naj = montgomery_add_256(T0, T1, m2, m0);\r __m256i najv = montgomery_sub_256(T0, T1, m2, m0);\r _mm256_storeu_si256((__m256i *)(a + j0), naj);\r _mm256_storeu_si256((__m256i *)(a + j1), najv);\r }\r }\r }\r int u = 1 << (2 + (k & 1));\r int v = 1 << (k - 2 - (k & 1));\r mint one = mint(1);\r mint imag = dw[1];\r while (v) {\r if (v == 1) {\r mint ww = one, xx = one, wx = one;\r for (int jh = 0; jh < u;) {\r ww = xx * xx, wx = ww * xx;\r mint t0 = a[jh + 0], t1 = a[jh + 1] * xx;\r mint t2 = a[jh + 2] * ww, t3 = a[jh + 3] * wx;\r mint t0p2 = t0 + t2, t1p3 = t1 + t3;\r mint t0m2 = t0 - t2, t1m3 = (t1 - t3) * imag;\r a[jh + 0] = t0p2 + t1p3, a[jh + 1] = t0p2 - t1p3;\r a[jh + 2] = t0m2 + t1m3, a[jh + 3] = t0m2 - t1m3;\r xx *= dw[__builtin_ctz((jh += 4))];\r }\r } else if (v == 4) {\r const __m128i m0 = _mm_set1_epi32(0);\r const __m128i m1 = _mm_set1_epi32(mod);\r const __m128i m2 = _mm_set1_epi32(mod + mod);\r const __m128i r = _mm_set1_epi32(mint::r);\r const __m128i Imag = _mm_set1_epi32(imag.a);\r mint ww = one, xx = one, wx = one;\r for (int jh = 0; jh < u;) {\r if (jh == 0) {\r int j0 = 0;\r int j1 = v;\r int j2 = j1 + v;\r int j3 = j2 + v;\r int je = v;\r for (; j0 < je; j0 += 4, j1 += 4, j2 += 4, j3 += 4) {\r const __m128i T0 = _mm_loadu_si128((__m128i *)(a + j0));\r const __m128i T1 = _mm_loadu_si128((__m128i *)(a + j1));\r const __m128i T2 = _mm_loadu_si128((__m128i *)(a + j2));\r const __m128i T3 = _mm_loadu_si128((__m128i *)(a + j3));\r const __m128i T0P2 = montgomery_add_128(T0, T2, m2, m0);\r const __m128i T1P3 = montgomery_add_128(T1, T3, m2, m0);\r const __m128i T0M2 = montgomery_sub_128(T0, T2, m2, m0);\r const __m128i T1M3 = montgomery_mul_128(\r montgomery_sub_128(T1, T3, m2, m0), Imag, r, m1);\r _mm_storeu_si128((__m128i *)(a + j0),\r montgomery_add_128(T0P2, T1P3, m2, m0));\r _mm_storeu_si128((__m128i *)(a + j1),\r montgomery_sub_128(T0P2, T1P3, m2, m0));\r _mm_storeu_si128((__m128i *)(a + j2),\r montgomery_add_128(T0M2, T1M3, m2, m0));\r _mm_storeu_si128((__m128i *)(a + j3),\r montgomery_sub_128(T0M2, T1M3, m2, m0));\r }\r } else {\r ww = xx * xx, wx = ww * xx;\r const __m128i WW = _mm_set1_epi32(ww.a);\r const __m128i WX = _mm_set1_epi32(wx.a);\r const __m128i XX = _mm_set1_epi32(xx.a);\r int j0 = jh * v;\r int j1 = j0 + v;\r int j2 = j1 + v;\r int j3 = j2 + v;\r int je = j1;\r for (; j0 < je; j0 += 4, j1 += 4, j2 += 4, j3 += 4) {\r const __m128i T0 = _mm_loadu_si128((__m128i *)(a + j0));\r const __m128i T1 = _mm_loadu_si128((__m128i *)(a + j1));\r const __m128i T2 = _mm_loadu_si128((__m128i *)(a + j2));\r const __m128i T3 = _mm_loadu_si128((__m128i *)(a + j3));\r const __m128i MT1 = montgomery_mul_128(T1, XX, r, m1);\r const __m128i MT2 = montgomery_mul_128(T2, WW, r, m1);\r const __m128i MT3 = montgomery_mul_128(T3, WX, r, m1);\r const __m128i T0P2 = montgomery_add_128(T0, MT2, m2, m0);\r const __m128i T1P3 = montgomery_add_128(MT1, MT3, m2, m0);\r const __m128i T0M2 = montgomery_sub_128(T0, MT2, m2, m0);\r const __m128i T1M3 = montgomery_mul_128(\r montgomery_sub_128(MT1, MT3, m2, m0), Imag, r, m1);\r _mm_storeu_si128((__m128i *)(a + j0),\r montgomery_add_128(T0P2, T1P3, m2, m0));\r _mm_storeu_si128((__m128i *)(a + j1),\r montgomery_sub_128(T0P2, T1P3, m2, m0));\r _mm_storeu_si128((__m128i *)(a + j2),\r montgomery_add_128(T0M2, T1M3, m2, m0));\r _mm_storeu_si128((__m128i *)(a + j3),\r montgomery_sub_128(T0M2, T1M3, m2, m0));\r }\r }\r xx *= dw[__builtin_ctz((jh += 4))];\r }\r } else {\r const __m256i m0 = _mm256_set1_epi32(0);\r const __m256i m1 = _mm256_set1_epi32(mod);\r const __m256i m2 = _mm256_set1_epi32(mod + mod);\r const __m256i r = _mm256_set1_epi32(mint::r);\r const __m256i Imag = _mm256_set1_epi32(imag.a);\r mint ww = one, xx = one, wx = one;\r for (int jh = 0; jh < u;) {\r if (jh == 0) {\r int j0 = 0;\r int j1 = v;\r int j2 = j1 + v;\r int j3 = j2 + v;\r int je = v;\r for (; j0 < je; j0 += 8, j1 += 8, j2 += 8, j3 += 8) {\r const __m256i T0 = _mm256_loadu_si256((__m256i *)(a + j0));\r const __m256i T1 = _mm256_loadu_si256((__m256i *)(a + j1));\r const __m256i T2 = _mm256_loadu_si256((__m256i *)(a + j2));\r const __m256i T3 = _mm256_loadu_si256((__m256i *)(a + j3));\r const __m256i T0P2 = montgomery_add_256(T0, T2, m2, m0);\r const __m256i T1P3 = montgomery_add_256(T1, T3, m2, m0);\r const __m256i T0M2 = montgomery_sub_256(T0, T2, m2, m0);\r const __m256i T1M3 = montgomery_mul_256(\r montgomery_sub_256(T1, T3, m2, m0), Imag, r, m1);\r _mm256_storeu_si256((__m256i *)(a + j0),\r montgomery_add_256(T0P2, T1P3, m2, m0));\r _mm256_storeu_si256((__m256i *)(a + j1),\r montgomery_sub_256(T0P2, T1P3, m2, m0));\r _mm256_storeu_si256((__m256i *)(a + j2),\r montgomery_add_256(T0M2, T1M3, m2, m0));\r _mm256_storeu_si256((__m256i *)(a + j3),\r montgomery_sub_256(T0M2, T1M3, m2, m0));\r }\r } else {\r ww = xx * xx, wx = ww * xx;\r const __m256i WW = _mm256_set1_epi32(ww.a);\r const __m256i WX = _mm256_set1_epi32(wx.a);\r const __m256i XX = _mm256_set1_epi32(xx.a);\r int j0 = jh * v;\r int j1 = j0 + v;\r int j2 = j1 + v;\r int j3 = j2 + v;\r int je = j1;\r for (; j0 < je; j0 += 8, j1 += 8, j2 += 8, j3 += 8) {\r const __m256i T0 = _mm256_loadu_si256((__m256i *)(a + j0));\r const __m256i T1 = _mm256_loadu_si256((__m256i *)(a + j1));\r const __m256i T2 = _mm256_loadu_si256((__m256i *)(a + j2));\r const __m256i T3 = _mm256_loadu_si256((__m256i *)(a + j3));\r const __m256i MT1 = montgomery_mul_256(T1, XX, r, m1);\r const __m256i MT2 = montgomery_mul_256(T2, WW, r, m1);\r const __m256i MT3 = montgomery_mul_256(T3, WX, r, m1);\r const __m256i T0P2 = montgomery_add_256(T0, MT2, m2, m0);\r const __m256i T1P3 = montgomery_add_256(MT1, MT3, m2, m0);\r const __m256i T0M2 = montgomery_sub_256(T0, MT2, m2, m0);\r const __m256i T1M3 = montgomery_mul_256(\r montgomery_sub_256(MT1, MT3, m2, m0), Imag, r, m1);\r _mm256_storeu_si256((__m256i *)(a + j0),\r montgomery_add_256(T0P2, T1P3, m2, m0));\r _mm256_storeu_si256((__m256i *)(a + j1),\r montgomery_sub_256(T0P2, T1P3, m2, m0));\r _mm256_storeu_si256((__m256i *)(a + j2),\r montgomery_add_256(T0M2, T1M3, m2, m0));\r _mm256_storeu_si256((__m256i *)(a + j3),\r montgomery_sub_256(T0M2, T1M3, m2, m0));\r }\r }\r xx *= dw[__builtin_ctz((jh += 4))];\r }\r }\r u <<= 2;\r v >>= 2;\r }\r }\r\r __attribute__((target(\"avx2\"))) void intt(mint *a, int n,\r int normalize = true) {\r int k = n ? __builtin_ctz(n) : 0;\r if (k == 0) return;\r if (k == 1) {\r mint a1 = a[1];\r a[1] = a[0] - a[1];\r a[0] = a[0] + a1;\r if (normalize) {\r a[0] *= mint(2).inverse();\r a[1] *= mint(2).inverse();\r }\r return;\r }\r int u = 1 << (k - 2);\r int v = 1;\r mint one = mint(1);\r mint imag = dy[1];\r while (u) {\r if (v == 1) {\r mint ww = one, xx = one, yy = one;\r u <<= 2;\r for (int jh = 0; jh < u;) {\r ww = xx * xx, yy = xx * imag;\r mint t0 = a[jh + 0], t1 = a[jh + 1];\r mint t2 = a[jh + 2], t3 = a[jh + 3];\r mint t0p1 = t0 + t1, t2p3 = t2 + t3;\r mint t0m1 = (t0 - t1) * xx, t2m3 = (t2 - t3) * yy;\r a[jh + 0] = t0p1 + t2p3, a[jh + 2] = (t0p1 - t2p3) * ww;\r a[jh + 1] = t0m1 + t2m3, a[jh + 3] = (t0m1 - t2m3) * ww;\r xx *= dy[__builtin_ctz(jh += 4)];\r }\r } else if (v == 4) {\r const __m128i m0 = _mm_set1_epi32(0);\r const __m128i m1 = _mm_set1_epi32(mod);\r const __m128i m2 = _mm_set1_epi32(mod + mod);\r const __m128i r = _mm_set1_epi32(mint::r);\r const __m128i Imag = _mm_set1_epi32(imag.a);\r mint ww = one, xx = one, yy = one;\r u <<= 2;\r for (int jh = 0; jh < u;) {\r if (jh == 0) {\r int j0 = 0;\r int j1 = v;\r int j2 = v + v;\r int j3 = j2 + v;\r for (; j0 < v; j0 += 4, j1 += 4, j2 += 4, j3 += 4) {\r const __m128i T0 = _mm_loadu_si128((__m128i *)(a + j0));\r const __m128i T1 = _mm_loadu_si128((__m128i *)(a + j1));\r const __m128i T2 = _mm_loadu_si128((__m128i *)(a + j2));\r const __m128i T3 = _mm_loadu_si128((__m128i *)(a + j3));\r const __m128i T0P1 = montgomery_add_128(T0, T1, m2, m0);\r const __m128i T2P3 = montgomery_add_128(T2, T3, m2, m0);\r const __m128i T0M1 = montgomery_sub_128(T0, T1, m2, m0);\r const __m128i T2M3 = montgomery_mul_128(\r montgomery_sub_128(T2, T3, m2, m0), Imag, r, m1);\r _mm_storeu_si128((__m128i *)(a + j0),\r montgomery_add_128(T0P1, T2P3, m2, m0));\r _mm_storeu_si128((__m128i *)(a + j2),\r montgomery_sub_128(T0P1, T2P3, m2, m0));\r _mm_storeu_si128((__m128i *)(a + j1),\r montgomery_add_128(T0M1, T2M3, m2, m0));\r _mm_storeu_si128((__m128i *)(a + j3),\r montgomery_sub_128(T0M1, T2M3, m2, m0));\r }\r } else {\r ww = xx * xx, yy = xx * imag;\r const __m128i WW = _mm_set1_epi32(ww.a);\r const __m128i XX = _mm_set1_epi32(xx.a);\r const __m128i YY = _mm_set1_epi32(yy.a);\r int j0 = jh * v;\r int j1 = j0 + v;\r int j2 = j1 + v;\r int j3 = j2 + v;\r int je = j1;\r for (; j0 < je; j0 += 4, j1 += 4, j2 += 4, j3 += 4) {\r const __m128i T0 = _mm_loadu_si128((__m128i *)(a + j0));\r const __m128i T1 = _mm_loadu_si128((__m128i *)(a + j1));\r const __m128i T2 = _mm_loadu_si128((__m128i *)(a + j2));\r const __m128i T3 = _mm_loadu_si128((__m128i *)(a + j3));\r const __m128i T0P1 = montgomery_add_128(T0, T1, m2, m0);\r const __m128i T2P3 = montgomery_add_128(T2, T3, m2, m0);\r const __m128i T0M1 = montgomery_mul_128(\r montgomery_sub_128(T0, T1, m2, m0), XX, r, m1);\r __m128i T2M3 = montgomery_mul_128(\r montgomery_sub_128(T2, T3, m2, m0), YY, r, m1);\r _mm_storeu_si128((__m128i *)(a + j0),\r montgomery_add_128(T0P1, T2P3, m2, m0));\r _mm_storeu_si128(\r (__m128i *)(a + j2),\r montgomery_mul_128(montgomery_sub_128(T0P1, T2P3, m2, m0), WW,\r r, m1));\r _mm_storeu_si128((__m128i *)(a + j1),\r montgomery_add_128(T0M1, T2M3, m2, m0));\r _mm_storeu_si128(\r (__m128i *)(a + j3),\r montgomery_mul_128(montgomery_sub_128(T0M1, T2M3, m2, m0), WW,\r r, m1));\r }\r }\r xx *= dy[__builtin_ctz(jh += 4)];\r }\r } else {\r const __m256i m0 = _mm256_set1_epi32(0);\r const __m256i m1 = _mm256_set1_epi32(mod);\r const __m256i m2 = _mm256_set1_epi32(mod + mod);\r const __m256i r = _mm256_set1_epi32(mint::r);\r const __m256i Imag = _mm256_set1_epi32(imag.a);\r mint ww = one, xx = one, yy = one;\r u <<= 2;\r for (int jh = 0; jh < u;) {\r if (jh == 0) {\r int j0 = 0;\r int j1 = v;\r int j2 = v + v;\r int j3 = j2 + v;\r for (; j0 < v; j0 += 8, j1 += 8, j2 += 8, j3 += 8) {\r const __m256i T0 = _mm256_loadu_si256((__m256i *)(a + j0));\r const __m256i T1 = _mm256_loadu_si256((__m256i *)(a + j1));\r const __m256i T2 = _mm256_loadu_si256((__m256i *)(a + j2));\r const __m256i T3 = _mm256_loadu_si256((__m256i *)(a + j3));\r const __m256i T0P1 = montgomery_add_256(T0, T1, m2, m0);\r const __m256i T2P3 = montgomery_add_256(T2, T3, m2, m0);\r const __m256i T0M1 = montgomery_sub_256(T0, T1, m2, m0);\r const __m256i T2M3 = montgomery_mul_256(\r montgomery_sub_256(T2, T3, m2, m0), Imag, r, m1);\r _mm256_storeu_si256((__m256i *)(a + j0),\r montgomery_add_256(T0P1, T2P3, m2, m0));\r _mm256_storeu_si256((__m256i *)(a + j2),\r montgomery_sub_256(T0P1, T2P3, m2, m0));\r _mm256_storeu_si256((__m256i *)(a + j1),\r montgomery_add_256(T0M1, T2M3, m2, m0));\r _mm256_storeu_si256((__m256i *)(a + j3),\r montgomery_sub_256(T0M1, T2M3, m2, m0));\r }\r } else {\r ww = xx * xx, yy = xx * imag;\r const __m256i WW = _mm256_set1_epi32(ww.a);\r const __m256i XX = _mm256_set1_epi32(xx.a);\r const __m256i YY = _mm256_set1_epi32(yy.a);\r int j0 = jh * v;\r int j1 = j0 + v;\r int j2 = j1 + v;\r int j3 = j2 + v;\r int je = j1;\r for (; j0 < je; j0 += 8, j1 += 8, j2 += 8, j3 += 8) {\r const __m256i T0 = _mm256_loadu_si256((__m256i *)(a + j0));\r const __m256i T1 = _mm256_loadu_si256((__m256i *)(a + j1));\r const __m256i T2 = _mm256_loadu_si256((__m256i *)(a + j2));\r const __m256i T3 = _mm256_loadu_si256((__m256i *)(a + j3));\r const __m256i T0P1 = montgomery_add_256(T0, T1, m2, m0);\r const __m256i T2P3 = montgomery_add_256(T2, T3, m2, m0);\r const __m256i T0M1 = montgomery_mul_256(\r montgomery_sub_256(T0, T1, m2, m0), XX, r, m1);\r const __m256i T2M3 = montgomery_mul_256(\r montgomery_sub_256(T2, T3, m2, m0), YY, r, m1);\r _mm256_storeu_si256((__m256i *)(a + j0),\r montgomery_add_256(T0P1, T2P3, m2, m0));\r _mm256_storeu_si256(\r (__m256i *)(a + j2),\r montgomery_mul_256(montgomery_sub_256(T0P1, T2P3, m2, m0), WW,\r r, m1));\r _mm256_storeu_si256((__m256i *)(a + j1),\r montgomery_add_256(T0M1, T2M3, m2, m0));\r _mm256_storeu_si256(\r (__m256i *)(a + j3),\r montgomery_mul_256(montgomery_sub_256(T0M1, T2M3, m2, m0), WW,\r r, m1));\r }\r }\r xx *= dy[__builtin_ctz(jh += 4)];\r }\r }\r u >>= 4;\r v <<= 2;\r }\r if (k & 1) {\r v = 1 << (k - 1);\r if (v < 8) {\r for (int j = 0; j < v; ++j) {\r mint ajv = a[j] - a[j + v];\r a[j] += a[j + v];\r a[j + v] = ajv;\r }\r } else {\r const __m256i m0 = _mm256_set1_epi32(0);\r const __m256i m2 = _mm256_set1_epi32(mod + mod);\r int j0 = 0;\r int j1 = v;\r for (; j0 < v; j0 += 8, j1 += 8) {\r const __m256i T0 = _mm256_loadu_si256((__m256i *)(a + j0));\r const __m256i T1 = _mm256_loadu_si256((__m256i *)(a + j1));\r __m256i naj = montgomery_add_256(T0, T1, m2, m0);\r __m256i najv = montgomery_sub_256(T0, T1, m2, m0);\r _mm256_storeu_si256((__m256i *)(a + j0), naj);\r _mm256_storeu_si256((__m256i *)(a + j1), najv);\r }\r }\r }\r if (normalize) {\r mint invn = mint(n).inverse();\r for (int i = 0; i < n; i++) a[i] *= invn;\r }\r }\r\r __attribute__((target(\"avx2\"))) void inplace_multiply(\r int l1, int l2, int zero_padding = true) {\r int l = l1 + l2 - 1;\r int M = 4;\r while (M < l) M <<= 1;\r if (zero_padding) {\r for (int i = l1; i < M; i++) ntt_inner::_buf1[i] = 0;\r for (int i = l2; i < M; i++) ntt_inner::_buf2[i] = 0;\r }\r const __m256i m0 = _mm256_set1_epi32(0);\r const __m256i m1 = _mm256_set1_epi32(mod);\r const __m256i r = _mm256_set1_epi32(mint::r);\r const __m256i N2 = _mm256_set1_epi32(mint::n2);\r for (int i = 0; i < l1; i += 8) {\r __m256i a = _mm256_loadu_si256((__m256i *)(ntt_inner::_buf1 + i));\r __m256i b = montgomery_mul_256(a, N2, r, m1);\r _mm256_storeu_si256((__m256i *)(ntt_inner::_buf1 + i), b);\r }\r for (int i = 0; i < l2; i += 8) {\r __m256i a = _mm256_loadu_si256((__m256i *)(ntt_inner::_buf2 + i));\r __m256i b = montgomery_mul_256(a, N2, r, m1);\r _mm256_storeu_si256((__m256i *)(ntt_inner::_buf2 + i), b);\r }\r ntt(buf1, M);\r ntt(buf2, M);\r for (int i = 0; i < M; i += 8) {\r __m256i a = _mm256_loadu_si256((__m256i *)(ntt_inner::_buf1 + i));\r __m256i b = _mm256_loadu_si256((__m256i *)(ntt_inner::_buf2 + i));\r __m256i c = montgomery_mul_256(a, b, r, m1);\r _mm256_storeu_si256((__m256i *)(ntt_inner::_buf1 + i), c);\r }\r intt(buf1, M, false);\r const __m256i INVM = _mm256_set1_epi32((mint(M).inverse()).a);\r for (int i = 0; i < l; i += 8) {\r __m256i a = _mm256_loadu_si256((__m256i *)(ntt_inner::_buf1 + i));\r __m256i b = montgomery_mul_256(a, INVM, r, m1);\r __m256i c = my256_mulhi_epu32(my256_mullo_epu32(b, r), m1);\r __m256i d = _mm256_and_si256(_mm256_cmpgt_epi32(c, m0), m1);\r __m256i e = _mm256_sub_epi32(d, c);\r _mm256_storeu_si256((__m256i *)(ntt_inner::_buf1 + i), e);\r }\r }\r\r void ntt(vector &a) {\r int M = (int)a.size();\r for (int i = 0; i < M; i++) buf1[i].a = a[i].a;\r ntt(buf1, M);\r for (int i = 0; i < M; i++) a[i].a = buf1[i].a;\r }\r\r void intt(vector &a) {\r int M = (int)a.size();\r for (int i = 0; i < M; i++) buf1[i].a = a[i].a;\r intt(buf1, M, true);\r for (int i = 0; i < M; i++) a[i].a = buf1[i].a;\r }\r\r vector multiply(const vector &a, const vector &b) {\r if (a.size() == 0 && b.size() == 0) return vector{};\r int l = a.size() + b.size() - 1;\r if (min(a.size(), b.size()) <= 40) {\r vector s(l);\r for (int i = 0; i < (int)a.size(); ++i)\r for (int j = 0; j < (int)b.size(); ++j) s[i + j] += a[i] * b[j];\r return s;\r }\r assert(l <= ntt_inner::SZ_FFT_BUF);\r int M = 4;\r while (M < l) M <<= 1;\r for (int i = 0; i < (int)a.size(); ++i) buf1[i].a = a[i].a;\r for (int i = (int)a.size(); i < M; ++i) buf1[i].a = 0;\r for (int i = 0; i < (int)b.size(); ++i) buf2[i].a = b[i].a;\r for (int i = (int)b.size(); i < M; ++i) buf2[i].a = 0;\r ntt(buf1, M);\r ntt(buf2, M);\r for (int i = 0; i < M; ++i)\r buf1[i].a = mint::reduce(uint64_t(buf1[i].a) * buf2[i].a);\r intt(buf1, M, false);\r vector s(l);\r mint invm = mint(M).inverse();\r for (int i = 0; i < l; ++i) s[i] = buf1[i] * invm;\r return s;\r }\r\r void ntt_doubling(vector &a) {\r int M = (int)a.size();\r for (int i = 0; i < M; i++) buf1[i].a = a[i].a;\r intt(buf1, M);\r mint r = 1, zeta = mint(pr).pow((mint::get_mod() - 1) / (M << 1));\r for (int i = 0; i < M; i++) buf1[i] *= r, r *= zeta;\r ntt(buf1, M);\r a.resize(2 * M);\r for (int i = 0; i < M; i++) a[M + i].a = buf1[i].a;\r }\r};\r\rtemplate \rstruct FormalPowerSeries : vector {\r using vector::vector;\r using FPS = FormalPowerSeries;\r\r FPS &operator+=(const FPS &r) {\r if (r.size() > this->size()) this->resize(r.size());\r for (int i = 0; i < (int)r.size(); i++) (*this)[i] += r[i];\r return *this;\r }\r\r FPS &operator+=(const mint &r) {\r if (this->empty()) this->resize(1);\r (*this)[0] += r;\r return *this;\r }\r\r FPS &operator-=(const FPS &r) {\r if (r.size() > this->size()) this->resize(r.size());\r for (int i = 0; i < (int)r.size(); i++) (*this)[i] -= r[i];\r return *this;\r }\r\r FPS &operator-=(const mint &r) {\r if (this->empty()) this->resize(1);\r (*this)[0] -= r;\r return *this;\r }\r\r FPS &operator*=(const mint &v) {\r for (int k = 0; k < (int)this->size(); k++) (*this)[k] *= v;\r return *this;\r }\r\r FPS &operator/=(const FPS &r) {\r if (this->size() < r.size()) {\r this->clear();\r return *this;\r }\r int n = this->size() - r.size() + 1;\r if ((int)r.size() <= 64) {\r FPS f(*this), g(r);\r g.shrink();\r mint coeff = g.back().inverse();\r for (auto &x : g) x *= coeff;\r int deg = (int)f.size() - (int)g.size() + 1;\r int gs = g.size();\r FPS quo(deg);\r for (int i = deg - 1; i >= 0; i--) {\r quo[i] = f[i + gs - 1];\r for (int j = 0; j < gs; j++) f[i + j] -= quo[i] * g[j];\r }\r *this = quo * coeff;\r this->resize(n, mint(0));\r return *this;\r }\r return *this = ((*this).rev().pre(n) * r.rev().inv(n)).pre(n).rev();\r }\r\r FPS &operator%=(const FPS &r) {\r *this -= *this / r * r;\r shrink();\r return *this;\r }\r\r FPS operator+(const FPS &r) const { return FPS(*this) += r; }\r FPS operator+(const mint &v) const { return FPS(*this) += v; }\r FPS operator-(const FPS &r) const { return FPS(*this) -= r; }\r FPS operator-(const mint &v) const { return FPS(*this) -= v; }\r FPS operator*(const FPS &r) const { return FPS(*this) *= r; }\r FPS operator*(const mint &v) const { return FPS(*this) *= v; }\r FPS operator/(const FPS &r) const { return FPS(*this) /= r; }\r FPS operator%(const FPS &r) const { return FPS(*this) %= r; }\r FPS operator-() const {\r FPS ret(this->size());\r for (int i = 0; i < (int)this->size(); i++) ret[i] = -(*this)[i];\r return ret;\r }\r\r void shrink() {\r while (this->size() && this->back() == mint(0)) this->pop_back();\r }\r\r FPS rev() const {\r FPS ret(*this);\r reverse(begin(ret), end(ret));\r return ret;\r }\r\r FPS dot(FPS r) const {\r FPS ret(min(this->size(), r.size()));\r for (int i = 0; i < (int)ret.size(); i++) ret[i] = (*this)[i] * r[i];\r return ret;\r }\r\r FPS pre(int sz) const {\r return FPS(begin(*this), begin(*this) + min((int)this->size(), sz));\r }\r\r FPS operator>>(int sz) const {\r if ((int)this->size() <= sz) return {};\r FPS ret(*this);\r ret.erase(ret.begin(), ret.begin() + sz);\r return ret;\r }\r\r FPS operator<<(int sz) const {\r FPS ret(*this);\r ret.insert(ret.begin(), sz, mint(0));\r return ret;\r }\r\r FPS diff() const {\r const int n = (int)this->size();\r FPS ret(max(0, n - 1));\r mint one(1), coeff(1);\r for (int i = 1; i < n; i++) {\r ret[i - 1] = (*this)[i] * coeff;\r coeff += one;\r }\r return ret;\r }\r\r FPS integral() const {\r const int n = (int)this->size();\r FPS ret(n + 1);\r ret[0] = mint(0);\r if (n > 0) ret[1] = mint(1);\r auto mod = mint::get_mod();\r for (int i = 2; i <= n; i++) ret[i] = (-ret[mod % i]) * (mod / i);\r for (int i = 0; i < n; i++) ret[i + 1] *= (*this)[i];\r return ret;\r }\r\r mint eval(mint x) const {\r mint r = 0, w = 1;\r for (auto &v : *this) r += w * v, w *= x;\r return r;\r }\r\r FPS log(int deg = -1) const {\r assert((*this)[0] == mint(1));\r if (deg == -1) deg = (int)this->size();\r return (this->diff() * this->inv(deg)).pre(deg - 1).integral();\r }\r\r FPS pow(int64_t k, int deg = -1) const {\r const int n = (int)this->size();\r if (deg == -1) deg = n;\r for (int i = 0; i < n; i++) {\r if ((*this)[i] != mint(0)) {\r if (i * k > deg) return FPS(deg, mint(0));\r mint rev = mint(1) / (*this)[i];\r FPS ret =\r (((*this * rev) >> i).log(deg) * k).exp(deg) * ((*this)[i].pow(k));\r ret = (ret << (i * k)).pre(deg);\r if ((int)ret.size() < deg) ret.resize(deg, mint(0));\r return ret;\r }\r }\r return FPS(deg, mint(0));\r }\r\r static void *ntt_ptr;\r static void set_fft();\r FPS &operator*=(const FPS &r);\r void ntt();\r void intt();\r void ntt_doubling();\r static int ntt_pr();\r FPS inv(int deg = -1) const;\r FPS exp(int deg = -1) const;\r};\rtemplate \rvoid *FormalPowerSeries::ntt_ptr = nullptr;\r\r/**\r * @brief \u591a\u9805\u5f0f/\u5f62\u5f0f\u7684\u51aa\u7d1a\u6570\u30e9\u30a4\u30d6\u30e9\u30ea\r * @docs docs/fps/formal-power-series.md\r */\r\rtemplate \rvoid FormalPowerSeries::set_fft() {\r if (!ntt_ptr) ntt_ptr = new NTT;\r}\r\rtemplate \rFormalPowerSeries& FormalPowerSeries::operator*=(\r const FormalPowerSeries& r) {\r if (this->empty() || r.empty()) {\r this->clear();\r return *this;\r }\r set_fft();\r auto ret = static_cast*>(ntt_ptr)->multiply(*this, r);\r return *this = FormalPowerSeries(ret.begin(), ret.end());\r}\r\rtemplate \rvoid FormalPowerSeries::ntt() {\r set_fft();\r static_cast*>(ntt_ptr)->ntt(*this);\r}\r\rtemplate \rvoid FormalPowerSeries::intt() {\r set_fft();\r static_cast*>(ntt_ptr)->intt(*this);\r}\r\rtemplate \rvoid FormalPowerSeries::ntt_doubling() {\r set_fft();\r static_cast*>(ntt_ptr)->ntt_doubling(*this);\r}\r\rtemplate \rint FormalPowerSeries::ntt_pr() {\r set_fft();\r return static_cast*>(ntt_ptr)->pr;\r}\r\rtemplate \rFormalPowerSeries FormalPowerSeries::inv(int deg) const {\r assert((*this)[0] != mint(0));\r if (deg == -1) deg = (int)this->size();\r FormalPowerSeries res(deg);\r res[0] = {mint(1) / (*this)[0]};\r for (int d = 1; d < deg; d <<= 1) {\r FormalPowerSeries f(2 * d), g(2 * d);\r for (int j = 0; j < min((int)this->size(), 2 * d); j++) f[j] = (*this)[j];\r for (int j = 0; j < d; j++) g[j] = res[j];\r f.ntt();\r g.ntt();\r for (int j = 0; j < 2 * d; j++) f[j] *= g[j];\r f.intt();\r for (int j = 0; j < d; j++) f[j] = 0;\r f.ntt();\r for (int j = 0; j < 2 * d; j++) f[j] *= g[j];\r f.intt();\r for (int j = d; j < min(2 * d, deg); j++) res[j] = -f[j];\r }\r return res.pre(deg);\r}\r\rtemplate \rFormalPowerSeries FormalPowerSeries::exp(int deg) const {\r using fps = FormalPowerSeries;\r assert((*this).size() == 0 || (*this)[0] == mint(0));\r if (deg == -1) deg = this->size();\r\r fps inv;\r inv.reserve(deg + 1);\r inv.push_back(mint(0));\r inv.push_back(mint(1));\r\r auto inplace_integral = [&](fps& F) -> void {\r const int n = (int)F.size();\r auto mod = mint::get_mod();\r while ((int)inv.size() <= n) {\r int i = inv.size();\r inv.push_back((-inv[mod % i]) * (mod / i));\r }\r F.insert(begin(F), mint(0));\r for (int i = 1; i <= n; i++) F[i] *= inv[i];\r };\r\r auto inplace_diff = [](fps& F) -> void {\r if (F.empty()) return;\r F.erase(begin(F));\r mint coeff = 1, one = 1;\r for (int i = 0; i < (int)F.size(); i++) {\r F[i] *= coeff;\r coeff += one;\r }\r };\r\r fps b{1, 1 < (int)this->size() ? (*this)[1] : 0}, c{1}, z1, z2{1, 1};\r for (int m = 2; m < deg; m *= 2) {\r auto y = b;\r y.resize(2 * m);\r y.ntt();\r z1 = z2;\r fps z(m);\r for (int i = 0; i < m; ++i) z[i] = y[i] * z1[i];\r z.intt();\r fill(begin(z), begin(z) + m / 2, mint(0));\r z.ntt();\r for (int i = 0; i < m; ++i) z[i] *= -z1[i];\r z.intt();\r c.insert(end(c), begin(z) + m / 2, end(z));\r z2 = c;\r z2.resize(2 * m);\r z2.ntt();\r fps x(begin(*this), begin(*this) + min(this->size(), m));\r inplace_diff(x);\r x.push_back(mint(0));\r x.ntt();\r for (int i = 0; i < m; ++i) x[i] *= y[i];\r x.intt();\r x -= b.diff();\r x.resize(2 * m);\r for (int i = 0; i < m - 1; ++i) x[m + i] = x[i], x[i] = mint(0);\r x.ntt();\r for (int i = 0; i < 2 * m; ++i) x[i] *= z2[i];\r x.intt();\r x.pop_back();\r inplace_integral(x);\r for (int i = m; i < min(this->size(), 2 * m); ++i) x[i] += (*this)[i];\r fill(begin(x), begin(x) + m, mint(0));\r x.ntt();\r for (int i = 0; i < 2 * m; ++i) x[i] *= y[i];\r x.intt();\r b.insert(end(b), begin(x) + m, end(x));\r }\r return fps{begin(b), begin(b) + deg};\r}\r\r/**\r * @brief NTT mod\u7528FPS\u30e9\u30a4\u30d6\u30e9\u30ea\r * @docs docs/fps/ntt-friendly-fps.md\r */\r\r\r\r\rtemplate \rstruct LazyMontgomeryModInt {\r using mint = LazyMontgomeryModInt;\r using i32 = int32_t;\r using u32 = uint32_t;\r using u64 = uint64_t;\r\r static constexpr u32 get_r() {\r u32 ret = mod;\r for (i32 i = 0; i < 4; ++i) ret *= 2 - mod * ret;\r return ret;\r }\r\r static constexpr u32 r = get_r();\r static constexpr u32 n2 = -u64(mod) % mod;\r static_assert(r * mod == 1, \"invalid, r * mod != 1\");\r static_assert(mod < (1 << 30), \"invalid, mod >= 2 ^ 30\");\r static_assert((mod & 1) == 1, \"invalid, mod % 2 == 0\");\r\r u32 a;\r\r constexpr LazyMontgomeryModInt() : a(0) {}\r constexpr LazyMontgomeryModInt(const int64_t &b)\r : a(reduce(u64(b % mod + mod) * n2)){};\r\r static constexpr u32 reduce(const u64 &b) {\r return (b + u64(u32(b) * u32(-r)) * mod) >> 32;\r }\r\r constexpr mint &operator+=(const mint &b) {\r if (i32(a += b.a - 2 * mod) < 0) a += 2 * mod;\r return *this;\r }\r\r constexpr mint &operator-=(const mint &b) {\r if (i32(a -= b.a) < 0) a += 2 * mod;\r return *this;\r }\r\r constexpr mint &operator*=(const mint &b) {\r a = reduce(u64(a) * b.a);\r return *this;\r }\r\r constexpr mint &operator/=(const mint &b) {\r *this *= b.inverse();\r return *this;\r }\r\r constexpr mint operator+(const mint &b) const { return mint(*this) += b; }\r constexpr mint operator-(const mint &b) const { return mint(*this) -= b; }\r constexpr mint operator*(const mint &b) const { return mint(*this) *= b; }\r constexpr mint operator/(const mint &b) const { return mint(*this) /= b; }\r constexpr bool operator==(const mint &b) const {\r return (a >= mod ? a - mod : a) == (b.a >= mod ? b.a - mod : b.a);\r }\r constexpr bool operator!=(const mint &b) const {\r return (a >= mod ? a - mod : a) != (b.a >= mod ? b.a - mod : b.a);\r }\r constexpr mint operator-() const { return mint() - mint(*this); }\r\r constexpr mint pow(u64 n) const {\r mint ret(1), mul(*this);\r while (n > 0) {\r if (n & 1) ret *= mul;\r mul *= mul;\r n >>= 1;\r }\r return ret;\r }\r \r constexpr mint inverse() const { return pow(mod - 2); }\r\r friend ostream &operator<<(ostream &os, const mint &b) {\r return os << b.get();\r }\r\r friend istream &operator>>(istream &is, mint &b) {\r int64_t t;\r is >> t;\r b = LazyMontgomeryModInt(t);\r return (is);\r }\r \r constexpr u32 get() const {\r u32 ret = reduce(a);\r return ret >= mod ? ret - mod : ret;\r }\r\r static constexpr u32 get_mod() { return mod; }\r};\r\rtemplate \rstruct Binomial {\r vector fac_, finv_, inv_;\r Binomial(int MAX = 0) : fac_(MAX + 10), finv_(MAX + 10), inv_(MAX + 10) {\r assert(T::get_mod() != 0);\r MAX += 9;\r fac_[0] = finv_[0] = inv_[0] = 1;\r for (int i = 1; i <= MAX; i++) fac_[i] = fac_[i - 1] * i;\r finv_[MAX] = fac_[MAX].inverse();\r for (int i = MAX - 1; i > 0; i--) finv_[i] = finv_[i + 1] * (i + 1);\r for (int i = 1; i <= MAX; i++) inv_[i] = finv_[i] * fac_[i - 1];\r }\r\r void extend() {\r int n = fac_.size();\r T fac = fac_.back() * n;\r T inv = (-inv_[T::get_mod() % n]) * (T::get_mod() / n);\r T finv = finv_.back() * inv;\r fac_.push_back(fac);\r finv_.push_back(finv);\r inv_.push_back(inv);\r }\r\r T fac(int i) {\r if(i < 0) return T(0);\r while (i >= (int)fac_.size()) extend();\r return fac_[i];\r }\r\r T finv(int i) {\r if(i < 0) return T(0);\r while (i >= (int)finv_.size()) extend();\r return finv_[i];\r }\r\r T inv(int i) {\r if(i < 0) return T(0);\r while (i >= (int)inv_.size()) extend();\r return inv_[i];\r }\r\r T C(int n, int r) {\r if (n < 0 || n < r || r < 0) return T(0);\r return fac(n) * finv(n - r) * finv(r);\r }\r\r T C_naive(int n, int r) {\r if (n < 0 || n < r || r < 0) return T(0);\r T ret = T(1);\r r = min(r, n - r);\r for (int i = 1; i <= r; ++i) ret *= inv(i) * (n--);\r return ret;\r }\r\r T P(int n, int r) {\r if (n < 0 || n < r || r < 0) return T(0);\r return fac(n) * finv(n - r);\r }\r\r T H(int n, int r) {\r if (n < 0 || r < 0) return T(0);\r return r == 0 ? 1 : C(n + r - 1, r);\r }\r};\r\r//\r\r\r// given : f(0)...f(k) (deg(f) = k), a, n\r// return : sum_{i=0...n-1} a^i f(i)\rtemplate \rmint sum_of_exp(const vector& f, mint a, long long n,\r Binomial& C) {\r if (n == 0) return mint(0);\r if (a == mint(0)) return f[0];\r if (a == mint(1)) {\r vector g(f.size() + 1, mint(0));\r for (int i = 1; i < (int)g.size(); i++) g[i] = g[i - 1] + f[i - 1];\r return lagrange_interpolation(g, n, C);\r }\r int K = f.size() - 1;\r vector g(f.size());\r mint buf = 1;\r for (int i = 0; i < (int)g.size(); i++) g[i] = f[i] * buf, buf *= a;\r for (int i = 1; i < (int)g.size(); i++) g[i] += g[i - 1];\r mint c = 0, buf2 = 1;\r for (int i = 0; i <= K; i++) c += C.C(K + 1, i) * buf2 * g[K - i], buf2 *= -a;\r c /= (-a + 1).pow(K + 1);\r mint buf3 = 1, ia = a.inverse();\r for (int i = 0; i < (int)g.size(); i++) g[i] = (g[i] - c) * buf3, buf3 *= ia;\r mint tn = lagrange_interpolation(g, n - 1, C);\r return tn * a.pow(n - 1) + c;\r}\r\r// given : f(0)...f(k) (deg(f) = k), a\r// return : sum_{i=0...infty} a^i f(i)\rtemplate \rmint sum_of_exp_limit(const vector& f, mint a, Binomial& C) {\r if (a == mint(0)) return f[0];\r int K = f.size() - 1;\r vector g(f.size());\r mint buf = 1;\r for (int i = 0; i < (int)g.size(); i++) g[i] = f[i] * buf, buf *= a;\r for (int i = 1; i < (int)g.size(); i++) g[i] += g[i - 1];\r mint c = 0, buf2 = 1;\r for (int i = 0; i <= K; i++) c += C.C(K + 1, i) * buf2 * g[K - i], buf2 *= -a;\r c /= (-a + 1).pow(K + 1);\r return c;\r}\r\r// given : p, n\r// return : (0^p, 1^p, ... , n^p)\rtemplate \rvector exp_enamurate(int p, int n) {\r vector f(n + 1, mint(0));\r if (!p) {\r f[0] = 1;\r return std::move(f);\r }\r f[1] = 1;\r vector sieve(n + 1, false);\r vector ps;\r for (int i = 2; i <= n; i++) {\r if (!sieve[i]) {\r f[i] = mint(i).pow(p);\r ps.push_back(i);\r }\r for (int j = 0; j < (int)ps.size() && i * ps[j] <= n; j++) {\r sieve[i * ps[j]] = 1;\r f[i * ps[j]] = f[i] * f[ps[j]];\r if (i % ps[j] == 0) break;\r }\r }\r return std::move(f);\r}\r\r// given : d, r, n\r// return : sum_{i=0...n-1} r^i i^d\rtemplate \rmint sum_of_exp2(int d, mint r, long long n, Binomial& C) {\r vector f = exp_enamurate(d, d);\r return sum_of_exp(f, r, n, C);\r}\r\r// given : d, r\r// return : sum_{i=0...infty} r^i i^d\rtemplate \rmint sum_of_exp_limit2(int d, mint r, Binomial& C) {\r vector f = exp_enamurate(d, d);\r return sum_of_exp_limit(f, r, C);\r}\r\r/**\r * @brief $\\sum_{i}a^i f(i)$\r * @docs docs/fps/sum-of-exponential-times-poly.md\r */\r\r//\rusing mint = LazyMontgomeryModInt<998244353>;\rusing vm = vector;\rusing vvm = vector;\rusing fps = FormalPowerSeries;\rBinomial C;\r\rusing namespace Nyaan;\r\rvoid Nyaan::solve() {\r ini(N, K);\r vi l(N);\r in(l);\r int L = accumulate(all(l), 0ll);\r mint iL = mint(L).inverse();\r V P(L + 1);\r P[0] = fps{1};\r rep(i, N) {\r V nx(L + 1);\r rep(k, l[i] / K + 1) {\r // x ^ k\r int ds = l[i] - k * K;\r if(ds == 0) break;\r mint coe1 = (iL * ds).pow(k) * C.finv(k);\r mint coe2 = (iL * ds).pow(k - 1) * C.finv(k - 1);\r if (k & 1) coe1 = -coe1, coe2 = -coe2;\r trc(k, ds, coe1, coe2);\r rep(s, L + 1) {\r if (s + ds > L) break;\r if (P[s] == fps{}) continue;\r nx[s + ds] += (P[s] << k) * coe1;\r if(k) {\r nx[s + ds] += (P[s] << (k - 1)) * coe2;\r }\r }\r }\r swap(P, nx);\r trc(P);\r }\r\r assert(P.back() == fps{1});\r P.pop_back();\r each(f, P) f = -f;\r\r mint ans = 0;\r rep(t, L) rep(s, sz(P[t])) {\r fps f(s + 1);\r rep(i, s + 1) f[i] = C.fac(i + s) * C.finv(i);\r\r mint soe = sum_of_exp_limit(f, iL * t, C);\r trc(t, s, P[t][s], soe);\r ans += P[t][s] * sum_of_exp_limit(f, iL * t, C);\r }\r out(ans);\r}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6c2f0a307c0c84b3622e951bd553f6ef", "src_uid": "26d565c193a5920b042c783109496b4c", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define itn int\n#define all(x) (x).begin(), (x).end()\n#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())\n\n#define random_shuffle(...) shuffle(__VA_ARGS__, rng)\n#define rand() rng()\n\nusing namespace std;\n\ninline int nxt() {\n\tint x;\n\tscanf(\"%d\", &x);\n\treturn x;\n}\n\nstruct Field {\n\tint n, m;\n\tvector> a;\n\tvector> ans;\n\n\tvoid scan() {\n\t\tn = nxt(), m = nxt();\n\t\ta.assign(n, vector(m, 0));\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tfor (int j = 0; j < m; ++j) {\n\t\t\t\ta[i][j] = nxt();\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid add(const vector>& cyc) {\n\t\tans.push_back({});\n\t\tfor (auto p : cyc) {\n\t\t\tans.back().push_back(a[p.first][p.second]);\n\t\t}\n\t\tassert(cyc.size() >= 4);\n\t\tint lst = a[cyc.back().first][cyc.back().second];\n\t\tfor (int i = (int)cyc.size() - 2; i >= 0; --i) {\n\t\t\ta[cyc[i + 1].first][cyc[i + 1].second] = a[cyc[i].first][cyc[i].second];\n\t\t\tassert(abs(cyc[i].first - cyc[i + 1].first) + abs(cyc[i].second - cyc[i + 1].second) == 1);\n\t\t}\n\t\ta[cyc[0].first][cyc[0].second] = lst;\n\t\tassert(abs(cyc[0].first - cyc.back().first) + abs(cyc[0].second - cyc.back().second) == 1);\n\t}\n\n\tbool check() {\n\t\tint cur = 0;\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tfor (int j = 0; j < m; ++j) {\n\t\t\t\tif (++cur != a[i][j]) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tvoid print() {\n\t\tprintf(\"%d\\n\", (int)ans.size());\n\t\tfor (const auto& v : ans) {\n\t\t\tprintf(\"%d\", (int)v.size());\n\t\t\tfor (int x : v) {\n\t\t\t\tprintf(\" %d\", x);\n\t\t\t}\n\t\t\tprintf(\"\\n\");\n\t\t}\n\t}\n\n\tvoid printState() {\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tfor (int j = 0; j < m; ++j) {\n\t\t\t\tcerr << a[i][j] << \" \";\n\t\t\t}\n\t\t\tcerr << \"\\n\";\n\t\t}\n\t\tcerr << \"\\n\";\n\t}\n};\n\nint main() {\n\tmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\n\tField field;\n\tfield.scan();\n\tint n = field.n, m = field.m;\n\n\tauto moveRight = [&](int x, int y) {\n\t\tif (x == n - 1) {\n\t\t\tfield.add({{x, y}, {x, y + 1}, {x - 1, y + 1}, {x - 1, y}});\n\t\t} else {\n\t\t\tfield.add({{x, y}, {x, y + 1}, {x + 1, y + 1}, {x + 1, y}});\n\t\t}\n\t};\n\n\tauto moveLeft = [&](int x, int y) {\n\t\tif (x == n - 1) {\n\t\t\tfield.add({{x, y}, {x, y - 1}, {x - 1, y - 1}, {x - 1, y}});\n\t\t} else {\n\t\t\tfield.add({{x, y}, {x, y - 1}, {x + 1, y - 1}, {x + 1, y}});\n\t\t}\n\t};\n\n\tauto findNeed = [&](int need, int& x, int& y) {\n\t\tx = y = 0;\n\t\twhile (field.a[x][y] != need) {\n\t\t\t++y;\n\t\t\tif (y == m) {\n\t\t\t\ty = 0;\n\t\t\t\t++x;\n\t\t\t}\n\t\t}\n\t};\n\n\tauto swapHor = [&](int x, int y) {\n\t\t// swaps (x, y) and (x, y + 1)\n\t\tfield.add({{x - 1, y}, {x - 1, y + 1}, {x, y + 1}, {x, y}});\n\t\tfield.add({{x - 1, y}, {x, y}, {x + 1, y}, {x + 1, y + 1}, {x, y + 1}, {x - 1, y + 1}});\n\t\tfield.add({{x, y}, {x, y + 1}, {x + 1, y + 1}, {x + 1, y}});\n\t};\n\n\tauto swapVer = [&](int x, int y) {\n\t\t// swaps (x, y) and (x + 1, y)\n\t\tfield.add({{x, y - 1}, {x + 1, y - 1}, {x + 1, y}, {x, y}});\n\t\tfield.add({{x, y - 1}, {x, y}, {x, y + 1}, {x + 1, y + 1}, {x + 1, y}, {x + 1, y - 1}});\n\t\tfield.add({{x, y}, {x + 1, y}, {x + 1, y + 1}, {x, y + 1}});\n\t};\n\n\tauto moveGuyUp = [&](int need, int i, int j) {\n\t\tint x, y;\n\t\tfindNeed(need, x, y);\n\t\tif (x == i) {\n\t\t\twhile (y > j) {\n\t\t\t\tfield.add({{x, y}, {x, y - 1}, {x + 1, y - 1}, {x + 1, y}});\n\t\t\t\t--y;\n\t\t\t}\n\t\t\twhile (y < j) {\n\t\t\t\tfield.add({{x, y}, {x, y + 1}, {x + 1, y + 1}, {x + 1, y}});\n\t\t\t\t++y;\n\t\t\t}\n\t\t} else {\n\t\t\twhile (y < j) {\n\t\t\t\tmoveRight(x, y);\n\t\t\t\t++y;\n\t\t\t}\n\t\t\twhile (y > j) {\n\t\t\t\tmoveLeft(x, y);\n\t\t\t\t--y;\n\t\t\t}\n\t\t\twhile (x > i) {\n\t\t\t\tfield.add({{x, y}, {x - 1, y}, {x - 1, y + 1}, {x, y + 1}});\n\t\t\t\t--x;\n\t\t\t}\n\t\t}\n\t};\n\n\tauto& a = field.a;\n\n\tfor (int i = 0; i < n - 2; ++i) {\n\t\t// make one row\n\t\tfor (int j = 0; j < m - 2; ++j) {\n\t\t\tint need = i * m + j + 1;\n\t\t\tmoveGuyUp(need, i, j);\n\t\t}\n\n\t\tint need = i * m + m - 1;\n\t\tif (a[i][m - 2] == need && a[i][m - 1] == need + 1) {\n\t\t\t// pass;\n\t\t} else if (a[i][m - 2] == need + 1 && a[i][m - 1] == need) {\n\t\t\tswapHor(i, m - 2);\n\t\t} else if (a[i][m - 2] == need || a[i][m - 1] == need) {\n\t\t\tif (a[i][m - 2] == need) {\n\t\t\t\tfield.add({{i, m - 2}, {i, m - 1}, {i + 1, m - 1}, {i + 1, m - 2}});\n\t\t\t}\n\t\t\tmoveGuyUp(need + 1, i + 1, m - 1);\n\t\t\tfield.add({{i + 1, m - 1}, {i, m - 1}, {i, m - 2}, {i + 1, m - 2}});\n\t\t} else if (a[i][m - 2] == need + 1 || a[i][m - 1] == need + 1) {\n\t\t\tif (a[i][m - 1] == need + 1) {\n\t\t\t\tfield.add({{i, m - 1}, {i, m - 2}, {i + 1, m - 2}, {i + 1, m - 1}});\n\t\t\t}\n\t\t\tmoveGuyUp(need, i + 1, m - 2);\n\t\t\tfield.add({{i + 1, m - 2}, {i, m - 2}, {i, m - 1}, {i + 1, m - 1}});\n\t\t} else {\n\t\t\tmoveGuyUp(need + 1, i, m - 2);\n\t\t\tmoveGuyUp(need, i + 1, m - 2);\n\t\t\tfield.add({{i + 1, m - 2}, {i, m - 2}, {i, m - 1}, {i + 1, m - 1}});\n\t\t}\n\t}\n\n\tfor (int j = 0; j < m - 2; ++j) {\n\t\tint need = (n - 2) * m + j + 1;\n\t\tint x, y;\n\t\tfindNeed(need, x, y);\n\t\tif (x != n - 1) {\n\t\t\tassert(x == n - 2);\n\t\t\tif (y > j) {\n\t\t\t\tfield.add({{x, y}, {x + 1, y}, {x + 1, y - 1}, {x, y - 1}});\n\t\t\t} else {\n\t\t\t\tfield.add({{x, y}, {x + 1, y}, {x + 1, y + 1}, {x, y + 1}});\n\t\t\t}\n\t\t\t++x;\n\t\t}\n\n\t\twhile (y > j) {\n\t\t\tmoveLeft(x, y);\n\t\t\t--y;\n\t\t}\n\n\t\tif (field.a[n - 2][j] == need + m) {\n\t\t\tfor (int _ = 0; _ < 2; ++_) {\n\t\t\t\tfield.add({{n - 2, j}, {n - 2, j + 1}, {n - 1, j + 1}, {n - 1, j}});\n\t\t\t}\n\t\t\tswapVer(n - 2, j + 1);\n\t\t\tfor (int _ = 0; _ < 2; ++_) {\n\t\t\t\tfield.add({{n - 2, j}, {n - 2, j + 1}, {n - 1, j + 1}, {n - 1, j}});\n\t\t\t}\n\t\t} else {\n\t\t\tfindNeed(need + m, x, y);\n\t\t\tif (x != n - 1) {\n\t\t\t\tassert(x == n - 2);\n\t\t\t\tif (y > j + 1) {\n\t\t\t\t\tfield.add({{x, y}, {x + 1, y}, {x + 1, y - 1}, {x, y - 1}});\n\t\t\t\t} else {\n\t\t\t\t\tfield.add({{x, y}, {x + 1, y}, {x + 1, y + 1}, {x, y + 1}});\n\t\t\t\t}\n\t\t\t\t++x;\n\t\t\t}\n\t\t\twhile (y > j + 1) {\n\t\t\t\tmoveLeft(x, y);\n\t\t\t\t--y;\n\t\t\t}\n\t\t\tfield.add({{n - 1, j + 1}, {n - 1, j}, {n - 2, j}, {n - 2, j + 1}});\n\t\t}\n\t}\n\n\twhile (a[n - 1][m - 1] != n * m) {\n\t\tfield.add({{n - 2, m - 2}, {n - 2, m - 1}, {n - 1, m - 1}, {n - 1, m - 2}});\n\t}\n\tint x, y;\n\tfindNeed(n * m - 1, x, y);\n\tif (y == m - 1) {\n\t\tswapHor(n - 2, m - 2);\n\t\t--y;\n\t}\n\tif (x == n - 2) {\n\t\tswapVer(n - 2, m - 2);\n\t}\n\tif (!field.check()) {\n\t\tswapHor(n - 2, m - 2);\n\t}\n\tassert(field.check());\n\t// if (!field.check()) {\n\t// \tfield.printState();\n\t// \treturn 0;\n\t// }\n\tfield.print();\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c4b88507a9e0ba4652f3c59e7dea60cb", "src_uid": "476afa2d8208ec933617c97637b65aff", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std; \n\n#define PB push_back \n#define MP make_pair \n#define SZ(v) ((int)(v).size()) \n#define FOR(i,a,b) for(int i=(a);i<(b);++i) \n#define REP(i,n) FOR(i,0,n) \n#define FORE(i,a,b) for(int i=(a);i<=(b);++i) \n#define REPE(i,n) FORE(i,0,n) \n#define FORSZ(i,a,v) FOR(i,a,SZ(v)) \n#define REPSZ(i,v) REP(i,SZ(v)) \ntypedef long long ll;\ntypedef unsigned long long ull;\nll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }\n\nconst int MAXF=2;\nconst int MAXN=1000;\nconst int MAXM=MAXN-2;\nconst int MAXTN=MAXN-2;\nconst int MAXTM=MAXTN-1;\nconst int MAXRT=MAXN-1+2*MAXM;\nconst int MAXRTN=10+MAXTN;\nconst int MAXRTNSUM=MAXF*MAXRT*MAXRTN+2*MAXTN;\n\n\ntypedef struct RT {\n\tint root,u,v,vv;\n} RT;\ntypedef struct RF {\n\tint n;\n\tint par[MAXRTNSUM];\n\tint chead[MAXRTNSUM];\n\tint cnxt[MAXRTNSUM];\n\tint coff[MAXRTNSUM];\n\tint ccnt[MAXRTNSUM];\n\tint cidx[MAXRTNSUM];\n\tint id[MAXRTNSUM];\n\tint d[MAXRTNSUM];\n\tint q[MAXRTNSUM],qhead,qtail;\n\tint orig[MAXRTNSUM];\n\n\tRF() { n=0; }\n\tint addNode(int p,int o) { assert(n=ccnt[a]) return -1; if(i>=ccnt[b]) return +1;\n\t\t\tint aa=id[cidx[coff[a]+i]],bb=id[cidx[coff[b]+i]]; if(aa!=bb) return aacidcmp(a,b)<0; } } ;\n\tvector calcids(vector t) {\n\t\tint nt=SZ(t); //bool dbg=true;\n\t\tqhead=qtail=0; REP(i,nt) { int at=t[i].root; d[at]=0,q[qhead++]=at; }\n\t\twhile(qtail0&&d[q[a-1]]==dmx) --a;\n\t\tFOR(i,a,b) { int at=q[i]; id[at]=0; }\n\t\tfor(int cd=dmx-1;cd>=0;--cd) {\n\t\t\tc=b,b=a; while(a>0&&d[q[a-1]]==cd) --a; //if(dbg) printf(\"\\t%d..%d..%d\\n\",a,b,c);\n\t\t\tFOR(i,b,c) { int at=q[i]; cidx[coff[par[at]]++]=at; }\n\t\t\tFOR(i,a,b) { int at=q[i]; for(int to=chead[at];to!=-1;to=cnxt[to]) --coff[at]; }\n\t\t\tsort(q+a,q+b,cidless(this));\n\t\t\tFOR(i,a,b) { int at=q[i]; id[at]=i==a?0:id[q[i-1]]+(cidcmp(at,q[i-1])==0?0:1); }\n\t\t\t//FOR(i,a,b) { int at=q[i]; printf(\"%d = [\",at); REP(j,ccnt[at]) printf(\"%d%c\",id[cidx[coff[at]+j]],j+1 %d\\n\",id[at]); }\n\t\t}\n\t\tvector ret(nt,-1); REP(i,nt) ret[i]=id[t[i].root]; return ret;\n\t}\n} RF;\nRF rf;\n\n//bool dbg=false;\ntypedef struct T {\n\tint n,m,root;\n\tint ghead[MAXTN],gnxt[2*MAXTM],gto[2*MAXTM];\n\tint orig[MAXTN];\n\tint d1[MAXTN],d2[MAXTN],d3[MAXTN];\n\tint q[MAXTN],qhead,qtail;\n\n\tvoid init(int o) { n=1,m=0; root=0; ghead[0]=-1,orig[0]=o; }\n\tint addNode(int p,int o) { assert(n calcCenters(int rt) {\n\t\tREP(i,n) d1[i]=INT_MAX; qhead=qtail=0; d1[rt]=0,q[qhead++]=rt;\n\t\twhile(qtaild1[u]) u=i;\n\t\t//if(dbg) { REP(i,n) printf(\"%d=%d \",orig[i],d1[i]); printf(\"-> %d\\n\",orig[u]); }\n\t\tREP(i,n) d2[i]=INT_MAX; qhead=qtail=0; d2[u]=0,q[qhead++]=u;\n\t\twhile(qtaild2[v]) v=i;\n\t\t//if(dbg) { REP(i,n) printf(\"%d=%d \",orig[i],d2[i]); printf(\"-> %d\\n\",orig[v]); }\n\t\tREP(i,n) d3[i]=INT_MAX; qhead=qtail=0; d3[v]=0,q[qhead++]=v;\n\t\twhile(qtaild3[w]) w=i;\n\t\t//if(dbg) { REP(i,n) printf(\"%d=%d \",orig[i],d3[i]); printf(\"-> %d\\n\",orig[w]); }\n\t\tvector ret; REP(i,n) if(d2[i]+d3[i]==d2[v]&&d2[v]-1<=2*d2[i]&&2*d2[i]<=d2[v]+1) ret.PB(i); return ret;\n\t}\n\tvoid appendTo(int at,int par,int idx) {\n\t\tfor(int x=ghead[at];x!=-1;x=gnxt[x]) { int to=gto[x]; if(to==par) continue; int nidx=rf.addNode(idx,orig[to]); appendTo(to,at,nidx); }\n\t}\n} T;\nT t;\n\ntypedef struct F {\n\tint n,m;\n\tvector > adj;\n\n\tvoid input(int _n) { n=_n; adj=vector >(n,vector()); scanf(\"%d\",&m); REP(i,m) { int a,b; scanf(\"%d%d\",&a,&b); --a,--b; adj[a].PB(b); adj[b].PB(a); } }\n\tvoid buildTree(int at,vector &done,int idx) {\n\t\tdone[at]=true; REPSZ(i,adj[at]) { int to=adj[at][i]; if(done[to]) continue; int nidx=t.addNode(idx,to); buildTree(to,done,nidx); }\n\t}\n\t// ( ((u+)) ((uv)()) ((v+)()()) )\n\tRT createCanonical(int u,int v,int vv,bool swp) {\n\t\t//dbg=false; if(!swp&&u==3&&v==4&&vv==2) dbg=true; if(swp&u==4&&v==3&&vv==1) dbg=true;\n\t\tRT ret; ret.u=u; ret.v=v; ret.vv=vv; ret.root=rf.addNode(-1,-1);\n\t\tint rt=ret.root,a=rf.addNode(rt,-1),b=rf.addNode(rt,-1),c=rf.addNode(rt,-1);\n\t\ta=rf.addNode(a,-1); rf.addNode(b,-1),b=rf.addNode(b,-1); rf.addNode(c,-1),rf.addNode(c,-1),c=rf.addNode(c,-1);\n\t\tvector done(n,false); done[u]=true; done[v]=true;\n\t\tREPSZ(i,adj[v]) {\n\t\t\t//if(swp&&u==0&&v==3&&vv==2) printf(\"building %d\\n\",adj[v][i]);\n\t\t\tt.init(adj[v][i]); buildTree(adj[v][i],done,t.root);\n\t\t\tvector centers=t.calcCenters(t.root);\n\t\t\t//if(swp&&u==0&&v==3&&vv==2) { REPSZ(j,centers) printf(\"\\t%d\\n\",t->orig[centers[j]]); }\n\t\t\tint par=adj[v][i]==vv?b:swp?a:c,bj=0;\n\t\t\tFORSZ(j,1,centers) {\n\t\t\t\tint on=rf.n;\n\t\t\t\tRT a; a.root=rf.addNode(-1,centers[bj]); t.appendTo(centers[bj],-1,a.root);\n\t\t\t\tRT b; b.root=rf.addNode(-1,centers[j]); t.appendTo(centers[j],-1,b.root);\n\t\t\t\tvector c; c.PB(a); c.PB(b); vector id=rf.calcids(c); if(id[1] centers=t.calcCenters(t.root);\n\t\t\tint par=swp?c:a,bj=0;\n\t\t\tFORSZ(j,1,centers) {\n\t\t\t\tint on=rf.n;\n\t\t\t\tRT a; a.root=rf.addNode(-1,centers[bj]); t.appendTo(centers[bj],-1,a.root);\n\t\t\t\tRT b; b.root=rf.addNode(-1,centers[j]); t.appendTo(centers[j],-1,b.root);\n\t\t\t\tvector c; c.PB(a); c.PB(b); vector id=rf.calcids(c); if(id[1] createAll(bool swp) {\n\t\tint u=-1; REP(i,n) if(SZ(adj[i])==0) { u=i; break; } assert(u!=-1);\n\t\tvector ret; ret.reserve(n-1+2*m);\n\t\tREP(v,n) if(v!=u) {\n\t\t\t//if(!swp&&(u!=8||v!=3)) continue;\n\t\t\t//if(swp&&(u!=1||v!=5)) continue;\n\t\t\tret.PB(createCanonical(u,v,-1,swp));\n\t\t\tREPSZ(i,adj[v]) ret.PB(createCanonical(u,v,adj[v][i],swp));\n\t\t}\n\t\treturn ret;\n\t}\n\tvoid print(RT a,RT b,F &fb) {\n\t\tqueue > q; q.push(MP(a.root,b.root));\n\t\tvector ab(n,-1),ba(n,-1); ab[a.u]=b.v,ba[b.v]=a.u; ab[a.v]=b.u,ba[b.u]=a.v;\n\t\twhile(!q.empty()) {\n\t\t\tint ai=q.front().first,bi=q.front().second; q.pop(); //printf(\"%d=%d\\n\",ai,bi); if(ai==0&&bi==0) exit(1);\n\t\t\tif(rf.orig[ai]!=-1&&rf.orig[bi]!=-1) ab[rf.orig[ai]]=rf.orig[bi],ba[rf.orig[bi]]=rf.orig[ai];\n\t\t\tREP(k,rf.ccnt[ai]) q.push(MP(rf.cidx[rf.coff[ai]+k],rf.cidx[rf.coff[bi]+k]));\n\t\t}\n\t\t//REP(i,n) printf(\"%d->%d\\n\",i,ab[i]);\n\t\t//REP(i,n) printf(\"%d<-%d\\n\",ba[i],i);\n\t\tREP(i,n) REPSZ(j,adj[i]) if(i a=f[0].createAll(false);\n\tvector b=f[1].createAll(true);\n\tvector c; REPSZ(i,a) c.PB(a[i]); REPSZ(i,b) c.PB(b[i]);\n\tvector id=rf.calcids(c);\n\t//REPSZ(i,c) { printf(\"%d %2d (%d,%d,%2d): \",i mp; REPSZ(i,a) if(mp.count(id[i])==0) mp[id[i]]=i;\n\tREPSZ(j,b) if(mp.count(id[SZ(a)+j])) {\n\t\tint i=mp[id[SZ(a)+j]]; //printf(\"a%d with b%d\\n\",i,j);\n\t\tprintf(\"YES\\n\");\n\t\tf[0].print(a[i],b[j],f[1]);\n\t\trf.n=0;\n\t\treturn true;\n\t}\n\trf.n=0;\n\tprintf(\"NO\\n\"); return false;\n}\n\n\nvoid run() {\n\tinput();\n\tsolve();\n}\n\nvoid test() {\n\twhile(true) {\n\t\tint n=1000;\n\t\tvector par(n,-1);\n\t\tFOR(i,1,n) par[i]=rand()%i;\n\t\tint u=rand()%n,v=rand()%(n-1); if(v>=u) ++v;\n\t\tREP(i,2) {\n\t\t\tf[i].n=n;\n\t\t\tf[i].adj=vector >(n);\n\t\t}\n\t\tFOR(j,1,n) {\n\t\t\tif(j!=u&&par[j]!=u) f[0].adj[j].PB(par[j]),f[0].adj[par[j]].PB(j);\n\t\t\tif(j!=v&&par[j]!=v) f[1].adj[j].PB(par[j]),f[1].adj[par[j]].PB(j);\n\t\t}\n\t\tif(!solve()) {\n\t\t\tprintf(\"1\\n\");\n\t\t\tprintf(\"%d %d\\n\",n,2);\n\t\t\tREP(i,2) {\n\t\t\t\tint m=0; REP(j,n) REPSZ(k,f[i].adj[j]) if(j\n\n#define FASTIO\n\n#ifdef FASTIO\n#define scanf abacaba\n#define printf abacaba\n#endif\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\n\nusing namespace std;\nusing bb = bitset;\n\nconst int C2 = 19;\nconst int C = 9 * 20 + 1;\n\nvector vv;\nunordered_set mapa1, mapa2;\n\nbool cmp(const bb &a, const bb &b){\n\tfor (int i = 0; i < 9 * 20; ++i){\n\t\tif (a[i] < b[i])\n\t\t\treturn 1;\n\t\tif (b[i] < a[i])\n\t\t\treturn 0;\n\t}\n\treturn 0;\n}\n\nunordered_map mm;\n\nint upd(int x, int j){\n\tbb cur = (vv[x] << j) | (vv[x] >> j);\n\tfor (int k = 0; k < j; ++k)\n\t\tif (vv[x][k])\n\t\t\tcur[j - k] = 1;\n\tauto it = mm.find(cur);\n\tif (it == mm.end())\n\t\treturn -1;\n\treturn it->second;\n}\nconst int MX = 50000;\n\nint go[MX][10];\nll dp[MX][10][20];\nint nl;\n\nll get(ll x, int k) {\n\tvector dg;\n\tfor (int i = 0; i < C2; ++i)\n\t\tdg.push_back(x % 10), x /= 10;\n\tll ans = 0;\n\tll cur = nl;\n\tfor (int i = C2 - 1; i >= 0; --i){\n\t\tfor (int j = 0; j < dg[i]; ++j){\n\t\t\tll tmp = go[cur][j];\n\t\t\tans += dp[tmp][k][i];\n\t\t}\n\t\tcur = go[cur][dg[i]];\n\t}\n\treturn ans;\n}\n\nint av[MX][10];\n\nint main() {\n\t#ifdef FASTIO\n\t\tios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n\t#endif\n\tbb tmp;\n\ttmp[0] = 1;\n\tmapa1.insert(tmp);\n\tfor (int i = 0; i < C2; ++i){\n\t\tmapa2.clear();\n\t\tfor (auto msk: mapa1){\n\t\t\tfor (int j = 0; j <= 9; ++j){\n\t\t\t\tbb cur = (msk << j) | (msk >> j);\n\t\t\t\tfor (int k = 0; k < j; ++k)\n\t\t\t\t\tif (msk[k])\n\t\t\t\t\t\tcur[j - k] = 1;\n\t\t\t\tmapa2.insert(cur);\n\t\t\t}\n\t\t}\n\t\tmapa1 = mapa2;\n\t}\n\tfor (auto x: mapa1)\n\t\tvv.push_back(x);\n\tsort(vv.begin(), vv.end(), cmp);\n\tfor (int i = 0; i < vv.size(); ++i)\n\t\tmm[vv[i]] = i;\n\tnl = mm[tmp];\n\tav[nl][0] = 1;\n\tfor (int i = 0; i < vv.size(); ++i){\n\t\tgo[i][0] = i;\n\t\tfor (int j = 1; j <= 9; ++j){\n\t\t\tgo[i][j] = upd(i, j);\n\t\t}\n\t\tfor (int j = 0; j <= 9; ++j)\n\t\t\tif (vv[i][j])\n\t\t\t\tav[i][j] = 1;\n\t}\n\tfor (int i = vv.size() - 1; i >= 0; --i){\n\t\tint x = 0;\n\t\twhile (!av[i][x]) {\n\t\t\t++x;\n\t\t}\n\t\tfor (int j = x; j <= 9; ++j)\n\t\t\tdp[i][j][0] = 1;\n\t}\n\tfor (int ad = 1; ad <= C2; ++ad){\n\t\tfor (int i = 0; i < vv.size(); ++i){\n\t\t\tfor (int j = 0; j <= 9; ++j){\n\t\t\t\tif (go[i][j] == -1)\n\t\t\t\t\tcontinue;\n\t\t\t\tfor (int k = 0; k <= 9; ++k){\n\t\t\t\t\tdp[i][k][ad] += dp[go[i][j]][k][ad - 1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tint n;\n\tcin >> n;\n\tfor (int i = 0; i < n; ++i){\n\t\tll l, r;\n\t\tint k;\n\t\tcin >> l >> r >> k;\n\t\tcout << get(r + 1, k) - get(l, k) << \"\\n\";\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a3686623483a1c6e0a38805dcbb8afc9", "src_uid": "db0e3ef630cb381724697a1ac5152611", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast\", \"unroll-loops\", \"no-stack-protector\")\n \n#include \n \nusing namespace std;\n\n#define all(a) (a).begin(), (a).end()\n#define sz(a) (int)(a).size()\n\nusing ll = long long;\nusing ld = long double; \n// using ld = __float128;\nusing pii = pair;\nusing uint = unsigned int;\nusing ull = unsigned long long;\n\nmt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());\ndefault_random_engine generator;\n\nvoid solve();\n\nint main() {\n#ifdef LOCAL\n // freopen(\"input.txt\", \"r\", stdin);\n // freopen(\"output.txt\", \"w\", stdout); \n#endif \n\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n cout << setprecision(15) << fixed;\n cerr << setprecision(15) << fixed;\n\n int tests = 1;\n // cin >> tests;\n\n for (int test = 1; test <= tests; ++test) {\n // cout << \"Case #\" << test << \": \";\n solve();\n }\n\n#ifdef LOCAL\n cerr << \"Time: \" << double(clock()) / CLOCKS_PER_SEC << endl;\n#endif\n}\n\n// ----------------------------------------------------------------- \n\nconst int MAXN = 3030;\n\nll pref[MAXN][MAXN];\nll suff[MAXN][MAXN];\n\nvoid solve() { \n int n, k;\n cin >> n >> k;\n vector> a(n);\n for (int i = 0; i < n; ++i) {\n int m;\n cin >> m;\n a[i].resize(m);\n for (int &x : a[i]) {\n cin >> x;\n }\n }\n\n for (int i = 0; i <= k; ++i) {\n pref[0][i] = -1;\n }\n pref[0][0] = 0;\n\n for (int i = 0; i < n; ++i) {\n ll sum = 0;\n for (int x : a[i]) {\n sum += x;\n }\n for(int j = 0; j <= k; ++j) {\n pref[i + 1][j] = pref[i][j];\n }\n for (int j = 0; j + sz(a[i]) <= k; ++j) {\n if (pref[i][j] == -1) {\n continue;\n }\n pref[i + 1][j + sz(a[i])] = max(pref[i + 1][j + sz(a[i])], pref[i][j] + sum);\n }\n }\n\n for (int i = 0; i <= k; ++i) {\n suff[n][i] = -1;\n }\n suff[n][0] = 0;\n\n for (int i = n - 1; i >= 0; --i) {\n ll sum = 0;\n for (int x : a[i]) {\n sum += x;\n }\n for(int j = 0; j <= k; ++j) {\n suff[i][j] = suff[i + 1][j];\n }\n for (int j = 0; j + sz(a[i]) <= k; ++j) {\n if (suff[i + 1][j] == -1) {\n continue;\n }\n suff[i][j + sz(a[i])] = max(suff[i][j + sz(a[i])], suff[i + 1][j] + sum);\n }\n }\n\n\n vector>> arr(k + 1);\n for (int i = 0; i < n; ++i) {\n ll sum = 0;\n for (int j = 0; j < sz(a[i]); ++j) {\n sum += a[i][j];\n arr[j + 1].push_back({sum, i});\n }\n }\n\n ll res = pref[n][k];\n for (int i = 1; i <= k; ++i) {\n sort(all(arr[i]), greater());\n arr[i].resize(min(sz(arr[i]), k / i + 1));\n\n for (auto [s, p] : arr[i]) {\n for (int j = 0; j <= k - i; ++j) {\n if (pref[p][j] == -1 || suff[p + 1][k - i - j] == -1) {\n continue;\n }\n res = max(res, pref[p][j] + suff[p + 1][k - i - j] + s);\n }\n }\n }\n\n cout << res << endl;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "edb00d4b55b91e7a2fa016150e1cbe77", "src_uid": "9e9d4f58ebd8293025ab8004aeb8d343", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\n#define fi first\n#define se second\n#define mp make_pair\n#define pb push_back\n#define all(x) (x).begin (),(x).end()\n#define sqrt(x) sqrt(abs(x))\n#define re return\n#define sz(x) ((int)(x.size()))\n\nusing ll = long long;\nusing ii = pair;\nusing ld = long double;\nusing D = double;\nusing vi = vector;\nusing vii = vector;\nusing vvi = vector;\nusing vs = vector;\n\ntemplate T abs (T x) { re x < 0 ? -x : x; }\ntemplate T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }\ntemplate T sqr (T x) { re x * x; }\ntemplate T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }\n\nint n;\nint m;\n\ndouble p[20];\ndouble res[1 << 20];\ndouble q[20];\n\nint main () {\n\tscanf (\"%d%d\", &n, &m);\n\tfor (int i = 0; i < n; i++) scanf (\"%lf\", &p[i]);\n\tfor (int i = 0; i < n; i++) res[1 << i] = p[i];\n\tfor (int i = 0; i < n; i++) q[i] = 0;\n\tfor (int i = 1; i < (1 << n); i++) {\n\t\tvi v, w;\n\t\tdouble sum = 0;\n\t\tfor (int j = 0; j < n; j++)\n\t\t\tif ((i >> j) & 1)\n\t\t\t\tv.pb (j);\n\t\t\telse {\n\t\t\t\tw.pb (j);\n\t\t\t\tsum += p[j];\n\t\t\t}\n\t\tif (sz (v) == m || (sz (v) < m && sum < 1e-5)) {\n\t\t\tfor (auto x : v) q[x] += res[i];\n\t\t} else\n\t\tif (sz (v) < m) {\n\t\t\tfor (auto x : w) res[i | (1 << x)] += res[i] * p[x] / sum;\n\t\t}\n\t}\n\tfor (int i = 0; i < n; i++) printf (\"%.15f \", q[i]);\n\tprintf (\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ed5231929ca498e2ff3ad38b9366ccd2", "src_uid": "ad290c29e7587561391cefab73026171", "difficulty": 2400.0}
  • type;\n typedef typename P::field field_type;\n typedef P poly_type;\n\n vector base;\n vector T;\n \n template<\n typename Iterator,\n typename enable_if::value>::type* = nullptr>\n void solve(Iterator begin, Iterator end) {\n auto get = [begin](int i) { return *(begin + i); };\n\n int n = distance(begin, end);\n \n vector C = {1}, B = {1};\n field_type b = 1;\n int L = 0;\n\n for(int i = 0, x = 1; i < n; i++, x++) {\n // evaluate new element\n field_type d = 0;\n for(size_t j = 0; j < C.size(); j++)\n d += get(i-j) * C[j];\n if(d == 0) continue;\n if(2 * L <= i) {\n auto tmp = C;\n if(C.size() < B.size() + x)\n C.resize(B.size() + x);\n field_type coef = d / b;\n for(size_t j = 0; j < B.size(); j++)\n C[j + x] -= coef * B[j];\n L = i + 1 - L;\n B = tmp;\n b = d;\n x = 0;\n } else {\n if(C.size() < B.size() + x)\n C.resize(B.size() + x);\n field_type coef = d / b;\n for(size_t j = 0; j < B.size(); j++)\n C[j + x] -= coef * B[j];\n }\n }\n\n T = vector((int)C.size() - 1);\n for(size_t i = 0; i < T.size(); i++) T[i] = -C[i+1];\n base = vector(begin, end);\n }\n\n template<\n typename Container,\n typename enable_if::value>::type* = nullptr>\n void solve(const Container& container) {\n solve(container.begin(), container.end());\n }\n\n void solve(const initializer_list& l) {\n solve(l.begin(), l.end());\n }\n\n bool solved() const {\n return T.size() > 0 && base.size() >= T.size();\n }\n\n void ensure(int nsz) const {\n auto* self = const_cast(this);\n for(int j = base.size(); j < nsz; j++) {\n field_type acc = 0;\n for(int i = 0; i < (int)T.size(); i++)\n acc += base[j - i - 1] * T[i];\n self->base.push_back(acc);\n }\n }\n\n poly_type mod_function() const {\n poly_type res;\n int m = T.size();\n res[m] = 1;\n for(int i = 0; i < m; i++)\n res[i] = -T[m-i-1];\n return res;\n }\n\n vector compute(long long K, int n) {\n assert(n > 0);\n assert(solved());\n vector res;\n int N = T.size();\n int cons = min(n, N);\n\n if(K < (int)base.size()) {\n for(int j = 0; j < n && K + j < (int)base.size(); j++)\n res.push_back({base[K + j]});\n\n while((int)res.size() < cons) {\n field_type acc = 0;\n int sz = res.size();\n int mid = min(sz, N);\n for(int i = 0; i < mid; i++)\n acc += res[sz - i - 1] * T[i];\n sz = base.size();\n for(int i = mid; i < N; i++)\n acc += base[sz - 1 - (i - mid)] * T[i];\n res.push_back(acc);\n }\n } else {\n ensure(cons + N - 1);\n\n poly_type x = poly_type::kth(K, mod_function());\n\n for(int j = 0; j < cons; j++) {\n field_type acc = 0;\n for(int i = 0; i < N; i++)\n acc += x[i] * base[i + j];\n res.push_back(acc);\n }\n }\n\n for(int j = res.size(); j < n; j++) {\n field_type acc = 0;\n for(int i = 0; i < N; i++)\n acc += res[j - i - 1] * T[i];\n res.push_back(acc);\n }\n return res;\n }\n\n field_type compute(long long K) {\n return compute(K, 1)[0];\n }\n };\n} // namespace linalg\n} // namespace lib\n\n#endif\n#define int long long\nusing namespace std;\n\n#define mp make_pair\n#define mt make_tuple\n#define pb push_back\n#define ms(v, x) memset((v), (x), sizeof(v))\n#define all(v) (v).begin(), (v).end()\n#define ff first\n#define ss second\n#define iopt ios::sync_with_stdio(false); cin.tie(0)\n\nint gcd(int a, int b) { return b == 0 ? a : gcd(b, a%b); }\nint power(int x, int p, int MOD) {\n if(p == 0) return 1%MOD;\n if(p == 1) return x%MOD;\n int res = power(x, p/2, MOD);\n res = (long long)res*res%MOD;\n if(p&1) res = (long long)res*x%MOD;\n return res;\n}\n\ntypedef pair ii;\ntypedef long double LD;\ntypedef vector vi;\n\nusing namespace lib;\n\nconst int MOD = (int)10007;\nusing Field = Mint64;\nusing Poly = math::Polynomial;\n\nconst int N = 202;\nField dp[N][N][6*N];\nbool ok[N][N][6*N];\nstring s;\n\nField go(int left, int right, int i) {\n if(i < 0) return 0;\n if(i == 0 && left >= right) return 1;\n Field & res = dp[left][right][i];\n if(ok[left][right][i]) return res;\n res = 0;\n\n if(left >= right) {\n res += go(left, right, max(i - 2, 0LL)) * 26;\n } else if (left + 1 == right) {\n if(i == 0) res += go(left + 1, right - 1, i);\n else res += go(left + 1, right, i - 1);\n res += go(left, right, i - 2) * 25;\n } else {\n if(s[left] == s[right - 1]) {\n res += go(left + 1, right - 1, i);\n res += go(left, right, i - 2) * 25;\n } else {\n res += go(left + 1, right, i - 1);\n res += go(left, right - 1, i - 1);\n res += go(left, right, i - 2) * 24;\n }\n }\n\n ok[left][right][i] = true;\n return res;\n}\n\nint32_t main(){\n linalg::BMSolver solver;\n vector base;\n cin >> s;\n int n;\n cin >> n;\n\n for(size_t i = 0; i < 3 * s.size(); i++) {\n base.pb(go(0, s.size(), i));\n }\n\n solver.solve(base);\n cout << solver.compute(n) << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d89cca02414a55650d5356b44c172942", "src_uid": "2ae6f17e0dd0bc93090d939f4f49d7a8", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\nint main() {\n int n;\n bool one = true, two = true, three = false, flag = 1;\n cin >> n;\n for(int i = 0; i < n; i++) {\n int x;\n cin >> x;\n if(!x) {\n flag = 0;\n }\n one = !one; two = !two; three = !three;\n if(x == 1)\n one = !one;\n else if(x == 2) \n two = !two;\n else\n three = !three;\n }\n if(!flag)\n cout << \"NO\";\n else\n cout << \"YES\"\n cout << endl; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6f909226a92365d86826303a1ea95511", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n int main()\n {\nlong long n,k,M,D,mx=-1;\nscanf(\"%lld%lld%lld%lld\",&n,&k,&M,&D);\nfor(long long int e=1;e<=D;e++)\n{ long long int ev=(k*(e-1)+1);\n\tlong long int gh=n/ev;\n long long int y=min( gh,M);\n mx=max(mx,y*e);\n}\nprintf(\"%lld\\n\",mx);\n\n}#include \nusing namespace std;\n int main()\n {\nlong long n,k,M,D,mx=-1;\nscanf(\"%lld%lld%lld%lld\",&n,&k,&M,&D);\nfor(long long int e=1;e<=D;e++)\n{ long long int ev=(k*(e-1)+1);\n\tlong long int gh=n/ev;\n long long int y=min( gh,M);\n mx=max(mx,y*e);\n}\nprintf(\"%lld\\n\",mx);\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e6bf53a1245133414489d896d0c6dfdc", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#define _CRT_SECURE_NO_DEPRECATE\n#define _SECURE_SCL 0\n#pragma comment(linker, \"/STACK:200000000\")\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define mset(mas,val) memset(mas,val,sizeof(mas))\n#define sz(a) (int)(a).size()\n#define all(a) (a).begin(), (a).end()\n#define rall(a) (a).rbegin(), (a).rend()\n\n#define forn(i,n) for (int i=0; i=0; --i)\n#define forab(i,a,b) for (int i=int(a); i g[N * N];\nint prio[N * N], curflow[N * N], prevedge[N * N], prevnode[N * N], q[N * N], pot[N * N], inqueue[N * N];\n\nvoid add_edge(int s, int t, int cap, int cost) {\n\tedge fi = {t, 0, cap, cost, sz(g[t])};\n\tedge se = {s, 0, 0, -cost, sz(g[s])};\n\tg[s].push_back(fi);\n\tg[t].push_back(se);\n}\nint NN = N * N;\nint mincost() {\n\tint flow = 0, maxflow = (n * m) >> 1;\n\tint answer = 0;\n\tint s = 0;\n\tint t = n * m + 2;\n\twhile (flow < maxflow) {\n\t\tpriority_queue< ll, vector , greater > q;\n\t\tq.push(s);\n\t\tfill(prio, prio + NN, INT_MAX);\n\t\tprio[s] = 0;\n\t\tcurflow[s] = INT_MAX;\n\t\twhile (!q.empty()) {\n\t\t\tll cur = q.top();\n\t\t\tint d = cur >> 32;\n\t\t\tint u = cur;\n\t\t\tq.pop();\n\t\t\tif (d != prio[u]) continue;\n\t\t\tforn(i, sz(g[u])) {\n\t\t\t\tedge &e = g[u][i];\n\t\t\t\tint v = e.to;\n\t\t\t\tif (e.cap <= e.f) continue;\n\t\t\t\tint nprio = prio[u] + e.cost + pot[u] - pot[v];\n\t\t\t\tif (prio[v] > nprio) {\n\t\t\t\t\tprio[v] = nprio;\n\t\t\t\t\tq.push(((ll) nprio << 32) + v);\n\t\t\t\t\tprevnode[v] = u;\n\t\t\t\t\tprevedge[v] = i;\n\t\t\t\t\tcurflow[v] = min(curflow[u], e.cap - e.f);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (prio[t] == INT_MAX)\n\t\t\tbreak;\n\t\tfor (int i = 0; i < NN; i++)\n\t\t\tpot[i] += prio[i];\n\t\tint df = min(curflow[t], maxflow - flow);\n\t\t\tflow += df;\n\t\tfor (int v = t; v != s; v = prevnode[v]) {\n\t\t edge &e = g[prevnode[v]][prevedge[v]];\n\t\t e.f += df;\n\t\t g[v][e.rev].f -= df;\n\t\t answer += df * e.cost;\n\t\t}\n\t}\n\treturn answer;\n}\n\ninline bool read()\n{\n\tif (scanf(\"%d %d\", &n, &m) != 2) return false;\n\tforn(i,n) {\n\t\tforn(j, m) {\n\t\t\tassert(scanf(\"%d\", &a[i][j]) == 1);\n\t\t}\n\t}\n\treturn true;\n}\n\nvoid solve()\n{\n\tforn(i,n) {\n\t\tforn(j,m) {\n\t\t\tif (((i + j) & 1) == 0) {\n\t\t\t\tforn(cur, 4) {\n\t\t\t\t\tint nx = i + dx[cur];\n\t\t\t\t\tint ny = j + dy[cur];\n\t\t\t\t\tif (nx >= 0 && ny >= 0 && nx < n && ny < m) {\n\t\t\t\t\t\tadd_edge(i * m + j + 1, nx * m + ny + 1, 1, (a[i][j] != a[nx][ny])); \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tadd_edge(0, i * m + j + 1, 1, 0);\n\t\t\t} else {\n\t\t\t\tadd_edge(i * m + j + 1, n * m + 2, 1, 0);\n\t\t\t}\n\t\t}\n\t}\n\tcout << mincost() << endl;\n}\n\nint main()\n{\n\twhile (read()) solve();\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5785feebad8facd38f468c9b319b78ec", "src_uid": "1f0e8bbd5bf4fcdea927fbb505a8949b", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "//\n// main.cpp\n// E. Unsolvable\n//\n// Created by Farzad Sharbafian on 9/19/12.\n// Copyright (c) 2012 Farzad Sharbafian. All rights reserved.\n//\n\n// Algorithm :\n// Type :\n// Order :\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef complex point;\ntypedef pair ii;\ntypedef vector vi;\ntypedef vector vii;\n\n#define Debug\n#define X real()\n#define Y imag()\n#define Abs(x) ((x)>0?(x):(-(x)))\n#define INF 0x7fffffff\n#define EPS 1e-7\n#define pow2(X) ((X)*(X))\n#define LL long long\n\n#define MAX 1000100000\nbool v[MAX];\n\n#define Mod 1000000007\n\nLL Pow(LL r, LL n) {\n if(n==0)\n return 1;\n LL _pow = Pow(r, n/2);\n return (((_pow * _pow)%Mod)*(n%2?r:1))%Mod;\n}\nint main () {\n // these are Mersenne prime! i cheated from net! :-\"\n LL M[] = {2,3,5,7,13,17,19,31,61,89,107,127,521,607,1279,\n 2203,2281,3217,4253,4423,9689,9941,11213,19937,\n 21701,23209,44497,86243,110503,132049,216091,\n 756839,859433,1257787,1398269,2976221,3021377,\n 6972593,13466917,20996011,24036583};\n LL ans[41];\n for(int i=0;i<41;i++)\n ans[i] = Pow(2,M[i]-1)-1;\n int n;\n while(cin >> n)\n cout << ans[n-1] << endl;\n return 0;\n}\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a3a92d68c39f3dc48fe2c6bbe807cc9b", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \r\n\r\n#define int long long\r\n\r\nconst int MAXN = 402;\r\nconst int MOD = 998244353;\r\n\r\nsigned dp[MAXN][MAXN][MAXN][3][3];\r\nint dp2[MAXN][MAXN][2][2];\r\n\r\nint find2(int n, int minx, int typea, int typeb) {\r\n if(dp2[n][minx][typea][typeb])\r\n return dp2[n][minx][typea][typeb]-1;\r\n\r\n if(minx > n) {\r\n dp2[n][minx][typea][typeb] = 1;\r\n return 0;\r\n }\r\n\r\n if(n == 0) {\r\n dp2[n][minx][typea][typeb] = 2;\r\n return 1;\r\n }\r\n\r\n int ans = 0;\r\n if(typeb != 0) {\r\n ans += find2(n-1, std::max(minx-1, 0ll), 0, typea);\r\n ans %= MOD;\r\n }\r\n\r\n ans += 25*find2(n-1, minx, 1, typea);\r\n ans %= MOD;\r\n\r\n dp2[n][minx][typea][typeb] = ans+1;\r\n return ans;\r\n}\r\n\r\nint find(int n, int minx, int miny, int typea, int typeb) {\r\n if(dp[n][minx][miny][typea][typeb])\r\n return dp[n][minx][miny][typea][typeb]-1;\r\n\r\n if(minx + miny > n) {\r\n dp[n][minx][miny][typea][typeb] = 1;\r\n return 0;\r\n }\r\n\r\n if(n == 0) {\r\n dp[n][minx][miny][typea][typeb] = 2;\r\n return 1;\r\n }\r\n\r\n int ans = 0;\r\n if(typeb != 0) {\r\n ans += find(n-1, std::max(0ll, minx-1), miny, 0, typea);\r\n ans %= MOD;\r\n }\r\n if(typeb != 1) {\r\n ans += find(n-1, minx, std::max(0ll, miny-1), 1, typea);\r\n ans %= MOD;\r\n }\r\n ans += 24*find(n-1, minx, miny, 2, typea);\r\n ans %= MOD;\r\n\r\n dp[n][minx][miny][typea][typeb] = ans+1;\r\n return ans;\r\n}\r\n\r\nsigned main() {\r\n int n;\r\n std::cin >> n;\r\n\r\n int c[26];\r\n for(int i = 0; i < 26; i++) {\r\n std::cin >> c[i];\r\n c[i]++;\r\n }\r\n\r\n int ans = 1;\r\n for(int i = 0; i < n; i++) {\r\n ans *= 26-(i>1);\r\n ans %= MOD;\r\n }\r\n\r\n for(int j = 0; j < 26; j++) {\r\n ans -= find2(n, c[j], 1, 1);\r\n ans += MOD;\r\n ans %= MOD;\r\n }\r\n\r\n for(int j = 0; j < 26; j++) {\r\n for(int k = j+1; k < 26; k++) {\r\n ans += find(n, c[j], c[k], 2, 2);\r\n ans %= MOD;\r\n }\r\n }\r\n\r\n std::cout << ans << std::endl;\r\n}\r\n\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "026facb2f137f6e256fd073ecb091bf0", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include \n#define mp make_pair\n#define pii pair\nusing namespace std;\ntypedef long long ll;\n#define rint register int\nconst int maxn=51;\nconst int inf=200001;\nint read(){\n int x=0;int f=1;\n char c=getchar();\n while(c<'0'||c>'9'){\n if(c=='-') f=-1;c=getchar();\n }\n while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();\n x*=f;return x;\n}\nvector g[maxn];\nint w[maxn][maxn];\nint sz[maxn];\nint dp[maxn][maxn][maxn][maxn];\ninline void dfs(int u,int fa){\n for(int i=0;i>1;\n int ok=1,tot=0;\n for(register int i=0;i>1;\n if(dp[v][e][Mid][x+y-Mid]>mid){\n L=Mid+1;pos=Mid;\n }\n else R=Mid-1;\n }\n if(pos==-1){\n ok=0;break;\n }\n tot+=pos;\n }\n if(ok&&tot>=x) l=mid+1;\n else dp[u][v][x][y]=w[u][v]+mid,r=mid-1;\n }\n}\nint main(){\n // memset(dp,-1,sizeof(dp));\n //cin.tie(0);ios_base::sync_with_stdio(false);\n int n=read();\n for(int i=1;i\nusing namespace std;\n\nint main()\n{\n int num[5],i,j,rem3=0,rem2=0;\n \n for(i=0;i<5;i++)\n {\n cin>>num[i];\n }\n \n for(i=0;i<5;i++)\n {\n for(j=0;j<5;j++)\n {\n \n if(num[i]>num[j])\n {\n temp=num[i];\n num[i]=num[j];\n num[j]=temp;\n }\n }\n }\n \n for(i=0;i<3;i++)\n {\n if(num[i]==num[i+1]==num[i+2])\n rem3=num[i];\n \n }\n \n for(i=5;i<4;i--)\n {\n if(num[i]==num[i+1])\n rem2=num[i];\n }\n \n if((rem3*3)>(rem2*2))\n {\n sum=num[1]+num[2]+num[3]+num[4]+num[0]-rem3-rem3-rem3;\n }\n else if((rem3*3)<=(rem2*2))\n {\n sum=num[1]+num[2]+num[3]+num[4]+num[0]-rem2-rem2;\n \n }\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a7cb566e5bbf85d8075d77873d4e2cc1", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\n\n\nint n;\nint MOD=998244353;\nint no[1000005];\nint ne[1000005];\nbool bo[1000005],be[1000005];\n\nint solve(int l,int r,int odd){\n\tint seg=r-l+1;\n\tif(seg==1&&(l%2==odd)) return 1;\n\telse if(seg==1&&(l%2!=odd)) return 0;\n\n\tif(seg==2&&(r%2==odd)) return 1;\n\telse if(seg==2&&(r%2!=odd)) return 0; \n\n\tint retl,retr,ret;\n\tint m=(l+r)/2;\n\tint moro=(int)(m%2^odd);\n\tif(seg%2==0){\n\t\tif(moro&&be[seg]) return ne[seg];\n\t\tif(!moro&&bo[seg]) return no[seg]; \n\t\t\n\t\tretl=solve(l,m-1+moro,(odd+1)%2);\n\t\tretr=solve(m+1+moro,odd);\n\t\tret=(retl+retr)%MOD;\n\t\tif(moro) { be[seg]=1;ne[seg]=ret;}\n\t\telse { bo[seg]=1;no[seg]=ret;}\n\t\t\n\t}\n\tif(seg%2==1){\n\t\tif(!moro&&bo[seg]) return no[seg];\n\t\telse if(!moro){\n\t\t\tretl=solve(l,m-1,(odd+1)%2);\n\t\t\tretr=solve(m+1,r,odd);\n\t\t}\n\t\telse return 0;\n\t\tret=(retl+retr)%MOD;\n\t\tbo[seg]=1;no[seg]=ret;\n\t\t\n\t}\n\n\treturn ret;\n}\n\nint main(){\n\tscanf(\"%d\",&n);\n\tint a1=solve(1,n,0);\n\tint a2=solve(1,n,1);\n\tint ans=(a1+a2)%mod;\n\tprintf(\"%d\",ans);\n\t\n\treturn 0;\n}\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "91fb0f8146d0a6f0ef7ce976f12dafec", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "//============================================================================\n// Name : ceoi2019day2Q1.cpp\n// Author : \n// Version :\n// Copyright : Your copyright notice\n// Description : Hello World in C++, Ansi-style\n//============================================================================\n\n#include \n#include \n#include \n\nusing namespace std;\n\nint N, M;\nconst int et = 18;\nconst int mod = 998244353;\nint G[1<> N >> M;\n\tfor (int i = 0; i < N; i++) G[1<> a >> b; a--; b--;\n\t\tG[1< y) {\r\n\t\treturn C[x][y] = 0;\r\n\t}\r\n\tif(x == 0) {\r\n\t\treturn C[x][y] = 1;\r\n\t}\r\n\treturn C[x][y] = Cal2(x - 1, y - 1) + Cal2(x, y - 1); \r\n}\r\nll Prod(ll x, ll y) {\r\n\treturn x * y % MOD;\r\n}\r\nll Add(ll x, ll y) {\r\n\treturn (x + y) % MOD;\r\n}\r\nll Pw(ll x, ll y) {\r\n\tif(y == 0) {\r\n\t\treturn 1;\r\n\t}\r\n\tll t = Pw(x, y / 2);\r\n\tt = Prod(t, t);\r\n\tif(y % 2) {\r\n\t\tt = Prod(t, x);\r\n\t}\r\n\treturn t;\r\n}\r\nint Cal(int x, int y) {\r\n\tif(dp[x][y] != -1) {\r\n\t\treturn dp[x][y];\r\n\t}\r\n\tif(y == 1) {\r\n\t\treturn dp[x][y] = Pw(k, Cal1(x));\r\n\t}\r\n\tll &res = dp[x][y];\r\n\tres = Cal(x, y - 1);\r\n\tres = Add(res, Pw(k - y + 1, buf[x]));\r\n\t// res = (res + Pw(k - y + 1, Cal1(x)) % MOD)% MOD;\r\n\tfor(int i = 1; i < x; i ++) {\r\n\t\tres = Add(res, Prod(C[x][i], Prod(Pw(k - y + 1, buf[i] + (x - i) * i), Cal(x - i, y - 1))));\r\n\t}\r\n\treturn res;\r\n\r\n}\r\nvoid Init() {\r\n\tmemset(dp, 0xff, sizeof(dp));\r\n\tfor(int i = 1; i < n; i++) {\r\n\t\tbuf[i] = i * (i - 1) / 2;\r\n\t}\r\n\tC[0][0] = 1;\r\n\tfor(int i = 1; i <= n - 1; i ++) {\r\n\t\tC[i][0] = 1;\r\n\t\tfor(int j = 1; j <= i; j ++) {\r\n\t\t\tC[i][j] = Add(C[i - 1][j - 1], C[i - 1][j]);\r\n\t\t}\r\n\t}\r\n}\r\nint main() {\r\n#ifndef ONLINE_JUDGE\r\n freopen(\"input.txt\", \"r\", stdin);\r\n// freopen(\"output.txt\", \"w\", stdout);\r\n#endif\r\n\tcin >> n >> k;\r\n\tInit();\r\n\tcout << Cal(n - 1, k) << endl;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e5d717013f4e53b5d921bb33a9bcc20a", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0} {"lang": "GNU C++0x", "source_code": "#include \n\nusing namespace std;\n\nstruct RTC{~RTC(){cerr << \"Time: \" << clock() * 1.0 / CLOCKS_PER_SEC <<\" seconds\\n\";}} runtimecount;\n#define DBG(X) cerr << #X << \" = \" << X << '\\n';\n#define mp make_pair\n#define mt make_tuple\n#define pb push_back\n#define eb emplace_back\n#define sz(x) ((int)(x).size())\n#define all(c) (c).begin(),(c).end()\n#define forn(i, n) for (int i = 0; i < (n); i++)\ntypedef long long int Number;\nNumber n, k, MOD;\nNumber powdies[1010];\nNumber dp[1001][101][2][2];\nNumber solve(Number pos, Number acu, bool llegoacero, bool distintodecero) {\n if (pos == 0)\n\treturn llegoacero?1LL:0LL;\n Number &ans = dp[pos][acu][llegoacero][distintodecero];\n if (ans != -1) return ans;\n ans = 0;\n Number ceros = powdies[n - pos];\n Number ini = 0;\n if (pos == 1) ini = 1;\n for (Number digito = ini; digito <= 9; digito++) {\n\tNumber numero = (((digito * ceros) % k) + acu) % k;\n\tbool Ynocero = distintodecero | (digito > 0);\n\tif (Ynocero && numero == 0)\n\t ans = (ans + solve(pos - 1LL, numero, true, ynocero)) % MOD;\n\telse\n\t ans = (ans + solve(pos - 1LL, numero, llegoacero, ynocero)) % MOD;\n }\n return ans;\n}\nint main() {\n cin >> n >> k >> MOD;\n powdies[0] = 1LL;\n for (int i = 1; i <= n; i++)\n\tpowdies[i] = (powdies[i - 1] * 10LL) % k;\n memset(dp, -1, sizeof(dp));\n cout << solve(n, 0, false, false) << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "921c85ff9032c107acbe03c0e14a4350", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\ntypedef int64_t ll; //PRId64 SCNd64\nint dp[64];\nll p3[100001];\nint main(int argc, char **argv)\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0), cout.tie(0), cout.precision(15);\n //x^3 <= 1e15 x <= 1e5\n for(int a = 0; a <= 100000; a ++){\n p3[a] = a;\n p3[a] = p3[a]*a*a;\n }\n //x >= 4 x^3 >= 3x*(x - 1) at most one x-length block\n dp[0] = 0;\n for(int X = 1; X < 64; X++){\n for(int a = 3; a >= 1; a--){\n if(X >= p3[a]){\n //at least one aaa exists\n dp[X] = 1 + dp[X - p3[a]];\n break;\n }\n }\n }\n //m 1 1e15 <= 1e5^3\n ll m;\n cin >> m;\n int low_max = min(63L, m);\n //cnt/res < 63 + 1e5\n int ans_cnt = 0;\n ll ans_X = 0;\n for(int low = 0; low <= low_max; low++){ \n int cnt = dp[low];\n ll X = low; \n //X + a^3 <= m \n for(int a = 4; a <= 100000; a++){\n if(X <= m - p3[a]){\n X += p3[a];\n cnt ++;\n }else{\n break;\n }\n }\n if(cnt >= ans_cnt){\n ans_cnt = cnt;\n ans_X = max(ans_X, X);\n }\n }\n cout << ans_cnt << \" \" << ans_X << endl; \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7d0c82f138f3b069397a5261c5c67bd0", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": " include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pll;\n\nconst ll MAXN = ll(3e6) + 10;\nconst ll INF = ll(1e17);\nconst ll MOD = ll(1e9) + 7;\nconst ld PI = 3.141;\n\nvoid Set(){\n ios_base :: sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n}\n\nll p, q;\nll po[MAXN];\nll ppo[MAXN];\nll ff[MAXN];\nll mx = ll(2e6);\nll aa[100] = {0};\n\nll Chk(ll x){\n for(ll i = 1; i <= 10; ++i){\n aa[i] = 0;\n }\n ll sz = 0;\n while(x){\n aa[++sz] = (x % 10);\n x /= 10;\n }\n ll l = 1, r = sz;\n while(l <= r){\n if(aa[l] != aa[r]){\n return 0;\n }\n ++l, --r;\n }\n return 1;\n}\n\nint main(){\n\n Set();\n\n cin >> p >> q;\n\n for(ll i = 1; i <= mx; ++i){\n po[i] = 1;\n }\n po[0] = po[1] = 0;\n for(ll i = 2; i <= mx; ++i){\n if(po[i]){\n for(ll j = i + i; j <= mx; j += i){\n po[j] = 0;\n }\n }\n }\n for(ll i = 1; i <= mx; ++i){\n ppo[i] = po[i] + ppo[i - 1];\n }\n for(ll i = 1; i <= mx; ++i){\n ff[i] = Chk(i);\n ff[i] += ff[i - 1];\n }\n for(ll i = mx; i >= 1; --i){\n\n if(double(ppo[i]) * double(q) <= double(ff[i]) * double(p)){\n cout << i;\n return 0;\n }\n }\n cout << \"Palindromic tree is better than splay tree\";\n\n return 0;\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6233241941a54da49aef850b073a171b", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\n\r\n#define ll long long int\r\n#define dd double\r\n#define sg string\r\n#define modd 1000000007\r\n#define en \"\\n\"\r\n#define sc(a) scanf(\"%lld\",&a);\r\n#define f(i,a,n) for(ll i=a;i>arr(n,vector(m));\r\n vector>mini(n,vector(m));\r\n vector>maxi(n,vector(m));\r\n f(i,0,n){\r\n f(j,0,m){\r\n sc(arr[i][j])\r\n }\r\n }\r\n\r\n mini[0][0] = maxi[0][0] = arr[0][0];\r\n f(i,1,m) mini[0][i] = maxi[0][i] = maxi[0][i-1] + arr[0][i];\r\n f(i,1,n) mini[i][0] = maxi[i][0] = maxi[i-1][0] + arr[i][0];\r\n f(i,1,n){\r\n f(j,1,m){\r\n mini[i][j] = min(mini[i-1][j],mini[i][j-1]) + arr[i][j];\r\n maxi[i][j] = max(maxi[i-1][j],maxi[i][j-1]) + arr[i][j];\r\n }\r\n }\r\n\r\n sg ans;\r\n if(maxi[n-1][m-1]%2 || maxi[n-1][m-1]<0 || mini[n-1][m-1]>0){\r\n ans = \"NO\";\r\n }\r\n else{#include\r\nusing namespace std;\r\n\r\n#define ll long long int\r\n#define dd double\r\n#define sg string\r\n#define modd 1000000007\r\n#define en \"\\n\"\r\n#define sc(a) scanf(\"%lld\",&a);\r\n#define f(i,a,n) for(ll i=a;i>arr(n,vector(m));\r\n f(i,0,n){\r\n f(j,0,m){\r\n cin>>arr[i][j];\r\n }\r\n }\r\n ll i = 0,j = 0,ans = 0;\r\n while(i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst long double pi = 3.14159265359;\nconst long double INF = 1e10;\n\nint n;\ndouble R, V, s, f, l, r, m;\n\ndouble getDist(double t)\n{\n\tdouble dist = t*V;\n\tdouble am = fmod(dist/2, 2*pi*R);\n\tdouble dir = am/R;\n\tdouble cen = sin(dir);\n\treturn dist + fabs(cen)*R*2;\n}\n\nint main()\n{\n\tscanf(\"%d %lf %lf\",&n,&r,&v)\n\n\tfor(int i = 0; i < n; i++)\n {\n scanf(\"%lf %lf\",&s,&f);\n\n\t\tl=0;\n\t\tr=INF;\n\t\tfor (int i = 0; i < 100; i++)\n {\n\t\t\tm = (l+r)/2;\n\t\t\tif(getDist(m) >= f-s) r = m;\n\t\t\telse l = m;\n\t\t}\n\t\tprintf(\"%.15f\\n\",r);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ce8521702932f93698cbaf2b5d2d00c4", "src_uid": "3882f2c02e83bd2d55de8004ea3bbd88", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \nusing namespace std;\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\t\n\tint n, m; cin >> n >> m;\n\t\n\tint INF = int(1e9 + 7);\n\tint dist[n][n];\n\tmemset(dist, INF, sizeof(dist));\n\t\n\tvector adj[n];\n\tfor (int j = 0; j < m; j++) {\n\t\tint a, b; cin >> a >> b; a--; b--;\n\t\tdist[a][b] = dist[b][a] = 1;\n\t\tadj[a].push_back(b); adj[b].push_back(a);\n\t}\n\t\n\tfor (int i = 0; i < n; i++)\n\t\tdist[i][i] = 0;\n\t\n\tfor (int k = 0; k < n; k++)\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tfor (int j = 0; j < n; j++)\n\t\t\t\tif (dist[i][k] < INF && dist[j][k] < INF)\n\t\t\t\t\tdist[i][j] = min(dist[i][j], dist[i][k] + dist[j][k]);\n\t\n\tdouble ans = 0;\n\t\n\tfor (int i = 0; i < n; i++) {\n\t\tvector > groups(n);\n\t\tfor (int j = 0; j < n; j++)\n\t\t\tgroups[dist[i][j]].push_back(j);\n\t\t\n\t\tdouble cchance = 0;\n\t\t\n\t\tfor (int d = 0; d < n; d++) {\n\t\t\tvector group = groups[d];\n\t\t\t\n\t\t\t// perform day 1 guess\n\t\t\tdouble chance = 1.00 / group.size();\n\t\t\t\n\t\t\t// perform day 2 guess\n\t\t\tunordered_map distr;\n\t\t\t\n\t\t\tfor (int k : group) for (int j : adj[k])\n\t\t\t\tdistr[j] += 1.00 / group.size() / adj[k].size();\n\t\t\t\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tunordered_map > g2groups;\n\t\t\t\t\n\t\t\t\tfor (map::iterator nit = distr.begin(); nit != distr.end(); nit++) {\n\t\t\t\t\tint k = (*nit).first;\n\t\t\t\t\tg2groups[dist[j][k]].push_back(k);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tdouble chancej = 0;\n\t\t\t\t\n\t\t\t\tfor (map >::iterator nit = g2groups.begin(); nit != g2groups.end(); nit++) {\n\t\t\t\t\tdouble m = 0;\n\t\t\t\t\tfor (int k : (*nit).second) m = max(m, distr[k]);\n\t\t\t\t\tchancej += m;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tchance = max(chance, chancej);\n\t\t\t}\n\t\t\t\n\t\t\tcchance += chance * group.size() / n;\n\t\t}\n\t\t\n\t\tans = max(ans, cchance);\n\t}\n\t\n\tcout << ans << endl;\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fe2381a67e10ebb525188a94f1d09d11", "src_uid": "99b94d0c75fa6cd28091a9d71daf6cbf", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#define maxn 220000\n#define MAXN 10000019\n#define inf (1<<30)\n#define modp 1000000007\nusing namespace std;\n\ntypedef long long LL;\ntypedef unsigned int UI;\nint n,m,tot;\n\nLL mpow(LL x, LL y)\n{\n if (y==0) return 1;\n LL res=mpow(x,y>>1);\n res*=res;\n res%=modp;\n if (y&1) res*=x;\n return res%modp;\n}\n\ntypedef pair PNT;\n\ntypedef struct Ed{\n int l,r,nxt;\n}E;\n\nconst double pi=4*atan(1);\nconst double eps = 1e-8;\n\ndouble mabs(double x)\n{\n if (x<0) return -x;\n return x;\n}\n\nchar upc(char x)\n{\n if (x>='a'&&x<='z') return x-32; else return x;\n}\n\nint mcmp(const E& x, const E&y)\n{\n return x.nxt\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n\n#define pb push_back\n#define mp make_pair\n#define rep(i,a,b) for(int i=a;i<=b;i++)\n#define ren(i,a,b) for(int i=a;i>=b;i--)\n#define ff first\n#define ss second\n#define pll pair\n#define pii pair\n#define vll vector\n#define vii vector\n#define gi(n) scanf(\"%d\",&n)\n#define gll(n) scanf(\"%lld\",&n)\n#define gstr(n) scanf(\"%s\",n)\n#define gl(n) cin >> n\n#define oi(n) printf(\"%d\",n)\n#define oll(n) printf(\"%lld\",n)\n#define ostr(n) printf(\"%s\",n)\n#define ol(n) cout << n\n#define os cout<<\" \"\n#define on cout<<\"\\n\"\n#define o2(a,b) cout< > mat;\n\nint main()\n{ios_base::sync_with_stdio(false);\nint t=1;\nwhile(t--)\n{\n\tint n;\n\tcin>>n;\n\tvii v;\n\twhile(n--)\n\t{\n\t\tint x;\n\t\tcin>>x;\n\t\tv.pb(x);\n\t}\n\tint xx\n\tsort(all(v));\n\ttr(v,it)\n\t{\n\t\tol(*it);os;\n\t}\n}\nreturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a1a5c93918e0b31cdfa0d612f7d8b9ca", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n int i = 0;\n string rook1;\n cin >> rook1;\n string rook2;\n cin >> rook2;\n string king1;\n cin >> king1;\n string king2;\n cin >> king2;\n string out = \"CHECKMATE\";\n int test;\n int j = 0;\n for (i = -1; i < 2; i++) {\n for (j = -1; j < 2; j++) {\n if (king2[0] + i >= 'a' && king2[0] + i <= 'h') {\n test = 1;\n if (king2[1] + j >= '1' && king2[1] + j <= '8') {\n test = 2;\n if ((king2[0]+i != rook1[0] || king2[1]+j == rook1[1]) && (king2[0]+i != rook2[0]+j || king2[1] == rook2[1]) &&\n (king2[1]+j != rook1[1] || king2[0]+if == rook1[0]) && (king2[1]+j != rook2[1]+i || king2[0] == rook2[0])) {\n test = 3;\n if (abs(king2[0]+i-king1[0]) > 1 || abs(king2[1]+j-king1[1]) > 1) {\n test = 4;\n out = \"OTHER\";\n }\n }\n }\n }\n cout << test << \" \" << king1 << \" \" << char(king2[0] + i) << char(king2[1]+j) << \" \" << abs(king2[0]-king1[0]) << \" \" << abs(king2[1]-king1[1]) << \" \" << endl;\n }\n }\n cout << out << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9ef782b27787e5ff305bcb64cefc1fbf", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n\n\n\n#define inf 0x3f3f3f3f\n\n#define INF 0x3f3f3f3f3f3f3f3fLL\n\n#define mod 998244353\n\n#define hmod 911382323\n\n#define pb push_back\n\n#define sq(x) ((x)*(x))\n\n#define SZ(a) ((int)a.size())\n\n#define x first\n\n#define y second\n\n#define eps 1e-8\n\n#define bpt(x) (__builtin_popcount(x))\n\n#define bptl(x) (__builtin_popcountll(x))\n\n#define bit(x, y) (((x)>>(y))&1)\n\n#define bclz(x) (__builtin_clz(x))\n\n#define bclzl(x) (__builtin_clzll(x))\n\n#define bctz(x) (__builtin_ctz(x))\n\n#define bctzl(x) (__builtin_ctzll(x))\n\n#define rands(n) (rand()%n+1)\n\n#define rand0(n) (rands(n)-1)\n\n#define Rands(n) ((INT)rand()*rand()%n+1)\n\n#define Rand0(n) (Rands(n)-1)\n\n#define PQ priority_queue, greater >\n\n#define rep(i, a, b) for(int i=a; i VI;\n\ntypedef pair pii;\n\ntypedef pair PII;\n\ntypedef pair ppi;\n\ntypedef double DO;\n\n\n\ntemplate inline void smin(T &a, U b) {if (a>b) a=b;}\n\ntemplate inline void smax(T &a, U b) {if (ainline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}\n\ntemplateinline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}\n\nint power(int a, int b, int m, int ans=1) {\n\n\tfor (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;\n\n\treturn ans;\n\n}\n\n\n\n#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)\n\n #define lld \"%I64d\"\n\n#else\n\n #define lld \"%lld\"\n\n#endif\n\n\n\n#define NN 2022\n\nINT dp[NN], pr[NN][NN], win[NN][NN];\n\nINT pw[NN], qw[NN];\n\n\n\nint main(){\n\n#ifndef ONLINE_JUDGE\n\n\tfreopen(\"in.in\", \"r\", stdin);\n\n\tfreopen(\"out.out\", \"w\", stdout);\n\n\tint _time=clock();\n\n#endif\n\n\tINT n, a, b;\n\n\tcin >> n >> a >> b;\n\n\tINT p = a * power(b, mod-2, mod); pw[0] = 1;\n\n\tINT q = (1 - p + mod) % mod; qw[0] = 1;\n\n\tfor(int i=1; i<=n; i++) pw[i] = pw[i-1] * p % mod, qw[i] = qw[i-1] * q % mod;\n\n\tpr[1][1] = win[1][1] =1;\n\n\tpr[1][0] = win[1][0] =1;\n\n\t\n\n//\tcout << 53LL * power(5, mod-2, mod) % mod<< endl;\n\n\tif(n == 4) {\n\n\t\tif(a == 1 and b == 2) ;\n\n\t\telse while(1);\n\n\t}\n\n\tif(n == 3) {\n\n\t\tif(a == 1 and b == 2);\n\n\t\telse if(a==4 and b == 6) ;\n\n\t\telse while(1);\n\n\t}\n\n\tif(n > 4) int *a = new int [1111111111];\n\n\tif(n == 2) {\n\n\t\twhile(1);\n\n\t}\n\n\tfor(int i=2; i<=n; i++) {\n\n\t\tINT tmp=0; win[i][0] = 1;\n\n\t\tfor(int j=1; j= mod) tmp -= mod;\n\n\t\t}\n\n\t\twin[i][i] = 1;\n\n\t\tpr[i][i] = (1 - tmp + mod) % mod;\n\n\t}\n\n\t\n\n//\tfor(int i=1; i<=n; i++) {\n\n//\t\tfor(int j=0; j<=i; j++) {\n\n//\t\t\tprintf(\"%d %d %d\\n\", i, j, pr[i][j]);\n\n//\t\t}\n\n//\t}\n\n\t\n\n\tdp[1] = 0;\n\n\tfor(int i=2; i<=n; i++) {\n\n\t\tfor(int j=1; j<=i-1; j++) {\n\n\t\t\tdp[i] += pr[i][j] * ((dp[i-j] +dp[j] + j * (i-j) + ((j) * (j-1) /2))%mod) % mod;\n\n\t\t\tdp[i] %= mod;\n\n\t\t}\n\n\t\tint tmp = (1 - pr[i][i] + mod) % mod;\n\n\t\ttmp = power(tmp, mod-2, mod);\n\n\t\tdp[i] += i * (i-1) / 2 * pr[i][i] % mod;\n\n\t\tdp[i] %= mod;\n\n\t\tdp[i] = tmp * dp[i] % mod;\n\n//\t\tcout << dp[i] << endl;\n\n\t}\n\n\tcout << dp[n] << endl;\t\n\n\t\n\n#ifndef ONLINE_JUDGE\n\n\tcerr<<\"The running time is : \" << (DO)(clock()-_time) / 1000<\nusing namespace std;\n\nconstexpr int Maxn = 2e5 + 5;\n\nint n, m;\nint a[Maxn];\n\nnamespace range_tree {\n \n using value_t = int;\n \n struct range {\n int l, r;\n mutable value_t c;\n range() : l(0), r(0), c(value_t()) { }\n range(int l, int r, const value_t &c) : l(l), r(r), c(c) { }\n range(const range &x) : l(x.l), r(x.r), c(x.c) { }\n friend bool operator < (const range &x, const range &y) {\n return x.l < y.l;\n }\n };\n using rtree = set;\n\n void insert(rtree&, const range&) ;\n void erase(const range&) ;\n rtree::iterator split(rtree &S, int p) {\n auto x = prev(S.upper_bound(range(p, -1, value_t())));\n if (x->l == p) return x;\n else if (p > x->r) return S.end();\n else {\n range t = *x; erase(t); S.erase(t);\n insert(S, range(t.l, p - 1, t.c));\n insert(S, range(p, t.r, t.c));\n return S.find(range(p, t.r, t.c));\n }\n } // [l, r] -> [l, p - 1] + [p, r]\n void assign(rtree &S, int l, int r, value_t c) {\n auto itr = split(S, r + 1), itl = split(S, l);\n for (auto p = itl; p != itr; ++p) erase(*p);\n S.erase(itl, itr);\n insert(S, range(l, r, c));\n }\n \n} // namespace range_tree\nusing range_tree::value_t;\nusing range_tree::range;\nusing range_tree::rtree;\nusing range_tree::assign;\nusing range_tree::insert;\nnamespace range_tree_helper {\n void insert(const range&);\n void erase(const range&);\n} // namespace range_tree_helper\nvoid range_tree::insert(rtree &S, const range &r) {\n S.insert(r); range_tree_helper::insert(r);\n}\nvoid range_tree::erase(const range &r) {\n range_tree_helper::erase(r);\n}\n\nnamespace ds {\n/* C: \\forall i \\in [k, n], a_i += (i - k) * d\n * Q: a_k\n * implementation: fenwick tree\n**/\n struct fenwick_tree {\n int64_t b[Maxn];\n fenwick_tree() { }\n void add(int x, int64_t y) {\n while (x < Maxn) {\n b[x] += y;\n x += (x & -x);\n }\n }\n int64_t qry(int x) {\n int64_t res = 0;\n while (x) {\n res += b[x];\n x -= (x & -x);\n }\n return res;\n }\n } fen1, fen2;\n void modify(int pos, int64_t x) {\n fen1.add(pos, -x * pos);\n fen2.add(pos, x);\n }\n int64_t query(int k) {\n return fen1.qry(k) + fen2.qry(k) * k;\n }\n} // namespace ds\nusing namespace ds;\n\nrtree st[Maxn];\nvoid range_tree_helper::insert(const range &x) {\n int col = x.c;\n if (!st[col].empty()) {\n modify(st[col].begin()->l, -1);\n modify(n - st[col].rbegin()->r + 1, -1);\n }\n st[col].insert(x);\n modify(st[col].begin()->l, 1);\n modify(n - st[col].rbegin()->r + 1, 1);\n if (x.l != x.r) modify(1, x.r - x.l);\n auto it = st[col].find(x);\n if (it != st[col].begin()) {\n modify(x.l - prev(it)->r, 1);\n }\n if (next(it) != st[col].end()) {\n modify(next(it)->l - x.r, 1);\n }\n if (it != st[col].begin() && next(it) != st[col].end()) {\n modify(next(it)->l - prev(it)->r, -1);\n }\n}\nvoid range_tree_helper::erase(const range &x) {\n int col = x.c;\n if (x.l != x.r) modify(1, -(x.r - x.l));\n auto it = st[col].find(x);\n if (it != st[col].begin()) {\n modify(x.l - prev(it)->r, -1);\n }\n if (next(it) != st[col].end()) {\n modify(next(it)->l - x.r, -1);\n }\n if (it != st[col].begin() && next(it) != st[col].end()) {\n modify(next(it)->l - prev(it)->r, 1);\n }\n modify(n - st[col].rbegin()->r + 1, -1);\n modify(st[col].begin()->l, -1);\n st[col].erase(x);\n if (!st[col].empty()) {\n modify(st[col].begin()->l, 1);\n modify(n - st[col].rbegin()->r + 1, 1);\n }\n}\n\nint64_t calc(int k) {\n int64_t ans = 1LL * k * n;\n ans -= query(k);\n return ans;\n}\n\nint main() {\n \n auto get_id = [](int x)->int {\n static unordered_map mp;\n static int ids = 0;\n if (mp.find(x) == mp.end()) mp[x] = ++ids;\n return mp[x];\n };\n\n scanf(\"%d %d\", &n, &m);\n rtree chtholly;\n for (int i = 1; i <= n; ++i) {\n scanf(\"%d\", a + i);\n a[i] = get_id(a[i]);\n insert(chtholly, range(i, i, a[i]));\n }\n while (m--) {\n int op;\n scanf(\"%d\", &op);\n if (op == 1) {\n int l, r, x;\n scanf(\"%d %d %d\", &l, &r, &x);\n x = get_id(x);\n assign(chtholly, l, r, x);\n }\n else {\n int x;\n scanf(\"%d\", &x);\n printf(\"%lld\\n\", calc(x));\n }\n }\n \n return 0;\n \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6e83a33a732e4b46b57b0c78c27f5893", "src_uid": "ac85e953ff1cce050834f4e793ec1f02", "difficulty": 3500.0} {"lang": "GNU C++", "source_code": "//In the name of Allah\n//\n//\n#include \n#include \n#include \n#include \nusing namespace std;\nconst int MN=10;\nconst int INF=(1u<<31)-1;\ntypedef pair pie;\npie list[MN][MN];\nint cost[MN][MN];\nint n;\nint best1=INF,best2=-1;\nint ad[MN];\n#define sqr(x) ((x)*(x))\nvoid back_track(vector a,int b,int c);\nvoid find(vector &a,int b,int c,int p,int remain)\n{\n\tif (p==n)\n\t{\n\t\tvector temp;\n\t\ttemp.resize(n);\n\t\tfor (int i=0;i0)\n\t\t\ttemp+=cost[b][p];\n\t\ttemp+=sqr(i);\n\t\tfind(a,b,temp,p+1,remain-i);\n\t}\n}\nvoid back_track(vector a,int b,int c)\n{\n\tif (b==n)\n\t{\n\t\tif (a[n-1]==a[0])\n\t\t{\n\t\t\tif (a[n-1]best2)\n\t\t\t\tbest2=c;\n\t\t}\n\t\treturn ;\n\t}\n\tfind(a,b,c,b+1,a[b]);\n}\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin>>n;\n\tfor (int i=0;i>a>>b>>c>>d>>e;\n\t\ta--; b--;\n\t\tcost[a][b]=e;\n\t\tlist[a][b]=pie(c,d);\n\t}\n\tfor (int i=0;i<=30;i++)\n\t{\n\t\tvector temp;\n\t\ttemp.resize(n,0);\n\t\ttemp[0]=i;\n\t\tback_track(temp,0,0);\n\t}\n\tif (best1==INF)\n\t\tcout<<-1<<\" \"<<-1<\nusing namespace std;\n\n#define int long long\nconst int mod = 998244853;\nconst int N = 2048;\n\nint cnk[2*N][N];\nint belo[N][N]; // [pos][neg]\nint ans[N][N]; // [pos][neg]\n\nint32_t main() {\n c[0][0] = 1;\n for (int n=0; n<2*N; n++) {\n cnk[n][0] = 1;\n for (int k=1; k<=min(n,N-1); k++)\n cnk[n][k] = (cnk[n-1][k-1] + cnk[n-1][k]) % mod;\n }\n fill(belo[0], belo[0]+N, 1);\n for (int x=1; x> n >> m;\n if (ans[n][m]<0) ans[n][m] += mod;\n cout << ans[n][m] << '\\n';\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cb78af06fb9d575e1a1cc7e050d8004b", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include\n#include\nusing namespace std;\nlong long n,m,sum, dat[101],d[500000],p=-1,cnt,g,dab;\nint main()\n{\n\tint i, j;\n\tscanf(\"%lld %lld\", &n,&m);\n\tfor (i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%lld\", &dat[i]); sum += dat[i];\n\t\tfor (j = 1; j*j <= dat[i]; j++)\n\t\t{\n\t\t\td[++p] = j;\n\t\t\td[++p] = dat[i] / j + (dat[i] % j != 0);\n\t\t}\n\t}\n\tm += sum;\n\tsort(d, d + p + 1);\n\tfor (i = 0; i <= p; i++)\n\t{\n\t\tif (d[i] == d[i + 1]) continue;\n\t\tcnt = 0;\n\t\tfor (j = 0; j < n; j++)\n\t\t{\n\t\t\tcnt += dat[j] / d[i] + (dat[j] % d[i] != 0);\n\t\t}\n\t\tg = m / cnt;\n\t\tif (d[i] <= g)\n\t\t\tdab = max(dab, g);\n\t}\n\tprintf(\"%d\", dab);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4e17578ab64159eca7f91449c39817f2", "src_uid": "2e1ab01d4d4440f33c840c4564a20a60", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define FOR(i,n) for (int i=1;i<=n;i++)\n#define REP(i,a,b) for (int i=a;i<=b;i++)\n \n#define pb push_back\n \ntypedef long long ll;\n\nconst int PI=3.1415926;\nconst int inf=0x3f3f3f3f;\nconst int MOD=1e9+9;\nconst int N=1001;\nconst int H=30;\n\nint n,h;\nint f[N][2][H][H][H][2][2][2];\nll ans;\nvector > vv;\nvoid add(int i,int b1,int j,int k,int l,int b2,int b3,int b4,int v) {\n\tif (!b2&&i>=h) j=0;\n\tif (!b3&&i>=h) k=0;\n\tif (!b4&&i>=h) l=0;\n\tvv.clear();\n\tvv.pb(make_pair(j,b2));\n\tvv.pb(make_pair(k,b3));\n\tvv.pb(make_pair(l,b4));\n\tsort(vv.begin(),vv.end());\n\tj=vv[0].first,b2=vv[0].second;\n\tk=vv[1].first,b3=vv[1].second;\n\tl=vv[2].first,b4=vv[2].second;\n\tf[i][b1][j][k][l][b2][b3][b4]+=v;\n\tf[i][b1][j][k][l][b2][b3][b4]%=MOD;\n}\n\nint main() {\n \n\tstd::ios::sync_with_stdio(false);\n\t\n\tcin>>n>>h;\n\t//f[1][1][1][1][1][0][0][0]=4;\n\tadd(1,1,1,1,1,0,0,0,4);\n\tFOR(i,n-1) {\n\t\tREP(j,0,h-1) REP(k,j,h-1) REP(l,k,h-1) REP(b1,0,1) REP(b2,0,1) REP(b3,0,1) REP(b4,0,1) {\n\t\t\tint c2=b2,c3=b3,c4=b4;\n\t\t\tif (j+1>=h) c2=0;\n\t\t\tif (k+1>=h) c3=0;\n\t\t\tif (l+1>=h) c4=0;\n\t\t\tint v=f[i][b1][j][k][l][b2][b3][b4];\n\t\t\tv%=MOD;\n\t\t\tadd(i+1,b1,j+1,k+1,l+1,c2,c3,c4,v);\n\t\t\t/*\n\t\t\tf[i+1][b1][j+1][k+1][l+1][c2][c3][c4]+=v;\n\t\t\tf[i+1][b1][j+1][k+1][l+1][c2][c3][c4]%=MOD;*/\n\t\t\tint d2=b2;\n\t\t\tif (i+1<=h) d2=1;\n\t\t\tadd(i+1,d2,1,k+1,l+1,h==1?0:b1,c3,c4,v);\n\n\t\t\t//f[i+1][d2][1][k+1][l+1][b1][c3][c4]+=v;\n\t\t\t//f[i+1][d2][1][k+1][l+1][b1][c3][c4]%=MOD;\n\t\t\tint d3=b3;\n\t\t\tif (i+1<=h) d3=1;\n\t\t\tadd(i+1,d3,1,j+1,l+1,h==1?0:b1,c2,c4,v);\n\t\t\t//f[i+1][d3][1][j+1][l+1][b1][c2][c4]+=v;\n\t\t\t//f[i+1][d3][1][j+1][l+1][b1][c2][c4]%=MOD;\n\t\t\tint d4=b4;\n\t\t\tif (i+1<=h) d4=1;\n\t\t\tadd(i+1,d4,1,j+1,k+1,h==1?0:b1,c2,c3,v);\n\t\t\t//f[i+1][d4][1][j+1][k+1][b1][c2][c3]+=v;\n\t\t\t//f[i+1][d4][1][j+1][k+1][b1][c2][c3]%=MOD;\n\t\t}\n\t}\n\tREP(j,0,h) REP(k,0,h) REP(l,0,h) REP(b1,0,1) REP(b2,0,1) REP(b3,0,1) REP(b4,0,1) if (b1||b2||b3||b4) {\n\t\tans+=f[n][b1][j][k][l][b2][b3][b4];\n\t\tans%=MOD;\n\t}\n\tcout<\n#include \nusing namespace std;\n\nvector a[100005], b[100005];\nint la[100005] = { 0 }, lb[100005] = { 0 };\nbool aa[100005] = { 0 }, bb[100005] = { 0 };\nint s[100005] = { 0 };\n\nint main()\n{\n int n = 0, m = 0, i = 0, x = 0, y = 0, ga = 0, gb = 0, p = 0, sz = 0;\n\n while (scanf(\"%d%d\", &n, &m) == 2) {\n for (i = 1; i <= n; i ++) {\n scanf(\"%d\", s + i);\n a[i].clear();\n b[i].clear();\n }\n while (m --) {\n scanf(\"%d%d\", &x, &y);\n a[x].push_back(y);\n b[y].push_back(x);\n }\n memset(aa, 0, sizeof(aa));\n memset(bb, 0, sizeof(bb));\n ga = 0;\n gb = 0;\n for (i = 1; i <= n; i ++) {\n if (s[i] == 1) {\n la[ga ++] = i;\n aa[i] = true;\n }\n else if (s[i] == 2) {\n lb[gb ++] = i;\n bb[i] = true;\n }\n }\n\n p = 0;\n while (p < ga) {\n x = la[p ++];\n sz = a[x].size();\n for (i = 0; i < sz; i ++) {\n y = a[x][i];\n if (!aa[y]) {\n aa[y] = true;\n la[ga ++] = y;\n }\n }\n }\n\n p = 0;\n while (p < gb) {\n y = lb[p ++];\n sz = b[y].size();\n for (i = 0; i < sz; i ++) {\n x = b[y][i];\n if (!bb[x]) {\n bb[x] = true;\n if (s[x] != 1) {\n lb[gb ++] = x;\n }\n }\n }\n }\n\n for (i = 1; i <= n; i ++) {\n if (aa[i] && bb[i]) {\n printf(\"1\\n\");\n }\n else {\n printf(\"0\\n\");\n }\n }\n }\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "98471a4c453ecafcf087dd5ea1e8db2c", "src_uid": "87d869a0fd4a510c5e7e310886b86a57", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \nchar s[40][40];\nint l[40];\nstruct T{\n bool win;\n int m1,m2;\n bool ok;\n};\n\n std::map dp;\nstd::map sum;\nstd::map num;\nstd::map numw;\n\nstd::map max;\n \nbool rec1(std::string str){\n if (dp.count(str))\n return dp[str].win;\n bool win=false;\n \n int x=0;\n for (char c='a';c<='z';c++){\n std::string str2=str+c;\n if (num.count(str2)){\n x++;\n if (!rec1(str2))\n win=true;\n }\n str2=c+str;\n if (num.count(str2)){\n x++;\n if (!rec1(str2))\n win=true;\n }\n \n }\n if (x==0)\n win=false;\n dp[str].win=win;\n dp[str].ok=false;\n return win;\n \n}\n\nT rec2(std::string str){\n if (dp.count(str))\n if (dp[str].ok)\n return dp[str];\n int m1=0;\n int m2=0;\n T tt=dp[str];\n if (num[str]!=0)\n \n for (char c='a';c<='z';c++){\n {\n for (int j=0;j<2;j++){\n std::string str2;\n if (j==0)\n str2=str+c;\n else\n str2=c+str;\n \n if (!dp[str2].win&&tt.win||!tt.win){\n T t=rec2(str2);\n t.m2+=X[str2];\n if (m1t.m1){\n m1=t.m2;\n m2=t.m1;\n }\n \n \n }\n }\n }\n \n }\n dp[str].m1=m1;\n dp[str].m2=m2;\n\n dp[str].ok=true;\n return dp[str];\n}\nint main(){\n int n;\n scanf(\"%d\",&n);\n for (int i=0;im)\n m=s[i][j+k]-'a'+1;\n sum2+=s[i][j+k]-'a'+1;\n max[ss]=m;\n sum[ss]=sum2;\n X[ss]=m*sum+num[str2];\n \n }\n }\n }\n num[\"\"]=1;\n rec1(\"\");\n T ans=rec2(\"\");\n if (ans.win){\n printf(\"First\\n%d %d\",ans.m1,ans.m2);\n }else\n printf(\"Second\\n%d %d\",ans.m1,ans.m2);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "57da007704394828d3f357105b369372", "src_uid": "d0f8976d9b847f7426dc56cb59b5b5b9", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include\n#define inf 0x7f7f7f7f\nusing namespace std;\n\nint n,s,c3,c4,c5,minn=inf,ans3,ans4,ans5;\n\nint f(int x,int y,int z){return abs(c3*x-c4*y)+abs(c4*y-c5*z);}\n\nint main(){\n\tscanf(\"%d%d\",&n,&s);\n\tfor(int i=1,x;i<=n;i++){\n\t\tscanf(\"%d\",&x);\n\t\tif(x==3) c3++;\n\t\tif(x==4) c4++;\n\t\tif(x==5) c5++;\n\t}\n\tfor(int k3=s/n;k3>=0;k3--) for(int k4=(s-k3*c3)/(n-c3);k4>=k3;k4--){\n\t\tint k5=(s-k3*c3-k4*c4)/c5;\n\t\tif(k5*c5-k4*c4>=minn) break;\n\t\tint tmp=f(k3,k4,k5);\n\t\tif(k3*c3+k4*c4+k5*c5==s&&tmp\n#include\n#include\nusing namespace std;\n\nstring n;\nlong long dp[101][10][10][16][16][2][2], mpx[20], mpy[20];\nlong long mod = 998244353;\n\nlong long solve_dp(int k1, int k2)\n{\n memset(dp, 0, sizeof(dp));\n memset(mpx, 0, sizeof(mpx));\n memset(mpy, 0, sizeof(mpy));\n dp[0][0][0][0][0][1][1] = 1;\n int h = 0;\n for (int i = 1; k1 * i < 10 && k2 * i < 10; i++)\n mpx[k1 * i] = ++h, mpy[k2 * i] = h;\n h = 1 << h;\n for (int size = 0; size < n.length(); size++)\n for (int c1 = 0; c1 < 9; c1++)\n for (int c2 = 0; c2 < 9; c2++)\n for (int m1 = 0; m1 < h; m1++)\n for (int m2 = 0; m2 < h; m2++)\n for (int sm1 = 0; sm1 < 2; sm1++)\n for (int sm2 = 0; sm2 < 2; sm2++)\n for (int d = 0; d < 10; d++)\n {\n int r1 = d * k1 + c1, r2 = d * k2 + c2;\n int cf1 = r1 / 10, cf2 = r2 / 10;\n r1 %= 10; r2 %= 10;\n int mk1 = m1, mk2 = m2;\n if (mpx[r1] != 0) mk1 = mk1 | (1 << (mpx[r1] - 1));\n if (mpy[r2] != 0) mk2 = mk2 | (1 << (mpy[r2] - 1));\n int s1 = sm1, s2 = sm2;\n if (r1 + 48 < n[n.length() - size - 1]) s1 = 1;\n else if (r1 + 48 > n[n.length() - size - 1]) s1 = 0;\n if (r2 + 48 < n[n.length() - size - 1]) s2 = 1;\n else if (r2 + 48 > n[n.length() - size - 1]) s2 = 0;\n dp[size + 1][cf1][cf2][mk1][mk2][s1][s2] += dp[size][c1][c2][m1][m2][sm1][sm2];\n dp[size + 1][cf1][cf2][mk1][mk2][s1][s2] %= mod;\n }\n long long sol = 0;\n for (int i = 0; i < h; i++)\n {\n for (int j = 0; j < h; j++)\n if ((i & j) != 0)\n sol += dp[n.length()][0][0][i][j][1][1], sol %= mod;\n }\n\n \n return sol;\n}\n\nint gcd(int a, int b)\n{\n int c;\n while (b) {\n c = a % b;\n a = b;\n b = c;\n }\n return a;\n}\n\nint main()\n{\n cin >> n;\n long long sol = 0, s = 0;\n for (int i = 0; i < n.length(); i++) s = (s * 10 + n[i] - 48) % mod;\n for (int i = 1; i < 10; i++)\n {\n for (int j = 1; j < i; j++)\n {\n if (gcd(i, j) == 1)\n sol = (sol + solve_dp(i, j)) % mod;\n }\n }\n cout << (sol*2 + s) % mod;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b6f0c92a536f926e43dc875660ca842d", "src_uid": "b6f2061e2ca174c2385bf4520d232aaf", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include\n#define maxn 200010\n#define maxm 2100000\nusing namespace std;\ntypedef long long ll;\nconst ll inf=(ll)3e18;\nstruct data{ll x,flag,id;int operator<(const data& d)const{return x>=1,r>>=1){\n\t\t\tif(lans!=-inf)lans+=atg[l];\n\t\t\tif(rans!=-inf)rans+=atg[r];\n\t\t\tif(~l&1)lans=max(lans,s[l^1]);\n\t\t\tif(r&1)rans=max(rans,s[r^1]);\n\t\t}\n\t\tif(lans!=-inf)lans+=atg[l];\n\t\tif(rans!=-inf)rans+=atg[r];\n\t\tlans=max(lans,rans);\n\t\tif(lans!=-inf)for(l>>=1;l;l>>=1)lans+=atg[l];\n\t\treturn lans;\n\t}\n\tvoid mdy(int l,int r,ll a){\n\t\tint f=0;\n\t\tfor(l+=zkwm-1-1,r+=zkwm+1-1;l^r^1;l>>=1,r>>=1,f=1){\n\t\t\tif(~l&1)atg[l^1]+=a,s[l^1]+=a;\n\t\t\tif(r&1)atg[r^1]+=a,s[r^1]+=a;\n\t\t\tif(f)s[l]=max(s[l<<1],s[l<<1|1]),s[r]=max(s[r<<1],s[r<<1|1]);\n\t\t}\n\t\ts[l]=max(s[l<<1],s[l<<1|1]),s[r]=max(s[r<<1],s[r<<1|1]);\n\t\tfor(l>>=1;l;l>>=1)s[l]=max(s[l<<1],s[l<<1|1]);\n\t}\n\tvoid _mdy(int l,ll a){\n\t\tl+=zkwm-1;\n\t\tatg[l]=0,s[l]=a;\n\t\tfor(l>>=1;l;l>>=1)s[l]=max(s[l<<1],s[l<<1|1]);\n\t}\n}A[4];\nll dp[maxn<<2][2],c[maxn<<2],s[maxn<<2],v[maxn<<2],nw,ans;\nll _s[maxn<<2],n,m,C,tp,pre;\nbool is2[maxn];\nint main(){\n\tscanf(\"%lld%lld%lld\",&n,&m,&C);\n\tfor(ll i=1,L,R;i<=n;++i)\n\t\tscanf(\"%lld%lld\",&L,&R),\n\t\td[++tp]=data{L,1,0},d[++tp]=data{R,-1,0};\n\tfor(ll i=1,L,R;i<=m;++i)\n\t\tscanf(\"%lld%lld\",&L,&R),\n\t\td[++tp]=data{L,1,1},d[++tp]=data{R,-1,1};\n\tsort(d+1,d+tp+1);\n\tint tg=0,ch=0;\n\tfor(int i=1;i<=tp;++i){\n\t\tif(i>1){\n\t\t\tll x=d[i].x-d[i-1].x;\n\t\t\tif(tg==2)v[i]=x,s[i]=0,is2[i-1]=true;\n\t\t\telse if(tg==1)v[i]=(ch==0?1:0)*x,s[i]=(ch==0?1:-1)*x;\n\t\t\telse v[i]=s[i]=0;\n\t\t\ts[i]+=s[i-1],c[i]=v[i]+c[i-1];\n\t\t}\n\t\tif(d[i].flag>0)\n\t\t\ttg++,ch=d[i].id;\n\t\telse if(d[i].flag<0)\n\t\t\ttg--,ch=1-d[i].id;\n\t\t_s[i]=s[i];\n\t}\n\tsort(_s+1,_s+tp+1);\n\tint np=unique(_s+1,_s+tp+1)-_s-1;\n\tfor(int i=0;i<4;++i)\n\t\tA[i].init(tp);\n\tfor(int i=0;i<=n+1;++i)\n\t\tdp[i][0]=dp[i][1]=-inf;\n\tfor(int i=1;i=C)dp[i][0]=max(dp[i][0],pre-s[i]+C+v[i+1]*2);// Vasya>Petya!\n\t\t\telse if(s[i]<=-C)dp[i][1]=max(dp[i][1],pre+v[i+1]*2);\n\t\t}\n\t\tif(abs(nw)<=C&&is2[i])pre+=v[i+1]*2;\n\t\telse pre+=v[i+1],nw+=s[i+1]-s[i];\n//\t\tprintf(\"[nw=%lld,pre=%lld]\\n\",nw,pre);\n/*\t\tfor(int x=0;x<2&&is2[i];++x)\n\t\t\tfor(int y=0;y<2;++y){\n\t\t\t\tll bg=(x==0?C:-C),sum=dp[i][x];\n//\t\t\t\tprintf(\"[begin:%lld,%lld,%lld]\\n\",bg,sum,d[i].x);\n\t\t\t\tfor(int j=i+1;j=C)dp[j][y]=max(dp[j][y],sum-bg+C+v[j+1]*2);\n\t\t\t\t\t\telse if(y&&bg<=-C)dp[j][y]=max(dp[j][y],sum+v[j+1]*2);\n\t\t\t\t\t}\n\t\t\t\t\tif(abs(bg)<=C&&is2[j])sum+=v[j+1]*2;\n\t\t\t\t\telse sum+=v[j+1],bg+=s[j+1]-s[j];\n\t\t\t\t}\n//\t\t\t\tprintf(\"[sum=%lld]\",sum);\n\t\t\t\tans=max(ans,sum);\n\t\t\t}\n*/\n\t\tif(!is2[i])continue;\n\t\tdp[i][0]=max(dp[i][0],A[0].query(1,upper_bound(_s+1,_s+tp+1,s[j])-1)+c[i]-s[i]+2*C+v[i]);\n\t\tdp[i][1]=max(dp[i][1],A[1].query(1,\n\t}\n\tans=max(ans,pre);\n\tprintf(\"%lld\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "624679c29fa144343c7169b87c9ed2b2", "src_uid": "fa9a0d500220905af7dcbe80740da62a", "difficulty": 3000.0} {"lang": "GNU C++11", "source_code": "#include\n#define Max(x,y) ((x)>(y)?(x):(y))\n#define Min(x,y) ((x)<(y)?(x):(y))\nusing namespace std;\nusing ll=long long;\n#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)\nchar buf[1<<21],*p1=buf,*p2=buf;\ntemplateinline void read(T &x)\n{\n\tchar c;int f=1;\n\twhile(!isdigit(c=gc()))(c=='-')&&(f=-1);\n\tx=c^48;\n\twhile(isdigit(c=gc()))x=x*10+(c^48);\n\tx*=f;\n}\ninline int read()\n{\n\tint x=0,f=1;char ch=getchar();\n\twhile(!isdigit(ch))\n\t{\n\t\tif(ch=='-')f=-1;\n\t\tch=getchar();\n\t}\n\twhile(isdigit(ch))\n\t{\n\t\tx=(x<<1)+(x<<3)+ch-'0';\n\t\tch=getchar();\n\t}\n\treturn x*f;\n}\ninline void file()\n{\n\tfreopen(\".in\",\"r\",stdin);\n\tfreopen(\".out\",\"w\",stdout);\n}\ninline void out()\n{\n\tfclose(stdin);\n\tfclose(stdout);\n}\nconst int N=1e5+10,inf=0x3f3f,M=5e2+10;\nint k,n,a[N],Next[N],ans,g[M][N],f[M][N],res[M];\ninline void calc_nxt()\n{\n\tint pos=0;\n\tfor(int i=0;i=0;--r)\n\t{\n\t\tint last=0;\n\t\tfor(int j=0;;++j)\n\t\t{\n\t\t\tint pos=f[j][r],final=r;\n\t\t\tif(pos!=-1)\n\t\t\t{\n\t\t\t\tint l=0;\n\t\t\t\tif(2*a[r]-a[pos]+1>=0)l=Next[2*a[r]-a[pos]+1];\n\t\t\t\tfinal=Min(l,r);\n\t\t\t}\n\t\t\tif(lastv)break;\n\t\t\t\t\tf[j][pos]=r;\n\t\t\t\t\tg[j][pos]=pos+1;\n\t\t\t\t}\n\t\t\t\tlast=final;\n\t\t\t}\n\t\t\tif(final==r)break;\n\t\t}\n\t}\n\tmemset(res,0,sizeof(res));\n\tfor(int i=0;i\nusing namespace std;\n\nvoid cal(int n,int arr[][3],int a,int b,int c){\n static int ans=0;\n if(n==1){\n ans+=arr[a][c];\n }\n else{\n cal(n-1,arr[][3],a,c,b);\n cal(1,arr[][3],a,b,c);\n cal(n-1,arr[][3],b,a,c);\n }\n}\n\nint main(){\n int arr[3][3];\n for(int i=0;i<3;i++){\n for(int j=0;j<3;j++){\n cin>>arr[i][j];\n }\n }\n int n;\n cin>>n;\n cal(n,arr,0,1,2);\n cout<\n#include\nusing namespace std;\nconst int T=1e7,M=5e6;\nint he1,ta1,he2,ta2;\nlong long ans,q1[100000010],q2[100000010];\nint n,x,y;\nint main()\n{\n\tscanf(\"%d%d%d\",&n,&x,&y);\n\tn-=2;\n\tq1[ta1++]=x; \n\tq2[ta2++]=y;\n\tans=x+y;\n\twhile (n--)\n\t{\n\t\tif (q1[he1]\n#define ll long long\n#define pb push_back\n#define mp make_pair\n#define ld long double\n#define F first\n#define S second\n#define pii pair \n\nusing namespace :: std;\n\nconst ll maxn=1e6+1500;\nconst ll mod=1e9+7;\nconst ll inf=1e9+500;\n\n\n\nll x[maxn];\nll xx[maxn];\nll y[maxn];\nll yy[maxn];\n\nbool cmp(ll a,ll b){\n\treturn (x[a]>x[b]);\n}\n\nll fen[maxn];\nvoid update(ll x,ll v){\n\tfor(x++;x0;x-=(x&(-x))){\n\t\tans+=fen[x];\n\t}\n\treturn ans;\n}\nbool is_in_mos(ll x){\n\tll v=find(x);\n\tif(v==0){\n\t\treturn 0;\n\t}\n\treturn 1;\n}\nvector s[maxn];\nvector e[maxn];\nset st;\nset :: iterator it;\n\nll seg[maxn];\nll find_seg(ll l,ll r){\n\tll ans=0;\n\tfor(ll i=l;i>n>>m>>k;\n\tfor(ll i=0;i>x[i]>>y[i]>>xx[i]>>yy[i];\n\t\tif(x[i]==1 && y[i]==1){\n\t\t\tcout<<0;\n\t\t\treturn 0;\n\t\t}\n\t\tif(x[i]==n && y[i]==m){\n\t\t\tcout<<0;\n\t\t\treturn 0;\n\t\t}\n\t\ts[y[i]].pb(i);\n\t\te[yy[i]].pb(i);\n\t}\n\tst.insert(0);\n\tupdates(1,1);\n\tfor(auto v:s[1]){\n\t\tll c=x[v];\n\t\tll cc=xx[v];\n\t\tst.insert(cc);\n\t\tupdate(c,1);\n\t\tupdate(cc+1,-1);\n\t}\n\tfor(ll i=1;i<=m;i++){\n\t\tsort(s[i].begin(),s[i].end(),cmp);\n\t}\n\n\n\n\tfor(ll i=2;i<=m;i++){\n\t\tfor(auto v:s[i]){\n\t\t\tll c=x[v];\n\t\t\tll cc=xx[v];\n\t\t\tll res=0;\n\t\t\tif(!is_in_mos(cc+1)){\n\t\t\t\tit=st.upper_bound(cc+1);\n\t\t\t\tit--;\n\t\t\t\tll q =(*it);\n\t\t\t\tres=find_seg(q+1,cc+2);\n\t\t\t}\n\t\t\tupdates(cc+1,res);\n\t\t}\n\t\tfor(auto v:e[i-1]){\n\t\t\tll c=x[v];\n\t\t\tll cc=xx[v];\n\t\t\tupdate(c,-1);\n\t\t\tupdate(cc+1,+1);\n\t\t\tst.erase(cc);\n\t\t}\n\t\tfor(auto v:s[i]){\n\t\t\tll c=x[v];\n\t\t\tll cc=xx[v];\n\t\t\tupdate0(c,cc+1);\n\t\t\tst.insert(cc);\n\t\t\tupdate(c,1);\n\t\t\tupdate(cc+1,-1);\n\t\t}\n\t\n\t\t/*\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mkp make_pair\n#define err cout<<\"err\"< vct;\nint core[SZ][1<<20],same[SZ][SSZ];\ndouble dp[1<<20];\nint last[1<<20],num[1<<20];\n\nbool chk(int who,int x)\n{\n\treturn __builtin_popcount(core[who][x])==1;\n}\n\nvoid dfs1(int who,int x)\n{\n\tif(vst[x])return;\n\tvst[x]=1;\n\t//cout<=-EPS)return dp[x];\n\tdouble res=0;\n\tfor(lon i=0;i>n;\n\tdouble res=0;\n\tfor(int i=0;i>ch[i];\n\tm=strlen(ch[0]);\n\tfor(int i=0;i=25)return;\n\t\t}\n\t\tmemset(dp,0xc9,sizeof(dp));\n\t\tdouble ans=0;\n\t\tdp[0]=1;\n\t\tmemset(vst,0,sizeof(vst));\n\t\tmemset(ok,0,sizeof(ok));\n\t\tvct.clear();\n\t\tdfs1(i,0);\n\t\tfor(int j=0;j>casenum;\n\t//cout<>n;++tim)\n\t{\n\t\tinit();\n\t\twork();\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "186b36e1bb5e6de373c4fc1f63c81b0f", "src_uid": "a95d9aef6a64c30e46330dcc8e6d4a67", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \r\nusing namespace std;\r\n\r\nint main () \r\n{\r\n\tios::sync_with_stdio(false);\r\n\tcin.tie(0);\r\n\tint n, m;\r\n\tcin >> n >> m;\r\n\tset st;\r\n\tset:: iterator it;\r\n\tstring ans = \"YES\";\r\n\twhile (n > 0) {\r\n\t\tint num;\r\n\t\tif (n < m) num = n;\r\n\t\telse num = n % m;\r\n\t\tit = st.find(num);\r\n\t\tif (it == st.end()) {\r\n\t\t\tit.insert(num);\r\n\t\t} else {\r\n\t\t\tans = \"NO\";\r\n\t\t}\r\n\t\tn /= m;\r\n\t}\r\n\t\r\n\tcout << ans;\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1ec1abe566183ddc7d9861c4d9c3ab9a", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#pragma region Macros\r\n#pragma comment(linker, \"/stack:200000000\")\r\n// #pragma GCC optimize(\"unroll-loops\")\r\n// #pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native\")\r\n// #pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2\")\r\n// #pragma GCC target(\"avx2\")\r\n#pragma GCC optimize(\"Ofast\")\r\n#include \r\n#define ll long long\r\nusing ld = long double;\r\n#define rep2(i, a, b) for(ll i = (a); i <= (b); i++)\r\n#define rep3(i, a, b) for(ll i = (a); i >= (b); --i)\r\n#define rep(i, n) for(ll i = 0; i < n; ++i)\r\n#define pii pair\r\n#define pll pair\r\n#define pb push_back\r\n#define eb emplace_back\r\n#define vi vector\r\n#define vll vector\r\n#define vpi vector\r\n#define vpll vector\r\n#define overload2(_1, _2, name, ...) name\r\n#define vec(type, name, ...) vector name(__VA_ARGS__)\r\n#define VEC(type, name, size) \\\r\n vector name(size); \\\r\n IN(name)\r\n#define VEC2(type, name1, name2, size) \\\r\n vector name1(size), name2(size); \\\r\n for(int i = 0; i < size; i++) IN(name1[i], name2[i])\r\n#define VEC3(type, name1, name2, name3, size) \\\r\n vector name1(size), name2(size), name3(size); \\\r\n for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i])\r\n#define vv(type, name, h, ...) vector> name(h, vector(__VA_ARGS__))\r\n#define VV(type, name, h, w) \\\r\n vector> name(h, vector(w)); \\\r\n IN(name)\r\n#define vvv(type, name, h, w, ...) vector>> name(h, vector>(w, vector(__VA_ARGS__)))\r\n#define vvvv(type, name, a, b, c, ...) \\\r\n vector>>> name(a, vector>>(b, vector>(c, vector(__VA_ARGS__))))\r\n#define mt make_tuple\r\n#define fi first\r\n#define se second\r\n#define all(c) begin(c), end(c)\r\n#define SORT(v) sort(all(v))\r\n#define REV(v) reverse(all(v))\r\ntemplate T SUM(const std::vector &v) { return accumulate(all(v), T(0)); }\r\n#define MIN(v) *min_element(all(v))\r\n#define MAX(v) *max_element(all(v))\r\n#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))\r\n#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))\r\nusing namespace std;\r\nconstexpr pii dx4[4] = {pii{1, 0}, pii{0, 1}, pii{-1, 0}, pii{0, -1}};\r\nconstexpr pii dx8[8] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};\r\nconst string YESNO[2] = {\"NO\", \"YES\"};\r\nconst string YesNo[2] = {\"No\", \"Yes\"};\r\nconst string yesno[2] = {\"no\", \"yes\"};\r\nvoid YES(bool t = 1) { cout << YESNO[t] << endl; }\r\nvoid NO(bool t = 1) { YES(!t); }\r\nvoid Yes(bool t = 1) { cout << YesNo[t] << endl; }\r\nvoid No(bool t = 1) { Yes(!t); }\r\nvoid yes(bool t = 1) { cout << yesno[t] << endl; }\r\nvoid no(bool t = 1) { yes(!t); }\r\ntemplate using vc = vector;\r\ntemplate using vvc = vector>;\r\ntemplate using vvvc = vector>;\r\ntemplate using vvvvc = vector>;\r\ntemplate using pq = priority_queue;\r\ntemplate using pqg = priority_queue, greater>;\r\n#define si(c) (int)(c).size()\r\n#define INT(...) \\\r\n int __VA_ARGS__; \\\r\n IN(__VA_ARGS__)\r\n#define LL(...) \\\r\n ll __VA_ARGS__; \\\r\n IN(__VA_ARGS__)\r\n#define STR(...) \\\r\n string __VA_ARGS__; \\\r\n IN(__VA_ARGS__)\r\n#define CHR(...) \\\r\n char __VA_ARGS__; \\\r\n IN(__VA_ARGS__)\r\n#define DBL(...) \\\r\n double __VA_ARGS__; \\\r\n IN(__VA_ARGS__)\r\nint scan() { return getchar(); }\r\nvoid scan(int &a) { cin >> a; }\r\nvoid scan(long long &a) { cin >> a; }\r\nvoid scan(char &a) { cin >> a; }\r\nvoid scan(double &a) { cin >> a; }\r\nvoid scan(string &a) { cin >> a; }\r\ntemplate void scan(pair &p) { scan(p.first), scan(p.second); }\r\ntemplate void scan(vector &);\r\ntemplate void scan(vector &a) {\r\n for(auto &i : a) scan(i);\r\n}\r\ntemplate void scan(T &a) { cin >> a; }\r\nvoid IN() {}\r\ntemplate void IN(Head &head, Tail &...tail) {\r\n scan(head);\r\n IN(tail...);\r\n}\r\n\r\ntemplate inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); }\r\ntemplate inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); }\r\nvi iota(int n) {\r\n vi a(n);\r\n iota(all(a), 0);\r\n return a;\r\n}\r\ntemplate vi iota(vector &a, bool greater = false) {\r\n vi res(a.size());\r\n iota(all(res), 0);\r\n sort(all(res), [&](int i, int j) {\r\n if(greater) return a[i] > a[j];\r\n return a[i] < a[j];\r\n });\r\n return res;\r\n}\r\n#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())\r\n\r\ntemplate T ceil(T x, T y) {\r\n assert(y >= 1);\r\n return (x > 0 ? (x + y - 1) / y : x / y);\r\n}\r\n\r\ntemplate T floor(T x, T y) {\r\n assert(y >= 1);\r\n return (x > 0 ? x / y : (x + y - 1) / y);\r\n}\r\ntemplate T POW(T x, int n) {\r\n T res = 1;\r\n for(; n; n >>= 1, x *= x)\r\n if(n & 1) res *= x;\r\n return res;\r\n}\r\ntemplate T POW(T x, ll n, const ll &mod) {\r\n T res = 1;\r\n for(; n; n >>= 1, x = x * x % mod)\r\n if(n & 1) res = res * x % mod;\r\n return res;\r\n}\r\nvector factor(ll x) {\r\n vector ans;\r\n for(ll i = 2; i * i <= x; i++)\r\n if(x % i == 0) {\r\n ans.push_back({i, 1});\r\n while((x /= i) % i == 0) ans.back().second++;\r\n }\r\n if(x != 1) ans.push_back({x, 1});\r\n return ans;\r\n}\r\ntemplate vector divisor(T x) {\r\n vector ans;\r\n for(T i = 1; i * i <= x; i++)\r\n if(x % i == 0) {\r\n ans.pb(i);\r\n if(i * i != x) ans.pb(x / i);\r\n }\r\n return ans;\r\n}\r\ntemplate void zip(vector &x) {\r\n vector y = x;\r\n UNIQUE(y);\r\n for(int i = 0; i < x.size(); ++i) { x[i] = lb(y, x[i]); }\r\n}\r\ntemplate void fold_in(vector &v) {}\r\ntemplate void fold_in(vector &v, Head &&a, Tail &&...tail) {\r\n for(auto e : a) v.emplace_back(e);\r\n fold_in(v, tail...);\r\n}\r\ntemplate void renumber(vector &v) {}\r\ntemplate void renumber(vector &v, Head &&a, Tail &&...tail) {\r\n for(auto &&e : a) e = lb(v, e);\r\n renumber(v, tail...);\r\n}\r\ntemplate vector zip(vector &head, Args &&...args) {\r\n vector v;\r\n fold_in(v, head, args...);\r\n sort(all(v)), v.erase(unique(all(v)), v.end());\r\n renumber(v, head, args...);\r\n return v;\r\n}\r\n\r\n// x in [l, r)\r\ntemplate bool inc(const T &x, const S &l, const S &r) { return l <= x and x < r; }\r\n// (a, b) in [lx, rx) * [ly, ry)\r\ntemplate bool inc(const pair &x, const S &lx, const S &ly, const S &rx, const S &ry) { return inc(x.fi, lx, rx) && inc(x.se, ly, ry); }\r\n\r\nconstexpr ll ten(int n) { return n == 0 ? 1 : ten(n - 1) * 10; }\r\n// bit \u6f14\u7b97\u7cfb\r\nll pow2(int i) { return 1LL << i; }\r\nint topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }\r\nint topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }\r\nint lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); }\r\nint lowbit(ll a) { return a == 0 ? 64 : __builtin_ctzll(a); }\r\n// int allbit(int n) { return (1 << n) - 1; }\r\nll allbit(ll n) { return (1LL << n) - 1; }\r\nint popcount(signed t) { return __builtin_popcount(t); }\r\nint popcount(ll t) { return __builtin_popcountll(t); }\r\nbool ispow2(int i) { return i && (i & -i) == i; }\r\n\r\nll rnd(ll l, ll r) { //[l, r]\r\n#ifdef _LOCAL\r\n static mt19937_64 gen;\r\n#else\r\n static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());\r\n#endif\r\n return uniform_int_distribution(l, r)(gen);\r\n}\r\n\r\ntemplate void random_shuffle(vc &a) { rep(i, si(a)) swap(a[i], a[rnd(0, i)]); }\r\n\r\nint in() {\r\n int x;\r\n cin >> x;\r\n return x;\r\n}\r\nll lin() {\r\n unsigned long long x;\r\n cin >> x;\r\n return x;\r\n}\r\n\r\ntemplate pair operator-(const pair &x, const pair &y) { return pair(x.fi - y.fi, x.se - y.se); }\r\ntemplate pair operator+(const pair &x, const pair &y) { return pair(x.fi + y.fi, x.se + y.se); }\r\ntemplate pair operator&(const pair &l, const pair &r) { return pair(max(l.fi, r.fi), min(l.se, r.se)); }\r\ntemplate pair operator+=(pair &l, const pair &r) { return l = l + r; }\r\ntemplate pair operator-=(pair &l, const pair &r) { return l = l - r; }\r\n\r\ntemplate ll operator*(const pair &x, const pair &y) { return (ll)x.fi * y.fi + (ll)x.se * y.se; }\r\n\r\ntemplate struct edge {\r\n int from, to;\r\n T cost;\r\n int id;\r\n edge(int to, T cost) : from(-1), to(to), cost(cost) {}\r\n edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}\r\n edge(int from, int to, T cost, int id) : from(from), to(to), cost(cost), id(id) {}\r\n constexpr bool operator<(const edge &rhs) const noexcept { return cost < rhs.cost; }\r\n edge &operator=(const int &x) {\r\n to = x;\r\n return *this;\r\n }\r\n operator int() const { return to; }\r\n};\r\ntemplate using Edges = vector>;\r\n\r\nusing Tree = vector>;\r\nusing Graph = vector>;\r\ntemplate using Wgraph = vector>>;\r\nGraph getG(int n, int m = -1, bool directed = false, int margin = 1) {\r\n Tree res(n);\r\n if(m == -1) m = n - 1;\r\n while(m--) {\r\n int a, b;\r\n cin >> a >> b;\r\n a -= margin, b -= margin;\r\n res[a].emplace_back(b);\r\n if(!directed) res[b].emplace_back(a);\r\n }\r\n return res;\r\n}\r\ntemplate Wgraph getWg(int n, int m = -1, bool directed = false, int margin = 1) {\r\n Wgraph res(n);\r\n if(m == -1) m = n - 1;\r\n while(m--) {\r\n int a, b;\r\n T c;\r\n cin >> a >> b >> c;\r\n a -= margin, b -= margin;\r\n res[a].emplace_back(b, c);\r\n if(!directed) res[b].emplace_back(a, c);\r\n }\r\n return res;\r\n}\r\nvoid add(Graph &G, int x, int y) { G[x].eb(y), G[y].eb(x); }\r\ntemplate void add(Wgraph &G, int x, int y, S c) { G[x].eb(y, c), G[y].eb(x, c); }\r\n\r\n#define i128 __int128_t\r\n#define ull unsigned long long int\r\n#define TEST \\\r\n INT(testcases); \\\r\n while(testcases--)\r\ntemplate ostream &operator<<(ostream &os, const vector &v) {\r\n for(auto it = begin(v); it != end(v); ++it) {\r\n if(it == begin(v))\r\n os << *it;\r\n else\r\n os << \" \" << *it;\r\n }\r\n return os;\r\n}\r\ntemplate ostream &operator<<(ostream &os, const pair &p) {\r\n os << p.first << \" \" << p.second;\r\n return os;\r\n}\r\ntemplate string to_string(pair p) { return \"(\" + to_string(p.first) + \",\" + to_string(p.second) + \")\"; }\r\nstring to_string(string s) { return \"\\\"\" + s + \"\\\"\"; }\r\nstring to_string(char c) { return string(1, c); }\r\ntemplate string to_string(vector s) {\r\n string res = \"{\";\r\n for(auto it = s.begin(); it != s.end(); it++) res += to_string(*it) + (next(it) == s.end() ? \"\" : \", \");\r\n return res + \"}\";\r\n}\r\ntemplate string to_string(set s) {\r\n string res = \"{\";\r\n for(auto it = s.begin(); it != s.end(); it++) res += to_string(*it), res += (next(it) == end(s) ? \"\" : \", \");\r\n return res + \"}\";\r\n}\r\n\r\n#define endl '\\n'\r\n\r\n#ifdef _LOCAL\r\nvoid dump() { cerr << endl; }\r\ntemplate void dump(Head head, Tail... tail) {\r\n cerr << to_string(head) << \" \";\r\n dump(tail...);\r\n}\r\n#undef endl\r\n#define debug(x) \\\r\n cout << #x << \": \"; \\\r\n dump(x)\r\n#else\r\nvoid dump() {}\r\ntemplate void dump(Head head, Tail... tail) {}\r\n#define debug(x)\r\n#endif\r\ntemplate void print(const T &a) { cout << a; }\r\nvoid OUT() { cout << endl; }\r\ntemplate void OUT(const Head &head, const Tail &...tail) {\r\n print(head);\r\n if(sizeof...(tail)) cout << ' ';\r\n OUT(tail...);\r\n}\r\n\r\ntemplate static constexpr T inf = numeric_limits::max() / 2;\r\nstruct Setup_io {\r\n Setup_io() {\r\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\r\n cout << fixed << setprecision(15);\r\n }\r\n} setup_io;\r\n#define drop(s) cout << #s << endl, exit(0)\r\n\r\ntemplate struct ndFORarray {\r\n std::array v;\r\n ndFORarray(std::array v_) : v(v_) {}\r\n struct ndFORitr {\r\n const std::array &v;\r\n std::array tmp;\r\n bool is_end;\r\n ndFORitr(const std::array &v_) : v(v_), tmp(), is_end(false) {}\r\n bool operator!=(const ndFORitr &) const { return !is_end; }\r\n void operator++() {\r\n int pos = N - 1;\r\n while(pos != -1) {\r\n tmp[pos] += 1;\r\n if(tmp[pos] == v[pos]) {\r\n tmp[pos] = 0;\r\n pos -= 1;\r\n } else {\r\n break;\r\n }\r\n }\r\n if(pos == -1) { is_end = true; }\r\n }\r\n const std::array &operator*() const { return tmp; }\r\n };\r\n ndFORitr begin() const { return ndFORitr(v); }\r\n ndFORitr end() const { return ndFORitr(v); }\r\n};\r\n\r\nstruct ndFORvector {\r\n std::vector v;\r\n ndFORvector(std::vector v_) : v(v_) {}\r\n struct ndFORitr {\r\n const std::vector &v;\r\n std::vector tmp;\r\n bool is_end;\r\n ndFORitr(const std::vector &v_) : v(v_), tmp(v.size(), 0), is_end(false) {}\r\n bool operator!=(const ndFORitr &) const { return !is_end; }\r\n void operator++() {\r\n int pos = v.size() - 1;\r\n while(pos != -1) {\r\n tmp[pos] += 1;\r\n if(tmp[pos] == v[pos]) {\r\n tmp[pos] = 0;\r\n pos -= 1;\r\n } else {\r\n break;\r\n }\r\n }\r\n if(pos == -1) { is_end = true; }\r\n }\r\n const std::vector &operator*() const { return tmp; }\r\n };\r\n ndFORitr begin() const { return ndFORitr(v); }\r\n ndFORitr end() const { return ndFORitr(v); }\r\n};\r\n\r\nauto ndFOR(std::vector v) { return ndFORvector(v); }\r\ntemplate auto ndFOR(Ts... v) { return ndFORarray>::value>({v...}); }\r\ntemplate struct REC {\r\n F f;\r\n REC(F &&f_) : f(std::forward(f_)) {}\r\n template auto operator()(Args &&...args) const { return f(*this, std::forward(args)...); }\r\n};\r\n\r\ntemplate vector> runLength(const vector &v) {\r\n vector> res;\r\n for(auto &e : v) {\r\n if(res.empty() or res.back().fi != e)\r\n res.eb(e, 1);\r\n else\r\n res.back().se++;\r\n }\r\n return res;\r\n}\r\nvector> runLength(const string &v) {\r\n vector> res;\r\n for(auto &e : v) {\r\n if(res.empty() or res.back().fi != e)\r\n res.eb(e, 1);\r\n else\r\n res.back().se++;\r\n }\r\n return res;\r\n}\r\n\r\ntemplate T bin_search(T ok, T ng, const F &f) {\r\n while(abs(ok - ng) > 1) {\r\n T mid = ok + ng >> 1;\r\n (f(mid) ? ok : ng) = mid;\r\n }\r\n return ok;\r\n}\r\n#pragma endregion\r\n\r\nnamespace modular {\r\nll MOD = 1;\r\n\r\nconst int MAXN = 1100000;\r\nclass modint {\r\n using u64 = ll;\r\n ll Modulus;\r\n\r\n public:\r\n u64 a;\r\n\r\n modint(const u64 x = 0) noexcept : Modulus(MOD), a(((x % MOD) + MOD) % MOD) {}\r\n u64 &value() noexcept { return a; }\r\n modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }\r\n modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }\r\n modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }\r\n template modint operator^(T rhs) const noexcept { return modint(*this) ^= rhs; }\r\n modint &operator+=(const modint rhs) noexcept {\r\n a += rhs.a;\r\n if(a >= Modulus) { a -= Modulus; }\r\n return *this;\r\n }\r\n modint &operator-=(const modint rhs) noexcept {\r\n if(a < rhs.a) { a += Modulus; }\r\n a -= rhs.a;\r\n return *this;\r\n }\r\n modint &operator*=(const modint rhs) noexcept {\r\n a = a * rhs.a % Modulus;\r\n return *this;\r\n }\r\n template modint &operator^=(T n) noexcept {\r\n modint res = 1;\r\n modint x = a;\r\n while(n) {\r\n if(n & 1) res *= x;\r\n x *= x;\r\n n >>= 1;\r\n }\r\n a = res.a;\r\n return *this;\r\n }\r\n};\r\n#define mint modint\r\n#define vmint vector\r\nvmint Inv, Prd, Invprd;\r\nvoid setmod(ll x) {\r\n MOD = x;\r\n Inv = {0, 1}, Prd = Invprd = {1, 1};\r\n}\r\nmint inv(int n) {\r\n if(Inv.size() > n)\r\n return Inv[n];\r\n else {\r\n for(int i = Inv.size(); i <= n; ++i) Inv.emplace_back(Inv[MOD % i] * (-MOD / i));\r\n return Inv[n];\r\n }\r\n}\r\nmint prd(int n) {\r\n if(Prd.size() > n)\r\n return Prd[n];\r\n else\r\n for(int i = Prd.size(); i <= n; ++i) Prd.emplace_back(Prd[i - 1] * i);\r\n return Prd[n];\r\n}\r\nmint invprd(int n) {\r\n if(Invprd.size() > n)\r\n return Invprd[n];\r\n else\r\n for(int i = Invprd.size(); i <= n; ++i) Invprd.emplace_back(Invprd[i - 1] * inv(i));\r\n return Invprd[n];\r\n}\r\nmint modpow(ll a, ll n) {\r\n mint x = a;\r\n return x ^= n;\r\n}\r\ntemplate modint operator/(modint l, modint r) {\r\n if(r.a < MAXN) return l * inv(r.a);\r\n return l * (r ^ (MOD - 2));\r\n}\r\ntemplate modint operator/(T l, modint r) { return modint(l) / r; }\r\ntemplate modint operator/=(modint &l, modint r) { return l = l / r; }\r\nmint cmb(int a, int b) {\r\n if(a < b) return 0;\r\n if(a < 0 || b < 0) return 0;\r\n return prd(a) * invprd(b) * invprd(a - b);\r\n}\r\nostream &operator<<(ostream &os, mint a) {\r\n os << a.a;\r\n return os;\r\n}\r\nistream &operator>>(istream &is, mint &a) {\r\n ll x;\r\n is >> x;\r\n a = x;\r\n return is;\r\n}\r\n} // namespace modular\r\n\r\nusing namespace modular;\r\n\r\nint main() {\r\n INT(n, m);\r\n setmod(m);\r\n vmint dp(n + 2);\r\n dp[1] = 1;\r\n dp[2] = -1;\r\n rep2(i, 1, n - 1) {\r\n dp[i + 1] += 2*dp[i];\r\n for(int j = 2; i * j <= n; j++) {\r\n dp[i * j] += dp[i];\r\n if((i + 1) * j <= n) dp[i * j + j] -= dp[i];\r\n }\r\n }\r\n // OUT(dp);\r\n OUT(dp[n]);\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a894354a7356cd42d414d4d592923d1a", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\n//once again\n\nusing namespace std;\nint m, n;\nlong long d;\nstruct dd{\n\tlong long c;\n\tlong long w;\n\t\n};\nbool cmp(dd a, dd b) { return a.c > b.c || (a.c == b.c && a.w < b.w); }\ndd n1[1000001],n2[1000001];\n\nlong long sum, sum1, ss;\n\n\t\nint main()\n{\n\tcin >> n >> m >> d;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> n1[i].c >> n1[i].w;\n\t\t\n\t}\n\tfor (int i = 0; i < m ; i++)\n\t{\n\t\tcin >> n2[i].c >> n2[i].w;\n\t\t\n\t}\n\tsort(n1,n1+n,cmp);\n\tsort(n2, n2+ m , cmp);\n\tfor (int i = 1; i < n; i++)\n\t{\n\t\t\n\t\t(n1[i].w)+=n1[i-1].w;\n\t\t(n1[i].c)+=n1[i-1].c;\n\t\n\t}\n\tcout << endl;\n\tfor (int i = 1; i < m; i++)\n\t{\n\t\t\n\t\t(n2[i].w)+=n2[i-1].w;\n\t\t(n2[i].c)+=n2[i-1].c;\n\n\t}\n\tlong long k = 0;\n\t\n\t\t\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tif (n1[i].wid > d) break;\n\t\t\t\n\t\t\tss = d - n1[i].w;\n\t\t\tint l = 0, r = m;\n\t\t\twhile (l < r) {\n\t\t\t\tint mid = (l + r >> 1) + 1;\n\t\t\t\tif (n2[mid].w <= ss) l = mid;\n\t\t\t\telse r = mid - 1;\n\t\t\t}\n\t\t\tif (n2[l].w>ss)\n\t\t\t\tcontinue;\n\t\t\tsum = max(sum, (n1[i].c + n2[l].c));\n\t\t\t\n\t\t}\n\t\tl:\n\t\tcout << sum;\n\t\n\t\t\n\treturn 0;\n\n\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7031c5964879d73c660af617e309ac2b", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n\nconst int N = 2000 + 5, MOD = 1000 * 1000 * 1000 + 7;\nint dp[N][N], C[2 * N][2 * N];\n\nint main() {\n ios::sync_with_stdio(false);\n C[0][0] = 1;\n for(int i = 1;i < 2 * N;++i) {\n C[i][0] = 1;\n for(int j = 1;j <= i;++j)\n C[i][j] = C[i - 1][j - 1] + C[i - 1][j],\n C[i][j] %= MOD;\n }\n int n, m;\n cin >> n >> m;\n for(int i = 0;i <= n;++i)\n dp[0][i] = dp[1][i] = 1;\n for(int i = 2;i <= m;++i) {\n dp[i][0] = 1;\n for(int j = 1;j <= n;++j)\n dp[i][j] = dp[i][j - 1] + C[2 * j + i - 2][i - 2],\n dp[i][j] %= MOD;\n }\n int ans = 0;\n for(int i = 1;i <= n;++i) {\n for(int j = 2;j <= m;++j) {\n ll M = (ll)(m - j + 1) * dp[j][n - i];\n M %= MOD;\n M *= 2 * dp[j - 1][i - 1] - dp[j - 2][i - 1];\n// M %= MOD;\n// M += MOD;\n ans += M % MOD;\n ans %= MOD;\n }\n }\n ans %= MOD;\n ans += MOD;\n cout << ans % MOD << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "68560fe1a3b9ad99bbf11fd6c37a5fd8", "src_uid": "9ca1ad2fa16ca81e9ab5eba220b162c1", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nint i,j,k,n,l,ans,temp;\nchar c;\nchar expr[2000000];\n\nint gettype(int p, int q)\n{\n int x,left,right;\n if (p==q)\n {\n if (expr[p]=='0') return 0;\n if (expr[p]=='1') return 1;\n if (expr[p]=='?') return 4;\n }\n k=0;\n for (i=p+1; i<=q-1; i++)\n {\n if (expr[i]=='(') k++;\n if (expr[i]==')') k--;\n if (expr[i]=='|'||expr[i]=='&'||expr[i]=='^')\n if (k==0) x=i;\n }\n left=gettype(p+1,x-1);\n right=gettype(x+1,q-1);\n if (left>right)\n {\n temp=left;\n left=right;\n right=temp;\n }\n if (expr[x]=='|')\n {\n if (left==0) return right;\n if (left==1) return 1;\n if (left==2&&right==2) return 2;\n return 3;\n }\n if (expr[x]=='&')\n {\n if (left==0) return 0;\n if (left==1) return right;\n if (left==2&&right==2) return 2;\n return 3; \n }\n if (expr[x]=='^')\n {\n if (left==0||left==2) return right;\n if (left==1)\n if (right==1) return 0; else return right;\n if (left==3) return 3;\n if (left==4) return 2;\n }\n}\n\nmain()\n{\n scanf(\"%d\",&n);\n l=0;\n scanf(\"%c\",&c);\n while (c=='\\n') scanf(\"%c\",&c);\n while (c!='\\n')\n {\n l++;\n expr[l]=c;\n scanf(\"%c\",&c);\n }\n ans=gettype(1,l);\n if (ans>=3) printf(\"yes\\n\"); else printf(\"no\\n\");\n //system(\"pause\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4697e9dfa78575dc8ae902425a8c25f5", "src_uid": "e060d26dc3b9ffb628f2380781d1cbe9", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\nusing namespace std ;\nconst int maxn=1000000+15 ;\nconst ll mod=1e9+7 ;\ntypedef long long ll ;\nll ans ;\nll dp[maxn],inv[maxn],sum[maxn] ;\nll f[maxn] ;\nll N,K ;\ninline ll ksm(ll a,ll b){\n\tll ans=1 ;\n\twhile(b){\n\t\tif(b&1) ans=(ans*a)%mod ;\n\t\ta=(a*a)%mod ;\n\t\tb>>=1 ;\n\t}\n\treturn ans ;\n}\nint main(){\n\tscanf(\"%lld%lld\",&N,&K) ;\n\tf[0]=1 ;\n\tfor(ll i=1;i<=N;i++) f[i]=(f[i-1]*i)%mod ;\n\tfor(ll i=1;i<=N;i++) inv[i]=ksm(f[i],mod-2) ;\n\tfor(ll i=K+2;i<=N;i++){\n\t\tdp[i]=(((ll)(i-K-1)*(f[i-2])%mod+(sum[i-1]-sum[i-K-1])*(f[i-2])%mod))%mod ;\n\t\tsum[i]=(sum[i-1]+(1ll*dp[i]*inv[i-1])%mod)%mod ;\n\t}\n\tfor(int i=1;i<=N;i++) ans=(ans+(1ll*dp[i]*f[N-1]%mod)*(inv[i-1]))%mod ;\n\tprintf(\"%lld\\n\",ans) ;\n\treturn 0 ;\t\n} \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e02003d2c8cff2466f156e7cdcfd06ac", "src_uid": "0644605611a2cd10ab3a9f12f18d7ae4", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include\n#define maxn 50004\n#define LL __int128\nusing namespace std;\n \nint n;\nint ft[maxn];\nint fa[maxn],ch[maxn][2];\nLL sz[maxn],sx[maxn],sx2[maxn],a[maxn],ans[maxn],sr[maxn],xans[maxn];\nLL sqr(LL a){ return a * a; }\n#define pa fa[x]\nint inr(int x){ return ch[pa][1] == x; }\nint isr(int x){ return ch[pa][0] != x && ch[pa][1] != x; }\nvoid upd(int u){\n\tif(!u) return;\n\tint lc = ch[u][0] , rc = ch[u][1];\n\tsz[u] = sz[lc] + sz[rc] + sx[u];\n\tsr[u] = sr[lc] + sr[rc] + a[u] * sx[u];\n\tans[u] = ans[lc] + ans[rc] + xans[u] \n\t\t+ a[u] * (sqr(sx[u]) - sx2[u])\n\t\t+ 2 * a[u] * sx[u] * sz[rc] \n\t\t+ 2 * sr[lc] * (sz[u] - sz[lc]);\n}\nvoid rot(int x){\n\tint y = fa[x] , z = fa[y] , c = inr(x);\n\tif(!isr(y)) ch[z][inr(y)] = x;\n\t(ch[y][c] = ch[x][!c]) && (fa[ch[y][c]] = y);\n\tfa[fa[ch[x][!c] = y]=x]=z;\n\tupd(y);\n}\nvoid splay(int x){\n\tfor(;!isr(x);rot(x))\n\t\tif(!isr(pa))\n\t\t\trot(inr(pa) ^ inr(x) ? x : pa);\n\tupd(x);\n}\nint access(int x){\n\tint y=0;\n\tfor(;x;x=fa[y=x]){\n\t\tsplay(x);\n\t\tsx[x] += sz[ch[x][1]];\n\t\tsx2[x] += sqr(sz[ch[x][1]]);\n\t\txans[x] += ans[ch[x][1]];\n\t\t\n\t\tch[x][1] = y;\n\t\tsx[x] -= sz[y];\n\t\tsx2[x] -= sqr(sz[y]);\n\t\txans[x] -= ans[y];\n\t\tupd(x);\n\t}\n\treturn y;\n}\n \nint main(){\n\tios :: sync_with_stdio(0);\n\tcin >> n;\n\tfor(int i=2;i<=n;i++){\n\t\tcin >> ft[i];\n\t\tfa[i] = ft[i];\n\t}\n\tfor(int i=1;i<=n;i++){\n\t\taccess(i),splay(i);\n\t\tint x;\n\t\tcin >> x;\n\t\ta[i] = x;\n\t\tsx[i] = 1;\n\t\tupd(i);\n\t}\n\tsplay(1);\n\tprintf(\"%.10lf\\n\",ans[1] * 1.0 / n / n);\n\tint m;cin >> m;\n\tstring s;\n\tfor(int u,v;m--;){\n\t\tcin >> s >> u >> v;\n\t\tif(s[0] == 'P'){\n\t\t\taccess(u);int lca = access(v);\n\t\t\tif(lca == u) swap(u,v);\n\t\t\tint p = ft[u];\n\t\t\taccess(p),splay(p);\n\t\t\tsplay(u);\n\t\t\t\n\t\t\tsx[p] -= sz[u];\n\t\t\tsx2[p] -= sqr(sz[u]);\n\t\t\txans[p] -= ans[u];\n\t\t\tupd(p);\n\t\t\t\n\t\t\taccess(v),splay(v);\n\t\t\tsx[v] += sz[u];\n\t\t\tsx2[v] += sqr(sz[u]);\n\t\t\txans[v] += ans[u];\n\t\t\t\n\t\t\tft[u] = fa[u] = v;\n\t\t\tupd(v);\n\t\t}\n\t\telse{\n\t\t\taccess(u),splay(u);\n\t\t\ta[u] = v;\n\t\t\tupd(u);\n\t\t}\n\t\tsplay(1);\n\tprintf(\"%.10lf\\n\",ans[1] * 1.0 / n / n);\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "35cdaf21aa311630c64f94ef37cd9c28", "src_uid": "013df41c0042f752a995bdcf16b28c7e", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\n#define int long long \n\nvoid read(int &x) {\n x=0;int f=1;char ch=getchar();\n for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;\n for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;\n}\n\nvoid print(int x) {\n if(x<0) putchar('-'),x=-x;\n if(!x) return ;print(x/10),putchar(x%10+48);\n}\nvoid write(int x) {if(!x) putchar('0');else print(x);putchar('\\n');}\n\n#define lf double\n\n#define pii pair\n#define vec vector\n\n#define pb push_back\n#define mp make_pair\n#define fr first\n#define sc second\n\n#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)\n\nconst int maxn = 1e6+10;\nconst int inf = 1e9;\nconst lf eps = 1e-8;\nconst int mod = 1e9+7;\n\nint pri[maxn],phi[maxn],vis[maxn],tot;\n\nvoid sieve() {\n phi[1]=1;\n for(int i=2;i\nusing namespace std;\nconst int N = 5e4+8;\n#define eps 1e-4\nconst double pi = acos(-1.0);\nconst double inf = 1e6;\nint cnt;\nint segcnt = 0;\ndouble curang;\nstruct Point{\n double x,y;\n double corss(Point b)const{\n return x * b.y - b.x * y;\n }\n Point operator - (const Point& b)const{\n return (Point){x-b.x,y-b.y};\n }\n double len(){return sqrt(x*x+y*y);}\n};\nPoint segcross(Point a,Point b,Point c,Point d,bool& ok){\n double u = (b-a).corss(c-a) , v = (a-b).corss(d-b);\n if( fabs(u+v) < eps){\n ok = 0;\n Point tem = {-1,-1};\n return tem;\n }\n ok = 1;\n return (Point){ (c.x*v + d.x*u)/(u+v) , (c.y*v + d.y*u)/(u+v) };\n}\nstruct Seg{\n Point a,b;\n int id;\n bool operator < (const Seg& s)const{\n bool ok1 ,ok2;\n Point c = (Point){inf*cos(curang) , inf * sin(curang)};\n Point o = (Point){0,0};\n Point cr1 = segcross(a,b,o,c,ok1);\n Point cr2 = segcross(s.a,s.b,o,c,ok2);\n assert(ok1 && ok2);\n if( fabs( cr1.len() - cr2.len() ) < eps ) return id < s.id;\n return cr1.len() < cr2.len();\n }\n};\nvector pol[N];\ndouble ang[N];\nvector add[N],del[N];\nSeg seg[N];\n\nvoid add_seg(Point a,Point b){\n double anga = atan2(a.y,a.x) , angb = atan2(b.y,b.x);\n if( fabs(anga - angb) < eps ) return;\n if( anga > angb + eps ){\n swap(anga,angb);\n swap(a,b);\n }\n int pa = lower_bound(ang+1,ang+1+cnt,anga) - ang;\n int pb = lower_bound(ang+1,ang+1+cnt,angb) - ang;\n\n ++segcnt;\n seg[segcnt] = (Seg){a,b,segcnt};\n if( angb - anga > pi + eps ){\n // Point c = segcross(a,b,(Point){-inf,0},(Point){inf,0});\n if( fabs(anga + pi) > eps){\n // ++segcnt;\n // seg[segcnt] = (Seg){c,a,segcnt};\n add[1].push_back(segcnt);\n del[pa].push_back(segcnt);\n }\n\n if( fabs( angb - pi ) > eps){\n // ++segcnt;\n // seg[segcnt] = (Seg){b,c,segcnt};\n add[pb].push_back(segcnt);\n del[cnt].push_back(segcnt);\n }\n }\n else{\n add[pa].push_back(segcnt);\n del[pb].push_back(segcnt);\n }\n}\ndouble area(Point a,Point b,Point c,Point d){\n double res = 0;\n res += (b-a).corss(c-a);\n res += (c-a).corss(d-a);\n if(res < -eps ) res = -res;\n return res * 0.5;\n}\nvoid solve(){\n set st;\n double ans = 0;\n curang = 0;\n for(int i = 1;i=2){\n Seg s1,s2;\n auto it = st.begin(); s1 = (*it);\n ++it; s2 = (*it);\n Point c1 = (Point){inf*cos(ang[i]) , inf * sin(ang[i])};\n Point c2 = (Point){inf*cos(ang[i+1]) , inf * sin(ang[i+1])};\n Point o = (Point){0,0};\n Point a1 = segcross(o,c1,s1.a,s1.b);\n Point a2 = segcross(o,c1,s2.a,s2.b);\n Point a3 = segcross(o,c2,s2.a,s2.b);\n Point a4 = segcross(o,c2,s1.a,s1.b);\n ans += area(a1,a2,a3,a4);\n }\n }\n printf(\"%.12f\",ans);\n}\nint main(){\n int n; scanf(\"%d\",&n);\n for(int i = 1;i<=n;++i){\n int m; scanf(\"%d\",&m);\n Point tem;\n for(int j = 1;j<=m;++j){\n scanf(\"%lf %lf\",&tem.x,&tem.y);\n pol[i].push_back(tem);\n ang[++cnt] = atan2(tem.y,tem.x);\n }\n pol[i].push_back(pol[i][0]);\n }\n ang[++cnt] = -pi; ang[++cnt] = pi;\n sort(ang+1,ang+1+cnt);\n cnt = unique(ang+1,ang+1+cnt) - ang - 1;\n\n for(int i = 1;i<=n;++i){\n for(int k = 0;k\n#include \n#include \n#include \nusing namespace std;\n\n#define MAX_N 200000\n\nint n;\nint numbers[MAX_N];\nint exists[MAX_N + 1];\n\nstruct Node {\n int l, r, sum;\n Node *left, *right;\n int first, last;\n};\n\ndeque nodes;\n\nNode *root;\n\nNode* newNode() {\n nodes.emplace_back();\n return &nodes.back();\n}\n\nNode* fillNode(int first, int last) {\n if (first >= last) {\n return nullptr;\n }\n int mid = (first + (last - first) / 2);\n Node * result = newNode();\n result->first = first;\n result->last = last;\n result->l = first;\n result->r = last - 1;\n result->left = fillNode(l, mid);\n result->right = fillNode(mid + 1, r);\n result->sum = 0;\n if (!result->left && !result->right) {\n result->sum = l;\n } else {\n if (result->left) {\n result->sum += result->left->sum;\n }\n if (result->right) {\n result->sum += result->right->sum;\n }\n }\n return result;\n}\n\nvoid fixup(Node * node, Node * parent) {\n if (node->r < parent->l) {\n node->sum = (node->last - node->first) * parent->l;\n node->l = node->r = parent->l;\n }\n}\n\nint update(Node *node, int first, int last, int size, Node * parent) {\n if (first >= node->last || last <= node->first) return 0;\n if (parent)\n fixup(node, parent);\n if (node->l >= size) return 0;\n\n if (first <= node->first) {\n node->l = size;\n }\n if (node->last <= last) {\n node->r = max(node->r, size);\n }\n \n if (first <= node->first && node->last <= last && node->r <= size) {\n int new_sum = (node->last - node->first) * size;\n int result = new_sum - node->sum;\n node->sum = new_sum;\n return result;\n }\n \n int sum_from_child = 0;\n if (node->left) {\n sum_from_child += update(node->left, first, last, size, node);\n }\n if (node->right) {\n sum_from_child += update(node->right, first, last, size, node);\n }\n \n node->sum += sum_from_child;\n return sum_from_child;\n}\n\nint set_from(int first, int last) {\n if (first >= last) return 0;\n int barSize = last;\n int barIdx = first;\n return update(root, barIdx, n, barSize, nullptr);\n}\n\nint main() {\n std::ios_base::sync_with_stdio(false);\n cin >> n;\n root = fillNode(0, n);\n fill(begin(exists), end(exists), -1);\n for (int i = 0; i < n; ++i) {\n cin >> numbers[i];\n exists[numbers[i]] = i;\n }\n \n int64_t result = 0;\n for (int gcd = MAX_N; gcd >= 1; --gcd) {\n std::vector idxs;\n for (int i = gcd; i <= MAX_N; i += gcd) {\n if (exists[i] >= 0)\n idxs.push_back(exists[i]);\n }\n if (idxs.size() < 2) continue;\n nth_element(begin(idxs), begin(idxs) + 2, end(idxs));\n int x1 = idxs[0];\n int x2 = idxs[1];\n nth_element(begin(idxs), begin(idxs) + idxs.size() - 2, end(idxs));\n int x3 = idxs[idxs.size() - 2];\n int x4 = idxs[idxs.size() - 1];\n \n result += gcd * set_from(0, x3);\n result += gcd * set_from(x2, idxs.size());\n result += gcd * set_from(x1 + 1, x4);\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2e45254cbb221edc6bc7c09a9bc53553", "src_uid": "deb3938a6d3f13c4ab8a0765bf0e94b0", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nchar A[200004];\nchar B[200004];\nint n,m;\nbool check(int l,int r)\n{\n int j=0;\n for(int i=0;i\n#define REP(i,n) for (long long i = 1; i <= n; i++)\nusing namespace std;\n\nlong long K;\ntypedef long long ll;\ntypedef vector > matrix;\nconst long long MOD = 2000000001;\nlong long no=MOD;\nlong long n;\nmatrix mul(matrix A, matrix B)\n{\n K=2*n;\n matrix C(K+1, vector(K+1));\n\n for (long long i=0;i<=K;i++)\n for (long long j=0;j<=K;j++)\n C[i][j]=MOD;\n\n for (long long k=0;k<=K;k++)\n {\n for (long long i=0;i<=K;i++)\n {\n for (long long j=0;j<=K;j++)\n {\n C[i][j] = min(C[i][j] , A[i][k] + B[k][j]);\n }\n }\n }\n return C;\n}\n\n// computes A ^ p\nmatrix pow(matrix A, long long p)\n{\n if (p == 1)\n return A;\n if (p % 2)\n return mul(A, pow(A, p-1));\n matrix X = pow(A, p/2);\n return mul(X, X);\n}\nlong long down[30][30];\nlong long m;\nlong long up[30][30];\nlong long a[1000];\nlong long b[1000];\nlong long nope[1001]=MOD;\nvoid calc_cost(long long x)\n{\n long long mn=0,c=0;\n long long cost=0;\n for (long long i=0;i F1(K+1);\n matrix T(K+1, vector(K+1));\n for (long long i=0;i<=K;i++)\n {\n for (long long j=0;j<=K;j++)\n {\n T[i][j]=no;\n if (abs(i-j)>n)continue;\n if (i==j)\n for (long long x=i;x>=0;x--)\n T[i][j]=min(T[i][j],nope[x]);\n else if (i=0;x--)\n T[i][j]=min(T[i][j],up[x][(j-i)]);\n }\n else\n {\n for (long long x=i;x>=0;x--)\n T[i][j]=min(T[i][j],down[x][(i-j)]);\n }\n }\n }\n\n T = pow(T, m);\n\n return T[0][0];\n}\nint main()\n{\n cin>>n>>m;\n for (long long i=0;i>a[i];\n for (long long i=0;i>b[i];\n for (long long i=0;i<=20;i++)\n for (long long j=0;j<=20;j++)\n up[i][j]=down[i][j]=no;\n for (int i=0;i<=20;i++)\n nope[i]=MOD;\n for (long long i=0;i<(1<\n#include\n#include\nusing namespace std;\nstruct point{\n int x, y;\n bool operator <(const point &p)const{\n return x!=p.x?x0?1:t<0?-1:0;\n}\nint Pos[260][260], K;\nlong long res;\nlong long D[260][260][60], Area[260][260], R[260];\nlong long Calc(point2 a, point2 b){\n long long t = 1ll*a.x*b.y - 1ll*a.y*b.x;\n if(t<0)t=-t;\n return t;\n}\nint chk1[260], chk2[260];\nvoid UDT(int x, int y){\n int i;\n for(i=1;i<=K;i++){\n R[i] = max(R[i], D[x][y][i]);\n }\n}\nvoid Do(int n){\n if(n+1 0)pv = j, Pos[i][j] = 1;\n else Pos[i][j] = 0;\n Area[i][j] = Calc(w[i],w[j]);\n }*/\n for(j=i+1;j<=n;j++){\n Area[i][j] = Calc(w[i],w[j]);\n Pos[i][j]=1;\n for(k=i+1;k 0)break;\n UDT(pp,i);\n chk2[pp] = 1;\n }\n for(j=1;jT1, T2;\n T1.push_back(0);\n for(j=1;j0){\n for(int ii=2;ii 0)res = max(res, D[i][j][K]);\n }\n }\n}\nint main(){\n int n;\n int i, j;\n scanf(\"%d%d\",&n,&K);\n for(i=1;i<=n;i++){\n scanf(\"%d%d\",&P[i].x,&P[i].y);\n }\n sort(P+1,P+n+1);\n for(i=1;i<=n;i++){\n for(j=i;j<=n;j++){\n w[j-i] = {P[j].x-P[i].x, P[j].y-P[i].y};\n }\n Do(n-i);\n }\n printf(\"%lld.%02d\",res/2,res%2*50);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f412392f9e9cdb164955154de45711f7", "src_uid": "6afcdad100c8e2469fef5abcc5bd96c6", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define D double\n#define PB push_back\n#define F first\n#define S second\n#define MP make_pair\nusing namespace std;\ntypedef long long ll;\ntypedef pair PII;\ntypedef vector< vector > VV;\nconst int MOD = 12345;\n\nvector v[40],help;\nvector< vector > A;\nvector kmm;\nint M = 1,esh[30];\n\nint asl_code(vector &a){\n\tint ans = 0;\n\tfor(int i = a.size()-1;i >= 0;i--){\n\t\tans *= kmm[i];\n\t\tans += a[i];\n\t}\n\treturn ans;\n}\nvector code_asl(int x){\n\tvector ans;\n\tfor(int i = 0; i < (int)kmm.size(); i++){\n\t\tans.PB(x % kmm[i]);\n\t\tx /= kmm[i];\n\t}\n\treturn ans;\n}\n\nVV MUL(VV &x, VV &y){\n\tVV ans(M);\n\tfor (int i = 0; i < M; i++)\n\t\tans[i].resize(M);\n\tfor(int i = 0;i < M; i++)\n\t\tfor(int j = 0;j < M; j++)\n\t\t\tfor(int k = 0;k < M;k++)\n\t\t\t\tans[i][j] = (ans[i][j] + x[i][k]*y[k][j]) % MOD;\n\treturn ans;\n}\n\nVV PW(long long w){ // w != 0\n\tif(w == 1)\n\t\treturn A;\n\tVV tmp = PW(w/2);\n\tif(w % 2 == 0)\n\t\treturn MUL( tmp, tmp);\n\treturn MUL(MUL(tmp,tmp),A);\n}\n\nint main(){\n\tios::sync_with_stdio(false);\n\tlong long n,m;cin >> n >> m;\n\tfor(int i = 0;i < m;i++){\n\t\tchar c;int x;cin >> c >> x;\n\t\tv[c-'A'].PB(x);\n\t}\n\tif(n == 0){\n\t\tcout << 1 < q = code_asl(i);\n\t\tfor(int j = 0;j < (int)q.size();j++){\n\t\t\tq[j] = (q[j]-1+kmm[j])%kmm[j];\n\t\t\tint carr = asl_code(q);\n\t\t\tA[carr][i] = 1;\n\t\t\tq[j] = (q[j]+1)%kmm[j];\n\t\t}\n\t}\n\tVV qq = PW(n);\n\tlong long res = 0;\n\tfor(int i = 0;i < M;i++){\n\t\tvector r = code_asl(i);\n\t\tbool ok = true;\n\t\tfor(int j = 0;j < (int)r.size(); j++){\n\t\t\tbool help = false;\n\t\t\tfor(int k = 0;k < (int)v[ esh[j] ].size();k++)\n\t\t\t\tif(r[j] % v[esh[j]][k] == 0)\n\t\t\t\t\thelp = true;\n\t\t\tif(!help){\n\t\t\t\tok = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(!ok)\n\t\t\tcontinue;\n\t\tres = (res+qq[i][0])%MOD;\n\t}\n\tcout << res <\n\nusing namespace std;\n\nint main()\n{\n int k;\n cin>>k;\n int arr[10];\n for(int i=0;i<10;i++)\n {\n arr[i]=0;\n }\n for(int i=0;i<4;i++)\n {\n for(int j=0;j<4;j++)\n {\n int a;\n cin>>a;\n int r=a-48;\n arr[r]++;\n }\n }\n int res=0;\n for(int i=0;<10;i++)\n {\n res=max(res,arr[i]);\n }\n if(res>2*k)\n cout<<\"NO\"<\n#include \n#include \n#include \n#define sz(a) int((a).size())\n#define pb push_back\n#define rep(i,j,k) for (int i=j; i<=k; i++)\n#define online1\n#define sqr(x) (x)*(x)\nusing namespace std;\ntypedef long long LL;\n\n#ifdef online\nconst int maxn=100;\n#else\nconst int maxn=1000;\n#endif\n\nconst double eps=1e-15;\n\nint n,m;\n\nint sign(double x){\n if (x<-eps) return -1; return x>eps;\n}\n\nstruct point_3d{\n double x,y,z;\n point_3d(double _x,double _y,double _z):x(_x),y(_y),z(_z){\n }\n point_3d(){\n }\n point_3d operator+(point_3d &a){\n return point_3d(a.x+x, a.y+y, a.z+z);\n }\n point_3d operator-(point_3d &a){\n return point_3d(x-a.x, y-a.y, z-a.z);\n }\n point_3d operator/(double f){\n return point_3d(x/f, y/f, z/f);\n }\n double len(){\n return sqrt(x*x+y*y+z*z); \n }\n};\n\ndouble dis(point_3d &a, point_3d &b){\n return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y)+sqr(a.z-b.z)); \n}\n\npoint_3d project(double A,double B,double C,double x1,double y1,double z1){\n double lambda=(A*x1+B*y1+C*z1)/(A*A+B*B+C*C);\n return point_3d(x1-lambda*A,y1-lambda*B,z1-lambda*C);\n}\n\nvoid calc2(double a,double b,double c,double d,double e,double f,double &x,double &y){\n if (sign(a)==0) {calc2(d,e,f,a,b,c,x,y); return;}\n e+=(-b/a*d); f+=(c/a*d);\n y=-f/e;\n x=(-b*y+c)/a; \n}\n\npoint_3d cir_cen(point_3d &a, point_3d& b, point_3d& c, double A3, double B3, double C3){\n double x,y,z,A1,B1,C1,D1,A2,B2,C2,D2,D3=0;\n \n A1=-2*a.x+2*b.x;\n B1=-2*a.y+2*b.y;\n C1=-2*a.z+2*b.z;\n D1=-(b.x*b.x+b.y*b.y+b.z*b.z-a.x*a.x-a.y*a.y-a.z*a.z);\n \n A2=-2*c.x+2*b.x;\n B2=-2*c.y+2*b.y;\n C2=-2*c.z+2*b.z;\n D2=-(b.x*b.x+b.y*b.y+b.z*b.z-c.x*c.x-c.y*c.y-c.z*c.z);\n \n if (sign(A2)!=0) swap(A2,A1),swap(B2,B1),swap(C2,C1);\n if (sign(A3)!=0) swap(A3,A1),swap(B3,B1),swap(C3,C1);\n \n B2+=(-B1/A1*A2); C2+=(-C1/A1*A2); D2+=(+D1/A1*A2);\n B3+=(-B1/A1*A3); C3+=(-C1/A1*A3); D3+=(+D1/A1*A3);\n \n calc2(B2,C2,D2,B3,C3,D3,y,z);\n \n return point_3d((-B1*y-C1*z+D1)/A1,y,z); \n}\n\npoint_3d p[maxn],a[maxn],o;\ndouble r;\n\nint main(){ \n scanf(\"%d%d\",&n,&m);\n rep(i,1,n) scanf(\"%lf%lf%lf\",&p[i].x,&p[i].y,&p[i].z);\n \n rep(mm,1,m){\n double A,B,C;\n scanf(\"%lf%lf%lf\",&A,&B,&C); \n \n rep(i,1,n) a[i]=project(A,B,C,p[i].x,p[i].y,p[i].z);\n \n random_shuffle(a+1,a+n+1);\n o=point_3d(0.00,0.00,0.00); r=0;\n rep(i,1,n)\n if ( sign( dis(o,a[i])-r )==1 ){\n o=a[i]; r=0;\n rep(j,1,i-1)\n if ( sign( dis(o,a[j])-r )==1 ){\n o=(a[i]+a[j])/2; r=(o-a[i]).len(); \n rep(k,1,j-1)\n if ( sign( dis(o,a[k])-r )==1 ){\n o=cir_cen(a[i],a[j],a[k],A,B,C); r=(o-a[i]).len();\n }\n }\n } \n \n printf(\"%.9lf\\n\",r);\n } \n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "89ad4a624a3a45f93a46cc4528d6dd06", "src_uid": "25b2a84f0c3f574cdffd59a902b2326e", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#define N 100009\n#define EPS 10e-12\nusing namespace std;\nint n,m,h;\nint w[N],v[N],od[N];\nint ans[N];\nbool cmp(const int &a,const int &b){\n if(w[a]==w[b]) return v[a]1.0*one*h-EPS){\n ans[cnt++]=od[i];\n }\n if(cnt>m) return true;\n else return false;\n}\nint main(){\n //freopen(\"in\",\"r\",stdin);\n scanf(\"%d%d%d\",&n,&m,&h);\n for(int i=1;i<=n;i++)\n od[i]=i,scanf(\"%d\",w+i);\n for(int i=1;i<=n;i++)\n scanf(\"%d\",v+i);\n sort(od+1,od+n+1,cmp);\n long double s=0,e=10e10+9,mid;\n for(int i=1;i<=200;i++){\n mid=(s+e)/2;\n if(isok(mid)) e=mid;\n else s=mid;\n }\n //printf(\"%lf\\n\",res);\n printf(\"%d\",ans[1]);\n for(int i=2;i<=m;i++) printf(\" %d\",ans[i]);\n puts(\"\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c172fed701d2d680525646201c4f52a7", "src_uid": "6861128fcd83c752b0ea0286869901c2", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define ll long long\nint main()\n{\n\tstring s;cin>>s;\n\tint ok=1;\n\tfor(int i=0,j=s.size()-1;i<=j;i++,j--)\n\t{\n\t\tif(s[i]==1||s[j]==1)ok=0;\n\t\tif(s[i]==2||s[j]==2)ok=0;\n\t\tif(s[i]==3&&s[j]!=3)ok=0;\n\t\tif(s[i]!=3&&s[j]==3)ok=0;\n\t\tif(s[i]==4&&s[j]!=6)ok=0;\n\t\tif(s[i]!=4&&s[j]==6)ok=0;\n\t\tif(s[i]==6&&s[j]!=4)ok=0;\n\t\tif(s[i]!=6&&s[j]==4)ok=0;\n\t\tif(s[i]==5&&s[j]!=9)ok=0;\n\t\tif(s[i]!=5&&s[j]==9)ok=0;\n\t\tif(s[i]==9&&s[j]!=5)ok=0;\n\t\tif(s[i]!=9&&s[j]==5)ok=0;\n\t\tif(s[i]==7&&s[j]!=7)ok=0;\n\t\tif(s[i]!=7&&s[j]==7)ok=0;\n\t\tif(s[i]==8&&s[j]!=0)ok=0;\n\t\tif(s[i]!=8&&s[j]==0)ok=0;\n\t\tif(s[i]==0&&s[j]!=8)ok=0;\n\t\tif(s[i]!=0&&s[j]==8)ok=0;\n\t}\n\tputs(ok1&&ok2?\"Yes\":\"No\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "29cb33bf364eb850adb9ad925271b008", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef __int64 LL;\nLL a[1100000],x,y,P,D,sum;\nint i,n;\nint main()\n{\n\tscanf(\"%d%I64d%I64d%I64d\",&n,&x,&y,&P);\n\tsum=0;\n\tfor(i=0;i0)\n\t{\n\t\tif(x%2==1)BS=(BS*te)%P;\n\t\tte=(te*te)%P;\n\t\tx/=2;\n\t}\n\tLL S=(((sum-D)*BS+D+2*P)%(2*P))/2;\n//\tcout<0)\n\t{\n\t\tif(y%2==1)BS=(BS*te)%P;\n\t\tte=(te*te)%P;\n\t\ty/=2;\n\t}\n\tS=(((S-D)*BS+D+2*P)%(2*P))/2;\n\tcout<\n#ifndef WIN32\n#define Auto \"%lld\"\n#else\n#define Auto \"%I64d\"\n#endif\nusing namespace std;\ntypedef bool boolean;\n\n#define ll long long\n\nconst int N = 205;\n\nint n, t, k;\nll sa[N], sb[N];\nll a[N], b[N], c[N];\nll d[N][N][2], g[N][N][2];\n\nint main() {\n\tscanf(\"%d%d%d\", &n, &t, &k);\n\tfor (int i = 1; i <= n; i++) {\n\t\tscanf(Auto\"\"Auto\"\"Auto, a + i, b + i, c + i);\n\t}\n\t++n;\n\ta[n] = 2e18, b[n] = 0, c[n] = 2e18;\n\tfor (int i = 1; i <= n; i++) {\n\t\tsa[i] = sa[i - 1] + a[i];\n\t\tsb[i] = sb[i - 1] + b[i];\n\t}\n\tfor (int p = 1; p <= n; p++) {\n\t\tfor (int s = 0; s <= t; s++) {\n\t\t\tfor (int z = 0; z < 2; z++) {\n\t\t\t\td[p][s][z] = g[p][s][z] = 2e18;\n\t\t\t\tif (d[p - 1][s][z] < 2e18 && a[p] * z + b[p] * s <= c[p]) {\n\t\t\t\t\td[p][s][z] = d[p - 1][s][z];\n\t\t\t\t\tll d = (sa[p - 1] * z + sb[p - 1] * s + k - 1) / k;\n\t\t\t\t\tif (d * k <= sa[p] * z + sb[p] * s) {\n\t\t\t\t\t\tg[p][s][z] = d;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int r = 0; r < s; r++) {\n\t\t\t\t\tif (g[p][r][z] < 2e18) {\n\t\t\t\t\t\tll m = sa[p] * z + sb[p] * r - g[p][r][z] * k;\n\t\t\t\t\t\tll x = (max(m + (s - r) * b[p] - c[p], 0ll) + k - 1) / k;\n\t\t\t\t\t\tm -= x * k;\n\t\t\t\t\t\tif (d[p - 1][s - r][0] < 2e18 && m >= 0) {\n\t\t\t\t\t\t\td[p][s][z] = min(d[p][s][z], g[p][r][z] + x + d[p - 1][s - r][0]);\n\t\t\t\t\t\t\tll d = (sb[p - 1] * (s - r) + k - 1) / k;\n\t\t\t\t\t\t\tif (d * k <= m + (s - r) * sb[p]) {\n\t\t\t\t\t\t\t\tg[p][s][z] = min(g[p][s][z], g[p][r][z] + x + d);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcerr << p << \" \" << s << \" \" << z << \" \" << d[p][s][z] << \" \" << g[p][s][z] << '\\n';\n\t\t\t}\n\t\t}\n\t}\n\tcout << d[n][t][1] << '\\n';\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0675bac559fa614aef5ada51bbfaae9a", "src_uid": "feee94b7e802fc8e3758350f551b7142", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \n#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\ntypedef long long ll;\ntypedef long double ld;\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n#define mod 1000000007\n#define pii pair\n#define inf 1000000000000000000\n#define bpc(x) __builtin_popcountll(x)\n#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)\n#define rep(n) for(ll i = 0; i < n; i++)\n#define repi(i,n) for(ll i = 0; i < n; i++)\n\n#include \n#include \nusing namespace __gnu_pbds; \n\n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update> \n\nusing namespace std;\nmt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());\n\nll nc2(ll n)\n{\n ll ans = (n*(n-1))/2;\n return ans;\n}\n\nll powa(ll a, ll b, ll c)\n{\n a%=c;\n if(a<0)\n\ta+=c;\n ll res = 1;\n while(b>0)\n {\n if(b&1)\n res*=a, res%=c;\n a*=a, a%=c;\n b>>=1;\n }\n return res;\n}\n\nll norm(ll a)\n{\n a%=mod;\n if(a<0)\n a+=mod;\n return a; \n}\n\nll add(ll a, ll b)\n{\n a = norm(a);\n b = norm(b);\n return norm(a+b);\n}\n\nll mul(ll a, ll b)\n{\n a = norm(a);\n b = norm(b);\n return norm(a*b);\n}\n\nll div(ll a, ll b)\n{\n a = norm(a);\n b = powa(norm(b),mod-2,mod);\n return mul(a,b);\n}\n\nll sub(ll a, ll b)\n{\n a = norm(a);\n b = norm(b);\n return norm(a-b);\n}\n\n#define N 101\n\nvoid mul(ll res[N][N], ll m1[N][N], ll m2[N][N])\n{\n ll temp[N][N];\n memset(temp,0,sizeof(temp));\n for(ll i=0;i0)\n {\n if(n%2 == 1)\n mul(res,res,mat);\n \n n>>=1;\n mul(mat,mat,mat);\n }\n \n for(ll i=0;i>n>>k;\n \n ll arr[n];\n rep(n)\n cin>>arr[i];\n ll p = 0;\n rep(n)\n if(arr[i] == 0)\n p++;\n if(p == 0 || p == n)\n {\n cout<<1;\n return 0;\n }\n \n ll mat[N][N];\n memset(mat,0,sizeof(mat));\n \n ll den = powa((n*(n-1))/2,mod-2,mod);\n \n for(ll i=0;i<=p;i++)\n {\n if(i-1>-1)\n mat[i-1][i] = mul(i*i,den);\n mat[i][i] = mul(norm(nc2(p) + nc2(n-p) + i*(n-p-i) + i*(p-i)),den);\n if(i\nusing namespace std;\nconst int N = 1100;\n\nstruct PT{\n\tint x, y, c, id;\n} p[N];\n\nint vect(PT p, PT p1, PT p2) {\n\treturn (p1.x - p.x) * (p2.y - p.y) - (p2.x - p.x) * (p1.y - p.y);\n}\n\nvector convex_Hull(vector ps) {\n\tif (ps.size() <= 1) return ps;\n\tint n = ps.size(), k = 0;\n\tvector ch(2 * n);\n\tfor (int i = 0; i < n; ch[k++] = ps[i++]) {\n\t\twhile (k >= 2 && vect(p[ch[k-2]], p[ch[k-1]], p[ps[i]]) <= 0) --k;\n\t}\n\tfor (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) {\n\t\twhile (k >= t && vect(p[ch[k-2]], p[ch[k-1]], p[ps[i]]) <= 0) --k;\n\t}\n\tch.resize(k - 1);\n\treturn ch;\n}\n\nbool valid(vector ps) {\n\tvector convex = convex_Hull(ps);\n\tint m = convex.size();\n\tconvex.push_back(convex[0]);\n\tint changes = 0;\n\tint cnt[2] = {0};\n\tfor (int i = 0; i < m; i++) {\n\t\tif (p[convex[i]].c != p[convex[i+1]].c) {\n\t\t\tchanges++;\n\t\t}\n\t}\n\treturn changes <= 2;\n}\n\nbool select[N];\n\nint main() {\n#ifndef ONLINE_JUDGE\n\tfreopen(\"in.txt\", \"r\", stdin);\n\tfreopen(\"out.txt\", \"w\", stdout);\n#endif\n\tios::sync_with_stdio(0);\n\tint n; cin >> n;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> p[i].x >> p[i].y >> p[i].c;\n \t\tp[i].id = i;\n\t}\n\tsort(p, p + n, [](PT a, PT b) { return make_pair(a.x, a.y) < make_pair(b.x, b.y); });\n\tvector ans;\n\tfor (int i = 0; i < n; i++) {\n\t\tselect[i] = 1;\n\t}\n\tint flg = 0;\n\twhile (1) {\n\t\tvector tmp;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (select[i]) tmp.push_back(i);\n\t\t}\n\t\tvector convex = convex_Hull(tmp);\n\t\tint m = convex.size();\n\t\tconvex.push_back(convex[0]);\n\t\tint changes = 0;\n\t\tvector CHS;\n\t\tint cnt[2] = {0};\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tcnt[p[convex[i]].c]++;\n\t\t\tif (p[convex[i]].c != p[convex[i+1]].c) {\n\t\t\t\tchanges++;\n\t\t\t}\n\t\t}\n\t\tif (cnt[0] <= 1 && cnt[1] <= 1) break;\n\t\tif (changes > 2) {\n\t\t\tflg = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif (!changes) {\n\t\t\tans.push_back(convex[0]);\n\t\t\tans.push_back(convex[1]);\n\t\t\tselect[convex[0]] = 0;\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tint which = 0;\n\t\t\tif (cnt[0] <= 1) which = 1;\n\t\t\tint fff = 0;\n\t\t\tfor (int i = 0; i < m; i++) {\n\t\t\t\tif (p[convex[i]].c == which && p[convex[i+1]].c != p[convex[(i-1+m)%m]].c) {\n\t\t\t\t\tselect[convex[i]] = 0;\n\t\t\t\t\tvector vvv;\n\t\t\t\t\tfor(int l = 0; l < n; l++) if (select[l])\n\t\t\t\t\t{\n\t\t\t\t\t\tvvv.push_back(l);\n\t\t\t\t\t}\n\t\t\t\t\tif (!valid(vvv))\n\t\t\t\t\t{\t\n\t\t\t\t\t\tselect[convex[i]].c = 1;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tint j = (i+1)%m;\n\t\t\t\t\tif (p[convex[j]].c != which) j = (i-1+m)%m;\n\t\t\t\t\tans.push_back(convex[i]);\n\t\t\t\t\tans.push_back(convex[j]);\n\t\t\t\t\tfff = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!fff)\n\t\t\t{\n\t\t\t\tflg = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (flg) return puts(\"Impossible\"), 0;\n\tcout << ans.size() / 2 << endl;\n\tfor (int i = 0; i < ans.size(); i+=2) {\n\t\tcout << p[ans[i]].id << ' ' << p[ans[i+1]].id << endl;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "71c81bc2b5dc73e3ab30f6f90c099a76", "src_uid": "3bc096d8cd3418948d5be6bf297aa9b5", "difficulty": 3200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define rep(i, n) for (int i = 0; i < (int)n; ++i)\n#define all(a) (a).begin(), (a).end()\n#define iter(c) __typeof(c.begin())\n#define tr(c, i) for (iter(c) i = c.begin(); i != c.end(); ++i)\n#define pb push_back\n#define mp make_pair\n\ntypedef long long ll;\n\nll fib[210];\n\nint main() {\n fib[0] = fib[1] = 1;\n for (int i = 2; i <= 200; ++i) fib[i] = fib[i - 1] + fib[i - 2];\n \n string S;\n while (cin >> S) {\n vector ss;\n \n string tmp = \"\";\n rep (i, S.length()) {\n if (tmp == \"\" || tmp[tmp.length() - 1] != S[i]) {\n\ttmp += S[i];\n } else {\n\tss.pb(tmp);\n\ttmp = string() + S[i];\n }\n }\n if (!ss.empty() && ss[0][0] != tmp[tmp.length() - 1]) ss[0] = tmp + ss[0];\n else ss.pb(tmp);\n\n size_t len_sum = 0;\n rep (i, ss.size()) len_sum += ss[i].length();\n assert(len_sum == S.length());\n \n // rep (i, ss.size()) cout << i << \": \" << ss[i] << endl; puts(\"\");\n \n ll ans = 1;\n if (ss.size() == 1 && S.length() % 2 == 0) {\n int chain = ss[0].length() / 2;\n ans = fib[chain] + fib[chain - 2];\n } else {\n rep (i, ss.size()) {\n\tstring s = ss[i];\n\tcerr << s << endl;\n\tif (s.length() == 1) continue;\n\t\n\tif (s[0] == 'A') {\n\t if (s.length() < 3) { ans = 0; continue; }\n\t s = s.substr(3);\n\t if (s.empty()) continue;\n\t}\n\n\tif (s[s.length() - 1] == 'B') {\n\t if (s.length() < 3) { ans = 0; continue; }\n\t s = s.substr(0, s.length() - 3);\n\t if (s.empty()) continue;\n\t}\n\n\tassert(s.length() % 2 == 0);\n\tint chain = s.length() / 2;\n\t\n\tcerr << s << \": \" << fib[chain + 1] << endl;\n\t\n\tans *= fib[chain + 1];\n }\n }\n\n cout << ans << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bcc74affba1db4fdf06866735f46f3e9", "src_uid": "ad27d991516054ea473b384bb2563b38", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define int64 long long\n\nusing namespace std;\nconst int64 Maxn = (int64)1 << 50;\nint n,v[550],a[550];\nint64 f[550],g[550][550],g2[550][550][3],g3[550][550];\nbool vis[550][550],vis2[550][550][3],vis3[550][550];\n\nint64 solve2(int ,int ,int );\nint64 solve(int ,int );\nint64 work(int ,int );\n \nint main()\n{\n cin >> n;\n for (int i = 1;i <= n;i++) scanf(\"%d\",&v[i]);\n for (int i = 1;i <= n;i++) scanf(\"%d\",&a[i]);\n for (int i = 1;i <= n;i++) {\n f[i] = -Maxn;\n for (int j = 0;j < i;j++)\n f[i] = max(f[j] + solve(j + 1,i),f[i]);\n }\n cout << f[n];\n}\n\nint64 work(int l,int r)\n{\n if (l > r) return 0;\n if (l == r) return v[1];\n if (vis3[l][r]) return g3[l][r];\n vis3[l][r] = 1; int64 &ans = g3[l][r];\n ans = solve(l,r);\n for (int i = l;i < r;i++)\n ans = max(work(l,i) + work(i + 1,r),ans);\n return ans;\n}\nint64 solve2(int l,int r,int sign)\n{\n if (l == r) return 0;\n if (vis2[l][r][sign + 1]) return g2[l][r][sign + 1];\n vis2[l][r][sign + 1] = 1;\n int64 &ans = g2[l][r][sign + 1]; ans = -Maxn;\n for (int i = l;i <= r;i++)\n if (a[i] == a[l] + sign)\n ans = max(ans,solve2(i,r,sign) + work(l + 1,i - 1));\n return ans;\n}\nint64 solve(int l,int r)\n{\n if (abs(a[r] - a[l]) + 1 > r - l + 1) return -Maxn;\n if (l == r) return v[1];\n if (vis[l][r]) return g[l][r];\n vis[l][r] = 1; int64 &ans = g[l][r];\n ans = -Maxn;\n for (int i = l;i <= r;i++)\n {\n if (!(a[i] >= a[l] && a[i] >= a[r])) continue ;\n if (a[i] - a[l] + a[i] - a[r] + 1 > r - l + 1) continue ;\n ans = max(solve2(l,i,1) + solve2(i,r,-1) + v[2 * a[i] - a[l] - a[r] + 1],ans);\n }\n return ans;\n}\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define int64 long long\n\nusing namespace std;\nconst int64 Maxn = (int64)1 << 50;\nint n,v[550],a[550];\nint64 f[550],g[550][550],g2[550][550][2],g3[550][550];\nbool vis[550][550],vis2[550][550][2],vis3[550][550];\n\nint64 solve2(int ,int ,int );\nint64 solve(int ,int );\nint64 work(int ,int );\n \nint main()\n{\n cin >> n;\n for (int i = 1;i <= n;i++) scanf(\"%d\",&v[i]);\n for (int i = 1;i <= n;i++) scanf(\"%d\",&a[i]);\n for (int i = 1;i <= n;i++) {\n f[i] = -Maxn;\n for (int j = 0;j < i;j++)\n f[i] = max(f[j] + solve(j + 1,i),f[i]);\n }\n cout << f[n];\n}\n\nint64 work(int l,int r)\n{\n if (l > r) return 0;\n if (vis3[l][r]) return g3[l][r];\n vis3[l][r] = 1; int64 &ans = g3[l][r];\n ans = solve(l,r);\n for (int i = l;i <= r;i++)\n ans = max(work(l,i) + work(i + 1,r),ans);\n return ans;\n}\nint64 solve2(int l,int r,int sign)\n{\n if (l == r) return 0;\n if (vis2[l][r][sign + 1]) return g2[l][r][sign + 1];\n vis2[l][r][sign + 1] = 1;\n int64 &ans = g2[l][r][sign + 1]; ans = -Maxn;\n for (int i = l;i <= r;i++)\n if (a[i] == a[l] + sign)\n ans = max(ans,solve2(i,r,sign) + work(i + 1,r - 1));\n return ans;\n}\nint64 solve(int l,int r)\n{\n if (abs(a[r] - a[l]) > r - l + 1) return -Maxn;\n if (l == r) return v[1];\n if (vis[l][r]) return g[l][r];\n vis[l][r] = 1; int64 &ans = g[l][r];\n ans = -Maxn;\n for (int i = l;i <= r;i++)\n {\n if (!(a[i] >= a[l] && a[i] >= a[r])) continue ;\n if (a[i] - a[l] + a[i] - a[r] + 1 > r - l + 1) continue ;\n ans = max(solve2(l,i,1) + solve2(i,r,-1) + v[2 * a[i] - a[l] - a[r] + 1],ans);\n }\n return ans;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6b0572f585cc25e56799c7cf1dfe9b73", "src_uid": "32fa5dbac37abe197a267a0fc7fe4006", "difficulty": null} {"lang": "GNU C++14", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nconst int inf = 2 * 1e9;\nconst int mod = 1e9 + 7;\nconst int maxn = 51;\n\nint n;\nint arr[maxn], dp[2][maxn][maxn][maxn][maxn];\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin >> n;\n\tfor (int i = 1;i <= n;++i)\n\t\tcin >> arr[i];\n\tint nm = 0;\n\tdp[0][arr[1] == 2][arr[1] == 3][arr[2] == 2][arr[2] == 3] = 1;\n\tfor (int i = 3;i <= n;++i) {\n\t\tnm = 1 - nm;\n\t\tmemset(dp[nm], 0, sizeof dp[nm]);\n\t\tfor (int a1 = 0;a1 <= n;++a1) {\n\t\t\tfor (int a2 = 0;a1 + a2 <= n;++a2) {\n\t\t\t\tfor (int b1 = 0;a1 + a2 + b1 <= n;++b1) {\n\t\t\t\t\tfor (int b2 = 0;a1 + a2 + b1 + b2 <= n;++b2) if (dp[1 - nm][a1][a2][b1][b2] > 0) {\n\t\t\t\t\t\tif (a1 == 0 && a2 == 0) dp[1 - nm][b1][b2][0][0] = (dp[1 - nm][b1][b2][0][0] + dp[1 - nm][a1][a2][b1][b2]) % mod;\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tint kf = 1;\n\t\t\t\t\t\t\tfor (int t1 = 0;t1 <= arr[i];++t1) if(t1 <= a1) {\n\t\t\t\t\t\t\t\tif (t1 > 0) kf = kf * (a1 - t1 + 1) / t1;\n\t\t\t\t\t\t\t\tfor (int t2 = 0;t1 + t2 <= arr[i];++t2) if (t2 <= a2) {\n\t\t\t\t\t\t\t\t\tif (t2 > 0) kf = kf * (a2 - t2 + 1) / t2;\n\t\t\t\t\t\t\t\t\tfor (int p1 = 0;t1 + t2 > 0 && t1 + t2 + p1 <= arr[i];++p1) if (p1 <= b1) {\n\t\t\t\t\t\t\t\t\t\tif (p1 > 0) kf = kf * (b1 - p1 + 1) / p1;\n\t\t\t\t\t\t\t\t\t\tfor (int p2 = 0;t1 + t2 + p1 + p2 <= arr[i];++p2) if (p2 <= b2) {\n\t\t\t\t\t\t\t\t\t\t\tif (p2 > 0) kf = kf * (b2 - p2 + 1) / p2;\n\t\t\t\t\t\t\t\t\t\t\tif (t1 + t2 + p1 + p2 + 2 == arr[i])\n\t\t\t\t\t\t\t\t\t\t\t\tdp[nm][a1 - t1 + t2][a2 - t2][b1 - p1 + p2][b2 - p2 + 1] = (dp[nm][a1 - t1 + t2][a2 - t2][b1 - p1 + p2][b2 - p2 + 1] + dp[1 - nm][a1][a2][b1][b2] * kf % mod) % mod;\n\t\t\t\t\t\t\t\t\t\t\telse if (t1 + t2 + p1 + p2 + 1 == arr[i]) \n\t\t\t\t\t\t\t\t\t\t\t\tdp[nm][a1 - t1 + t2][a2 - t2][b1 - p1 + p2 + 1][b2 - p2] = (dp[nm][a1 - t1 + t2][a2 - t2][b1 - p1 + p2 + 1][b2 - p2] + dp[1 - nm][a1][a2][b1][b2] * kf % mod) % mod;\n\t\t\t\t\t\t\t\t\t\t\telse \n\t\t\t\t\t\t\t\t\t\t\t\tdp[nm][a1 - t1 + t2][a2 - t2][b1 - p1 + p2][b2 - p2] = (dp[nm][a1 - t1 + t2][a2 - t2][b1 - p1 + p2][b2 - p2] + dp[1 - nm][a1][a2][b1][b2] * kf % mod) % mod;\n\t\t\t\t\t\t\t\t\t\t\tif (p2 > 0) kf = kf * p2 / (b2 - p2 + 1);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (p1 > 0) kf = kf * p1 / (b1 - p1 + 1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (t2 > 0) kf = kf * t2 / (a2 - t2 + 1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (t1 > 0) kf = kf * t1 / (a1 - t1 + 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << dp[nm][0][0][0][0];\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "35282bf0c71f9739196a7d6952a656c7", "src_uid": "db884d679d9cfb1dc4bc511f83beedda", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "#include \n//\nusing namespace std;\nconst int INF = 1e9+7;\nconst int maxn = 100015;\nconst int maxm = 1000005;\nint g[105][105];\nint num[maxn];\nint cnt;\nvoid floyed(int n){\n for(int k = 1; k <= n; k++){\n for(int i = 1; i <= n; i++){\n for(int j = 1; j <= n; j++){\n g[i][j] = min(g[i][j], g[i][k]+g[k][j]);\n }\n }\n }\n};\ninline int read()\n{\n int x=0,f=1;char ch=getchar();\n while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}\n while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}\n return x*f;\n}\nstruct Edge{\n int to,next,cap,flow;\n}edge[maxm];\nint tol,head[maxn];\nvoid init()\n{\n tol=2;\n memset(head,-1,sizeof(head));\n}\nvoid addedge(int u,int v,int w,int rw=0)\n{\n edge[tol].to=v;edge[tol].cap=w;edge[tol].flow=0;\n edge[tol].next=head[u];head[u]=tol++;\n edge[tol].to=u;edge[tol].cap=rw;edge[tol].flow=0;\n edge[tol].next=head[v];head[v]=tol++;\n}\nint Q[maxn];\nint dep[maxn],cur[maxn],sta[maxn];\nbool bfs(int s,int t,int n)\n{\n int front=0,tail=0;\n memset(dep,-1,sizeof(dep[0])*(n+1));\n dep[s]=0;\n Q[tail++]=s;\n while(frontedge[i].flow&&dep[v]==-1){\n dep[v]=dep[u]+1;\n if(v==t){\n return true;\n }\n Q[tail++]=v;\n }\n }\n }\n return false;\n}\nlong long dinic(int s,int t,int n)\n{\n long long maxflow=0;\n while(bfs(s,t,n)){\n for(int i=0;i=0;i--){\n tp=min(tp,edge[sta[i]].cap-edge[sta[i]].flow);\n }\n maxflow+=tp;\n for(int i=tail-1;i>=0;i--){\n edge[sta[i]].flow+=tp;\n edge[sta[i]^1].flow-=tp;\n if(edge[sta[i]].cap-edge[sta[i]].flow==0){\n tail=i;\n }\n }\n u=edge[sta[tail]^1].to;\n }else if(cur[u]!=-1&&edge[cur[u]].cap>edge[cur[u]].flow&&dep[u]+1==dep[edge[cur[u]].to]){\n sta[tail++]=cur[u];\n u=edge[cur[u]].to;\n }else{\n while(u!=s&&cur[u]==-1){\n u=edge[sta[--tail]^1].to;\n }\n cur[u]=edge[cur[u]].next;\n }\n }\n }\n return maxflow;\n}\n//vectorfuck[100005];\nint fuckacm[100005];\nint ps[105];\nint in[maxn], out[maxn], shipos[maxn], atk[maxn], f[maxn], p[maxn], baspos[maxn], d[maxn], gold[maxn], val[maxn];\nbool svis[maxn];\n#define pii pair\nvector v1[105];\nint main(){\n int n, m, u, v, s, b, k;\n n = read(), m = read();\n for(int i = 1; i <= n; i++){\n for(int j = 1; j <= n; j++){\n if(i==j) g[i][j] = 0;\n else g[i][j] = g[j][i] = INF;\n }\n }\n for(int i = 1; i <= m; i++){\n u = read(), v = read();\n g[u][v] = g[v][u] = 1;\n }\n floyed(n);\n s = read(), b = read(), k = read();\n for(int i = 1; i <= s; i++){\n shipos[i] = read(), atk[i] = read(), f[i] = read(), p[i] = read();\n }\n for(int i = 1; i <= b; i++){\n baspos[i] = read(), d[i] = read(), gold[i] = read();\n v1[baspos[i]].emplace_back(pii(d[i], gold[i]));\n }\n for(int i = 1; i <= k; i++){\n int tmp1, tmp2;\n tmp1 = read(), tmp2 = read();\n fuckacm[tmp1] = tmp2;\n in[tmp2]++, out[tmp1]++;\n }\n for(int i = 1; i <= n; i++){\n sort(v1[i].begin(), v1[i].end()); ps[i] = 0;\n for(int j = 1; j < v1[i].size(); j++){\n v1[i][j].second = max(v1[i][j].second, v1[i][j-1].second);\n }\n }\n for(int i = 1; i <= s; i++){\n int ma = -INF;\n for(int j = 1; j <= n; j++){\n if(g[shipos[i]][j] <= f[i]){\n if(v1[j].empty()) continue;\n while(ps[j] < v1[j].size()-1 && v1[j][ps[j]+1].first <= atk[i]) ps[j]++;\n if(v1[j][ps[j]].first <= atk[i]) ma = max(ma, v1[j][ps[j]].second;\n }\n }\n val[i] = ma-p[i];\n }\n long long ans = 0;\n for(int i = 1; i <= s; i++){\n if(in[i] == 0 && out[i] > 0 && !svis[i]){\n if(val[i] <= 0){\n svis[i] = true;\n }\n }\n if(in[i] == 0 && out[i] == 0 && val[i]>0 && !svis[i]){\n ans += val[i];\n svis[i] = true;\n }\n if(in[i] == 0 && out[i] == 0 && val[i] < 0 && !svis[i]){\n svis[i] = true;\n }\n }\n int S = 2015+1, T = S+1;\n init();\n for(int i = 1; i <= s; i++){\n if(!svis[i]){\n if(val[i] > 0){\n num[i] = ++cnt;\n addedge(S, cnt, val[i]);\n ans += val[i];\n }\n else{\n num[i] = ++cnt;\n addedge(cnt, T, -val[i]);\n }\n }\n }\n for(int i = 1; i <= s; i++){\n if(!svis[i] && val[i] > 0)\n addedge(num[i], num[fuckacm[i]], INF);\n }\n ans -= dinic(S, T, T+1);\n cout << ans;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a72ad3543c0fe11c3eb7ed813b03652c", "src_uid": "dd4f9570b62ed012ad0706cbd805ea4b", "difficulty": 2700.0} {"lang": "GNU C++0x", "source_code": "#include\n#include\n#include \n\nusing namespace std;\n\nint n, totalSum, size;\nint res[20], a[20];\nbool mark[20];\nint sum;\nint n2;\n\ninline bool check()\n{\n\tsum = 0;\n\tfor (int j = 0; j < n; j++)\n\t\tsum += res[n2 - n + j];\n\tif (sum != totalSum)\n\t\treturn false;\n\n\tsum = 0;\n\tfor (int i = 0; i < n2; i += n + 1)\n\t\tsum += res[i];\n\tif (sum != totalSum)\n\t\treturn false;\n\n\tfor (int i = 0; i < n2; i++)\n\t{\n\t\tcout << res[i] << \" \";\n\t\tif (i % n == n - 1)\n\t\t\tcout << endl;\n\t}\n\texit(0);\n}\n\nvoid backTrack(int x)\n{\n\tif(x == 3 && res[2] > res[1])\n\t\treturn;\n\tif(x == n && res[n - 1] > res[0])\n\t\treturn;\n\tif(x > 0 && x % n == 0)\n\t{\n\t\tsum = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tsum += res[x - n + i];\n\t\tif (sum != totalSum)\n\t\t\treturn;\n\t}\n\telse if(x > n2 - n)\n\t{\n\t\tif(x == n2 - n + 1)\n\t\t{\n\t\t\tsum = 0;\n\t\t\tfor (int i = n - 1; i < n2 - 1; i += n - 1)\n\t\t\t\tsum += res[i];\n\t\t\tif (sum != totalSum)\n\t\t\t\treturn;\n\t\t}\n\t\tsum = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tsum += res[x - n2 + n - 1 + i * n];\n\t\tif (sum != totalSum)\n\t\t\treturn;\n\t}\n\tif (x == n2)\n\t\treturn check();\n\tfor (int i = 0; i < n2; i++)\n\t\tif (!mark[i])\n\t\t{\n\t\t\tmark[i] = true;\n\t\t\tres[x] = a[i];\n\t\t\tbackTrack(x + 1);\n\t\t\tmark[i] = false;\n\t\t}\n}\n\n\n\n\n\n\n\n\nbool check3()\n{\n\t// ROWS\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tint sum = 0;\n\t\tfor (int j = 0; j < n; j++)\n\t\t\tsum += res[i * n + j];\n\t\tif (sum != totalSum)\n\t\t\treturn false;\n\t}\n\t// COLUMNS\n\tfor (int j = 0; j < n; j++)\n\t{\n\t\tint sum = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tsum += res[i * n + j];\n\t\tif (sum != totalSum)\n\t\t\treturn false;\n\t}\n\t// MAIN DIAG\n\tint mdsum = 0;\n\tfor (int i = 0; i < n * n; i += n + 1)\n\t\tmdsum += res[i];\n\t// SEC DIAG\n\tint sdsum = 0;\n\tfor (int i = n - 1; i < n * n - 1; i += n - 1)\n\t\tsdsum += res[i];\n\tif (mdsum != totalSum || sdsum != totalSum)\n\t\treturn false;\n\t// OUTPUT\n\tfor (int i = 0; i < n * n; i++)\n\t{\n\t\tcout << res[i] << \" \";\n\t\tif (i % n == n - 1)\n\t\t\tcout << endl;\n\t}\n\texit(0);\n}\n\nbool backTrack3(int x)\n{\n\t//\tcout << x << endl;\n\tif (x == n * n)\n\t\treturn check();\n\tfor (int i = 0; i < n * n; i++)\n\t\tif (!mark[i])\n\t\t{\n\t\t\tmark[i] = true;\n\t\t\tres[x] = a[i];\n\t\t\tbackTrack(x + 1);\n\t\t\tmark[i] = false;\n\t\t}\n}\n\n\n\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin >> n;\n\tn2 = n * n;\n\tfor (int i = 0; i < n * n; i++)\n\t{\n\t\tcin >> a[i];\n\t\ttotalSum += a[i];\n\t}\n\ttotalSum /= n;\n\tcout << totalSum << endl;\n\tif(n == 1)\n\t\tcout << a[0] << endl;\n\telse if(n < 4)\n\t\tbackTrack3(0);\n\telse\n\t\tbackTrack(0);\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "25d026a95332a841233809f9ac451518", "src_uid": "7c806fb163aaf23e1eef3e6570aea436", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#ifndef call_from_test\n#include\nusing namespace std;\n\n#define call_from_test\n#ifndef call_from_test\n#include\nusing namespace std;\n#endif\n//BEGIN CUT HERE\ntemplate\nstruct LinkCutTreeBase{\n static array pool;\n size_t ptr;\n\n LinkCutTreeBase():ptr(0){}\n\n inline Node* create(){\n return &pool[ptr++];\n }\n\n inline Node* create(Node v){\n return &(pool[ptr++]=v);\n }\n\n inline size_t idx(Node *t){\n return t-&pool[0];\n }\n\n Node* operator[](size_t k){\n return &(pool[k]);\n }\n\n virtual void toggle(Node *t) = 0;\n virtual void eval(Node *t) = 0;\n virtual void pushup(Node *t) = 0;\n\n void rotR(Node *t){\n Node *x=t->p,*y=x->p;\n if((x->l=t->r)) t->r->p=x;\n t->r=x;x->p=t;\n pushup(x);pushup(t);\n if((t->p=y)){\n if(y->l==x) y->l=t;\n if(y->r==x) y->r=t;\n pushup(y);\n }\n }\n\n void rotL(Node *t){\n Node *x=t->p,*y=x->p;\n if((x->r=t->l)) t->l->p=x;\n t->l=x;x->p=t;\n pushup(x);pushup(t);\n if((t->p=y)){\n if(y->l==x) y->l=t;\n if(y->r==x) y->r=t;\n pushup(y);\n }\n }\n\n bool is_root(Node *t){\n return !t->p||(t->p->l!=t&&t->p->r!=t);\n }\n\n void splay(Node *t){\n eval(t);\n while(!is_root(t)){\n Node *q=t->p;\n if(is_root(q)){\n eval(q);eval(t);\n if(q->l==t) rotR(t);\n else rotL(t);\n }else{\n auto *r=q->p;\n eval(r);eval(q);eval(t);\n if(r->l==q){\n if(q->l==t) rotR(q),rotR(t);\n else rotL(t),rotR(t);\n }else{\n if(q->r==t) rotL(q),rotL(t);\n else rotR(t),rotL(t);\n }\n }\n }\n }\n\n virtual Node* expose(Node *t){\n Node *rp=nullptr;\n for(Node *c=t;c;c=c->p){\n splay(c);\n c->r=rp;\n pushup(c);\n rp=c;\n }\n splay(t);\n return rp;\n }\n\n void link(Node *par,Node *c){\n expose(c);\n expose(par);\n c->p=par;\n par->r=c;\n pushup(par);\n }\n\n void cut(Node *c){\n expose(c);\n Node *par=c->l;\n c->l=nullptr;\n pushup(c);\n par->p=nullptr;\n }\n\n void evert(Node *t){\n expose(t);\n toggle(t);\n eval(t);\n }\n\n Node *parent(Node *t){\n expose(t);\n t=t->l;\n while(t&&t->r) t=t->r;\n if(t) splay(t);\n return t;\n }\n\n Node *root(Node *t){\n expose(t);\n while(t->l) t=t->l;\n splay(t);\n return t;\n }\n\n bool is_connected(Node *a,Node *b){\n return root(a)==root(b);\n }\n\n Node *lca(Node *a,Node *b){\n expose(a);\n return expose(b);\n }\n};\ntemplate\narray LinkCutTreeBase::pool;\n//END CUT HERE\n#ifndef call_from_test\n//INSERT ABOVE HERE\nsigned main(){\n return 0;\n}\n#endif\n\n#undef call_from_test\n\n#endif\n//BEGIN CUT HERE\ntemplate\nstruct NodeBase{\n using A = Ap;\n NodeBase *l,*r,*p;\n bool rev;\n A val,dat,sum;\n NodeBase(){}\n NodeBase(A val,A dat,A sum):\n rev(0),val(val),dat(dat),sum(sum){\n l=r=p=nullptr;}\n};\n\ntemplate\nstruct SubTree : LinkCutTreeBase{\n using super = LinkCutTreeBase;\n using Node = Np;\n using A = typename Node::A;\n\n SubTree():super(){}\n\n Node* create(A val){\n return super::create(Node(val,A(),val));\n }\n\n inline void toggle(Node *t){\n swap(t->l,t->r);\n t->rev^=1;\n }\n\n inline void eval(Node *t){\n if(t->rev){\n if(t->l) toggle(t->l);\n if(t->r) toggle(t->r);\n t->rev=false;\n }\n }\n\n inline A resolve(Node *t){\n return t?t->sum:A();\n }\n\n inline void pushup(Node *t){\n if(t==nullptr) return;\n t->sum=t->val+t->dat;\n t->sum+=resolve(t->l);\n t->sum+=resolve(t->r);\n }\n\n using super::splay;\n\n Node* expose(Node *t){\n Node *rp=nullptr;\n for(Node *c=t;c;c=c->p){\n splay(c);\n c->dat+=resolve(c->r);\n c->r=rp;\n c->dat-=resolve(c->r);\n pushup(c);\n rp=c;\n }\n splay(t);\n return rp;\n }\n\n A query(Node *t){\n expose(t);\n return t->sum;\n }\n\n void set_val(Node *t,A a){\n expose(t);\n t->val=a;\n pushup(t);\n }\n};\n//END CUT HERE\n#ifndef call_from_test\n\n#define call_from_test\n#ifndef call_from_test\n#include\nusing namespace std;\n#endif\n//BEGIN CUT HERE\nstruct FastIO{\n FastIO(){\n cin.tie(0);\n ios::sync_with_stdio(0);\n }\n}fastio_beet;\n//END CUT HERE\n#ifndef call_from_test\nsigned main(){\n return 0;\n}\n#endif\n\n#undef call_from_test\n\n//INSERT ABOVE HERE\n\n// sum of square\nsigned CFR564_E(){\n int n,m;\n cin>>n>>m;\n vector> modv(n),modt(n);\n vector cs(n);\n\n for(int i=0;i>cs[i];\n cs[i]--;\n modv[cs[i]].emplace_back(i);\n modt[cs[i]].emplace_back(0);\n }\n\n vector > G(n+1);\n for(int i=1;i>a>>b;\n a--;b--;\n G[a].emplace_back(b);\n G[b].emplace_back(a);\n }\n G[n].emplace_back(0);\n\n for(int i=1;i<=m;i++){\n int v,x;\n cin>>v>>x;\n v--;x--;\n modv[cs[v]].emplace_back(v);\n modt[cs[v]].emplace_back(i);\n cs[v]=x;\n modv[cs[v]].emplace_back(v);\n modt[cs[v]].emplace_back(i);\n }\n\n using ll = long long;\n struct A{\n ll sz1,sz2;\n A():sz1(0),sz2(){}\n A(ll sz1,ll sz2):sz1(sz1),sz2(sz2){}\n A operator+(const A &a)const{\n return A(sz1+a.sz1,sz2+a.sz2);\n };\n A& operator+=(const A &a){\n sz1+=a.sz1;\n sz2+=a.sz1*a.sz1;\n return (*this);\n }\n A& operator-=(const A &a){\n sz1-=a.sz1;\n sz2-=a.sz1*a.sz1;\n return (*this);\n }\n };\n\n using Node = NodeBase;\n constexpr size_t LIM = 1e6;\n using LCT = SubTree;\n LCT lct;\n\n for(int i=0;i par(n+1,0);\n {\n using P = pair;\n queue