akhauriyash/Code-Regression huggingface dataset:
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
char s[6011];
int n,rk[6011];
vector<int> pa,pb;
const int maxn=3011*6011;
int go[maxn][2],tot=1;
int head[maxn],nxt[3011];
pair<int,int> seg[3011];
void add(int il,int ir)
{
//	cerr<<"add:"<<il<<" "<<ir<<endl;
	int p=1;
	int l=n+n,r=0;
	for(int i=0;i<n+n;i++)
	{
		if(rk[i]>=il&&rk[i]<=ir)
		{
			int &q=go[p][s[i]-'a'];
			if(!q)
			{
				q=++tot;
				head[q]=-1;
			}
			p=q;
			l=min(l,i);
			r=max(r,i);
		}
	}
	nxt[il]=head[p];
	head[p]=il;
	seg[il]=MP(l,r);
}
vector<int> ANS;
char st[6011];
int stn;
void dfs(int p)
{
	for(int i=1;i>=0;i--)
	{
		if(go[p][i])
		{
			st[stn++]='a'+i;
			dfs(go[p][i]);
			stn--;
		}
	}
	if(p==1)return;
//	cerr<<"dfs:"<<p<<" "<<head[p]<<endl;
	for(int i=head[p];i!=-1;i=nxt[i])
	{
		if(ANS.size()==0||seg[ANS[ANS.size()-1]].SS<seg[i].FF)
		{
			ANS.PB(i);
			for(int j=0;j<stn;j++)putchar(st[j]);
		}
	}
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n+n;i++)
	{
		if(s[i]=='a')rk[i]=pa.size(),pa.PB(i);
		else rk[i]=pb.size(),pb.PB(i);
	}
	for(int i=n-1;i>=0;i--)
	{
		if(pa[i]<pb[i])
		{
			add(i,i);
		}
		else
		{
			int j=i;
			while(j+1<n&&pb[j+1]<pa[j])j++;
			add(i,j);
		}
	}
	dfs(1);
	return 0;
}


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

int main(int argc, char const *argv[])
{
	int n,m;
	while(cin>>n>>m,n+m)
	{
		int a[n],ans=0;
		for (int i = 0; i < n; ++i) cin>>a[i];
		for (int i = 0; i < n; ++i) for (int j = 0; j < i; ++j) if(a[i]+a[j]<=m) ans=max(ans,a[i]+a[j]);
		if(ans) cout<<ans<<endl;
		else cout<<"NONE\n";
	}
	return 0;
}



Measured memory_bytes: 3080
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include <stdio.h>
#include <functional>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

string x(string s, const string cs, const string se) {
	int pos = 0;
	while ((pos = s.find_first_of(se)) != string::npos) {
		s.replace(pos, 1, cs);
	}
	return s;
}

string y(string a) {
	int pos4 = 0, pos9 = 0;
	a = x(a, "3", "5");
	a = x(a, "5", "6");
	a = x(a, "6", "7");
	a = x(a, "7", "8");
	int pos = a.length();
	if ((pos4 = a.find_first_of("4")) != string::npos && (pos9 = a.find_first_of("9")) != string::npos)
	{
		if (pos4 > pos9) {//4>9
			a = a.replace(pos9, 1, "7");
			pos = pos9 + 1;
		}
		else {
			a = a.replace(pos4, 1, "3");
			pos = pos4 + 1;
		}
	}
	else if ((pos4 = a.find_first_of("4")) != string::npos) {
		a = a.replace(pos4, 1, "3");
		pos = pos4 + 1;
	}
	else if ((pos9 = a.find_first_of("9")) != string::npos) {
		a = a.replace(pos9, 1, "7");
		pos = pos9 + 1;
	}
	while (pos != a.length()) {
		a = a.replace(pos, 1, "7");
		pos++;
	}
	return a;
}

int n;
int m;
int aji[100000];

int saiki(){
	return 0;
}

