akhauriyash/Code-Regression huggingface dataset:
//Author : Siriuslight
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0),cout<<setprecision(10)<<fixed;
#define int long long
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const ll inf = 1e9+100, N = 3e3+5;
const ll INF = 1e18+100, MOD = 1e9+7;

ll powmod(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll power(ll a,ll b){ll r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);}
ll inv(ll a, ll m = MOD){return powmod(a,m-2,m);}
ll lcm(ll a,ll b){return(a*b)/gcd(a,b);}

//ordered_set X;
//X.insert(3);
//X.order_of_key(3) no of elements less than 3
//*X.find_by_order(n) nth greatest element(0-indexed)
string s, t, ans;
int n, m, dp[N][N];
pair<int,int> mp[N][N];

int solve(int is, int it){
    if(is < 0 || it < 0) return 0;
    int &res = dp[is][it];
    if(res != -1) return res;
    res = 0;
    if(s[is] == t[it]){
        int temp = 1 + solve(is - 1, it - 1);
        if(res <= temp){
            res = temp;
            mp[is][it] = {is - 1, it - 1};
            return res;
        }
    }
    int temp1 = solve(is - 1, it), temp2 = solve(is, it - 1);
    if(temp1 >= res){
        res = temp1;
        mp[is][it] = {is - 1, it};
    }
    if(temp2 >= res){
        res = temp2;
        mp[is][it] = {is, it - 1};
    }
    return res;
}

int32_t main(){
    FIO;
    cin >> s >> t;
    n = s.size();
    m = t.size();
    memset(dp, -1, sizeof(dp));
    solve(n - 1, m - 1);
    int is = n - 1, it = m - 1;
    while(is >= 0 && it >= 0){
        if(s[is] == t[it]){
            ans += s[is];
        }
        int ts, tt;
        ts = is, tt = it;
        is = mp[ts][tt].F;
        it = mp[ts][tt].S;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}


Measured memory_bytes: 212224
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int x,y;
  cin >> x >> y;
  char gx,gy;
  if(x == 2){
    gx = 'a';
  }else if(x == 4 || x == 6 || x == 9 || x == 11){
    gx = 'b';
  }else{
    gx = 'c';
  }
  if(y == 2){
    gy = 'a';
  }else if(y == 4 || y == 6 || y == 9 || y == 11){
    gy = 'b';
  }else{
    gy = 'c';
  }
  if(gx == gy) cout << "Yes";
  else cout << "No";
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

int main(){
  int n;cin>>n;
  nvec(int,a,n);
  SORT(a);
  const int b=a[n-1];
  vector<bool> nyan(b+1,0);
  for (int i:a) {
    nyan[i]=1;
  }
  for (int i = 1; i <= b; i++) {
    if(nyan[i]==1){
      for (int d=2; i*d<=b; d++){
        nyan[i*d]=0;
      }
    }
  }
  for (int i = 1; i < n; i++) {
    if(a[i-1]==a[i]) nyan[a[i]]=0;
  }
  cout<<SUM(nyan);
}


/* きょむ〜 */


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

int cost[200][200];
int a[8];
signed main() {
	memset(cost, 0x3f, sizeof(cost));
	int n, m, r; cin >> n >> m >> r;
	for (int i = 0; i < r; i++) { cin >> a[i]; a[i]--; }
	sort(a, a + r);
	for (int i = 0; i < m; i++) {
		int b, c, d; cin >> b >> c >> d;
		b--; c--;
		cost[b][c] = cost[c][b] = d;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
			}
		}
	}
	int ans = 1 << 29;
	do {
		int sum = 0;
		for (int i = 1; i < r; i++) {
			sum += cost[a[i - 1]][a[i]];
		}
		ans = min(ans, sum);
	} while (next_permutation(a, a + r));
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;


