akhauriyash/Code-Regression huggingface dataset:
my $X = <STDIN>;
my %h;
$h{1} = '';
foreach my $i (2..31) {
        foreach (2..31) {
                my $v = $_**$i;
                if ($v < 1001){
                        $h{$v} = '';
                } else {
                        last;
                }
        }
}
my $vv = 1;
foreach (sort {$a <=> $b} keys %h) {
        if ($_ <= $X) {
                $vv = $_;
        } else {
                last;
        }
}
print $vv;

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
int b[N];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, sum = 0;
	cin >> n;
	for(int i = 0; i < n - 1; i++) cin >> b[i];

	sum = b[0];
	for(int i = 1; i < n - 1; i++) sum += min(b[i-1],b[i]);
	sum += b[n-2];

	cout << sum;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
R, L, K = map(int, input().split())
V = [0]*(R*L)
for _ in range(K):
    r, c, v = map(int, input().split())
    V[(c-1)*R+(r-1)] = v
A, B, C, D = [[0]*(R+1) for _ in range(4)]
for i in range(L):
    for j in range(R):
        A[j] = max(A[j-1],B[j-1],C[j-1],D[j-1])
        v = V[i*R+j]
        if v != 0:
            D[j], C[j], B[j] = max(C[j]+v,D[j]), max(B[j]+v,C[j]), max(A[j]+v,B[j])
print(max(A[-2],B[-2],C[-2],D[-2]))

Measured memory_bytes: 145748
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <string.h>
#include <set>
#include <cstdlib>
#include <iostream>
#include <bits/stdc++.h>
#define pii pair<int,int> 
#define ll long long int 
#define sl(n) scanf("%lld",&n)
#define s(n) scanf("%d",&n)
#define f(i,n) for(int i=0;i<n;++i)
#define fo(i,n) for(int i=1;i<=n;++i)
#define fnm(n,m) for(ll i=n;i<m+1;++i)
#define pb push_back
#define pf printf
#define F first
#define S second
#define srt(v) sort(v.begin(),v.end());
#define srtc(v,cmp) sort(v.begin(),v.end(),cmp);
#define srta(v,n) sort(v,v+n);
const ll LL_INF=0x3f3f3f3f3f3f;
const ll MOD=1000000007;


using namespace std;


int T;
int h,m;
string arr[1005];

ll dp[1002][1002];

ll gen(int n,int k){
    if(n==h||k==m)return 0;
    if(arr[n][k]=='#')return 0;
    if(n==h-1&&k==m-1)return 1;
    ll &ret = dp[n][k];
    if(~ret)return ret;
    ret=gen(n+1,k)%MOD;
    ret+=gen(n,k+1)%MOD;
    return ret%MOD;
    
}

int main(){
    // pf("\t\t\t***************************************************************************\n\n");
    // pf("\t\t\t***************************************************************************\n\n");
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    s(h);
    s(m);
    memset(dp,-1,sizeof dp);
    f(i,h)cin>>arr[i];
    string temp="";
    f(i,m)temp+="#";
    arr[h]=temp;
    pf("%lld\n",gen(0,0));
    return 0;
} 

Measured memory_bytes: 9216
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int ans = K;
        
        for(int i = 1; i<N; i++){
            ans *= (K-1);
        }
        System.out.println(ans);
    }
}


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

#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1){ans = (ans*a);}b>>=1;a=a*a;}return ans;}
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}