int main(){
	int m, t, p, r;
	while (cin >> m >> t >> p >> r && !(m == 0 && t == 0 && p == 0 && r == 0)){
		vector<pair<int, pair<int, int>>> juni; // テヲツュツ」ティツァツ」テヲツ閉ー テヲツ卍づゥツ鳴?テ」ツδ?」ツδシテ」ツδ?・ツ青?テァツュツ氾」ツ?暗」ツ?ョテ」ツ?淌」ツつ?」ツ?ョvector)
		int teamscore[50]; // テ・ツ青?」ツδ?」ツδシテ」ツδ?」ツ?ョテ」ツつケテ」ツつウテ」ツつ「
		int teamsecond[50]; // テ・ツ青?」ツδ?」ツδシテ」ツδ?」ツ?ョテヲツ卍づゥツ鳴?
		int teamincorr[50][2000]; // テ・ツ青?」ツδ?」ツδシテ」ツδ?・ツ青?・ツ閉湘ゥツ。ツ古」ツ?ョテゥツ鳴禿ゥツ?陛」ツ?暗」ツ?淌・ツ崢榲ヲツ閉ー
		int teamincorrcnt[50]; // テ・ツ青?」ツδ?」ツδシテ」ツδ?」ツ?ョテヲツュツ」ティツァツ」テ」ツ?療」ツ?淌・ツ閉湘ゥツ。ツ古」ツ?ョテゥツ鳴禿ゥツ?陛」ツ?暗」ツ?淌・ツ崢榲ヲツ閉ー
		for (int i = 0; i < 50; i++) {
			teamscore[i] = 0;
			teamsecond[i] = 0;
			teamincorrcnt[i] = 0;
			for (int j = 0; j < 2000; j++) {
				teamincorr[i][j] = 0;
			}
		}
		for (int i = 0; i < r; i++) {
			int mk, tk, pk, jk;
			cin >> mk >> tk >> pk >> jk;
			if (jk == 0) { // テヲツュツ」ティツァツ」
				teamscore[tk - 1]++; // テヲツュツ」ティツァツ」テヲツ閉ーテ」ツつ津・ツ「ツ療」ツつ?」ツ??
				teamincorrcnt[tk - 1] += teamincorr[tk - 1][pk];
				teamsecond[tk - 1] += mk + 20 * teamincorr[tk - 1][pk];
			}
			else { // テゥツ鳴禿ゥツ?陛」ツ??
				teamincorr[tk - 1][pk]++;
			}
		}
		for (int i = 0; i < t; i++) {
			juni.push_back(make_pair(teamscore[i], make_pair(1000000 - teamsecond[i], i + 1)));
		}
		sort(juni.begin(), juni.end());

		int score = -1;
		int jikan = -1;
		for (int i = t - 1; i >= 0; i--) {
			if (i != t - 1) {
				if (score == juni[i].first && jikan == juni[i].second.first) {
					cout << "=";
				}
				else {
					cout << ",";
				}
			}
			cout << juni[i].second.second;
			score = juni[i].first;
			jikan = juni[i].second.first;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
constexpr int DMAX = 4001;
constexpr lint MOD = 998244353;

int main()
{
    int N;
    cin >> N;
    vector<bitset<DMAX>> A;

    string S;
    cin >> S;
    bitset<DMAX> X(S);
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        A.push_back(bitset<DMAX>(S));
    }

    int d = 0;
    while (true)
    {
        sort(A.begin(), A.end(), [](const auto &l, const auto &r) { return l.to_string() < r.to_string(); });
        while (A[0].none()) A.erase(A.begin());
        bitset<DMAX> tmp = A[0];
        d = 0;
        for (int j = 1; j <= DMAX; j++) if (tmp[j-1]) d = j;

        for (int i = 1; i < A.size(); i++)
        {
            int d_ = 0;
            for (int j = d; j <= DMAX; j++) if (A[i][j-1]) d_ = j;
            A[i] ^= tmp << (d_ - d);
        }
        if (A.size() == 1) break;
    }
    bitset<DMAX> making;
    for (int i = DMAX - d; i >= 0; i--)
    {
        bitset<DMAX> making_tmp = making ^ (A[0] << i);
        if (making.to_string() > making_tmp.to_string()) swap(making, making_tmp);
        if ((making_tmp >> (i + d - 1)).to_string() <= (X >> (i + d - 1)).to_string()) making = making_tmp;
    }
    lint ans = 0;
    lint dig = 1;
    for (int i = 0; i < DMAX; i++)
    {
        (ans += (X >> (d - 1))[i] * dig) %= MOD;
        (dig *= 2) %= MOD;
    }
    
    cout << (ans + (making.to_string() <= X.to_string())) % MOD << endl;
}


Measured memory_bytes: 256
N,M,K = map(int, input().split())
P=1000000007
MPL = 1
f = 1
for i in range(1, N*M-1):
    MPL = MPL * i % P
    MPL %= P
    if i == K - 2:
        f *= pow(MPL, P - 2, P)
    if i == N*M - K:
        f *= pow(MPL, P - 2, P)
MPL = MPL * f % P
ans = 0
for A in [N, M]:
    width = N ^ M ^ A
    for i in range(1, A):
        ans = (ans + width * width * i * (i + 1) // 2) % P
print(ans * MPL % P)

Measured memory_bytes: 65136
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n;
  cin >> n;
  vector<P> ans;
  if(n%2==1){
    for(int i=1;i<n;i++){
      ans.push_back(P(i,n));
    }
    n--;
  }
  for(int i=1;i<n;i++){
    for(int j=i+1;j<=n;j++){
      if(i+j!=n+1){
        ans.push_back(P(i,j));
      }
    }
  }
  cout << ans.size()<<"\n";
  for(auto p:ans){
    cout << p.first<<" "<<p.second<<endl;
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

ll l;

ll cnorm(ll x) {
    x %= l;
    if (x < 0)
        x += l;
    return x;
}

int main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    int n, t;
    cin >> n >> l >> t;
    vector<int> x(n), w(n);
    forn (i, n) {
        cin >> x[i] >> w[i];
    }
    int id = -1;
    int idDist = 1e9;
    forn (i, n) {
        if (w[i] == 2)
            continue;
        int i2 = (i+1)%n;
        if (w[i2] != 2)
            continue;
        if (id == -1 || cnorm(x[i2] - x[i]) > idDist) {
            id = i;
            idDist = cnorm(x[i2] - x[i]);
        }
    }

    vector<int> coord(n);
    int idc = -1;
    forn (i, n) {
        coord[i] = cnorm(x[i] + (w[i] == 1 ? 1 : -1) * t);
        //cerr << i << ' ' << coord[i] << '\n';
        if (i == id)
            idc = coord[i];
    }
    if (id == -1) {
        for (int x: coord)
            cout << x << '\n';
        return 0;
    }
    sort(coord.begin(), coord.end());
    int idpos = lower_bound(coord.begin(), coord.end(), idc) - coord.begin();
    int sh = idpos - id;
    sh %= n;
    if (sh < 0)
        sh += n;

    forn (i, n) {
        if (w[i] != 2)
            continue;
        ll x1 = x[id];
        ll x2 = x[i];
        ll T = t * 2;
        T -= cnorm(x2 - x1);
        if (T <= 0)
            continue;
        ll cur = (T + l - 1) / l;
        //cerr << "CUR " << cur << '\n';
        sh -= cur % n;
        if (sh < 0)
            sh += n;
    }
    //for (int x: coord)
        //cerr << x << '\n';
    rotate(coord.begin(), coord.begin() + sh, coord.end());
    for (int x: coord)
        cout << x << '\n';
}


Measured memory_bytes: 2304
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)-(a+b-1);
    return 0;
}


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};


