akhauriyash/Code-Regression huggingface dataset:
a, b, c, d = map(int, input().split())
if a == b and c == d:
  print(a*c)
else:
  p1 = a*c
  p2 = a*d
  p3 = b*c
  p4 = b*d
  print(max(p1,p2,p3,p4))

Measured memory_bytes: 9140
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

class LazySegmentTree {
private:
	int size_;
	vector<long long> v, lazy;
	void update(int a, int b, long long x, int k, int l, int r) {
		push(k, l, r);
		if (r <= a || b <= l) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			push(k, l, r);
		}
		else {
			update(a, b, x, k * 2, l, (l + r) >> 1);
			update(a, b, x, k * 2 + 1, (l + r) >> 1, r);
			v[k] = merge(v[k * 2], v[k * 2 + 1]);
		}
	}
	long long query(int a, int b, int k, int l, int r) {
		push(k, l, r);
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return v[k];
		long long lc = query(a, b, k * 2, l, (l + r) >> 1);
		long long rc = query(a, b, k * 2 + 1, (l + r) >> 1, r);
		return merge(lc, rc);
	}
 
public:
	LazySegmentTree() : v(vector<long long>()), lazy(vector<long long>()) {};
	LazySegmentTree(int n) {
		for (size_ = 1; size_ < n;) size_ <<= 1;
		v.resize(size_ * 2,0);
		lazy.resize(size_ * 2,0);
	}
	inline void push(int k, int l, int r) {
		if (lazy[k] != 0) {
			v[k] += lazy[k];
			if (r - l > 1) {
				lazy[k * 2] += lazy[k];
				lazy[k * 2 + 1] += lazy[k];
			}
			lazy[k] = 0;
		}
	}
	inline long long merge(long long x, long long y) {
		return max(x, y);
	}
	inline void update(int l, int r, long long x) {
		update(l, r, x, 1, 0, size_);
	}
	inline long long query(int l, int r) {
		return query(l, r, 1, 0, size_);
	}
};

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	int ans = max(0,n-m);
	LazySegmentTree st(m+3);
	for(int i=1;i<=m+1;i++) st.update(i,i+1,i);
	vector<ii> vec;
	for(int i=0;i<n;i++)
	{
		int l,r; cin>>l>>r; vec.pb(mp(l,r));
	}
	sort(vec.begin(),vec.end());
	int ptr=0;
	for(int l=0;l<=m;l++)
	{
		while(ptr<vec.size()&&vec[ptr].fi<=l)
		{
			st.update(1,vec[ptr].se+1,1);
			ptr++;
		}
		int q = st.query(l+1,m+2);
		ans=max(ans,q-l-(m+1));
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 10612
#include <bits/stdc++.h>
using namespace std;
int n, a, b;
int main() {
	while(cin >> n, n) {
		int p = 0, q = 0;
		while(n--) {
			cin >> a >> b;
			if(a > b) p += a + b;
			else if(a < b) q += a + b;
			else p += a, q += b;
		}
		cout << p << ' ' << q << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
  int N,n=0,s=1;
  cin >> N;
  vector<int>a(N);
  for(int i=0 ; i<N ; i++){
      cin >> a[i];
  }
  for(int i=0;i<N;i++){
    if(a[i]==s){
        s++;
    }else{
        n++;
    }
  }
  if(n==a.size()){
      n= -1;
  }

  cout << n;

}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n;
  cin >> n;
  vector<ll> h(n, 0);

  for (ll i = 0; i < n; ++i) {
    cin >> h[i];
  }

  vector<ll> t;
  ll prev = h[0];
  ll cnt = 0;
  for (ll i = 1; i < n; ++i) {
    if (prev >= h[i]) {
      ++cnt;
    } else {
      t.push_back(cnt);
      cnt = 0;
    }
    prev = h[i];
  }
  t.push_back(cnt);
  sort(t.begin(), t.end(), greater<ll>());

  cout << t[0] << endl;
  
  return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <cstring>
#include <ctype.h>
using namespace std;
int main(void){
char str[100];
cin>>str;
int a=0;
int b=0;
int c=0;
int N;
if(str[0]=='A'){a=1;}
N=strlen(str);
int ans;
ans=0;
for(int i=2;i<=N-1;i++)
{if(str[i]=='C') ans=ans+1;
}
if(ans==1){b=1;}
int sum=0;
for(int j=0;j<N;j++){if(islower(str[j])==0)sum++;}
if(sum==2&&(str[N-1]!='C')){c=1;}
if(a==1&&b==1&&c==1){cout<<"AC";}
else cout<<"WA";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n;cin>>n;
    ll a[2*n-1];
    rep(i,0,2*n-2){
        cin>>a[i];
    }
    ll l=1,r=2*n;
    while(r-l>1){
        ll mid=(r+l)/2;
        bool b[2*n-1];
        rep(i,0,2*n-2){
            if(a[i]>=mid){
                b[i]=true;
            }else{
                b[i]=false;
            }
        }
        ll le=-1,ri=2*n-1;
        int bl=0,br=0;
        ll mi=n-1;
        for(ll i=mi-1;i>=0;i--){
            if(b[i] && b[i+1]){
                le=i+1;
                bl=1;
                break;
            }else if(!b[i] && !b[i+1]){
                le=i+2;
                bl=0;
                break;
            }else if(b[i] && !b[i+1]){
                le=i;
            }
        }
        for(ll i=mi+1;i<=2*n-2;i++){
            if(b[i] && b[i-1]){
                ri=i-1;
                br=1;
                break;
            }else if(!b[i] && !b[i-1]){
                ri=i-2;
                br=0;
                break;
            }else if(b[i] && !b[i-1]){
                ri=i;
            }
        }
        bool res=true;
        if(bl && br){
            res=true;
        }else if(!bl && !br){
            if(le==0 && ri==2*n-2){
                res=true;
            }else{
                res=false;
            }
        }else if(bl && !br){
            ll k=(ri+le)/2;
            if(mi<=k){
                res=true;
            }else{
                res=false;
            }
        }else if(!bl && br){
            ll k=(ri+le)/2;
            if(k<=mi){
                res=true;
            }else{
                res=false;
            }
        }
        if(res){
            l=mid;
        }else{
            r=mid;
        }
    }
    cout<<l<<endl;
    
    return 0;
}




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

using namespace std;
using ll = long long int;

int main() {
	ll x;
	cin>>x;
	int f = 0;
	for(ll a = 1; a <= 200; a++) {
		for(ll b = -200; b <= 200; b++) {
			if(a*a*a*a*a - b*b*b*b*b == x) {
				cout<<a<<" "<<b<<endl;
				f = 1;
				break;
			}
		}
		if(f) break;
	}
	return 0;
}	
	


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0,p=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s%2==0)
		{
		if(s%5==0||s%3==0)
		{
		   continue;
	    }
	    else
	    {
	    	p=1;
		}
	    }
    }
    if(p==0)
    cout<<"APPROVED";
    else
    cout<<"DENIED";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

