akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int par, impar, i, n, p, x;

int main()
{
 cin.sync_with_stdio(false);

    cin >> n >> p;
    for(i=1; i<=n; ++i)
    {
        cin >> x;
        if(x&1) ++impar;
            else ++par;
    }

    if(impar == 0 && p == 1) cout << 0 << '\n';
        else if(impar == 0 && p == 0) cout << (1LL<<par) << '\n';
            else cout << (1LL<<(par+impar-1)) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
    string s,t;
    while(cin >> s >> t, s != "0"){
        int x = 0, y = 0;
        int a[10] = {}, b[10] = {};
        rep(i,4){
            if(s[i] == t[i])x++;
            else{
                a[s[i]-'0']++;
                b[t[i]-'0']++;
            }
        }
        rep(i,10)y += min(a[i],b[i]);
        cout << x << " " << y << endl;
    }
}



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

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 300;
const int P = 1e9+7;
llong f[N+N+3][N+3][N+3];
int a[N+N+3];
bool used[N+N+3];
vector<int> vec;
int n;

llong updsum(llong &x,llong y) {x = x+y>=P?x+y-P:x+y;}

int main()
{
	scanf("%d",&n); int cnt1 = 0,cnt2 = 0;
	for(int i=1; i<=n; i++)
	{
		scanf("%d%d",&a[i+i-1],&a[i+i]);
		if(a[i+i-1]!=-1&&a[i+i]!=-1)
		{
			vec.push_back(a[i+i-1]),vec.push_back(a[i+i]);
			i--,n--;
		}
		else if(a[i+i-1]==-1&&a[i+i]==-1) {cnt1++;}
		else {cnt2++;}
	}
	sort(vec.begin(),vec.end());
	for(int i=1; i<=n+n; i++) {a[i] -= (lower_bound(vec.begin(),vec.end(),a[i])-vec.begin());}
//	printf("a: "); for(int i=1; i<=n+n; i++) printf("%d ",a[i]); puts("");
	for(int i=1; i<=n+n; i++) if(a[i]!=-1) {used[a[i]] = true;}
	f[n+n+1][0][0] = 1ll;
	for(int i=n+n+1; i>=2; i--)
	{
		for(int j=0; j<=cnt1+cnt2; j++)
		{
			for(int k=0; k<=cnt2; k++)
			{
				llong x = f[i][j][k]; if(!x) continue;
				if(!used[i-1])
				{
					updsum(f[i-1][j+1][k],x);
					if(j>0) {updsum(f[i-1][j-1][k],x);}
					updsum(f[i-1][j][k-1],x*k%P);
				}
				else
				{
					updsum(f[i-1][j][k+1],x);
					if(j>0) {updsum(f[i-1][j-1][k],x);}
				}
			}
		}
	}
	llong ans = f[1][0][0]; int tmp = 0;
	for(int i=1; i<=n; i++) tmp += (a[i+i-1]==-1)&&(a[i+i]==-1);
	while(tmp) {ans = ans*tmp%P; tmp--;}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 431616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPowersOfTwo solver = new BPowersOfTwo();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPowersOfTwo {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            TreeMap<Integer, Integer> counts = new TreeMap<>();

            for (int i = 0; i < N; i++) {
                counts.compute(in.nextInt(), (k, v) -> v == null ? 1 : v + 1);
            }

            int ans = 0;
            while (!counts.isEmpty()) {
                int cur = counts.lastKey();
                decrease(counts, cur);

                int p2 = 1;
                while (p2 <= cur) p2 *= 2;
                int need = p2 - cur;
                Integer got = counts.get(need);
                if (got != null) {
                    ans++;
                    decrease(counts, need);
                }
            }
            out.println(ans);
        }

        private void decrease(TreeMap<Integer, Integer> counts, int cur) {
            if (counts.get(cur) == 1) {
                counts.remove(cur);
            } else {
                counts.put(cur, counts.get(cur) - 1);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 61892
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
int dp[101][10005];

int main() {
    int n;
    cin >> n;
    vector<int> s;
    rep(i,0,n){
        int tmp;
        cin >> tmp;
        s.push_back(tmp);
    }

    dp[0][0] = 1;

    rep(i,0,n){
        rep(j,0,10005){
            dp[i+1][j] |= dp[i][j];
            dp[i+1][j+s[i]] |= dp[i][j];
        }
    }
    int ans = 0;
    rep(i,0,10005){
        if(dp[n][i] && i % 10){
            ans = max(ans,i);
        }
    }
//    rep(i,0,n+1){
//        rep(j,0,30){
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
from operator import itemgetter
n,m = map(int,input().split())
lis = []
ans = [0 for i in range(m)]
num = [0 for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  lis.append([i,a,b])
lis.sort(key=itemgetter(2))
for i in range(m):
  num[lis[i][1]-1] += 1
  cou = max(0,5-(lis[i][1] // 10))
  co = max(0,5-(num[lis[i][1]-1] // 10))
  ans[lis[i][0]] = format(lis[i][1],'06d') + format(num[lis[i][1]-1],'06d')
for i in range(m):print(ans[i])

Measured memory_bytes: 32220
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

template<typename T> class fenwick_tree {
private: vector<T> FT;
public:
	fenwick_tree(int N) { FT.assign(N + 1, 0); }
	void update(int x, T val) { if (x > 0) for (; x < FT.size(); x += x & -x) FT[x] += val; }
	T query(int x) { T ret = 0; if (x > 0) for (; x > 0; x -= x & -x) ret += FT[x]; return ret; }
	T query(int x, int y) { return query(y) - query(x - 1); }
};

int a[100001];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	ll N;
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> a[i];
	
	int l = 0, r = 1e9, ans;
	while (l <= r) {
		int m = (l + r) >> 1, tmp = N + 1;
		fenwick_tree<ll> FT(2 * (N + 1));
		FT.update(tmp, 1);
		ll cnt = 0;
		for (int i = 0; i < N; ++i) {
			tmp += (a[i] >= m ? 1 : -1);
			cnt += FT.query(0, tmp);
			FT.update(tmp, 1);
		}
		cnt >= (N * (N + 1) + 3) / 4 ? l = m + 1, ans = m : r = m - 1;
	}
	cout << ans << '\n';
}

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

typedef long long LL;

const int N=20,mod=998244353;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}
int Power(int a,int k,int p=mod){int res=1;for (;k;k>>=1,smul(a,a,p)) if (k&1) smul(res,a,p);return res;}
int Get_inv(int a,int p=mod){return Power(a,p-2,p);}

int n,m,r[N+9],c[N+9];
char s[N+9];

void into(){
  scanf("%d%d",&n,&m);
  for (int i=1;i<=n;++i){
	scanf("%s",s+1);
	for (int j=1;j<=m;++j) r[i]|=(s[j]=='#')<<j-1,c[j]|=(s[j]=='#')<<i-1;
  }
}

int inv[N+9],fac[N+9],ifac[N+9];

void Get_inv(){
  inv[1]=1;
  fac[0]=fac[1]=1;
  ifac[0]=ifac[1]=1;
  for (int i=2;i<=n+m;++i){
	inv[i]=mul(mod-mod/i,inv[mod%i]);
	fac[i]=mul(fac[i-1],i);
	ifac[i]=mul(ifac[i-1],inv[i]);
  }
}

int Get_c(int n,int m){return n<m||m<0?0:mul(fac[n],mul(ifac[m],ifac[n-m]));}

int dp0[N+9][N+9][3],dp1[N+9][N+9][3],ans;

void Get_dp(){
  for (int j=1;j<=m;++j) dp0[n][j][2]=mul(Get_c(m,j),1<<m-j);
  ans=1<<m;
  for (int i=n;i>=1;--i)
	for (int j=m;j>=1;--j){
	  dp0[i][j][0]=add(dp0[i][j][1],dp0[i][j][2]);
	  for (int k=1;k<i;++k){
		sadd(dp1[k][j][1],mul(Get_c(i,k),add(mul(dp0[i][j][2],2),dp0[i][j][1])));
		sadd(dp1[k][j][2],mul(Get_c(i,k),mul((1<<i-k)-2,dp0[i][j][2])));
	  }
	  sadd(ans,mul(dp0[i][j][2],(1<<i)-2));
	  dp1[i][j][0]=add(dp1[i][j][1],dp1[i][j][2]);
	  for (int k=1;k<j;++k){
		sadd(dp0[i][k][1],mul(Get_c(j,k),add(mul(dp1[i][j][2],2),dp1[i][j][1])));
		sadd(dp0[i][k][2],mul(Get_c(j,k),mul((1<<j-k)-2,dp1[i][j][2])));
	  }
	  sadd(ans,mul(dp1[i][j][2],(1<<j)-2));
	}
  for (int u=1;u<1<<n;++u)
	for (int v=1;v<1<<m;++v){
      int flag=1;
	  for (int i=0;i<n;++i)
		if (u>>i&1){
		  int t=r[i+1]&v;
		  if (!t||t==v) flag=0;
		}
	  for (int i=0;i<m;++i)
		if (v>>i&1){
		  int t=c[i+1]&u;
		  if (!t||t==u) flag=0;
		}
	  if (!flag) continue;
	  int x=0,y=0;
	  for (int i=0;i<n;++i) x+=u>>i&1;
	  for (int i=0;i<m;++i) y+=v>>i&1;
	  sadd(ans,mul(add(dp0[x][y][0],dp1[x][y][0]),Get_inv(mul(Get_c(n,x),Get_c(m,y)))));
	}
}

void work(){
  Get_inv();
  Get_dp();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3804
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int[][][] room = new int[4][3][10];
    int n = Integer.parseInt(br.readLine());
    for(int b=0;b<4;b++) {
      for(int f=0;f<3;f++) {
        for(int r=0;r<10;r++) {
          room[b][f][r] = 0;
        }
      }
    }
    for(int i=0;i<n;i++) {
      String[] input = br.readLine().split(" ");
      int b = Integer.parseInt(input[0]);
      int f = Integer.parseInt(input[1]);
      int r = Integer.parseInt(input[2]);
      int v = Integer.parseInt(input[3]);
      room[b-1][f-1][r-1] += v;
    }
    for(int b=0;b<4;b++) {
      for(int f=0;f<3;f++) {
        for(int r=0;r<10;r++) {
          System.out.print(" " + room[b][f][r]);
        }
        System.out.println();
      }
      if(b!=3) {
        System.out.println("####################");
      }
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    VP vp;
    REP(i,1,n+1){
        REP(j,1,n+1){
            if(i==j)continue;
            if(n%2==0){
                if(j==n+1-i)continue;
            }else{
                if(j==n-i)continue;
            }
            if(i>j)continue;
            vp.emplace_back(i,j);
        }
    }
    cout<<vp.size()<<endl;
    rep(i,vp.size()){
        out2(vp[i].fi,vp[i].se);
    }
    return  0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef map<ll,ll> mll;
typedef set<ll> sll;

#define se second
#define fi first
#define pb push_back

ll d[300000],a[300000];
sll st;

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

  ll n,m;
  cin>>n;
  d[0]=1000000000000;
  for(ll i=1;i<=n;i++)
  {
    cin>>a[i];
    d[i]=min(d[i-1],a[i]);
    st.insert(d[i]);
  }
  cout<<st.size();
}


Measured memory_bytes: 13312
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>

using namespace std;

long long count(int n, long long x){
    long long p = pow(2,n)-1;
    long long all = pow(2,n+1)-3;
    long long ans = 0;
    if(n == 0 && x==1){
        return 1;
    }
    else if(x==0 || x==1){
        return 0;
    }
    else if(all+1 >= x){
        ans+=count(n-1,x-1);
    }
    else if(all+2 == x){
        ans += p+1;
    }
    else if(2*all+1 >= x){
        ans +=p+1;
        ans+=count(n-1,x-all-2);
    }
    else if(2*all+2 <= x){
        ans += 2*p+1;
    }
    return ans;
}

int main(){
  int n;
  long long x;
  string bager("P");
  cin >> n >> x;
  
//   for(int i = 0; i < n; i++){
//       bager += bager;
//       bager.insert(bager.length()/2,"P");
//       bager.insert(0, "B");
//       bager.push_back('B');
//      // cout << bager << endl;
//   }
  
//   for(int i =0; i < x; i++){
//       if(bager[i] == 'P')
//         cnt++;
//   }
  if(n ==0)
    cout << 1<<endl;
  else
    cout << count(n,x)<< endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n-1);
  rep(i,n-1) cin >> a.at(i);
  
  map<int,int> buka;
  rep(i,n) buka[i] = 0;
  
  rep(i,n-1) buka[a.at(i)-1]++;
  
  rep(i,n)
    cout << buka[i] << endl;
}

Measured memory_bytes: 13468
#include <cstdio>

int main (){
    char s[4];
    scanf("%s",s);
    if((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])||
        (s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])||
        (s[1]==s[2]&&s[0]==s[3]&&s[0]!=s[1])) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,a[101010],x;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		x^=a[i];
	}
	if(x==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
n=int(input())
a=[]
a.append(n)
i=0
flg=0
while True:
  i+=1
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  a.append(n)
  for j in range(len(a)):
    if i!=j and a[j]==n:
      print(i+1)
      flg=1
      break
  if flg==1:
    break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string S;cin >> S;
  int N = S.length();
  bool Impossible = false;
  if(S[N-1] == '1') Impossible = true;
  if(S[0] == '0')Impossible = true;
  rep(i,N/2) if(S[i] != S[N-2-i])Impossible = true;
  if(Impossible){
    cout << -1 << endl;
    return 0;
  }
  int l = 1,r = 1;
  int next1 = 2, next2 = 3;
  if(N%2==0){
    if(S[N/2-1] == '1'){
      cout << l SP next1 << endl;
      r = next1;
      next1+=2;
    }else{
      cout << l SP next1 << endl;
      next1+=2;
    }
    --N;
  }

  per(i,N/2){
    if(S[i] == '1'){
      cout << l SP next1 << endl;
      cout << r SP next2 << endl;
      l = next1;
      r = next2;
      next1+=2;
      next2+=2;
    }else{
      cout << l SP next1 << endl;
      cout << r SP next2 << endl;
      next1+=2;
      next2+=2;
    }
  }
  return 0;
}


Measured memory_bytes: 1616
N,Q = map(int,input().split())
point = [[] for x in range(N)]
plus = [0]*N
for _ in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    point[a].append(b)

for _ in range(Q):
    p,x = map(int,input().split())
    p -= 1
    plus[p] += x

ans = [0]*N
dfs = [(0,0)]
while len(dfs):
    n,p = dfs.pop()
    p += plus[n]
    ans[n] = p
    for be in point[n]:
        dfs.append((be,p))

for a in ans:
    print(a,end=' ')
print()

Measured memory_bytes: 50716
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <list>
#include <set>
using namespace std;
typedef long long LL;
const int maxn=50005;
set<pair<int,int> >se;
set<pair<int,int> >::iterator it,itt;
map<pair<int,int>,string>a;
map<string,pair<int,int> >b;
//priority_queue<int>pri;
int g[100005];
char s[25],c[5];
string ss;
pair<int,int>t,z;
int main()
{
    int n,k;
    scanf("%d",&n);
    for(int i=0; i<n; ++i)
    {
        scanf("%s%d",s,&k);
        ss=string(s);
        t=make_pair(k,++g[k]);
        se.insert(t);
        a[t]=ss;
        b[ss]=t;
    }
    int su=se.size();
    it=--se.end();
    int f=su/5;
    for(int i=0; i<f; ++i)
        --it;
    int m;
    scanf("%d",&m);
    while(m--)
    {
        scanf("%s%s",c,s);
        ss=string(s);
        if(c[0]=='+')
        {
            scanf("%d",&k);
            ++su;
            itt=it;
            t=make_pair(k,++g[k]);
            se.insert(t);
            a[t]=ss;
            b[ss]=t;
            if(t>*it) ++f;
            if(f>su/5)
            {
                --f;
                ++it;
            }
            else if(f<su/5)
            {
                ++f;
                --it;
            }
            if(t>*it) printf("%s is working hard now.\n",s);
            else printf("%s is not working now.\n",s);
            if(*itt>*it)
                printf("%s is working hard now.\n",&a[*itt][0]);
            ++itt;
            if(itt!=se.end()&&*itt!=t&&*itt<=*it)
                printf("%s is not working now.\n",&a[*itt][0]);
        }
        else
        {
            t=b[ss];
            --su;
            z=*it;
            if(t>*it) --f;
            if(f<su/5)
            {
                ++f;
                --it;
            }
            if(f>su/5)
            {
                --f;
                ++it;
            }
            if(*it==t)
                --it;
            se.erase(t);
            b.erase(a[t]);
            a.erase(t);
            itt=it;
            if(*itt>z)
                printf("%s is not working now.\n",&a[*itt][0]);
            ++itt;
            if(itt!=se.end()&&*itt<=z)
                printf("%s is working hard now.\n",&a[*itt][0]);
        }
    }
    return 0;
}

Measured memory_bytes: 14624
from math import sin, cos, atan2

def sgn(x, eps=1e-10):
    if x < -eps: return -1
    if -eps <= x <= eps: return 0
    if eps < x: return 1

class Vector():
    def __init__(self, x=0.0, y=0.0):
        self.x = x
        self.y = y

    def arg(self):
        return atan2(self.y, self.x)

    def norm(self):
        return (self.x**2 + self.y**2)**0.5

    def rotate(self, t):
        nx = self.x * cos(t) - self.y * sin(t)
        ny = self.x * sin(t) + self.y * cos(t)
        return Vector(nx, ny)

    def counter(self):
        nx = -self.x
        ny = -self.y
        return Vector(nx, ny)

    def times(self, k):
        nx = self.x * k
        ny = self.y * k
        return Vector(nx, ny)

    def unit(self):
        norm = self.norm()
        nx = self.x / norm
        ny = self.y / norm
        return Vector(nx, ny)

    def normal(self):
        norm = self.norm()
        nx = -self.y / norm
        ny = self.x / norm
        return Vector(nx, ny)

    def add(self, other): #Vector, Vector -> Vector
        nx = self.x + other.x
        ny = self.y + other.y
        return Vector(nx, ny)

    def sub(self, other):
        nx = self.x - other.x
        ny = self.y - other.y
        return Vector(nx, ny)

    def dot(self, other): #Vector, Vector -> int
        return self.x * other.x + self.y * other.y

    def cross(self, other): #Vector, Vector -> int
        return self.x * other.y - self.y * other.x

    def __str__(self):
        return '{:.9f}'.format(self.x) + ' ' + '{:.9f}'.format(self.y)

class Line():
    def __init__(self, bgn=Vector(), end=Vector()):
        self.bgn = bgn
        self.end = end

    def build(self, a, b, c): #ax + by == 1
        assert sgn(a) != 0 or sgn(b) != 0
        if sgn(b) == 0:
            self.bgn = Vector(-c / a, 0.0)
            self.end = Vector(-c / a, 1.0)
        else:
            self.v = Vector(0, -c / b)
            self.u = Vector(1.0, -(a + b) / b)

    def vec(self):
        return self.end.sub(self.bgn)

    def projection(self, point):
        v = self.vec()
        u = point.sub(self.bgn)
        k = v.dot(u) / v.norm()
        h = v.unit().times(k)
        return self.bgn.add(h)

    def refrection(self, point):
        proj = self.projection(point)
        return proj.sub(point).times(2).add(point)

xp1, yp1, xp2, yp2 = map(int, input().split())
q = int(input())

p1 = Vector(xp1, yp1)
p2 = Vector(xp2, yp2)
l = Line(p1, p2)

for _ in range(q):
    x, y = map(int, input().split())
    p = Vector(x, y)
    ref = l.refrection(p)
    print(ref)


Measured memory_bytes: 5748
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>

using namespace std;
using PIC = pair<int, char>;

const vector<int> num_match = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

vector<PIC> nums;
string s_cand;

bool bigger(const string &s, const string &t) {
	if (s.size() == t.size()) {
		return s > t;
	} else {
		return s.size() > t.size();
	}
}

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

	vector<int> a(m, 0);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	map<int, int> tmp;
	for (auto x: a) {
		tmp[num_match[x]] = x;
	}
	for (auto p: tmp) {
		nums.emplace_back(p.first, '0' + p.second);
	}
	sort(nums.begin(), nums.end(),
		[](PIC &a, PIC &b) {
			return a.second < b.second;
		});

	vector<string> dp(n + 1, "0");
	dp[0] = "";

	for (int i = 0; i < n; i++) {
		if (dp[i] == "0") {
			continue;
		}
		for (auto p: nums) {
			int ni = i + p.first;
			string s = dp[i] + p.second;

			if (ni <= n && bigger(s, dp[ni])) {
				dp[ni] = s;
			}
		}
	}

	cout << dp[n] << endl;
	return 0;
}


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

int main(){

    int N;
    cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(p[i] == (i + 1)){
            swap(p[i], p[i + 1]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	double T;
	cin >> N >> T;
	VI X(N), H(N);
	double ans = 0;
	REP(i, N) cin >> X[i] >> H[i];
	REP(i, N) {
		//cout << H[i] * T / X[i] << endl;
		ans = max(ans, H[i] * T / X[i]);
	}
	printf("%.4f", ans);

	return 0;
}




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

int main() {
    string s;
    cin >> s;
    int min_val = s.size();
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] != s[i + 1]) {
            min_val = min(min_val, max(i + 1, (int)s.size() - i - 1));
        }
    }
    cout << min_val << endl;
    return 0;
}


Measured memory_bytes: 512
def c_sugar_water(A, B, C, D, E, F):
    x = set()  # 水の量が取りうるパターン
    y = set()  # 砂糖の量が取りうるパターン
    for a in range(0, F + 1, 100 * A):
        for b in range(0, F - a + 1, 100 * B):
            x.add(a + b)
    for c in range(0, F + 1, C):
        for d in range(0, F - c + 1, D):
            y.add(c + d)

    concentration = -1.0  # 砂糖水の濃度
    tmp = [0, 0]
    for water in x:
        for sugar in y:
            # 砂糖水の質量がビーカーに入れられるもので、砂糖が溶け残らない
            if 0 < water + sugar <= F and E * (water // 100) >= sugar:
                if concentration < sugar / (water + sugar):
                    tmp = (water + sugar, sugar)
                    concentration = sugar / (water + sugar)
    ans = '{} {}'.format(*tmp)
    return ans

A, B, C, D, E, F = [int(i) for i in input().split()]
print(c_sugar_water(A, B, C, D, E, F))

Measured memory_bytes: 3188
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = True
show_flg = False


def divisor(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret

def eucledean(A, N):
    # A = sorted(A)
    ans = A[0]
    for i in range(1, N):
        ans = gcd(A[i], ans)
    print(ans)


def main():
    N, M = MI()
    data = sorted(divisor(M))
    ans = 1

    for i in data:
        c = M // i
        # print(i, c)
        if c >= N:
            ans = i

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5148
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, m; cin >> n >> m;
    ll lmax = 0, rmin = n;
    REP(i, m) {
        ll l, r; cin >> l >> r;
        chmax(lmax, l);
        chmin(rmin, r);
    }
    cout << max(0LL, rmin - lmax + 1) << endl;
    
}

Measured memory_bytes: 256
N = int(input())
AB = [[]]*(N-1)
for i in range(N-1):
    AB[i] = list(map(int,input().split()))
from collections import defaultdict as ddict
from collections import deque
tree = ddict(list)
B = [0]*(N-1)
for i,ab in enumerate(AB):
    tree[ab[0]].append(ab[1])
    B[i] = ab[1]
# 各エッジの色を格納する変数の初期化
# C[0]は使わない
C = [0]*N
# 幅優先探索用のcue
Q = deque([1])
while Q:
    q = Q.popleft()
    c = 0
    for w in tree[q]:
        # 色をインクリメントした際に親の色とかぶったら更に1を加算する
        # 他は単純なインクリメント
        c += 1 + int(C[q-1] == c+1)
        # エッジの色を格納
        C[w-1] = c
        # 子供をcueに追加
        Q.append(w)
print(max(C))
for b in B:
    print(C[b-1])
    

Measured memory_bytes: 44344
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl vector<long long>v(n);
#define mii unordered_map<ll,ll>
double pi = 2*acos(0.0);
//ll power(ll a,ll b){ ll res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}
 
 
    
      
 int main()
 {
       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
       ll tst;
       tst=1;
       //cin>>tst;
    
       while(tst--)
       {
         ll n;
         cin>>n;
         vl(n);ll k;cin>>v[0];k=v[0];
         for(int i=1;i<n;i++)
         {
               cin>>v[i];
               k=k^v[i];
         }
         for(int i=0;i<n;i++)
         {
               cout<<(v[i]^k)<<" ";
         }
         
       }
       
 }

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

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector<vector<int> > G(n, vector<int>(n));
	for (int i = 0; i < n; ++i)
	{
	    int u,k;
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			int v;
			cin >> v;
			G[u - 1][v - 1] = 1;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n - 1; ++j)
		{
			cout << G[i][j] << " ";
		}
		cout << G[i][n-1] << endl;
	}
}

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



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

int main()
{
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    S[K - 1] = S[K-1] - 'A' + 'a';
    cout << S;
	// std::ios::sync_with_stdio(false);
   	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

int a,b,c;
cin >> a >> b >> c;

int maxl = 0;
maxl = max(a,b);
maxl = max(maxl,c);

cout << a+b+c-maxl << endl;


return 0;
}



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

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

using namespace std;

int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	cout<<max(min(b,d)-max(a,c),0)<<endl;

	return 0;
}


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

class Main {

	static final int MOD = 1000000007;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		long m = Integer.parseInt(line.substring(0,line.indexOf(" ")));
		long n = Integer.parseInt(line.substring(line.indexOf(" ")+1));

		long ans = 1;
		while (n > 0) {
			if ((n&1) == 1)
				ans = ans * m % MOD;
			m = m * m % MOD;
			n >>= 1;
		}

		System.out.println(ans);

		br.close();
	}
}