vector<pll> g;
ll dp[2005][2005]={0};

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

    ll test=1;
    //cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;
        ll x;
        for(ll i=1;i<=n;i++)
        {
            cin>>x;
            g.pb({x,i});
        }

        sort(g.begin(),g.end());
        reverse(g.begin(),g.end());
        auto k=g.begin();
        
        for(ll i=1;i<=n;i++)
        {
            for(ll j=0;j<i;j++)
            {
                ll left=j;
                ll right=i-j-1;

                dp[left+1][right]=max(dp[left+1][right],dp[left][right]+(k->ff)*(abs(k->ss-(left+1))));

                dp[left][right+1]=max(dp[left][right+1],dp[left][right]+(k->ff)*(abs(k->ss-(n-right))));
            }

            k++;
        }

        ll ans=0;

        for(ll i=0;i<=n;i++)
        {
            ans=max(ans,dp[i][n-i]);
        }

        cout<<ans;

    }
}

Measured memory_bytes: 26356
import sys

f_i = sys.stdin

max_d = float("inf")

V, E = map(int, f_i.readline().split())

# adjacency matrix
A = [[max_d] * i + [0] + [max_d] * (V - i - 1) for i in range(V)]

for l_i in f_i:
    s, t, d = map(int, l_i.split())
    A[s][t] = d

# Warshall???Floyd Algorithm
for k in range(V - 1):
    for i in range(V):
        for j in range(V):
            A[i][j] = min(A[i][j], A[i][k] + A[k][j])

for i in range(V):
    for j in range(V):
        e = min(A[i][j], A[i][V - 1] + A[V - 1][j])
        if e == max_d:
            A[i][j] = "INF"
        else:
            A[i][j] = e


# check whether A has negative cycle
flag = 1
for k in range(V):
    if A[k][k] < 0:
        flag = 0
        print("NEGATIVE CYCLE")
        break

# Output
if flag:
    for a in A:
        print(*a)

Measured memory_bytes: 8416
#include <bits/stdc++.h>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)
#define int long long

const int maxn = 5e5 + 1, mod = 1e9 + 7;

using namespace std;

int a[maxn];
int cnt[32];

