akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
const int mo = 1e9 + 7;
struct mint
{
    int n;
    mint(int n = 0) : n(n) {}
};
mint operator+(mint a, mint b) { return (a.n += b.n) >= mo ? a.n - mo : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + mo : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n & mo; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }
const int ma=1e5+10;
void solve()
{
    vector<int> isp(ma,1);
    isp[0]=isp[1]=0;
    for(int i=2;i<ma;i++)
    {
        if(isp[i])
        {
            for(int j=2*i;j<ma;j+=i)
            {
                isp[j]=0;
            }
        }
    }
    vector<int> cnt(ma,0);
    for(int i=2;i<ma;i++)
    {
        if(isp[i]&&isp[(i+1)/2])cnt[i]++;
    }
    rep(i,ma-1)cnt[i+1]+=cnt[i];
    int q;
    cin>>q;
    while(q--)
    {
        int a,b;cin>>a>>b;
        cout<<cnt[b]-cnt[a-1]<<endl;
    }
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, q, x, k;
string s, t;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>k;
	vll a(n);
	for(ll i=0;i<n;i++) cin>>a[i];
		sort(all(a));
	cout<<accumulate(a.begin(),a.begin() + k,0);
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main()
{	
    string s;
    cin >> s;
    vector<ll> v(s.size()+1, 0);
    
    REP(i, s.size()){
        if(s[i] == '<'){
            v[i+1] = v[i]+1;
        }
    }
    
    REPR(i, s.size()-1){
        if(s[i] == '>'){
            v[i] = max(v[i], v[i+1]+1);
        }
    }
    cout << accumulate(ALL(v), 0LL) << endl;
}


Measured memory_bytes: 7636
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
const int C=10001, D=101, M=1000000007;

char k[C];
ll dp[C][D], wynn;

int sget(char tab[]){
	for (int z=0;;z++){
		tab[z]=getchar();
		if (tab[z]<=32)	return z;
	}
}

int main(){
	int i, j, ij, c, m, x, sum=0;
	dp[0][0]=1;
	x=sget(k);
	scanf ("%d", &m);
	
	for (i=1;i<C;i++){
		for (j=0;j<m;j++){
			for (ij=0;ij<10;ij++){
				c=(j-ij)%m;
				if (c<0)	c+=m;
				dp[i][j]=(dp[i][j]+dp[i-1][c])%M;
			}
		}
	}
	
	wynn=M-1;	
	for (i=0;i<x;i++){
		for (j=0;j<k[i]-48;j++){
			c=(m-sum-j)%m;
			if (c<0)	c+=m;
			wynn=(wynn+dp[x-i-1][c])%M;
		}
		sum=sum+k[i]-48;
	}
	if (sum%m==0)	wynn++;
	
	printf ("%lld", wynn);
	
	
return 0;}

Measured memory_bytes: 8064
main=do
    [x,y]<-map read.words<$>getLine
    print $ sol x y
sol x y =  minimum $ map (uncurry (+)) $ filter (\(a,_)->a>0) [(axx,0),(a00,0),(a10,1),(a01,1),(a11,2)]
    where
        axx = if x+y==0 then 1 else -1
        a00 = y-x
        a10 = y-(-x)
        a01 = (-y)-x
        a11 = (-y)-(-x)


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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}
int main()
{

    ll N, K;

    cin >> N >> K;

    if (N <= K)
    {
        cout << endl
             << 0 << endl;
        return 0;
    }

    priority_queue<ll> que;

    ll a;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        que.push(a);
    }

    for (int i = 0; i < K; i++)
    {
        que.pop();
    }

    ll ans = 0;
    while (que.size() > 0)
    {
        ans += que.top();
        que.pop();
    }

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

Measured memory_bytes: 2420
#include <stdio.h>
#include <string.h>
 
