# Codeforces Round #549 (Div. 1)

https://codeforces.com/contest/1142

## A. The Beatles

A题随便写写就行了（

#include<bits/stdc++.h>
using namespace std;

#define int long long

void read(int &x) {
x=0;int f=1;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
if(x<0) putchar('-'),x=-x;
if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,k,a,b,p[5];

signed main() {
p[1]=a+b,p[2]=a+k-b,p[3]=k-a+b,p[4]=k-a+k-b;
for(int i=1;i<=4;i++)
if(p[i]>k) p[i]-=k;
int ans1=1e18,ans2=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=4;j++) {
int t=n*k/__gcd(n*k,p[j]);
ans1=min(ans1,t),ans2=max(ans2,t);
if(p[j]+k<=n*k) p[j]+=k;
}
printf("%lld %lld\n",ans1,ans2);
return 0;
}


## B. Lynyrd Skynyrd

#include<bits/stdc++.h>
using namespace std;

void read(int &x) {
x=0;int f=1;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
if(x<0) putchar('-'),x=-x;
if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int p[maxn],a[maxn],f[maxn][20],t[maxn],n,m,q,rev[maxn],r[maxn];

int main() {

for(int i=1;i<=m;i++) {
if(a[i]==p[1]) f[i][0]=t[n];
else f[i][0]=t[rev[a[i]]-1];
t[rev[a[i]]]=i;
}

for(int i=1;i<=m;i++)
for(int j=1;j<20;j++)
f[i][j]=f[f[i][j-1]][j-1];

for(int i=1;i<=m;i++) {
int d=n-1,p=i;
for(int j=0;j<20;j++)
if(d&(1<<j)) d-=1<<j,p=f[p][j];
r[i]=max(r[i-1],p);
}

for(int i=1;i<=q;i++) {
if(r[y]>=x) putchar('1');
else putchar('0');
}puts("");
return 0;
}


## C. U2

#include<bits/stdc++.h>
using namespace std;

#define int long long

void read(int &x) {
x=0;int f=1;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
if(x<0) putchar('-'),x=-x;
if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

struct P {
int x,y;

P operator - (const P &a) {return (P){x-a.x,y-a.y};}
int operator * (const P &a) {return x*a.y-y*a.x;}
}a[maxn],sta[maxn];
int n,top;

int cmp(P x,P y) {return x.x==y.x?x.y>y.y:x.x<y.x;}

signed main() {
sort(a+1,a+n+1,cmp);a[0].x=1e18;
for(int i=1;i<=n;i++) {
if(a[i].x==a[i-1].x) continue;
if(top<=1) sta[++top]=a[i];
else {
while(top>1&&(sta[top-1]-sta[top])*(a[i]-sta[top])<=0) top--;
sta[++top]=a[i];
}
}write(top-1);
return 0;
}


## D. Foreigner

$x\%10+\frac{r_{x/10}(r_{x/10}-1)}{2}-1$

#include<bits/stdc++.h>
using namespace std;

void read(int &x) {
x=0;int f=1;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
if(x<0) putchar('-'),x=-x;
if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

#define ll long long

char s[maxn];
int n,f[maxn][12];
ll ans;

int main() {
scanf("%s",s+1);n=strlen(s+1);
for(int i=n;i;i--) {
int t=s[i]-'0';
for(int j=0;j<=10;j++)
if(t>=j) f[i][j]=0;
else f[i][j]=f[i+1][(j*(j-1)/2+t+10)%11]+1;
if(t) ans+=f[i+1][t]+1;
}printf("%lld\n",ans);
return 0;
}


## E. Pink Floyd

#include<bits/stdc++.h>
using namespace std;

void read(int &x) {
x=0;int f=1;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
if(x<0) putchar('-'),x=-x;
if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,m,vis[maxn],in[maxn],d[maxn],sta[maxn],top;
vector<int > e[maxn],t[maxn];

void dfs(int x) {
vis[x]=in[x]=1;
for(auto v:e[x]) {
if(!in[v]) t[x].pb(v),d[v]++;
if(!vis[v]) dfs(v);
}in[x]=0;
}

int main() {