akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair <int,int> pii;

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

const int MAXN=200005,SIGMA=26;

struct mv
{
	char c;
	int d;
}p[MAXN];

char s[MAXN];
int n,m,l[SIGMA],r[SIGMA],now[SIGMA];

void update(int c,int d)
{
	now[c]+=d;
	l[c]=min(l[c],now[c]);
	r[c]=max(r[c],now[c]);
}

bool check(int x)
{
	for (int i=0;i<m;i++)
		if (s[x]==p[i].c)
		{
			x+=p[i].d;
			if (x<0||x>=n)
				return false;
		}
	return true;
}

int main()
{
	#ifdef local
		freopen("read.txt","r",stdin);
	#endif
	scanf("%d%d%s",&n,&m,s);
	for (int i=0;i<m;i++)
	{
		char c[3],d[3];
		scanf("%s%s",c,d);
		p[i]={c[0],d[0]=='L'?-1:1};
	}
	int l1=0,r1=n-1;
	while (l1<=r1)
	{
		int m=l1+r1>>1;
		if (check(m))
			r1=m-1;
		else
			l1=m+1;
	}
	int l2=0,r2=n-1;
	while (l2<=r2)
	{
		int m=l2+r2>>1;
		if (check(m))
			l2=m+1;
		else
			r2=m-1;
	}
	printf("%d",max(0,r2-l1+1));
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    ll mo=0;
    cin>>n>>mo;
    ll a[n],ans=0;
    map<ll,ll> m;
    for(int i=0;i<n;++i)
    {
    cin>>a[i];        
    }
    m[0]=1;
    for(int i=1;i<n;++i)
    {
        a[i]+=a[i-1];
    }
    for(int i=0;i<n;++i)
    {
        ll r=a[i]%mo;
        ans+=m[r];
        m[r]++;
    }
    cout<<ans;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    std::cin >> S;
    if(S == "Sunny") {
        std::cout << "Cloudy" << std::endl;
    }
    else if(S == "Cloudy") {
        std::cout << "Rainy" << std::endl;
    }
    else {
        std::cout << "Sunny" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

	string S;
	
	std::vector<char> v;

	cin >> S;

	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == '0')
		{
			v.pb('0');
		}
		else if (S[i] == '1')
		{
			v.pb('1');
		}
		else if (S[i] == 'B')
		{
			if (v.size() > 0)
			{
				v.pop_back();
			}
		}
	}

	for (int i = 0; i < v.size(); i++)
	{
		cout << v[i];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
  ll A; cin >> A;
  ll B; cin >> B;
  ll T; cin >> T;
  ll ans = 0;
  for (ll j=A; j <= T; j+=A) {
    ans += B;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	string str, str_head, str_rest;
	int m, i;
	int h;

	while (1) {
		cin >> str >> m;

		if (str == "-") break;

		for (i = 0; i < m; i++) {
			cin >> h;
			str_head = str.substr(0, h);
			str_rest = str.substr(h, str.size() - 1);
			str = str_rest + str_head;
		}

		cout << str << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3156
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int dp[3005][3005];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(dp, 0, sizeof(dp));
  string s, t;
  cin >> s;
  cin >> t;
  for (int i = 0; i <= s.size(); ++i)
    for (int j = 0; j <= t.size(); ++j)
      {
        if (i == 0 || j == 0) dp[i][j] = 0;
        else if (s[i - 1] == t[j - 1])
          dp[i][j] = dp[i - 1][j - 1] + 1;
        else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
  int a = s.size(), b = t.size();
  string ans;
  while (a && b)
    {
      if (s[a - 1] == t[b - 1])
        {
          ans.push_back(s[a - 1]);
          a--; b--;
        }
      else if (dp[a - 1][b] > dp[a][b - 1])
        a--;
      else b--;
    }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 38940
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 1e5+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/

main(){
    fast();per(0);
    //get_fact();
    int n;cin>>n;
    set<int>st;
    while(n--){
        int x;cin>>x;
        st.insert(x);
    }
    cout<<st.size();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define maxn 305
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,m,l,Q;
int headd[maxn*maxn],nextt[maxn*maxn],to[maxn*maxn],val[maxn*maxn],cntt;
int dp[maxn][maxn],ss[maxn],vis[maxn];
inline void add(int u,int v,int w)
{nextt[++cntt]=headd[u];headd[u]=cntt;to[cntt]=v,val[cntt]=w;}
struct node
{
    int x,y,z;
    bool operator <(const node &b)const
    {
        if(y==b.y)return z<b.z;
        return y>b.y;
    }
};
priority_queue<node>q;
inline void dij(int x)
{
    memset(vis,0,sizeof vis);
    memset(dp[x],63,sizeof dp[x]);
    memset(ss,63,sizeof ss);
    dp[x][x]=0;ss[x]=l;node u;reg int i,k,o;
    q.push((node){x,0,l});
    while(!q.empty())
    {
        u=q.top();q.pop();
        if(vis[u.x])continue;vis[u.x]=1;
        for(i=headd[u.x];i;i=nextt[i])
        {
            k=-1;if(u.z<val[i]&&l>=val[i])k=1,o=l-val[i];
            if(u.z>=val[i])k=0,o=u.z-val[i];if(k==-1)continue;
            if(dp[x][to[i]]>dp[x][u.x]+k)
            {
                dp[x][to[i]]=dp[x][u.x]+k;ss[to[i]]=o;
                q.push((node){to[i],dp[x][to[i]],ss[to[i]]});
            }
            else
            {
                if(dp[x][to[i]]==dp[x][u.x]+k&&ss[to[i]]<o)
                    ss[to[i]]=o,q.push((node){to[i],dp[x][to[i]],ss[to[i]]});
            }
        }
    }
}
int main()
{
    n=read(),m=read(),l=read();
    reg int i,u,v,w;
    for(i=1;i<=m;++i)
    {
        u=read(),v=read(),w=read();
        add(u,v,w);add(v,u,w);
    }
    for(i=1;i<=n;++i)dij(i);
    Q=read();while(Q--)
    {
        u=read(),v=read();
        if(dp[u][v]>n)puts("-1");
        else printf("%d\n",dp[u][v]);
    }
	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,g;
    bool tacno=true;
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> g;
        if(g%2==0 && g%3!=0 && g%5!=0)
        {tacno=false;break;}
    }
    if(tacno) cout << "APPROVED";
    else cout << "DENIED";
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, 0, n) cin >> v[i];

    ll ans = -1e12;
    rep(a, 0, min(n,k)+1){
        rep(b, 0, min(n,k)+1-a){
            vector<ll> neg;
            ll sum = 0;
            rep(i, 0, a){
                if(v[i] < 0) neg.push_back(v[i]);
                sum += v[i];
            }
            rep(i, n-b, n){
                if(v[i] < 0) neg.push_back(v[i]);
                sum += v[i];
            }
            sort(neg.begin(), neg.end());
            ll i = 0;
            while(i < neg.size() && i < k-(a+b)){
                sum -= neg[i];
                i++;    
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;

struct UF {
	vector<int> par, rank, cnt; //root, tree, count
	UF() {}
	UF(int n){ init(n); }
	void init(int n) {
		par.assign(n+4,0); rank.assign(n+4,0); cnt.assign(n+4,1);
		for(int i = 0; i<n; i++) par[i] = i;
	}
	int find(int x){if(par[x] == x) return x; else return par[x] =find(par[x]);}
	void unite(int x, int y) { //unite, (add)
		x = find(x); y = find(y);
		if(x == y) return;
		if(rank[x] < rank[y]){ par[x] = y; cnt[y] +=cnt[x]; }
		else{ par[y] = x;  cnt[x] +=cnt[y]; if(rank[x] == rank[y]) rank[x]++;}
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int count(int x){return cnt[find(x)];}
};



int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,k,l;
	cin >>n >>k >>l;
	vector<pii> vp(n);
	UF ufa(n+2), ufb(n+2);
	rep(i,k){
		int p,q; cin >>p >>q;
		ufa.unite(p-1,q-1);
	}
	rep(i,l){
		int p,q; cin >>p >>q;
		ufb.unite(p-1,q-1);
	}
	map<pii, int> mp;
	rep(i,n) mp[pii(ufa.find(i),ufb.find(i))]++;
	rep(i,n){
		cout <<(i? " ":"") <<mp[pii(ufa.find(i),ufb.find(i))];
	}
	cout <<endl;
	return 0;
}


Measured memory_bytes: 18048
d,g=map(int,input().split())

p=[]
c=[]

for i in range(d):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
    
sum=[]
for i in range(d):
    sum.append((i+1)*100*p[i]+c[i])


def ans(g,t):
    if t<=0:
        return 100000000000
    n=min(int(g/(100*t)),p[t-1])
    s=100*t*n
    
    if n==p[t-1]:
        s=sum[t-1]
    if g>s:
        n+=ans(g-s,t-1)
    
    return min(n,ans(g,t-1))

print(ans(g,d))
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 5050;

int N;

char S[MAX_N], T[MAX_N];
vector<int> digestS, digestT;
int cnt2S, cnt2T;
int ans = INT_MAX;

vector<int> getDigest(char A[]) {
    vector<int> digest;
    int curr = 1;
    for (int i = 2; i <= N; i++) {
        if (A[i] != A[i - 1]) {
            digest.push_back(curr);
            curr = 1;
        } else {
            curr++;
        }
    }
    digest.push_back(curr);
    return digest;
}

void init() {
    scanf("%d", &N);
    scanf("%s", S + 1);
    scanf("%s", T + 1);
    if (N <= 2) {
        int ans = 0;
        for (int i = 1; i <= N; i++)
            if (S[i] != T[i]) ans++;
        printf("%d\n", ans);
        exit(0);
    }
    digestS = getDigest(S);
    digestT = getDigest(T);
    for (int i : digestS)
        if (i == 2) cnt2S++;
    for (int i : digestT)
        if (i == 2) cnt2T++;
}

void gather(vector<int> &digest, int cnt, int target, int &res) {
    int obst = 0;
    for (int i = 0, j = 0; i < digest.size() && cnt; i++) {
        if (digest[i] == target) {
            res += obst;
            swap(digest[j++], digest[i]);
            cnt--;
        } else obst++;
    }
    if (cnt) res = -1;
}

void convert(vector<int> &digest, int delta, int &res) {
    if (delta > 0) {
        gather(digest, 2 * delta, 1, res);
        if (res == -1) return;
        digest.erase(digest.begin(), digest.begin() + 2 * delta);
        digest.insert(digest.begin(), delta, 2);
        res += delta * (delta - 1) + delta;
    }
    if (delta < 0) {
        gather(digest, -delta, 2, res);
        if (res == -1) return;
        digest.erase(digest.begin(), digest.begin() + (-delta));
        digest.insert(digest.begin(), -delta * 2, 1);
        res += (-delta) * (-delta - 1) + (-delta);
    }
}

vector<int> get_2pos(const vector<int> &digest) {
    vector<int> res;
    for (int i = 0; i < digest.size(); i++) {
        if (digest[i] == 2) res.push_back(i);
    }
    return res;
}

void solve(int delta_l, int delta_r) {
    int res = 0;
    vector<int> digest = digestS;
    convert(digest, delta_l, res);
    if (res == -1) return;
    reverse(digest.begin(), digest.end());
    convert(digest, delta_r, res);
    if (res == -1) return;
    reverse(digest.begin(), digest.end());
    vector<int> pos_curr = get_2pos(digest);
    vector<int> pos_target = get_2pos(digestT);
    for (int i = 0; i < pos_curr.size(); i++)
        res += abs(pos_curr[i] - pos_target[i]);
    ans = min(ans, res);
}

int main() {
    init();
    for (int i = -N / 2; i <= N / 2; i++) {
        if ((i & 1) ^ (S[1] == T[1])) {
            solve(i, cnt2T - cnt2S - i);
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include <string>
using namespace std;

int main(){
    double W,H,x,y;
    cin>>W>>H>>x>>y;
    int judge=0;
    double ans=(H*W)/2.0;

    if(x==W/2.0 && y==H/2.0){
        judge=1;
    }

    cout<<ans<<" "<<judge<<endl;

    return 0;

}

Measured memory_bytes: 256
N=int(input())
H=list(map(int,input().split(" ")))
D=[0]*N
M=[0]*N
D[N-1]=0
M[N-1]=0
for i in reversed(range(N-1)):  
  if H[i] >= H[i+1]:
    D[i]=D[i+1]+1
  else:
    D[i]=0
  M[i]=max(D[i],M[i+1])
#print(H)
#print(D)
#print(M)
print(M[0])

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   int sun[6];
   memset(sun,0,sizeof(sun));
   cin>>n;
   getchar();
   while(n--)
   {
       string s;
       cin>>s;
       if(s[0]=='A') sun[1]++;
        else if(s[0]=='W') sun[2]++;
        else if(s[0]=='T') sun[3]++;
        else if(s[0]=='R') sun[4]++;
   }
    cout<<"AC x "<<sun[1]<<endl;
    cout<<"WA x "<<sun[2]<<endl;
    cout<<"TLE x "<<sun[3]<<endl;
    cout<<"RE x "<<sun[4]<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double
#define DUMP(v) "," #v ":" << v


int main(){
  ll n ; // 2 x 10^5
  cin >> n;
  vector<ll> a(n,0); // <= 1e9
  rep(i,n) cin >> a[i];

  ll ans = 0;
  ll maxH = a[0];
  rep2(i,1,n) {
    if (maxH > a[i]) {
      ans += maxH - a[i];
    } else if (maxH < a[i]) {
      maxH = a[i];
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4836
#include <iostream>
using namespace std;

int main()
{
  char s[100];
  char p[100];
  cin >> s >> p;
  int i=0;
  while(s[i]!='\0')
    i++;
  int sizeS=i;

  int j=0;
  while(p[j]!='\0')
    j++;
  int sizeP=j;
  if(sizeP>sizeS){cout << "No" << endl;return 0;}

  for(int m=0;m<sizeS;m++)
    {
      for(int n=0;n<sizeP;n++)
	{
	  if(m+n<sizeS)
	    {
	  if(s[m+n]!=p[n])
	    goto retry;
	    }
	  else
	    {
	      if(s[m+n-sizeS]!=p[n])
		goto retry;
	    }
	}
      cout << "Yes" <<endl;
      return 0;
    retry:
      ;
    }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 1140
use proconio::input;
use std::collections::HashSet;
#[allow(unused_mut)]
fn main() {
    input! {
        n: usize,
        a: [usize;n]
    }
    let set: HashSet<usize> = a.into_iter().collect();
    println!("{}", if set.len() == n { "YES" } else { "NO" });
}


Measured memory_bytes: 7784
N, M = map(int, input().split())
S = list(input().split())
T = list(input().split())
MOD = 10**9+7
dp = [[0] * (M+1) for _ in range(N+1)]
sum = [[0] * (M+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N+1):
    sum[i][0] = 1
for j in range(M+1):
    sum[0][j] = 1
for i in range(N):
    for j in range(M):
        dp[i+1][j+1] = (S[i] == T[j]) * sum[i][j]
        sum[i+1][j+1] = (sum[i+1][j] + sum[i][j+1] - sum[i][j] + dp[i+1][j+1]) % MOD
print(sum[N][M])

Measured memory_bytes: 104284
#include <iostream>
#include <string>

using namespace std;
int main(void){
  string s;
  cin >> s;
  int ans = 0;
  int now = 0;
  for(int i = 0; i < 3; i ++){
    if(s[i] == 'R'){
      now ++;
    }else{
      now = 0;
    }
    if(now > ans){
      ans = now;
    }
  }
  cout << ans << endl;

  
  
  return 0;
  
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i,n)for(i=0;i<n;i++)
void cm(ll &a,ll b){if(a>b)a=b;}
int main(void){ll n,s,k,v,i,j,b;cin>>n;vl x(n),y(n),p(n),a(n+1,1LL<<60);vector<vl>X(n),Y(n);rep(i,n)cin>>x[i]>>y[i]>>p[i];rep(i,n){X[i]=vl(1<<n,abs(x[i])),Y[i]=vl(1<<n,abs(y[i]));rep(b,1<<n)rep(j,n)if(b&1<<j)cm(X[i][b],abs(x[i]-x[j])),cm(Y[i][b],abs(y[i]-y[j]));}rep(b,1<<n){s=b;do{k=__builtin_popcountl(b),v=0;rep(i,n)v+=p[i]*min(X[i][s],Y[i][b&~s]);cm(a[k],v),s=(s-1)&b;}while(s!=b);}rep(i,n+1)cout<<a[i]<<endl;return 0;}

Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
using Graph = vector<vector<int>>;
int main() {
  int N;
  cin >> N;
  long long sum = 0;
  long long sum2 = 0;
  FOR(i,0,N) {
    long long x;
    cin >> x;
    sum += x;
    sum %= 1000000007;
    sum2 += (x*x)%1000000007;
    sum2 %= 1000000007;
  }
  long long A = (sum*sum) % 1000000007;
  while (A < sum2) {
    A += 1000000007;
  }
  cout << (((A - sum2)%1000000007) * 500000004) % 1000000007 << endl;
      
  return 0;
}

Measured memory_bytes: 3548
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    OP(x - a - ((x - a) / b) * b);
    return 0;
}

Measured memory_bytes: 256
// author: lkx
// Problem:
// ID:
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long
#define ull unsigned long long
#define debug(x) cerr<<#x<<"="<<x<<'\n'
//#define DEBUG

const int MOD=1e9+7;

ll a,b,c,k;

int main()
{
	#ifdef DEBUG
	clock_t tStart = clock();
	#endif
	cin>>a>>b>>c>>k;
	if(k&1) cout<<b-a;
	else cout<<a-b;
	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
	#endif
	return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<String>()
        .chars()
        .map(|c| c.to_digit(10).unwrap())
        .collect::<Vec<_>>();

    let mut q = vec![vec![]];
    let mut ans = 0;
    let c753 = vec![7, 5, 3];

    use std::collections::HashSet;
    while let Some(v) = q.pop() {
        for &c in &c753 {
            let mut vv = v.clone();
            vv.push(c);
            if is_smaller(&vv, &n) {
                let mut s = HashSet::new();
                s.insert(3);
                s.insert(5);
                s.insert(7);
                for i in 0..vv.len() {
                    s.remove(&vv[i]);
                }
                if s.is_empty() {
                    ans += 1;
                }
                q.push(vv)
            }
        }
    }
    println!("{}", ans);

    fn is_smaller(vv: &Vec<u32>, n: &Vec<u32>) -> bool {
        if vv.len() < n.len() {
            true
        } else if vv.len() == n.len() {
            for i in 0..n.len() {
                if vv[i] < n[i] {
                    return true;
                } else if vv[i] == n[i] {
                    // pass
                } else {
                    return false;
                }
            }
            true
        } else {
            false
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int count =0;
	int max = 0;
	int i=0;
	while(i<s.length())
	{
		if(s[i] == 'R')
		{
			count++;
			while(s[i+1] == 'R')
			{
				count++;
				i++;
			}
			if(count>=max)max = count;
			i++;
		}
		else
		{
			count = 0;
			i++;
		}

	}
	cout<<max;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 3005;
int t;
int n,m;
int c[MN],w[MN]; 
int f[MN][MN],g[MN][MN];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;++i) cin>>c[i]>>w[i];
	
	for(int i=1;i<=n;++i)
	{
		for(int j=0;j<=m;++j) f[i][j] = f[i-1][j];
		for(int j=m;j>=c[i];--j) 
		{
			f[i][j] = max(f[i-1][j],f[i-1][j-c[i]]+w[i]);
		}
	}
	for(int i=n;i>=1;--i)
	{
		for(int j=0;j<=m;++j) g[i][j] = g[i+1][j];
		for(int j=m;j>=c[i];--j) 
		{
			g[i][j] = max(g[i+1][j],g[i+1][j-c[i]]+w[i]);
		}
	}
	int ans = 0;
	for(int i=1;i<=n;++i)
	{
		for(int j=0;j<m;++j)
		{
			 ans = max(ans,f[i-1][j]+w[i]+g[i+1][m-j-1]);
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
using namespace std;

bool isValidRange(int y, int x) {
    return 0 <= x && x < 10 && 0 <= y && y < 10;
}

void dropInk(int x, int y, int size, int d[10][10]) {
    switch (size) {
    case 1:
        for (int i = x - 1; i <= x + 1; i++) {
            if (isValidRange(y, i)) {
                d[y][i]++;
            }
        }
        for (int i = y - 1; i <= y + 1; i++) {
            if (isValidRange(i, x)) {
                d[i][x]++;
            }
        }
        d[y][x]--;
        break;
    case 2:
        for (int i = y - 1; i <= y + 1; i++) {
            for (int j = x - 1; j <= x + 1; j++) {
                if (isValidRange(i, j)) {
                    d[i][j]++;
                }
            }
        }
        break;
    case 3:
        for (int i = y - 1; i <= y + 1; i++) {
            for (int j = x - 1; j <= x + 1; j++) {
                if (isValidRange(i, j)) {
                    d[i][j]++;
                }
            }
        }
        if (isValidRange(y - 2, x)) d[y - 2][x]++;
        if (isValidRange(y, x - 2)) d[y][x - 2]++;
        if (isValidRange(y, x + 2)) d[y][x + 2]++;
        if (isValidRange(y + 2, x)) d[y + 2][x]++;
        break;
    }
}

int main() {
    int cells[10][10] = {};
    int x, y, size;
    while (scanf("%d,%d,%d", &x, &y, &size) != EOF) {
        dropInk(x, y, size, cells);
    }
    int zeroNum = 0, max = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (cells[i][j] == 0) {
                zeroNum++;
            }
            if (max < cells[i][j]) {
                max = cells[i][j];
            }
        }
    }
    cout << zeroNum << endl
         << max << endl;
}

Measured memory_bytes: 0
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    const MOD: i64 = 1000000007;

    let mut ans = 1;
    for i in 1..n + 1 {
        ans *= i;
        ans %= MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=1e2;
int A[N+10];
int main(){
	int n=read(),m=read(),cnt=0;
	for (int i=1;i<=m;i++)	A[i]=read(),cnt+=A[i]&1;
	if (cnt>2){
		printf("Impossible\n");
		return 0;
	}
	for (int i=1;i<=m;i++)	if (A[i]&1)	swap(A[1]&1?A[m]:A[1],A[i]);
	if (m==1){
		if (A[1]==1){
			printf("1\n1\n1\n");
			return 0;
		}
		printf("%d\n2\n1 %d\n",A[1],A[1]-1);
		return 0;
	}
	for (int i=1;i<=m;i++)	printf("%d",A[i]),putchar(i==m?'\n':' ');
	printf("%d\n%d ",m-(A[m]==1),A[1]+1);
	for (int i=2;i<m;i++)	printf("%d ",A[i]);
	if (A[m]!=1)	printf("%d\n",A[m]-1);
	return 0;
}

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = sorted(map(int, input().split()), reverse=True)[:x]
q = sorted(map(int, input().split()), reverse=True)[:y]
r = list(map(int, input().split()))
ls = sorted(p+q+r, reverse=True)[:x+y]
print(sum(ls))


Measured memory_bytes: 22548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;

const int INF = 1001001001;
int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> Graph(700000);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        Graph[a].push_back(b);
        Graph[b].push_back(a);
    }
    queue<int> nextWillVisit;
    vector<int> dist(N, INF);
    dist[0] = 0;
    vector<int> prev(N, INF);
    prev[0] = -1;
    nextWillVisit.push(0);

    while(!nextWillVisit.empty()) {
        int v = nextWillVisit.front();
        nextWillVisit.pop();
        for(int nv: Graph[v]) {
            if(dist[nv] != INF) continue;
            dist[nv] = dist[v]+1;
            prev[nv] = v;
            nextWillVisit.push(nv);
        }
    }
    
    cout << "Yes" << endl;

    for(int i=1; i<N; i++) {
        cout << prev[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 24560
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n, v, u, ans;

main () {
	cin >> n;
	for (int i = 1; i <= n; ++i) 
		ans += i * (n - i + 1);
	
	for (int i = 1; i < n; ++i) {
		cin >> v >> u;
		if (v > u)
			swap(v, u);
		ans -= v * (n - u + 1);
	}

	cout << ans << endl;
}
	
        	
//check for the constants

                                                                                   	

                     	             

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#define MAXN 500
#define FL(i,j,k) for(ll i=j;i<k;++i)
using namespace std;
typedef long long int ll;
ll N;
int main(){
    cin>>N;
    ll n=(sqrt(1+8*N)-1)/2;
    ll k=N-n*(n+1)/2;
    if(k==0){
        FL(i, 0, n)cout<<i+1<<'\n';
    }
    else{
        FL(i, 0, n+1){
            if(i!=n-k){
                cout<<i+1<<'\n';
            }
        }
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

H,W = map(int, input().split())

# T字で区切るパターンを縦横それぞれ試す
mnval = float("inf")
for i in range(1,H):
    # Tの横棒に当たる方
    tmpA = i * W
    # 縦2等分
    tmpB = (H-i) * (W // 2)
    # 残り
    tmpC = H*W - tmpA - tmpB
    mnval = min(mnval, abs(max(tmpA,tmpB,tmpC) - min(tmpA,tmpB,tmpC)))
for i in range(1,W):
    tmpA = i * H
    tmpB = (W-i) * (H // 2)
    tmpC = H*W - tmpA - tmpB
    mnval = min(mnval, abs(max(tmpA,tmpB,tmpC) - min(tmpA,tmpB,tmpC)))

# 縦並び横並びパターンをそれぞれ試す
if W >= 3:
    # 3等分
    tmpA = H * (W // 3)
    # 3等分と、その余った部分の半分
    tmpB = H * (W // 3 + ((W % 3) // 2))
    # 残り
    tmpC = H*W - tmpA - tmpB
    mnval = min(mnval, abs(max(tmpA,tmpB,tmpC) - min(tmpA,tmpB,tmpC)))
if H >= 3:
    tmpA = W * (H // 3)
    tmpB = W * (H // 3 + ((H % 3) // 2))
    tmpC = H*W - tmpA - tmpB
    mnval = min(mnval, abs(max(tmpA,tmpB,tmpC) - min(tmpA,tmpB,tmpC)))

print(mnval)

Measured memory_bytes: 3064
N = int(input())
K = int(input())
x = list(map(int, input().split()))
count = 0

for i in range(N):
  if K>x[i]:
    if K-x[i]<x[i]:
      count += (K-x[i])*2
    else:
      count += x[i]*2
  else:
    count += (x[i]-K)*2

print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> a(m);
	REP(i, m) cin >> a[i];
	int root[n + 1] = {0};
	REP(i, m){
		root[a[i]]++;
	}

	int right = 0, left = 0;
	for (int i = x; i > 0; i--){
		if (root[i]) left++;
	}
	for (int i = x; i < n + 1; i++){
		if (root[i]) right++;
	}

	cout << (left < right ? left : right) << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b ? "true" : "false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vector<bool> v) {
	string res;
	for(int i = 0; i < (int) v.size(); i++)
		res += char('0' + v[i]);
	return res;
}
 
template<size_t S> string to_string(bitset<S> b) {
	string res;
	for(int i = 0; i < S; i++)
		res += char('0' + b[i]);
	return res;
}

template<class T> string to_string(T v) {
    bool f = 1;
    string res;
    for(auto& x : v) {
		if(!f)
			res += ' ';
		f = 0;
		res += to_string(x);
	}
    return res;
}
 
void DBG() {
	cerr << "]" << endl;
}

template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
		cerr << ", ";
	DBG(t...);
}

#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};

void solve() {
	long long d, t, s;
	cin >> d >> t >> s;
	if(t * s >= d) cout << "Yes";
	else cout << "No";
	cout << '\n';
}	
 
int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
 	
	int t = 1;
	//cin >> t;
	for(int i = 1; i <= t; i++) {
		//cout << "Case #" << i << ": ";
		solve();
	}
}

Measured memory_bytes: 3648
n = int(input())
P = list(map(int, input().split()))
C = list(range(1, n+1, 1))

cnt = 0
for i in range(n) : 
    if P[i] != C[i] : 
        cnt += 1

if cnt == 0 or cnt == 2 : 
    print("YES")
else : 
    print("NO")

Measured memory_bytes: 3060
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;

const int MAXN = 100001;
const int mod = 1000000007;

int main(){
    int n;
    cin>>n;
    long double p[n];
    fr(i,n)cin>>p[i];
    long double dp[n][n+1];

    for(int i = 0; i < n; i++){
        for(int j= 0 ; j <= n; j++)dp[i][j] = 0;
    }

    dp[0][1] = p[0], dp[0][0] = 1-p[0];

    for(int i = 1; i < n; i++){
        dp[i][0] = (1-p[i])*dp[i-1][0];
        for(int j = 1; j <= i+1; j++){
            dp[i][j] = p[i] * dp[i-1][j-1] + (1-p[i])*dp[i-1][j];
        }
    }

    long double ans = 0;

    for(int i = (n>>1)+1; i <= n; i++)ans += dp[n-1][i];
    cout<<setprecision(10)<<fixed<< ans << endl;
}


Measured memory_bytes: 140928
#include<iostream>

using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;

	int Q = abs(x - a);
	int W = abs(x - b);

	if (Q < W) {
		cout << 'A' << endl;
	}
	else cout << 'B' << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<int> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  sort(va.begin(), va.end(), greater<int>());
  int a, b;
  a = b = 0;
  for (int i = 0; i < va.size(); ++i) {
    if (i % 2 == 0) {
      a += va[i];
    } else {
      b += va[i];
    }
  }

  cout << a - b << '\n';
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef double db;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll qsm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n,m,k,rt;

int main(){
    scanf("%d%d",&n,&m);
    if(n==m) puts("Yes");
    else puts("No");
    return 0;
}
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 256
n = input()
k = int(input())
l = len(n)

dp0 = [[0] * (k + 1) for _ in range(l + 1)]
dp1 = [[0] * (k + 1) for _ in range(l + 1)]

for i in range(1, l + 1):
    dp0[i][0] = 1

dp1[0][0] = 1

for i in range(1, l + 1):
    for j in range(1, k + 1):
        m = int(n[i - 1])
        if m != 0:
            dp0[i][j] = dp0[i-1][j-1] * 9 + dp0[i-1][j] + dp1[i-1][j-1] * (m-1) + dp1[i-1][j]
            dp1[i][j] = dp1[i-1][j-1]
        else:
            dp0[i][j] = dp0[i-1][j-1] * 9 + dp0[i-1][j]
            dp1[i][j] = dp1[i-1][j]

print(dp0[l][k] + dp1[l][k])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

    int a[3][3];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j)
            cin >> a[i][j];
    }
    int n;
    cin >> n;
    for(int z = 0; z < n; ++z){
        int x;
        cin >> x;
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 3; ++j){
                if(a[i][j] == x)
                    a[i][j] = 0;
            }
        }
    }
    bool ans = 0;
    for(int i = 0; i < 3; ++i){
            if(a[i][0] == 0 && a[i][1] == a[i][0] &&  a[i][2] == a[i][0])
                ans = 1;
    }
    for(int i = 0; i < 3; ++i){
            if(a[0][i] == 0 && a[1][i] == a[0][i] &&  a[2][i] == a[0][i])
                ans = 1;
    }
    if(a[0][0] == a[1][1] && a[0][0] == 0 && a[2][2] == a[0][0])
        ans = 1;
    if(a[0][2] == a[1][1] && a[0][2] == 0 && a[2][0] == a[0][2])
        ans = 1;
    if(ans)
        cout << "Yes\n";
    else
        cout << "No\n";
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main() {
	char b;
	cin >> b;
	if(b=='A'){
		cout << 'T';
	}
	 else if(b=='T'){
	 	cout << 'A';
	 }
	 else if(b=='C'){
	 	cout << 'G';
	 }
	 else if(b=='G'){
	 	cout << 'C';
	 }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#define LL long long 
using namespace std;
map<string ,LL > mp;
int main()
{
	char s[12];
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%s",s);
		sort(s,s+10);
		mp[s]++;
	}
	LL sum=0;
	map<string ,LL> :: iterator it;
	for(it=mp.begin() ;it!=mp.end() ;it++)
	{
		LL k=it->second;
		sum+=k*(k-1)/2;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    VI x(N+1,0), y(N+1,0), t(N+1,0); REP(i,N) cin >> t[i+1] >> x[i+1] >> y[i+1];
    REP(i,N){
        if(abs(x[i+1]-x[i])+abs(y[i+1]-y[i]) > t[i+1]-t[i]){
            cout << "No" << endl;
            return 0;
        }
        if((abs(x[i+1]-x[i])+abs(y[i+1]-y[i]))%2 != (t[i+1]-t[i])%2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  ll X,ans=0;
  cin>>X;
  
  ans+=X/500*1000;
  ans+=(X%500)/5*5;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

const ll mod = 1e9 + 7;

ll binpow(ll a, long long b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}

vector<vector<int>> a;
vector<int> vis;

int dfs(int node) {
	vis[node] = 1;
	int ans = 1;
	for (auto child : a[node]) {
		if (vis[child] == 1) continue;

		ans += dfs(child);
	}
	return ans;
}
void solve() {

	int n , m;
	cin >> n >> m;

	a = vector<vector<int>>(n + 1);
	vis = vector<int> (n + 1 , 0);

	for (int i = 0 ; i < m ; i++) {
		int u , v;
		cin >> u >> v;

		a[u].pb(v) , a[v].pb(u);
	}

	int cc = 0;
	vector<int> cntnodes;

	for (int i = 1 ; i <= n ; i++)
	{
		if (vis[i] == 0)
		{
			int c = dfs(i);
			cntnodes.pb(c);
		}
	}

	sort(cntnodes.begin() , cntnodes.end());

	/*for (auto c : cntnodes)
		cout << c << " ";
	cout << "\n";*/

	int sz = cntnodes.size() , i = 0;

	while (i < sz) {

		if (cntnodes[i] == 0) {
			i++;
			continue;
		}

		int e = cntnodes[i];
		int j = i;

		while (j < sz) {
			cntnodes[j] -= e;
			if (cntnodes[j] == 0)
				i++;
			j++;
		}

		cc += e;
		if (cntnodes[sz - 1] == 0)
			break;
	}

	cout << cc << "\n";

}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
		solve();
	return 0;
}





Measured memory_bytes: 21068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main()
{
    ll N;
    cin >> N;
    ll max = N - 1;
    for (ll i = 1; N >= i * i; i++)
    {
        if ((N % i == 0) && (max > (i + N / i - 2)))
        {
            max = i + N / i - 2;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256