akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


const int MAX_N=200010;
int n,dat[4*MAX_N-1];
int Seg_init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;++i)dat[i]=0;
    return n;
}
int Seg_calc(int a,int b){
    return (a+b)%3;
}
void Seg_update(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=Seg_calc(dat[2*k+1],dat[2*k+2]);
    }
}
/*
int Seg_query(int a,int b,int k,int l,int r){
    cout << a MM b MM k MM l MM r << endl;
    //外からはSeg_query(a,b,0,0,n)で呼ぶ
    if(r<=a||b<=l)return 0;
    if(a<=l&&r<=b)return dat[k];
    int vl=Seg_query(a,b,2*k+1,l,(l+r)/2);
    int vr=Seg_query(a,b,2*k+2,(l+r)/2,r);
    return Seg_calc(vl,vr);
}*/

int Seg_query(int a,int b){
    int R=0;
    a+=n;b+=n;
    
    while(a<b){
        if(a%2==1){
            R=Seg_calc(dat[a-1],R);
            a++;
        }
        if(b%2==1){
            b--;
            R=Seg_calc(R,dat[b-1]);
        }
        a/=2;b/=2;
    }
    
    
    return R;
}

signed main(void){
    string S,T;
    int Q;
    int A[114514],B[114514],C[114514],D[114514];
    int G[114514],H[114514];
    
    cin >> S >> T;
    cin >> Q;
    REP(i,Q){
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--;B[i]--;C[i]--;D[i]--;
    }
    
    //Aを1、Bを2、O(=AB)を0と扱う
    
    //Sをセグる
    Seg_init(S.size());
    REP(i,S.size()){
        Seg_update(i,(S[i]=='A'?1:2));
    }
    REP(i,Q){
        G[i]=Seg_query(A[i],B[i]+1);
    }
    //Tをセグる
    Seg_init(T.size());
    REP(i,T.size()){
        Seg_update(i,(T[i]=='A'?1:2));
    }
    REP(i,Q){
        H[i]=Seg_query(C[i],D[i]+1);
    }
    
    //REP(i,Q){cout << G[i] MM H[i] << endl;}
    
    REP(i,Q){
        if(G[i]==H[i]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 10240
//============================================================================
// Name        : HelloWorld.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int N;
	int P[21];
	cin>>N;
    for(int i=0;i<N;i++){
    	cin>>P[i];
    }
    int R=0;
    for(int i=1;i<N-1;i++){
    	if(P[i-1]>P[i]&&P[i]>P[i+1]){
    		R++;
    	}else if(P[i-1]<P[i]&&P[i]<P[i+1]){
    		R++;
    	}
    }
    cout<<R<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    if (n < 1000) {
        println("ABC");
    }
    else {
        println("ABD")
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
   int n;cin>>n;
   for (ll i = n; i < 10000000000; i+=n)
   {
      /* code */
      if (i%2==0&&i%n==0)
      {
         /* code */
         cout<<i<<endl;
         break;
      }
      
   }
   
   
   }
   



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

int main(void)
{
	int i,j,w,h,c;
	scanf("%d %d %c",&w,&h,&c);
	for(i=0;i<h;i++)	{
		for(j=0;j<w;j++)	{
			if((i==0 || i==h-1) && (j==0 || j==w-1))	{
				printf("+");
			}
			else if(i==0 || i==h-1)	{
				printf("-");
			}
			else if(j==0 || j==w-1)	{
				printf("|");
			}
			else if(j==w/2 && i==h/2)	{
				printf("%c",c);
			}
			else printf(".");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2592
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
const int MOD = 924844033;
using M = Mint<int, MOD>;
M dp[2][2020][2020]={};

signed main(){
  int n,k;
  cin>>n>>k;
  for(int i=0;i<min(n,k*2);i++){
    // tunaganai
    dp[0][0][i]+=M(1);

    // usirototunagu
    if(i>=k)
      dp[0][1][i]+=M(1);

    // maetotunagu
    if(i+k<n)
      dp[1][1][i]+=M(1);
  }

  for(int i=k*2;i<n;i++){
    for(int j=0;j<n;j++){
      // tunaganai
      dp[0][j+0][i]+=dp[0][j][i-k*2];
      dp[0][j+0][i]+=dp[1][j][i-k*2];

      // usirototunagu
      dp[0][j+1][i]+=dp[0][j][i-k*2];

      // maetotunagu
      if(i+k<n){
        dp[1][j+1][i]+=dp[0][j][i-k*2];
        dp[1][j+1][i]+=dp[1][j][i-k*2];
      }
    }
  }

  vector<M> ps({M(1)});
  for(int i=1;i<=min(n,k*2);i++){
    vector<M> qs;
    for(int j=0;j<=n;j++)
      qs.emplace_back(dp[0][j][n-i]+dp[1][j][n-i]);

    while(qs.back()==M(0)) qs.pop_back();

    vector<M> rs(ps.size()+qs.size()-1,M(0));
    for(int a=0;a<(int)ps.size();a++)
      for(int b=0;b<(int)qs.size();b++)
        rs[a+b]+=ps[a]*qs[b];

    ps=rs;
  }

  ps.resize(n+1,0);

  M ans{0};
  for(int i=0;i<=n;i++){
    M res=ps[i];
    for(int j=1;j<=n-i;j++) res*=M(j);
    if(~i&1)
      ans+=res;
    else
      ans-=res;
  }

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


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long int a, b, n;
	cin >> a >> b >> n;
	if(n < b) cout << ((a*n)/b);
	else cout << ((a*b-a)/b);
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<vector<int>> A(N, vector<int>(M));
    vector<int> B(M);
    for(int i = 0; i < M; i++) cin >> B[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++) cin >> A[i][j];
    }

    int counte = 0;
    for(int i = 0; i < N; ++i){
        int sum = 0;
        for(int j = 0; j < M; ++j){
            sum += A[i][j] * B[j];
        }
        if(sum + C > 0) counte++;
    }
    cout << counte << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;
const int maxd = 2e5+10;
typedef pair<int,int> P;
void solve()
{
    int n;scanf("%d",&n);
    int now =0;
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        if(now+1 == x) now++;
    }
    if(now == 0) printf("-1");
    else printf("%d",n-now);
}
int main()
{
//    freopen("a.in","r",stdin);
//    freopen("k.out","w",stdout);
    //int t;scanf("%d",t);
    int t = 1;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d = in.nextInt();
        int[][] x = new int[n][d];
        for(int a=0; a<n; a++) {
            for(int b=0; b<d; b++) {
                x[a][b] = in.nextInt();
            }
        }
        int c = 0;
        for(int i=0; i<n; i++) {
            for(int j=i+1; j<n; j++) {
                if(isInt(x[i], x[j])) {
                    c++;
                }
            }
        }
        System.out.println(c);
    }
    private static boolean isInt(int[] pi, int[] pj) {
        int dist = 0;
        for(int d=0; d<pi.length; d++) {
            dist += Math.pow(pj[d]-pi[d], 2);
        }
        int sqrt = (int)Math.round(Math.sqrt(dist));
        return dist == sqrt * sqrt;
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>

using namespace std;

template<class T> inline bool chmax(T& a,T b){
  if(a<b){
    a=b; 
    return 1;
  }
  return 0;
}

int GCD(int a,int b){return b?GCD(b,a%b):a;}
int main(){
  int N; cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a[i];

  vector<int> left(N+1,0),right(N+1,0);
  for(int i=0;i<N;i++)left[i+1]=GCD(left[i],a[i]);
  for(int i=N-1;i>=0;i--) right[i]=GCD(right[i+1],a[i]);

  int res=0;
  for(int i=0;i<N;i++){
    int l=left[i];
    int r=right[i+1];
    chmax(res,GCD(l,r));
  }

  cout<<res<<endl;

  return 0;

}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 100000+10;
ll dp1[maxn],dp2[maxn],dp3[maxn],N,M;
vi graph[maxn];

void dfs(int u,int p){
	dp1[u] = 1;
	vi nodes;
	for(auto &v : graph[u]){
		if(v == p)continue;
		nodes.pb(v);
		dfs(v,u);
	}
	if(nodes.empty())return;
	dp2[0] = dp1[nodes[0]]+1;
	for(int i = 1; i < nodes.size(); i++){
		dp2[i] = dp2[i-1];
		dp2[i] += ((dp2[i-1]%M)*(dp1[nodes[i]]%M))%M;
		dp2[i] %= M;
	}
	dp1[u] = dp2[nodes.size()-1];
}
void dfs2(int u,int p, ll arriba){
	vi nodes;
	for(auto &v : graph[u]){
		if(v == p)continue;
		nodes.pb(v);
	}
	if(nodes.empty())return;
	vector<ll> l(nodes.size()),r(nodes.size());
	l[0] = (dp1[nodes[0]]+1);
	r[nodes.size()-1] = (dp1[nodes.back()]+1);
	forn(i,1,nodes.size()){
		ll act = dp1[nodes[i]]+1;
		l[i] = ((l[i-1]%M)*(act%M))%M;
	}
	forr(i,nodes.size()-2,0){
		ll act = dp1[nodes[i]]+1;
		r[i] = ((r[i+1]%M)*(act%M))%M;
	}
	int cnt = 0;
	for(auto &v : graph[u]){
		if(v == p)continue;
		ll p1 = (cnt-1 < 0) ? 1 : l[cnt-1];
		ll p2 = (cnt+1 >= nodes.size()) ? 1 : r[cnt+1];
		ll sum = ((p1%M)*(p2%M))%M;
		dp3[v] = ((sum%M)*(arriba%M))%M; dp3[v]++;
		dp3[v] %= M;
		dfs2(v,u,dp3[v]);
		cnt++;
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	forn(i,0,N-1){
		int u,v; cin >> u >> v; u--; v--;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	dfs(0,0);
	dfs2(0,0,1);
	dp3[0] = 1;
	/*forn(i,0,N){
		cout << i+1 << ' ' << dp1[i] << ' ' << dp3[i] << ":D\n";
	}*/
	forn(i,0,N){
		ll res = ((dp1[i]%M)*(dp3[i]%M))%M;
		if(res < 0)res += M;
		cout << res << '\n';
	}
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


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

int a[51];
int b[51];

vector<int> g[51];
bool vis[51];

void dfs(int x){
	vis[x] = true;

	for(int to : g[x]){
		if(vis[to]) continue;
		dfs(to);
	}
}

int main(){
	int n,m;
	cin>>n>>m;

	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
	}

	int res = 0;
	for(int i=0;i<m;i++){
		for(int j=1;j<=n;j++) g[j].clear();

		for(int j=0;j<m;j++){
			if(i!=j){
				g[a[j]].push_back(b[j]);
				g[b[j]].push_back(a[j]);
			}
		}
		for(int k = 1;k<=n;k++) vis[k] = 0;
		dfs(1);
		int cnt = 0;
		for(int j=1;j<=n;j++){ 
			if(vis[j]) cnt++;
		}
		if(cnt<n) res++; 
	}
	cout<<res;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

void solve(){
}

int main(){
  int n;

  while(cin>>n){
    int t[n];
    rep(i,n){
      cin>>t[i];
    }
    sort(t,t+n);

    int ans = 0;
    int sum = 0;
    rep(i,n){
      sum += t[i];
      ans += sum;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define per(i,n,k) for(int i=n;i>=k;i--)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define ll long long
using namespace std;
const int maxn=100005;
struct edge
{
	int nxt,y;
} e[maxn];
int head[maxn],cnt;
int n,m,vis[maxn],ans;
queue<pii> q;
void add_edge(int x,int y)
{
	e[++cnt].y=y;
	e[cnt].nxt=head[x];
	head[x]=cnt;
}
int main()
{
	scanf("%d%d",&n,&m);
	rep(i,0,m-1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add_edge(x,y);
		vis[y]++;
	}
	rep(i,1,n) if(!vis[i]) q.push(mp(i,0));
	while(!q.empty())
	{
		pii u=q.front();
		int x=u.fi,val=u.se;
		ans=max(ans,val);
		q.pop();
		for(int i=head[x];i;i=e[i].nxt)
		{
			int y=e[i].y;
			vis[y]--;
			if(!vis[y])
			q.push(mp(y,val+1));
		}
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

 int main(){

  int r,D,x2000;
  cin>>r>>D>>x2000;

   int ans = x2000;

 for(int i=0;i<10;i++){

     ans = r*ans-D;
    cout<<ans<<endl;
 }

  return 0;
 }


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define ll long long
using namespace std; 
int main(){
	ll x,y,z,K;
	scanf("%lld %lld %lld %lld",&x,&y,&z,&K);
	vector<ll>a,b,c,ans;
	ll temp;
	for(int i=0; i<x; i++){
		scanf("%lld",&temp);
		a.push_back(temp);
	}
	for(int i=0; i<y; i++){
		scanf("%lld",&temp);
		b.push_back(temp);
	}
	for(int i=0; i<z; i++){
		scanf("%lld",&temp);
		c.push_back(temp);
	}
	sort(a.begin(),a.end(),greater<ll>());
	sort(b.begin(),b.end(),greater<ll>());
	sort(c.begin(),c.end(),greater<ll>());
	
	
	for(int i=0; i<x ; i++){
		for(int j=0; j<y ; j++){
			for(int k=0; k<z ; k++){
				if((i+1)*(j+1)*(k+1)>K)
					break ;
				else
					ans.push_back(a[i]+b[j]+c[k]);
			}
		}
	}

	sort(ans.begin(),ans.end(),greater<>());
	for(auto i:ans){
		if(!K)
			break;
		printf("%lld\n",(ll)i);
		K--;
	}
		
	return 0;
}
/*
2 2 2 8
4 6
1 5
3 8
*/


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

int e, m;

int main(void){
  while(cin >> e && e != 0){
    m = 1000000;
    for(int y = 0; y <= 1000; y++){
      for(int z = 0; z <= 100; z++){
        int x = e - y * y - z * z * z;
        if(x < 0) continue;
        if(x + y + z < m) m = x + y + z;
      }
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp(x,y) make_pair(x,y)
const int nax=2e5+5;
void solve(){
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    vector<int> v;
    vector<int> vis(n,-1);
    int ci=0;
    vis[ci]=0;
    int pos=-1;
    int gh=1;
    while(true){
        v.push_back(ci);
        ci=a[ci];
        if(vis[ci]!=-1){
            pos=vis[ci];
            break;
        }
        vis[ci]=gh++;
    }
    if(pos==(int)v.size()-1){
        int r=min(k,(ll)v.size()-1);
        cout<<v[r]+1<<'\n';
        return ;
    }
    if(k<=pos){
        cout<<v[k]+1<<'\n';
        return ;
    }
    k-=pos;
    int r=(int)v.size()-pos;
    cout<<v[pos+k%r]+1<<'\n';
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
    tc=1;
    while(tc--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6496
A, B = map(int, input().split())
S = input()
X = {str(i) for i in range(0, 10)}
f = 0
for i in range(A+B+1):
  if i != A and S[i] not in X:
    f = 1
    break
  if i == A and S[i] != "-":
    f = 1
    break
if f == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 61796
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 9)
 
H, W = list(map(int, input().split()))
G = [list(input()) for i in range(H)]
 
Visited = [[0] * W for i in range(H)]
direction = [[0, 1], [0, -1], [1, 0], [-1, 0]]
 
 
def dfs(ny, nx, color):
    for dy, dx in direction:
        if not ((0 <= ny + dy < H) and (0 <= nx + dx < W)):
            continue
 
        if G[ny + dy][nx + dx] == G[ny][nx]:
            continue
 
        if Visited[ny + dy][nx + dx] != 0:
            continue
 
        if G[ny + dy][nx + dx] == '#':
            Visited[ny + dy][nx + dx] = color
        else:
            Visited[ny + dy][nx + dx] = -color
 
        dfs(ny + dy, nx + dx, color)
 
 
Color = 1
for y in range(H):
    for x in range(W):
        if Visited[y][x] == 0:
            if G[y][x] == '#':
                Visited[y][x] = Color
            else:
                Visited[y][x] = -Color
            dfs(y, x, Color)
            Color += 1
 
 
D = defaultdict(int)
for row in Visited:
    for data in row:
        D[data] += 1
 
ans = 0
for key in D.keys():
    if -key in D.keys():
        ans += D[key] * D[-key]
 
print(ans // 2)

Measured memory_bytes: 151000
import java.util.Scanner;
import java.util.TreeSet;

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

		Scanner scan = new Scanner (System.in);
		
		//list作成
		TreeSet<Integer> set = new TreeSet<>();
		
		int a = scan.nextInt();
		for(int i=0; i<a; i++) {
			int num = scan.nextInt();
			set.add(num);
		}
		
		//list2作成
		TreeSet<Integer> set2 = new TreeSet<>();
		
		int b = scan.nextInt();
		for(int i=0; i<b; i++) {
			int num = scan.nextInt();
			set2.add(num);
		}
		
		//Symmetric Difference
		TreeSet<Integer> symDiff = new TreeSet<>(set);
		symDiff.addAll(set2);
		TreeSet<Integer> tmp = new TreeSet<>(set);
		tmp.retainAll(set2);
		symDiff.removeAll(tmp);
		
		
//		System.out.println("dubug");
//		System.out.println(intersection.size());
		
		for(int i : symDiff) {
			System.out.println(i);
		}

	}
}


Measured memory_bytes: 210324
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
	LL a[60],i,j,k,l,n;
	cin>>k;
	n=50;
	cout<<n<<endl;
	for(i=0;i<n;i++)	a[i]=n-1;
	j=k%n;	l=k/n;
	for(i=0;i<n;i++)
	{
		a[i]=a[i]+n*l;
		if(i<j)	a[i]+=n;
		if(j!=0&&i<j)	a[i]=a[i]-k+l+1;
		else a[i]=a[i]-k+l;
	}
	for(i=0;i<n;i++)
	{
		cout<<a[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		UnionFindTree uft = new UnionFindTree(n);
		for (int i = 0; i < m; i++) {
		    uft.unite(sc.nextInt() - 1, sc.nextInt() - 1);
		}
		int count = uft.getCount();
		System.out.println(count - 1);
	}
	
	static class UnionFindTree {
	    int[] parents;
	    
	    public UnionFindTree(int size) {
	        parents = new int[size];
	        for (int i = 0; i < size; i++) {
	            parents[i] = i;
	        }
	    }
	    
	    public int find(int x) {
	        if (x == parents[x]) {
	            return x;
	        } else {
	            return parents[x] = find(parents[x]);
	        }
	    }
	    
	    public boolean same(int x, int y) {
	        return find(x) == find(y);
	    }
	    
	    public void unite(int x, int y) {
	        if (!same(x, y)) {
	            parents[find(x)] = find(y);
	        }
	    }
	    
	    public int getCount() {
	        HashSet<Integer> set = new HashSet<>();
	        for (int i = 0; i < parents.length; i++) {
	            set.add(find(i));
	        }
	        return set.size();
	    }
	}
}


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

int main(){
    int n;
    cin >> n;
    vector<long long int> a(n);
    vector<long long int> num(n+1);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i <= n; i++) num[i] = 0;
    for(int i = 0; i < n; i++) num[a[i]]++;
    
    long long int res = 0;
    for(int i = 1; i <= n; i++){
        if(num[i] >= 2) res += num[i] * (num[i]-1)/2;
    }
    
    for(int i = 0; i < n; i++){
        long long int cores = res;
        if(num[a[i]] >= 2) cores -= num[a[i]] * (num[a[i]]-1)/2;
        if(num[a[i]]-1 >= 2) cores += (num[a[i]]-1) * (num[a[i]]-2)/2;
        cout << cores << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 5760
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    const int N = 1_000_000;
    auto tab = new bool[N];
    tab[] = true;
    for (int i = 2 + 2; i < N; i += 2)
        tab[i] = false;
    for (int i = 3; i < N; i += 2) {
        if (tab[i]) {
            for (int j = i + i; j < N; j += i) {
                tab[j] = false;
            }
        }
    }

    auto sum = new int[N];
    for (int i = 2; i < N; i++) {
        sum[i] = sum[i - 1] + (tab[i] ? 1 : 0);
    }

    string s;
    while ((s = readln.chomp).length > 0) {
        int n = s.to!int;
        writeln(sum[n]);
    }
}

Measured memory_bytes: 7088
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{   char x[200001];
    scanf("%s",x);
    int l=strlen(x),s=0,t=0,flag=0;
    for(int i=0;i<l;i++){
        if(x[i]=='S'){
            break;
        }else{
            t++;
        }
    }
    for(int i=l-1;i>=0;i--){
        if(x[i]=='T'){
            break;
        }else{
            s++;
        }
    }
    int ct=0,cs=0;
    for(int i=t;i<l-s;i++){
        if(x[i]=='S'){cs++;
            }else{
            if(cs>0){
                cs--;
            }else{
                ct++;
            }
        }
    }
    
    printf("%d",s+t+ct+cs);

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main(){
    long long N,M;
    cin >> N >> M;
    if (M<2)
        cout << 0<< endl;
    else if (N*2 >= M)
        cout << M/2<< endl;
    else
        cout << N+(M-2*N)/4<< endl;

        
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,m;
  cin>>n>>m;
  int a[m],b[m];
  ll c[m];
  rep(i,0,m){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;
    b[i]--;
  }
  ll d[n];
  rep(i,0,n){
    d[i]=-1e12;
  }
  d[0]=0;
  rep(j,0,n){
    rep(i,0,m){
      if(d[a[i]]!=1e12 && d[b[i]]<d[a[i]]+c[i]){
        d[b[i]]=d[a[i]]+c[i];
      }
    }
  }
  bool p=true;
  rep(i,0,m){
    if(d[a[i]]!=1e12 && d[b[i]]<d[a[i]]+c[i]){
      d[b[i]]=d[a[i]]+c[i];
      if(b[i]==n-1) p=false;
    }
  }
  if(p) cout<<d[n-1]<<endl;
  else cout<<"inf"<<endl;
}

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

int main() {
  string S;
  cin >> S;
  
  int len = S.length();
  int nbits = len -1;
  int64_t ans = 0;
  
  for (int tmp = 0; tmp < (1 << nbits); tmp++) {
  bitset<11>  s(tmp);
  // (ビット列sに対する処理)
    string tasareru, tasu;
    int previous_cut = -1;
    for(int i =0; i < nbits; i++){
      if ( s.test(i)){
        tasareru = S.substr(1 + previous_cut, i - previous_cut);
   //     cout << tasareru << ", ";
        previous_cut = i;
        ans += stoll(tasareru);
      }
    }
      //  cout << S.substr(1+previous_cut) << endl;
        ans += stoll(S.substr(1+previous_cut));
  }
  cout << ans << endl;
}


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

int n;
string a;
map<string,int> memo;

int rec(string v){
  if(memo.find(v)!=memo.end())return memo[v];
  
  int res = 0;
  for(int i=8;i>=1;i--){
    if(v[i]){
      if(v[0]+i==10){
	v[i]--; v[0] = 0;
	res = max(res,rec(v)+1);
	v[i]++; v[0] = 10-i;
      }else if(v[0]+i<10){
	v[i]--; v[0] += i;
	res = max(res,rec(v));
	v[i]++; v[0] -= i;
      }
    }
  }

  return memo[v] = res;
}

int main(){
  while(cin >> n,n){
    a.resize(10);
    for(int i=0;i<10;i++)a[i] = 0;
    int tmp;
    for(int i=0;i<n;i++){
      cin >> tmp; a[tmp]++;
    }

    int res = 0;
    for(int i=1;i<=4;i++){
      tmp = min(a[i],a[10-i]);
      a[i]-=tmp; a[10-i]-=tmp;
      res += tmp;
    }
    res += a[5]/2; a[5] &= 1;

    memo.clear();
    cout << res+rec(a) << endl;
  }
}

Measured memory_bytes: 58152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    v a(n+1);
    
    for(int i=0; i<n; i++){
        cin >> a[i+1];
    }
    
    v b(n+1,0);
    v c;
    
    for(int i=n; i>0; i--){
        if(a[i]==b[i]%2)continue;
        
        b[i]++;
        c.push_back(i);
        
        if(i!=1)b[1]++;
        
        for(int j=2; j*j<=i; j++){
            if(i%j)continue;
            
            if(i/j!=j)b[i/j]++;
            b[j]++;
        }
    }
    
    cout << c.size() << endl;
    
    for(int i=0; i<c.size(); i++){
        cout << c[i];
        if(i==c.size()-1)
            cout << endl;
        else
            cout << " ";
    }
    
    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void)
{

	int H,W,h,w;
	
	
	cin>>H;
    cin>>W;
    cin>>h;
    cin>>w;
	cout<<H*W-H*w-W*h+h*w <<endl;
	return 0;

}
		



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

int main() {
	int there_is[26];
	for(int i = 0; i < 26; i++) {
		there_is[i] = 0;
	}
	string S; cin >> S;
	for(int i = 0; i < S.length(); i++) {
		there_is[int(S[i]-'a')]++;
	}
	int is_ok = 1;
	for(int i = 0; i < 26; i++) {
		if(there_is[i] > 1) is_ok = 0;
	}
	if(is_ok == 1) cout << "yes" << endl;
	else cout << "no" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
#define int long long
map<int,int> x;
int A[100005];
int mod = (int) 1e9 + 7;
int dp[100005],n;
int32_t main(){
	cin>>n;
	rep(i,1,n+1) cin>>A[i];
	dp[0] = 1;
	x[-1] = 3;
	for(int i = 1 ; i <=n ;i++){
		dp[i] = ((dp[i-1]) * (x[A[i] - 1]))%mod;
		x[A[i] - 1]--;
		x[A[i]]++;
	}
	cout<< dp[n] << endl;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    int x;
    cin >> x;

        int ans = 0;
        map<int,int>xx;
        map<int,int>yy;
        yy[0]++;
        ans++;
        int deg = x;
        bool chk = false;
        while(!chk){
            if(deg==0){
                break;
            }else{
                ans++;
                deg = (deg+x)%360;
            }
        }
        cout<<ans<<endl;





    
    
    
    
    
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

ll cnt[10005];
const int MAXN = 10005;
bool is[MAXN];
int prime[MAXN];
int Cnt = 0;
void getprime()
{
    memset(is, 1, sizeof(is));
    is[0] = is[1] = 0;
    for(int i = 2; i < MAXN; i++)
    {
        if(is[i])
        {
            prime[Cnt++] = i;
        }
        for(int j = 0; j < Cnt; j++)
        {
            if(i * prime[j] >= MAXN) break;
            is[i * prime[j]] = 0;
            if(i % prime[j]) break;
        }
    }
}
const int mod = 1e9+7;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    getprime();
    /*for(int i = 0; i < 10; i++)
    {
        cout << prime[i] << endl;
    }*/
    for(int i = 2; i <= n; i++)
    {
        int num = i;
        int cur = 0;
        while(num > 1)
        {
            while(num % prime[cur] == 0)
            {
                cnt[prime[cur]]++;
                num /= prime[cur];
            }
            cur++;
        }
    }
    ll ans = 1;
    for(int i = 0; i < MAXN; i++)
    {
        if(cnt[i])
        {
            ans = ans * (cnt[i] + 1);
            ans %= mod;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	int ans = 0;
	for (int i = A; i <= B; i++)
	{
		string s = to_string(i);
		bool k = true;
		for (int j = 0; j < s.size() / 2; j++)
		{
			if (s[j] != s[s.size() - j - 1])
			{
				k = false;
				break;
			}
		}

		if (k)
			ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[s.size()-1]!='s') s+="s";
    else s+="es";
    cout<<s;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}



void solve()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans=max({a*c,a*d,b*c,b*d});
  if(ans<0)
  {
    if((a>=0 and b<=0)or (c>=0 and d<=0))
    {
      cout<<0;
    }
    else
      cout<<ans;
  }
  else
    cout<<ans;
}

int main()
{
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
}

Measured memory_bytes: 3640
//package beg_171;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		String[] a = s.nextLine().split(" ");
		int many = Integer.parseInt(a[1]);
		
		String[] l = s.nextLine().split(" ");
		int[] list = new int[l.length];
		for (int i=0;i<l.length;i++) {
			list[i]=Integer.parseInt(l[i]);		}
		
		Arrays.sort(list);
		int count=0;
		for (int i=0;i<many;i++) {
			count=count+list[i];
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 37016
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    a = a / 100000 + a / 10000 % 10 + a / 1000 % 10 + a / 100 % 10  + a / 10 % 10 + a % 10;// 各桁の和
    cout << (a == 1 ? 10 : a);/* aが1であれば10を,1でなければaを出力
                                                        if()を書くまでもない時に使います */
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n, k; cin >> n >> k;
    VL a(n);
    REP(i, n)
    {
        cin >> a[i];
        result += a[i];
    }
    if(k > n) k = n;
    sort(ALL(a));
    FORD(i, n-1, n-k)
    {
        result -= a[i];
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){FIN;
  int n; cin >> n;
  vector<int> ans,a[n+1];
  a[0].resize(n);
  fore(i,0,n) cin >> a[0][i];
  fore(it,0,n){
    int now=-1;
    fore(i,0,SZ(a[it])) if(a[it][i]-1==i) now=i;
    if(now<0){
      cout << -1 << endl;
      return 0;
    }
    ans.pb(a[it][now]);
    fore(i,0,SZ(a[it])) if(now!=i) a[it+1].pb(a[it][i]);
  }
  reverse(ALL(ans));
  for(auto x : ans) cout << x << "\n";
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

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

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var n, k int
	fmt.Scan(&n, &k)
	var s string
	fmt.Scan(&s)
	rs := append([]rune(s), 'L')

	count := n
	mode := 'R'
	for i, r := range rs {
		switch {
		case mode == 'R' && r == 'L':
			count--
			if i > 0 && i < n {
				count--
			}
			mode = 'L'
		case mode == 'L' && r == 'R':
			mode = 'R'
		}
	}

	fmt.Println(minInt(n-1, count+(2*k)))
}


Measured memory_bytes: 1664
N=int(input())
*D,=map(int,input().split())
M=max(D)
from collections import*
C=Counter(D)

ans=1
now=C[1]
for i in range(2,M+1):
    ans*=pow(now,C[i],998244353)
    ans%=998244353
    now=C[i]

if D[0]!=0:
    ans=0
if 0 in D[1:]:
    ans=0
print(ans)

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

int main() {
	string s;
	cin >> s;
	rep(i,s.size()){
		if(i%2==0) cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 2222 * 2;
char a[N], b[N];
int n, ok1 = 0, ok2 = 0, ans = 1e18;
int st[N], top = 0, L[N], R[N], pos[N];


inline int getmod(int x) {
  return ((x % n) + n) % n;
}

inline void init(void) {
  memset(L, 0, sizeof L);
  memset(R, 0, sizeof R);
  for (int i = 0; i < n; i ++)
    b[i + n] = b[i];
  
  for (int i = 0; i < n; i ++) {
    while (b[getmod(i + L[i])] == 0)
      -- L[i];
    while (b[getmod(i + R[i])] == 0)
      ++ R[i];
  }
  
  for (int i = 0; i < n; i ++)
    pos[i] = i;
  auto cmpLR = [] (int a, int b) {
                 return R[a] < R[b] || R[a] == R[b] && L[a] > L[b];
               };
  sort(pos, pos + n, cmpLR);
}

inline void doit(void) {
  init();
  for (int ed = 0; ed <= (n - 1); ed ++) {
    for (int _ = 0; _ < n; _ ++) {
      int i = pos[_];
      if (a[getmod(i + ed)] != b[i])
        st[++ top] = i;
    }
    int l = 0;
    int all = top;
    
    while (top) {
      int i = st[top --];
      ans = min(ans, 2 * (max(ed, R[i]) - l) - ed + all);
      l = min(l, L[i]);
    }
    ans = min(ans, 2 * (max(ed, 0ll) - l) - ed + all);
  }

}

main(void) {
  scanf("%s", a); scanf("%s", b);
  n = strlen(a);
  for (int i = 0; i < n; i ++) {
    a[i] -= '0'; ok1 |= a[i];                   
  }
  for (int i = 0; i < n; i ++) {
    b[i] -= '0'; ok2 |= b[i];
  }
  if (!ok2 && ok1) return puts("-1"), 0;
  else if (!ok2 && !ok1) return puts("0"), 0;
  doit();
  reverse(a, a + n);
  reverse(b, b + n);
  doit();
  cout << ans << "\n";
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    string s;
    cin>>s;
    if(s[2]==s[3] and s[4]==s[5])
    {
        cout<< "Yes";
    }
    else cout<< "No";

    return 0;
}


Measured memory_bytes: 3608
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
T.append(-1)

def bsearch(arr, key):
    left = 0
    right = len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] == key:
            return True
        elif key < arr[mid]:
            right = mid
        else:
            left = mid + 1
    return False

i = 0
count = 0
while T[i] != -1:
    if bsearch(S, T[i]):
        count += 1
    i += 1

print(count)



Measured memory_bytes: 16712
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    multiset<int> S1, S2, tmp;
    for(int i=0; i<(1<<N); i++) {
        int S;
        cin >> S;
        S1.insert(S);
    }

    cerr << *S1.rbegin() << endl;
    S2.insert(*S1.rbegin());
    S1.erase(--S1.end());

    for(int d=0; d<N; d++) {
        tmp = S2;
        for(auto itr=tmp.rbegin(); itr!=tmp.rend(); itr++) {
            auto l = S1.lower_bound(*itr);
            if(l == S1.begin()) {
                cout << "No" << endl;
                return 0;
            } else {
                --l;
                S2.insert(*l);
                S1.erase(l);
            }
        }
    }
    // vector<int> S(1<<N), d(1<<N);
    // for(int i=0; i<(1<<N); i++) {
    //     cin >> S[i];
    // }

    // sort(S.begin(), S.end());

    // d.back() = N;
    // for(int i=S.size()-2; i>=0; i--) {
    //     int u = distance(S.begin(), upper_bound(S.begin(), S.end(), S[i]));
    //     bool flag = false;
    //     for(int j=u; j<S.size(); j++) {
    //         if(d[j]) {
    //             --d[j];
    //             d[i] = d[j];
    //             flag = true;
    //             break;
    //         }
    //     }
    //     if(!flag) {
    //         cout << "No" << endl;
    //         return 0;
    //     }
    // }

    // queue< pair<int,int> > q;
    // q.emplace(S.back(), 0);
    // S.pop_back();

    // while(!q.empty()) {
    //     int val = q.front().first;
    //     int day = q.front().second;
    //     q.pop();
    //     for(int d=day+1; d<=N; d++) {
    //         if(S.back() == val) {
    //             cout << "No" << endl;
    //             return 0;
    //         } else {
    //             q.emplace(S.back(), d);
    //             S.pop_back();
    //         }
    //     }
    // }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 18688
#include<iostream>
using namespace std;
int main(){
  int N, H, tmp, c=0, m=0;
  cin >> N;
  cin >> tmp;
  for(int i=1; i<N; i++){
    cin >> H;
    if(c>m){
      m=c;
    }
    if(H<=tmp){
      c++;
    }else{
      c=0;
    }
    tmp = H;
  }
  if(c>m){
    m=c;
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		String[] a = new String[n];
		String[] b = new String[m];
		for(int i = 0; i < n; i++) a[i] = sc.next();
		for(int i = 0; i < m; i++) b[i] = sc.next();
		sc.close();

		//処理
		String ans = "No";
		for(int i = 0; i <= n-m; i++){
			for(int j = 0; j <= n-m; j++){
				boolean f = true;
				for(int x = 0; x < m; x++){
					for(int y = 0; y < m; y++){
						if(a[i+x].charAt(j+y) != b[x].charAt(y)) f = false;
					}
				}
				if(f) ans = "Yes";
			}
		}

		//出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename T> inline T range(T l, T r) {
    return uniform_int_distribution<T>(l, r)(rng);
}

inline void setin(string s) {
    freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
    freopen(s.c_str(), "w", stdout);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}

template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int N = 1e3 + 15;
int n, k;
string s;
int dp[2][N][N]; // dp[i][operation_applied][free_ones]
int a[N];

inline int add(int a, int b) {
    a += b;
    if(a >= mod)
        a -= mod;
    return a;
}

inline void add_t(int &a, int b) {
    a = add(a, b);
}

inline int mt(int a, int b) {
    return 1ll * a * b % mod;
}

inline void construct() {
    int sz = 1;
    for(int i = 1; i <= n && s[i] == '1'; ++i)
        a[1] = i;
    for(int i = a[1] + 1; i <= n; ++i) {
        if(s[i] == '0') {
            if(i + 1 <= n && s[i + 1] == '0')
                a[++sz] = 0;
        }
        else {
            int j = i;
            while(j + 1 <= n && s[j + 1] == '1')
                ++j;
            a[++sz] = j - i + 1;
            i = j;
        }
    }
    n = sz;
}

inline void solve() {
    // dp[i][operation_applied][free_ones]
    dp[(n + 1) & 1][0][0] = 1;
    int sum = 0;
    for(int i = n; i >= 1; --i) {
        int bit = i & 1;
        memset(dp[bit], 0, sizeof(dp[bit]));
        for(int k = 0; k < N; ++k) {
            for(int t = 0; t <= sum; ++t) {
                for(int j = 0; j <= a[i] && k + j < N; ++j)
                    add_t(dp[bit][k + j][j + t], dp[bit ^ 1][k][t]);

                for(int j = 0; j < t; ++j)
                    add_t(dp[bit][k][j], dp[bit ^ 1][k][t]);
            }
        }
        sum += a[i];
    }
}

inline void output() {
    int ans = 0;
    for(int i = 0; i < min(N, k + 1); ++i)
        add_t(ans, dp[1][i][0]);
    cout << ans << endl;
}

main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // setin("input.txt");
    cin >> s >> k;
    n = s.size();
    s = '#' + s;
    construct();
    solve();
    output();
    return 0;
}

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

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

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

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

    ll n, _n;
    cin >> n;
    _n = n;

    if (n % 2 > 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    _n /= 10;
    while (_n > 0) {
        ans += _n;
        _n /= 5;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  bool f = true;
  while (1) {
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 0) {
        a[i] /= 2;
      } else {
        f = false;
        break;
      }
    }
    if (!f) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] alp1 = new int[26];
    int[] alp2 = new int[26];
    for(int i = 0; i < 26; i++){
      alp1[i] = 50;
    }
     
    for(int i = 0; i < N; i++){
      String S = sc.nextLine();
      for(int j = 0; j < S.length(); j++){
        alp2[(int)S.charAt(j)-97]++;
      }
      for(int j = 0; j < 26; j++){
        if(alp1[j] > alp2[j]){
          alp1[j] = alp2[j];
        }
        alp2[j] = 0;
      }
    }
    for(int i = 0; i < 26; i++){
      for(int j = 0; j < alp1[i]; j++){
        System.out.print((char)(i+97));
      }
    }
    System.out.println("");
  }
}

Measured memory_bytes: 23764