akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    string s; cin >> s;
    bool all9 = true;
    REP(i,1,s.size()) if(s[i]!='9') all9 = false;
    ll ans;
    if(all9){
        ans = s[0] - '0' + 9 * (s.size()-1);
    }else{
        ans = s[0] - '0' - 1 + 9 * (s.size()-1);
    }
    //cout << all9 << endl;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    string R,T;cin>>R>>T;
    vector<string> S;
    int r=R.size(),t=T.size();
    int i=r-t;
    bool b=false;
    while(i>=0){
        int k=0;
        while(k<t && i+k<r){
            if(R[i+k]==T[k] || R[i+k]=='?'){
                k++;
                if(k==t){
                    string s=R;
                    for(int x=i;x<i+t;x++)
                        s[x]=T[x-i];
                    for(int y=0;y<r;y++){
                        if(s[y]=='?')s[y]='a';
                    }
                    S.push_back(s);
                }
            }
            else break;
        }
        i--;
    }
    if(!S.empty()){
        sort(S.begin(),S.end());
        cout<<S[0]<<endl;
    }
    else cout<<"UNRESTORABLE"<<endl;
    return 0;
}

Measured memory_bytes: 256
# 2019-11-19 10:28:31(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, *d = map(int, sys.stdin.read().split())

    total = 0
    for i, j in itertools.combinations(d, 2):
        total += i * j
    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
const int maxn=1000+7;
int main()
{
	int n;
	cin>>n;
	set<int> a;
	rep(i,0,n)
	{
		int t;
		scanf("%d",&t);
		if(a.find(t)==a.end())
			a.insert(t);
		else
			a.erase(t);
	}
	cout<<a.size();
	return 0;
}


Measured memory_bytes: 4864
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)

long long p(long long a, long long n,long long m)
{
    long long ret=1;
    for(;n>0;n>>=1,a=a*a%m)
    {
        if(n%2==1)
        {
            ret = ret * a % m;
        }
    }
    return ret % m;
}

int main()
{
    long long n,a,b;
    const long long mod = 1e9+7;
    cin>>n>>a>>b;
    long long ans = p(2LL,n,mod) - 1;
    long long xa=1,ya=1,xb=1,yb=1;
    // cout << ans << endl;
    for(int i=1;i<=a;i++)
    {
        ya=(ya * i) % mod;
        xa=(xa * (n-i+1)) % mod;
    }
    // cout << xa << " "<< ya << endl;
    // cout << xa * p(ya, mod-2, mod) << endl;
    ans = (ans - xa * p(ya, mod-2, mod) + mod) % mod;
    for(int i=1;i<=b;i++)
    {
        yb=(yb * i) % mod;
        xb=(xb * (n-i+1)) % mod;
    }
    // cout << yb << " " << xb << endl;
    ans = (ans - xb * p(yb, mod-2, mod) + mod) % mod;
    cout << (ans + mod) % mod << endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque

fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toInt() }

    // 言語番号 -> ノード番号のリスト
    val languageNodes = Array(M + 1) { mutableListOf<Int>() }

    val edges = Array(100000) { mutableListOf<Int>() }

    var currentNode = 0

    for (i in 1..N) {
        val languages = readInputLine().split(" ").map { it.toInt() }.drop(1).toIntArray()

        // 同じ参加者のノードをつなぐ
        for (j in 1 until languages.size) {
            edges[j + currentNode].add(j + currentNode - 1)
            edges[j + currentNode - 1].add(j + currentNode)
        }

        // 同じ言語のノードを覚えておく
        for ((index, l) in languages.withIndex()) {
            languageNodes[l].add(currentNode + index)
        }

        currentNode += languages.size
    }

    // 同じ言語のノードをつなぐ
    for (i in 1..M) {
        for (j in 1 until languageNodes[i].size) {
            edges[languageNodes[i][j - 1]].add(languageNodes[i][j])
            edges[languageNodes[i][j]].add(languageNodes[i][j - 1])
        }
    }

    // アクセス済みノード管理
    val used = BooleanArray(currentNode)
    val queue = ArrayDeque<Int>(currentNode)

    queue.add(0)
    used[0] = true

    while (queue.isNotEmpty()) {
        val n = queue.poll()!!
        for (e in edges[n]) {
            if (!used[e]) {
                queue.add(e)
                used[e] = true
            }
        }
    }

    if (used.count { it } == currentNode) {
        println("YES")
    } else {
        println("NO")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 92604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1)%1000000007;
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


