akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>

using namespace std;

#define ll long long

int main() {
	string c[5] = { "dream","dreamer","erase","eraser" };
	string s;
	cin >> s;

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

	bool can = true;
	for (int i = 0; i < s.size();) {
		bool flag = false;
		for (int j = 0; j < 4; j++) {
			string  hoge = c[j];
			if (s.substr(i, hoge.size()) == hoge) {
				flag = true;
				i += hoge.size();
			}
		}
		if (!flag) {
			can = false;
			break;
		}
	}
	if (can)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  int A, B, C;
  cin >> A >> B >> C;
  if(C >= A && C <= B){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int x[5];
  for(int i=0;i<5;i++){
    scanf("%d", &x[i]);
  }

  for(int i=0;i<5;i++){
    if(x[i]==0) printf("%d\n", i+1);
  }

  return 0;
}


Measured memory_bytes: 1692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,x;
  cin >> N;
  x = 0;
  
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >>r;
    x += 1 + r - l;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    ll dist = abs(a - b);
    ll vel = v - w;
    if (vel * t >= dist)
    {
        cout << "YES"
             << "\n";
    }
    else
        cout << "NO"
             << "\n";
    return 0;
}

Measured memory_bytes: 3648
// https://atcoder.jp/contests/abc125/tasks/abc125_c

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0, maxv = 0;
    cin >> n;
    vector<int> a(n), r(n), l(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    //最大公約数を求める
    ans = a[0];
    l[0] = ans;
    for (int i = 1; i < n; i++) {
        ans = gcd(ans, a[i]);
        l[i] = ans;
    }
    ans = a[n - 1];
    r[0] = ans;
    for (int i = 1; i < n; i++) {
        ans = gcd(ans, a[n - i - 1]);
        r[i] = ans;
    }

    // i番目を抜きにした最大公約数
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            maxv = max(maxv, r[n - 2]);
        } else if (i == n - 1) {
            maxv = max(maxv, l[n - 2]);
        } else {
            // int d1 = l[i - 1], d2 = r[n - 2 - i];
            maxv = max(maxv, gcd(l[i - 1], r[n - 2 - i]));
        }
    }

    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 1408
#import sys
#input = sys.stdin.readline
def main():
    X, N = map( int, input().split())
    if N == 0:
        print(X)
        return
    Q = list( map( int, input().split()))
    # P.sort()
    Z = [True]*102
    for q in Q:
        Z[q] = False
    P = []
    for i in range(102):
        if Z[i]:
            P.append(i)
    # print(P)
    now = P[0]
    ab = abs(X-P[0])
    for p in P:
        pab = abs(X-p)
        if pab == ab:
            if p < now:
                now = p
        elif pab < ab:
            now = p
            ab = pab
    print(now)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9216
// nb_9960
#include <bits/stdc++.h> 
using namespace std; 
#define fi(i,a,n) for (ll i=a; i < n; i++) 
#define ll long long
#define pb push_back 
#define mp make_pair 
#define F first 
#define S second 
#define all(x) x.begin(), x.end() 
#define clr(x) memset(x, 0, sizeof(x)) 
#define sortall(x) sort(all(x)) 
typedef pair<ll, ll> pl; 
typedef vector<ll> vl; 
typedef vector<pl> vpii; 
#define sz(a) int((a).size())
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())

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

  ll t = 1; 
  // cin >> t;

  while (t--) { 
    ll a,b;
    char c;
    cin>>a>>c>>b;
    if(c=='+')
    cout<<a+b<<endl;
    else cout<<a-b<<endl;
  } 
  return 0; 
} 


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