ostream& operator<<(ostream &o, pi &pt) {
    o << pt.l << ' ' << pt.r;
    return o;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int s; cin >> s;
    int l = -1, r = 1e9;
    while (r - l > 1) {
        int md = (l + r) / 2;
        if (md * md < s)
            l = md;
        else
            r = md;
    }
    pi p1(0, 0), p2, p3;
    p2.l = p3.r = r;
    p2.r = 1; p3.l = r * r - s;
    if (r * r == s)
        p2.r = p3.l = 0;
    cout << p1 << ' ' << p2 << ' ' << p3;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;

int n, m, x;
int c[12], a[12][12];

int main()
{
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int all = 1 << n;
    int mincost = INT_MAX;
    for (int mask = 0; mask < all; mask++) {
        int cost = 0;
        vector<int> level(m);
        for (int i = 0; i < n; i++) {
            if ((mask >> i) & 1) {
                cost += c[i];
                for (int j = 0; j < m; j++)
                    level[j] += a[i][j];
            }
        }
        bool ok = true;
        for (int j = 0; j < m; j++) {
            if (level[j] < x) ok = false;
        }
        if (ok) {
            mincost = min(mincost, cost);
        }
    }
    if (mincost == INT_MAX)
        cout << -1 << endl;
    else
        cout << mincost << endl;
    return 0;
}

Measured memory_bytes: 3628
import itertools
N,K=map(int,input().split())
dlist=[list(map(int,input().split())) for i in range(2*K)]
alist=[]
num=0
for i in range(1,len(dlist),2):
  alist.append(dlist[i])
alist=list(itertools.chain.from_iterable(alist))
alist=set(alist)
ans=N-len(alist)
print(ans)

Measured memory_bytes: 9204
#include<stdio.h>
int search(int A[],int n,int key){
    int i=0;
    A[n]=key;
    while(A[i]!=key) i++;
    return i!=n;
}

int main(void){
    int n,A[10000+1],q,key,sum=0;
    int i;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
	scanf("%d",&key);
	if(search(A,n,key)) sum++;
    }
    printf("%d\n",sum);

    return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
#include<string.h>

int main() {
	char S[10], T[10], U[10];
	int  A, B;
	scanf("%s", S);
	scanf("%s", T);
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%s", U);

	if (!strcmp(S, U)) {
		printf("%d %d", A - 1, B);
	}
	else{
		printf("%d %d", A, B - 1);
	}
	return(0);
}

Measured memory_bytes: 128
#include<iostream>
#include<string.h>
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,b) loop(i,0,b)
using namespace std;
int main(){
    bool flag=1;
    int temp,n;
    int A[101];
    int c=0;
    int i=0;
    cin>>n;
    rep(i,n){
        cin>>A[i];
    }
    while(flag){
        flag=0;
        for(int j=n-1;j>0;j--){
            if(A[j]<A[j-1]){
                temp=A[j];
                A[j]=A[j-1];
                A[j-1]=temp;
                flag=1;
                c+=1;
            }
        }
    }
    rep(i,n){
        if(i==0) cout<<A[i];
        else cout<<" "<<A[i];
    }
    cout<<endl<<c<<endl;
}




Measured memory_bytes: 3100
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define gcd(a,b) __gcd(a,b)
#define endl '\n'
const int N=2e5+10;
const int inf=1e9;
const int mod=1e9+7;