Measured memory_bytes: 17068
N,D =input().split()
N = int(N)
D = int(D)
xy = [map(int, input().split()) for i in range(N)]
x, y = [list(i) for i in zip(*xy)]

def dis(a, b):
    return (a**2+b**2)**0.5

count = 0

for j in range(N):
    if dis(x[j],y[j]) <= D:
        count += 1
    else :
        count += 0

print(count)

Measured memory_bytes: 116736
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;

const ll MOD = 1000000000 + 7;

ll mpow(int base, int n)
{
    if (n == 0)
        return 1;
    ll prev = mpow(base, n / 2);
    if (n % 2 == 0)
    {
        return (prev * prev) % MOD;
    }
    else
    {
        return (prev * prev * base) % MOD;
    }
}

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n)
    {
        int a;
        cin >> a;
        mp[a]++;
    }
    int i = n - 1;
    while (i > 0)
    {
        cerr << i << endl;

        if (mp[i] != 2)
        {
            cout << 0 << endl;
            return 0;
        }
        i -= 2;
    }
    cout << mpow(2, n / 2) << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    bool flag = false;
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            int num = i * 4 + j * 7;
            if (num == N) {
                flag = true;
            }
        }
    }

    if (flag) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> t(2020);
    // t[0]     = 1;
    lint ret = 0;
    for (int i = 0; i < n; ++i) {
        vector<int> u(2020);
        for (int j = 0; j < 2020; ++j) {
            u[(j * 10 + (s[i] - '0')) % 2019] += t[j];
        }
        u[(s[i] - '0')]++;
        ret += u[0];
        swap(u, t);
    }
    cout << ret << "\n";
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int res = 15 - s.size();
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'o') res += 1;
    }
    if (res >= 8) cout << "YES";
    else cout << "NO";
}

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