/*最小公倍数*/
/*
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
*/

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<ll>l(q),r(q);
    vector<ll>sum(s.size()+1,0);
    for(ll i=0;i<q;i++){
        cin>>l[i]>>r[i];
    }
    ll a=0;
    for(ll i=0;i<s.size()-1;i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            a++;
        }
        sum[i+2]=a;

    }
    for(ll i=0;i<q;i++){
        cout<<sum[r[i]]-sum[l[i]]<<endl;
    }


    


    

}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define PI acos(-1.0)
typedef long long ll;
 
int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  if (c>a+b && 4*a*b<(a+b-c)*(a+b-c)) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define mem(a, b)     memset(a, b, sizeof(a))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});
*/
int const fx[]= {+1,+0,-1,+1};
int const fy[]= {-1,+1,+0,+0};
const int inf = numeric_limits<int>::max();
const int mx=2e5;
const ll mod=1e9+7;
int main()
{
    int n,i,f=-1,st=-1,coun=0,sum=0;
    cin >> n;
    string s;
    cin >> s;
    for(i=0;i<n;i++)
    {
        if(s[i]=='W' && f==-1)f=i;
        if(s[i]=='W')coun++;
        if(s[i]=='R')sum+=coun,coun=0,st=i;
    }
    if(f==-1 || st==-1)cout << 0 << endl;
    else
    {
        coun=0;
        for(i=f;i<s.size();i++)
        {
            if(s[i]=='R')coun++;
        }
        int s1=0;
        for(i=f;i<f+coun;i++)
        {
            if(s[i]=='W')s1++;
        }
        cout << min(sum,s1) << endl;
    }
    return 0;
}




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

int main() {
	int n;
	cin>>n;
	string str;
	cin>>str;
	if(n%2!=0){
	    cout<<"No\n";
	}
	else{
	    if(str.compare(0,(n/2),str,(n/2),(n/2))==0){
	        cout<<"Yes\n";
	    }
	    else{
	        cout<<"No\n";
	    }
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  rep(i, S.size()) {
    if(S[i] != T[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3916
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
    }
    let mut v = vec![a,b,c];
    v.sort();
    println!("{}", v[2] * 10 + v[1] + v[0]);
}


Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
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
 *
 * @author AnandOza
 */
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);
        ARemainingBalls solver = new ARemainingBalls();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARemainingBalls {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next(), t = in.next();
            int a = in.nextInt(), b = in.nextInt();
            String u = in.next();

            if (u.equals(s))
                a--;
            else
                b--;

            out.println(Util.join(a, b));
        }

    }

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

    }

    static class Util {
        public static String join(int... i) {
            StringBuilder sb = new StringBuilder();
            for (int o : i) {
                sb.append(o);
                sb.append(" ");
            }
            if (sb.length() > 0) {
                sb.deleteCharAt(sb.length() - 1);
            }
            return sb.toString();
        }

        private Util() {
        }

    }
}



Measured memory_bytes: 21460
N,K = map(int,input().split())
S = input()

if S[N-1] == '1':
    S += '0'
else:
    S += '1'

memo = [1]
now = S[0]
cnt = 1
for i in range(N):
    if S[i+1] == now:
        cnt += 1
    else:
        cnt += 1
        memo.append(cnt)
        now = S[i+1]

n = len(memo)
for i in range(2*K+1):
    memo.append(N+1)

m = 0
l = []
if S[0] == '1':
    for i in range(n):
        if i%2 == 0:
            l.append(memo[i+2*K+1]-memo[i])
        else:
            l.append(memo[i+2*K]-memo[i])



        # if s > m:
        #     m = s
else:
    for i in range(n):
        if i%2 == 1:
            l.append(memo[i+2*K+1]-memo[i])
        else:
            l.append(memo[i+2*K]-memo[i])


        # if s > m:
        #     m = s

print(max(l))


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> a(N + 1);
    rep(i, N) cin >> a[i + 1];
    vector<int> b(N + 1);

    // 大きい数が書かれた箱から入れ方を決めていく
    for (int i = N; i >= 1; i--) {
        int sum = 0;
        // i以降のiの倍数で既に入れらた箱を調べる
        for (int j = i + i; j <= N; j += i) {
            sum ^= b[j];
        }
        b[i] = sum ^ a[i];
    }

    vector<int> ans;
    for (int i = 1; i <= N; i++) {
        if (b[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) {
        printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' ');
    }
}


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


