akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };

    let p250: usize = sc.read();
    let p500: usize = sc.read();
    let p1000: usize = sc.read();
    let p2000: usize = sc.read();
    let n: usize = sc.read();
    let mut v = vec![p250 * 8, p500 * 4, p1000 * 2, p2000];
    v.sort();
    let ans = n / 2 * v[0];

    let mut v = vec![p250 * 4, p500 * 2, p1000];
    v.sort();
    println!("{}", ans + n % 2 * v[0]);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
///
// File:  dsl_1_a.cpp
// Author: ymiyamoto
//
// Created on Thu Oct 19 00:53:31 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct tree_t {
  tree_t *parent;
  vector<tree_t *> children;
  uint32_t val;

  tree_t(uint32_t v)
  {
    parent = this;
    val = v;
  }
};

#define SIZE 10000
static vector<tree_t *> trees(SIZE, NULL);
static vector<uint32_t> height(SIZE, 1);

tree_t *find_root(tree_t *t)
{
  if (t == t->parent) {
    return t;
  } else {
    return find_root(t->parent);
  }
}

void unite(uint32_t x, uint32_t y)
{
  tree_t *x_root = find_root(trees[x]);
  tree_t *y_root = find_root(trees[y]);

  if (height[x_root->val] < height[y_root->val]) {
    x_root->parent = y_root;
    y_root->children.push_back(x_root);
  } else {
    y_root->parent = x_root;
    x_root->children.push_back(y_root);
  }
}

bool same(uint32_t x, uint32_t y)
{
  tree_t *x_root = find_root(trees[x]);
  tree_t *y_root = find_root(trees[y]);

  return x_root->val == y_root->val;
}