int  main(int argc, char const *argv[])
{
	/*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);

	string s;
	cin >> s;

	//cout << s[2] << ' ' << s[3] << ' ' << s[4] << ' ' << s[5] << endl;

	if(s[2]==s[3] && s[4]==s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int x[100005]={};
  bool b[100005]={};
  for(int i=2; i<=100000; i++) {
    if(!b[i]) {
      for(int j=i*2; j<=100000; j+=i) {
        b[j]=true;
      }
    }
  }
  for(int i=3; i<=100000; i++) {
    if(!b[i]&&!b[(i+1)/2]) {
      x[i]=1;
    }
  }
  for(int i=3; i<=100000; i++) {
    x[i]+=x[i-1];
  }
  int q,l,r;
  cin >> q;
  while(q--) {
    cin >> l >> r;
    cout << x[r]-x[l-1] << endl;
  }
}

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

int main(void){
    string N;
    cin >> N;
    REP(i,3){
        if(N[i]-'\0' == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
    
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N; cin>>N;
    int ans = 0;
    vector<int> a; 
    int tmp;
    int cnt[N]; REP(i,N) cnt[i]=0;
    REP(i,N) {
        cin>>tmp;
        if (tmp>N) ans++;
        else {
            cnt[tmp-1]++;
            a.push_back(tmp);
        }
    }
    REP(i,N) {
        if (cnt[i]>i+1) ans+=cnt[i]-i-1;
        else if (cnt[i]<i+1) ans+=cnt[i];
    }
    cout<<ans<<endl;
}


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

void cnt_passenger(){
    int N,K; cin >> N >> K;
    int height[N]={};
    int cnt=0;
    for(int i=0;i<N;i++){
        cin >> height[i];
        if(height[i]>=K){
            cnt+=1;
        }
    }
    cout << cnt << endl;
}

int main(){
    cnt_passenger();
    return 0;
}

Measured memory_bytes: 640
arr = []
n = int(input())

for i in range(n):
    arr.append([int(s) for s in input().split(" ")])



import math

def calculate(n, arr):
    for i in range(101):
        for j in range(101):

            centerH = -100

            for ar in arr:
                posX = ar[0]
                posY = ar[1]
                posH = ar[2]

                if posH > 0:

                    if centerH == -100:
                        centerH = posH + int(math.fabs(i - posX)) + int(math.fabs(j - posY))
                        continue

                    tmp = posH + int(math.fabs(i - posX)) + int(math.fabs(j - posY))

                    if tmp != centerH:
                        centerH = -2
                        break

            for ar in arr:
                posX = ar[0]
                posY = ar[1]
                posH = ar[2]
                if posH == 0:
                    if int(math.fabs(i - posX)) + int(math.fabs(j - posY)) < centerH:
                        centerH = -2
                        break

            if centerH != -2:
                print(i, j, centerH)





calculate(n, arr)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
    if(x>y) swap(x,y);
    if(y%x==0) return x;
    else return gcd(y%x,x);
    
    return 0;
}
int main(void){
    // Your code here!
    int a,b,k;cin>>a>>b>>k;
    int cou=0;
    for(int i=100;i>=1;i--){
        if(a%i==0&&b%i==0)cou++;
        if(cou==k){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
bool used[114514];
signed main(){
	int n;
	cin>>n;
	int ans = 0;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=30;i>=0;i--){
		int cnt = 0;
		for(int j=0;j<n;j++){
			if( (a[j]>>i)%2 ) cnt++;
		}
		if( cnt % 2 == 1 ){
			bool fl = false;
			for(int j=0;j<n;j++){
				if( a[j] == (1<<i) && fl == false && used[j] == false){
					a[j]--;
					ans++;
					fl = true;
					used[j] = true;
				}
			}
			if( fl == false ){
				cout<<-1<<Endl;
				return 0;
			}
		}
		for(int j=0;j<n;j++){
			a[j] = a[j] % (1<<i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;


namespace VirtualAtCorder
{
    class Program
    {

        static void Main(string[] args)
        {
            string inputs = Console.ReadLine();

            string output = "";

            foreach (char c in inputs)
            {
                if ('0' == c)
                {
                    output += c;
                }
                else if ('1' == c)
                {
                    output += c;

                }
                else if ('B' == c)
                {
                    if(!string.IsNullOrEmpty(output)) output = output.Remove(output.Length - 1, 1);
                }
            }

            if (string.IsNullOrEmpty(output))
            {
                output = " ";
            }

            Console.WriteLine(output);


            Console.ReadKey();
        }


    }
}


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

int main(){
	int c1,c5,c10,c50,c100,c500,co;
	cin>>c1>>c5>>c10>>c50>>c100>>c500;
	co=c1+c5*5+c10*10+c50*50+c100*100+c500*500;
	if(co>=1000){
		cout<<"1"<<endl;
		}else{
		cout<<"0"<<endl;
	}
return 0;
}

Measured memory_bytes: 1156
#include<string.h>
#include <iostream>
using namespace std;

int main(){

	int N,M,a[60],b[60],lop,lop2,cnt=0;
	cin >> N;
	cin >> M;
	
	for(lop=0;lop<M;lop++){
		cin >> a[lop];
		cin >> b[lop];
	}

	for(lop=1;lop<N+1;lop++){
		for(lop2=0;lop2<M;lop2++){
			if(a[lop2]==lop){
				cnt++;
			}
			if(b[lop2]==lop){
				cnt++;
			}
		}
	cout << cnt << endl;
	cnt=0;
	}

	return 0;
}

Measured memory_bytes: 256
public class Main {


  private static void solve() {
    int h = ni();
    int w = ni();
    char[][] map = new char[h + 2][w + 2];
    for (int i = 0; i < h; i++) {
      char[] line = ns();
      for (int j = 0; j < w; j++) {
        map[i + 1][j + 1] = line[j];
      }
    }

    int mod = 1000000000 + 7;
    long[][] dp = new long[h + 2][w + 2];
    dp[1][1] = 1;
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if (map[i][j] != '.')
          continue;
        dp[i][j] += dp[i - 1][j];
        dp[i][j] += dp[i][j - 1];
        dp[i][j] %= mod;
      }
    }
    System.out.println(dp[h][w]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 40076
'use strict'

function Main(input) {
    const S = input.trim()
    const output = operate(S)
    console.log(output)
}

function operate(S) {
    let detMin = null
    for (let i = 0; i < S.length - 2; i++) {
        const n = parseInt(S.substring(i, i + 3))
        const det = Math.abs(753 - parseInt(S.substring(i, i + 3)))
        if (detMin == null || det < detMin) {
            detMin = det
        }
    }
    return detMin
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll a[6];
int main(){FAST;
ll n=5;
for(ll i=0;i<n;i++){
	cin>>a[i];
}
ll k;cin>>k;
sort(a,a+n);
if(a[n-1]-a[0]>k){
	cout<<":(";
}
else{
	cout<<"Yay!";
}
return 0;
}


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

using namespace std;

int main()
{
    string A, B;
    cin >> A >> B;
    if (A.length() < B.length()) {
        cout << "LESS";
    } else if (B.length() < A.length()) {
        cout << "GREATER" << endl;
    } else if (A < B) {
        cout << "LESS" << endl;
    } else if (B < A) {
        cout << "GREATER" << endl;
    } else {
        cout << "EQUAL" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int getidx(int x, int n) { return x + n; }

int main() {
  //
  string s;
  cin >> s;
  int n = s.size();
  ll X, Y;
  cin >> X >> Y;
  bool xmove = true;
  vl dx, dy;
  ll cnt = 0;
  rep(i, s.size()) {
    if (s[i] == 'F') {
      cnt++;
    } else {
      if (xmove) {
        // cerr << "dx:" << cnt << endl;
        dx.push_back(cnt);
      } else {
        // cerr << "dy:" << cnt << endl;
        dy.push_back(cnt);
      }
      xmove = !xmove;
      cnt = 0;
    }
  }
  if (cnt > 0) {
    if (xmove) {
      // cerr << "dx:" << cnt << endl;
      dx.push_back(cnt);
    } else {
      // cerr << "dy:" << cnt << endl;
      dy.push_back(cnt);
    }
  }

  vector<vector<bool>> dpx(2, vector<bool>(2 * n + 1, false));
  vector<vector<bool>> dpy(2, vector<bool>(2 * n + 1, false));
  dpx[0][getidx(0, n)] = true;
  if (dx.size() > 0) {
    dpx[1][getidx(dx[0], n)] = true;
    // cerr << getidx(dx[0], n) << endl;
  }
  for (int i = 1; i < dx.size(); i++) {
    for (int x = -n; x <= n; x++) {
      dpx[(i + 1) & 1][getidx(x, n)] = false;
    }
    for (int x = -n; x <= n; x++) {
      if (dpx[i & 1][getidx(x, n)] == true) {
        if (x - dx[i] >= -n) dpx[(i + 1) & 1][getidx(x - dx[i], n)] = true;
        if (x + dx[i] >= -n) dpx[(i + 1) & 1][getidx(x + dx[i], n)] = true;
      }
    }
  }
  // cerr << "!" << endl;
  dpy[0][getidx(0, n)] = true;
  for (int i = 0; i < dy.size(); i++) {
    for (int y = -n; y <= n; y++) {
      dpy[(i + 1) & 1][getidx(y, n)] = false;
    }
    for (int y = -n; y <= n; y++) {
      if (dpy[i & 1][getidx(y, n)] == true) {
        if (y - dy[i] >= -n) dpy[(i + 1) & 1][getidx(y - dy[i], n)] = true;
        if (y + dy[i] >= -n) dpy[(i + 1) & 1][getidx(y + dy[i], n)] = true;
      }
    }
  }
  if (dpx[(dx.size()) & 1][getidx(X, n)] &&
      dpy[(dy.size()) & 1][getidx(Y, n)]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int h=sc.nextInt(),m=sc.nextInt(),h2=sc.nextInt(),m2=sc.nextInt(),k=sc.nextInt();
	  int kh=k/60,km=k%60;
	  if(m2>=km) {
		  kh=h2-kh;
		  km=m2-km;
	  }else {
		  kh=h2-kh-1;
		  km=60-km+m2;
	  }
	  //System.out.println(kh+" "+km);
	  if(km>=m) {
		  kh=kh-h;
		  km=km-m;
	  }else {
		  kh=kh-h-1;
		  km=60-m+km;
	  }
	  System.out.println(kh*60+km);
  }
}



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

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

long long MOD = 10000000000 + 7;

// dijkstra法 
int INF = 1000000;
int N;
vector<vector<int>> v;
vector<int> dist;

bool operator>(pil x, pil y){
  return x.second > y.second;
}

void shortest_path(int s){
  // sから各点への最短距離計算
  dist.assign(N,INF);
  priority_queue<pil, vector<pil>, greater<pil>> q;

  dist[s] = 0;
  map<int,int> check;
  q.push(make_pair(s, dist[s]));
  check[s] = 1;

  while(!q.empty()){
    pil now = q.top();
    int now_v = now.first;
    int now_dist = now.second;
    check[now_v] = 1;
    q.pop();

    if(dist[now_v] < now_dist) continue;
    
    for(int next_v: v.at(now_v)){
      if(dist[next_v] > dist[now_v] + 1){
        dist[next_v] = dist[now_v] + 1;
        q.push(make_pair(next_v, dist[next_v]));
      }
    }
  }
}

int main(){
  cout << setprecision(10);
  int H,W; cin >> H >> W;
  int sx,sy; cin >> sx >> sy;
  sx--; sy--;
  int gx, gy; cin >> gx >> gy;
  gx--; gy--;

  vector<string> S(H);
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }

  vector<vector<int>> sim(H, vector<int>(W, -1));

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


  int sim_num = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){


      if(sim[i][j] == -1 && S[i][j] == '.'){
        sim[i][j] = sim_num;
        queue<pii> q;
        q.push(make_pair(i,j));
        while(!q.empty()){
          int now_x = q.front().first;
          int now_y = q.front().second;
          q.pop();

          for(int k = 0; k < 4; k++){
            int next_x = now_x + dx[k];
            int next_y = now_y + dy[k];

            if(next_x < 0 || next_x >= H) continue;
            if(next_y < 0 || next_y >= W) continue;
            if(S[next_x][next_y] == '#') continue;

            if(sim[next_x][next_y] == -1){
              sim[next_x][next_y] = sim_num;
              q.push(make_pair(next_x, next_y));
            }

          }
        }
        sim_num++;
      }
    }
  }

  N = sim_num;
  v.assign(sim_num, vector<int>());

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(sim[i][j] == -1) continue;

      int now = sim[i][j]; // 今の同地類
      // cerr << " now: " << now << endl;
      for(int k = -2; k <= 2; k++){
        for(int l = -2; l <= 2; l++){
          int next_x = i + k;
          int next_y = j + l;

          if(next_x < 0 || next_x >= H) continue;
          if(next_y < 0 || next_y >= W) continue;
          if(sim[next_x][next_y] == -1) continue;

          int next = sim[next_x][next_y];
          if(now == next) continue;

          //if(check[now][next] == -1){
          if(find(v[now].begin(), v[now].end(), next) == v[now].end()){
            v[now].push_back(next);
            v[next].push_back(now);
          }
        }
      }
    }
  }

  int start = sim[sx][sy];
  int goal = sim[gx][gy];
  shortest_path(start);

  if(start == goal){
    cout << 0 << endl;
    return 0;
  }

  if(dist[goal] == INF){
    cout << -1 << endl;
  } else { 
    cout << dist[goal] << endl;
  }
}



Measured memory_bytes: 26604
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[]a = sc.nextIntArr(n);
        int[]b = sc.nextIntArr(n);
        Stack<Integer>[]ids= new Stack[n+1];
        for (int i =0;i<=n;i++)ids[i]=new Stack<>();
        int sum=0;
        for (int i =0;i<n;i++){
            if (a[i]==b[i]){
                ids[b[i]].add(i);
            }
        }
        Stack<Integer>cur = new Stack<>();
        for (int i =0;i<=n;i++){
            while (!cur.isEmpty()&&!ids[i].isEmpty()){
                int c= cur.pop();
                int d = ids[i].pop();
                int t =b[c];
                b[c]=b[d];
                b[d]=t;
            }
            while (!ids[i].isEmpty())cur.add(ids[i].pop());
        }
        if (!cur.isEmpty()){
            for (int i =0;i<n&&!cur.isEmpty();i++){
                if (a[i]!=b[cur.peek()]&&b[i]!=b[cur.peek()]){
                    int t = b[cur.peek()];
                    b[cur.pop()]=b[i];
                    b[i]=t;
                }
            }
            if (cur.isEmpty()){
                pw.println("Yes");
                for (int i =0;i<n;i++)
                    pw.print(b[i]+" ");
                pw.println();
            }
            else pw.println("No");
        }
        else {
            pw.println("Yes");
            for (int i =0;i<n;i++)
                pw.print(b[i]+" ");
            pw.println();
        }
        pw.flush();
    }
    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }

    }

}

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

int main()
{
  int x, y;
  int a, b;

  cin >> x >> y;

  if(y-2*x >= 0 && (y-2*x)%2 == 0 && 4*x-y >= 0 && (4*x-y)%2 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<time.h>
#include<cmath>
using namespace std;


int main(void)
{
	int a[200], N, i, T = 1 << 16;
	scanf("%d", &N);
	for (i = 0; i < N; i++)
	{
		int t = 0;
		scanf("%d", &a[i]);
		
		while (a[i] % 2 == 0)
		{
			a[i]=a[i]/ 2;
			t++;
		}
		T = (T < t) ? T : t;

		
	}
	printf("%d", T);
	
	


	


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int shar;
typedef double shara;
typedef string w;
int main(){
    w s;
    cin>>s;
    if(s.at(0)==s.at(1)||s.at(2)==s.at(3))
    {cout<<"Bad";}
    else if(s.at(1)==s.at(2))
    {cout<<"Bad";}
    else{cout<<"Good";}
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  int n;
  cin>>n;
  std::vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  std::vector<int> max;
  max.push_back(a[0]);
  for(int i=1;i<n;i++){
    if(max.size()==1){
      if(max[0]<a[i]){
        max[0]=a[i];
      }else{
        max.push_back(a[i]);
      }
    }else{
      int left=-1;
      int right=max.size();
      while(right-left>1){
        int mid=left+(right-left)/2;
        if(max[mid]<a[i]){
          right=mid;
        }else{
          left=mid;
        }
      }
      int res=right;
      if(res==max.size()){
        max.push_back(a[i]);
      }else{
        max[res]=a[i];
      }
    }
  }

  cout<<max.size()<<endl;


  return 0;
}


Measured memory_bytes: 1276
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, V = MAP()
B, W = MAP()
T = INT()

if V <= W:
	print("NO")
	exit()

t = abs(A-B)/(V-W)

print("YES" if t <= T else "NO")


Measured memory_bytes: 10600
K,A,B = map(int, input().split())
bis=1
nokori_kaisuu=K
if A+3<B:
    tataki_onechange_max=K-2
    if tataki_onechange_max+1>=A:
        bis+=((A-1)+(B-A))
        nokori_kaisuu-=((A-1)+2)
        more_change_kaisuu=nokori_kaisuu//2
        bis+=(B-A)*more_change_kaisuu
        nokori_kaisuu-=2*more_change_kaisuu
        if nokori_kaisuu==1:
            bis+=1
    else:
        bis+=K
else:
    bis+=K
print(bis)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#define MAX_N 55
#define INF 1000000000

using namespace std;

struct Data
{
	int x,y;
	Data(int _x,int _y) { x=_x,y=_y; }
	Data(){}
};

int n;
int mx=-INF,mxid;
int mn=INF,mnid;
int a[MAX_N];
vector<Data> v;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>mx) mx=a[i],mxid=i;
		if(a[i]<mn) mn=a[i],mnid=i;
	}
	if(mn>=0 || (mx>=0 && mx>=(-mn)))
	{
		for(int i=1;i<=n;i++)
		{
			if(a[i]<0)
			{
				a[i]+=mx;
				v.push_back(Data(mxid,i));
			}
		}
		for(int i=2;i<=n;i++)
		{
			a[i]+=a[i-1];
			v.push_back(Data(i-1,i));
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			if(a[i]>0)
			{
				a[i]+=mn;
				v.push_back(Data(mnid,i));
			}
		}
		for(int i=n-1;i>=1;i--)
		{
			a[i]+=a[i+1];
			v.push_back(Data(i+1,i));
		}
	}
	printf("%d\n",(int)v.size());
	for(int i=0;i<v.size();i++) printf("%d %d\n",v[i].x,v[i].y);
	/*for(int i=1;i<=n;i++) cout<<a[i]<<" "; cout<<endl;
	for(int i=2;i<=n;i++) if(a[i]<a[i-1]) { cout<<"WA"<<endl; return 0; }
	cout<<"AC"<<endl;*/
}


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