int main(){
  int n,m,a[100];
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++) scanf("%d",a+i);
  for(int i=1;i<=m;i++){
    for(int j=0;j<n-1;j++){
      if(a[j]%i>a[j+1]%i){
        int t = a[j];
        a[j] = a[j+1];
        a[j+1] = t;
      }
    }
  }
  for(int i=0;i<n;i++) printf("%d\n",a[i]);
  return 0;
}

Measured memory_bytes: 2596
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int main() {
	char str[128];

	while(fgets(str, sizeof(str), stdin) != NULL) {
		stack<double> s;

		for(int i = 0; str[i] && str[i] != '\n';) {
			if(str[i] == ' ') i++;
			else if('0' <= str[i] && str[i] <= '9') {
				int p = 0;
				for(;str[i] && str[i] != ' ' && str[i] != '\n'; i++) {
					p *= 10;
					p += str[i] - '0';
				}
				s.push((double)p);
			}

			else if(str[i] == '-' && str[i + 1] != ' ' && str[i + 1] != '\n') {
				int p = 0;
				i++;
				for(;str[i] && str[i] != ' ' && str[i] != '\n'; i++) {
					p *= 10;
					p += str[i] - '0';
				}
				s.push((double)p * (-1));
			}

			else {
				double r, l;
				double p;
				r = s.top(); s.pop();
				l = s.top(); s.pop();

				switch(str[i]) {
					case '+':
						p = l + r;
						break;
					case '-':
						p = l - r;
						break;
					case '*':
						p = l * r;
						break;
					case '/':
						p = l / r;
						break;
				}
				s.push(p);
				i++;
			}
		}
		printf("%f\n", s.top());
	}
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    string s;
    cin >> s;
    if (s == "RSR") {
        cout << 1 << endl;
        return 0;
    }
    int ans = 0;
    REP(i, 3)
    {
        if (s[i] == 'R')
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const ll INF=1e9;


int main(){
  ll n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;
  ll m=min(a,min(b,min(c,min(d,e))));

  cout<<(n-1)/m+5;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <queue>
#include <iostream>
#define INF 0x7FFFFFFF;

using namespace std;

int main(void){
	int n, p[100000], s[100000], i, d, x;
	queue<int> que;
	scanf("%d",&n);
	for(i = 0;i < n;i++)
		s[i] = INF;
	for(i = 0;i < n;i++)
		scanf("%d",&p[i]);
	s[0] = 0;
	que.push(0);
	while(que.size()){
		for(i = 1;i <= 6;i++){
			x = que.front() + i, d = s[que.front()] + 1;
			if(x > n - 1)
				x = n - 1;
			else if(x < 0)
				x = 0;
			while(p[x] != 0 && s[x] > d){
				s[x] = d;
				x += p[x];
				if(x > n - 1)
					x = n - 1;
				else if(x < 0)
					x = 0;
			}
			if(p[x] == 0 && s[x] > d){
				que.push(x);
				s[x] = d;
			}
		}
		que.pop();
	}
	printf("%d\n",s[n - 1]);
	return 0;
}

Measured memory_bytes: 1992
S=input()
Q=int(input())

from collections import deque

S=deque(list(S))

flg=0

for i in range(Q):

    Query = list(input().split())
    
    if len(Query)!=1:
        F_i ,C_i = int(Query[1]),Query[2]
        
        if F_i==1 and flg==0:
            S.appendleft(C_i)
        
        elif F_i==2 and flg==0:
            S.append(C_i)   
        
        elif F_i==1 and flg==1:
            S.append(C_i)
        else:
            S.appendleft(C_i)
    else:
        if flg ==0:
            flg=1
        else:
            flg=0 

if flg ==1:
    S=reversed(S)

print(''.join(S))


Measured memory_bytes: 8420
n = $stdin.gets.to_i
s = []
po =[]
result = []
n.times do |i|
  s[i],po[i] = $stdin.gets.split
  po[i] = po[i].to_i
  result[i] = 1
end

n.times do |i|
  n.times do |j|
    if s[i] == s[j]
      if po[i]<po[j]
        result[i]+=1
      end
    elsif [s[i],s[j]].min == s[j]
      result[i]+=1
    end
  end
end

n.times do |i|
  puts result.index(i+1)+1
end

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

int main() {
 string a;
 cin>>a;
 int x=0;
  sort(a.begin(),a.end());
  int p=a.size();
  if(p%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  
  for(int i=0;i<p;i++){
    if(i==p-1){
      if(a.at(p-2)!=a.at(p-1)){
      cout<<"No"<<endl;
      return 0;
      }
      else{
        if((p-x)%2==0){
          cout<<"Yes"<<endl;
          return 0;
        }
        else{
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
    
    else{
      if(a.at(i)!=a.at(i+1)){
        if((1+i-x)%2==1){
          cout<<"No"<<endl;
          return 0;
        }
        else{
          x=i+1;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 100010
#define MOD 1000000007
typedef long long  ll;

using namespace std;


int main() {
	ll a,b;
	cin  >> a >> b;

	if (a < b) {
		rep(i, b) {
			cout << a;
		}
		cout << endl;
		return 0;
	}
	else{
		rep(i, a) {
			cout << b;
		}
		cout << endl;
		return 0;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPN(i,n) for(int i=1;i<=(n);i++)
#define REPV(i,b,n) for(int i=(b);i<=(n);i++)
using namespace std;
int n,k,c; 
string s;
int main()
{
	cin>>n>>k>>c;
	cin>>s;
	c++;
	vector<int>sum1(n,0),sum2(n,0);
	int now=0;
	while(now<n)
	{
		if(s[now]=='x')
		{
			now++; 
			continue;
		}
		else 
		{
			if(now!=n-1)sum2[now+1]++;
			now+=c;
		}
	}
	REP(i,n)
	{
		if(i!=0)
		{
			sum2[i]+=sum2[i-1];
		}
	}
	now=n-1;
	while(now>=0)
	{
		if(s[now]=='x')
		{
			now--; 
			continue;
		}
		else
		{
			if(now!=0)sum1[now-1]++;
			now-=c;
		}
	}
	for(int i=n-1;i>=0;i--)
	{
		if(i!=n-1)
		{
			sum1[i]+=sum1[i+1];
		}
	}
	vector<int>ans(0);
	REP(i,n)
	{
		if(s[i]=='o'&&sum1[i]+sum2[i]<k)
		{
			ans.push_back(i+1);
		}
	}
	REP(i,ans.size()) 
	{
		cout<<ans[i]<<endl;
	}
	return 0;	
} 

Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
int a[233333],w[233333];
int main()
{
	int n,mx=0,p=2100000000;scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mx=max(mx,a[i]);
	}
	for (int i=0;i<=mx;i++)
	{
		int d=max(i,mx-i);p=min(p,d);
		for (int j=1;j<=n;j++) if (a[j]==d) {a[j]=-1;w[i]=j;break;}
		if (!w[i]) {puts("Impossible");return 0;}
	}
	for (int i=1;i<=n;i++) if ((a[i]!=-1)&&(a[i]<=p)) {puts("Impossible");return 0;}
	puts("Possible");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	vector<ll> a(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];

	ll ans = 0, mx = a[0];

	for(int i = 1; i < n; i++){
		if(mx > a[i])
			ans += (mx - a[i]);
		mx = max(mx, a[i]); 
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4776
#include <stdio.h>
#define ABS(X) ((X)<0?-(X):(X))

int main(){
    int q;
    double x;
    
    while(scanf("%d",&q)){
        if (q==-1) break;
        for (x=q/2.0; ABS(x*x*x-q) >= 0.00001*q; x-=(x*x*x-q)/(3*x*x));
        printf("%f\n", x);
    }
    
    return 0;
}

Measured memory_bytes: 1056
x, n = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i)

others = (-100..200).to_a - ps
diffs = others.map{ |o| [o, (o - x).abs] }
min = diffs.sort{ |a, b| a[1] <=> b[1] }[0][1]
puts diffs.select{ |d| d[1] == min }.sort{|a,b| a[0] <=> b[0]}.first[0]


Measured memory_bytes: 14316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main() {
    list<int> l(105);
    int n,b; cin>>n;
    rep(i,n){
        cin>>b;
        if(b>i+1){
            cout<<-1<<endl;
            return 0;
        }
        l.insert(next(l.begin(),b-1),b);
    }
    for(auto v: l){
        if(v==0)break;
        cout<<v<<endl;
    }
}

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

int main() {
	int n,q;cin>>n>>q;
	priority_queue<int> que[1010];
	
	while(q--){
		int query,t;cin>>query>>t;
		if(query==0){
			int x;cin>>x;
			que[t].push(x);
		}else if(query==1){
			if(que[t].empty()) continue;
			cout<<que[t].top()<<endl;
		}else{
			if(que[t].empty()) continue;
			que[t].pop();
		}
	}
  return 0;
}



Measured memory_bytes: 4112
from queue import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()

for i in range(n):
    if i%2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

ans = list(b)

if n%2 != 0:
    ans = ans[::-1]

print(*ans)

Measured memory_bytes: 26892
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            char[] s = in.next().toCharArray();

            int[] total = new int[2];
            for (char c : s) {
                total["WE".indexOf(c)]++;
            }
            int[] count = new int[2];
            int best = n - 1;
            for (int i = 0; i < n; i++) {
                if (s[i] == 'W') {
                    best = Math.min(best, count[0] + (total[1] - count[1]));
                } else {
                    best = Math.min(best, count[0] + (total[1] - 1 - count[1]));
                }
                count["WE".indexOf(s[i])]++;
            }
            out.println(best);
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

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

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 25684
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n;
  cin >> n;

  ll d = 0, tp = n;
  vector<ll> v;
  while(tp){
    d++;
    v.pb(tp % 10);
    tp /= 10;
  }

  reverse(v.begin(), v.end());

  ll r[d - 2], ans = 10000;
  REP(i, d - 2){
    r[i] = 100 * v[i] + 10 * v[i + 1] + v[i + 2];
    ans = min(ans, abs(753 - r[i]));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n, x = map(int, raw_input().split())
a = map(int, raw_input().split())
ans = 10 ** 18
for i in xrange(n):
    t = sum(a) + x * i
    if ans > t:
        ans = t
    t = a[-1]
    for j in xrange(n - 1, 0, -1):
        if a[j] > a[j-1]:
            a[j] = a[j-1]
    if a[0] > t:
        a[0] = t
print ans


Measured memory_bytes: 2796
#define _CRT_SECURE_NO_WARNINGS


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <fstream>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <assert.h>
#include <bitset>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 998244353LL 
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
 
 
#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
 
//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

 
struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
 
};
typedef vector<vector<Edge>> Graph;
typedef unsigned long long ull;
 
 
inline ll ksum(ll n, ll k){
  return k * (2*n - k - 1);
}

pii updtp2(pii p, int nw){
  if(p.first == -1) p.first = nw;
  else if(p.second == -1) p.second = nw;
  else if(p.first >= nw) {
    p.second = p.first;
    p.first = nw;
  }
  else if(p.second >= nw) p.second = nw;
  return p;
}
 
#define isValid(y,x) (y >=0 && y < n && x >= 0 && x < m)

const pii Dir[4] = {{-1,0}, {0,1}, {1,0}, {0,-1}};

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


int main(){
    ll n;
    cin >> n;
    n--;

    string s;
    while(n >= 0){
        s+='a' + n%26;
        n /= 26;
        n--;
    }
    reverse(ALL(s));
    cout << s << endl;
  
	return 0;
} 

Measured memory_bytes: 3628
def c_synthetic_kadomatsu(N, A, B, C, L):
    def dfs(cur, a, b, c):
        # cur本竹を使ったとき、長さA, B, Cにしたい竹のそれぞれの長さがa, b, cの状態
        if cur == N:
            # 竹をすべて使った。長さが違う分だけ伸縮する
            # -30しているのは、 長さ0の竹に "合成" はしないため
            # (合成魔法のMP10 * 最終的に作りたい竹の数3 = 30 が余分に計上されている)
            # なお、最終的にできる3本の竹について、1本も竹を使わないことがあってはいけない
            return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else float('inf')
        # cur番目の竹をどれかの竹と合成するか、何もしない。そのときのMP
        ret0 = dfs(cur + 1, a, b, c)
        ret1 = dfs(cur + 1, a + L[cur], b, c) + 10
        ret2 = dfs(cur + 1, a, b + L[cur], c) + 10
        ret3 = dfs(cur + 1, a, b, c + L[cur]) + 10
        return min(ret0, ret1, ret2, ret3)
    ans = dfs(0, 0, 0, 0)  # 初期状態では0本目の竹に注目し、どの竹も長さ0とする
    return ans

N, A, B, C = [int(i) for i in input().split()]
L = [int(input()) for _ in range(N)]
print(c_synthetic_kadomatsu(N, A, B, C, L))

Measured memory_bytes: 3064
#include <stdio.h>
int main () {
    int N;
    scanf("%d", &N);
    int A[200000];
    int a = 0, b = 0;
    int c = 0;
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        if (a < A[i]) c = a, a = A[i], b = 1;
        else if (a == A[i]) b++;
        else if (c < A[i]) c = A[i];
    }
    for (int i = 0; i < N; i++) {
        if (A[i] == a) printf("%d\n", (b > 1) ? a : c);
        else printf("%d\n", a);
    }
}

Measured memory_bytes: 2304
#include <stdio.h>

int main() {
	char a[] = "#.";

	while (1) {
		int H, W;
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) {
			return 0;
		}

		for (int i = 0; i < H; i++) {
			for (int i2 = 0; i2 < W; i2++) {
				int b = (i % 2 + i2) % 2;
				printf("%c", a[b]);
			}
			printf("\n");
		}

		printf("\n");
	}


	return 0;
}


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

int main()
{
	//??????????????????
	int num1,num2,num3,num4,num5,num6,num7,num8,num9,num10,num11,num12,num13,num14,num15,num16,num17,num18,num19,num20,num21,num22,num23,num24,num25,num26,num27;
	int p1,p2,p3,p4,p5,p6,p7,p8,p9;
	int f1,f2,f4,f5,f7,f8;
	cin>>num1>>num2>>num3>>num4>>num5>>num6>>num7>>num8>>num9>>num10>>num11>>num12>>num13>>num14>>num15>>num16>>num17>>num18;
	num19=num1*3600+num2*60+num3;
	num20=num4*3600+num5*60+num6;
	num21=num7*3600+num8*60+num9;
	num22=num10*3600+num11*60+num12;
	num23=num13*3600+num14*60+num15;
	num24=num16*3600+num17*60+num18;
	num25=num20-num19;
	num26=num22-num21;
	num27=num24-num23;
	p1=num25/3600;
	f1=num25%3600;
	p2=f1/60;
	f2=f1%60;
	p3=f2;
	p4=num26/3600;
	f4=num26%3600;
	p5=f4/60;
	f5=f4%60;
	p6=f5;
	p7=num27/3600;
	f7=num27%3600;
	p8=f7/60;
	f8=f7%60;
	p9=f8;
	cout<< p1 <<" "<< p2 <<" "<< p3 <<"\n";
	cout<< p4 <<" "<< p5 <<" "<< p6 <<"\n";
	cout<< p7 <<" "<< p8 <<" "<< p9 <<"\n";
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5+1;
const long inf=1e14;
int main(){
	int N;cin>>N;
	int cnt[N] = {};
	int a; int t = 0;
	rep(i,0,N){
		cin>>a;
		cnt[a]++; t = max(t, a);
	}rep(i,0,t+1){
		if(cnt[max(i, t-i)] >= 1) cnt[max(i, t-i)]--;
		else{ cout<<"Impossible"<<endl; return 0; }
	}rep(i,0,(t + 3) / 2){
		if(cnt[i]){ cout<<"Impossible"<<endl; return 0; }
	}cout<<"Possible"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
//mapを使うことにより配列の通し番号ではなくキーとして数字を処理するので
//上限を設ける必要がない。今回のポイントは初期値が0であることを利用する、だ。
//あと通し番号となる部分を値の一つと考えることができる。
using namespace std;

int func(int n){
    if(n%2){
        return 3*n+ 1;
    }else{
        return n/2;
    }
}

int main(){
    int s;
    cin >> s;
    map<int,int> mp;
    
    //mp[s]の初期値は０だった。
    //一度登場するとインクリメントが行われる。
    mp[s]++;
    //最短で一致するとa2となるので。
    int count = 2;

    while(1){
        //この時点でｓは別物のｓとなる。
        s = func(s);

        //なるほど、同じ数字が出てくると同じ配列？の通し番号
        //にアクセスすることを利用しているのか。
        if(mp[s]){
            cout << count << endl;
            return 0;
        }
        //一度登場するとインクリメントが行われる。
        mp[s]++;
        count++;
        
    }
    


    

}


Measured memory_bytes: 384
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 100

int
main(int argc, char** argv)
{
	bool trump[4][13];
	char m;
	int i, j;

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

	int n;
	scanf("%d\n", &n);

	for (i = 0; i < n; ++i)
	{
		int x;
		scanf("%c %d\n", &m, &x);
		x -= 1;
		switch (m)
		{
		case 'S':
			trump[0][x] = true;
			break;

		case 'H':
			trump[1][x] = true;
			break;

		case 'C':
			trump[2][x] = true;
			break;

		case 'D':
			trump[3][x] = true;
			break;
		}
	}

	for (i = 0; i < 4; ++i)
	{
		switch (i)
		{
		case 0:
			m = 'S';
			break;

		case 1:
			m = 'H';
			break;

		case 2:
			m = 'C';
			break;

		case 3:
			m = 'D';
			break;
		}

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

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)

bool query(ll p, int k, vector<int> &w) {
  ll cw = 0;
  int m = 1;
  for(int i = 0; i < w.size(); i++) {
    if(cw + w[i] > p) {
      m++;
      cw = 0;
    }
    cw += w[i];
  }
  return m <= k;
}

int search(ll il, ll ir, int k, vector<int> &w) {
  ll l = il, r = ir;
  while(r - l > 1) {
    ll m = (l + r) / 2;
    if(query(m, k, w)) {
      r = m;
    } else {
      l = m;
    }
  }
  return r;
}

int main () {
  int n, k;
  cin >> n >> k;
  vector<int> w(n);
  ll l = 0;
  ll r = 0;
  rep(i,n) {
    cin >> w[i];
    r += w[i];
    l = max(l, (ll)w[i]);
  }

  cout << search(l-1, r, k, w) << endl;
  return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	int N;
	int x;
	cin >> N >> x;
	if(x==1||x==2*N-1){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if(N==2){
		REPA(i, 4){
			cout << i << endl;
		}
		return 0;
	}
	set<int> s;
	vector<int> ans;
	if(x==2){
		ans.push_back(3);
		ans.push_back(2);
		ans.push_back(1);
		ans.push_back(4);
	}else{
		ans.push_back(x-1);
		ans.push_back(x);
		ans.push_back(x+1);
		ans.push_back(x-2);
	}
	REPA(i, 2*N)s.insert(i);
	foreach(i, ans)s.erase(i);
	int count = 0;
	foreach(i, s){
		cout << i << endl;
		if(++count == N - 2){
			foreach(j, ans)cout << j << endl;
		}
	}

	return 0;
}


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

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

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

   int mx = 0 ;
   vector<int>bk ;
   bk.push_back(a[0]) ;
   for( int i = 1 ; i < n ; i++ ){
      if( bk.back() < a[i] ){
         int cn = 0 ;
         while( bk.size() ){
            cn++;
            bk.pop_back();
         }
        mx = max(cn, mx);
      }
      bk.push_back(a[i]) ;
   }

   mx = max( (int)bk.size() , mx ) ;
   cout << mx - 1 ;


}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

int ord(ll a,ll p){
  int i=0;
  while(a%p==0){
    a/=p;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++)cin>>a[i];
  ll x=0;
  for(i=0;i<n;i++)x^=a[i];
  int p[n];
  for(i=0;i<n;i++){
    p[i]=ord(a[i],2)+1;
  }
  int q[50];
  for(i=0;i<50;i++)q[i]=0;
  for(i=0;i<n;i++)q[p[i]]++;
  for(i=digit(x,2);i>=1;i--){
    if((x/pow1(2,i-1))%2==1 && q[i]!=0){
      x^=(pow1(2,i)-1);
      cnt++;
    }
  }
  if(x!=0)cout<<-1<<endl;
  else cout<<cnt<<endl;
}


Measured memory_bytes: 1408
import numpy as np

sheet=[input().split() for l in range(3)]
n=int(input())
b=[input() for i in range(n)]
a=np.array(sheet)
i,j,k,c,z=0,0,0,0,0

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]="x"


if a[0][0]==a[1][1]==a[2][2]=="x":
    c+=1

if a[0][2]==a[1][1]==a[2][0]=="x":
    c+=1

for z in range(3):
    if a[0][z]==a[1][z]==a[2][z]=="x":
        c+=1
    if a[z][0]==a[z][1]==a[z][2]=="x":
        c+=1
if c!=0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 12500
import sys
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if B - A == 0:
  print('YES')
  sys.exit()
elif B - A > 0:
  if (B + (W * T)) - (A + (V * T)) <= 0:
    print('YES')
  else:
    print('NO')
else:
  if (B - (W * T)) - (A - (V * T)) >= 0:
    print('YES')
  else:
    print('NO')

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

int main() {
	int n;
	cin >> n;
	
	double x;
	string u;
	double sum = 0.0;

	for (int i = 0; i < n; i++) {
		cin >> x >> u;
		if (u == "JPY") {
			sum += x;
		}
		else {
			sum += x * 380000.0;
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N,A[100];
    cin >> N;
    int count =0;
    int minj,tmp;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
       minj = i;
       for(int j=i;j<N;j++){
           if(A[j] < A[minj]){
               minj=j;
           }
       }
       if(i!=minj){
           tmp=A[i];
           A[i]=A[minj];
           A[minj]=tmp;
           count++;
       }
    }
    for(int i=0;i<N;i++){
        if(i!=N-1){
            cout<<A[i]<<' ';
        }else{
            cout <<A[i]<<endl;
        }
    }
    cout <<count<<endl;
    return 0;
}


Measured memory_bytes: 3092
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve(){
	complex<long double> A, B;
	long double a, b;
	cin >> a >> b;
	A = complex<long double>{ a,b };
	cin >> a >> b;
	B = complex<long double>{ a,b };
	int n;
	cin >> n;
	vector<pair<long double, int>> inputs;
	
	REP(i, n) {
		long double a, b;
		cin >> a >> b;
		complex<long double> C{ a,b };
		cin >> a >> b;
		complex<long double> D{ a,b };
		int e, f;
		cin >> e >> f;
		long double r = 0.0;
		long double bunbo = (B.real() - A.real()) * (D.imag() - C.imag()) - (B.imag() - A.imag()) * (D.real() - C.real());
		if (abs(bunbo) < eps) continue;
		r = ((D.imag() - C.imag()) * (C.real() - A.real()) - (D.real() - C.real()) * (C.imag() - A.imag()));
		r /= bunbo;
		long double s = ((B.imag() - A.imag()) * (C.real() - A.real()) - (B.real() - A.real()) * (C.imag() - A.imag())) / bunbo;
		e += f;
		e %= 2;
		if (r > 0.00000000L+eps && r < 1.00000000L - eps&&s > 0.00000000L + eps&&s < 1.00000000L - eps) {
			inputs.push_back(mp(r, e));
		}
	}
	sort(ALL(inputs));
	int ans = 0;
	for (int i = 1; i < inputs.size(); ++i) {
		if (inputs[i].second != inputs[i - 1].second) ans++;
	}
	cout << ans << endl;
}

#undef int
int main() {
	init();
	int t;
	cin >> t;
	REP(tea,t)
	solve();
}


Measured memory_bytes: 3276
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int number = 0;
		String symbol;

		String S = scan.nextLine();

		for (int i = 0; i < 4; i++){
			symbol = S.substring(i, i + 1);
			if (symbol.equals("+")){
				number += 1;
			}else if (symbol.equals("-")) {
				number -= 1;
			}
		}
		System.out.println(number);
	}
}

Measured memory_bytes: 23124
n, q = map(int, input().split())
s = input()
S = [0]
last = "!"
for i in range(n):
    if last == "A" and s[i] == "C":
        S.append(S[-1]+1)
    else:
        S.append(S[-1])
    last = s[i]

for i in range(q):
    l, r = map(int, input().split())
    print(S[r]-S[l])



Measured memory_bytes: 6124
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] food = new int[m+1];
        Arrays.fill(food, 0);
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                food[a] += 1;
            }
        }
        int ans = 0;
        for (int i = 0; i <= m; i++) {
            if (food[i] == n) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23636
N = int(input())

c = []
s = []
f = []
for i in range(N-1):
    l = list(map(int, input().split()))
    c.append(l[0])
    s.append(l[1])
    f.append(l[2])

ans = []
for i in range(N):
    t = 0
    for j in range(i, N-1):
        if t < s[j]:
            t = s[j]
        elif t % f[j] == 0:
            pass
        else:
            t += f[j] - (t % f[j])
        t += c[j]
    ans.append(t)

print('\n'.join(map(str, ans)))


Measured memory_bytes: 3064