using ll = long long;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

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

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 h,w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h)cin >> s[i];
    vector<vector<int32>> cnt(h, vector<int32>(w,INF));
    if(s[0][0] == '.'){
        cnt[0][0] = 0;
    }else{
        cnt[0][0] = 1;
    }
    REP(i,h)REP(j,w){
        if(i == 0 && j == 0)continue;
        if(i == 0){
            cnt[i][j] = cnt[i][j-1];
            if(s[i][j] != s[i][j-1])cnt[i][j]++;
        }else if(j == 0){
            cnt[i][j] = cnt[i-1][j];
            if(s[i][j] != s[i-1][j])cnt[i][j]++;
        }else{
            cnt[i][j] = min(cnt[i-1][j] + ((s[i][j] != s[i-1][j])?1:0), cnt[i][j-1] + ((s[i][j] != s[i][j-1])?1:0));
        }
    }
    if(s[0][0] == '.' && s[h-1][w-1] == '.'){
        ANS(cnt[h-1][w-1] / 2);
    }else if(s[0][0] == '#' && s[h-1][w-1] == '#'){
        ANS(cnt[h-1][w-1] / 2 + 1);
    }else{
        ANS((cnt[h-1][w-1] + 1) / 2);
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n)
          cin >>
      a[i];
  int ans = 0;
  rep(i, n)
  {
    if ((i+1) % 2 == 1 && a[i] % 2 == 1)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define reps(i, x) for(int i = 1; i <= (int)(x); i++)
#define UNIQUE(v) v..erase( unique(v.begin(), v.end()), v.end() );
#define Size(x) ((int)(x).size())
using namespace std;

const int N = 1000000;
int for_erat[N];
vector<int> prime;
void erat(){
    for(int i = 0; i < N; i++){
        for_erat[i] = 1;
    }
    for(int i = 2; i < sqrt(N); i++){
        if(for_erat[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                for_erat[i *(j + 2)] = 0;
            }
        }
    }

    for(int i = 2; i < N; i++){
        if(for_erat[i]){
            prime.push_back(i);
        }
    }
}

int main(){
	erat();
	int n;
	while(cin >> n){
		int cnt = 0;
		rep(i, Size(prime)){
			if(prime[i] <= n) cnt++;
			else break;
		}
		cout << cnt << endl;
	}
	return 0;
}



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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,D;
    string S;
    cin >> N>>D;
    vector<ll> x(N),y(N);

    REP(i,N){
        cin >> x.at(i) >> y.at(i);
    }

    vector<double> z(N);
    ll ans = 0;
    REP(i, N)
    {
        ll tmp = x[i] * x[i] + y[i] * y[i];
        z.at(i) = sqrt((double)tmp);
        if(D>=z.at(i)){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7952
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N;
  cin >> N;
  map<string, i64> mp;
  i64 MAX = 0;
  rep(i,0,N) {
    string s;
    cin >> s;
    mp[s]++;
    MAX = std::max(MAX, mp[s]);
  }
  for(auto p: mp) {
    if(p.second == MAX) {
      cout << p.first << "\n";
    }
  }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int H = nextInt();
  int W = nextInt();
  swap(H, W);
  int N = nextInt();

  map<int, set<int>> obj;
  REP(i, N) {
    int x = nextInt();
    int y = nextInt();
    obj[y].insert(x);
  }

  int x = 1;
  int y = 1;
  int ans = W;
  int cur = 0;
  for (bool change=true; change; ) {
    change=false;
    if (x + 1 <= W && obj[y].count(x) == 0) {
      cur++;
      x++;
      change = true;
    } else {
      cur++;
      chmin(ans, cur);
      break;
    }
    auto it = obj[y].lower_bound(x);
    int val = (W+1) - x;
    if (it != obj[y].end()) {
      val = (*it) - x;
    }
    // cout << "(" << x << "," << y << ") " << cur << " + " << val << endl;

    chmin(ans, cur + val);

    if (y + 1 <= H && obj[y+1].count(x) == 0) {
      y++;
      change = true;
    }
  }

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

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 27136
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

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

    cout << max({A + B, A - B, A * B}) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int ans = 0;
void dfs(int start, int v_cnt);     // 再帰関数
bool used[10];              // 訪問したかどうか
int adjacency[50][50];      // 隣接行列

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < M; i++){
        adjacency[a[i]][b[i]] = 1;
        adjacency[b[i]][a[i]] = 1;
    }
    
    used[1] = true;
    dfs(1, N);
    
    cout << ans << endl;
}

void dfs(int start, int v_cnt){
    bool flag = true;
    for(int i = 1; i <= v_cnt; i++){
        if(!used[i]){
            flag = false;
            break;
        }
    }
    if(flag){
        ans++;
        return;
    }
    
    for(int i = 1; i <= v_cnt; i++){
        if(!used[i] && adjacency[start][i] != 0){
            used[i] = true;
            dfs(i, v_cnt);
            used[i] = false;
        }
    }
    
    return;
}



Measured memory_bytes: 256
require "date"
x,y=gets.split.map(&:to_i)
xdate=Date.new(2020,x%12+1,1)
ydate=Date.new(2020,y%12+1,1)
if (xdate-1).day==(ydate-1).day
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 2040
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long
const int INF=1e9+7;
int n,m,c,sz;
int fa[100005],rk[100005],id[100005],dis[2000005];
bool used[100005];
vector<int> g[2000005];
vector<pair<int,int> > ve[2000005];
int getF(int x){return ((x==fa[x])?x:(fa[x]=getF(fa[x])));}
void combine(int a,int b){
	a=getF(a);
	b=getF(b);
	if(rk[a]<rk[b]){
		fa[a]=b;
	}
	else if(rk[a]>rk[b]){
		fa[b]=a;
	}
	else{
		fa[a]=b;
		rk[b]++;
	}
	return;
}
inline string change(string s){
	string s1="";
	for(int i=0;i<s.size();i++){
		if(s[i]>='A'&&s[i]<='Z'){
			s[i]=s[i]-'A'+'Z';
		}
		s1+=s[i];
	}
	return s1;
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		ve[w].push_back(make_pair(u,v));
		c=max(c,w);
	}
	sz=n;
	for(int i=1;i<=c;i++){
		for(int j=0;j<ve[i].size();j++){
			int u=ve[i][j].first;
			int v=ve[i][j].second;
			id[u]=id[v]=-1;
			used[u]=used[v]=0;
			rk[u]=rk[v]=1;
			fa[u]=u;fa[v]=v;
		}
		for(int j=0;j<ve[i].size();j++){
			int u=ve[i][j].first;
			int v=ve[i][j].second;
			combine(u,v);
		}
		for(int j=0;j<ve[i].size();j++){
			int u=ve[i][j].first;
			int v=ve[i][j].second;
			if(used[u]==0){
				used[u]=1;
				int fu=getF(u);
				if(id[fu]==-1) id[fu]=++sz;
				g[u].push_back(id[fu]);
				g[id[fu]].push_back(u);
			}
			if(used[v]==0){
				used[v]=1;
				int fv=getF(v);
				if(id[fv]==-1) id[fv]=++sz;
				g[v].push_back(id[fv]);
				g[id[fv]].push_back(v);
			}
		}
	}
	queue<int> q;
	q.push(1);
	memset(dis,-1,sizeof(dis));
	dis[1]=0;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int i=0;i<g[u].size();i++){
			int v=g[u][i];
			if(dis[v]==-1){
				dis[v]=dis[u]+1;
				q.push(v);
			}
		}
	}
	if(dis[n]==-1){
		cout<<"-1";
		return 0;
	}
	else{
		cout<<dis[n]/2;
		return 0;
	}
	return 0;
} 