int main() {
   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   // cout << fixed << setprecision(10);
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   ll sum=0;
   if(k<=a){
       cout<<k<<endl;
       return 0;
   }
   if(k<=(a+b)){
       cout<<a<<endl;
       return 0;
   }
   ll d=k-(a+b);
   cout<<(a-d)<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<functional>
long long const p=1e9+7;
int main(){
    int n,m;
    long long a[1001]={},b[1001]={};
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    for(int j=0;j<m;j++)scanf("%lld",&b[j]);
    std::sort(a,a+n,std::greater<int>());
    std::sort(b,b+m,std::greater<int>());
    for(int i=1;i<n;i++){
        if(a[i-1]==a[i]){
            printf("0");
            return 0;
        }
    }
    for(int j=1;j<m;j++){
        if(b[j-1]==b[j]){
            printf("0");
            return 0;
        }
    }
    int nowi=0,nowj=0;
    long long ans=1;
    for(int num=n*m;num>0;num--){
        if(nowi<n && a[nowi]>num)nowi++;
        if(nowj<m && b[nowj]>num)nowj++;
        if(a[nowi]!=num&&b[nowj]!=num){
            long long choice=nowi*nowj-(n*m-num);
            ans=(ans*choice)%p;
        }else{
            long long choicei=(a[nowi]==num)?1:nowi,
                      choicej=(b[nowj]==num)?1:nowj;
            ans=(ans*choicei*choicej)%p;
        }
    }
    printf("%lld",ans%p);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){

  int a, b, c;

  scanf("%d %d %d",&a, &b, &c);

  if (a > b && b > c)
    printf("%d %d %d\n",c,b,a);
  else if (a < b && b < c)
    printf("%d %d %d\n",a,b,c);
  else if (a < b && b > c && a > c)
    printf("%d %d %d\n",c,a,b);
  else if (a < b && b > c && a < c)
    printf("%d %d %d\n",a,c,b);
  else if (a > b && b < c && a > c)
    printf("%d %d %d\n",b,c,a);
  else if (a > b && b < c && a < c)
    printf("%d %d %d\n",b,a,c);
  else if (a > b && b == c)
    printf("%d %d %d\n",b,c,a);
  else if (a > b && a == c)
    printf("%d %d %d\n",a,c,b);
  else if (a == b && b < c)
    printf("%d %d %d\n",a,b,c);
  else if (a < b && a == c)
    printf("%d %d %d\n",a,c,b);
  return 0;
}

Measured memory_bytes: 596
package main

import "fmt"

func payment(n int) int {
	if n % 1000 != 0 {
		return 1000 - n % 1000
	}
	return 0
}

func main() {
	var n int
	fmt.Scan(&n)
	ans := payment(n)
	fmt.Println(ans)
}

Measured memory_bytes: 1768
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#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)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

//Sieve sieve(1e6);
//auto f = sieve.factor(x);
// for(auto p:f){
//   p.firstは約数
//   p.secondは割れる回数
// }


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    Sieve sieve(10000005);
    for(int i=1;i<=n;i++){
        auto v = sieve.factor(i);
        ll c = 1;
        for(auto p:v){
            c*=(p.second+1);
        }
        //cout << c << endl;
        ans += c*i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 46124
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

const ll MOD = 1000000007;
const ll INF = 100000;

int n, m;

int main(void){
    cin >> n;
    int x1, x2 = 0, y1, y2 = 0, t1, t2 = 0;
    for (int i = 0; i < n; i++){
        cin >> t1 >> x1 >> y1;
        int d = abs(x1 - x2) + abs(y1 - y2);
        if (t1 - t2 < d || (t1 - t2 - d) % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
        t2 = t1; x2 = x1; y2 = y1;
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
  int n, k;
  scanf("%d\n%d", &n, &k);

  int sum=1;
  for (int i=0; i<n; i++) {
    sum += (sum<k)  ? sum
                    : k;
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
n=int(input())-1
A=list(map(int,input().split()))
i=0
for j in range(n):
 if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1
A[i],A[n]=A[n],A[i]
print(" ".join(map(str,A[:i]))+" ["+str(A[i])+"] "+" ".join(map(str,A[i+1:])))


Measured memory_bytes: 16384
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,popcnt,sse4.1,sse4.2,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 105, mod = 1e9 + 7;
const ld tau = 6.28318530717958647692;
const ld A = 2.5*tau - 20.;
const ld B = 5.0*tau - 20.;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define y1 orz
int x1, n, y1, m, k;
vpi a;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> x1 >> y1 >> n >> m >> k;
	n -= x1, m -= y1;
	a.resize(k);
	for(auto &i : a) cin >> i.first >> i.second, i.first -= x1, i.second -= y1;
	if(n < 0) {
		n *= -1;
		for(auto &i : a) i.first *= -1;
	}
	if(m < 0) {
		m *= -1;
		for(auto &i : a) i.second *= -1;
	}
	map<int, int> xty, ytx;
	{
		vpi t;
		for(auto &i : a) {
			if(i.first >= 0 && i.first <= n && i.second >= 0 && i.second <= m) t.pb(i);
		}
		a = t;
		for(auto i : a) {
			xty[i.first] = i.second;
			ytx[i.second] = i.first;
		}
	}
	if(a.empty()) return cout << fixed << setprecision(15) << 100.*(n+m), 0;
	if(n == 0 || m == 0) return cout << fixed << setprecision(15) << 100.*(n+m) + a.size()*B, 0;
	vi lis, ux, uy;
	sort(all(a));
	vi cur;
	for(auto &i : a) {
		auto it = lower_bound(all(lis), i.second);
		if(it == lis.end()) {
			lis.pb(i.second), it = --lis.end();
			ux.pb(ux.size()?ux.back():0);
			uy.pb(uy.size()?uy.back():0);
		} else {
			*it = i.second;
		}
		int p = it-lis.begin();
		if(p) {
			ux[p] |= ytx[lis[p]]-ytx[lis[p-1]]>1;
			uy[p] |= lis[p]-lis[p-1]>1;
		}
		cur.pb(p+1);
	}
	vi rlis;
	for(int t = lis.size(), i = a.size(); i-- && t;) {
		if(t == cur[i]) rlis.pb(a[i].second), t--;
	}
	reverse(all(rlis));
	lis = rlis;
	int border = 0;
	pi pos;
	for(auto i : a) {
		if(!binary_search(all(lis), i.second)) continue;
		if(i.first==0 || i.first==n || i.second==0 || i.second==m) pos = i, border = 1;
	}
	if(!border || ((pos.first == 0 || pos.first == n)?ux.back():uy.back())) return cout << fixed << setprecision(15) << 100.*(n+m) + lis.size()*A, 0;
	//if((ytx[lis.back()]!=n&&lis.back()!=m)||(ytx[lis[0]]&&lis[0])) lis.pb(0);
	cout << fixed << setprecision(15) << 100.*(n+m) + ((int)lis.size()-(lis.size()%2==0))*A + B*(lis.size()%2==0), 0;
}


Measured memory_bytes: 26836
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define sc(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pl;
typedef vector<int>	vi;
typedef  set<int>	s;
typedef map<int,int>	m;
int main()
{

priority_queue <int> p;
int a,b;
cin>>a>>b;
int arr[a];
for(int i=0;i<a;i++)
 cin>>arr[i];
for(int i=0;i<a;i++)
{
    if(p.size()>b)
     p.pop();
    p.push(arr[i]);
}
if(p.size()>b)
p.pop();
int count=0;
while(p.size()>0)
{
    count+=p.top();
    p.pop();
}
cout<<count;
 

return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(c<b){
		cout<<c*a/b<<endl;
		return 0;
	}
	long long ans1=(b-1)*a/b;
	if(((b-1)*a%b+b*a)/b>a){
		long long u=c/b*b-1;
		cout<<max(a*c/b+a*(c/b),a*u/b+a*(u/b))<<endl;
	}else{
		cout<<ans1<<endl;
	}
} 

Measured memory_bytes: 3564
import java.util.*;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		List<Integer> pi = new ArrayList<>();

		for(int i=0; i<N; i++){
			pi.add(sc.nextInt());
		}

		Collections.sort(pi);

		int ans = 0;

		for(int i=0; i<K; i++){
			ans += pi.get(i);
		}

		System.out.println(ans);
		return;
	}
}


Measured memory_bytes: 39048
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll n,m,s;
vector <pair<ll,pair<ll,ll>>> vec[55];
vector <pair<ll,ll>> bank;
ll dp[55][55*55*55];
ll flg[55][55*55*55];
ll ma = 55*55;
void dijkastra()
{
    set < pair<ll,pair<ll,ll>> > pq;
    
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=ma;j++)
        {
            dp[i][j] = 1e18;
        }
    }
    s = min(s,ma);
    dp[1][s] = 0;
    
    pq.insert({0,{s,1}});
    memset(flg,-1,sizeof(flg));
    while(pq.size()>0)
    {
        auto p = *pq.begin();
        pq.erase(p);
        flg[p.second.second][p.second.first] = 1;
     //   cout<<p.first<<" "<<p.second.first<<" "<<p.second.second<<endl;
        for(auto v:vec[p.second.second])
        {
         //   cout<<v.first<<endl;
            ll i = 0;
            while(1)
            {
                ll st = p.second.first-v.second.first + i*bank[p.second.second-1].first;
                if(st>(ma))break;
                if(st>=0)
                {
       //             cout<<st<<endl;
                   if(flg[v.first][st]==-1){
                    if(dp[v.first][st] > dp[p.second.second][p.second.first]+v.second.second + i*bank[p.second.second-1].second)
                    {
             //           cout<<v.first<<"*"<<st<<endl;
                        if(pq.find({dp[v.first][st],{st,v.first}})!=pq.end())
                        {
                            pq.erase({dp[v.first][st],{st,v.first}});
                        }
                        dp[v.first][st] = dp[p.second.second][p.second.first]+v.second.second + i*bank[p.second.second-1].second;
                        pq.insert({dp[v.first][st],{st,v.first}});    
                    }
                   }
                }
                i++;
            }
        }
    }

    ll ans[n+1];
    for(ll i=0;i<=n;i++)ans[i] = 1e18;

    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=ma;j++)
        {
            ans[i] = min(ans[i],dp[i][j]);
        }
    }
    for(ll i=2;i<=n;i++)
    {
        cout<<ans[i]<<endl;
    }

}