ll V[51];
ll l[51], r[51];
ll ans = -1e9;


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

	ll N, K;
	cin >> N >> K;

	FOR(i, 0, N) {
		cin >> V[i];
	}
	l[0] = V[0];
	r[N - 1] = V[N - 1];

	FOR(i, 1, N) {
		l[i] = l[i - 1] + V[i];
		r[N - 1 - i] = r[N - i] + V[N - 1 - i];
	}
	

	for (int i=0; i <= min(N,K); i++) {
		for (int j = 0; i + j <= min(N,K); j++) {
			ll cur = 0;
			priority_queue<ll> que;
			FOR(k, 0, i) {
				if (i >= N - 1)break;
				cur += V[k];
				que.push(-V[k]);
			}
			FOR(s, 0, j) {
				if (N - 1 - s < 0)break;
				cur += V[N - 1 - s];
				que.push(-V[N - 1 - s]);
			}
			FOR(t, 0, max(0LL, K - i-j)) {
				if (que.empty())break;
				if (que.top() <= 0)break;
				cur += que.top();
				que.pop();
			}
			ans = max(ans, cur);
		}
	}

	cout << ans << endl;


	return 0;
}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define MOD  1000000000
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};
ll n,m,a[200005];

int main()
{
    ll var;
    double d;
    sfd(d);
    d=2*PI*d;
    pf("%.7f\n",d);
}


Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X[] = new int[N];
        int sum = 0;
        int ans = 0;
        for (int i = 0 ; i< N ; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        double x =(double) sum/N;
        double M =Math.round(x);
        int ans1 = 0;
        for (int i= 0 ; i< X.length;i++ ){
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 24916
//
//  main.cpp
//  ABC_095_C
//
//  Created by Joe Mori on 2020/06/28.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

#include <iostream>
#include<vector>

int main(int argc, const char * argv[]) {
    // insert code here...
    int A,B,C,X,Y,count;
    std::cin>>A>>B>>C>>X>>Y;
    count=1000000000;
//    long long int zero=0;
    for(int i=0;i<=std::max(X,Y);i++){
        count=std::min(count,C*2*i+A*std::max((X-i),0)+B*std::max((Y-i),0));
    }
    std::cout<<count<<std::endl;
    return 0;
}


Measured memory_bytes: 3532
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main()
{
    int n,m;
    vector<int> t(101,0);
    vector<vector<int> > drink(101,vector<int>(3,0));
    cin >> n;
    rep(i,n) cin >> t[i];
    cin >> m;
    rep(i,m) cin >> drink[i][0] >> drink[i][1];

    int sum = 0;
    rep(j,n) sum += t[j];
    
    rep(i,m){
        int ans = 0;
        ans = sum - t[drink[i][0]-1] + drink[i][1];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,ans;
signed main(){
    cin>>n;
    for(int x=1;x<=9;x++){
        for(int y=1;y<=9;y++){
            int A=0,B=0;
            for(int i=y;i<=n;i+=10){
                string s=to_string(i);
                if(s[0]==(char)(x+'0'))A++;
            }
            for(int i=x;i<=n;i+=10){
                string s=to_string(i);
                if(s[0]==(char)(y+'0'))B++;
            }
            ans+=A*B;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n);
    long long result = 0;

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

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

    for (int i = 0; i < n; i++) {
        if (a[i] >= b[i]) {
            a[i] = a[i] - b[i];
            result += b[i];
        }
        else {
            result += a[i];
            b[i] -= a[i];
            a[i] = 0;

            if (a[i + 1] >= b[i]) {
                a[i + 1] = a[i + 1] - b[i];
                result += b[i];
            }
            else {
                result += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
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 N, K;
	cin >> N >> K;

	map<LL,LL> mod_list;

	for (int i = 1; i <= N; i++) {
		mod_list[i % K]++;
	}

	if (K%2 == 0) {
		cout << LL(pow(mod_list[K / 2], 3) + pow(mod_list[0], 3)) << endl;
	}
	else {
		cout << LL(pow(mod_list[0], 3)) << endl;
	}

	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<(double)w*h/2<<" ";
  cout<<(x*2==w&&y*2==h)<<endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let K: usize = read();
    let mut A: Vec<usize> = (0..K).map(|_| read()).collect();
    A.reverse();
    if *A.first().unwrap() > 2 {
        println!("{}", -1);
        return;
    }
    let mut min = 2;
    let mut max = if A[0] == 1 { 2 } else { 3 };
    for &a in &A[1..] {
        if (min - 1)/ a == max / a {
            println!("-1");
            return
        }
        max += a - (max % a) - 1;
        if min % a != 0 {
            min += a - (min % a);
        }
    }
    println!("{} {}", min, max)
}


Measured memory_bytes: 2844
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> g[200000];
int d[2][200000],id;
void dfs(int a,int w=-1)
{
    if(w!=-1)
	{
        d[id][a]=d[id][w]+1;
    }
    for(int i=0;i<g[a].size();i++)
	{
    	
        if(g[a][i]!=w)
		{
            dfs(g[a][i],a);
        }
    }
    return;
}
int main()
{
    cin>>n;
    for(int i=0;i<n-1;i++)
	{
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    id=0;
    dfs(0);
    id=1;
    dfs(n-1);
    int cnt=0;
    for(int i=0;i<n;i++)
	{
        if(d[0][i]<=d[1][i])
		{
            cnt++;
        }
    }
    if(cnt>=n/2+1)
	{
       cout<<"Fennec"<<endl;
    }
    else
	{
        cout<<"Snuke"<<endl;
    }
    return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<LL> VI;
typedef unsigned long long ULL;

#define MP make_pair
#define PB push_back
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()
#define f first
#define s second
#define FILL(a, b) memset(a, b, sizeof(a))

const int MAX = 200*1000 + 7;
const int INF = 1000*1000*1000;
const LL LINF = 1LL*INF*INF;
const int MOD = 998244353;
const double PI = acos(-1.);

LL dpT1[MAX][3];
LL dp1(int n, int ost)
{
	if(n==0)
	{
		return (ost==0);
	}
	if(dpT1[n][ost] != -1)
		return dpT1[n][ost];
	LL ans = 0;
	FOR(i, 0, 3)
	{
		ans += dp1(n-1, (ost + 3 - i)%3);
	}
	return dpT1[n][ost] = ans % MOD;
}
LL dpT2[MAX][3][4];
LL dp2(int n, int ost, int prev)
{
	if(n==0)
	{
		return (ost==0);
	}
	if(dpT2[n][ost][prev] != -1)
		return dpT2[n][ost][prev];
	LL ans = 0;
	FOR(i, 0, 3)
	{
		if(i != prev)
			ans += dp2(n-1, (ost + 3 - i)%3, i);
	}
	return dpT2[n][ost][prev] = ans% MOD;
}

int cnt = 0;
map<string, int> used;
void dfs(string s)
{
	cnt++;
	used[s] = 1;
	FOR(i,0,SZ(s)-1)
	{
		if(s[i] != s[i+1])
		{
			string ns = s;
			int ind = 3 - (s[i]-'a') - (s[i+1]-'a');
			ns[i] = char(int('a') + ind);
			ns[i+1] = char(int('a') + ind);
			if(!used[ns])
				dfs(ns);
		}
	}
}
int brut(string s)
{
	dfs(s);
	return cnt;
}
int main()
{
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	bool ok = 1;
	FOR(i,0,SZ(s))
		if(s[i]!= s[0])
			ok = 0;
	if(ok)
	{
		cout << 1;
		return 0;
	}
	if(SZ(s) > 7)
	{
		FILL(dpT1, -1);
		FILL(dpT2, -1);
		int ost = 0;
		FOR(i,0,SZ(s))
			ost += (s[i] - 'a');
		ost %= 3;
		int no_double = 1;
		FOR(i,0,SZ(s) - 1)
			if(s[i]==s[i+1])
				no_double = 0;
		cout << (dp1(SZ(s), ost) + MOD - dp2(SZ(s), ost, 3) + no_double)%MOD;
	}
	else
	{
		cout << brut(s);
	}
	return 0;
}



Measured memory_bytes: 39700
#include <bits/stdc++.h>
using namespace std;
char S[120000]; int n,a[3],x,y;
int main(){
	scanf("%s",S); n=strlen(S);
	for (int i=0;i<n;++i) ++a[S[i]-'a'],x=max(x,a[S[i]-'a']);
	if (x-a[0]>1||x-a[1]>1||x-a[2]>1) puts("NO"); else puts("YES");
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

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

Measured memory_bytes: 600
N=int(input())
D=[]
TF=[]
for i in range(N):
    Input=list(map(int,input().split()))
    D.append(Input)
    if D[i][0]==D[i][1]:
        TF.append(1)
    else:
        TF.append(0)
TF.append(0)
TF.append(0)
Q=[]
for i in range(N):
    temp=TF[i]+TF[i+1]+TF[i+2]
    Q.append(temp)
if max(Q)==3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9144
n = int(input())
li = list(map(int,input().split()))

cnt_odd = 0
cnt_even = 0

for x in li:
    if x%2 == 0:
        cnt_even += 1
    else:
        cnt_odd += 1
        
if cnt_odd%2 != 0:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 14108
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
   int n;
   cin>>n;
   string s1,s2="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
   cin>>s1;
   loop(i,0,s1.size())
   {
       int p = s1[i]-'A';
       cout<<s2[p+n];
   }
   cout<<endl;
    return 0;
}



Measured memory_bytes: 3628
def Judgement(x,y,z):
    if z-x-y>0 and (z-x-y)**2-4*x*y>0:
        return 0
    else:
        return 1

a,b,c=map(int,input().split())
ans=Judgement(a,b,c)
if ans==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string S; cin >> S;
    vector<int>A(26);
    rep(i, S.size())A[S.at(i) - 97]++;
    rep(i, 26) {
        if (A[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3584
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  vector<string> v={"KIHBR","KIHBRA","KIHBAR","KIHBARA","KIHABR","KIHABRA","KIHABAR","KIHABARA","AKIHBR","AKIHBRA","AKIHBAR","AKIHBARA","AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"};
  bool flag=false;
  rep(i,16){
    if(v[i]==s) flag=true;
  }
  if(flag) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
n = int(input())
kaidan = [1]
for i in range(2,int((2*n)**0.5+1)):
    kaidan.append(kaidan[-1]+i)
if not n in kaidan:
    print("No")
    exit()
print("Yes")
size = kaidan.index(n)+1
print(size+1)
hyo = [[0 for i in range(size)] for j in range(size)]
for i in range(size):
    for j in reversed(range(i+1)):
        hyo[i][j] = kaidan[i] - (i - j)
        hyo[j][i] = hyo[i][j]
kar = []
for i in range(size):
    kar.append(hyo[i][i])
hyo.append(kar)

for i in range(size+1):
    print(size,end=" ")
    print(*hyo[i])

Measured memory_bytes: 13852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  vector<ll> C(2);
  int K;
  cin >> C[0] >> C[1] >> K;
  int flag = 0;
  rep(i, K) {
    C[flag] /= 2;
    C[1-flag] += C[flag];
    flag = 1-flag;
  }
  cout << C[0] << ' ' << C[1] << endl;
  return 0;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,m,d;
int main(){
  cin>>n>>m>>d;
  double res=(n-d)*(d==0?1.0:2.0)/n/n*(m-1);
  printf("%.10f\n",res);
  return 0;
}





Measured memory_bytes: 256
if __name__ == "__main__":
    h,w = map(int,input().split())
    s = []
    s.append([0]*(w+2))

    for i in range(h):
        q = [0]
        q.extend(list(input()))
        q.append(0)
        s.append(q)
    s.append([0]*(w+2))

    for p in range(h):
        for q in range(w):
            if s[p+1][q+1] == "#":
                print("#",end = "")
            else:
                aro = [s[p][q],s[p+1][q],s[p+2][q],s[p][q+1],s[p+2][q+1],s[p][q+2],s[p+1][q+2],s[p+2][q+2]]
                print(aro.count("#"),end = "")
        print("")

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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
template<class T> lint gcd(T a, T b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T> lint lcm(T a, T b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

template<class T, class Q> inline bool chmin(T& a, Q b) {
    if (a > b) { 
        a = b;
        return true; 
    }
    return false;
}

template<class T, class Q> inline bool chmax(T& a, Q b) {
    if (a < b) { 
        a = b; 
        return true; 
    }
    return false;
}

// 定数 //
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define inf ((1LL << 62) - 1 + (1LL << 62))

// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
        
    int N;
    cin >> N;
    vi L(N);
    rep(i, N) cin >> L[i];
    sort(L);
    int tori = 0;

    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            for (int k = j + 1; k < N; k++) {
                if (L[i] + L[j] <= L[k]) continue;
                tori++;
            }
        }
    }
    cou(tori);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'

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

    string bal[n];
    for(int i=0;i<n;i++){
        cin>>bal[i];
    }
 string mn=bal[0];
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        if(bal[j]<bal[i]){
            mn=bal[j];
            bal[j]=bal[i];
            bal[i]=mn;
        }
      }
    }
    for(int i=0;i<n;i++){
        cout<<bal[i];
    }

 return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
#define MAX 100000
#define NIL -1

int n;
vector<int> G[MAX];
int color[MAX];


void dfs(int r, int c) {
  stack<int> S;
  int i, v, u;
  S.push(r);
  color[r]=c;
  while (! S.empty()) {
    u=S.top();
    S.pop();
    for (i=0; i<G[u].size(); i++) {
        v=G[u][i];
      if (color[v]==NIL) {
        color[v]=c;
        S.push(v);
      }
    }
  }
}



void assignColor() {
  int i, u;
  int id=1;
  for (i=0; i<n; i++) color[i]=NIL;
  for (u=0; u<n; u++) {
    if (color[u]==NIL)
      dfs(u, id++);
  }
}

int main() {

  int  m, i, j, v, s, t, q;

  cin >> n >> m;

  for (i=0; i<m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;

  for (i=0; i<q; i++) {
    cin >> s >> t;
    if (color[s]== color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;

}

Measured memory_bytes: 8928
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;

typedef struct {
  int city;
  int year;
  int prefecture;
  int id;
} City;
int main() {
  int n, m;
  int p, y;
  City tmpc;
  vector<City> v;
  cin >> n >> m;
  rep(i, m) {
    cin >> p >> y;
    tmpc.city = i;
    tmpc.year = y;
    tmpc.prefecture = p;
    tmpc.id = -1;
    v.push_back(tmpc);
  }
  sort(v.begin(), v.end(), [](const City &a, const City &b) {
                             return a.prefecture == b.prefecture
                               ? a.year < b.year : a.prefecture < b.prefecture ;
                           });
  // sort(v.begin(), v.end(), [](const City &a, const City &b) {
  //                            return a.year < b.year;
  //                          });
  // rep(i, m) {
  //   cout << v[i].prefecture << " " <<  v[i].year << endl;
  // }
  int nowp = v[0].prefecture;
  int cnt = 0;
  rep(i, m) {
    if (v[i].prefecture == nowp) {
      cnt++;
      v[i].id = cnt;
    } else {
      cnt = 1;
      nowp = v[i].prefecture;
      v[i].id = 1;
    }
  }
  sort(v.begin(), v.end(), [](const City &a, const City &b) {
                             return a.city < b.city;
                           });
  rep(i, m) {
    printf("%06d%06d\n", v[i].prefecture, v[i].id);
  }
  return 0;
}


Measured memory_bytes: 3184
import Data.List
main = do
  [x, n] <- map read . words <$> getLine
  if n == 0
    then print x
    else do
      ns <- map read . words <$> getLine
      print $ solve ns x

solve ns x = head $ dropWhile (flip elem ns) xs
  where
    xs = (x:) . concat $ zipWith (\a b -> [a, b]) [x-1, x-2..] [x+1, x+2..]

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

int main(){
	int w,a,b;
	cin >> w >> a >> b;
	int out;
	if(a<b){
		out = b-(a+w);
	} else {
		out = a-(b+w);
	}
	if(out>0) cout << out << endl;
	else cout << 0 << endl;
	
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int>v(N),a(N);

for(int i=0;i<N;i++)cin>>v[i];
for(int i=0;i<N;i++)a[i]=v[i];

sort(v.begin(),v.end());
for(int i=0;i<N;i++){
  if(a[i]<=v[N/2-1])cout<<v[N/2]<<endl;
  else cout<<v[N/2-1]<<endl;
}
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int H,W,N;
set<pi> tri,z;
ll ans[10];

bool valid(pi x) {
    return 1 <= x.f && x.f <= H-2 && 1 <= x.s && x.s <= W-2;
}

int co(pi a) {
    int ans = 0;
    F0R(i,3) F0R(j,3) if (z.count({a.f+i,a.s+j})) ans ++;
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> H >> W >> N;
    F0R(i,N) {
        int a,b; cin >> a >> b;
        F0R(j,3) F0R(k,3) tri.insert({a-j,b-k});
        z.insert({a,b});
    }
    for (auto a: tri) if (valid(a)) ans[co(a)] ++;
    ll tot = (ll)(H-2)*(W-2);
    FOR(i,1,10) tot -= ans[i];
    ans[0] = tot;
    F0R(i,10) cout << ans[i] << "\n";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 47104
import sys

N, P = map(int, input().split())
A = list(map(int, input().split()))
dp = [[1 - i for _ in range(N + 1)] for i in range(2)]

for i in range(N):
    # 食べない
    dp[0][i + 1] = dp[0][i]
    dp[1][i + 1] = dp[1][i]

    # 食べる
    if A[i] % 2:
        dp[0][i + 1] += dp[1][i]
        dp[1][i + 1] += dp[0][i]
    else:
        dp[0][i + 1] += dp[0][i]
        dp[1][i + 1] += dp[1][i]

print(dp, file=sys.stderr)
print(dp[P][N])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n;cin>>n;
      string s,t;
      cin>>s>>t;
      for(int i=0;i<s.size();i++)
      {
        	cout<<s[i];
        	cout<<t[i];
      }
    }

Measured memory_bytes: 256
def main():
  n=int(input())
  a=list(map(int,input().split()))
  ans=[0]*n
  ans[0]=sum([a[i]*(-1)**i for i in range(n)])
  for i in range(1,n):
    ans[i]=ans[i-1]*(-1)+2*a[i-1]
  print(*ans)
if __name__=='__main__':
  main()

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////


ll N;
pll xl[101010];


ll i, j,ans;
int main(){
    scanf("%lld",&N);
    fornum(i,0,N){
        ll x, l;
        scanf("%lld%lld", &x, &l);
        xl[i] = {x + l, x - l};
    }
    sort(xl, xl + N);
    j = -1e18;
    fornum(i,0,N){
        if(j<=xl[i].second){
            j = xl[i].first;
            ++ans;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1792
n = int(input())
A = [int(el) for el in input().split(' ')]
if n % 2 == 0:
    B = A[(n-1):0:-2] + A[0:n:2]
else:
    B = A[(n-1)::-2] + A[1:n:2]

print(' '.join(str(el) for el in B))


Measured memory_bytes: 29476
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

int N, A[110];

void trace(int A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void selectionSort(int A[], int N) {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(A[i], A[minj]);
            cnt++;
        }
    }
    trace(A, N);
    cout << cnt << endl;
}

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];
    selectionSort(A, N);
}


Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main() {
  int n;
  while( cin >> n, n ) {
    int num[n], pro[n], lip[n], car[n];
    int p, q, r, c, cnt = 0;
    for(int i=0; i<n; i++) {
      cin >> num[i] >> pro[i] >> lip[i] >> car[i];
    }

    cin >> p >> q >> r >> c;
    for(int i=0; i<n; i++) {
      if( pro[i] <= p && lip[i] <= q && car[i] <= r ) {
	if( pro[i]*4 + lip[i]*9 + car[i]*4 <= c ) {
	  cout << num[i] << endl;
	  cnt++;
	}
      }
    }

    if( !cnt ) cout << "NA" << endl;
  }
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int p2(int B){
  if(!B)return 1;
  if(B&1)return p2(B-1)*2%mod;
  int C=p2(B/2);
  return C*C%mod;
}
signed main(){
  int N;
  cin>>N;
  map<pair<int,int>,int> mp;
  int ans=-1,ans2=1;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    if(a==0 && b==0){
      ans++;
      continue;
    }
    int n=gcd(abs(a),abs(b));
    a/=n,b/=n;
    if(b<0)a*=-1,b*=-1;
    if(!b && a<0)a*=-1;
    mp[make_pair(a,b)]++;
  }
  for(pair<pair<int,int>,int> p:mp){
    if(!mp.count(make_pair(p.first.second,-p.first.first)) && !mp.count(make_pair(-p.first.second,p.first.first)))
      ans2=ans2*p2(p.second)%mod;
    else if(p.first.first<=0)
      ans2=ans2*((p2(p.second)+p2(mp[make_pair(p.first.second,-p.first.first)])-1+mod)%mod)%mod;
  }
  cout<<(ans+ans2+mod)%mod<<endl;
}

Measured memory_bytes: 16032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

struct G {
    ll a, f, cost;
    G(ll a_, ll f_) {
        a = a_;
        f = f_;
        cost = a * f;
    }
    bool operator <(const G &g) const {return cost < g.cost;}
};

int main() {
    fast_io
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());

    vector<G> g;
    rep(i,n) g.emplace_back(a[i], f[i]);
    sort(g.begin(), g.end());

    ll left = 0, right = 1001001001001, mid;
    bool ok;
    rep(i,100) {
        ll k_copy = k;
        mid = (left + right) / 2;
        ok = true;
        for (G gg: g) {
            if (gg.cost <= mid) continue;
            ll k_tmp = (gg.cost - mid + gg.f - 1) / gg.f;
            k_copy -= k_tmp;
            if (k_copy < 0) {ok = false; break;}
        }
        if (ok) right = mid;
        else left = mid;
    }
    cout << right << endl;

    return 0;
}

Measured memory_bytes: 11376
from collections import deque
N = int(input())
A = list(map(int,input().rstrip().split(" ")))
A.sort(reverse = True)
ans = 0
que = deque()
que.append(A[0])
for i in range(1,len(A)):
    ans += que[0]
    que.popleft()
    que.append(A[i])
    que.append(A[i])
print(ans)

Measured memory_bytes: 33136
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int g[101][101];
int dist[101];
int seen[101];

int main(){

  long ii,jj,kk;
  vector<int> a;

  memset(g,0,sizeof(g));
  int n;
  cin >> n;
  int v,vn,r;
  for(ii=0;ii<n;ii++){
    cin >> v;
    cin >> vn;
    for(jj=0;jj<vn;jj++){
      cin >> r;
      g[v][r] = 1;
    }
  }
  vector<int> todo;
  memset(seen,0,sizeof(seen));
  for(ii=0;ii<101;ii++){
    dist[ii] = -1;
  }

  dist[1] = 0;
  seen[1] = 1;
  todo.push_back(1);
  //int v;
  while(!todo.empty()){

    v = todo[0];
    todo.erase(todo.begin());
    
    //cout << "v:" << v <<endl;
    for(ii=1;ii<=n;ii++){
      if(g[v][ii] == 1 && seen[ii] == 0){
        dist[ii] = dist[v] + 1;
        seen[ii] = 1;
        todo.push_back(ii);
      }
    }
    
  }

  for(ii=1;ii<=n;ii++){
    cout << ii << " " << dist[ii] << endl;
  }
  
//  for(ii=1;ii<=n;ii++){
//    for(jj=1;jj<=n;jj++){
//      cout << g[ii][jj] ;
//      if(jj!=n){
//        cout << " ";
//      }
//    }
//    cout << endl;
//  }
  
  return 0;
}



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

class team{
public:
	int num, ans, time;
	team(int n){
		num = n;
		ans = time = 0;
	}
	bool operator<(const team &t2)const{
		if (ans != t2.ans)
			return ans > t2.ans;
		else if (time != t2.time)
			return time < t2.time;
		else
			return num > t2.num;
	}
};

int main()
{
	int M, T, P, R, m[2001], t[2001], p[2001], r[2001], before;
	while (cin >> M >> T >> P >> R, (M || T || P || R)){
		vector<team> v;
		vector<team>::iterator pv;
		//入力
		for (int i = 0; i < R; i++){
			cin >> m[i] >> t[i] >> p[i] >> r[i];
		}

		//各チームの時間
		for (int i = 1; i <= T; i++){
			team te = team(i);
			for (int j = 0; j < R; j++){
				//正解時間の計算
				if (t[j] == i && r[j] == 0){
					te.time += m[j];
					te.ans++;
					//以前のペナルティを計算
					for (int k = 0; k < j; k++){
						if (t[k] == i && p[k] == p[j]){
							te.time += 20;
						}
					}
				}
			}
			v.push_back(te);
		}

		//ソート
		sort(v.begin(), v.end());
		pv = v.begin();
		before = -1;
		while (pv != v.end()){
			if (before == pv->time)
				cout << "=" << pv->num;
			else {
				if (pv == v.begin())
					cout << pv->num;
				else
					cout << "," << pv->num;
				before = pv->time;
			}
			pv++;
		}
		cout << endl;
	
	}
	return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
	//変数の宣言
	long long int n,s;
	static long long int num[1000010];
	long long int sqrtn;
	
	//よく使う変数
	int i;
	long long int j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	long long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%lld",&n);
	scanf("%lld",&s);
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
//	printf("n=%lld\n",n);

	if(n<s){
		printf("-1");
		return 0;
	}else if(n==s){
		printf("%lld",n+1);
		return 0;
	}

	if(n==2&&s==1){
		printf("2");
		return 0;
	}

	for(j=1;j<n;j++){
//		printf("i=%lld, i*i=%lld\n",i,i*i);
		if(j*j>=n){
			sqrtn=j;
			break;
		}
	}

//	printf("sqrtn=%lld,sqrtn^2=%lld,\n",sqrtn,sqrtn*sqrtn);

	for(i=1;i<sqrtn;i++){
//		printf("i=%d (n-s)%%i=%lld\n",i,(n-s)%i);
		if((n-s)%i==0){
			num[count]=i;
//			printf("num[%d]=%lld\n",count,num[count]);
			count++;
		}
	}
	
	for(i=count;i<2*count;i++){
		num[i]=(n-s)/num[2*count-1-i];
	}
	
	for(i=0;i<2*count;i++){
//		printf("num[%d]=%lld\n",i,num[i]);
		temp=n;
		temp2=0;
		while(temp!=0){
			temp2=temp2+temp%(num[i]+1);
			temp=temp/(num[i]+1);
//			printf("temp=%lld,temp2=%lld\n",temp,temp2);
		}
		if(temp2==s){
			printf("%lld",num[i]+1);
			return 0;
		}
	}
	
//	printf("計算部分終了\n");
	//出力
	
	printf("-1");
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



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

int main(){
    int  L, R, d;
    cin >> L >> R >> d;
    int cnt = 0;

    for(int i = L; i <= R; i++){
        if (i % d == 0){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3616