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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
#define PI acos(-1.0)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int main()
{
    
    int n, a[5], i;
    string s;
    cin>>s;
    a[0]=s[0]-48;
    a[1]=s[1]-48;
    a[2]=s[2]-48;
    a[3]=s[3]-48;
    if(a[0]+a[1]+a[2]+a[3]==7)
    	cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl,exit(0);
    if(a[0]+a[1]+a[2]-a[3]==7)
    	cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl,exit(0);
    if(a[0]+a[1]-a[2]-a[3]==7)
    	cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl,exit(0);
    if(a[0]-a[1]-a[2]-a[3]==7)
    	cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl,exit(0);
    if(a[0]-a[1]-a[2]+a[3]==7)
    	cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl,exit(0);
    if(a[0]-a[1]+a[2]+a[3]==7)
    	cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl,exit(0);
    if(a[0]-a[1]+a[2]-a[3]==7)
    	cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl,exit(0);
    if(a[0]+a[1]-a[2]+a[3]==7)
    	cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl,exit(0);
    return 0;
}

Measured memory_bytes: 256
siki = gets.chomp.split("\s")
a, b = siki[0].to_i, siki[2].to_i

until siki[1] == "?"
	case	siki[1]
		when	"+"
			puts a + b
		when	"-"
			puts a - b
		when	"*"
			puts a * b
		else	
			puts a / b
	end
	
	siki = gets.chomp.split
	a, b = siki[0].to_i, siki[2].to_i
end

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

using namespace std;

int main() {
    int N;
    cin >> N;

    vector<string> S(0);
    for (int i = 0; i < N; i++) {
        string tmpS;
        cin >> tmpS;
        S.push_back(tmpS);
    }

    // 景品を保存する箱（ユニーク）
    set<string> box;
    for (int i = 0; i < N; i++) {
        box.insert(S.at(i));
    }

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

    return 0;
}

Measured memory_bytes: 24996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    

    // kuro-siro
    int ans1 = 0;
    for(int i=0; i<s.size(); i++){
        if(i%2 == 0 && s[i] == '1') ans1++;
        if(i%2 == 1 && s[i] == '0') ans1++;
    }

    // siro-kuro
    int ans2 = 0;
    for(int i=0; i<s.size(); i++){
        if(i%2 == 0 && s[i] == '0') ans2++;
        if(i%2 == 1 && s[i] == '1') ans2++;
    }

    cout << min(ans1, ans2) << endl;

}

Measured memory_bytes: 512
# class Solution:
#     def solve(self, a, b, c, s):
#         return str(a + b + c) + " " + s


def main():
    inp = lambda: [int(x) for x in input().split()]
    n = float(input()) / 3
    print(n ** 3)

if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	vector<int64> xx(nn), yy(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> xx[ii] >> yy[ii];
	}
	long double sum = 0.0;
	for(int64 ii = 0;ii < nn;ii++)
	{
		for(int64 jj = 0;jj < nn;jj++)
		{
			sum += sqrtl((long double)((xx[ii] - xx[jj]) * (xx[ii] - xx[jj]) + (yy[ii] - yy[jj]) * (yy[ii] - yy[jj])));
		}
	}
	sum /= (long double)nn;
	cout << fixed << setprecision(20);
	cout << sum << endl;
	return 0;
}

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