int main()
{	
    std::ios_base::sync_with_stdio(0);
	  cin.tie(0);
	  cout.tie(0);
    
    cin>>n>>m>>s;
    
    for(ll i=0;i<m;i++)
    {
        ll u,v,a,b;
        cin>>u>>v>>a>>b;
        
        a = min(ma,a);
        vec[u].push_back({v,{a,b}});
        vec[v].push_back({u,{a,b}});
    }

    for(ll i=0;i<n;i++)
    {
        ll c,d;
        cin>>c>>d;
        bank.push_back({c,d});
    }
    dijkastra();
}

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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long int
#define mod 1000000007


void solve()
{
    int x;
    cin>>x;
    if(x)
        cout<<0;
    else
        cout<<1;
}

int main()
{
    sync;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}







Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return (n%mod)*(factorial(n-1)%mod);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	return b ? gcd(b,a%b) : a;
}



/*最小公倍数*/

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/
//組み合わせの数nCrを計算
    ll calcNumOfCombination(ll n, ll r){
        return factorial(n) / (factorial(r) * factorial(n-r));
    }

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    string s;
    cin>>s;
    string rs;
    ll n=s.size();
    string a=s.substr(0,(n-1)/2);
    string b=s.substr((n+3)/2-1,n-(n+3)/2+1);
    string ra,rb;
    rs=s;
    ra=a;
    rb=b;
    reverse(all(rs));
    reverse(all(ra));
    reverse(all(rb));
    if(ra==a&&rb==b&&rs==s){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 998244353;

struct lazy_segtree {
  int n;
  vector<ll> data;
  vector<ll> lazy;
  vector<bool> lazyFlag;

  lazy_segtree(const int s) {
    init(s);
  }

  lazy_segtree(const int s, const ll u) {
    init(s);
    for (int i = 0; i < s; i++) {
      data[i+n-1] = u;
    }
    for (int i = n-2; i >= 0; i--) {
      data[i] = data[i*2+1] + data[i*2+2];
    }
  }

  lazy_segtree(const vector<ll> &v) {
    int s = v.size();
    init(s);
    for (int i = 0; i < s; i++) {
      data[i+n-1] = v[i];
    }
    for (int i = n-2; i >= 0; i--) {
      data[i] = data[i*2+1] + data[i*2+2];
    }
  }

  void init(const int s) {
    n = 1;
    while (n < s) n <<= 1;
    data = vector<ll>(2*n-1);
    lazy = vector<ll>(2*n-1);
    lazyFlag = vector<bool>(2*n-1);
  }

  void evaluate(int p, int a, int b) {
    if (lazyFlag[p]) {
      data[p] = lazy[p];
      if (b - a > 1) {
        lazy[p*2+1] = lazy[p];
        lazy[p*2+2] = lazy[p];
        lazyFlag[p*2+1] = true;
        lazyFlag[p*2+2] = true;
      }
      lazy[p] = 0;
      lazyFlag[p] = false;
    }
  }

  void update(int l, int r, ll v, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init

    // evaluate lazy value
    evaluate(p, a, b);

    if (r <= a || b <= l) return; // out of range
    if (l <= a && b <= r) { // fully covered
      lazy[p] = v;
      lazyFlag[p] = true;
      evaluate(p, a, b);
    }
    else {
      update(l, r, v, p*2+1, a, (a + b) / 2); // left
      update(l, r, v, p*2+2, (a + b) / 2, b); // right
      data[p] = data[p*2+1] + data[p*2+2]; // update
    }
    return;
  }

  ll query(int l, int r, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init
    if (r <= a || b <= l) return 0; // out of range

    // evaluate lazy value
    evaluate(p, a, b);

    if (l <= a && b <= r) return data[p];// fully covered

    int vl = query(l, r, p*2+1, a, (a + b) / 2); // left
    int vr = query(l, r, p*2+2, (a + b) / 2, b); // right
    return vl + vr;
  }
};

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

  ll n, q;
  cin >> n >> q;
  n -= 2;
  vector<Pii> query(q);
  for (auto &x: query) {
    cin >> x.first >> x.second;
    x.second -= 2;
  }

  lazy_segtree row(n, n), col(n, n);
  ll ans = n * n;
  int row_most = n;
  int col_most = n;
  for (auto &[t, x]: query) {
    if (t == 1) {
      ans -= row.query(x, x+1);
      if (x < row_most) {
        row_most = x;
        col.update(0, col_most, row_most);
      }
    }
    else {
      ans -= col.query(x, x+1);
      if (x < col_most) {
        col_most = x;
        row.update(0, row_most, col_most);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 21436
char buf[1<<18];sz;
N,H;
dp[10000];
main()
{
	read(0,buf,1<<18);
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		H=H*10+k-'0';
	}
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	int ans=1000000000;
	for(int i=1;i<H;i++)dp[i]=1000000000;
	for(int i=0;i<N;i++)
	{
		int A=0,B=0;
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			A=A*10+k-'0';
		}
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			B=B*10+k-'0';
		}
		for(int j=0;j<H;j++)
		{
			int now=dp[j]+B;
			if(j+A<H)
			{
				if(dp[j+A]>now)dp[j+A]=now;
			}
			else
			{
				if(ans>now)ans=now;
			}
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;

 //dp[i] - true if first player wins if there are i stones remaining

void solve()
{
ll n,k;
cin>>n>>k;
std::vector<ll> a(n);
for (int i = 0; i < n; ++i)
{
  cin>>a[i];
  /* code */
}
std::vector<bool> dp(k+1);
for (ll stones = 0; stones <= k  ; ++stones)
{
  for(auto it : a)
  {
    // agar dp[stones - k] true he to dusra wala player jit jayega
    if(stones>=it and !dp[stones - it])
    {
        dp[stones]  = 1;
    }
  }
}
if(dp[k])
  cout<<"First\n";
else cout<<"Second\n";

}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int w,h;
	int i ,j;
	char c;

	while(1){
		
		scanf("%d %d",&h,&w);
		if((w ==0) || (h == 0)){
			break;
		}
				
		for(i=0;i < h;i++){
			if(i % 2 == 0 ){
				c = '#';		
			}else{
				c = '.';
			}
			for(j = 0;j<w;j++){
				printf("%c",c);
				
				if(c == '#' ){
					c = '.';		
				}else{
					c = '#';
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}



Measured memory_bytes: 2044
#include<iostream>
#include<stdio.h>

using namespace std;


int main(){
	int price,stock,sum_price=0,sum_stock=0,i=0;
	char gomi;
	while(cin >> price >> gomi >> stock){
		i++;
		sum_price += price*stock;
		sum_stock += stock;
	}
	sum_stock = sum_stock * 10 / i;
	if(sum_stock%10 >= 5){
		sum_stock += 10;
	}
	sum_stock /= 10;
		

	cout << sum_price << endl << sum_stock << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);
    REP(i, N) cin >> s[i] >> t[i];

    string x;
    cin >> x;

    int ans = 0;
    bool ok = false;
    REP(i, N){
        if (ok) ans += t[i];
        if (s[i] == x)ok = true;
        
    }

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

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int n,N[100];
  int i=0;

  scanf("%d",&n);

  for(i=0; i<n; ++i){
    scanf("%d",&N[i]);
  }

  for(i=n-1;i>0;--i){
    printf("%d ",N[i]);
  }
  printf("%d\n",N[0]);
  


  return 0;
}



Measured memory_bytes: 2680
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <string>
#include <sstream>
#include  <list>
//#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
/*
int cmp(shi a,shi b)
{
    return a.x<b.x;
}
long long cmd(long long a, long long  b)
{
    return a > b;
}*/

struct shi{
    long long num;
    long long time;
}ff[1000000];
int cmd(shi a ,shi b){
    return a.num<b.num;
}

int main()
{
    long long n,m;
    cin >>n>>m;
    for(long long i=0;i<n;i++)
        cin >>ff[i].num>>ff[i].time;
    sort(ff,ff+n,cmd);
    for(long long i=0;i<n;i++)
    {
        if(m)
        {
            if(m>=ff[i].time)
            m-=ff[i].time;
            else if(m<ff[i].time)
            {
                cout<<ff[i].num<<endl;
                break;
            }
        }
        if(m==0){
            cout<<ff[i].num<<endl;
            break;
        }

    }
    return 0;

}


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

int main(){
    int n;
    cin>>n;
    vector<int>man(n);
    long int count=0;
    for(int i=0;i<n;i++){
        cin>>man.at(i);
    }
    sort(man.begin(),man.end());
    for(int i=0;i<n;i++){
        if(i!=0){
            if(man.at(i)!=man.at(i-1)){
                count+=1;
            }
            else{
                count+=0;
            }
        }
        else{
            count+=1;
        }


    }
    cout<<count<<endl;
}

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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    int x,n;

    cin>>x>>n;

    set<int> s;

    forn(i,n){
        int temp;
        cin>>temp;
        s.insert(temp);
    }
    if(s.count(x)==0){
        cout<<x<<endl;
        return;
    }

    int i=x-1,j=x+1;

    while(1){
        if(s.count(i)==0){
            cout<<i<<endl;
            return;
        }

        if(s.count(j)==0){
            cout<<j<<endl;
            return;
        }

        i--;
        j++;
    }

}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
  cin>>n>>k;
  int h[n+1],dp[n+1];
   int i;
  for(i=1;i<=n;i++) cin>>h[i];
 memset(dp,0,sizeof(dp));
  for(i=2;i<=n;i++){
    int x,j,q;
    x=dp[i-1]+abs(h[i]-h[i-1]);
    for(j=2;j<=k;j++){
        if(i>j){
            q=dp[i-j]+abs(h[i]-h[i-j]);
            x=min(x,q);
        }
    }
    dp[i]=x;
  }
  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <cassert>
#include <vector>
#include <cmath>
#include <stdio.h>

using namespace std;

//-------------------------------------------------------------------------
// geometric library

namespace geometry {

#define EPS 1E-10 ///< 0とみなすサイズ。適当

	struct point {
		double x;
		double y;

		point& operator += (const point& rhs) { x += rhs.x; y += rhs.y; return *this; }
		point& operator -= (const point& rhs) { x -= rhs.x; y -= rhs.y; return *this; }
		point& operator /= (double factor) { x /= factor; y /= factor; return *this; }
		point& operator *= (double factor) { x *= factor; y *= factor; return *this; }
		bool operator == (const point& rhs) const { return (std::abs(x - rhs.x) < EPS) && (std::abs(y - rhs.y) < EPS); }
		bool operator != (const point& rhs) const { return !(*this == rhs); }
		bool operator <= (const point& rhs) const { return x < rhs.x || (x == rhs.x && y <= rhs.y); }
		bool operator >= (const point& rhs) const { return x > rhs.x || (x == rhs.x && y >= rhs.y); }
		bool operator < (const point& rhs) const { return !(*this >= rhs); }
		bool operator > (const point& rhs) const { return !(*this <= rhs); }
	};

	enum rotate_dir {
		rotate_None = 0,
		rotate_CW = 1,
		rotate_CCW = -1
	};

	point operator + (const point& p1, const point& p2)
	{
		point p(p1);
		p += p2;
		return p;
	}

	point operator / (const point& p1, double factor)
	{
		point p(p1);
		p /= factor;
		return p;
	}

	point operator - (const point& p1, const point& p2)
	{
		point p(p1);
		p -= p2;
		return p;
	}

	///! 2点の距離
	double get_distance(const point& p1, const point& p2)
	{
		return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
	}

} // namespace geometry

//-------------------------------------------------------------------------
// solution

using namespace geometry;

double get_area_of_triangle(const point& p1, const point& p2, const point& p3) {
	double a = get_distance(p1, p2);
	double b = get_distance(p2, p3);
	double c = get_distance(p3, p1);
	double z = (a + b + c) / 2;

	return sqrt(z * (z - a) * (z - b) * (z - c));
}

double get_area_of_convex(const vector<point>& points) {
	double S = 0.0;

	for (int i = 2; i < points.size(); i++) {
		S += get_area_of_triangle(points[0], points[i - 1], points[i]);
	}
	return S;
}

int main(void) {
	vector<point> points;
	point p;
	char sep;

	while (cin >> p.x >> sep >> p.y) {
		points.push_back(p);
	}

	cout << get_area_of_convex(points);
	return 0;
}

Measured memory_bytes: 1300
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1000000000000
#define fr first
#define sc second
using vl =vector<ll>;
using vvl =vector<vl>;
const ll md = 1000000007;

ll ad(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod) % mod;
}

ll ml(ll a, ll b, ll mod = md) {
    return ( (a%mod) * (b%mod) ) % mod;
}

void multiply(vvl &F, vvl &R, ll N) {
	vvl temp(N, vl (N, 0));
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			for(int k = 0; k < N; k++) {
				temp[i][j] = ad(temp[i][j], ml(F[i][k], R[k][j]));
			}
		}
	}
	F = temp;
}

void mpow(vvl &F, ll N, ll n) {
	vvl res(N, vl (N, 0));
	for(int i = 0; i < N; i++) res[i][i] = 1;
	while(n) {
		if(n&1) multiply(res, F, N);
		multiply(F, F, N);
		n >>= 1;
	}
	F = res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	int s;
   	cin >> s;
   	vvl F = {{1,0,1},{1,0,0},{0,1,0}};
   	if(s>=3) mpow(F, 3, s-3);
 	cout << (s>=3 ? F[0][0] : 0) << "\n";
    return 0;
}

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

const int mod = 1000000007;

int main(){
    int n, k, s;
    cin >> n >> k >> s;
    vector<int> a(n);
    if(s==1000000000){
        rep(i,n){
            a[i] = 999999999;
        }
        rep(i,k){
            a[i] = s;
        }
        rep(i,n){
            cout << a[i] << endl;
        }
        return 0;
    }
    if(k==0){
        rep(i,n) a[i] = s + 1;
        rep(i,n) cout << a[i] << endl;
        return 0;
    }

    rep(i, n) a[i] = s + 1;
    rep(i, k) a[i] = s;
    rep(i, n) cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 1664
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		int n = int.Parse(Console.ReadLine());
		var p = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int counter = 0;
		int a = 0;
		int b = 0;
		int c = 0;
		
		for(int i=1; i!=n-1;i++){
			a = p[i-1];
			b = p[i];
			c = p[i+1];
			if(a!=c){
				if((a<=b)==(b<=c)){
					counter++;
				}
			}
		}
		
		Console.WriteLine(counter);
		
	}
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a > b){
            System.out.println("a > b");
        }else if(a < b){
            System.out.println("a < b");
        }else if(a == b){
            System.out.println("a == b");
        }

    }
}