int main(void){
  int i, len, even0=0, odd0=0, even1=0, odd1=0, ans;
  char s[100000];
  scanf("%s", s);
  len = strlen(s);
  for(i=0;i<len;i+=2){
    if(s[i]=='0') even0++;
  }
  for(i=1;i<len;i+=2){
    if(s[i]=='0') odd0++;
  }
  even1=(len+1)/2 - even0;
  odd1 = len/2 - odd0;
  ans = (even1+odd0) > (even0+odd1)?(even0+odd1):(even1+odd0);
  printf("%d\n", ans);
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007

ll n, m;
map<ll, bool> a;
vector<ll> seen;

ll search(ll p){
  if(p == n-1){
    return 1;
  }
  
  ll ret = 0;
  
  if(p+1 < n){
    if(seen[p+1] != -1){
      ret += seen[p+1];
    }else{
      if(!a[p+1]) ret += search(p+1);
    }
  }
  //cerr << p << " " << ret << endl;
  
  if(p+2 < n){
    if(seen[p+2] != -1){
      ret += seen[p+2];
    }else{
      if(!a[p+2]) ret += search(p+2);
    }	
  }
  //cerr << p << " " << ret << endl;

  if(p != -1)  seen[p] = ret%MOD;
  
  //cerr << p << " " << ret << endl;
  return ret%MOD;
}

int main(){
  cin >> n >> m;
  for(ll i=0; i<n; i++) a[i] = false;
  for(ll i=0; i<m; i++){
    ll tmp;
    cin >> tmp;
    a[tmp-1] = true;
  }
  seen.assign(n, -1);
  ll ans = search(-1);
  cout << ans%MOD << endl;
  
  return 0;
}

Measured memory_bytes: 13568
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n){
        int a;
        cin >> a;
        a--;
        mp[i] = a;
    }
    int now = 0, cnt = 0;
    bool ans = false;
    rep(i, n){
        now = mp[now];
        cnt++;
        if(now == 1){
            ans = true;
            break;
        }
    }
    if(ans){
        cout << cnt << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N,M;cin>>N>>M;
    vector<int>vec(M);
    REP(i,M)cin>>vec[i];
    sort(vec.rbegin(),vec.rend());
    vector<int>dist(M-1);
    REP(i,M-1){
        dist[i]=vec[i]-vec[i+1];
    }
    sort(dist.begin(),dist.end());
    int ans=0;
    REP(i,M-N) ans+=dist[i];
    cout<<ans<<endl;
}

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

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}


 
int main(){
    string s ; cin >> s;
    int n = s.size();
    vector<ll > a(n+1),c(n+1),q(n+1),qr(n+1);
    ll asum=0, csum=0, qsum=0, qsumr=0;
    rep(i,n){
        
        if(s[i]=='A'){
            asum++;
        }
        if(s[n-i-1]=='C'){
            csum++;
        }
        if(s[i]=='?'){
            qsum++;
        }
        if(s[n-i-1]=='?'){
            qsumr++;
        }
        a[i+1] = asum;
        c[n-i] = csum;
        q[i+1] = qsum;
        qr[n-i] = qsumr;
    }
    mint res = 0;
    for(int i=2;i<n;i++){
        if(s[i-1]=='B' || s[i-1]=='?'){
            res += modpow(3, q[i-1]+qr[i+1]) * a[i-1] * c[i+1];
            res += modpow(3,q[i-1]+qr[i+1]-1) * a[i-1] * qr[i+1];
            res += modpow(3,q[i-1]+qr[i+1]-1) * q[i-1] * c[i+1];
            res += modpow(3,q[i-1]+qr[i+1]-2) * q[i-1] * qr[i+1];
        }
 
    }
    cout << res << endl;
}

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

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

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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; }