int main() {
    int N;
    while (cin >> N , N) {
        vector<int> v(12);
        for (auto& i : v) {
            int x, y;
            cin >> x >> y;
            i = x - y;
        }

        int sum = 0;
        for (int i = 0; i < 12; i++) {
            sum += v[i];
            if (sum >= N) {
                cout << i + 1 << endl;
                break;
            }

            if (i == 11) {
                cout << "NA" << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 2984
n,a,b = map(int,input().split())
modnum = 10**9+7
ans = pow(2,n,modnum)-1

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res
ans -= combination(n, a, modnum)
ans -= combination(n, b, modnum)
ans %= modnum
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	str := sc.Text()
	sc.Scan()
	ser := sc.Text()
	str += str
	if strings.Contains(str, ser) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	return
}



Measured memory_bytes: 1092
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
int a[N];

signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int c = 0;
	for(int i = 2; i < n; i++){
		set<int> s;
		s.insert(a[i-1]);
		s.insert(a[i]);
		s.insert(a[i+1]);
		auto t = s.begin();
		t++;
		if((*t) == a[i])
			c++;
	}	
	cout << c;
	return 0;
}

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

using namespace std;

std::vector<std::string> split(const std::string &str, char sep){
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

bool solve(std::vector<int> go, int ans, bool x){
	int maxstr = 8000;
	bool temp[maxstr * 2 + 10], now[maxstr * 2 + 10];
	memset(now,false,sizeof(now));

	int i = 0;
	if (x == true) {
		now[maxstr + go[0]] = true;
		i = 1;
	}
	else {
		now[maxstr] = true;
	}

	while (i < go.size()) {
		memset(temp,false,sizeof(temp));
		for (int j = -maxstr; j < maxstr; j++) {
			if (now[j + maxstr]) {
				if (j + go[i] <= maxstr) {
					temp[j + go[i] + maxstr] = true;
				}
				if (j - go[i] >= -maxstr) {
					temp[j - go[i] + maxstr] = true;
				}
			}
		}
		// コピー
		for (size_t j = 0; j < sizeof(temp); j++) {
			now[j] = temp[j];
		}
		i++;
	}

	return now[ans + maxstr];
}

int main(int argc, char const *argv[]) {
	string str;
	std::cin >> str;
	int x,y;
	std::cin >> x >> y;
	std::vector<string> strary(split(str,'T'));
	std::vector<int> gox;
	std::vector<int> goy;
	for (size_t i = 0; i < strary.size(); i++) {
		// x軸方向に移動する
		if (i % 2 == 0) {
			gox.push_back(strary[i].size());
		}
		// y軸方向に移動する
		else {
			goy.push_back(strary[i].size());
		}
	}

	bool xx,yy;
	xx = solve(gox, x, true);
	yy = solve(goy, y, false);

	if (xx && yy) {
		std::cout << "Yes" << '\n';
	}
	else {
		std::cout << "No" << '\n';
	}


	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll LINF = 6e18;

ll c2, c3, c5, c1;
map<ll, ll> mp;

ll dfs(ll n) {
  if (!mp.count(n)) {
    if (n == 0) {
      mp[n] = 0;
    } else {
      ll res = LINF;
      if (n <= res / c1) res = min(res, c1 * n);
      res = min(res, dfs(n / 2) + c2 + c1 * (n % 2));
      res = min(res, dfs(n / 3) + c3 + c1 * (n % 3));
      res = min(res, dfs(n / 5) + c5 + c1 * (n % 5));
      if (n > 1) {
        if (n > 2) res = min(res, dfs(1 + n / 2) + c2 + c1 * (2 - (n % 2)));
        res = min(res, dfs(1 + n / 3) + c3 + c1 * (3 - (n % 3)));
        res = min(res, dfs(1 + n / 5) + c5 + c1 * (5 - (n % 5)));
      }
      mp[n] = res;
    }
  }
  return mp[n];
}

int main(){
  int T;
  cin >> T;
  while (T--) {
    mp = {};
    ll n;
    cin >> n;
    cin >> c2 >> c3 >> c5 >> c1;
    ll ans = dfs(n);
    cout << ans << endl;
  }
}

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

struct point
{
	int num;
	int val;
	bool operator<(const point p)
	{
		return val<p.val;
	}
}a[100010];
int main()
{    
   int n;cin>>n;
   for(int i=1;i<=n;i++)
    {
    	cin>>a[i].val;a[i].num=i;
	}
	sort(a+1,a+n+1);
	
      for(int i=1;i<=n;i++)
    {
    	cout<<a[i].num<<" ";
	}cout<<endl;
   
   return 0;
} 

Measured memory_bytes: 1536
module.exports=function(t){var r={};function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(r){return t[r]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=0)}([function(t,r,e){"use strict";var n=e(1);e(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,r){t.exports=require("fs")},function(t,r,e){"use strict";var n=e(3),i=e(5);t.exports=function(t){var r=new n(t);i(r)}},function(t,r,e){"use strict";var n=e(4);t.exports=class{constructor(t){var r=t.trim().split(/\s+/g);this.inp=new n(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,r,e){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,r,e){"use strict";var n=e(6);t.exports=function(t){for(var r=99999999999,e=t.in(),i=t.in(),o=t.in(),s=new Array(e),u=0;u<e;u++)s[u]=new Array(e).fill(r);for(var c=0;c<i;c++){var f=t.in(),a=t.in(),l=t.in();s[f-1][a-1]=l,s[a-1][f-1]=l}for(var p=n(s),v=0;v<e;v++)for(var d=0;d<e;d++)p[v][d]<=o?s[v][d]=1:s[v][d]=r;for(var h=n(s),y=t.in(),b=[],m=0;m<y;m++){var x=t.in(),g=t.in(),j=h[x-1][g-1];j==r?b.push(-1):b.push(j-1)}console.log(b.join("\n"))}},function(t,r,e){"use strict";t.exports=function(t){for(var r=t.length,e=[],n=0;n<r;n++)e.push(t[n].concat());for(var i=0;i<r;i++)for(var o=0;o<r;o++)for(var s=0;s<r;s++)e[o][s]>e[o][i]+e[i][s]&&(e[o][s]=e[o][i]+e[i][s]);return e}}]);

Measured memory_bytes: 60600
#include <stdio.h>

int main(){
	int time, h, m, s;
	scanf("%d", &time);
	for(h = 0; h <= 24; h++){
		if(time-h*3600 >= 0){
			continue;
		}
		else{
			time = time-(h-1)*3600;
			break;
		}
	}
	for(m = 0; m <= 60; m++){
		if(time-m*60 >= 0){
			continue;
		}
		else{
			time = time-(m-1)*60;
			break;
		}
	}
	s = time;
	printf("%d:%d:%d\n", h-1, m-1, s);
	return 0; 
}

Measured memory_bytes: 592
import java.util.*;
//System.out.println("")

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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vvd = vector<vd>;

int main() {
  int n; cin >> n;
  int n_ = n+1;

  vd p(n_);
  rep(i, n_) {
    cin >> p.at(i);
  }
  
  vvd dp = vvd(n_, vd(n_));
  dp.at(0).at(0) = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      if (j > i) continue;
      dp.at(i+1).at(j) += dp.at(i).at(j) * p.at(i);
      dp.at(i+1).at(j+1) += dp.at(i).at(j) * (1.0 - p.at(i));
    }
  }
  
  double result = 0.0;
  int m = n/2 + 1;
  for (int j = 0; j < m; j++) {
    result += dp.at(n).at(j);
  }
  
  cout << setprecision(10) << result << endl;
}


Measured memory_bytes: 70784
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int A = scanner.nextInt();
		if(X < A) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
	}
}


Measured memory_bytes: 21844