Measured memory_bytes: 26336
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int N = 1000005;
int V = 1000000, c[N], inv[N], s[N], mu[N];
int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	while (n--) {
		int x;
		scanf("%d", &x);
		ans = (ans - x + mod) % mod;
		c[x]++;
	}
	inv[1] = 1;
	for (int i = 2; i <= V; i++)
		inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = 1; i <= V; i++) {
		mu[i] = (i == 1 ? 1 : 0) - mu[i];
		for (int j = i + i; j <= V; j += i)
			mu[j] += mu[i];
	}
	for (int i = 1; i <= V; i++) {
		for (int j = i; j <= V; j += i) {
			s[i] = (s[i] + 1ll * j * c[j]) % mod;
		}
	}
	for (int i = 1; i <= V; i++) {
		int cur = 0;
		for (int j = 1, j_end = V / i; j <= j_end; j++) {
			cur = (cur + 1ll * s[i * j] * s[i * j] % mod * (mu[j] + mod) % mod) % mod;
		}
		ans = (ans + 1ll * cur * inv[i]) % mod;
	}
	ans = 1ll * ans * ((mod + 1) / 2) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 16000
#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 rrng(a) a.rbegin(), a.rend()
#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);

    string s; std::cin >> s;
    int n = s.size();
    auto calc = [](string s) {
        ll ret = 0, tmp = 0;
        rep(i, s.size()) {
            if (s[i] == '+') ret += tmp, tmp = 0;
            else tmp = tmp*10 + (s[i]-'0');
        }
        ret += tmp;
        return ret;
    };
    ll ans = 0;
    rep(i, 1 << (n-1)) {
        string ss;
        ss += s[0];
        rep(j, n-1) {
            if ((i >> j) & 1) ss += '+';
            ss += s[j+1];
        }
        ans += calc(ss);
    }
    std::cout << ans << "\n";
}


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