int main() {
  int h, w;
  cin >> h >> w;
  char mine[h][w];
  char ans[h][w];
  int dx[3] = {-1, 0, 1}, dy[3] = {-1, 0, 1};
  rep(i, h){
    rep(j, w){
      cin >> mine[i][j];
      ans[i][j] = mine[i][j];
      
    }
  }

  rep(i, h){
    rep(j, w){
      if (mine[i][j] == '.'){
        int count = 0;
        rep(k, 3){
          rep(l, 3){
            int a = i+dx[k], b = j+dy[l];
            
              if (a >= 0 && b >= 0 && a < h && b < w && mine[i+dx[k]][j+dy[l]] == '#'){
                count ++;
            }
          }
        }
        cout << count;
      }
      else{
        cout << '#';
      }
    } 
    cout << endl;
  }
  

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type,
		less_equal<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
		
typedef tree<int, null_type,
		less<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_set;
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	
 
vector<string>v;
 
bool comp(string a,string b)
{
	if(a.size()!=b.size()) return a.size()<b.size();
	return a<b;
}
 
 
void dfs(string u)
{
	v.push_back(u);
	if(u.size()==11) return;
	int x=u.back()-'0';
	if(x==0)
	{
		string a=u+"0";
		string b=u+"1";
		
		dfs(a);
		dfs(b);
	}
	else if(x==9)
	{
		string a=u+(char)(u.back()-1);
		string b=u+(char)(u.back()+0);
		
		dfs(a);
		dfs(b);
	}
	else 
	{
		string a=u+(char)(u.back()-1);
		string b=u+(char(u.back()+0));
		string c=u+(char)(u.back()+1);
		
		dfs(a);
		dfs(b);
		dfs(c);
	}
}
 
void make()
{
	for(int i=1;i<10;i++)
	{
		string x=to_string(i);
		dfs(x);
	}
		
	sort(v.begin(),v.end(),comp);
}
 
void solve()
{
	make();
	
	int n;
	cin>>n;
	
	n--;
	
	cout<<v[n];
	
}
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


Measured memory_bytes: 42860
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

typedef struct edge{
    ll to;
    ll cost;
} edge;

typedef struct DP {
    ll cost;
    ll from;
} DP;

vector<edge> G[100002];

//自作構造体にしたいけど比較演算子の定義がわからないので保留
typedef pair<ll, ll> P; 

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;

    bool E[n][n];
    REP(i,n) REP(j,n) E[i][j] = false;

    REP(i,m) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a-1].push_back({b-1, c}); 
        G[b-1].push_back({a-1, c});
    }
    for (int I = 0; I < n; ++I) {

        DP dp[n];
        REP(i,n) {
            dp[i].cost = INF;
            dp[i].from = INF;
        }
        priority_queue<P, vector<P>, greater<P>> pq;
        pq.push({0, I});
        dp[I].cost = 0;
        dp[I].from = I;
        
        while(!pq.empty()) {
            P now = pq.top(); pq.pop();
            ll v = now.second;
            if (dp[v].cost < now.first) continue;
            for (int i = 0; i < G[v].size(); ++i) {
                edge e = G[v][i];
                if (dp[e.to].cost > dp[v].cost+e.cost) {
                    dp[e.to].cost = dp[v].cost+e.cost;
                    dp[e.to].from = v;
                    pq.push({dp[e.to].cost, e.to});
                }
            }
        }
        REP(j,n) if (j != dp[j].from) E[dp[j].from][j] = E[j][dp[j].from] = true;
    }
    int c = 0;
    REP(i,n) {
        REP(j,n) {
            if(E[i][j]) c++;
        }
    }
    int ans = m-(c/2);
    cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 2688
using namespace std;
#include<string.h>
#include <sstream>
typedef long long int ll;
typedef long double ld;
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <map>
//#define N 4
#include <stack>
#include <unordered_set>
#include <math.h>
#include <cstring>
#include <bitset>
#include <numeric>
#include <set>
#include <sstream>
#include <list>
#include <queue>
#define PI 3.14159265358979323846264338327950
#define mp make_pair
#define inf 1e9
//#define M 1000000007
#define M 10000000
#define N 100000

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	int a[5];

	for (int i = 1; i <= 5; i++) {
		cin >> a[i];
	}

	int ans = 0;
	for (int i = 1; i <= 5; i++) {
		if (a[i] == 0) {
			ans = i;
		}
	}

	cout << ans << endl;
}



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

int	main(void)
{
	string str;
	string str2;
  
  	cin >> str >> str2;

	int len = str.length();
	int count = 0;

	for (int i = 0; i < len; i++)
	{
		if (str[i] != str2[i])
        {
            cout << "No" << endl;
      		break;
        }
		else
			count++;
	}

	if (len == count)
		cout << "Yes" << endl;

	return (0);
}

Measured memory_bytes: 3636
s=input()
n=len(s)
for i in range(n):
  if not s[i]==s[n-i-1]:
    print('No')
    exit()