long long int a,b,x;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b>>x;
	if(!(a%x))cout<<(b/x)-(a/x)+1;
	else cout<<(b/x)-(a/x);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int a,b; 

int main()
{
	scanf("%d",&a);
	for(int i=a;i>=1;i--)
	{
	  b=int(sqrt(i));
	  if(b*b==i){
	  	b=i;break;
	  }	
	  
	}
  cout<<b;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int a = group(x);
    int b = group(y);
    if(a == b) System.out.println("Yes");
    else System.out.println("No");
  }
  public static int group(int a) {
    if(a == 2) return 1;
    else if(a == 4 || a == 6 || a == 9 || a == 11) return 2;
    else return 3;
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007


int main() {
    int N, X; cin >> N >> X;
    vector<int> A(N);
    for(int &a:A)
        cin >> a;
    
    ll ans = 0;
    if(A[0]>X){
        ans += A[0]-X;
        A[0] = X;
    }
    for(int i=0; i<N-1; i++){
        if(A[i+1]+A[i]>X){
            ans += A[i+1]+A[i]-X;
            A[i+1] -= A[i+1]+A[i]-X;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int l, r, d;
	cin >> l >> r >> d;
	int c = 0;
	for(int i = l; i <= r; i ++)
		c += (i % d == 0);
	cout << c;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
string s;
ll dp[8010][8010];
int d[4010][2];

void solve(){
    cin >> s;
    n=s.length();
    d[0][0]=0;
    d[0][1]=0;
    rep(i,2*n+1){
        rep(j,2*n+1) dp[i][j]=0;
    }
    rep(i,n) {
        int m=s[i]-'0';
        d[i+1][0]=d[i][0]+2-m;
        d[i+1][1]=d[i][1]+m;
    }
    Rep(i,n,2*n) {
        d[i+1][0]=d[i][0];
        d[i+1][1]=d[i][1];
    }
    rep(i,2*n+1){
        //cout << d[i][0] << " " << d[i][1] << endl;
    }
    dp[0][0]=1;
    rep(i,2*n){
        rep(j,2*n){
            if (d[i+1][0]>j){
                dp[i+1][j+1]+=dp[i][j];
                dp[i+1][j+1]%=mod;
            }
            if (d[i+1][1]>i-j){
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j]%=mod;
            }
            //cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }

    ll ans=0;
    rep(i,2*n+1){
        ans+=dp[2*n][i];
        ans%=mod;
    }

    cout << ans << endl;
}

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

Measured memory_bytes: 251264
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int point[101];
vector<int> pointed;
int main() {
	int N;
	cin >> N;
	for(int i=0;i<N*(N-1)/2;i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		if(c==d){
		point[a]++;
		point[b]++;
		}
		if(c>d){
			point[a]+=3;
		}
		if(c<d){
			point[b]+=3;
		}
	}
	for(int i=0;i<N;i++){
		pointed.push_back(point[i+1]);
///		cout << point[N] << endl;
	}
	sort(pointed.begin(),pointed.end());
	
	for(int i=1;i<=N;i++){
		for(int j=N-1;j>=0;j--){
			if(pointed[j]==point[i]){
				cout << N-j << endl;
			break;
			}
		}
	}
	
	// your code goes here
	return 0;
}

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



int main(){
    int n; cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    int ans=0;
    sort(d.begin(),d.end());
    if(d[n/2-1]==d[n/2]){
        cout << 0<<endl;
    }else{
        cout << d[n/2]-d[n/2-1] << endl;
    }


}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
const int maxn=100005,mod=1e9+7;
int n,m,dp[2][maxn];
ll dis[2][maxn];
bool mark[maxn];
int S,T;
struct edge{int v,w;};
struct data{
	int id;
	ll dis;
	bool operator < (const data &A) const {
		return dis>A.dis;
	}
};
vector<edge>E[maxn];
void add(int &x,const int &y){
	x+=y;
	if(x>=mod)x-=mod;
	if(x<0)x+=mod;
}
void solve(int S,ll *dis,int *dp){
	static priority_queue<data>Q;
	static bool vis[maxn];
	static int indeg[maxn];
	REP(i,1,n)dis[i]=1e18,vis[i]=0,indeg[i]=0;
	Q.push((data){S,dis[S]=0});
	while(!Q.empty()){
		int u=Q.top().id;Q.pop();
		if(vis[u])continue;
		vis[u]=1;
		REP(i,0,E[u].size()-1){
			int v=E[u][i].v;
			if(chkmin(dis[v],dis[u]+E[u][i].w))Q.push((data){v,dis[v]});
		}
	}
	REP(i,1,n)
		REP(j,0,E[i].size()-1)
			if(dis[E[i][j].v]==dis[i]+E[i][j].w)++indeg[E[i][j].v];
	static queue<int>q;
	q.push(S),dp[S]=1;
	while(!q.empty()){
		int u=q.front();q.pop();
		REP(i,0,E[u].size()-1){
			int v=E[u][i].v;
			if(dis[v]==dis[u]+E[u][i].w){
				add(dp[v],dp[u]);
				if(--indeg[v]==0)q.push(v);
			}
		}
	}
/*
	REP(i,1,n)write(dis[i],i==n?'\n':' ');
	REP(i,1,n)write(dp[i],i==n?'\n':' ');
*/
}
int main(){
	n=read(),m=read(),S=read(),T=read();
	REP(i,1,m){
		int u=read(),v=read(),w=read();
		E[u].pb((edge){v,w}),E[v].pb((edge){u,w});
	}
	solve(S,dis[0],dp[0]);
	solve(T,dis[1],dp[1]);
	REP(i,1,n)mark[i]=(dis[0][T]==dis[0][i]+dis[1][i]);
	int ans=1ll*dp[0][T]*dp[0][T]%mod;
	REP(i,1,n){
		if(!mark[i])continue;
		if(dis[0][i]==dis[1][i])
			add(ans,-1ll*dp[0][i]*dp[1][i]%mod*dp[0][i]%mod*dp[1][i]%mod);
		REP(j,0,E[i].size()-1){
			int v=E[i][j].v;
			if(!mark[v])continue;
			if(dis[0][v]==dis[0][i]+E[i][j].w)
				if((dis[0][v]>dis[1][v])&&(dis[1][i]>dis[0][i]))
					add(ans,-1ll*dp[0][i]*dp[1][v]%mod*dp[0][i]%mod*dp[1][v]%mod);
		}
	}
	write(ans,'\n');
	return 0;
}

Measured memory_bytes: 13040
#include<stdio.h>
int Prime(int x);
int main( ){
int i,j,n,x;
  int count=0;

scanf("%d",&n);
for(i = 0; i < n; i++){
scanf("%d",&x);
if(Prime(x)==1){
count++;
}

}
printf("%d\n",count);
return 0;
}

int Prime(int x){
int i;

if(x < 2) return 0;
 else if(x == 2) return 1;
if(x % 2 == 0) return 0;
for(i = 3; i*i <= x; i+=2){
if(x % i == 0) return 0;
}
return 1;
}



Measured memory_bytes: 2064
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MOD 998244353
#define MAX 200100
//#define NIL -1
//#define INFTY 1000000000000000000

LL mod_pow(LL x, LL n){
    LL ans = 1;
    while(n>0){
        if((n&1)==1){
            ans = (ans * x) % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ans;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0){
        u += MOD;
    }
    return u;
}

vector<LL> fac(MAX), finv(MAX);
void COMinit() {
    fac[0] = 1;
    finv[0] = 1;
    for (int i = 1; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        finv[i] = mod_pow(fac[i], (LL)MOD - 2) % MOD;
    }
}
 
LL COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
    LL n;
    LL m;
    LL k;
    LL ans=0;
    cin >> n >> m >> k;
    LL tmp=m;
    for(LL i=1; i<n; i++){
        tmp=(tmp*(m-1))%MOD;
    }

    COMinit();
    if(m==1){
        if(k!=n-1){
            ans=0;
        }else{
            ans=1;
        }
    }else{
        for(LL i=0; i<=k; i++){
            //cout << COM(n-1,i) << " " << tmp << endl;
            ans+=COM(n-1,i)*tmp;
            ans%=MOD;
            tmp=(tmp*modinv(m-1))%MOD;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6284
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<bitset>
#include<functional>
#include<climits>
using namespace std;
typedef pair<int,int>pii;
const int INF=1e9;
const int dx[]={0,-1,0,1},dy[]={-1,0,1,0};

int main(){
    bool f[10001];fill(f,f+10001,true);
    f[0]=f[1]=false;
    for(int i=2;i<=10000;i++){
        if(!f[i])continue;
        for(int j=i+i;j<=10000;j+=i)f[j]=false;
    }
    int n;
    while(scanf("%d",&n)!=EOF){
        int cnt=0;
        for(int i=0;i<n;i++){
            if(f[i+1]&&f[n-i])cnt++;
        }
        printf("%d\n",cnt);
    }

    return 0;

    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
int main(){
  while(true){
    string s;cin>>s;
    if(s == "#")break;
    char nw = 'a';
    for(int i = 0; s.size() > i; i++){
      if(s[i] == '0'){
        if(nw == 'x'){
          break;
        }else if(nw == 'a' || nw == 'y')nw = 'x';
        else if(nw == 'z')nw = 'w';
        else if(nw == 'w')nw = 'b';
        else if(nw == 'b')nw = 'y';
      }else{
        if(nw == 'y'){
          break;
        }else if(nw == 'a' || nw == 'w')nw = 'y';
        else if(nw == 'x')nw = 'z';
        else if(nw == 'z')nw = 'b';
        else if(nw == 'b')nw = 'x';
      }
    }
    if(nw == 'b')cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 3160
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;


std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);
 
    std::vector<std::string> result;
 
    while (first < str.size()) {
        std::string subStr(str, first, last - first);
 
        result.push_back(subStr);
 
        first = last + 1;
        last = str.find_first_of(del, first);
 
        if (last == std::string::npos) {
            last = str.size();
        }
    }
 
    return result;
}

int main(){
    int w,n;
    cin >> w >> n;
    vector<int> N(w);
    for(int i=0; i<w; i++) N[i]=i;
    // rep(i,w) cout << N[i]; cout << endl;
    // cout << endl;
    rep(i,n){
        string s;
        cin >> s;
        vector<string> A = split(s, ',');
        string a = A[0], b = A[1];
        // cout << a << " " <<b << endl;
        int tmp=N[stoi(a)-1];
        N[stoi(a)-1]=N[stoi(b)-1];
        N[stoi(b)-1]=tmp;

    }
    rep(i,w) cout << N[i]+1 << endl;
    return 0;
}


Measured memory_bytes: 3188
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int num = r * 100 + g * 10 + b;
        if (num % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        sc.close();
    }
}

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

using namespace std;
typedef double D;
typedef long long ll;
const ll mod=1e9+7;
const int MX=3e5+9;
int n,a[MX],sum;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n+1;i++)sum+=abs(a[i]-a[i-1]);
    for(int i=1;i<=n;i++){
        int x=sum;
        x-=abs(a[i]-a[i-1]);
        x-=abs(a[i]-a[i+1]);
        x+=abs(a[i-1]-a[i+1]);
        cout<<x<<endl;
    }
}


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

int t[5];

int main()
{
  for(int i =0; i<5; i++)
  {
    scanf("%d", &t[i]);
  }
  
  int timer = 0;
  int wait = 0;
  std::sort(t, t+5, [](int a, int b){return (a%10 + ((a%10 == 0) ? 10000 : 0)) > (b%10 + ((b%10 == 0) ? 10000 : 0));});
  
  for(int i =0; i<5; i++)
  {
    if(timer % 10 != 0)
    {
      int m = timer - (timer/10 * 10);
      timer += 10 - m;
    }
    timer += t[i];
  }
  printf("%d", timer);
  return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for(int i=0;i<m;++i){
    int k;
    cin >> k;
    for(int j=0;j<k;++j){
      int a;
      cin >> a;
      --a;
      s[i].push_back(a);
    }
  }
  vector<int> p(m);
  for(int i=0;i<m;++i){
    cin >> p[i];
  }
  long long res=0;
  for(int bit=0;bit<(1<<n);++bit){
    bool ok=true;
    for(int i=0;i<m;++i){
      int num=0;
      for(auto v : s[i]){
        if(bit & (1<<v)) ++num;
      }
      if(num%2!=p[i]) ok=false;
    }
    if(ok==true) ++res;
  }
  cout << res << endl;
  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct vector{
  int64 x,y;
} vec;

int64 innerNorm(vec a,vec b){
  return a.x*b.x+a.y*b.y;
}

int64 norm(vec a){
  return a.x*a.x+a.y*a.y;
}

int isParallel(vec a,vec b){
  int64 in=innerNorm(a,b);
  int64 x=norm(a);
  int64 y=norm(b);
  return in*in==x*y;
}

int isOrthogonal(vec a,vec b){
  return innerNorm(a,b)==0;
}

void run(void){
  int query;
  scanf("%d",&query);
  while(query--){
    int a,b,c,d,p,q,r,s;
    scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&p,&q,&r,&s);
    vec aa,bb;
    aa.x=c-a;
    aa.y=d-b;
    bb.x=r-p;
    bb.y=s-q;
    if(isParallel(aa,bb)){
      printf("2\n");
    } else if(isOrthogonal(aa,bb)){
      printf("1\n");
    } else {
      printf("0\n");
    }
  }
}

int main(void){
  run();
  return 0;
}



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

#define endl "\n"
#define INF 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int factmod(int n, int k) {
    int res = 1;
    int t = k;
    while (k--) {
        res = (res * (n - k)) % HELL;
    }
    int den = 1;
    while (t--) {
        den = (den * (t + 1)) % HELL;
    }
    den = fastpow(den, HELL - 2, HELL);
    res = (res * den) % HELL;
    return res;
}

int now() {
    return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int n, a, b;
    cin >> n >> a >> b;
    int res = (fastpow(2, n, HELL) - 1) % HELL;
    res = (res - factmod(n, a) - factmod(n, b) + 2 * HELL) % HELL;
    cout << res << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const double eps=1e-6,pi=acos(-1);
const int N=2e5+5,M=1e9+7,SEGM=4*N,OO=0x3f3f3f3f;
int t,n,m,k;
int a[N];
int b[N];

int main(){
    //freopen("myfile.txt","w",stdout);
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        scanf("%d",a+i);
    for(int i=n-1;i>-1;--i)
        scanf("%d",b+i);
    int l=n,r=-1;
    for(int i=0;i<n;++i){
        if(a[i]==b[i]){
            l=i;
            break;
        }
    }
    for(int i=n-1;i>-1;--i){
        if(a[i]==b[i]){
            r=i;
            break;
        }
    }
    for(int i=0;i<n;++i)
        if(l<=r&&b[l]!=a[i]&&b[l]!=b[i])
            swap(b[i],b[l++]);
    if(l<=r){
        printf("No\n");
    }else{
        printf("Yes\n");
        for(int i=0;i<n;++i)
            printf("%d%c",b[i]," \n"[i+1==n]);
    }
    return 0;
}


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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if ( L > R ) {
    cout << "Left" << endl;
  }
  if ( L == R ) {
    cout << "Balanced" << endl;
  }
  if ( L < R ) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [A[0]] + [y for x, y in zip(A, A[1:]) if x != y]
    seq = []
    answer = 1
    for x in B:
        if len(seq) < 2:
            seq.append(x)
            continue
        a, b = seq[-2:]
        if a > b > x or a < b < x:
            seq.append(x)
        else:
            answer += 1
            seq = [x]

    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14228
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();

		long M = (long) Math.ceil(Math.sqrt(N));

		int ans = Integer.MAX_VALUE;
		for(long i=M;i>0;i--) {
			if(N%i == 0) {
				int f = Math.max(String.valueOf(i).length(),String.valueOf(N/i).length());
				if(ans > f) {
					ans = f;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0022
{
    class Program
    {
        static void Main(string[] args)
        {
            string rStr = Console.ReadLine();

            int N = int.Parse(rStr.Split(' ')[0]);

            int M = int.Parse(rStr.Split(' ')[1]);

            rStr = Console.ReadLine();

            var voteArray = rStr.Split(' ');

            double sum = 0;

            List<double> numlis = new List<double>();

            for (int i = 0; i < voteArray.Length; i++)
            {
                sum += int.Parse(voteArray[i]);

                numlis.Add(int.Parse(voteArray[i]));
            }

            numlis.Sort();

            if ((sum / (4 * M)) <= numlis[numlis.Count - M])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27788
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//エラトステネスの篩
const int N = 50009;
vector<bool> p2(N, true);
void Eratosthenes() {
	p2[0] = false;
	p2[1] = false;
	for (int i = 0; i < N; ++i)if (p2[i])
		for (int j = i * 2; j < N; j += i)p2[j] = false;
}

int main() {
	Eratosthenes();
	vector<int> p;
	rep(i, N) {
		if (p2[i])p.pb(i);
	}

	while (true) {
		int n; scanf("%d", &n);
		if (n == 0)break;

		int ans = 0;
		for (auto m : p) {
			if (m > n / 2)break;
			if (p2[n - m]) {
				ans++;
			}
		}
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 3240
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	int N;
	ll a[100] = {};
	a[0] = 2; a[1] = 1;
	cin >> N;
	FOR(i, 2, N+1){
		a[i] = a[i-1]+a[i-2];
	}
	cout << a[N] << endl;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var HW = Console.ReadLine().Split().Select(long.Parse).ToList();
        var hw = Console.ReadLine().Split().Select(long.Parse).ToList();
        Console.WriteLine(HW[0] * HW[1] - HW[0] * hw[1] - hw[0] * HW[1] + hw[0] * hw[1]);
    }
}

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

int main() {
	int a,b;
	cin >> a >> b;
	cout << fixed << setprecision(5);
	cout << a/b << " " << a%b << " " << (double)a/(double)b << endl;
//	printf("%d %d %.5lf",a/b,a%b,(double)a/(double)b);
	return 0;
}

Measured memory_bytes: 3260
// 問題名: Railway Connection
// URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1182&lang=jp
// 所要時間: 100分
// --感想--
// 初めに(現在いる頂点, 直前まで使っていた鉄道会社, その鉄道会社の路線でここまで乗ってきた距離)の組を状態としてダイクストラ法で
// 運賃を最小化する方針で実装したが、時間計算量、空間計算量ともに少し厳しかった。同じ会社の鉄道に乗り続けるほど安くなることから、
// 同じ会社の鉄道の途中で一度降りてまたすぐに乗るような行動も認めてしまっても答えは変わらなく、こう考えて前処理をすると状態を
// 決めるのが頂点だけになることに中々気づけなかった。制約なども見て適切な解法を選択できるようにしたい。

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

#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)

int p[21], q[21][51], r[21][51];

int fare(int c, int L1, int R1){
    int sum = 0;
    for (int i = 0; i < p[c]; i++){
        int L2 = q[c][i], R2 = q[c][i + 1];
        sum += r[c][i] * max(0, min(R1, R2) - max(L1, L2));
    }
    return sum;
}

int main(){
    while(1){
        int N, M, C, s, g;
        cin >> N >> M >> C >> s >> g;
        if(N == 0)
            break;
        int x, y, d, c;
        int INF = 1e9, d1[101][101][21];
        for (int i = 1; i <= N;i++)
            for (int j = 1; j <= N;j++)
                for (int k = 1; k <= C;k++)
                    d1[i][j][k] = INF;
        for (int i = 0; i < M; i++){
            cin >> x >> y >> d >> c;
            d1[x][y][c] = min(d1[x][y][c], d);
            d1[y][x][c] = min(d1[y][x][c], d);
        }
        for (int i = 1; i <= C; i++)
            cin >> p[i];
        for (int i = 1; i <= C; i++){
            q[i][0] = 0;
            for (int j = 1; j < p[i]; j++)
                cin >> q[i][j];
            q[i][p[i]] = 1e9;
            for (int j = 0; j < p[i]; j++)
                cin >> r[i][j];
        }
        for (int l = 1; l <= C;l++)
            for (int k = 1; k <= N; k++)
                for (int i = 1; i <= N; i++)
                    for (int j = 1; j <= N; j++)
                        d1[i][j][l] = min(d1[i][j][l], d1[i][k][l] + d1[k][j][l]);
        vector<pair<int, int>> li[101];
        for (int i = 1; i <= N; i++){
            for (int j = 1; j <= N;j++){                
                if(i!=j){
                    int mi = INF;
                    for (int k = 1; k <= C;k++){
                        if(d1[i][j][k] < INF)
                            mi = min(mi, fare(k, 0, d1[i][j][k]));
                    }
                    if(mi < INF)
                        li[i].pb(mp(j, mi));
                }
            }
        }
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
        int d2[101];
        for (int i = 1; i <= N;i++)
            d2[i] = INF;
        que.push(mp(0, s));
        while(!que.empty()){
            int nd = que.top().first, now = que.top().second;
            que.pop();
            if(nd < d2[now]){
                d2[now] = nd;
                for (auto &e:li[now])
                    que.push(mp(nd + e.second, e.first));
            }
        }
        if(d2[g]<INF)
            cout << d2[g] << endl;
        else
            cout << "-1" << endl;
    }
}


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

struct union_find{
    vector<int> r;
    
    union_find(int n){
        r = vector<int> (n, -1);
    }
    
    int root(int x){
        if(r[x] < 0){
            return x;
        }else{
            return r[x] = root(r[x]);
        }
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }
        r[rx] += r[ry];
        r[ry] = rx;
    }
    
    int size(int x){
        return -r[root(x)];
    }
};

int main() {
    int n, m, a, b;
    cin >> n >> m;
    union_find UF(n);
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        UF.unite(a - 1, b - 1);
    }
    
    int ans = 0;
    
    for(int i = 0; i < n; i ++){
        ans = max(ans, UF.size(i));
    }
    cout << ans << endl;
    return 0;
}


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

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

 
const int MAXN = 1e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


signed main() {
	FAST_IO;
	int n;
	cin >> n;
	int c = 0;
	while (c < n) {
		c += 1000;
	}
	// c -= 1000;
	cout << abs(n - c);
 	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

// 拡張gcd
int ext_gcd(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1; y = 0; return a;
  }
  int q = a/b;
  int g = ext_gcd(b,a-q*b,x,y);
  int z = x-q*y;
  x = y; y = z;
  return g;
}

// 逆元 | a と mod は互いに素
int inv_mod(int a, int mod = MOD) {
  int x,y;
  ext_gcd(a,mod,x,y);
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

int N,D,X;
int dp[2010][2010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> N >> D >> X,N) {
    dp[0][0] = 1;
    REP(i,N) {
      int sum = 0;
      REP(j,N) {
        (sum += dp[i][j]) %= MOD;
        if (j+1-X >= 0) (sum += MOD-dp[i][j+1-X]) %= MOD;
        dp[i+1][j+1] = sum;
      }
    }
    int ans = 0;
    int comb = 1;
    FOR(i,1,min(N,D)+1) {
      comb = comb*((D-i+1)%MOD)%MOD*inv_mod(i)%MOD;
      (ans += dp[i][N]*comb%MOD) %= MOD;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 34508
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int Length = sc.nextInt();
        int[] number = new int[Length];
        for(int i=0; i<Length; i++){
            number[i] = sc.nextInt();
        }
        for(int i=Length-1; i>-1; i--){
            System.out.printf("%d", number[i]);
            if(i != 0){
                System.out.printf(" ");
            }
        } 
        System.out.println();
        sc.close();
    }
}


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

int main()
{
	int 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;
	}

	return 0;
}




Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9012337203685477580
using ll = long long;
using namespace std;

//powMod
ll powMod(ll k, ll n, ll mod) {
    ll x = 1;
    while (n > 0) {
        if (n & 1) {
            x = x * k % mod;
        }
        k = k * k % mod;
        n >>= 1;
    }
    return x;
}

ll comb(const ll &n, const ll &r, const ll &mod) {
    ll c = 1;
    for (ll i = 2; i <= n; i++)
    {
        c *= i;
        c %= mod;
    }
    ll a = 1;
    for (ll i = 2; i <= n - r; i++)
    {
        a *= i;
        a %= mod;
    }
    for (ll i = 2; i <= r; i++)
    {
        a *= i;
        a %= mod;
    }
    c *= powMod(a, mod - 2, mod);
    c %= mod;
    return c;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    ll ans = 1;
    for (int i = 2; i <= M; i++)
    {
        int k = 0;
        while (M % i == 0) {
            M /= i;
            k++;
        }
        if (k > 0) {
            ans *= comb(k + N - 1, k, MOD);
            ans %= MOD;
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 256
N = int(input())
li = [int(zz) for zz in input().split()]

count = 1
ans = 0
ind = 0
while ind < N:
    if li[ind] == count:
        count += 1
        ans += 1
    ind += 1

if ans != 0:
    print(N-ans)
else:
    print(-1)


Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("distinct.in","r",stdin);
    string s,t;
    cin>>s>>t;
    bool ok = true;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
            ok=false;
    }
    if(ok)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 50;
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int r = 0;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'R') r++;
    }
    int w = 0;
    int ans = 1e9;
    for(int i = 0;i < n + 1;i++){
        ans = min(ans, max(w, r));
        if(i == n) break;
        if(s[i] == 'R'){
            r--;
        }
        else{
            w++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3792
def main():
	# a,b,k = map(int,input().split())
	n = int(input())
	# s = str(input())
	a = list(map(int,input().split()))
	# l = [list(map(int, input().split())) for _ in range(n-1)]
	# s = list(s)
	
	a_sorted = sorted(a)
	# print(a)
	# print(a_sorted)
	ans = 0
	for i in range(n):
		if a[i] != a_sorted[i]:
			ans += 1
	if ans == 2 or ans == 0:
		print("YES")
	else:
		print("NO")


	
 
 
if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    map<int64_t, int64_t>d;
    for (int64_t i=0; i<N; i++) {
        int64_t num;
        cin >> num;
        if (d.count(num) > 0) {
            d[num] = d[num] + 1;
        } else {
            d[num] = 1;
        }
    }

    int64_t sum = 0;
    for (auto c : d) {
        if (c.first == c.second) {
            continue;
        } else if (c.second > c.first) {
            sum += c.second - c.first;
        } else if (c.first > c.second) {
            sum += c.second;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 9596
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>
#include<fstream>
#include<array>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	UnionFind(int N) :parent(N, 0), rank(N, 0)
	{
		rep(i, 0, N)parent[i] = i;
	}

	int find(int x)
	{
		if (parent[x] == x)return x;
		else return parent[x] = find(parent[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (x == y)return;

		if (rank[x] < rank[y])parent[x] = y;
		else {
			parent[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}

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

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

	int N, M;
	cin >> N >> M;

	UnionFind uf(N);
	int A, B;
	rep(i, 0, M)
	{
		cin >> A >> B;
		A--, B--;
		uf.unite(A, B);
	}

	set<int> vset;
	rep(i, 0, N)vset.insert(uf.find(i));

	cout << SZ(vset) - 1 << endl;

	return 0;
}


Measured memory_bytes: 8324
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0;i < n;i++){
			h[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0;i < n;i++){
			boolean vail = true;
			for(int j = 0;j < i;j++){
				if(h[j] > h[i]){
					vail = false;
					break;
				}
			}
			if(vail){
				ans++;
			}
		}
		
		System.out.print(ans);
	}
	


}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




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

int main() {
  int N, K, C = 1;
  cin >> N;
  cin >> K;

  for (int i = 0; i < N; i++) {
    if (2 * C > C + K){
      C += K;
    }
    else{
      C = 2 * C;
    }
  }
  
  cout << C << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int getID(char);
char getSuit(int);

int main(void)
{
    int card[4][13];

    int i,j,num;

    for(i=0;i<4;i++)
    {
        for(j=0;j<13;j++)
        {
            card[i][j]=0;
        }
    }

    scanf("%d",&num);

    for(i=0;i<num;i++)
    {
        char suit;
        int id,rank;

        scanf(" %c",&suit);
        scanf("%d",&rank);

        id=getID(suit);

        card[id][rank-1]=1;
    }

    for(i=0;i<4;i++)
    {
        for(j=0;j<13;j++)
        {
            if(card[i][j]==0) printf("%c %d\n",getSuit(i),j+1);
        }
    }

    return 0;
}

int getID(char suit)
{
    int id;

    if(suit=='S') id=0;
    else if(suit=='H') id=1;
    else if(suit=='C') id=2;
    else id=3;

    return id;
}
char getSuit(int id)
{
    char suit;

    if(id==0) suit='S';
    else if(id==1) suit='H';
    else if(id==2) suit='C';
    else suit='D';

    return suit;
}

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

int main(void) {
    string s; cin >> s;
    if (s.length() == 3) {
        for (int i = 0; i < 3; i++)
            cout << s[2 - i];
        cout << endl;
    }
    else {
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

A, B = map(int, input().split())
S = [i for i in input()]

for i in range(A+B+1):
    if i != A:
        if S[i] == '-':
            print('No')
            sys.exit()
    else:
        if S[i] != '-':
            print('No')
            sys.exit()

print('Yes')


Measured memory_bytes: 2940