void delete_if_mono(int i, std::vector<std::set<int>>& red, std::vector<std::set<int>>& black, std::set<int>& remain) {
    if (red[i].size() > 0 && black[i].size() > 0) return;
    remain.erase(i);
    if (red[i].size() == 0 && black[i].size() == 0) {
    } else if (red[i].size() == 0) {
        for (auto to : black[i]) black[to].erase(i);
        for (auto to : black[i]) delete_if_mono(to, red, black, remain);
    } else {
        for (auto to : red[i]) red[to].erase(i);
        for (auto to : red[i]) delete_if_mono(to, red, black, remain);
    }
}

int main() {
    int n, m;
    std::string str;
    std::cin >> n >> m >> str;
    std::vector<bool> c(n);
    for (int i = 0; i < n; i++) c[i] = str[i] == 'A';
    std::vector<std::set<int>> red(n), black(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        std::cin >> a >> b;
        a--;
        b--;
        if (a < b) std::swap(a, b);
        if (c[a] ^ c[b]) {
            red[a].insert(b);
            red[b].insert(a);
        } else {
            black[a].insert(b);
            black[b].insert(a);
        }
    }

    std::set<int> remain;
    for (int i = 0; i < n; i++) remain.insert(i);
    for (int i = 0; i < n; i++) {
        if (remain.find(i) == remain.end()) continue;
        delete_if_mono(i, red, black, remain);
    }
    std::cout << (remain.size() ? "Yes" : "No") << std::endl;

    return 0;
}


