akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb			push_back
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define hastr(s, c)		((s).find(c) != string::npos)
template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}
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;
}
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
#ifndef	ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s, t; 
    cin >> s >> t;
    int cnt = 0; 
    for(int i = 0; i < SZ(s); ++i) {
    	if(s[i] != t[i])
    		cnt++;
    }
    cout << cnt; 
    return 0;
}


Measured memory_bytes: 3740
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}
/*nCk*/
ll nckused[1000][1000];
ll nckreached[1000][1000];
ll comb(ll n,ll k){
    if(n>1000) return (k==0 || k==n)?1:comb(n-1,k-1)+comb(n-1,k);
    if(nckreached[n][k]==1) return nckused[n][k];
    nckreached[n][k] = 1;
    nckused[n][k] = (n==1 || (k==0 || k==n) )?1:comb(n-1,k-1)+comb(n-1,k);
    return (n==1 || (k==0 || k==n) )?1:comb(n-1,k-1)+comb(n-1,k);
}
ll combination(ll n, ll a[n]){
    ll i,r=0;
    for(i=1;i<n;i++){
        if(a[i-1]==a[i]) r++;
    }
    if(r==0) return 6;
    if(r==1) return 3;
    return 1;
    // return comb(n,n-r);
}

int main(void){
    ll k,s,i,j,ans=0,a[3];
    scanf("%lld%lld",&k,&s);
    for(i=k;i>=0;i--){
        a[0]=i;
        // if(s-a[0]>2*k) break;
        for(j=i;j>=0;j--){
            a[1]=j;
            a[2]=s-i-j;
            if(a[2]<0) continue;
            if(a[2]>j) break;
            // printf("%lld %lld %lld\n",a[0],a[1],a[2]);
            ans+=combination(3,a);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

int n,k,q;
int a[2005];
int p;
int t[2005];
int b[2005];
int c[2005];
int pp,ppp;
int s;
int ans;
int sum;
int r;

int main(){
	cin>>n>>k>>q;
	ans=0x3f3f3f3f;
	for(int i=1;i<=n;i++)cin>>a[i];
	
	for(int i=1;i<=n;i++){
		p=0,s=0,sum=0;
		pp=0;ppp=0;
		for(int j=1;j<=n;j++)if(a[j]>=a[i])t[++p]=j;
		if(p<q)continue;
//		for(int j=1;j<=p;j++)cout<<t[j]<<" ";
//		cout<<endl;
		for(int j=1;j<=p+1;j++){
			if(t[j]==t[j-1]+1){
				s++;
			}
			else{
				pp=0;
				if(s>=k){
					for(int l=j-s;l<j;l++)b[++pp]=a[t[l]];
					sort(b+1,b+pp+1);
					for(int l=1;l<=s-k+1;l++)c[++ppp]=b[l];
				}
				s=1;
			}
		}
//		cout<<ppp<<endl;
//		for(int j=1;j<=ppp;j++)cout<<c[j]<<" ";
//		cout<<endl;
		sort(c+1,c+ppp+1);
		if(ppp>=q)ans=min(ans,c[q]-a[i]);
	}
	cout<<ans;
}

		

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<utility>
using namespace std;


int main(){
	int n, q;
	cin >> n >> q;
	pair<string, int> ps[200010];
	for(int i=0; i<n; i++){
		string s;
		int t;
		cin >> s >> t;
		ps[i] = pair<string, int>(s, t);
	}

	int p0 = 0;
	int p1 = n;
	int time = 0;
	for(;;){
		if(p0==p1) break;
		if(ps[p0].second > q){
			time += q;
			ps[p1] = pair<string, int>(ps[p0].first, ps[p0].second-q);
			p1++;
			p0++;
		}else{
			time += ps[p0].second;
			cout << ps[p0].first << " " << time << endl;
			p0++;
		}
		if(p0 > 100000){
			for(int i=0; i<100000; i++){
				ps[i] = ps[i+100000];
			}
			p0 -= 100000;
			p1 -= 100000;
		}
	}
	return 0;
}

Measured memory_bytes: 6676
x, y = map(int, input().split())

A = [1, 3, 4, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]

ok = False
if x in A and y in A:
    ok = True
elif x in B and y in B:
    ok = True

print('Yes' if ok else 'No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int main()
{
    fastio();
    int n; cin>>n; set <int> s; s.insert(n);
    int prev=s.size();
    for(;;)
    {
        if(n%2) n=3*n+1;
        else n>>=1;
        s.insert(n);
        if(prev==s.size()) {cout<<s.size()+1; return 0;}
        prev=s.size();
    }
    return 0;
}

Measured memory_bytes: 256
a = [int(input()) for i in range(1)]
n = a[0] 
works = [list(map(int, input().split())) for i in range(n)]
#print(works)
works = sorted(works, key=lambda x: x[1])

time = 0
flag = 0
#print(works[1][0])

for k in range(n):
  time += works[k][0]
  if time > works[k][1]:
    flag = 1
#  print(time)
    
if flag == 0:
  print('Yes')
else:
  print('No')
    

Measured memory_bytes: 55256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N;
	cin >> N;
	vector<int> C(N), V(N);
	for(int i = 0; i < N; i ++){
		cin >> V[i];
	}
	for(int i = 0; i < N; i ++){
		cin >> C[i];
	}
	ll ans = 0;
	for(int i = 0; i < N; i ++){
		if(V[i] - C[i] > 0)ans += V[i] - C[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N = 0;
	char Sn[3];
	int AC   = 0;
	int WA   = 0;
	int TLE  = 0;
	int RE   = 0;

	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%s", Sn);
		if (Sn[0] == 'A') {
			AC++;
		}else if (Sn[0] == 'W') {
			WA++;
		}
		else if (Sn[0] == 'T') {
			TLE++;
		}
		else {
			RE++;
		}
	}

	printf("AC x %d\n", AC );
	printf("WA x %d\n", WA );
	printf("TLE x %d\n", TLE);
	printf("RE x %d\n", RE );

	return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}



Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  string S;
  cin >> S;
  ll N = S.length();
  vector<ll> ans(N,0);
  ll a,b;
  ll i,j,point;
  ll state = 0;
  ll t=0;
  a=0;b=0;
  for(i=0;i<N;i++){
    if(state==0){
      if(S[i] == 'R'){
        t++;
        if(t%2==0){
          a++;
        }else{
          b++;
        }
      }else{
        state = 1;
        
        if(t%2==0){
          ans[i] += b;
          ans[i-1] += a;
        }else{
          ans[i] += a;
          ans[i-1] += b;
        }
        
        a = 0;
        b = 1;
        t = 1;
        point = i;
      }
    }else{
      if(S[i] == 'R'){
        state = 0;
        ans[point-1] += a;
        ans[point] += b;
        a=0;b=1;t=1;
      }else{
        t++;
        if(t%2==0){
          a++;
        }else{
          b++;
        }
      }
    }
  }
  ans[point-1] += a;
  ans[point] += b;
  for(i=0;i<N;i++){
    cout << ans[i] << ' ';
  }
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = acos(-1.0); //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    ll n, x;
    cin >> n >> x;
    ll a[n];
    rep(i, n) cin >> a[i];

    ll b[n][n];
    ll Min = LINF;

    rep(i, n) b[i][0] = a[i];

    rep(i, n) {

        rep(k, n - 1) {
            b[i][k + 1] = min(b[i][k], a[(n + i - (k + 1)) % n]);
        }
    }

    rep(k, n) {
        ll sum = k*x;

        rep(i, n) {
            sum += b[i][k];
        }
        Min = min(Min, sum);
    }

    cout << Min << endl;

    return 0;
}


Measured memory_bytes: 31488
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;
const ll MOD = 1'000'000'007;

#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
  	string s;
  	cin >> s;
  	ll n = s.size();
  	ll dp[n][13];
  	fill(dp[0],dp[0]+n*13,0LL);
  	for(ll i=0;i<10;i++){
      	if(s[0]=='?'){
        	dp[0][i]=1;
        }
    	else if((s[0]-'0')==i){
        	dp[0][i]=1;
        }else{
        	dp[0][i]=0;
        }
    }
  	for(ll i=1;i<n;i++){
      	if(s[i]=='?'){
          	for(ll j=0;j<13;j++){
            	for(ll k=0;k<10;k++){
                	dp[i][ (j*10+k)%13 ] = (dp[i][(j*10+k)%13] + dp[i-1][j] )%MOD;
                }
            }
        }else{
            for(ll j=0;j<13;j++){
            	dp[i][ (j*10+(s[i]-'0'))%13 ]=dp[i-1][j];
            }    
        }
    }

  	cout << dp[n-1][5];
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;
const ll MAX_N=131072;
const ll INF=1000000;
const ll MOD=1000000007;

int main(){
    string s;cin>>s;
    string t;
    for(auto v:s){
        if (v=='0') t+='0';
        else if(v=='1') t+='1';
        else {
            if (t.size()>=1) t.pop_back();
        }
    }
    cout<<t<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N;
  string s;
  cin >> N;
  cin >> s;
  bool flag = true;

  if (N %2 == 1) flag = false;

  for (int i=0; i<N/2; i++){
    //cout << s.at(i) << " " << s.at(N/2 + i) << endl;
    if (s.at(i) != s.at(N/2 + i)){
      flag = false;
      break;
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

}


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

const int MAXN = 2123456;
pair <int, int> v[MAXN];

int main () {

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i) { scanf ("%d", &v[i].first); v[i].second = i; }
	sort (v, v + n);
	reverse (v, v + n);
	
	for (int i = 0; i < n; ++i) {
		if (v[0].second == i)
			printf ("%d\n", v[1].first);
		else
			printf ("%d\n", v[0].first);
	}

	return 0;
}

Measured memory_bytes: 3200
public class Main {

	public static void main(String[] args) {
		solve_0000();
	}

	public static void solve_0000(){
		for (int i = 1;i<10;i++){
			for(int j=1;j<10;j++){
				System.out.println(i+"x"+j+"="+(i*j));
			}
		}
	}

}

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

int main() {

    std::priority_queue<int, std::vector<int>, std::greater<int> > pq;
    std::stack<int> st;
    int tmp;
    for (int i = 0; i < 10; i++) {
        std::scanf("%d", &tmp);
        if (pq.size() == 3) {
            if (pq.top() < tmp) {
                pq.pop();
                pq.push(tmp);
            }
        }
        else {
            pq.push(tmp);
        }

    }

    while(!pq.empty()) {
        st.push(pq.top());
        pq.pop();
    }
    for (int i = 0; i < 3; i++) {
        std::cout << st.top() << std::endl;
        st.pop();
    }


    return 0;


}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int main(){
  double W, H, x, y;
  cin>>W>>H>>x>>y;
  int ans=0;
  if(W/2==x && H/2==y) ans++;
  cout << setprecision(10)<< W*H/2;;
  cout << " " << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
from itertools import combinations

# 平方数　桁落ち対策
def is_square(n):
  m = int(round(n**0.5))
  return n == m*m
  
N, D = map(int, input().split())
A = [np.array(input().split(), dtype=np.int64) for _ in range(N)]
answer = 0
for x, y in combinations(A, 2):
  d = (pow((x-y),2)).sum()
  if is_square(d):
    answer += 1
print(answer)    
 

Measured memory_bytes: 12484
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

ll to_k(ll a,ll b){
	ll res = 0 ;
	ll ten = 1 ;
	while(a>0){
		res += ten*(a%b) ;
		ten *= 10 ;
		a /= b ;
	}
	return res ;
}

int main(){
	ll n ; cin >> n ;
	vector<pll> t(n) ;
	vll p(n) ;
	for(int i=0;i<n;i++){
		cin >> t.at(i).first >> t.at(i).second >> p.at(i) ;
	}
	vvll yoko((1<<n),vll(n,INF)),tate((1<<n),vll(n,INF)) ;
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			ll dx=INF,dy=INF ;
			for(int k=0;k<n;k++){
				if(i>>k&1) chmin(dx,abs(t.at(j).first-t.at(k).first)) ;
				if(i>>k&1) chmin(dy,abs(t.at(j).second-t.at(k).second)) ;
			}
			chmin(dx,abs(t.at(j).first)) ;
			chmin(dy,abs(t.at(j).second)) ;
			yoko.at(i).at(j) = dx*p.at(j) ;
			tate.at(i).at(j) = dy*p.at(j) ;
		}
	}
	ll mx = 1 ;
	vll ans(n+1,INF) ;
	for(int i=0;i<n;i++) mx *= 3 ;
	for(int i=0;i<mx;i++){
		string num = to_string(to_k(i,3)) ;
		reverse(all(num)) ;
		ll yo=0,ta=0 ;
		for(int j=0;j<num.size();j++){
			if(num.at(j)=='1') yo |= (1<<j) ;
			if(num.at(j)=='2') ta |= (1<<j) ;
		}
		ll cnt = 0 ;
		for(int j=0;j<num.size();j++) cnt += (num.at(j)!='0') ;
		ll sum = 0 ;
		for(int j=0;j<n;j++) sum += min(yoko.at(yo).at(j),tate.at(ta).at(j)) ;
		chmin(ans.at(cnt),sum) ;
	}
	for(int i=0;i<=n;i++) cout << ans.at(i) << endl ;
}


Measured memory_bytes: 13004
import math

while True:
    n = int(input())
    scores = [int(input()) for i in range(n)]
    scores.sort()

    if n == 0:
        break

    total = 0

    for i in range(1, n - 1):
        total += scores[i]
    
    print(math.floor(total / (n - 2)))


Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	sort(all(s));
	if(s=="abc") cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		

ll nn, q;
VC t(200005), d(200005);
string s;

bool dfsr(int m) {
	REP(i, q) {
		if (t[i] == s[m]) {
			if (d[i] == 'R')m++;
			else m--;
			if (m == nn)return false;
			if (m == -1)return true;
		}
	}
	return true;
}

bool dfsl(int m) {
	REP(i, q) {
		if (t[i] == s[m]) {
			if (d[i] == 'R')m++;
			else m--;
			if (m == -1)return false;
			if (m == nn)return true;
		}
	}
	return true;
}



int main() {

	
	cin >> nn >> q;
	cin >> s;
	
	REP(i, q) {
		char a, b;
		cin >> a >> b;
		t[i] = a;
		d[i] = b;
	}

	int ok = -1;
	int ng = nn;
	while (ng-ok > 1) {
		int mid = (ok + ng) / 2;
		if (dfsr(mid)) ok = mid;
		else ng = mid;
	}
	int ans = ng;

	ok = nn;
	ng = -1;

	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (dfsl(mid))ok = mid;
		else ng = mid;
	}
	

	cout << max(0, ans - ok) << endl;
}


Measured memory_bytes: 1024
/*
 * atcoder/dp_3rd/j.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 310;
int N;
int I[4] = {0}; // initial


void input() {
  cin >> N;
  int a;
  loop(n,0,N) {
    cin >> a;
    I[a]++;
  }
}

/*
 * i := すし1つ乗った皿の数
 * j := ... 2つ ...
 * k := ... 3つ ...
 * E(i,j,k) := 皿の状態がi,j,kである時にE(0,0,0)に移行するまでの試行回数の期待値
 * E(i,j,k) = (N-i-j-k)/N * E(i,j,k) + i/N * E(i-1,j,k) + j/N * E(i+1,j-1,k) + k/N * E(i,j+1,k-1) + 1
 * E(i,j,k) * N = (N-i-j-k) * E(i,j,k) + i * E(i-1,j,k) + j * E(i+1,j-1,k) + k * E(i,j+1,k-1) + N
 * (i+j+k) * E(i,j,k) = i * E(i-1,j,k) + j * E(i+1,j-1,k) + k * E(i,j+1,k-1) + N
 * E(i,j,k) = { i * E(i-1,j,k) + j * E(i+1,j-1,k) + k * E(i,j+1,k-1) + N } / i+j+k
 */
double E[MAX][MAX][MAX];

void solve() {
  loop(k,0,N+1) loop(j,0,N+1) loop(i,0,N+1) {
    if (i+j+k==0) { E[0][0][0] = 0; continue; }
    E[i][j][k] = N;
    if (i>0) E[i][j][k] += i * E[i-1][j][k];
    if (j>0) E[i][j][k] += j * E[i+1][j-1][k];
    if (k>0) E[i][j][k] += k * E[i][j+1][k-1];
    E[i][j][k] *= 1.0 / (i+j+k);
  }
  cout << E[I[1]][I[2]][I[3]] << endl;
}

int main() {
  cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 227584
#include <bits/stdc++.h>
using namespace std;
 
deque <long long> wyn;
deque <long long> v, rd;
map <int, int> M;
long long wynikmax, wynik;
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
       
        int n, k, kk, a, b;
        cin>>n>>k;
        kk=k;
        for(int i=1; i<=n; i++)
        {
                cin>>a>>b;
                if(M[a]==0)
                        rd.push_back(a);
                if(M[a]<b)
                {
                        if(M[a]!=0)
                                v.push_back(M[a]);
                        M[a]=b;
                }
                else
                        v.push_back(b);
        }
        sort(v.begin(), v.end());
        for(int i=0; i<rd.size(); i++)
        {
                wyn.push_back(M[rd[i]]);
        }
        sort(wyn.begin(), wyn.end());
        long long dod=1;
        for(int i=wyn.size()-1; i>=0; i--)
        {
                wyn[i]+=dod;
                dod+=2;
                //cout<<wyn[i]<<' ';
        }
        for(int i=wyn.size()-1; i>=0; i--)
        {
                k--;
                wynikmax+=wyn[i];
                if(k==0)
                        break;
        }
        for(int i=v.size()-1; k>0; k--, i--)
        {
                wynikmax+=v[i];
        }
        //cout<<wynikmax<<' ';
       
        int ii=wyn.size()-(min(kk-1, (int)wyn.size()-1))-1;
        kk-=wyn.size();
        kk=max(0, kk);
        //cout<<"                    "<<kk<<endl;
        int jj=v.size()-kk-1;
        wynik=wynikmax;
        //cout<<ii<<' '<<jj<<endl;
       
        for(;;ii++, jj--)
        {
                if(ii==wyn.size() || jj==-1)
                        break;
                wynik-=wyn[ii];
                wynik+=v[jj];
                //cout<<ii<<' '<<jj<<' '<<wynik<<endl;
                wynikmax=max(wynikmax, wynik);
        }      
       
        cout<<wynikmax<<endl;
}

Measured memory_bytes: 6656
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


int main(void) {
    int vs, es;
    cin >> vs >> es;
    vector<int> cnts(vs+1);

    for(int i = 0; i < es; i++) {
        int v1, v2;
        cin >> v1 >> v2;
        cnts[v1]++;
        cnts[v2]++;
    }

    bool ans = 1;
    for(int cnt: cnts) {
        if(cnt%2) ans = 0;
    }
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s, t, u;
  cin >> s >> t >> u;
  if (s.back() == t[0] && t.back() == u[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

def main():
    K = int(input())
    num_list = np.array([i for i in range(1,K+1)])
    print(np.sum(np.gcd.outer(np.gcd.outer(num_list,num_list),num_list)))

main()


Measured memory_bytes: 89432
N = int(input())
#print(N)

S = [input() for i in range(N)]
#print(S)

ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    if S[i] == 'AC':
        ac += 1
    elif S[i] == 'WA':
        wa += 1
    elif S[i] == 'TLE':
        tle += 1
    elif S[i] == 'RE':
        re += 1

print('AC x' , ac)
print('WA x' ,wa)
print('TLE x' ,tle)
print('RE x' , re)

Measured memory_bytes: 16332
#include <iostream>

using namespace std;

int N;
long long int MOD = 1000000007;

int main(void) {

	cin >> N;

	long long int num1 = 1;
	for (int i = 1; i <= N; i++) {
		num1 *= 10;
		num1 %= MOD;
	}

	long long int num2 = 1;
	for (int i = 1; i <= N; i++) {
		num2 *= 9;
		num2 %= MOD;
	}

	long long int num3 = 1;
	for (int i = 1; i <= N; i++) {
		num3 *= 8;
		num3 %= MOD;
	}

	long long int ans = 0;

	ans = (num1 - num2 * 2 + num3 + MOD * 3) % MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#define MAX 100000

int partition(int [],int , int);
int main(){
  int A[MAX],n,i,same;
    scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
    same=partition(A,0,n-1);
    for(i=0;i<n;i++){
      if(i==same){
        printf("[%d] ",A[same]);
        continue;
      }
      if(i==n-1  )printf("%d\n",A[i]);
      else printf("%d ",A[i]);
    }
    return 0;
      }

int partition(int A[],int p,int r)
{
  int x,i,j,a;

  x=A[r];
  i=p-1;

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      a=A[j];
      A[j]=A[i];
      A[i]=a;
    }
  }
    a=A[i+1];
    A[i+1]=A[r];
    A[r]=a;

    return i+1;
}




Measured memory_bytes: 2108
N = gets.to_i
A = gets.split.map(&:to_i)

sum = 0
A.each_with_index do |a, i|
  if i.even?
    sum += a
  else
    sum -= a
  end
end

fa = sum

ans = [fa]

A[0..-2].each do |a|
  ans << 2 * a - ans.last
end

puts ans.join(' ')


Measured memory_bytes: 14084
#include <ctype.h>
#define max(a, b)   (((a) > (b)) ? (a) : (b))       /* ２個の値の最大値 */
#define min(a, b)   (((a) < (b)) ? (a) : (b))       /* ２個の値の最小値 */
#define ENTER       printf("\n")                    /* 改行プリント */
int DBG = 1;                                        /* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
    int     p,a,b,c,i,j,k,n,m,x,y,ans = 0;
    char    str[256];

    scanf("%d %d", &p, &c);
    m = 0;
    for(i=0;i<c;i++) {
        scanf("%d", &a);
        m += a;
    }

    ans = m / (p+1);
    if (m % (p+1) != 0) ans++;

    printf("%d\n", ans);


    return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
const int INF = 1e9;
const int MO = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define rt return
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)
#define s second
#define f first

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    SCIN(str);
    if(str.back() == str.front()){
        COUT(((str.size()-3)%2 == 0?"Second":"First"));
    }else{
        COUT((str.size()-2)%2 == 0?"Second":"First");
    }
}


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


bool isPrime(int n){
	if(n == 2) return true;
	for(int i = 2;i <= sqrt(n);i++)
		if(!(n%i)) return false;
	return true;
}


int main(){
	int n;
	int ans;
	while(ans = 0, cin >> n, n){
		for(int i = n+1;i <= 2*n;i++){
			if(isPrime(i)) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
n, t = gets.split.map(&:to_i)
ts = gets.split.map(&:to_i)
sum = 0
previous = ts.shift # たぶんたいてい0
ts.each do |now|
  if previous + t >= now
    # まだお湯が出ている
    sum += now - previous
  else
    # お湯が途中で止まっている
    sum += t
  end
  previous = now
end
puts sum + t # 最後押してからはt秒間必ず流れる


Measured memory_bytes: 16004
use std::io;
use std::str::FromStr;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    let mut nums = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (A, P) = (nums.next().unwrap(), nums.next().unwrap());

    let ans = (A*3 + P) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  int A[3][3], B[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> A[i][j];
      B[i][j] = 0;
    }
  }
  int N;
  cin >> N;
  for(int t = 0; t < N; t++){
    int b;
    cin >> b;
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        if(A[i][j] == b){
          B[i][j] = 1;
        }
      }
    }
  }
  if(B[0][0] == 1 && B[1][0] == 1 && B[2][0] == 1)
    cout << "Yes";
  else if(B[0][1] == 1 && B[1][1] == 1 && B[2][1] == 1)
    cout << "Yes";
  else if(B[0][2] == 1 && B[1][2] == 1 && B[2][2] == 1)
    cout << "Yes";
  else if(B[0][0] == 1 && B[0][1] == 1 && B[0][2] == 1)
    cout << "Yes";
  else if(B[1][0] == 1 && B[1][1] == 1 && B[1][2] == 1)
    cout << "Yes";
  else if(B[2][0] == 1 && B[2][1] == 1 && B[2][2] == 1)
    cout << "Yes";
  else if(B[0][0] == 1 && B[1][1] == 1 && B[2][2] == 1)
    cout << "Yes";
  else if(B[2][0] == 1 && B[1][1] == 1 && B[0][2] == 1)
    cout << "Yes";
  else cout << "No";
           
  return 0;
}

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

struct UnionFind{
    vector<int> par;
    vector<int> rank;

    UnionFind(int N):par(N),rank(N){
        for(int i = 0;i < N;i++){
          par[i] = i;
          rank[i] = 0;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)return;
        if(rank[x] > rank[y]){
          par[y] = rx;
        }
        if(rank[x] < rank[y]){
          par[rx] = ry;
        }else{
          par[ry] = rx;
          if(rank[x] == rank[y]){
            rank[rx]++;
          }
        }
    }

    bool same(int x,int y){
      return root(x) == root(y);
    }
};

int main(){
 int N,M;
 cin >> N >> M;
 vector<int> P(N);
 UnionFind tree(N);
 for(int i = 0;i < N;i++){
   cin >> P[i];
 }
 for(int i = 0;i < M;i++){
   int a,b;cin >> a >> b;
   tree.unite(a-1,b-1);
 }
 int ans = 0;
 for(int i = 0;i < N;i++){
   if(tree.same(i,P[i]-1)){
     ans++;
   }
 }
 cout << ans << endl;
}

Measured memory_bytes: 1408
from collections import Counter

N, K, Q = map(int, input().split())
a = [int(input()) for _ in range(Q)]

ju = [0 for _ in range(N)]

for i in range(Q):
    ju[a[i]-1] += 1

# print(ju)
for v in ju:
    if K-Q+v <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 9052
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int A[200], M, N;

	cin >> N >> M;

	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	sort(A, A + N);

	int ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (A[i] * 4 * M >= sum) {
			ans++;
		}
	}
	if (ans >= M) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pa;
const ll MOD = 1e9 + 7;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//-----------------------------------------------------------//

int main() {
    init();
    ll N, A, B;
    cin >> N >> A >> B;
    if (A > B)
        cout << 0 << endl;
    else if (N == 1 && A != B)
        cout << 0 << endl;
    else if (A == B)
        cout << 1 << endl;
    else {
        ll m, M;
        m = B + A * (N - 1);
        M = A + B * (N - 1);
        cout << M - m + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>

using namespace std;

int main(int argc, const char * argv[]) {
    vector<long long> a;
    unsigned long long K;
    cin >> K;
    long long i;
    for(i=1;i<10;i++) a.push_back(i);
    while(true){
        if(K<=a.size()){
            cout << a[K-1] << endl;
            return 0;
        }
        K -= a.size();
        vector<long long> old;
        swap(a,old);
        for(long long k=0;k<old.size();k++){
            for(long long j=-1; j<=1;j++){
                long long d = old[k]%10 + j;
                if(d<0 || d>9) continue;
                a.push_back(old[k]*10+d);
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <cassert>
#include <complex>
#include <functional>
 
using namespace std;
 
typedef long long ll;

const int md = 1e9 + 7;

const int N = 1e5 + 7;

int f[N];

int mul(int a, int b) {
  return ((ll)a * b) % md;
}

int power(int a, ll b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int inv(int a) {
  return power(a, md - 2);
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  f[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
  }
  int n;
  cin >> n;
  vector <int> x(n);
  for (int i = 0; i < n; ++i) cin >> x[i];
  int ans = 0;
  int sum = 0;
  for (int i = 0; i + 1 < n; ++i) {
    sum += mul(f[i], inv(f[i + 1]));
    sum %= md;
    int d = x[i + 1] - x[i];
    ans += mul(d, sum);
    ans %= md;
  }
  ans = mul(ans, f[n - 1]);
  cout << ans << '\n';
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
		String S = scan.next();
		int length = S.length();
		char[] s = S.toCharArray(); 
		
		if(K >= length) {
			System.out.println(S);
		}else {
			for(int i = 0; i < K; i++) {
				System.out.print(s[i]);
			}
			System.out.print("...");
		}
		
	}

}


Measured memory_bytes: 35748
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>s;
    if(Size(s)==3)reverse(all(s));
    Cout(s);
    return 0;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int n;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    cin>>n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int maxa = *max_element(all(a));
    int mina = *min_element(all(a));

    if (maxa == mina) {
        if (n - 1 == maxa or n / 2 >= maxa) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }

    if (maxa - mina > 1) {
        cout << "No" << endl;
        return 0;
    }

    int s = 0, ss = 0;
    rep(i, n) if(mina == a[i]) {
        s++;
    } else {
        ss++;
    }

    if (ss > 1 and ss / 2 + s == maxa) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    
    return 0;
}


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

typedef long long LL;

const int N = 200005;

int n, a[N], d[N], tot;

int head[N], numE = 0, f[N], dat[N << 2], ans[N];

struct E{
	int next, v;
} e[N << 1];

void inline add(int u, int v) {
	e[++numE] = (E) { head[u], v };
	head[u] = numE;
}

void inline pushup(int p) {
	dat[p] = max(dat[p << 1], dat[p << 1 | 1]);
}

void change(int p, int l, int r, int x, int k) {
	if (l == r) { dat[p] = k; return; }
	int mid = (l + r) >> 1;
	if (x <= mid) change(p << 1, l, mid, x, k);
	else change(p << 1 | 1, mid + 1, r, x, k);
	pushup(p);
}

int query(int p, int l, int r, int x, int y) {
	if (x > y) return 0;
	if (x <= l && r <= y) return dat[p];
	int mid = (l + r) >> 1, res = 0;
	if (x <= mid) res = max(res, query(p << 1, l, mid, x, y));
	if (mid < y) res = max(res, query(p << 1 | 1, mid + 1, r, x, y));
	return res;
}

void dfs(int u, int last) {
	f[u] = query(1, 1, tot, 1, a[u] - 1) + 1;
	ans[u] = max(f[u], ans[last]);
	int t = query(1, 1, tot, a[u], a[u]);
	if (f[u] > t) change(1, 1, tot, a[u], f[u]);
	for (int i = head[u]; i; i = e[i].next) {
		int v  = e[i].v;
		if (v == last) continue;
		dfs(v, u);
	}
	if (f[u] > t) change(1, 1, tot, a[u], t);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a + i), d[i] = a[i];
	sort(d + 1, d + 1 + n);
	tot = unique(d + 1, d + 1 + n) - d - 1;
	for (int i = 1; i <= n; i++) a[i] = lower_bound(d + 1, d + 1 + tot, a[i]) - d;
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d%d", &u, &v);
		add(u, v); add(v, u);
	}	
	dfs(1, 0);
	for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  vi vec(3); rep(i, 3) std::cin >> vec[i];
  sort(rng(vec));
  int add = vec[2]-vec[1];
  int ans = add;
  vec[0] += add, vec[1] += add;
  if (vec[0] != vec[2]) {
    add = (vec[2] - vec[0] + 1) / 2;
    ans += add;
    vec[0] += add * 2;
    if (vec[0] > vec[2]) ans++;
  }
  std::cout << ans << "\n";
}


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

int main(){
    long long n,x,a[2020],ans,sum,b[2020][2020];
    cin>>n>>x;
    for(int i=0;i<n;i++) cin>>a[i];
    ans = 2000*1e9;
    for(int i=0;i<n;i++){
        sum=0;
        for(int j=0;j<n;j++){
            if(i==0) b[i][j]=a[j];
            else b[i][j] = min(b[i-1][j],a[(j-i+n)%n]);
            sum += b[i][j];
        }
        ans = min(ans,sum+i*x);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
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;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  char x,y; cin>>x>>y;

  if(x==y){
    cout<< "="<<"\n";
    return;
  }

  cout<< ( x<y ? "<" : ">" )<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Q;
    cin >> Q;
    rep(i, Q) {
        int A, B;
        cin >> A >> B;

        int C = sqrt(A * B);
        int ans = 2 * C - 1;
        if (C * C == A * B && A != B) ans--;
        if (C * (C + 1) >= A * B) ans--;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=(s.size()-1)/2;
	while(true){
		bool ok=true;
		for(int i=0;i<ans;i++){
			if(s[i]!=s[i+ans])ok=false;
		}
		if(ok)break;
		ans--;
	}
	cout<<ans*2<<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  if a[i]<0:
    cnt+=1
if min(a)>=0:
  print(sum(a))
  exit()
b=[abs(a[i]) for i in range(n)]
s=sum(b)
if cnt%2==0:
  print(s)
  exit()
ans=-10**18
for i in range(n):
  ans=max(ans,s-2*b[i])
print(ans)


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;


int main() {
	make(n);
	makev(v, n);
	VI ans;
	while (ans.size() != n) {
		VI w = v;
		int pos = -1;
		FOR(i,0,w.size()) {
			if (w[i] == i+1) pos = i;
		}
		if (pos == -1) {
			printf("-1\n");
			return 0;
		}
		ans.pb(pos+1);
		v.clear();
		FOR(i,0,pos) v.pb(w[i]);
		FOR(i,pos+1,w.size()) v.pb(w[i]);
	}
	FOR(i,0,n) {
		printf("%d\n", ans[n-1-i]);
	}
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main() {
    string c;
    cin >> c;
    if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o") {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// include headers{{{
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*}}}*/
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<int> l(m), r(m);
    rep (i, m) {
        cin >> l[i] >> r[i];
        l[i]--; r[i]--;
    }

    vector<int> allowed_cards(n+1);
    rep (i, m) {
        // L_i, L_{i+1}, ..., R_i
        allowed_cards[l[i]]++;
        allowed_cards[r[i]+1]--;
    }

    int ans = 0;
    int ptr = 0;
    rep (i, n) {
        ptr += allowed_cards[i];
        if (ptr == m) ans++;
    }
        
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1408