void Main(){
    int X; cin >> X;
    cout << (X>=30 ? "Yes" : "No") << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n-1; i++) {
            int x = i+1;
            if(a[i] == x){
                int y = a[i+1];
                a[i+1] = a[i];
                a[i] = y;
                ans++;
            }
        }
        if(a[n-1] == n)ans++;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 51056
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      
      	int x = sc.nextInt();
      	int n = sc.nextInt();
      
        Integer p[] = new Integer[n];
      
      	for(int i = 0; i < n; i++){
        	p[i] = sc.nextInt();
        }
      
      	if(n == 0){
          System.out.print(x);
          return;
        }
      
      	List<Integer> list = Arrays.asList(p);
      
      	int r = 0;
     	for(int i =0; i < 100; i++){
          	r = x - i;
          
          	if(!list.contains(r)){
            	System.out.print(r);
              return;
            }
          
          	r = x + i;
          
          	if(!list.contains(r)){
            	System.out.print(r);
              return;
            }
          
        }
      
    }
}


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

int main() {
  string S;
  cin>>S;
  if(S.at(S.size()-1)=='s'){cout<<S<<"es"<<endl;}else{cout<<S<<"s"<<endl;}
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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 INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/
ll pow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}
/*------------------------------------*/

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

	ll N,K;
	cin>>N>>K;
	vector<ll> A(N);
	rep(i,N)cin>>A[i];
	ll maxx = 0;
	//bitのk桁目が立っている個数を数える
	for(ll k = 43;k>=0;k--){
		//cerr<<pow(2,k)<<endl;
		if(bit(k)>K){
			continue;
		}
		ll cnt = 0;
		rep(i,N){
			if(A[i]>>k&1LL)cnt++;
		}
		//cerr<<k<<"桁目は"<<N<<"個中"<<cnt<<"個"<<endl;
		if(2 * cnt < N){
			//cerr<<(1<<k)<<endl;
			if((maxx | bit(k) )>K)continue;
			maxx |= (1LL<<k);
			//if(maxx >= K)break;
		}
	}
	//cerr<<maxx<<endl;
	ll ans = 0;
	rep(i,N){
		ans += (ll)(maxx ^ A[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
n,q=map(int,input().split())
s=input()
i=0
bb=[]
c=0
while True:
    b=s.find('AC', i)
    if b<0:
        bb.extend([c]*(len(s)-i))
        break
    bb.extend([c]*(b-i+1))
    i=b+1
    c+=1
for _ in range(q):
    l,r=map(int,input().split())
    print(bb[r-1]-bb[l-1])

Measured memory_bytes: 6140
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;

int n, x, sum;

int main(){
	scanf("%d%d", &n, &x);
	FOR(i, 0, n){
		int y;
		scanf("%d", &y);
		sum += y;
		if(sum > x){
			printf("%d\n", i + 1);
			return 0;
		}
	}
	printf("%d\n", n + 1);
	return 0;
}



Measured memory_bytes: 256
#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()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
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 N; cin >> N;
vi L(N);
rep(i,N) cin >> L[i];
sort(all(L));
int ans = 0;
for(int i = 0; i < N-2; ++i) {
    for(int j = i+1; j < N-1; ++j) {
        ans += lower_bound(all(L), L[i]+L[j]) - L.begin();
        ans -= j + 1;
    }
}
cout << ans << endl;
return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
    ll a, b;
    cin >> a >> b;
    if (a<b) {
        cout << "a < b" << endl;
    } else if (a==b) {
        cout << "a == b" << endl;
    } else {
        cout << "a > b" << endl;
    }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int r, s, p;
    while (cin >> r) {
        cin >> s >> p;
        vector<pii> v(p);
        rep(i, p) cin >> v[i].F >> v[i].S;
        vector<int> d(p);
        
        rep(i, p) {
            if (v[i].S <= s) {
                d[i] = s + 1 - v[i].S;
            } else {
                d[i] = v[i].S - s;
            }
            d[i] += r + 1 - v[i].F;
        }
        sort(all(d));
        rep3(i, 1, p) if (d[i] <= d[i - 1]) d[i] = d[i - 1] + 1;
        cout << d[p - 1] << endl;
    }
    
}



Measured memory_bytes: 8444
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>

using namespace std;

int a[3], d;

int main() {
  for(int i = 0; i < 3; i++)
    scanf("%d", &a[i]);
  scanf("%d", &d);
  if(abs(a[2] - a[0]) <= d) {
    printf("Yes\n");
    return 0;
  }
  if(abs(a[2] - a[1]) <= d && abs(a[1] - a[0]) <= d) {
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
  return 0;
}


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

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i, n) for(ll i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (ll i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

signed main()
{
    ll N, L; cin >> N >> L;
    
    ll minTaste = INF;
    ll selected = -1;
    rep1(i, N + 1){
        if (abs(L + i - 1) < minTaste){
            minTaste = abs(L + i - 1);
            selected = i;
        }
    }
    ll ans = 0;
    rep1(i, N + 1){
        ans += (L + i - 1);
    }
    ans -= (L + selected - 1);

    cout << ans << endl;

    return 0;
}


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

int main(){
    int n,A[100];
    
    cin>>n;
    for (int i=0;i<n;i++) cin>>A[i];
    
    for (int i=n-1;i>=0;i--){
        if (i != n-1) cout<<" ";
        cout<<A[i];
    }
    
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 3084
a=raw_input()
b=raw_input()

aa=list(a)
bb=list(b)

aa.sort()
bb.sort()

aaa=[]
ac=0
acw=aa[0]
for i in aa:
    if acw==i:
        ac+=1
    else:
        acw=i
        aaa.append(ac)
        ac=1
aaa.append(ac)

bbb=[]
bc=0
bcw=bb[0]
for i in bb:
    if bcw==i:
        bc+=1
    else:
        bcw=i
        bbb.append(bc)
        bc=1
bbb.append(bc)

aaa.sort()
bbb.sort()
ch=0
if len(aaa)==len(bbb):
    for i in range(len(aaa)):
        if aaa[i]!=bbb[i]:
            print "No"
            ch=1
            break
else:
    print "No"
    ch=1

if ch==0:
    print "Yes"

Measured memory_bytes: 7224
<?php
  function to_i($e) {
    return (int)$e;
  }

  $n = fgets(STDIN);
  for($i=0; $i<(int)$n; $i++) {
    $line = fgets(STDIN);
    $a = explode(" ", $line);
    $a = array_map("to_i", $a);
    rsort($a);
    if($a[0] > $a[1] && $a[0] > $a[2] && $a[0]*$a[0] == $a[1]*$a[1] + $a[2]*$a[2]) {
      echo "YES\n";
    }
    else {
      echo "NO\n";
    }
  }

Measured memory_bytes: 15144
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <math.h>
#include <numeric>

using namespace std;

int main() {
  int k;
  cin >> k;

  int sum = 0;
  for(int i = 1; i <= k; i++){
    for(int j = 1; j <= k; j++){
      for(int l = 1; l <= k; l++){
        int g = gcd(i, j);
        g = gcd(g, l);

        sum += g;
      }
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,k;
	cin>>n>>k;
	set<int> s;
	vector<int> v(n);
	int res=0;
	int c=1;
	bool f=false;
	for(int i=0,x;i<n;++i){
		scanf("%d",&x);
		v[i]=x;
		if(i && v[i]>v[i-1])
			++c;
		if(i && v[i]<v[i-1]){
			if(c>=k){
				--res;
				f=true;
			}
			c=1;
		}
		s.insert(x);
		if(i-k>=0)
			s.erase(v[i-k]);
		if(i>=k-1){
			bool ok=true;
			if(i-k>=0 && v[i]==*--s.end() && v[i-k]<*s.begin())
				ok=false;
			res+=ok;
		}
	}
	if(c>=k){
		--res;
		f=true;
	}
	if(f)
		++res;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 10368
#include<iostream>

using namespace std;

int main(){
	int K;
	cin >> K;
	bool kisuu=true;
	if(K%2==0)kisuu=false;
	if(kisuu){
		cout << (K/2)*(K/2+1);
	}
	else {
		cout << (K/2)*(K/2);
	}
	
}

Measured memory_bytes: 256
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    A = list(map(int, input().split()))
    S = list(accumulate(A))

    # 先頭が正の場合
    times_plus = 0
    added = 0
    for i in range(N):
        num = S[i] + added
        if num * (-1)**i > 0: continue
        added += abs(num - (-1)**i) * (-1)**i
        times_plus += abs(num - (-1)**i)
        

    # 先頭が負の場合
    times_minus = 0
    added = 0
    for i in range(1, N + 1):
        num = S[i - 1] + added
        if num * (-1)**i > 0: continue
        added += abs(num - (-1)**i) * (-1)**i
        times_minus += abs(num - (-1)**i)
    
    print(min(times_minus, times_plus))
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 91088
#include <iostream>
#include <algorithm>
#define llong long long
llong gcd(llong a, llong b)
{
    llong mod;
    mod = std::max(a, b) % std::min(a, b);
    if(mod == 0) return std::min(a, b);
    else return gcd(std::min(a, b), mod);
}
llong lcm(llong a, llong b, llong gcd)
{
    return (a * b) / gcd;
}
int main()
{
    llong a, b;
    while(std::cin >> a >> b)
    {
        llong g = gcd(a, b);
        std::cout << g << " " << lcm(a, b, g) << std::endl;
    }
}

Measured memory_bytes: 3068
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type discount struct {
	a     int
	b     int
	price int
}

func main() {
	sc.Split(bufio.ScanWords)
	A, B, M := nextInt(), nextInt(), nextInt()

	a := make([]int, A)
	for i := 0; i < A; i++ {
		a[i] = nextInt()
	}

	b := make([]int, B)
	for i := 0; i < B; i++ {
		b[i] = nextInt()
	}

	m := make([]discount, M)
	for i := 0; i < M; i++ {
		m[i] = discount{nextInt(), nextInt(), nextInt()}
	}

	min_a := getMin(a)
	min_b := getMin(b)

	min := min_a + min_b
	for _, d := range m {
		price := a[d.a-1] + b[d.b-1] - d.price
		if price < min {
			min = price
		}
	}
	fmt.Println(min)
}

func getMin(x []int) int {
	min := 100000
	for _, v := range x {
		if v < min {
			min = v
		}
	}
	return min
}


Measured memory_bytes: 7552
// AOJ 2875 Mapping
// 2018.4.16 bal4u

#include <stdio.h>

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int  a[100002];
char f[100002];

int main()
{
	int N, i, b, cnt;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	cnt = 0;
	for (i = 0; i < N; i++) {
		b = in();
		if (!f[b]) cnt++, f[b] = 1;
	}
	if (cnt == N) { puts("Yes"); return 0; }

	puts("No");
	putchar('1');
	for (i = 1; i < N; i++) putchar(' '), putchar('1');
	putchar('\n');

	putchar('2'-f[a[0]]);
	for (i = 1; i < N; i++) putchar(' '), putchar('2'-f[a[i]]);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2100
def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    root = 0  # 根
    d = [-1]*n  # 根からの距離
    d[root] = 0
    q = [root]
    cnt = 0
    while q:  # BFS
        cnt += 1
        qq = []
        while q:
            i = q.pop()
            for j in g[i]:
                if d[j] == -1:
                    d[j] = cnt
                    qq.append(j)
        q = qq
    d = [i % 2+1 for i in d]
    d2 = [0]*n
    x = d.count(1)
    y = d.count(2)
    if x > n//3 and y > n//3:
        j1 = 1
        for i in range(n):
            if d[i] == 1:
                d2[i] = j1
                j1 += 3
                cnt += 1
        j2 = 2
        for i in range(n):
            if d[i] == 2:
                d2[i] = j2
                j2 += 3
        j3 = 3
        for i in range(n):
            if d2[i] > n:
                d2[i] = j3
                j3 += 3
    elif x <= n//3:
        j3 = 3
        for i in range(n):
            if d[i] == 1:
                d2[i] = j3
                j3 += 3
        j2 = 1
        for i in range(n):
            if d[i] == 2:
                d2[i] = j2
                if j2 % 3 == 2:
                    j2 += 2
                else:
                    j2 += 1
        for i in range(n):
            if d2[i] > n:
                d2[i] = j3
                j3 += 3
    else:
        j3 = 3
        for i in range(n):
            if d[i] == 2:
                d2[i] = j3
                j3 += 3
        j2 = 1
        for i in range(n):
            if d[i] == 1:
                d2[i] = j2
                if j2 % 3 == 2:
                    j2 += 2
                else:
                    j2 += 1
        for i in range(n):
            if d2[i] > n:
                d2[i] = j3
                j3 += 3
    print(*d2)


main()


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

int main()
{

#ifdef _d
    freopen("input.txt", "r", stdin);
#endif

    string str;
    cin >> str;
    char ch = str[0];
    if (ch >= 97) {
        cout << "a\n";
    } else {
        cout << "A\n";
    }

    return 0;
}


Measured memory_bytes: 3620
import numpy as np
N = int(input())
B = []
for i in range(N):
    L1, R1 = input().split()
    R2 = -1 * int(R1)
    B.append((L1,R2))
BC = np.array(B,dtype= [('town', "U10"),("s", "i1")])
a= np.argsort(BC ,order = ['town', 's'])
for i in range(N):
    print(int(a[i])+1)

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

using namespace std;

int cost(int x, int y, int z) {
    return abs(x - y) + abs(y - z);
}

int min(int a, int b) {
    return a < b ? a : b;
 }

int main() {
    int x, y, z;
    cin >> x;
    cin >> y;
    cin >> z;
    
    int c = 114514;
    c = min(c, cost(x, y, z));
    c = min(c, cost(x, z, y));
    c = min(c, cost(y, x, z));
    c = min(c, cost(y, z,x ));
    c = min(c, cost(z, x, y));
    c = min(c, cost(z, y, x));
    
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
import math
N = int(input())

def query(n):
  print(n)
  ret = input()
  if ret == 'Vacant':
    exit()
  return ret

low = 0
high = N
lowseat = query(low)
while True:
  mid = math.ceil((low + high) / 2)
  midseat = query(mid)
  if (mid - low) % 2 == 0:
    # 違う時、low～midの間に空席がある
    if lowseat != midseat:
      high = mid
    else:
      low = mid
      lowseat = midseat
  else:
    # 同じ時、low～midの間に空席がある
    if lowseat == midseat:
      high = mid
    else:
      low = mid
      lowseat = midseat

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

typedef long long LL;

int digits(LL x) {
	int ans = 0;
	while(x) {
		x /= 10;
		ans++;
	}
	return ans;
}

int main() {
	LL n; cin >> n;
	int ans = 100;
	for(LL i = 1; i * i <= n; i++) if(n % i == 0)
		ans = min(ans, max(digits(i), digits(n / i)));
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        
        int ans = 0;
        for (int a = 0; a <= A; a++) {
        	for (int b = 0; b <= B; b++) {
        		for (int c = 0; c <= C; c++) {
        			if (a*500+b*100+c*50 == X) {
        				ans++;
        			}
        		}
        	}
        }
        
        System.out.println(ans);
    }
    
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int a[105];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n-1;i++)
    {
        int Min=i;
        for(int j=i;j<n;j++)
            if(a[j]<a[Min])
                Min=j;
        if(Min!=i)swap(a[i],a[Min]),ans++;
    }
    for(int i=0;i<n;i++)
    {
        if(i)cout<<' ';
        cout<<a[i];
    }
    cout<<endl;
    cout<<ans<<endl;
    return 0;
}



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

int main()
{
	int a,b;
	cin>>a>>b;
	
	int x=0;
	if(b<10) x=a*10+b;
	else if(b<99) x=a*100+b;
	else x=a*1000+b;
	
	bool f=0;
	for(int i=1;i*i<=x;i++) if(x==i*i) f=1;
	
	cout<<(f? "Yes":"No")<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<cstring>
#include<string>
#include<map>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<queue>
#include<sstream>
#include<climits>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	char a[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	cout<<a[0][0]<<a[1][1]<<a[2][2];
	return 0;
}
 

Measured memory_bytes: 256
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 100000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
const int N=50005;
//Code begin....

int rr[10];
int G[205][205];
int dp[9][(1<<9)+5];
int top, R;

int dfs(int x, int sta){
    if (~dp[x][sta]) return dp[x][sta];
    if (sta==0) return 0;
    int res=INF;
    FOR(i,0,R-1) {
        if (i!=x&&((sta>>i)&1)) res=min(res,G[rr[x]][rr[i]]+dfs(i,sta^(1<<i)));
    }
    return dp[x][sta]=res;
}
int main ()
{
    int n, m, u, v, w;
    scanf("%d%d%d",&n,&m,&R);
    mem(dp,-1);
    top=(1<<R)-1;
    FOR(i,0,R-1) scanf("%d",rr+i);
    FOR(i,1,n) FOR(j,1,n) if (i!=j) G[i][j]=INF;
    FOR(i,1,m) scanf("%d%d%d",&u,&v,&w), G[u][v]=G[v][u]=min(G[u][v],w);
    FOR(k,1,n) FOR(i,1,n) FOR(j,1,n) G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
    FOR(i,0,R-1) dfs(i,top^(1<<i));
    int ans=INF;
    FOR(i,0,R-1) ans=min(ans,dp[i][top^(1<<i)]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define aaa(i,n) for ((i)=1;(i)<=(n);(i)++)
#define bbb(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
using namespace std;
int n,m,i,j,f[200005][19],g[200005][19],a[200005],l[200005],lg[200005],t,ans,ys;int qrymi(int x,int y){int k=lg[y-x+1];return min(f[x][k],f[y-(1<<k)+1][k]);}int qrymx(int x,int y){	int k=lg[y-x+1];	return max(g[x][k],g[y-(1<<k)+1][k]);}
int main(){bbb(i,2,200000){		lg[i]=lg[i/2]+1;	}	scanf("%d%d",&n,&m);	aaa(i,n){		scanf("%d",&a[i]);		g[i][0]=f[i][0]=a[i];	}
	aaa(j,18)aaa(i,n-(1<<j)+1){		f[i][j]=min(f[i][j-1],f[i+(1<<(j-1))][j-1]);		g[i][j]=max(g[i][j-1],g[i+(1<<(j-1))][j-1]);	}	aaa(i,n){		if(i>1&&a[i-1]<a[i]) l[i]=l[i-1]+1; else l[i]=1;	}
	if(l[m]>=m) ys=1; else ans=1;	bbb(i,m+1,n){		if(l[i]>=m){			ys=1;			continue;		}		if(qrymi(i-m,i)==a[i-m]&&qrymx(i-m,i)==a[i]){			continue;
		}		else{			ans++;		}	}	cout<<ans+ys<<endl;	return 0;}

Measured memory_bytes: 32256
//ABC067B
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string s;
	cin >> s;
	int n = (s.size()-1) /2;
	for(int len = n; len > 0; len--){
		bool isSame = true;
		for(int i = 0; i < len; i++){
			if(s.at(i) != s.at(len + i)){
				isSame = false;
				break;
			}
		}
		if(isSame){
        	cout << len*2 << endl;
        	break;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1005
using namespace std;
int n;
void solve(){
	scanf("%d",&n);
	if(n%10==n/10%10||n/10%10==n/100%10||n/100%10==n/1000)puts("Bad");
	else puts("Good");
}
int main(){
	solve();
	return 0;
}

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

int a, c;
string b, d="-", e="+";

int main () {
    cin>>a>>b>>c;
    if (b [0]==d [0]) {cout<<a-c<<endl;}
    else if (b [0]==e [0]) {cout<<a+c<<endl;}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  char c1,c2,c3;
  cin >> c1 >> c2 >> c3;
  int count = 0;
  if(c1=='1')count++;
  if(c2=='1')count++;
  if(c3=='1')count++;
  cout << count << endl;
}


Measured memory_bytes: 256
while 1:
	n=input()
	if n==0:break
	a=raw_input()
	for r in range(n):
		aa=""
		s=a[0]
		count=1
		for i in range(len(a)-1):
			if a[i]==a[i+1]:
				count+=1
			else:
				aa+=str(count)+s
				count=1
				s=a[i+1]
		aa+=str(count)+s
		a=aa
	print a

Measured memory_bytes: 4988
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		// 入力
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<Integer> d = new HashSet<Integer>();
		for (int i = 0; i < N; i++) {
			d.add(sc.nextInt());
		}

		// 出力
		System.out.println(d.size());

		sc.close();
	}
}


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

int main() {
  int N;
  int i = 1;
  cin >> N;

  while(1){
    if(i*1000 >= N){
      cout << i*1000 - N << endl;
      return 0;
    }else{
      i+=1;
    }
  }
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;


int main() {
  int a, b, c;
  cin >>a >> b >> c;
  
  for(int i=0;i<c;i++){
      if(i%2==0){
        b=b+(a/2);
        a=a/2;
      }
      else{
      a=a+(b/2);
      b=b/2;
      }
  }
  
  cout << a << " " << b <<endl;
}
    
    

Measured memory_bytes: 256
// Date: 2020-04-04

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    FIO;
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b), swap(a, c);
    cout << a << " " << b << " " << c;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <utility>
#include <queue>
#include <vector>
#include <array>
#include <stack>
#include <list>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define bs(n) (1ull<<(n))

int main() {
	string s;
	cin >> s;
	int len = s.length();
	const char* r = ((s[0] == s[len - 1]) ^ (len % 2 == 0)) ? "Second" : "First";
	cout << r << endl;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = in.nextLongArray(n);
			long[] b = in.nextLongArray(n);

			long sumA = 0, sumB = 0;
			for (int i = 0; i < n; i++) {
				sumA += a[i];
				sumB += b[i];
			}
			if (sumA > sumB) {
				out.println("No");
				return;
			}
			long sa = sumB - sumA;
			long count = 0;
			for (int i = 0; i < n; i++) {
				if (b[i] > a[i]) {
					count += (b[i]-a[i]+1) / 2;
				}
			}

			out.println(count <= sa ? "Yes" : "No");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

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

using namespace std;
using ll = long long;

void solve();

struct RollingHash{
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<ll> hash1, hash2, power1, power2;

    RollingHash(const string &S){
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1); //power1[i] = pow(base1, i)
        power2.assign(n+1, 1);
        for(int i = 0; i < n; i++){
            hash1[i+1] = (hash1[i]*base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i]*base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }

    //S[left:right]のハッシュ値を得る left >= 0, r < N
    inline pair<ll, ll> get(int l, int r) const{
        ll res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if(res1 < 0) res1 += mod1;
        ll res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if(res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    inline int getLCP(int a, int b) const{
        int len = min((int) hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while(high - low > 1){
            int mid = (low + high) >> 1;
            if(get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }

    int solve(){

    }
};

int main(void){
    int N; cin >> N;
    string s; cin >> s; //英小文字からなる
    RollingHash rh(s);

    auto check = [&](int d) -> bool {
        map<pair<ll, ll>, int> ma;
        for(int i = 0; i+d <= N; i++){
            auto p = rh.get(i, i+d);
            if(ma.count(p)){
                if(i - ma[p] >= d) return true;
            }
            else ma[p] = i;
        }
        return false;
    };

    int left = 0, right = N/2 + 1;
    while(right - left > 1){
        int mid = (left + right) >> 1;
        if(check(mid)) left = mid;
        else right = mid;
    }

    cout << left << endl;
    
    return 0;
}

void solve(){}

Measured memory_bytes: 768