akhauriyash/Code-Regression huggingface dataset:
#![allow(unused)]

use std::io::{Read, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

pub fn read_bytes<T: FromIterator<char>>(s: &mut StdinLock) -> T {
    s.bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<T>()
}

pub fn reads(s: &mut StdinLock) -> String {
    read_bytes::<String>(s)
}

pub fn read<T: FromStr>(s: &mut StdinLock) -> T {
    reads(s).parse().ok().unwrap()
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

fn main() {
    let sin = std::io::stdin();
    let mut sin = sin.lock();

    let n: usize = read(&mut sin);
    let m: usize = read(&mut sin);
    let avec: Vec<usize> = (0..n).map(|_| read(&mut sin)).collect();

    let tot = avec.iter().sum();

    if avec.iter().filter(|&a| a * (4 * m) >= tot).count() >= m {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

using namespace std;
string s;
int main() {
  cin >> s;
  int ans = 0;
  for(int i = s.size()-2; i >= 0; i -= 2) {
    string tmp = s.substr(0,i);
    string a = tmp.substr(0,tmp.length() / 2);
    string b = tmp.substr(tmp.length() / 2 , tmp.length());
  
    if(a == b) {
      cout << a.length() * 2 <<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

const int MOD=1e9+7;

const int maxn=1000000+10;

ll fac[maxn*3];
ll Pow(ll x,ll p){
	x%=MOD;ll ret=1;
	for(;p;p>>=1,x=x*x%MOD) if(p&1) ret=ret*x%MOD;
	return ret;
}

ll inv(ll x){return Pow(x,MOD-2);}
ll fix(ll x){return (x%MOD+MOD)%MOD;}

ll C(int n,int m){
	if(n<0||m<0||n<m) return 0;
	return fac[n]*inv(fac[n-m]*fac[m]%MOD)%MOD;	
}

ll S(int r,int c)
{
	if(r<=0||c<=0) return 0;
	ll ret=0;
	rep(i,1,r) 	ret+=C(i+c+1,c)-1;
	return ret%MOD;
}

int main()
{
//	freopen("std.in","r",stdin);
	fac[0]=1; rep(i,1,2001000) fac[i]=fac[i-1]*i%MOD;
	
	int r1,r2,c1,c2;
	cin>>r1>>c1>>r2>>c2;
	cout<<fix(S(r2,c2)-S(r1-1,c2)-S(r2,c1-1)+S(r1-1,c1-1))<<endl;
	return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll inf = (ll)1e9 + 7;
int main()
{
    ll i, j, k, c[3][3], n, d[3][3] = {0};
    for (i = 0; i < 3; i++)
    {
        for (j = 0; j < 3; j++)
        {
            cin >> k;
            c[i][j] = k;
        }
    }
    cin >> n;
    for (ll ii = 0; ii < n; ii++)
    {
        cin >> k;
        for (i = 0; i < 3; i++)
        {
            for (j = 0; j < 3; j++)
            {
                //cin >> k;
                //c[i][j] = k;
                if (c[i][j] == k)
                    d[i][j] = 1;
            }
        }
    }
    ll f = 0;
    for (i = 0; i < 3; i++)
    {
        if (d[i][0] == 1 && d[i][1] == 1 && d[i][2] == 1)
            f = 1;
    }
    for (i = 0; i < 3; i++)
    {
        if (d[0][i] == 1 && d[1][i] == 1 && d[2][i] == 1)
            f = 1;
    }
    if (d[0][0] == 1 && d[1][1] == 1 && d[2][2] == 1)
        f = 1;
    if (d[0][2] == 1 && d[1][1] == 1 && d[2][0] == 1)
        f = 1;
    if (f == 1)
        cout << "Yes";
    else
    {
        cout << "No";
    }

    return 0;
}

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

int n, m;
vector<vector<int>> g;
vector<bool> visited;

int dfs(int i) {
    if(visited[i]) return 0;
    int res = 1;
    visited[i] = true;
    for(auto j : g[i]){
        res += dfs(j);
    }
    return res;
}

int main() {
    cin >> n >> m;
    vector<int> a(m), b(m);
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    int cnt = 0;
    for(int i=0;i<m;i++){
        g.clear();
        g.resize(n);

        // 枝i以外からなるグラフ(隣接リストg)をつくる
        for(int j=0;j<m;j++){
            if(i == j) continue;
            g[a[j]].push_back(b[j]);
            g[b[j]].push_back(a[j]);
        }

        // 連結性判定
        visited.clear();
        visited.resize(n, false);
        if(dfs(0) != n) cnt++;  // 探索
        //for(int i=0;i<n;i++){
            //if(visited[i] == false){
                //cnt++;
                //break;
            //}
        //}
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 1005; 
using namespace std;

int cnt, len; 
char c[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
	scanf("%s", c + 1);
	len = strlen(c + 1); 
	for(int i = 1; i <= len - i + 1; i++)
		if(c[i] != c[len - i + 1]) cnt++;
	printf("%d\n", cnt); 
	return 0; 
}


Measured memory_bytes: 384
/*
  AOJ 1147
  Title:
  @kankichi573
*/
#include <stdio.h>

#define Max(x,y) (((x)>(y))?(x):(y))
#define Min(x,y) (((x)<(y))?(x):(y))
main()
{
  int i,n,p,sum,min_,max_;


  while(scanf("%d",&n) && n)
    {
      sum=0;
      max_=0;min_=1000;
      for(i=0;i<n;i++)
	{
	  scanf("%d\n",&p);
	  sum += p;
	  min_ = Min(min_,p);
	  max_ = Max(max_,p);
	}
      //printf("sum=%d %d %d\n",sum,min_,max_);
      printf("%d\n",(sum-min_-max_)/(n-2));
    }
  return(0);
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

class Parser
{
public:
	string exp;
	int p;
	int expression (void );
	int term (void );
	int factor (void );
private:

};

int Parser::expression (void)
{
	int value = term ();

	while (exp[p] == '+' || exp[p] == '-' ){
		if (exp[p] == '+' ){
			++p; value += term();
		}else{
			++p; value -= term();
		} // end if
	} // end while

	return value;
}

int Parser::term (void)
{
	int value = factor();

	while (exp[p] == '*' || exp[p] == '/' ){
		if (exp[p] == '*'){
			++p; value *= factor();
		}else{
			++p; value /= factor();
		} // end if
	} // end while

	return value;
}

int Parser::factor (void)
{
	int value = 0;

	if (exp[p] == '('){
		++p; value = expression(); ++p;
	}else{
		while (isdigit(exp[p]) ){
			value = value * 10 + exp[p] - '0';
			++p;
		} // end while
	} // end if
	
	return value;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.sc", "r", stdin);

	Parser parser;
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i;
	for (i = 0; i < n; ++i){
		getline (cin, str );
		parser.exp = str;
		parser.p = 0;
		cout << parser.expression() << endl;
	} // end loop
		
	return 0;
}

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int N;
	cin >> N;

	// 条件は j-i = A[i]+A[j] (i<j)
	// 移項 : i+A[i] = j-A[j]
	// それぞれを集計してペアを数える
	map<int,int> small;
	map<int,int> big;

	vi A(N);
	rep(i,N){
		cin >> A[i];
		small[i + A[i]]++;
		big[i - A[i]]++;
	}

	ll ans = 0;
	for(auto& [key, value] : small){
		if(big[key] != 0){
			ans += value * big[key];
		}
	}

	cout << ans << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

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

cin >> a;

if(a=='a'){
	cout << 'b' << endl;
}else if(a=='b'){
	cout << 'c' << endl;
}else if(a=='c'){
	cout << 'd' << endl;
}else if(a=='d'){
	cout << 'e' << endl;
}else if(a=='e'){
	cout << 'f' << endl;
}else if(a=='f'){
	cout << 'g' << endl;
}else if(a=='g'){
	cout << 'h' << endl;
}else if(a=='h'){
	cout << 'i' << endl;
}else if(a=='i'){
	cout << 'j' << endl;
}else if(a=='j'){
	cout << 'k' << endl;
}else if(a=='k'){
	cout << 'l' << endl;
}else if(a=='l'){
	cout << 'm' << endl;
}else if(a=='m'){
	cout << 'n'<< endl;
}else if(a=='n'){
	cout << 'o' << endl;
}else if(a=='o'){
	cout << 'p'<< endl;
}else if(a=='p'){
	cout << 'q' << endl;
}else if(a=='q'){
	cout << 'r' << endl;
}else if(a=='r'){
	cout << 's' << endl;
}else if(a=='s'){
	cout << 't' << endl;
}else if(a=='t'){
	cout << 'u' << endl;
}else if(a=='u'){
	cout << 'v' << endl;
}else if(a=='v'){
	cout << 'w' << endl;
}else if(a=='w'){
	cout << 'x' << endl;
}else if(a=='x'){
	cout << 'y' << endl;
}else if(a=='y'){
	cout << 'z' << endl;
}
   
return 0;
}

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

int main(){
    string s; cin>>s;
    int n = s.size();
    int hug = 0;
    rep(i,n/2){
        if(s.at(i)!=s.at(n-1-i)) hug++;
    }
    cout << hug << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

const int N = 301;
int cap[N][N], flow[N][N], edge[N][N];
int level[N];
bool finished[N];
const int inf = 1<<29;
int n,m;

inline int residue(int s,int t) { return cap[s][t] - flow[s][t]; }

void makeLevel(int s) {
    memset(level, -1, sizeof(level));
    level[s] = 0;
    queue<int> Q; Q.push(s);
    while(!Q.empty()) {
        int here = Q.front(); Q.pop();
        for(int there=0; there<n; ++there) {
            if(level[there] < 0 && residue(here,there) > 0) {
                level[there] = level[here] + 1;
                Q.push(there);
            }
        }
    }
}

int augment(int here,int curf,int t) {
    if(here == t || curf == 0) return curf;
    if(finished[here] != 0) return 0;
    finished[here] = 1;

    for(int there=0; there<n; ++there) {
        if(level[there] > level[here]) {
            int f = augment(there, min(curf, residue(here, there)), t);
            if(f > 0) {
                flow[here][there] += f;
                flow[there][here] -= f;
                finished[here] = false;
                return f;
            }
        }
    }
    return 0;
}

int Dinic(int s,int t) {
    memset(flow, 0, sizeof(flow));
    int ret = 0;
    for(bool cont = true; cont; ) {
        cont = false;
        makeLevel(s);
        memset(finished, 0, sizeof(finished));
        for(int f; (f = augment(s, inf, t)) > 0; cont = true)
            ret += f;
    }
    return ret;
}

int main() {
    int a,b;
    cin>>n>>m;
    memset(cap, 0, sizeof(cap));
    memset(edge, 0, sizeof(edge));
    for(int i=0; i<m; ++i) {
        cin>>a>>b;
        a--,b--;
        cap[a][b] = cap[b][a] = 1;
        edge[a][b] = i+1;
    }

    cin>>a>>b;
    a--,b--;

    cout<<Dinic(a,b)<<endl;

    int ans = 0;
    vector<int> av;
    for(int i=0; i<n; ++i) {
        for(int j=0; j<n; ++j) {
            if(i == j) continue;
            if(flow[i][j] > 0 && edge[j][i] > 0)
                av.push_back(edge[j][i]);
        }
    }

    sort(av.begin(), av.end());
    cout<<av.size()<<endl;
    for(int i=0; i<av.size(); ++i)
        cout<<av[i]<<endl;
}

Measured memory_bytes: 0
import sys
n = int(input())
w = list(map(int, input().split()))
imin = 10000
for i in range(n-1):
    if abs(sum(w[:i+1]) - sum(w[i+1:])) < imin:
        imin = abs(sum(w[:i+1]) - sum(w[i+1:]))
print(imin)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;
ll n, l, a[100100], last;
bool judge = false;
int main(void){
    // Your code here!
    cin >> n >> l;
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 1; i < n; i++){
        if (a[i - 1] + a[i] >= l){
            last = i;
            judge = true;
            break;
        }
    }
    if (judge){
        cout << "Possible" << endl;
        for (ll i = 1; i < last; i++) cout << i << endl;
        for (ll i = n - 1; i >= last; i--) cout << i << endl;
    } else {
        cout << "Impossible" << endl;
    }
}


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

int main() {
	
	int a, b;
	cin >> a >> b;
	
	if (a > b) {
		cout << "a > b" <<endl;
	}
	else if (a < b) {
		cout << "a < b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}

	return 0;
}


Measured memory_bytes: 3100
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

while 1:
    A = [int(i) for i in readline().split()]
    if A[0] == 0 and A[1] == 0:
        break
    else:
        A.sort()
        print(*A)



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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

//拡張ユークリッドの互除法
int extgcd(int a, int b, int& x, int& y) {
    int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

// mod逆元
int mod_inverse(int a, int m) {
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

// 階乗、階乗逆元テーブル
int fact[1100000], fact_inv[1100000];
int mod_fact(int n, int m) {
    fact[0] = fact_inv[0] = 1;
    for (int i = 1; i <= n; i++) {
        fact[i] = fact[i - 1] * i % m;
        fact_inv[i] = mod_inverse(fact[i], m);
    }
}
int N, M;
int mod = 1e9 + 7;
signed main() {
    cin>>N>>M;
    mod_fact(110000, mod);
    int ans=1;
    while (M != 1) {
        for (int i = 2; i <= sqrt(M); i++) {
            if (M % i == 0) {
                int cnt = 0;
                while (M % i == 0) {
                    cerr<<2<<endl;
                    M /= i;
                    cnt++;
                }
                    cerr<<cnt<<endl;
                (ans *= fact[N + cnt - 1] * fact_inv[cnt] % mod * fact_inv[N - 1] % mod) %= mod;
                cerr<<4<<endl;
                goto nene;
            }
        }
        (ans *= N) %= mod;
        break;
        nene:;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()

const int Mod = 1e9 + 7;
const int inf = 1e18;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> a (N , vector<int>(3));
  for(int i = 0; i < N; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  } 
  auto cal = [&](vector<int> &data) {
    int ans = 0;
    for(int i = 0; i < M; i++) {
      ans += data[i];
    }
    return ans;
  };
  int ans = 0;
  for(int mask = 0; mask < 8; mask++) {
    vector<int> tmp;
     for(int i = 0; i < N; i++) {
       int sum = 0;
       for(int j = 0;j < 3; j++) {
         if(mask & (1 << j)) {
           sum += a[i][j];
         }else sum -= a[i][j];
       }
       tmp.push_back(sum);
       sort(tmp.rbegin() , tmp.rend());
     }
     ans = max(ans , cal(tmp));
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3720
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 200010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-9
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m, cnt, ans;
ll a[SIZE];

ll sol(ll n, ll m) {
	cnt = 0;
	while (n) {
		cnt++;
		n /= m;
	}
	return cnt;
}

int main() {
	io(); cin >> n >> m;
	cout << sol(n, m);
}

Measured memory_bytes: 256
#include "stdio.h"
#include <stdlib.h>
 
int main (){
  int N;
  int a, b, c;
  scanf("%d",&N);
  int array[N+1];
  bool issorted = true;
  for (int i=1; i<=N; i++){
    scanf("%d",&array[i]);
  }
  for (int i=2; i<=N; i++){
    if (array[i]<array[i-1]){
      issorted = false;
    }
  }
  if (issorted){
    printf("YES\n");
    return 0;
  }
  
  int index1=-1;
  int index2=-1;
  for (int i=2; i<=N; i++){
    if (array[i-1]>array[i]){
      index1=i-1;
      //      printf("index1=%d\n",index1);
      break;
    }
  }
  for (int i=N; i>index1; i--){
    if (array[i-1]>array[i]){
      index2=i;
      //      printf("index2=%d\n",index2);
      break;
    }
  }
  if (index2==-1){
    printf("NO\n");
  }

  int temp = array[index1];
  array[index1]= array[index2];
  array[index2]= temp;

  for (int i=1; i<=N; i++){
    //    printf("array[%d]=%d\n",i,array[i]);
  }

  issorted = true;
  for (int i=2; i<=N; i++){
    if (array[i]<array[i-1]){
      issorted = false;
    }
  }
  if (issorted){
    printf("YES\n");
  } else {
    printf("NO\n");
    return 0;
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll n,l;
ll x[200003];
int main() {
	cin>>l>>n;
	rep(i,1,n+1){
		cin>>x[i];
	}
	x[n+1]=l;
	ll ans=0,v=0,b=n-1;

	for(int i=1;b>0;b-=2){
		v+=(x[i]-x[i-1])*b;
		++i;
	}
	b=n;
	for(int i=n;b>0;b-=2){
		v+=(x[i+1]-x[i])*b;
		--i;
	}
	ans=v;
	int left=n/2,right=n/2+1;
	if(n%2==1)++left;
	rep(i,0,n){
		v+=(x[left]-x[i]);
		v-=x[i];
		v-=l-x[right];
		ans=max(ans,v);
		if(left!=right)++left;
		else ++right;
//		cout<<v<<endl;
	}
	v=0;
	b=n;
	for(int i=1;b>0;b-=2){
		v+=(x[i]-x[i-1])*b;
		++i;
	}
	b=n-1;
	for(int i=n;b>0;b-=2){
		v+=(x[i+1]-x[i])*b;
		--i;
	}
	ans=max(ans,v);
	left=n/2,right=n/2+1;
	if(n%2==1)++left;
	rrep(i,n+1,1){
		v-=(l-x[i]);
		v+=x[i]-x[right];
		v-=x[left];
		ans=max(ans,v);
		if(left==right)--left;
		else --right;
//		cout<<v<<endl;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node{
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};
typedef struct node * Node;
#define NIL NULL
Node root = NIL;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)
    return u;
  if(k<u->key)
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y = x->parent;
  if(x->right != NIL)
    {
      return treeMinimum(x->right);
    }
  while( y != NIL && x == y->right)
    {
      x = y;
      y = y->parent;
    }
return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL)
    {
      y = z;
    }
  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    {
      x = y->left;
    }
  else
    x = y->right;

  if(x != NIL)
    {
      x->parent = y->parent;
    }
  if(y->parent == NIL)
    {
      root = x;
    }
  else if(y == y->parent->left)
    {
      y->parent->left = x;
    }
  else
    y->parent->right = x;

  if(y != z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  z->parent = NIL;
  while(x != NIL)
    {
      y = x;
      if(z->key < x->key)
	{
	  x = x->left;
	}
      else
	x = x->right;

      z->parent = y;
    }
  if(y == NIL)
    {
      root = z;
    }
  else if(z->key < y->key)
    {
      y->left = z;
    }
  else
    y->right = z;
    
}

void inorder(Node u){
  if(u == NIL) return;
 inorder(u->left);
 printf(" %d",u->key);
 inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  
  return 0;
}




Measured memory_bytes: 25296
<?php
$filter = function($i){
    if($i%3==0) return true;
    for(;$i>0;$i/=10) {
        if($i%10==3) return true;
    }
    return false;
};

$n = (int)trim(fgets(STDIN));
echo(" " . implode(" ", array_filter(range(1, $n), $filter)) . "\n");



Measured memory_bytes: 11232
n,a,b = gets.split.map(&:to_i)
s = gets.chomp

s.each_char do |c|
    case c
    when "a"
        if a + b > 0
            a -= 1
            puts "Yes"
        else
            puts "No"
        end
    when "b"
        if a + b > 0 && b > 0
            b -= 1
            puts "Yes"
        else
            puts "No"
        end
    else puts "No"
    end
end

Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int N;
    string str;
    cin >> N >> str;
    ll count = 0;
    for(int i = 0; i < 1000; i++){//000~999までを作れるかどうかを調べる
        string ans = "abc";
        if(i < 10){
            ans[0] = '0';
            ans[1] = '0';
            ans[2] = i + 48;
        }else if(i < 100){
            ans[0] = '0';
            ans[1] = (i / 10) + 48;
            ans[2] = (i % 10) + 48;
        }else ans = to_string(i);
        bool flag1 = false;
        bool flag2 = false;
        bool flag3 = false;
        for(int j = 0; j < N; j++){
            if(str.at(j) == ans[0] && flag1 == false) flag1 = true;
            else if(str.at(j) == ans[1] && flag1 == true && flag2 == false) flag2 = true;
            else if(str.at(j) == ans[2] && flag1 == true && flag2 == true && flag3 == false){
                flag3 = true;
            }
        }
        if(flag3 == true) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
function Main (input) {
  input = input.split("\n")[0].split(" ").map(Number);
  var X = input[0];
  var Y = input[1];
  var Z = input[2];
  var now = 0;
  var loop = true;
  var ans = 0;
  while (loop) {
    now += Z;
    now += Y;
    ans++;
    if (now + Z > X) {
      break;
    }
  }
  console.log(ans-1);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n; cin >> n;
	for(int i = 0; i < 100 ; i++){
		for(int j = 0; j < 100; j++){
			if(i * 4 +  j * 7 == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;	               
	return 0;	
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n, h, w;
	cin >> n >> h >> w;
	int* height = new int[n];
	int* width = new int[n];

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

	int cnt = 0;

    for (int i = 0; i < n; ++i)
    {
    	if(height[i]>=h && width[i]>=w) cnt++;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;
const ll SEG_L=1<<18;
vector<ll> segtree(2*SEG_L);


ll get(ll i){
    i+=SEG_L;
    ll res=0;
    while(i>0){
        res+=segtree[i];
        i/=2;
    }
    return res;
}


void add(ll l, ll r, ll v){
    l+=SEG_L;
    r+=SEG_L;
    while(r-l>0){
        if(l%2==1){
            segtree[l]+=v;
            l++;
        }
        if(r%2==1){
            segtree[r-1]+=v;
            r--;
        }
        l/=2;
        r/=2;
    }
}


int main(){
    ll n,d,a;
    cin>>n>>d>>a;
    vector<P> p(n);
    for(ll i=0;i<n;i++){
        cin>>p[i].first>>p[i].second;
    }
    sort(p.begin(),p.end());
    vector<ll> x(n),h(n);
    for(ll i=0;i<n;i++){
        x[i]=p[i].first;
        h[i]=p[i].second;
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        //cout<<get(i)<<endl;
        ll num=(h[i]-get(i)+a-1)/a;
        num=max(num,0ll);
        if(num==0) continue;
        ans+=num;
        ll nex=upper_bound(x.begin(),x.end(),x[i]+2*d)-x.begin();
        nex--;
        //cout<<i<<" "<<nex<<endl;
        add(i,nex+1,num*a);

    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 13180
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N, ans = 0, c = 1;
    in >> N;
    vector<string> s;
    s.resize(N);
    REP(i, N){
        in >> s[i];
        SORT(s[i]);
    }
    SORT(s);

    REP(i, N){
        if(i<(N-1) && s[i]==s[i+1]){
            c++;
        }else{
            if (c > 1) {
                ans += (c * (c - 1)) / 2;
            }
            c = 1;
        }
    }
    out << ans << endl;
}

Measured memory_bytes: 5760
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s;

int main(){
	cin>>s;
	if(s.back()=='s') s+="es";
	else s+='s';
	cout<<s<<endl;
}

Measured memory_bytes: 3640
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

asum = a.inject(:+)
bsum = b.inject(:+)

if asum<bsum
  #むりくぼ
  p -1
  exit
end

dif = asum-bsum
w = []
n.times{|i|
  if a[i]>=b[i]
    w << a[i]-b[i]
  end
}

w.sort!
w.each{|t|
  dif-=t
  n-=1 if dif>=0
}

p n

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

int check(char a,char b){
  if(a == b) return 1;
  return 0;
}

int main(void){
  string str;
  int cnt = 0;

  while(cin >> str){
    int flg = 0;
    
    for(int i = 0 ; i < str.size()/2 ; i++){
      if(!check(str[i],str[str.size()-i-1])){
        flg = 1;
        break;
      }
    }

  if(flg == 0) cnt++;
  }

  cout << cnt << endl; 

  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[5];
int main()
{
    scanf ("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    if (a[0]==a[1]&&a[1]==5&&a[2]==7) printf ("YES\n");
    else printf ("NO\n");
    return 0;
}




Measured memory_bytes: 256
import std.stdio;

void main() {
	int x, n;
	readf("%s %s", &x, &n);
	auto forbiddenList = new bool[101];

	foreach (i;0..n) {
		int a;
		readf(" %s", &a);
		assert(a < forbiddenList.length);
		forbiddenList[a] = true;
	}

	bool isForbidden(int a) {
		if (a >= 0 && a < forbiddenList.length) {
			return forbiddenList[a];
		}
		return false;
	}

	for (int i = 0;i < forbiddenList.length;++i) {
		if (!isForbidden(x - i)) {
			writeln(x - i);
			return;
		}
		if (!isForbidden(x + i)) {
			writeln(x + i);
			return;
		}
	}

	assert(false);
}


Measured memory_bytes: 2832
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	int n = 0, w = 0, s = 0, e = 0;
	for (int i = 0; i < x.length(); i++)
	{
		string c = x.substr(i, 1);
		if (c == "N")
		{
			n++;
		}
		else if (c == "S")
		{
			s++;
		}
		else if (c == "E")
		{
			e++;
		}
		else
		{
			w++;
		}
	}

	string ans = "No";

	if (n > 0 && s > 0)
	{
		if ((w == 0 && e > 0) || (w > 0 && e == 0))
		{
			ans = "No";
		}
		else
		{
			ans = "Yes";
		}
	}
	if (w > 0 && e > 0)
	{
		if ((n == 0 && s > 0) || (n > 0 && s == 0))
		{
			ans = "No";
		}
		else
		{
			ans = "Yes";
		}
	}

	cout << ans << endl;
}


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

int top=0, S[1000];

void push (int x) {
    S[++top] = x;
}

int pop () {
    top--;
    return S[top + 1];
}

int main(){
    int a, b;
    char s[100];
    
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            b = pop();
            a = pop();
            push(a + b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if (s[0] == '*') { 
            b = pop();
            a = pop();
            push(a * b);
        // } else if (s[0] == '0') {  
        //     break;
        } else {
            push(atoi(s));
        }
        // cout << s << " " << top << " " << S[top] << endl;
    }
    printf("%d\n", pop());
    return 0;
} 


Measured memory_bytes: 3196
#include <stdio.h>
int main() {
  int a, b, n;
  scanf("%d", &n);
  for (a = 1; a <= 9; a++) {
    for (b = 1; b <= 9; b++) {
      if (a*b == n) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(i,0,len) cout << a[i] << " ";

int main(){
  ll n, h, last=0;
  cin >> n;
  rep(i, 0, n){
    cin >> h;
    if (h > last){
      last = h-1;
    }else if (h == last){
      last = h;
    }else{
      print("No");
      exit(0);
    }
  }
  print("Yes");
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var ret1 = abcd[0] * abcd[2];
            var ret2 = abcd[0] * abcd[3];
            var ret3 = abcd[1] * abcd[2];
            var ret4 = abcd[1] * abcd[3];
            Console.WriteLine(Math.Max(Math.Max(Math.Max(ret1,ret2),ret3),ret4));
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  
  bool good =false;
  for(int i=1; i<=9; i++){
    for(int j=1; j<=9; j++){
      if(n == i*j )
        good =true;
    }
  }
  
  if(good) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int X, Y; cin >> X >> Y;
	bool ans = false;
	rep(i, 0, X + 1) {
		int x = 2 * i, y = 4 * (X - i);
		if (x + y == Y)ans = true;
	}
	cout << (ans ? "Yes" : "No") << "\n";

	return 0;
}

Measured memory_bytes: 3688
//#include "SaveFuncs.cpp"

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
string strMulti(string t, int n) { string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }

/*****/

int Main()
{
	int N;
	cin >> N;
	vector<ll> A(N + 1), B(N);
	rep(i, N + 1)	cin >> A.at(i);
	rep(i, N)		cin >> B.at(i);

	ll ret = 0;
	for (int i = N - 1; i >= 0; i--)
	{
		//debug_cout(ret);

		if (A.at(i + 1) >= B.at(i))
		{
			ret += B.at(i);
			//A.at(i + 1) -= B.at(i);
		}
		else
		{
			ret += A.at(i + 1);
			B.at(i) -= A.at(i + 1);
			//A.at(i + 1) = 0;

			if (A.at(i) >= B.at(i))
			{
				ret += B.at(i);
				A.at(i) -= B.at(i);
			}
			else
			{
				ret += A.at(i);
				//B.at(i) -= A.at(i);
				A.at(i) = 0;
			}
		}
	}

	cout << ret << endl;

	return 0;
}

/*****/

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

	Main();

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int H,W,N;
    cin >> H >> W >> N;
    int r,c;
    cin >> r >> c;
    string S,T;
    cin >> S >> T;
    int x = r;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'U') {
            x--;
        }
        if(x == 0) {
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'D') {
            if(x < H) {
                x++;
            }
        }
    }
    x = r;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'D') {
            x++;
        }
        if(x > H) {
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'U') {
            if(x-1) {
                x--;
            }
        }
    }
    int y = c;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'L') {
            y--;
        }
        if(y == 0) {
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'R') {
            if(y < W) {
                y++;
            }
        }
    }
    y = c;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'R') {
            y++;
        }
        if(y > W) {
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'L') {
            if(y-1){
                y--;
            }
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 3896
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main(){
  int n;
  cin >> n;
  vector<int> a;
  for(int i = 0;i < n;i++)
  {
    int A;
    cin >> A;
    if(A%2 == 0)
      a.push_back(A);
  }
  for(int i = 0;i < a.size();i++)
  {
    if(a[i]%3 != 0 && a[i]%5 != 0)
    {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}


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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;
	vector<double> v(n);

	rep(i, n) {
		cin >> v.at(i);
	}

	rep(i, n-1) {
		sort(v.begin(), v.end(), greater<double>());
		v.at(n-i-2) += v.at(n-i-1);
		v.at(n-i-2) /= 2.0;
		v.pop_back();
	}

	cout << setprecision(10) << v.at(0) << endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X = int(input())
if 599 >= X:
    ans = 8
elif 600 <= X <= 799:
    ans = 7
elif 800 <= X <= 999:
    ans = 6
elif 1000 <= X <= 1199:
    ans = 5
elif 1200 <= X <= 1399:
    ans = 4
elif 1400 <= X <= 1599:
    ans = 3
elif 1600 <= X <= 1799:
    ans = 2
else:
    ans = 1
print(str(ans))

Measured memory_bytes: 10924
#include<stdio.h>
int main(void)
{
	int i=1,x=1;
	while(x!=0)
	{
		scanf("%d",&x);
		if(x!=0)
		{
		printf("Case %d: %d\n",i,x);
		}
		i++;
	}
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
//static const int INF = (1 << 21);
typedef long long ll;
int main(void){
    // Your code here!
    vector<int> R(5);
    vector<int> r(5);
    int ans = 0;
    for(int i = 0; i < 5; i++){
        cin >> R.at(i);
        r.at(i) = R.at(i) % 10;
        r.at(i) = 10 - r.at(i);
        if(r.at(i) == 10)r.at(i) = 0;
        ans += R.at(i);
        //cout << r.at(i);
    }
    sort(r.begin(),r.end());
    for(int i = 0; i < 4; i++){
        ans += r.at(i);
    }
    cout << ans << endl;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N, T;
  std::cin >> N >> T;

  std::vector<std::pair<int, int>> AB(N);
  rep(i, N) {
    int a, b;
    std::cin >> a >> b;
    AB[i] = std::make_pair(a, b);
  }
  std::sort(AB.begin(), AB.end());
  std::vector<int> A(N), B(N);
  for(int i = 0; i < N; ++i) {
    auto p = AB[i];
    A[i] = p.first;
    B[i] = p.second;
  }

  std::vector<std::vector<int>> dp(N + 1, std::vector<int>(T));
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < T; ++j) {
      if(j > 0) {
        dp[i + 1][j] = std::max(dp[i + 1][j - 1], dp[i][j]);
      }
      if(j - A[i] >= 0) {
        dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j - A[i]] + B[i]);
      }
    }
  }

  int ans = dp[N][T - 1];
  for(int i = 0; i < N; ++i) {
    ans = std::max(ans, dp[i][T - 1] + B[i]);
  }
  std::cout << ans << '\n';

}


Measured memory_bytes: 35584
#coding:utf-8
import re

if __name__ == "__main__":
    patterns = ["dream", "dreamer", "erase" ,"eraser"]
    S = input()

    while True:
        flag = False
        if S[-5:] == "dream":
            S = S[:-5]
            flag = True
        if S[-7:] == "dreamer":
            S = S[:-7]
            flag = True
        if S[-5:] == "erase":
            S = S[:-5]
            flag = True
        if S[-6:] == "eraser":
            S = S[:-6]
            flag = True

        if flag == False:
            print("NO")
            break

        if S == "":
            print("YES")
            break

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int rem(long long n, long long m) {
	if (n >= (n / m) * m) {
		return n / m;
	}
	else {
		return n / m + 1;
	}
}

int main()
{
	long long n, m;
	cin >> n;
	m = n;
	vector<int> v;
	long long sum = 0;
	long long i = 1;
	if (n == 0) {
		v.push_back(0);
	}
	while (m != 0) {
		if (m % 2 != 0) {
			v.push_back(1);
			sum += i;
		}
		else {
			v.push_back(0);
		}
		i *= (-2);
		m = rem(m, -2);
	}
	int l = v.size();
	for (int i = l - 1; i >= 0; i--) {
		cout << v[i];
	}
	cout << endl;
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

//bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


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

    vector<vector<int>> characters(n, vector<int>(26, 0));
    rep(i, n) {
        string s;
        cin >> s;
        for (char c : s) {
            characters[i][c - 'a']++;
        }
    }

    vector<int> min_characters(26, INT_MAX);
    rep(i, n) rep(j, 26) {
            cmin(min_characters[j], characters[i][j]);
        }

    rep(i, 26) rep(j, min_characters[i]) cout << (char) (i + 'a');
    cout << endl;

}



Measured memory_bytes: 256