Measured memory_bytes: 119040
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(3e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    set<int> s;
    while (n % 2 == 0)  
    {  
    	s.in(2);
        // cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
        	s.in(i);
            // cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
    	s.in(n);
        // cout << n << " ";  
    return (int)s.size();
} 

  

void solve(){
		
	int a,b;
	cin >> a >> b;
	int g = __gcd(a,b);
	// for(int i = 1;i<=g;i++){
	// 	if(g%i==0){
	// 		cout << i << " ";
	// 	}
	// }
	// cout << endl;
	cout << primeFactors(g) + 1 << endl;
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 3612
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1], x = tmp[2];
    writeln(a <= x && x <= a + b ? "YES" : "NO");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

using namespace std;

struct Node {
    int key;
    Node *left, *right;
};
Node *root, *NIL;

void insert(int k) {
    if(root == NIL) {
        root = (Node *)malloc(sizeof(Node));
        root->key = k;
        root->left = root->right = NIL;
    }else {
        Node *z = (Node *)malloc(sizeof(Node));
        z->key = k;
        z->left = z->right = NIL;

        Node *x = root;
        while(true) {
            if(k < x->key) {
                if(x->left == NIL) {
                    x->left = z;
                    break;
                }
                else x = x->left;
            }else {
                if(x->right == NIL) {
                    x->right = z;
                    break;
                }
                else x = x->right;
            }
        }
    }
}

Node * find(Node *node, int k) {
    Node *x = node;
    while(x != NIL && k != x->key) {
        if(k < x->key) x = x->left;
        else x = x->right;
    }
    return x;
}

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

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

int main()
{
    int n, x;
    char str[19];
    scanf("%d", &n);

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

    return 0;
}

Measured memory_bytes: 15632
def solve(N, K, Q, A):
    wincount = [0] * (N + 1)
    win = ['Yes'] * (N + 1)
    for i in range(Q):
        wincount[A[i]] += 1
    for i in range(1, N + 1):
        win[i] = (Q - K) < wincount[i]
    return win[1:]


def main():
    N, K, Q = map(int, input().strip().split())
    A = [0] * Q
    for i in range(Q):
        A[i] = int(input().strip())
    result = solve(N, K, Q, A)
    for r in result:
        print('Yes' if r else 'No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 58072
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
const int mod = 1000000007;

int main(){
	char s[30];
	cin>>s;
	for (int i = 0;i < 19; ++i){
		if (i == 5 || i == 13) printf(" ");
		else printf("%c",s[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val s = scanner.next()

    val ret = s.mapIndexed { index, c ->
        (index % 2 == 1 && c == 'R') || (index % 2 == 0 && c == 'L')
    }.firstOrNull { it } ?: false

    println(if (ret) "No" else "Yes")
}

Measured memory_bytes: 31260
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0278();
	}
	
	class AOJ0278{
		
		void doIt(){
			int x = in.nextInt(),y = in.nextInt(),a = in.nextInt(),b = in.nextInt();
			int result = Integer.MAX_VALUE;
			if(a>=5&&b>=2)result = (int)((x*a+y*b)*0.8);
			else if(a>=5)result = Math.min((int)((x*a+y*2)*0.8), x*a+y*b);
			else if(b>=2)result = Math.min((int)((x*5+y*b)*0.8), x*a+y*b);
			else result = Math.min((int)((x*5+y*2)*0.8), x*a+y*b);
			System.out.println(result);
		}
		
		public AOJ0278() {
			int n = in.nextInt();
			for(int i=0;i<n;i++)doIt();
		}
	}
	
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.length(); i++){
        char  c = s.at(i);
        c += n;
        if((int)c >= 91){
            c -= 26;
        }
        cout << c;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
int p[210000];
int q[210000];
long long inv[11000];
long long fact[11000];
long long factinv[11000];
int M=10000;
inline long long C(int a,int b){
	return fact[a]*factinv[b]%mod*factinv[a-b]%mod;
}
//int T[2100][2100];
//int Y[2100][2100];
long long d2=500000004;
int dp[4100][4100];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d",p+i,q+i);
	}
	long long ret=0;
	inv[1]=fact[0]=factinv[0]=1;
	for(int i=1;i<M;i++)fact[i]=fact[i-1]*i%mod;
	for(int i=2;i<M;i++)inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	for(int i=1;i<M;i++)factinv[i]=factinv[i-1]*inv[i]%mod;
	
/*	for(int i=0;i<a;i++){
		T[p[i]][0]++;
		T[p[i]][q[i]]--;
		Y[q[i]][0]++;
		Y[q[i]][p[i]]--;
	}
	for(int i=0;i<2100;i++){
		for(int j=1;j<2100;j++){
			T[i][j]+=T[i][j-1];
			Y[i][j]+=Y[i][j-1];
		}
	}*/
	int D=2050;
	for(int i=0;i<a;i++){
		dp[D+p[i]][D+q[i]]++;
	}
	for(int i=D+2010;i>=0;i--){
		for(int j=D+2010;j>=0;j--){
			if(dp[i][j]>=mod)dp[i][j]-=mod;
			if(i)dp[i-1][j]+=dp[i][j];
			if(j)dp[i][j-1]+=dp[i][j];
		}
	}
	for(int i=0;i<a;i++){
		//printf("%d: %lld\n",i,dp[D-p[i]][D-q[i]]);
		ret=(ret+dp[D-p[i]][D-q[i]])%mod;
	}
	//printf("%lld\n",ret);
	
	for(int i=0;i<a;i++){
	//	printf("%d: %lld\n",i,C(p[i]*2+q[i]*2,p[i]*2));
		ret=(ret+mod-C(p[i]*2+q[i]*2,p[i]*2))%mod;
	}
	//printf("%lld\n",ret);
	
	ret=ret*d2%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 67072
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(b<a && c<a){
        cout << b+c << endl;
    }else if(a<b && c<b){
        cout << a+c << endl;
    }else{
        cout << a+b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int ans = 1;
  for (int i = 1; i * i <= m; ++i) {
    if (m % i == 0) {
      if (i >= n) {
        ans = max(ans, m / i);
      }
      if (m / i >= n) {
        ans = max(ans, i);
      }
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;


namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }

        public decimal[] DecimalArray()
        {
            var array = Array();
            var result = new decimal[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = decimal.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private int[] A;
        private long[,] Dp;
        void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = sc.IntArray();
            Dp = new long[N, N];
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    Dp[i, j] = -1;
                }
            }
        }

        private long Calc(int left, int right)
        {
            if (left == right)
            {
                return A[right];
            }

            if (Dp[left, right] != -1)
            {
                return Dp[left, right];
            }

            long reslt = Math.Max(A[left] - Calc(left + 1, right), A[right] - Calc(left, right - 1));
            Dp[left, right] = reslt;
            return reslt;
        }

        public void Solve()
        {
            Scan();
            Console.WriteLine(Calc(0, N - 1));
        }




        static void Main() => new Program().Solve();
    }


}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
int a[353][353];

bool ok(int x){
  int bancnt = 0;
  vector<bool> banned(m,false);
  vector<int> cnt(m,0);
  vector<int> head(n,0);
  REP(i,n){
    cnt[a[i][head[i]]]++;
  }
  while(true){
    int id = -1;
    REP(i,m)if(cnt[i]>x){
      id = i;
      break;
    }
    if(id==-1)return true;
    bancnt++;
    if(bancnt==m)return false;
    banned[id] = true;
    REP(i,n){
      while(banned[a[i][head[i]]]){
        cnt[a[i][head[i]]]--;
        head[i]++;
        cnt[a[i][head[i]]]++;
      }
    }
  }
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n)REP(j,m)scanf("%d",&a[i][j]),a[i][j]--;
  int mn = 0, mx = n;
  while(mn+1<mx){
    int x = (mn+mx)/2;
    if(ok(x)){
      mx = x;
    }else{
      mn = x;
    }
  }
  printf("%d\n",mx);
  return 0;
}


Measured memory_bytes: 640
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)