Measured memory_bytes: 44932
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int memo[5000][5001];
struct aa {
	int now;
	int taxi;
	int time;
};
class Compare {
public:
	//aa?????????????????¶
	bool operator()(const aa&l, const aa&r) {
		return l.time> r.time;
	}
};
int main() {
	for (int i = 0; i < 5000; ++i) {
		for (int j = 0; j < 5001; ++j) {
			memo[i][j] = 1e9;
		}
	}
	int N, K; cin >> N >> K;
	vector<pair<int, int>>ps(N);
	for (int i = 0; i < N; ++i) {
		int C, R; cin >> C >> R;
		ps[i] = make_pair(C, R);
	}
	vector<vector<int>>edges(N);
	for (int i = 0; i < K; ++i) {
		int A, B; cin >> A >> B; A--; B--;
		edges[A].push_back(B);
		edges[B].push_back(A);
	}
	priority_queue<aa, vector<aa>, Compare>que;
	que.push(aa{ 0,0,0 });
	memo[0][0] = 0;
	int ans;
	while (!que.empty()) {
		aa atop(que.top());
		const int now = atop.now;
		const int ntime = atop.time;
		const int ntaxi = atop.taxi;
		if (now == N - 1) {
			ans = ntime;
			break;
		}
		que.pop();
		for (auto e : edges[now]) {
			if (ntaxi) {
				if (memo[e][ntaxi - 1]>ntime) {
					memo[e][ntaxi - 1] = ntime;
					que.push(aa{ e,ntaxi - 1,ntime });
				}
			} 
			{
				const int nextime = ntime + ps[now].first;
				const int nextaxi =  ps[now].second - 1;
				if (memo[e][nextaxi]>nextime) {
					memo[e][nextaxi] = nextime;
					que.push(aa{ e,nextaxi,nextime });
				}
			}
			
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 101464
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int h,w;
vector<vector<char> > V;

int res;

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


void go(int y,int x,char a){

	if(x<0 || y<0 || x>=w || y>=h ||V[y][x]!=a) return;
	V[y][x]='.';
	for(int r=0;r<4;r++)
		go(y+dy[r],x+dx[r],a);
}

void solve()
{
	V.clear();
	V.resize(h,vector<char>(w));
	res=0;
	for(int i=0;i<h;i++){
		string h;
		cin>>h;
		for(int j=0;j<w;j++)
			V[i][j]=h[j];
	}
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			if(V[i][j]!='.'){
				res++;
				go(i,j,V[i][j]);
			}
	cout<<res<<endl;
}

int main()
{
	while(cin>>h>>w){
		if(h==0) break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

int A,B,C;
cin >> A >> B >> C;
rrep(k,B) {
    if( (k*A) % B == C) {
        cout << "YES" << endl;
        return 0;
    }
}
cout << "NO" << endl;
return 0;
}

Measured memory_bytes: 256
N=int(input())
List=list(map(int,input().split()))

count=0
SumL=SumR=0
R=0
for L in range(N):
    if L>R:
        R=L
    while R<N and SumL^List[R]==SumR+List[R]:
        SumR+=List[R]
        SumL^=List[R]
        R+=1

    SumR-=List[L]
    SumL^=List[L]
    count += R-L

print(count)

Measured memory_bytes: 24712
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N = 0;
    cin >> N;

    vector<pair<int, int>> nihon;
    vector<bool> isShima(N + 2);
    int count = 0;
    int maxCount = 0;
    
    for (int i = 1; i <= N; ++i) {
        int num = 0;
        cin >> num;
        nihon.push_back(make_pair(-num, i));
    }
    
    stable_sort(nihon.begin(), nihon.end());
    
    if (nihon[0].first != 0) {
        for (int i = 0; i < N; ++i) {
            isShima[nihon[i].second] = true;
            if (!isShima[nihon[i].second - 1] && !isShima[nihon[i].second + 1]) {
                count++;
            }
            else if (isShima[nihon[i].second - 1] && isShima[nihon[i].second + 1]) {
                count--;
            }
            if (nihon[i].first != nihon[i + 1].first) maxCount = max(maxCount, count);
        }
    }
    
    cout << maxCount << endl;
}


Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int check[110000][3];
vector<vin> g;

void bfs(int now,int r,int dis){
  queue<P> que;
  que.push(mp(now,r));
  check[now][r]=dis;
  while(!que.empty()){
    int w=que.front().first;
    int z=que.front().second;
    int dist=check[w][z];
    que.pop();
    if(z==0)dist++;
    for(auto v:g[w]){
     if(check[v][(z+1)%3]!=-1)continue;
      
      check[v][(z+1)%3]=dist;
      que.push(mp(v,(z+1)%3));
    }
  }
  
  
  return ;
}

int main(){cout<<fixed<<setprecision(20);
		   //3で割ったあまりで判定する？
           int n,m;
           cin>>n>>m;
           g.resize(n);
           rep(i,0,m){
            int a,b;
             cin>>a>>b;
             a--;b--;
             g[a].pb(b);
           }
           rep(i,0,n){
            rep(j,0,3)check[i][j]=-1; 
           }
           int s,t;
           cin>>s>>t;
           s--;t--;
           bfs(s,0,0);
           cout<<check[t][0]<<endl;
           //間に合う？
}



Measured memory_bytes: 9644
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define maxn 10000010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int prime[maxn],primesize;
bool isprime[maxn];
void get_prime()
{
    memset(isprime,true,sizeof(isprime));
    isprime[1]=false;
    for(int i=2;i<=maxn-10;i++)
    {
        if(isprime[i])  prime[++primesize]=i;
        for(int j=1;j<=primesize&&i*prime[j]<=maxn-10;j++)
        {
            isprime[i*prime[j]]=false;
            if(i%prime[j]==0)  break;
        }
    }
}
int s[maxn];
int a[101],b[201];
int top1,top2;
int re[101][101];
int match[101];
int vis[101];
bool dfs(int x)
{
    for(int i=1;i<=top2;i++)
    {
        if(re[x][i]&&!vis[i])
        {
            vis[i]=1;
            if(!match[i]||dfs(match[i]))
            {
                match[i]=x;
                return true;
            }
        }
    }
    return false;
}
int main()
{
    get_prime();
    n=read();
    for(int i=1;i<=n;i++)  s[read()]^=1;
    for(int i=1;i<=maxn-9;i++)
    {
        if(s[i]!=s[i-1])
        {
            if(i&1)  a[++top1]=i;
            else     b[++top2]=i;
        }
    }
    for(int i=1;i<=top1;i++)
      for(int j=1;j<=top2;j++)  if(isprime[abs(a[i]-b[j])])  re[i][j]=1;
    int a=0;
    for(int i=1;i<=top1;i++)
    {
        memset(vis,0,sizeof(vis));
        if(dfs(i))  a++;
    }
    printf("%d\n",a+((top1-a)/2)*2+((top2-a)/2)*2+(top1-a)%2*(top2-a)%2*3);
    return 0;
}

Measured memory_bytes: 51584