for i in range(n//2):
  if not s[i]==s[n//2-i-1]:
    print('No')
    exit()
for i in range(n//2+1,n):
  if not s[i]==s[n-i-1]:
    print('No')
    exit()
print('Yes')

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

template<typename T>
struct binary_indexed_tree {
    vector<T> t_;
    i64 n_;

    binary_indexed_tree(size_t n): t_(n + 1), n_(n + 1) {}

    void add(i64 i, T x) {
        for (; i <= n_; i += i & -i) t_[i] += x;
    }

    T sum(i64 i) {
        T res = 0;
        for (; i > 0; i -= i & -i) res += t_[i];
        return res;
    }
};

struct query { i64 idx, l, r; };

void solve() {
    i64 n, q;
    cin >> n >> q;
    vector<i64> c(n);
    for (auto& e : c) cin >> e;
    vector<query> qs(q);
    for (i64 i = 0; i < q; i++) {
        auto& [ idx, l, r ] = qs[i];
        idx = i;
        cin >> l >> r;
    }
    sort(all(qs), [](const query &x, const query &y) { return x.r < y.r; });

    vector<i64> right(n), ans(q);
    binary_indexed_tree<i64> cnt(n);
    i64 i = 0;
    for (auto& [ idx, l, r ] : qs) {
        while (i < r) {
            if (right[c[i]]) cnt.add(right[c[i]], -1);
            right[c[i]] = i + 1;
            cnt.add(right[c[i]], 1);
            i++;
        }
        ans[idx] = cnt.sum(r) - cnt.sum(l - 1);
    }
    for (auto& e : ans) cout << e << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

using namespace std;
typedef long long int ll;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

const int INF = 7368791;
int P[INF + 1];

int main() {
  while (true) {
    int M, N; scanf("%d %d", &M, &N);
    if (N == 0 and M == 0) break;
    memset(P, 0, sizeof(P));

    for (int i = M, cnt = 0; ; i++) {
      if (not P[i]) {
        if (cnt == N) {
          printf("%d\n", i);
          break;
        }
        for (int j = i; j <= INF; j += i) P[j] = 1;
        cnt++;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 31976
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)
#define maxx 1000001
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    FASTIO
    string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='s') s+="es";
    else s+='s';
    cout<<s<<endl;
    return 0;
}


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

int main(){
    int n,x;
    while(1){
        cin>>n>>x;
        int ans =0;
        if(n==0&&x==0){
            return 0;
        }
        for(int i=n;2<i;i--){
            for(int j=i-1;1<j;j--){
                for(int k=j-1;0<k;k--){
                  
                    if(i+j+k==x){
                        ans++;
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3088
def f(h, w):
    dt = [[-1, 0], [0, -1], [0, 1], [1, 0]]
    t = [[True] * (w + 2)]
    for _ in range(h):
        t += [[True] + [(c == "#") for c in input()] + [True]]
    t += [[True] * (w + 2)]
    kuro = []
    for i, ti in enumerate(t[1:-1]):
        for j, tij in enumerate(ti[1:-1]):
            if tij:
                kuro+=[(i + 1, j + 1)]
    cnt = -1
    while kuro:
        cnt += 1
        nxt = []
        for i, j in kuro:
            ti=t[i]
            if not ti[j+1]:
                ti[j + 1]=True
                nxt += [(i, j+1)]
            if not ti[j-1]:
                ti[j - 1]=True
                nxt += [(i, j-1)]
            if not t[i - 1][j]:
                t[i - 1][j]=True
                nxt += [(i - 1, j)]
            if not t[i + 1][j]:
                t[i + 1][j]=True
                nxt += [(i + 1, j)]
        kuro = nxt
    print(cnt)
 
 
h, w = map(int, input().split())
f(h, w)

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

int main() {
  int N;
  cin >> N;
  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);
  rep(i,N){
    cin >> t.at(i);
    cin >> x.at(i);
    cin >> y.at(i);
  }
  int key=1;
  int i=0;
  int lon=0;
  while(key==1&&i<N){
    lon=x.at(i)+y.at(i);
    if(t.at(i)%2==0){
      if(lon%2==1){
        key=0;
      }
    }
    else{
      if(lon%2==0){
        key=0;
      }
    }
    if(N==1){
      int sax=x.at(i);
      if(sax<0){
        sax*=-1;
      }
      int say=y.at(i);
      if(say<0){
        say*=-1;
      }
      int sat=t.at(i);
      if(sat<sax+say){
        key=0;
      }
    }
    if(i<N-1){
      int sax=x.at(i)-x.at(i+1);
      if(sax<0){
        sax*=-1;
      }
      int say=y.at(i)-y.at(i+1);
      if(say<0){
        say*=-1;
      }
      int sat=t.at(i+1)-t.at(i);
      if(sat<sax+say){
        key=0;
      }
    }
    i++;
  }
  if(key==1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}



Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b){
		if (b == c){
			cout << 1 << endl;
		}
		else{
			cout << 2 << endl;
		}
	}
	else{
		if (b == c){
			cout << 2 << endl;
		}
		else{
			if (a == c){
				cout << 2 << endl;
			}
			else{
				cout << 3 << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
num = []
while n != 0:
  num.append(n%10)
  n -= n%10
  n /= 10
a=num[2]
b=num[1]
c=num[0]
d=0
e=0
f=0
if a==9:
  d=1
elif a==1:
  d=9
else:
  d=a
if b==9:
  e=1
elif b==1:
  e=9
else:
  e=b
if c==9:
  f=1
elif c==1:
  f=9
else:
  f=c
print(int(100*d+10*e+f))

Measured memory_bytes: 3188
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
	pair<int, int> a[5];
	while (true) {
		int x, y;
		for (int i=0; i<5; ++i) {
			scanf("%d%d", &x, &y);
			if (x==0 && y==0) return 0;
			a[i] = make_pair(x+y, i);
		}
		sort(a, a+5);
		printf("%c %d\n", 'A'+a[4].second, a[4].first);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define MAX (ll)(1e6 + 7)
#define INF (ll)(2e5 + 7)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;
ll md[2] = {231, 3006703054056749LL}, pw[MAX];

ll mult (ll a, ll b, bool fl) {
	return (a * 1LL * b) % md[fl];
}

ll add (ll a, ll b, bool fl) {
	b += md[fl], a += md[fl];
	return (a % md[fl] + b % md[fl]) % md[fl];
}

map<ll, int> m1;
int cou[INF][26];

int main () {
	ios_base :: sync_with_stdio (false);
	cin.tie (nullptr);
	pw[0] = 1;
	vector<pair<int, int>> vp;
	for (int i = 1; i < MAX; i++) {
		pw[i] = mult (md[0], pw[i - 1], 1);
	}
	vector<ll> vv;
	ll n;
	cin >> n;
	vector<string> vs (n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> vs[i];
		vp.push_back (make_pair ((int)vs[i].size (), i));
	}
	sort (vp.begin (), vp.end ());
	for (int y = 0; y < n; y++) {
		int i = vp[y].second, nn = vp[y].first;
		int ch[26] = {};
		for (char x : vs[i]) {
			ch[x - 'a']++;
		}
		ll h = 0;
		for (int j = 0; j < nn; j++) {
			auto q = m1.find (h);
			if (q != m1.end ()) {
				for (int k = 0; k < 26; k++) {
					if (ch[k]) {
						ans += cou[q -> second][k];	
					}
				}
			}
			if (j + 1 < nn) {
				int x = vs[i][nn - j - 1] - 'a';
				h = add (h, mult (pw[j], x + 1, 1), 1);
				ch[x]--;
			}
		}
		auto q = m1.find (h);
		if (q == m1.end ()) {
			m1[h] = i;
		}
		cou[m1[h]][vs[i][0] - 'a']++;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 47676
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
typedef long long  ll;
typedef long double ld;
typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii;
const ld pi=3.14159265359;
const int maxn=2e5+7;
const int mod=1e9+7;
const ll INF=9223372036854775807;
const int inf=2e9+7; 
#define int long long
/*Almost copy pasted part :)*/
int a[maxn];

int32_t main(){
	int n;
	cin>>n;
	int A,B;
	cin>>A>>B;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(int i=1;i<=n-1;i++){
		int dis=a[i+1]-a[i];
		ll ret=A*dis;
		ans+=min(ret,1ll*B);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

string s[4] = { "dream", "dreamer", "erase", "eraser" };

int main() {
	string a;
	cin >> a;

	

	reverse(a.begin(), a.end());
	for (int i = 0; i < 4; ++i) {
		reverse(s[i].begin(), s[i].end());
	}


	bool flag = true;

	for (int i = 0; i < a.size();) {
		bool flag2 = false;
		for (int j = 0; j < 4; ++j) {
			string b = s[j];
			
			if (a.substr(i, b.size()) == b) {
				flag2 = true;
				i += b.size();
			}
		}
		if (!flag2) {
			flag = false;
			break;
		}
	}

	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;


int main() {
    string S;
    cin >> S;
    int now = S.size() - 5;
    while(now >= 0){
        if(S.substr(now, 5) == "dream" or S.substr(now, 5) == "erase"){
            now -= 5;
            continue;
        }
        now--;
        if(now < 0) puts("NO");
        if(S.substr(now, 6) == "eraser"){
            now -= 5;
            continue;
        }
        now--;
        if(now < 0) puts("NO");
        if(S.substr(now, 7) == "dreamer"){
            now -= 5;
            continue;
        }
        puts("NO");
        return 0;
    }
    puts("YES");
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N, M = list(map(int, input().split()))
    k, s = [], []
    for m in range(M):
        l = list(map(int, input().split()))
        k.append(l[0])
        s.append(l[1:])
    p = list(map(int, input().split()))

    return N, M, k, s, p


def main(N: int, M: int, s: list, p: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): スイッチの数(1 <= N <= 10)
        M (int): 電球の数(1 <= M <= 10)
        s (list): 電球と繋がっているスイッチ(1 <= s_ij <= N)
        p (list): 点灯判定(0または1)
    """
    # 求解処理
    ans = 0
    for bit in range(1 << N):
        is_all_light_on = True
        for m in range(M):
            on_count = 0
            for s_i in s[m]:
                if ((bit >> (s_i - 1)) & 1):
                    on_count += 1
            if on_count % 2 != p[m]:
                is_all_light_on = False
                break
        if is_all_light_on:
            ans += 1

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, M, k, s, p = get_input()

    # メイン処理
    main(N, M, s, p)


Measured memory_bytes: 9116
# Problem C - Lower

# input process
N = int(input())
h_list = list(map(int, input().split()))
h_len = len(h_list)

# initialization
max_step = 0
tmp_step = 0

# step process
for i in range(N-1):
    if h_list[i]>=h_list[i+1]:
        tmp_step += 1
    else:
        max_step = max(max_step, tmp_step)
        tmp_step = 0
max_step = max(max_step, tmp_step)

print(max_step)


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

class Dice {
	int m_top;
	int m_front;
	int m_right;
	int m_face[6];
public:
	Dice(int face[], int top, int front, int right);
	int faceNum(int face) {
		return m_face[face];
	}
	void roll(int news);
	int top() {
		return m_top;
	}
	int bottom() {
		return (5 - m_top);
	}
	int front() {
		return m_front;
	}
	int back() {
		return (5 - m_front);
	}
	int right() {
		return m_right;
	}
	int left() {
		return (5 - m_right);
	}
};

Dice::Dice(int face[], int top, int front, int right) {
	for (int i = 0; i < 6; i++) {
		m_face[i] = face[i];
	}
	m_top = top;
	m_front = front;
	m_right = right;
}

void Dice::roll(int news) {
	int temp = 0;
	switch (news)
	{
	case 0:		// N
		temp = bottom();
		m_top = m_front;
		m_front = temp;
		break;
	case 1:		// E
		temp = left();
		m_right = m_top;
		m_top = temp;
		break;
	case 2:		// S
		temp = back();
		m_front = m_top;
		m_top = temp;
		break;
	case 3:		// W
		temp = bottom();
		m_top = m_right;
		m_right = temp;
		break;
	default:
		break;
	}
}

int main()
{
	int f[6] = { 0 };
	string str;

	for (int i = 0; i < 6; i++) {
		cin >> f[i];
	}
	cin >> str;

	Dice d(f, 0, 1, 2);
	int l = str.length();
	for (int i = 0; i < l; i++) {
		if (str[i] == 'N') {
			d.roll(0);
		}
		if (str[i] == 'E') {
			d.roll(1);
		}
		if (str[i] == 'S') {
			d.roll(2);
		}
		if (str[i] == 'W') {
			d.roll(3);
		}
	}

	cout << d.faceNum(d.top()) << endl;

	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
const int maxn=200100;
int up2[maxn],d2[maxn],up5[maxn],d5[maxn];
int cnt[11][11][11][11],n;
long long ans=0;
int main()
{
	cin>>n;
	for(int x=1;x<=n;x++)
	{
		string s;cin>>s;
		long long upv=0,dv=1,flag=0;
		for(int i=0;i<(int)s.size();i++) if(isdigit(s[i])) upv=10*upv+s[i]-'0';
		for(int i=0;i<(int)s.size();i++)
		{
			if(s[i]=='.') flag=1;
			else if(flag) dv=10*dv;
		}
		long long ttt=__gcd(upv,dv);
		upv/=ttt;dv/=ttt;
		while(upv%2==0) upv/=2,up2[x]++;
		while(upv%5==0) upv/=5,up5[x]++;
		while(dv%2==0) dv/=2,d2[x]++;
		while(dv%5==0) dv/=5,d5[x]++;
		up2[x]=min(up2[x],10);
		d2[x]=min(d2[x],10);
		up5[x]=min(up5[x],10);
		d5[x]=min(d5[x],10);
		for(int A=0;A<=10;A++) for(int B=0;B<=(A?0:10);B++)
			for(int C=0;C<=10;C++) for(int D=0;D<=(C?0:10);D++)
			{
				if(A>=d2[x]&&B<=up2[x]&&C>=d5[x]&&D<=up5[x])
					ans+=cnt[A][B][C][D];
			}
		cnt[up2[x]][d2[x]][up5[x]][d5[x]]++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int x, y;
Int a[210];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> x >> y;
	a[1] = 300000;
	a[2] = 200000;
	a[3] = 100000;
	cout << a[x] + a[y] + (x+y == 2 ? 400000 : 0) << "\n";
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int Lj4PdHRW;
  int A;
  int KL2GvlyY = rd_int();
  for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
    rd(A);
    if(A%2==0 && (A%3!=0 && A%5!=0)){
      wt_L("DENIED");
      wt_L('\n');
      return 0;
    }
  }
  wt_L("APPROVED");
  wt_L('\n');
  return 0;
}
// cLay varsion 20200217-1

// --- original code ---
// {
//   int A;
//   REP(rd_int()){
//     rd(A);
//     if(A%2==0 && (A%3!=0 && A%5!=0)) wt("DENIED"), return 0;
//   }
//   wt("APPROVED");
// }


Measured memory_bytes: 256
/*

        /////////     /////        ////      ////
        //           //   //      //   //  // //
        //////      //    //     //     //   //
            //     // /// //    //          //
      ////////    //      //   //          //
*/

#include<bits/stdc++.h>
#include<assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fo(i,s,n) for(int i=s;i<n;i++)
#define pb(x) push_back(x);
#define mod 1000000007


int main()
{
    Fast
    int n,w;
    
    cin>>n>>w;
    vector<ll>dp(w+1);
    for(int i=1;i<=n;i++)
    {
        ll a, b;
        cin>>a>>b;
        for(int j=w;j>=a;j--)
            dp[j]=max(dp[j-a]+b,dp[j]);

    }
    //fo(i,0,w)
    //cout<<dp[i];
    cout<<*max_element(dp.begin(),dp.end())<<endl;

    return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    int n = gi;
    FORD(i, (int)sqrt(n), 1) {
        double v = (double)n/(double)i;
        if (trunc(v) == v) {
            print((n/i) + i - 2);
            break;
        }
    }
}

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

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

//
#define int long long
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;

  int tmp = N;
  int cont = 0;
  while (tmp > 0) {
    tmp /= 10;
    cont++;
  }

  int ans = 0;
  for (int i = 3; i <= cont; i++) {
    for (int bit = 0; bit < pow(3, i); bit++) {
      int mp[3];
      mp[0] = mp[1] = mp[2] = 0;

      int tmp = 0, now = bit;
      for (int j = 0; j < i; j++) {
        int x = now % 3;
        mp[x]++;

        if (x == 0) tmp += 3;
        if (x == 1) tmp += 5;
        if (x == 2) tmp += 7;

        now /= 3;
        tmp *= 10;
      }

      tmp /= 10;

      if (tmp <= N && mp[0] != 0 && mp[1] != 0 && mp[2] != 0) ans++;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 
int main(void) {
    ll n;
    cin >> n;
    ll tmp, ans = 0, val = 1;
    rep(i, 0, n) {
        cin >> tmp;
        if (tmp == val) val++;
        else ans++;
    }
    if (val == 1 && ans != 0) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 256
A=[]
B=[]
for i in range(4):
    s1=int(input())
    A.append(s1)
for j in range(2):
    s2=int(input())
    B.append(s2)
C=sorted(A)
D=sorted(B)
C.pop(0)
D.pop(0)
sm1=sum(C)
sm2=sum(D)
print(sm1+sm2)


Measured memory_bytes: 5592
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var n = parseInt(input);
var result = [];
for (var i=1;i<=n;i++){
    if(i % 3 === 0){
        result.push(i);
    }
    if(i % 3 !== 0 && (i+"").match(/3/)){
      result.push(i);
    }
}
console.log(' ' + result.join(" "));


Measured memory_bytes: 17672
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int N = Cin();
    vector<vector<int>> adList(N);
    for (int i = 0; i < N - 1; ++i)
    {
        int ai = Cin(), bi = Cin();
        adList[ai - 1].push_back(bi - 1);
        adList[bi - 1].push_back(ai - 1);
    }
    vector<int> cs(N);
    for (auto &ci : cs) ci = Cin();
    sort(cs.rbegin(), cs.rend());
    // これまで考えた部分グラフと連結する辺に
    // これまで使っていない最大の数を入れていく
    vector<bool> hasNotVisited(N, true);
    vector<int> nums(N);
    stack<int> stack;
    stack.push(0);
    int index = 0;
    nums[0] = cs[index];
    hasNotVisited[0] = false;
    ++index;
    int ans = 0;
    // DFSで全ての頂点と接続しながら，大きい数から順に入れていく
    while (!stack.empty())
    {
        int v = stack.top();
        stack.pop();
        for (const int n : adList[v])
        {
            if (hasNotVisited[n])
            {
                stack.push(n);
                hasNotVisited[n] = false;
                nums[n] = cs[index];
                ans += cs[index];
                ++index;
            }
        }
    }
    cout << ans << endl;
    for (int i = 0; i < N; ++i)
    {
        cout << nums[i] << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
  }
  int counter = 0;
  for(int i=1; i<n-1; i++){
    vector<int> triple(3), triplesort(3);
    triple[0] = p[i-1];
    triple[1] = p[i];
    triple[2] = p[i+1];
    triplesort = triple;
    boost::sort(triplesort);
    if (triple[1] == triplesort[1]) counter++;
  }

  cout << counter << endl;

  return 0;
}


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

int main() {

    //入力
    string word;
    int i;
  	int result = 0;
    cin >> word;
    i = word.size();

    //判定回数の決定
    if (i % 2 == 1) {
        i = (i - 1) / 2;
    }
    else {
        i = i / 2;
    }

    //判定
    int k = word.size();
    k--;
    for (int j = 0; j < i; j++) {
        if (word[j] != word[k]) {
            result++;
        }
        k--;
    }

    //出力
    cout << result << endl;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  int matrix[n][m];
  int vector[m];
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      scanf("%d",&matrix[i][j]);
    }
  }

  for(int i=0; i<m; i++){
    scanf("%d",&vector[i]);
  }

  for(int i=0; i<n; i++){
  int s = 0;
    for(int j=0; j<m; j++){
      s += matrix[i][j]*vector[j];
    }
   cout << s << endl;
 }

  

}

Measured memory_bytes: 3156
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

#define FOR(i, a) for(int i=0;i<(int)a;++i)
typedef long long ll;
using namespace std;

void solver() {
    int N;
    vector<int> vec;
    FOR(i, 3) {
        cin >> N;
        vec.push_back(N);
    }
    sort(vec.begin(), vec.end());
    cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
}

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

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    ll r;
    cin>>r;
    double x=2*pi*r;
    cout<<preci(7)<<x<<nl;
    return 0;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(ll i=a;i<b;++i)
#define REPN(i,a,b) for(ll i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
const int M=1e9+7;
const int MAXN=17;


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

  string s;
  cin>>s;
  REP(i,0,s.size())
  cout<<"x";
  
  cout<<"\n";

    return 0;
}

Measured memory_bytes: 256
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 2e5 + 5;

int N;
int A[MAXN];

void input()
{
    read(N);
    for (int i = 1; i < N * 2; ++i) {
        read(A[i]);
    }
}

int get(int x)
{
    static int B[MAXN];

    for (int i = 1; i < N * 2; ++i) {
        B[i] = (A[i] >= x);
    }
    for (int i = 1; i < N; ++i) {
        if (B[N - i + 1] == B[N - i])
            return B[N - i];
        if (B[N + i - 1] == B[N + i])
            return B[N + i];
    }
    return B[N] ^ (~N & 1);
}

void solve()
{
    int l = 1, r = N * 2;
    while (l + 1 < r) {
        int mid = (l + r) >> 1;
        int t = get(mid);
        if (t == 0)
            r = mid;
        else
            l = mid;
    }

    printf("%d\n", l);
}

int main()
{
#ifdef __DEBUG
    freopen("D.in", "r", stdin);
    freopen("D.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 当时轻别意中人，山长水远知何处。
//     -- 晏殊《踏莎行·碧海无波》


Measured memory_bytes: 1792
N,M=gets.split.map(&:to_i)
s=gets.chomp.split("")
s.pop

ans=[]
cnt=0
put=0
s.reverse_each do |c|
    cnt+=1
    put=cnt if c!="1"
    if cnt==M
        if put==0
            puts -1
            exit
        end
        ans << put
        cnt=cnt-put
        put=0
    end
end
ans << put if put!=0
puts ans.reverse.join(" ")

Measured memory_bytes: 11516
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int[] l = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int r = l[0], c = l[1];
        int[] cans = new int[c + 1];
        string ans = "";

        for (int i = 0; i < r; i++)
        {
            int[] o = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = 0;

            for (int j = 0; j < c; j++)
            {
                cans[j] += o[j];
                ans += o[j] + " ";
                a += o[j];
            }

            cans[c] += a;
            ans += a + "\r\n";
        }
        for (int i = 0; i < c; i++)
        {
            ans += cans[i] + " ";
        }
        ans += cans[c];

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 10000
use whiteread::parse_line;

fn main() {
    let s: String = parse_line().unwrap();
    let mut s: Vec<char> = s.chars().collect();
    s.push('<');
    let mut left = s[0];
    let mut ans: Vec<[usize; 2]> = Vec::new();
    let mut cnt = [0, 0];

    for i in 1..s.len() {
        match (left, s[i]) {
            ('<', '<') => cnt[0] += 1,
            ('<', '>') => {
                cnt[0] += 1;
                left = '>';
            }
            ('>', '>') => cnt[1] += 1,
            ('>', '<') => {
                cnt[1] += 1;
                left = '<';
                ans.push(cnt);
                cnt = [0, 0];
            }
            _ => unreachable!(),
        }
    }
    ans.push(cnt);
    println!(
        "{}",
        ans.iter().fold(0, |x, y| x
            + (0..=y[0].max(y[1])).sum::<usize>()
            + (0..=y[0].min(y[1])).sum::<usize>()
            - y[0].min(y[1]))
    );
}


Measured memory_bytes: 6840
import java.util.*;

public class Main {

    long INF = 1000000001;
    long[][] dp;
    boolean A, B, C;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        char[] s = S.toCharArray();
        char[] t = T.toCharArray();
        dp = new long[S.length() + 1][T.length() + 1];
        for (int i = 0; i < S.length(); i++) {
            for (int j = 0; j < T.length(); j++) {
                if (s[i] == t[j]) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                } else {
                    dp[i + 1][j + 1] = Math.max(dp[i + 1][j], dp[i][j + 1]);
                }
            }
        }

        String ans = "";
        int i = S.length();
        int j = T.length();
        while (i > 0 && j > 0) {
            if (s[i - 1] == t[j - 1]) {
                ans = String.valueOf(s[i - 1]) + ans;
                i--;
                j--;
            } else if (dp[i - 1][j] > dp[i][j - 1]) {
                i--;
            } else {
                j--;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 128828
<?php
$input = trim(fgets(STDIN));
list($a, $b, $c) = sscanf($input, "%d %d %d");
$divisor = 0;

for ($i=$a; $i<=$b; $i++) {
    $surplus = $c % $i;
    if ($surplus == 0) {
        $divisor++;
    }
}
echo $divisor.PHP_EOL;


Measured memory_bytes: 9224
import numpy as np

H,W = map(int,input().split())
temp = np.array([list(input()) for _ in range(H)])
# 周りに壁を、0,1化、壁をTrueで持つ
map = np.ones((H+2,W+2),dtype=np.bool)
map[1:-1,1:-1] = (temp == '#')

# x軸正方向の集計
def F(transpose):
  x = map.copy()
  if transpose:
    x = x.T
  x = np.ravel(x) # to 1D array
  
  zero_idx = np.nonzero(x)[0]
  zero_span = np.diff(zero_idx) - 1 # 次の0までにある1の個数
  y = np.zeros(len(x),dtype=np.int32)
  y[1:][zero_idx[:-1]] = zero_span
  y[zero_idx[1:]] -= zero_span
  y = y.cumsum()
  if transpose:
    y = y.reshape(map.T.shape).T
  else:
    y = y.reshape(map.shape)
  return y

answer = np.zeros(map.shape,dtype=np.int32)
for t in [True,False]:
  answer += F(t)
    
answer = answer.max() - 1
print(answer)

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

int main()
{
    ll n, k, r, s, p, i, sum = 0;
    string t, c;

    cin >> n >> k >> r >> s >> p >> t;

    c = t;

    for(i = 0; i < n; i++){
        if(t[i] == 'r') t[i] = 'p';
        else if(t[i] == 's') t[i] = 'r';
        else t[i] = 's';
    }

    for(i = k; i < n; i++){
        if(t[i] == t[i - k]) t[i] = 'z';
    }

    for(i = 0; i < n; i++){
        
            if(t[i] == 'r') sum += r;
            else if(t[i] == 's') sum += s;
            else if(t[i] == 'p') sum += p;
        
    }

    //cout << t << endl;
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
  int a;
  std::cin >> a;
  if(a==3||a==5||a==7)std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;
}


Measured memory_bytes: 256