#define SZ(x)  (ll)(x.size())

//comment the below if now required

#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second


#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const ll N = 7;
ll n,m,k,i,j,r[7],c[7],ans;
char a[7][7];


void solve1(ll val,ll c,ll r)
{
    if(c>m)
    {
        ll tot = 0;

        c = val;

        for(i=1;i<=n;++i)
        {
            for(j=1;j<=m;++j)
            {
                if(!(r&(1<<i)) && !(c&(1<<j)))
                {
                    //if(r==6)
                       // cout<<(r&(1<<i))<<" "<<i<<"\n";

                    if(a[i][j]=='#')
                        ++tot;
                }
            }
        }

        
        if(tot == k){
          // cout<<r<<" "<<c<<"\n";
            ++ans;
        }

        return ;

    }


    solve1(val,c+1,r);

    val = val | (1<<c);

    solve1(val,c+1,r);
}


void solve(ll val,ll r)
{

    if(r>n)
    {
        solve1(2,2,val);
        solve1(0,2,val);

        return ;

    }


    solve(val,r+1);

    val = val | (1<<r);

    solve(val,r+1);

}

int main()
{
    cin>>n>>m>>k;
 
    rep(i,1,n+1)
    {
        rep(j,1,m+1)
            cin>>a[i][j];
    }


    solve(2,2);
    solve(0,2);

    cout<<ans;


    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
typedef unsigned long long int ull;

int main()
{
  // int t;
  // cin>>t;
  // while(t--)
  // {
    ull n, x;
    cin>>n>>x;
    int a[n];
    for(int i = 0; i<n; i++)
    cin>>a[i];

    ull sum = 0, dif ;
    ull max = x;
    ull c = 0;
    for(int i = 1; i<n; i++)
    {
      sum = a[i-1] + a[i];
      if(sum > x)
      {
        dif = sum - x;
        c += dif;
        if(a[i] >= dif)
        {
          a[i] -= dif;
        }
        else
        {
          dif = dif - a[i];
          a[i] = 0;
          a[i-1] -= dif;
        }
      }
    }
    cout<<c<<endl;
  // }

  return 0;
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define rep(i , a , n) for (int i=a; i<(int)(n); i++)
#define re(i , n)     for (int i=0; i<(int)(n); i++)
#define p push_back
#define em emplace_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define trace(a) cerr << #a << " = " << a << endl

using namespace std;

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

const int mod=7+1e9;
const int inf=1e9;
const int N=0;

int main()
{
#ifdef LOCAL
    freopen("input.in", "r", stdin);
#endif
    IOS;
  int n,k;
  cin>>n>>k;
  if( (n+1)/2>=k)cout<<"YES\n";
  else cout<<"NO\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  ll n; cin >> n;
  ll ans = 0;
  for(ll i = 2; i*i <= n; i++){
    if(n % i == 0){
      int c = 0;
      while(n % i == 0){
        c++;
        n /= i;
      }
      for(int j = 1; j <= c; j++){
        c -= j;
        ans++;
      }
    }
  }
  if(n != 1) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define MAXN (int)1e5
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)
#define inf (int)1e9
vi arr[MAXN];
int dp[MAXN];

int dfs(int v){
	if(dp[v] != -1) return dp[v];

	int len = 0;

	for(int i = 0;i < arr[v].size();i++){
		len = max(len, 1 + dfs(arr[v][i]));
	}

	dp[v] = len;

	return dp[v];
}

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

	memset(dp,-1,sizeof(dp));

	fo(m){
		int u,v;
		cin >> u >> v;

		arr[u-1].pb(v-1);
	}


	int ans = -1;

	for(int i = 0;i < n;i++){
		ans = max(dfs(i), ans);
	}

	cout << ans << endl;

	return 0;
 }	

Measured memory_bytes: 8192
#include "bits/stdc++.h"
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 imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
using ll = long long;
 
struct S {
    int w, s, v;
    void read() {
        scanf("%d%d%d", &w, &s, &v);
    }
    bool operator <(const S& b) const {
        return w + s < b.w + b.s;
    }
};
 
int main() {
    int n;
    scanf("%d", &n);
    vector<S> in(n);
    int MAX_S = 20123;
    for(int i = 0; i < n; ++i) {
        in[i].read();
        //~ MAX_S = max(MAX_S, in[i].s + in[i].w);
    }
    sort(in.begin(), in.end());
    vector<ll> dp(MAX_S + 1);
    // dp[i] - best score of boxes with total weight i
    for(S block : in) {
        for(int w = min(block.s, MAX_S - block.w); w >= 0; --w) {
            dp[w+block.w] = max(dp[w+block.w], dp[w] + block.v);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= MAX_S; ++i) {
        answer = max(answer, dp[i]);
    }
    printf("%lld\n", answer);
}

Measured memory_bytes: 384
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const merge = (arr1, arr2) => {
    if (arr1.length === 0) return arr2;
    if (arr2.length === 0) return arr1;
    const head1 = arr1[0];
    const tail1 = arr1.slice(1);
    const head2 = arr2[0];
    const tail2 = arr2.slice(1);

    if (head1[1] <= head2[1]) return [head1, ...merge(tail1, arr2)];
    else return [head2, ...merge(arr1, tail2)];
};

const msort = arr => {
    if (arr.length <= 1) return arr;
    const n = Math.floor(arr.length / 2);
    const t = arr.slice(0, n);
    const b = arr.slice(n);
    return merge(msort(t), msort(b));
};


const partition = arr => {
    const x = arr[arr.length-1][1];
    const result = [...arr];
    let i = -1;
    for (let j = 0; j < arr.length - 1; j++) {
        if (result[j][1] <= x) {
            i++;
            const tmp = result[i];
            result[i] = result[j];
            result[j] = tmp;
        }
    }
    const tmp = result[i+1];
    result[i+1] = result[arr.length-1];
    result[arr.length-1] = tmp;

    return [i+1, result];
}

const qsort = arr => {
    if (arr.length <= 1) return arr;
    const newArr = partition(arr);
    const mid = newArr[1][newArr[0]];
    const l = newArr[1].slice(0, newArr[0]);
    const r = newArr[1].slice(newArr[0]+1);
    return [...qsort(l), mid, ...qsort(r)];
};

const check = target => {
    for (let i = 1; i < target.length; i++) {
        if (target[i][1] === target[i-1][1] && target[i][2] < target[i-1][2]) {
            return false;
        }
    }
    return true;
};

const data = line.slice(1, parseInt(line[0])+1)
                 .map(x => x.split(' '))
                 .map((xs, i) => [xs[0], Number(xs[1]), i]);

const qsorted = qsort(data);

console.log(check(qsorted) ? 'Stable' : 'Not stable');
qsorted.map(x => x.slice(0, 2))
       .map(x => x.join(' '))
       .forEach(x => console.log(x));



Measured memory_bytes: 107260
import Data.List
import Data.Function

main = readLn >>= sequence . ($ getLine) . replicate >>= 
  putStrLn . ($ "No") . ($ "Yes") . if' . test

if' p x y = if p then x else y

test :: [String] -> Bool
test xs = valid && unique where
  valid   = and . zipWith ((==) `on` head) (tail xs) . 
            map reverse $ xs
  unique  = all (== 1) . map length . group . sort $ xs

Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <string>
#include <unordered_map>
#include <vector>

int main() {
  int n;
  while (std::cin >> n) {
    bool first = false;
    for (int i = 0; i < n; ++ i) {
      int temp;
      std::cin >> temp;
      first |= ((temp&1) == 1);
    }
    std::cout << (first ? "first": "second") << std::endl;
  }
  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c; cin >> a>>b>>c;
    int cnt = 0;
    for(int i=a; i<=b; ++i) {
        if (c%i==0) cnt++;
    }
    ct(cnt);
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 200007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
ll dp[MAXN][2];
int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> v(n + 1);
    for (int i = 1; i <= n; i++) cin >> v[i];
    dp[2][0] = v[1];
    dp[2][1] = v[2];
    for (int i = 3; i <= n; i++) {
        if (i % 2 == 0) {
            dp[i][0] = v[i - 1] + dp[i - 2][0];
            dp[i][1] = v[i] + max(dp[i - 2][0], dp[i - 2][1]);
        } else {
            dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
            dp[i][1] = v[i] + max(dp[i - 2][0], dp[i - 2][1]);
        }
    }
    cout << max(dp[n][0], dp[n][1]) << endl;

    return 0;
}


Measured memory_bytes: 7948
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var cin = GetIntArray().Select(s => s - 1).ToArray();
            var ans = cin[0] * cin[1];

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
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 convstr(string str){
	int rst = 0;
	int tmp = -1;
	REP(i,str.size()){
		if(str[i]=='m'){
			if(tmp!=-1) rst+=(tmp*1000);
			else rst+=1000;
			tmp = -1;
		}else if(str[i]=='c'){
			if(tmp!=-1) rst+=(tmp*100);
			else rst+=100;
			tmp = -1;
		}else if(str[i]=='x'){
			if(tmp!=-1) rst+=(tmp*10);
			else rst+=10;
			tmp = -1;
		}else if(str[i]=='i'){
			if(tmp!=-1) rst+=(tmp);
			else rst+=1;
			tmp = -1;
		}else{
			tmp = str[i] - '0';
		}
	}
	return rst;
}

string inttostring(int num){
	string str;
	stringstream ss;
	ss << num;
	return ss.str();
}

string convint(int num){
	string rst = "";
	while(num>0){
		if(num>=1000){
			if(num/1000==1) rst+='m';
			else{ rst+=inttostring(num/1000); rst+='m';}
			num %= 1000;
		}else if(num>=100){
			if(num/100==1) rst+='c';
			else{ rst+=inttostring(num/100); rst+='c';}
			num %= 100;
		}else if(num>=10){
			if(num/10==1) rst+='x';
			else{ rst+=inttostring(num/10); rst+='x';}
			num %= 10;
		}else{
			if(num==1) rst += 'i';
			else {rst+=inttostring(num); rst+='i';};
			num = 0;
		}
	}
	return rst;
}
int main(){
	int n;
	cin >> n;
	REP(i,n){
		string s1,s2;
		cin >> s1 >> s2;
		//cout << convstr(s1) <<" " << convstr(s2) << endl;
		cout << convint(convstr(s1)+convstr(s2)) << endl;
	}
}

Measured memory_bytes: 1228