int32_t main()
{
  uint32_t n, q;
  cin >> n >> q;

  for (uint32_t i = 0; i < n; i++) {
    tree_t *t = new tree_t(i);
    trees[i] = t;
  }

  for (uint32_t i = 0; i < q; i++) {
    string str;
    uint32_t x, y;
    cin >> str >> x >> y;
    if (str[0] == '0') {
      unite(x, y);
    } else {
      if (same(x, y)) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 4328
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
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;}
#define MOD 998244353ll // prime
// How to devide :
// ModInt a(6ll);
// ModInt b(2ll);
// a *= b.exp(MOD-2ll);  -> a/=b;  result: a = 3
struct ModInt{
	ll val;
	ModInt():val(0ll){}
	ModInt(ll v):val(((v%MOD)+MOD)%MOD){}
	ModInt exp(ll y)const{
		if(!y)return ModInt(1ll);
		ModInt a = exp(y/2ll);
		a *= a;
		if(y&1)a*=(*this);
		return a;
	}
	bool operator==(const ModInt& x)const{return val==x.val;}
	inline bool operator!=(const ModInt& x)const{return !(*this==x);}
	bool operator<(const ModInt& x)const{return val<x.val;}
	bool operator>(const ModInt& x)const{return val>x.val;}
	inline bool operator>=(const ModInt& x)const{return !(*this<x);}
	inline bool operator<=(const ModInt& x)const{return !(*this>x);}
	ModInt& operator+=(const ModInt& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator-=(const ModInt& x){if((val+=MOD-x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator*=(const ModInt& x){(val*=x.val)%=MOD;return *this;}
	ModInt operator+(const ModInt& x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt& x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt& x)const{return ModInt(*this)*=x;}
};
istream& operator>>(istream&i,ModInt&x){i>>x.val;return i;}
ostream& operator<<(ostream&o,const ModInt&x){o<<x.val;return o;}
ModInt pow(ModInt a,ll x){
	ModInt res = ModInt(1ll);
	while(x){
		if(x&1)res *= a;
		x >>= 1;
		a = a*a;
	}
	return res;
}
const int SIZE = 10000100;
ModInt inv[SIZE+10],fac[SIZE+10],facinv[SIZE+10];
// notice: 0C0 = 1 
ModInt nCr(int n,int r){
	assert(!(n<r));
	assert(!(n<0||r<0));
	return fac[n]*facinv[r]*facinv[n-r];
}
void init(){
	fac[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)fac[i]=fac[i-1]*ModInt(i);
	inv[1]=ModInt(1ll);
	for(int i=2;i<=SIZE;i++)inv[i]=ModInt(0ll)-ModInt(MOD/i)*inv[MOD%i];
	facinv[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)facinv[i]=facinv[i-1]*inv[i];
	return;
}
int N,M;
int main(){
	init();
	cin >> N >> M;
	ModInt ans = nCr(3*M+N-1,N-1);
	//cout << ans << endl;
	for(int i=2*M+1;i<=3*M;i++){
		ans -= ModInt(N)*nCr(N-2+3*M-i,3*M-i);
		//cout << ret << endl;
	}
	for(int i=M+1;i<=N;i++){
		if((3*M-i)%2==0 && 3*M-i>=0){
			ans -= nCr(N,i)*nCr(N-1+(3*M-i)/2,N-1);
		}
	}

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

Measured memory_bytes: 234624
import heapq

n,m=map(int,input().split())
a=list(map(lambda x:x*(-1),map(int,input().split())))
heapq.heapify(a)  # リストを優先度付きキューへ
for i in range(m):
  y=(-1*heapq.heappop(a))//2
  heapq.heappush(a,-1*y)
print(-sum(a))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> v(3*n); cin >> v;
    sort(ALL(v));
    ll ans = 0;
    rep(i, n) {
        ans += v[n+i*2];
    }
    cout << ans << endl;
}


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

using namespace std;
#define ll long long

int main(){
	ll a, b;
	ll ans = 0;
	cin >> a >> b;
	
	for( ; a%4; a++){ans ^= a;}
	for( ; (b+1)%4; b-- ){ans ^= b;}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<pair<ll,ll>> a(n);
	rep(i,n) cin >> a.at(i).first >> a.at(i).second;
	sort(a.begin(),a.end());
	ll ans=0,sum=0;
	rep(i,n){
		if(sum+a.at(i).second>=m){
			ans+=a.at(i).first*(m-sum);
			break;
		}
		else{
			ans+=a.at(i).first*a.at(i).second;
			sum+=a.at(i).second;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int t[200];

int a[200];
int b[200];
int c[200];

int dp[2][200];

int main()
{
	int d,n;
	scanf("%d%d",&d,&n);
	for(int i = 0; i < d; i++)
	{
		scanf("%d",t + i);
	}
	for(int i = 0; i < n; i++)
	{
		scanf("%d%d%d",a + i,b + i,c + i);
	}
	int now = 0;
	for(int i = 0; i < n; i++)
	{
		if(a[i] <= t[0] && t[0] <= b[i])
		{
			dp[now][i] = 0;
		}
		else
		{
			dp[now][i] = -1000000;
		}
	}
	for(int i = 1; i < d; i++)
	{
		int nex = (now + 1) % 2;
		for(int j = 0; j < n; j++)
		{
			dp[nex][j] = -1000000;
		}
		for(int j = 0; j < n; j++)
		{
			if(a[j] <= t[i] && t[i] <= b[j])
			{
				for(int jj = 0; jj < n; jj++)
				{
					dp[nex][j] = max(dp[nex][j],dp[now][jj] + abs(c[j] - c[jj]));
				}
			}
		}
		now = nex;
	}
	int maxw = -1000000;
	for(int i = 0; i < n; i++)
	{
		maxw = max(maxw,dp[now][i]);
	}
	printf("%d\n",maxw);
	return 0;
}

Measured memory_bytes: 1196
a, b = map(int, input().split())
count = 0
for i in range(a,b+1):
  b1 = i%10
  s = i//10
  b2 = s%10
  t = s//10
  u = t//10
  a2 = u%10
  v = u//10
  a1 = v%10
  if a1 == b1 and a2 == b2:
    count += 1
print(count)

Measured memory_bytes: 39408
#include<iostream>

using namespace std;

int ruisekiwa[100001];
bool prime[100001];

int Q;

bool isprime(int a) {
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0)return false;
	}
	return true;
}

int main() {

	prime[2] = true;
	for (int i = 3; i <= 100000; i++) {
		prime[i] = isprime(i);
	}
	
	for (int i = 2; i <= 100000; i++) {
		ruisekiwa[i] = ruisekiwa[i - 1];
		if (prime[i] && prime[(i + 1) / 2])ruisekiwa[i]++;
	}

	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b;
		cout << ruisekiwa[b] - ruisekiwa[a - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

#define SENTINEL (1000000001)

int c = 0;
int S[500000];
int L[250001];
int R[250001];
char str[5500000];
char *p = str;

static void Merge(int A[], int left, int mid, int right);
static void MergeSort(int A[], int left, int right);
static int getNum(void);
static void putNum(int n);

int main(void) {
	register int i;
	int n;
	
	fread(str, sizeof(char), 5500000, stdin);
	n = getNum();
	for (i = 0; i < n; ++i) {
		S[i] = getNum();
	}
	
	MergeSort(S, 0, n);
	
	--n;
	p = str;
	for (i = 0; i < n; ++i) {
		putNum(S[i]);
		*p = ' ';
		++p;
	}
	putNum(S[i]);
	*p = '\n';
	++p;
	
	putNum(c);
	*p = '\0';
	
	puts(str);

	return 0;
}

int getNum(void) {
	int n = 0;
	while ((*p >= '0') && (*p <= '9')) {
		n = n * 10 + (int)(*p - '0');
		++p;
	} 
	++p;
	return n;
}

void putNum(int n) {
	int d = n / 10;
	if (n < 10) {
		*p = '0' + (char)n;
		++p;
		return;
	}
	if (d) putNum(d);
	*p = '0' + (char)(n % 10);
	++p;
}

void Merge(int A[], int left, int mid, int right) {
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	memcpy(L, A + left, n1 * sizeof(int));
	memcpy(R, A + mid, n2 * sizeof(int));
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for (k = left; k < right; ++k) {
		++c;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			++i;
		} else {
			A[k] = R[j];
			++j;
		}
	}
}

void MergeSort(int A[], int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x <<
const int MOD = (int)1e9 + 7;
const int INF = 1145141919;
using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using l_l = pair<ll, ll>;
using d_d = pair<double, double>;
using vint = vector<int>;
using vll = vector<ll>;

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans;
    if (a % 2 == 0) {
        switch ((b - a) % 4) {
        case 0:
            ans = 0 ^ b;
            break;
        case 1:
            ans = 1;
            break;
        case 2:
            ans = 1 ^ b;
            break;
        case 3:
            ans = 0;
            break;
        }
    } else {
        a -= 1;
        switch ((b - a) % 4) {
        case 0:
            ans = 0 ^ b;
            break;
        case 1:
            ans = 1;
            break;
        case 2:
            ans = 1 ^ b;
            break;
        case 3:
            ans = 0;
            break;
        }
        ans ^= a;
    }
    cout << ans;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

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

	int n;
	cin >> n;
	cout << (n + n * n + n * n * n) << "\n";

	return 0;
}


Measured memory_bytes: 3648
x = [                                                        
  list(map(int, input().split()))                            
  for i in range(3)                                          
]                                                            
                                                             
lines = list()                                               
for i in range(3):                                           
  lines.append(set(x[i]))                                    
  lines.append(set(x[j][i] for j in range(3)))               
                                                             
lines.append({x[i][i] for i in range(3)})                    
lines.append({x[2 - i][i] for i in range(3)})                
                                                             
                                                             
                                                             
z = set()                                                    
for i in range(int(input())):                                
  z.add(int(input()))                                        
                                                             
                                                             
for line in lines:                                           
  if len(z & line) == 3:                                     
    print("Yes")                                             
    break                                                    
else:                                                        
  print("No")                                                

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


#define rep(i, j) for(int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define rrep(i, j) for(int i = (j); i >= 0; i--)
#define all(v) v.begin(), v.end()




struct Monoid {
	using T = long long; // ??¢??????????????°????????????
	T operator()(const T& a, const T& b) { return min(a, b); } // ????????????
	static constexpr T identity() { return (1LL << 31) - 1; } // ?????????
};

template<class Monoid>
class SegmentTree {
  public:
    using T = typename Monoid::T;
    Monoid f;
    int n;
    vector<T> data;
    // function<T(T, T) > f; // ?????????
    // T unit;               // f ?????????????????????
    SegmentTree(int nn) {
        n = 1;
        while(n < nn) n *= 2;
        data.resize(2 * n - 1, f.identity());
    }
    //index k in [0, n) ????????? val ?????´??°
    void update(int k, T val) {
        assert(0 <= k and k < n);
        k += n - 1;
        data[k] = val;
        while(k > 0) {
            k = parent(k);
            data[k] = f(data[left_child(k)], data[right_child(k)]);
        }
    }
    // [a, b) 
    int query(int a, int b) {
        assert(0 <= a and a < b and b <= n);
        return query(a, b, 0, 0, n);
    }
  private:
    //[a, b) ????????¨???, now???????????´???, [l,r)?????????????????´???
    T query(int a, int b, int now, int l, int r){
        if( out_of_range(a, b, l, r) ) return f.identity();
        if( within_range(a, b, l, r) ) return data[now];
        else { // cross range
            T vleft = query(a, b, left_child(now), l, (l + r) / 2);
            T vright = query(a, b, right_child(now), (l + r) / 2, r);
            return f(vleft, vright);
        }
    }
    bool out_of_range(int a, int b, int l, int r) { return r <= a or b <= l; }
    bool within_range(int a, int b, int l, int r) { return a <= l and r <= b; }
    int left_child(int i) { return i * 2 + 1; }
    int right_child(int i) { return i * 2 + 2; }
    int parent(int i) { return (i - 1) / 2; }
};

// -----------------------------------------------------------------------


template<class T>
T rmq_op(T a, T b) {
    return min(a, b);
}

template<class T, T INF>
using RangeMinimumQuery = SegmentTree<Monoid>;

/*
template<class T>
class RangeMinimumQuery : public SegmentTree<T> {
  public:
    RangeMinimumQuery(int n) : SegmentTree<T>(n, [](T a, T b){ min(a, b); }, INF) {}
};

template<class T>
class RangeMaximumQuery : public SegmentTree<T> {
  public:
    RangeMaximumQuery(int n) : SegmentTree<T>(n, [](T a, T b){ max(a, b); }, -INF) {}
};

template<class T>
class RangeSumQuery : public SegmentTree<T> {
  public:
    RangeSumQuery(int n) : SegmentTree<T>(n, [](T a, T b){ a + b; }, 0) {}
};

*/


int main() {
    int n, q; cin >> n >> q;
    RangeMinimumQuery<long long, (1LL << 31) - 1> rmq(n);
    rep(i, q) {
        int com, x, y; cin >> com >> x >> y;
        if(com == 0) rmq.update(x, y);
        else cout << rmq.query(x, y + 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 4936
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)  
#define forn(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pp printf("Case %d: \n",t)
const int MAXX=1000005;
const int maxInt = 2147483647;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int n,ans=0;cin >> n;
  int a[20]={0};forn(i,n)cin >> a[i];
  ref(i,1,n-2){
  	if( (a[i]>a[i+1] && a[i]<a[i-1]) || (a[i]>a[i-1] && a[i]<a[i+1]) )++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,w,en=0,flg;
  while(1){
    scanf("%d",&w);
    if(w==-1)break;
    for(i=11,en=1150;i<=w;i++){
      if(i<=20)en+=125;
      else if(i<=30)en+=140;
      else en+=160;
    }
    printf("%d\n",4280-en);
  }
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <vector>

using namespace std;

int main(){

  int n, kin;
  vector <int> k;
  scanf("%d", &n);
  k.push_back(-1);
  for(int i=1;i<=n;++i){
    scanf("%d", &kin);
    k.push_back(kin);
  }
  
  for(int i=1;i<=n;++i){
    printf("node %d: key = %d, ", i, k[i]);
    if(i != 1)printf("parent key = %d, ", k[i/2]);
    if(i*2 < n+1)printf("left key = %d, ", k[i*2]);
    if(i*2+1 < n+1)printf("right key = %d, ", k[i*2+1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2796
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	ll x[n-1];
	for(int i=0;i<n-1;i++)
		x[i]=a[i]^a[i+1];
	ll w=0;
	for(int i=0;i<n-1;i+=2)
		w=w^x[i];
	ll ans[n];
	for(int i=0;i<n;i++)
	{
		ans[i]=a[i]^w;
	}
	for(int i=0;i<n;i++)cout<<ans[i]<<" ";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 7520
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;
    ll n = s.size();

    ll ans = n;
    rep(i, n-1) {
        if(s[i] != s[i+1]) {
            chmin(ans, max(i+1, (n-1)-i));
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int selectionSort(vi& a) {
    int cnt = 0;
    for (int i = 0; i < a.size(); i++) {
        int minj = i;
        for (int j = i; j < a.size(); j++) {
            if (a[j] < a[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(a[i], a[minj]);
            cnt++;
        }
    }
    return cnt;
}

void printvec(vi& x, int size = 0) {
    cout << x.front();
    for (int i = 1; i < (size == 0 ? x.size() : size); i++) {
        cout << " " << x[i];
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vi as;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as.push_back(a);
    }
    int cnt = selectionSort(as);
    printvec(as);
    cout << cnt << endl;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n, m;
  cin >> n >> m;
  priority_queue<int> pq;
  rep(i, 0, n) {
    int a;
    cin >> a;
    pq.push(a);
  }

  rep(i, 0, m) {
    int x = pq.top();
    pq.pop();
    x /= 2;
    pq.push(x);
  }

  ll ans = 0;
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }

  cout << ans << endl;
}


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

int main() {
  int l,sum=0;
  string n; cin >> n;
  l=n.size();
  
  for(int i=0;i<l;i++){
  sum+=n.at(i)-'0';
  }
  
  if(sum%9==0){
  cout << "Yes" <<endl;
  }else{
  cout << "No" << endl;
  }
  
  return 0;
  
  
  
  
}

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

int main(void) {
    int A,B;
    cin >> A >> B;
    A = (A == 1) ? 14 : A;
    B = (B == 1) ? 14 : B;

    if(A > B) {
        cout << "Alice\n";
    } else if(A < B) {
        cout << "Bob\n";
    } else {
        cout << "Draw\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    string a;
    cin >> a;
    int y = (a[0]-'0') * 10 + a[1]-'0';
    int m = (a[2]-'0') * 10 + a[3]-'0';
    if(1 <= y && y <= 12 && 1 <= m && m <= 12) pr("AMBIGUOUS");
    else if(1 <= y && y <= 12) pr("MMYY");
    else if(1 <= m && m <= 12) pr("YYMM");
    else pr("NA");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{

    int input;
    int frenum = 0;
    int data[101] = {0};
    int i;
    
    while (scanf("%d", &input) != EOF) {
        data[input]++;
        if (frenum < data[input]) frenum = data[input];
    }
    for (i = 1; i <= 100; i++) {
        if (frenum == data[i]) {
            printf("%d\n", i);
        }
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//オーバーフローに注意 long long　にする
//'1'+=16;      で大文字Aに
//'大文字'+=32;  で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


 
int main() {
 
  int n;
  cin >> n;
  
  int ans = 0;
  int taka = 0;
  
  vector<int> p(n);
  rep(i,n) {
  cin >>p[i];
  ans+=p[i];
  taka = max(taka, p[i]);
  }

  cout << ans-taka/2 << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll n, b[N];

void solve()
{
    cin >> n;
    for (int i=0; i<n-1; ++i) cin >> b[i];
    ll s=0;
    for (int i=0; i<n-2; ++i) {
        if (b[i]<=b[i+1]) {
            s+=b[i];
        }else{
            s+=b[i+1];
        }
    }nout(s+b[0]+b[n-2]);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}       

Measured memory_bytes: 3656
from collections import deque
S = deque(input())
Q = int(input())
reverse_count = 0
for i in range(Q):
    Q_i = list(input().split())
    if Q_i[0] == "1":
        reverse_count += 1
    elif ((Q_i[1] == "1" and reverse_count % 2 == 0) or
          (Q_i[1] == "2" and reverse_count % 2 == 1)):
        S.appendleft(Q_i[2])
    else:
        S.append(Q_i[2])
if reverse_count%2==1:
    S.reverse()
print("".join(S))

Measured memory_bytes: 8436
#include "bits/stdc++.h"
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++)
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int n;
int bb[10001];
int aa[10001];


signed main(){
    
    cin >> n;
    int p = 0;
    int m = 0;
    rep(i,n)cin >> aa[i];
    rep(i,n)cin >> bb[i];
    rep(i,n){
        int a = aa[i];
        int b = bb[i];
        if(b-a > 0)p += (b-a)/2;
        else m += abs(b-a);    
    }
    if(p >= m)cout << "Yes" << endl;
    else cout << "No" << endl;
    


    
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://apc001.contest.atcoder.jp/tasks/apc001_b

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>

int main(void){
	int i = 0,stack[200],temp;
	char a;
	
	while(i != 101){
		scanf("%c",&a);
		if(a == '\n')
			break;
		if(a == '+'){
			temp = stack[i - 2] + stack[i - 1];
			stack[i - 2] = temp;
			i--;
		}
		if(a == '-'){
			temp = stack[i - 2] - stack[i - 1];
			stack[i - 2] = temp;
			i--;
		}
		if(a == '*'){
			temp = stack[i - 2] * stack[i - 1];
			stack[i - 2] = temp;
			i--;
		}
		if(a == '/'){
			temp = stack[i - 2] / stack[i - 1];
			stack[i - 2] = temp;
			i--;
		}
		if(a >= '0'&&a <= '9'){
			stack[i] = atoi(&a);
			i++;
			scanf("%c",&a);
			while(isspace(a) == 0){
				stack[i - 1] *= 10;
				stack[i - 1] += atoi(&a);
				scanf("%c",&a);
			}
		}
	}
	printf("%d\n",stack[0]);
	return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std; void solve(); int main() {cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); solve();}
using ll = int_fast64_t; using ld = long double;
#define SELECTOR(_1, _2, _3, SELECT, ...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__, _rep1, _rep0)(__VA_ARGS__)
#define _rep0(i, n) for (ll i = 0; i < n; ++i)
#define _rep1(i, k, n) for (ll i = k; i < n; ++i)
#define dump(x) cout << #x << " = " << x << "\n";
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template <typename T> void vecout(const T &v) { for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n")) cout << *it; }

void solve(){
  ll x; cin>>x;
  if(x==7||x==5||x==3) cout<<"YES"<<"\n";
  else cout<<"NO"<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

bool check(int k,vi prea,vi preb,int n,int m,int t)
{
    int sum=0;
    rep(i,0,t+1)
    {
        int a,b;
        a=i;
        b=t-i;
        sum=0;
        if(a<=n)
        {
            sum+=prea[a];
        }
        else continue;
        if(b<=m)
        {
            sum+=preb[b];
        }
        else continue;
        if(sum<=k) return true;
    }
    return false;
}

void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b,c;
    cin>>n>>m>>k;
    vi a(n);
    vi b(m),preb(m+1),prea(n+1);
    rep(i,0,n) cin>>a[i],sum+=a[i],prea[i+1]=sum;
    sum=0;
    rep(i,0,m) cin>>b[i],sum+=b[i],preb[i+1]=sum;
    l=0,r=n+m;
    int mid,ans=0;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(check(k,prea,preb,n,m,mid))
        {
            l=mid+1;
            ans=max(ans,mid);
        }
        else
        {
            r=mid-1;
        }
    }
    cout<<ans;
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 12696
#include<cstdio>
#include<algorithm>
#include<functional>

using namespace std;

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1, 0);
  for (int i = 1; i < N; ++i) {
    int ind;
    cin >> ind;
    ++A.at(ind);
  }
  for (int i = 1; i <= N; ++i) {
    cout << A.at(i) << endl;
  }
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

ll n, p;
string s;

ll f() {
  mod = p;
  mint r = 0;
  vl a(p, 0);
  a[0]++;
  rep2(i, 1, n + 1) {
    mint c = s[n - i] - '0';
    c *= ((mint)10).pow(i - 1);
    r += c;
    a[r.x]++;
  }
  ll res = 0;
  rep(i, p) res += a[i] * (a[i] - 1) / 2;
  return res;
}

ll f2() {
  ll res;
  rep(i, n) {
    int c = s[i] - '0';
    if(c % 2 == 0) res += i + 1;
  }
  return res;
}

ll f5() {
  ll res;
  rep(i, n) {
    int c = s[i] - '0';
    if(c == 0 || c == 5) res += i + 1;
  }
  return res;
}

int main() {
  cin >> n >> p >> s;
  ll ans;
  if(p == 2)
    ans = f2();
  else if(p == 5)
    ans = f5();
  else
    ans = f();
  cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())
#10**N - 8**N
mod = 10**9 + 7
TEN = 1
EIGHT = 1
NINE = 1
for n in range(N):
    TEN *= 10
    EIGHT *= 8
    NINE *= 9#どっちか使わない
    TEN %= mod
    EIGHT %= mod
    NINE %= mod
print((TEN - NINE*2 + EIGHT)%mod)

Measured memory_bytes: 68696
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define long long long

class UnionFind {
public:
  vector<int> par, rank; // parent(negative := it's root and abs-value represents its size), depth
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;  // already belong to same tree
    if(rank[x] < rank[y]){  // y becomes parent node
      par[y] += par[x];
      par[x] = y;
    } else {  // x becomes parent node
      par[x] += par[y];
      par[y] = x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int size(int x){ return -par[find(x)]; }
}; // END class UnionFind

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> u(m),v(m);
  rep(i,m) cin>>u[i]>>v[i];

  UnionFind uf(2*n);
  rep(i,m) u[i]--,v[i]--;
  rep(i,m) uf.unite(u[i]+n, v[i]), uf.unite(u[i], v[i]+n);

  long alone=0;
  long bad=0;
  long good=0;
  set<int> checked;
  rep(i,n) if(checked.count(uf.find(i))==0){//dbg(i);
    if(uf.size(i)==1) alone++;
    else if(! uf.same(i, i+n)) good++;
    else bad++;
    checked.insert(uf.find(i));
    checked.insert(uf.find(i+n));
  }
//  dbg(alone),dbg(good),dbg(bad);

  long ans = alone*n*2L - alone*alone;
  ans += 2L*good*good;
  ans += bad*bad;
  ans += 2L*good*bad;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h> 
using namespace std;
string a,b;
int main()
{
	cin>>a>>b;
	for(int s=0;s<min(a.size(),b.size());s++)
	{
		cout<<a[s]<<b[s];
	}
	if(a.size()!=b.size())
	{
		if(a.size()>b.size())
		{
			for(int s=min(a.size(),b.size());s<a.size();s++)
			{
				cout<<a[s];
			}
		}
		else
		for(int s=min(a.size(),b.size());s<b.size();s++)
		{
			cout<<a[s];
		}
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i,j,H,W,count=1,flag=0;
  while(1)
  {
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)
      break;

    for(i=0;i<H;i++)
    {
      for(j=0;j<W;j++)
      {
        if((i+j)%2==1)
          printf(".");
        else
          printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2052
n,m = map(int,input().split())
li = []
kli = []
for i in range(m):
    s = list(map(int,input().split()))
    k = s[0]
    kli.append(k)
    s.pop(0)
    li.append(s)
p = list(map(int,input().split()))
def judge():
    light = [0]*m
    for i in range(m):
        cnt = 0
        for j in range(kli[i]):
            if switch[li[i][j]-1] == 1:
                cnt += 1
        if cnt%2 == p[i]:
            light[i] = 1
    if sum(light) == m:
        return True
        
ans = 0
for i in range(2**n):
    switch = [0]*n
    for j in range(n):
        if (i>>j)&1:
            switch[n-1-j] = 1
    if judge():
        ans+=1
print(ans)

Measured memory_bytes: 3064
n, m = map(int, input().split())
a = list(map(int, input().split()))

setnum = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6} 
rset = {}
for i in a:
    if i in rset:
        if rset[setnum[i]] > i:
            rset[i] = setnum[i]
    else:
        rset[i] = setnum[i]

rset = sorted(rset.items(), reverse=True)
dp = [0] * (n + 1)
for i in rset:
    if n < i[1]:
        continue
    dp[i[1]] = max(dp[i[1]] , i[0])
    for j in range(i[1], n + 1 - i[1]):
        if dp[j] != 0:
            dp[j + i[1]] = max(dp[j + i[1]], dp[j] * 10 + i[0])
print(dp[-1])

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

int main(){
  long long int   X, Y;
  string S;
  cin >> X >> Y;
  
  if(Y % 2 == 0 && 2 * X <= Y && 4 * X >= Y) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const unsigned int mod = 1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    
    int n,num,val;
    cin >> n;
    ll a[n];
    ll pref[n];
    cin >> num;
    a[0] = num;
    pref[0]= num;
    for(int i = 1; i < n; i++)
    {
        cin >> val;
        val = val % mod;
        a[i] = val;
    }
    for(int i = 0; i < n; i++)
    {
        if(i == 0)
        {
            pref[i] = a[i] % mod;
        }
        else
        {
            pref[i] = (pref[i-1] + a[i]) % mod;
        }
    }
    ll sum = 0;
    for(int i = 0; i < n; i++)
    {
        ll m;
        m = (a[i]*(pref[n-1] - pref[i])) % mod;
        sum += m;
        sum = sum % mod;
    }
    if(sum < 0){
        cout << (sum + mod) << "\n" ;
    }
    else{
        cout << sum << "\n" ;
    }
}


Measured memory_bytes: 6716
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

int n,q;
ll k;
std::vector<int> a();

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

    int n,m; cin >> n >> m;
    std::vector<ll> a(n); rep(i,n) cin >> a[i];

    std::priority_queue<ll> pq;

    rep(i,n) pq.push(a[i]);

    rep(i,m){
        ll x = pq.top();
        ll new_x = x/2;
        pq.pop();
        pq.push(new_x);
    }

    ll price = 0LL;

    rep(i,n){
        price += pq.top();
        pq.pop();
    }
    cout << price << endl;

    return 0;
}

Measured memory_bytes: 2168
# 10**9+7のmodでの逆元を利用した高速組み合わせ数計算。
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


n,k = [int(_) for _ in input().split()] 
mod = 10**9+7 #出力の制限
N = n
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1,k+1):
    ans = (cmb(k-1,i-1,mod) * cmb(n-k+1,i,mod)) % mod
    print(ans)



Measured memory_bytes: 42992
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------
// http://drken1215.hatenablog.com/entry/2019/05/28/124300
// けんちょんさんのUnion Find
struct UnionFind {
    vector<int> par, w;

    UnionFind(int n) : par(n, -1), w(n, 0) { }
    void init(int n) { par.assign(n, -1); w.assign(n, 0); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) {
            ++w[x];
            return false;
        }
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        w[x] += w[y];
        ++w[x];
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }

    int wei(int x) {
        return w[root(x)];
    }
};

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
    a[i]--;
  }
  UnionFind uf(N);
  for(int i=0; i<M; i++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    uf.merge(a[x],a[y]);
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    if(uf.issame(i,a[i])){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int cnt = 0;
    bool alice = false;
    bool bob = false;

    for (int i = 0; i < 100; ++i) {
        if (a == i) alice = true;
        else if (b == i) alice = false;

        if (c == i) bob = true;
        else if (d == i) bob = false;

        if (alice==true && bob==true) ++cnt;
    }

    cout << cnt << endl;

}

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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  if(a > b) {
    cout << "a > b\n";
      }else if(a < b){
    cout << "a < b\n";
      }else{
    cout << "a == b\n";
      }
  return 0;

}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    REP(i, n) cin >> p[i];
    ll cnt = 0;
    REP(i, n-2){
        if(p[i] < p[i+1] && p[i+1] < p[i+2]) cnt++;
        else if(p[i] > p[i+1] && p[i+1] > p[i+2]) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3544
#include<stdio.h>
#include<string.h>
#define M 1128979
#define S 20
char T[M][S];

void insert(long num ,char ch[]){
  int i;
  int h1 = num % M;
  int h2 = 1 + (num % (M-1));
  int h;

  i=0;
  while(i<M){
    h = (h1 + i * h2)%M;
    if(T[h][0]=='\0'){
      strcpy(T[h],ch);
      break;
    }
    i++;
  }
}

int find(long num,char ch[]){
  int i,f=0;
  int h1 = num % M;
  int h2 = 1 + num%(M-1);
  int h;

  i=0;
  while(i<M){
    h = (h1 + i * h2)%M;
    if(strcmp(T[h],ch)==0)return 1;
    else if(strlen(T[h])==0) return 0;
    i++;
  }
    return 0;
}

int main(){
  int n,j,i;
  long num,p;
  char ch[12];
  char com[7];

  for(i=0;i<M;i++){
    for(j=0;j<S;j++){
    T[i][j]='\0';
    }
  }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    scanf("%s",ch);
    num = 0;
    p=1;
    for(j=0;j<strlen(ch);j++){
      if(ch[j]=='A'){
        num+=1*p;
      }else if(ch[j]=='C'){
        num+=2*p;
      }else if(ch[j]=='G'){
        num+=3*p;
      }else if(ch[j]=='T'){
        num+=4*p;
      }
      p*=3;
    }

    if(!strcmp("insert",com)){
      insert(num,ch);
    }else if(!strcmp("find",com)){
      if(find(num,ch)){
        printf("yes\n");
      }else{
        printf("no\n");
      }
    }
  }
   return 0;
}

Measured memory_bytes: 22652
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int  K;
	cin >> K;
	int S = e - a;
	if (S <= K) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256