int main(){
    int H, W;
    char c;
    cin >> H >> W;
    char mat[H][W];
    for(int j=0; j<H; j++){
        for(int i=0; i<W; i++){
            cin >> c;
            mat[j][i] = c;
        }
    }
    for(int j=0; j<H; j++){
        for(int i=0; i<W; i++){
            if(mat[j][i] == '.'){
                continue;
            }
            if(i != 0){
                if(mat[j][i-1] == '#'){
                    continue;
                }
            }
            if(i != W-1){
                if(mat[j][i+1] == '#'){
                    continue;
                }
            }
            if(j != 0){
                if(mat[j-1][i] == '#'){
                    continue;
                }
            }
            if(j != H-1){
                if(mat[j+1][i] == '#'){
                    continue;
                }
            }
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = gets.split(" ").map(&:to_i)
ac = Array.new(N,0)
wa = Array.new(N,0)
M.times do |i|
    pr,s = gets.split(" ")
        if s == 'AC'
            if ac[pr.to_i-1] == 0
                ac[pr.to_i-1] += 1
            end
        elsif s == 'WA'
            if ac[pr.to_i-1] == 0
                wa[pr.to_i-1] += 1
            end
        end   
end
ans1 = 0
ans2 = 0
0.step(N-1) do |i|
    if ac[i] != 0
        ans1 += ac[i]
        ans2 += wa[i]
    end
end
printf("%d %d",ans1,ans2)

Measured memory_bytes: 3324
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int d,n;
  int res;
  cin>>d>>n;
  if(n==100 && d==0) cout<<"101"<<endl;
  else if(n==100 && d==1) cout<<"10100"<<endl;
  else if(n==100 && d==2) cout<<"1010000"<<endl;
  else{
     res=n*pow(100,d);
     cout<<res<<endl;
  }  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b,x=0,y=0,z=0;
	cin>>n>>a>>b;
	vl p(n);
	rep(i,n)cin>>p[i];
	rep(i,n){
		if(p[i]<=a)x++;
		else if(b<p[i])z++;
		else y++;
	}
	cout<<min({x,y,z})<<endl;

}

 

Measured memory_bytes: 256
S = input()

sum = 0
for i in range(1 << len(S)-1):
    l = []
    for j in range(len(S)-1):
        if (i >> j) & 1 == 1:
            l.append(S[j])
            l.append("+")
        else:
            l.append(S[j])
    l.append(S[len(S)-1])
    sum += eval(''.join(l))
print(sum)

Measured memory_bytes: 39152