akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
typedef long long ll;
#define vint vector<int>

int main(){
    int a;
    cin >> a;
    ll sum = 0;
    vint A(a-1);
    rep(i,a-1) cin >> A[i];
    if(a != 2){
      rep(i,a-2) sum += min(A[i],A[i+1]);
      cout << A[0] + sum + A[a-2];
    }
    else cout << A[0] * 2 << endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  ll N, M; cin >> N >> M;

  if (N > M / 2){
    cout << M / 2 << endl;
    return 0;
  }

  ll ans = N; M -= N * 2;
  ans += M / 4;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3596
/********************************************************************************
	
	Code by a weak man named CYJian, and he hopes the code can get more points.

	Algorithm: 

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int MAXN = 360010;

vector<int>to[MAXN];
int used[MAXN];
int col[MAXN];
int sq[MAXN];
int pw[610];
int BigCol;
int Num;

inline void AddEdge(int u, int v) { to[u].push_back(v), to[v].push_back(u); }
inline void dfs(int x, int c) {
	if(col[x] || !used[x]) return ; col[x] = c;
	(BigCol ^ c) && !Num ? (BigCol = c, Num = 1) : (Num += BigCol ^ c ? -1 : 1);
	for(auto u : to[x]) dfs(u, 3 - c);
}

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n = ri, D1 = ri, D2 = ri, N = n * n << 2, M = n << 1;
	memset(sq, -1, sizeof(sq));
	for(int i = 0; i < M; i++) sq[pw[i] = i * i] = i;
	for(int dx = 0; dx < M; dx++) {
		int t = D1 - pw[dx];
		if(t < 0 || sq[t] == -1) continue;
		int dy = sq[t];
		for(int i = dx; i < M; i++) {
			for(int j = dy; j < M; j++) {
				int x = i - dx, y = j - dy;
				AddEdge(i * M + y, x * M + j);
				AddEdge(x * M + y, i * M + j);
			}
		}
	} BigCol = 1;
	for(int i = 0; i < N; i++) used[i] = 1;
	for(int i = 0; i < N; i++) if(!col[i]) dfs(i, 1);
	for(int i = 0; i < N; i++) used[i] = col[i] == BigCol, col[i] = 0;
	for(int i = 0; i < N; i++) to[i].clear();
	for(int dx = 0; dx < M; dx++) {
		int t = D2 - pw[dx];
		if(t < 0 || sq[t] == -1) continue;
		int dy = sq[t];
		for(int i = dx; i < M; i++) {
			for(int j = dy; j < M; j++) {
				int x = i - dx, y = j - dy;
				AddEdge(i * M + y, x * M + j);
				AddEdge(x * M + y, i * M + j);
			}
		}
	} BigCol = 1;
	for(int i = 0; i < N; i++) if(!col[i]) dfs(i, 1);
	for(int i = 0, ct = n * n; i < N && ct; i++) if(col[i] == BigCol) printf("%d %d\n", i / M, i % M), --ct;
	return 0;
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll vs[110][2];
ll dp[110][100100];

void solve() {
    int N, W;
    cin >> N >> W;
    for (ll i = 1; i <= N; ++i) cin >> vs[i][0] >> vs[i][1];
    for (ll i = 0; i <= W; ++i) dp[0][i] = 0;
    for (ll i = 0; i <= N; ++i) dp[i][0] = 0;

    for (ll i = 1; i <= N; ++i) {
        ll* vi = vs[i];
        for (ll w = 1; w <= W; ++w) {
            if (w < vi[0]) dp[i][w] = dp[i - 1][w];
            else dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - vi[0]] + vi[1]);
        }
    }
    cout << dp[N][W] << endl;
}

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


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[200005];
int32_t main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	int i=1;
	for(int j=1;j<=n;j++){
		if(ar[j]==i){
			i++;
		}
	}
	if(i==1) cout<<-1;
	else cout<<n-i+1;
}


Measured memory_bytes: 1792
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int a, b, x;
    cin >> a >> b >> x;

    if (a <= x && x <= a + b) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  char x;
  scanf("%c",&x);
  if(x=='A'){
    printf("T\n");
  }else if(x=='T'){
    printf("A\n");
  }else if(x=='C'){
    printf("G\n");
  }else if(x=='G'){
    printf("C\n");
  }
  return 0;
}

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if(A >= K){
  	cout << K << endl;
  }
  else if(B >= K-A){
  	cout << A << endl;
  }
  else{
  	cout << 2*A + B - K << endl;
  }
}

Measured memory_bytes: 3632
use std::io;

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn main() {
    let s1 = str2vec(&input_line_str());
    let s2 = str2vec(&input_line_str());

    if s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0] {
        println!("YES");
    } else {
        println!("NO");
    }
}

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

int main(){
  int X,Y;cin>>X>>Y;
  int ans = 0;
  if(X<4) ans += (4-X)*100000;
  if(Y<4) ans += (4-Y)*100000;
  if(X*Y==1){ ans+=400000;}
  cout<<ans<<"\n";
}


Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define piiii pair<pair<int, int>, pair<int, int>>


ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

ll dp[300][300];

void solve() {
    ll n;
    cin>>n;
    ll N15=n/15;
    ll N5=n/5;
    ll N3=n/3;
    ll summAll=n*(n+1)/2;
    ll kolvo=15ll*(N15*(N15+1)/2);
    ll kolv1=5ll*(N5*(N5+1)/2);
    ll kolv2=3ll*(N3*(N3+1)/2);
    cout<<summAll-(kolv1+kolv2-kolvo);
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}

Measured memory_bytes: 3616
// https://atcoder.jp/contests/arc064/tasks/arc064_a
// 3-2 反転
// ARC064 C Boxes and Candies
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
#define MAX_N 100005


int main() {
	int n,x;
	ll a[MAX_N];
	cin >> n >> x;
	rep(i,n)cin>>a[i];

	ll cnt = 0;
	rep(i,n-1){
		if(x < a[i]+a[i+1]){
			ll sub = a[i]+a[i+1] - x;
			if(a[i+1]>=sub){
				a[i+1] -= sub;
			}else{
				a[i] -= (sub-a[i+1]);
				a[i+1] = 0;
			}
			cnt += sub;
		}
	}
	cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

#define INF_INT 2147483647

//現状保存用
class status{
public:
    int now, len;
    vector<bool> mem;
    status(){}
    status(int n, int l, vector<bool> m){
        now = n;
        len = l;
        mem = m;
    }
};

queue<status> q;
int G[10][10];
int lenList[10];

void bfs(){
    status st = q.front();
    q.pop();
    
    //行ったことあるフラグ更新
    st.mem[st.now] = false;
    //最短距離の更新
    if(st.len < lenList[st.now]) lenList[st.now] = st.len;
    //行ったことのない場所があればキューに追加
    for(int i = 0; i < 10; i++){
        if(st.mem[i]){
            status add(i, st.len+G[i][st.now], st.mem);
            q.push(add);
        }
    }
}

int main(){
    //入力
    int H,W;
    cin >> H >> W;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> G[i][j];
        }
    }
    
    //初期値を作成
    vector<bool> v;
    for(int i = 0; i < 10; i++) v.push_back(true);
    status st(1, 0, v);
    q.push(st);
    for(int i = 0; i < 10; i++) lenList[i] = INF_INT;
    
    //キューがなくなるまで計算
    while(!q.empty()){
        bfs();
    }
    
    //計算
    int sum = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int kabe;
            cin >> kabe;
            if(kabe != -1) sum += lenList[kabe];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 30368
def popcount(x):
    return bin(x).count('1')
 
def f(x):
    if x == 0:
        return 1
    return f(x%popcount(x))+1
 
n=int(input())
x=input()
xx=int(x,2)
p=x.count('1')
s=xx%(p+1)
if p!=1:
    t=xx%(p-1)
for i in range(n):
    if x[i]=='1':
        if p!=1:
            k=t
            k-=pow(2,n-i-1,p-1) 
            k%=p-1
        else:
            print(0)
            continue
    else:
        k=s
        k+=pow(2,n-i-1,p+1)
        k%=p+1
    print(f(k))

Measured memory_bytes: 9308
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    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;
    }
};
// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};


int main(){
    int n;
    cin >> n;
    vector<P> time;
    rep(i,n){
        ll x,l;
        cin >> x >> l;
        time.pb(mp(l+x,x-l));
        
    }
    SORT(time);
    int ans = 0; ll t = - 1001001001001;
    rep(i,n){
        if( t <= time[i].second){
            ans++;
            t = time[i].first;
        }
    }
    cout << ans;
}



Measured memory_bytes: 2420
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  string s; cin >> s;
  s = "0"s + s;
  int sz = s.size();
  reverse(ALL(s));
  vector<vector<ll> > dp(sz+10, vector<ll>(2, ll(1e18)));
  dp[0][0] = 0;
  rep(i,sz) {
    int d = s[i] - '0';
    rep(j, 10) rep(k, 2) {
      int a = j - k;
      if(a >= d) {
        chmin(dp[i+1][0], dp[i][k] + j + a - d);
      } else {
        chmin(dp[i+1][1], dp[i][k] + j + a - d + 10);
      }
    }
  }
  cout << dp[sz][0] << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 55880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=32;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int k;
		cin>>k;
		n-=k;
	}
	if(n<0)cout<<-1<<endl;
	else cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n;
struct point {
	double x, y;
	bool operator < (point rhs) const {
		return atan2(y, x) < atan2(rhs.y, rhs.x);
	}
} p[N];
double X = 0.0, Y = 0.0, ans = 0.0;
int main () {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%lf%lf", &p[i].x, &p[i].y);
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		int j = i;
		X = 0.0, Y = 0.0;
		do {
			X += p[j].x, Y += p[j].y;
			ans = max(ans, sqrt(X * X + Y * Y));
			j = (j + 1) % n;
		} while (j != i);
	}
	printf("%.15lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
<?php

$x = (int)(trim(fgets(STDIN)));

for ($a = -118; $a <= 119; $a++) {
  for ($b = -119; $b <= 118; $b++) {
    if ($a ** 5 - $b ** 5 === $x) {
      printf("%d %d \n", $a, $b);
      exit;
    }
  }
}


Measured memory_bytes: 16060
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const int MAX_M = 1e5;

int main(void){
    int N, M;
    int X[MAX_M];
    int L[MAX_M];
    int answer;
    
    cin >> N >> M;
    
    if (N >= M) {cout << 0 << endl; return 0;}

    rep(i, M) cin >> X[i];

    sort(X, X + M);

    rep(i, M - 1) L[i] = X[i + 1] - X[i];

    sort(L, L + M - 1);

    answer = X[M - 1] - X[0];

    rep(i, N - 1) answer -= L[M - i - 2];

    cout << answer << endl;

    return 0;
}

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

int main() {
  int x,n;
  int a[5000];
  long int sum,nextsum;
  while(cin >> n) {
    if(n == 0) break;
    for(int i=0;i<n;i++) {
      cin >> x;
      a[i] = x;
    }
    sum = *max_element(a,a+n);
    for(int i=0;i<n;i++) {
      if(a[i] >= 0) {
        nextsum = a[i];
        for(int j=1;j<n-i;j++) {
          nextsum += a[i+j];
          if(nextsum > sum)
            sum = nextsum;
        }
      }

    }
    cout << sum << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

struct way{
	ll a,b,d;
	way(ll x,ll y, ll z){a = x, b = y, d = z;}
};

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

	ll N, M, C; cin >> N >> M >> C;
	ll sum = 0;

	vector<way> w;

	vector<P> G[100005]; // (to, dist)

	for (int i = 0;i < M;i++){
		ll A, B, D; cin >> A >> B >> D;
		G[A].push_back(P(B,D));
		G[B].push_back(P(A,D));
		w.push_back(way(A,B,D));
		sum += D;
	}

	ll d[100005]; fill(d, d+N+5, INT_MAX);
	d[1] = 0;

	priority_queue<P, vector<P>, greater<P> > que; // (dist, node)
	que.push(P(0,1));

	while(que.size()){
		P p = que.top(); que.pop();
		ll now = p.second;
		if(d[now] < p.first) continue;
		for (int i = 0;i < G[now].size();i++){
			ll to = G[now][i].first;
			ll len = G[now][i].second;
			if(d[to] > d[now]+len){
				d[to] = d[now]+len;
				que.push(P(d[to], to));
			}
		}
	}

	vector<P> lis;
	map<ll, ll> mp;
	for (int i = 1;i <= N;i++){
		lis.push_back(P(d[i],i));
	}

	sort(lis.begin(),lis.end());

	for (int i = 0;i < N;i++){
		mp[lis[i].second] = i;
	}

	ll minus[100005]; fill(minus,minus+N+5, 0);

	for (int i = 0;i < M;i++){
		way tmp = w[i];
		minus[max(mp[tmp.a], mp[tmp.b])] += tmp.d;
	}

	ll ans = sum;

	for (int i = 0;i < N;i++){
		sum -= minus[i];
		ans = min(ans, sum+lis[i].first*C);
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 30048
#include "bits/stdc++.h"
#define ll long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define se second
#define fi first
using namespace std;
typedef pair<ll,ll> pll;

const ll N = 1e3+3;
ll n,m,k;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin>>n>>m>>k;
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i*m+j*n-2*i*j==k){
                cout<<"Yes\n";
                return 0;
            }
        }
    }
    cout<<"No\n";
    return 0;
}

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


int main(void) {

	int n;
	int ans;
	bool d = false;
	cin >> n;

	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			ans = 4 * i + 7 * j;
			if (ans == n) {
				d = true;
				break;
			}
		}
	}
	if (d == true) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
n = int(input())

ans = n
for i in range(n+1):
    tmp_ans = 0
    m = i
    while m > 0:
        tmp_ans += m % 6
        m = m // 6
    m = n - i
    while m > 0:
        tmp_ans += m % 9
        m = m // 9

    ans = min(ans, tmp_ans)

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
  string s;
  std::vector<int> v(26);
  std::cin >> s;
  rep(i,x){
    v[i]=0;
  }
  rep(i,s.size()){
    v[(int)s[i]-97]++;
  }
  sort(rall(v));
  std::cout << ((v[0]<=1)?"yes":"no") << '\n';
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
 
N, Q = map(int, input().split())
INF = 2**31-1
 
LV = (N-1).bit_length()
N0 = 2**LV
data = [INF]*(2*N0)
lazy = [None]*(2*N0)
 
def gindex(l, r):
    L = (l + N0) >> 1; R = (r + N0) >> 1
    lc = 0 if l & 1 else (L & -L).bit_length()
    rc = 0 if r & 1 else (R & -R).bit_length()
    for i in range(LV):
        if rc <= i:
            yield R
        if L < R and lc <= i:
            yield L
        L >>= 1; R >>= 1
 
def propagates(*ids):
    for i in reversed(ids):
        v = lazy[i-1]
        if v is None:
            continue
        lazy[2*i-1] = data[2*i-1] = lazy[2*i] = data[2*i] = v
        lazy[i-1] = None
 
def update(l, r, x):
    *ids, = gindex(l, r)
    propagates(*ids)
 
    L = N0 + l; R = N0 + r
    while L < R:
        if R & 1:
            R -= 1
            lazy[R-1] = data[R-1] = x
        if L & 1:
            lazy[L-1] = data[L-1] = x
            L += 1
        L >>= 1; R >>= 1
    for i in ids:
        data[i-1] = min(data[2*i-1], data[2*i])
 
def query(l, r):
    propagates(*gindex(l, r))
    L = N0 + l; R = N0 + r
 
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])
        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s
 
 
answer = []
for q in range(Q):
    t, *cmd = map(int, readline().split())
    if t:
        s, t = cmd
        answer.append(str(query(s, t+1)))
    else:
        s, t, x = cmd
        update(s, t+1, x)
 
write("\n".join(answer))
write("\n")


Measured memory_bytes: 17748
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

const int INF = 2000000000;

int main() {
  int N;
  cin >> N;
  int a[100000];
  int dp[100000];
  rep(i, N) {
    dp[i] = INF;
  }
  rep(i, N) {
    cin >> a[N-1-i];
  }
  rep(i, N) {
    int key = a[i];
    int ind = upper_bound(dp, dp+N, key) - dp;
    dp[ind] = key;
  }
  int ans = lower_bound(dp, dp+N, INF) - dp;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4292
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <cassert>
#include <string.h>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;



//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();
///(10-(n%10))%10  1桁目取得

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て

int gcd(int a,int b);
size_t length(const std::string& str) {
	return str.length();
}
int main() {
	int len,win=0;
	string s;
	cin>>s;
	//cout<<s[0]<<endl;
	len=length(s);

	rep(i,len){
		if(s[i]=='o')
			win++;
	}
	if(8-win<=15-len)
		cout<<"YES"<<endl;
	else{
		cout<<"NO"<<endl;
	}
}




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


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
    let table = read_table();
    println!("{}", if trust(&table) { "Yes" } else { "No" });
}

fn trust(t: &[Vec<i32>]) -> bool {
    // want something like zip
    let t0 = t[0][0];
    let da0 = t[0][1] - t[0][0];
    let da1 = t[0][2] - t[0][1];
    let db0 = t[1][0] - t[0][0];
    let db1 = t[2][0] - t[1][0];
    t[1][1] == t0 + da0 + db0 && t[1][2] == t[1][1] + da1 && t[2][1] == t[1][1] + db1
        && t[2][2] == t[2][1] + da1
}

fn read_table() -> Vec<Vec<i32>> {
    let mut table: Vec<Vec<i32>> = Vec::new();
    for _ in 0..3 {
        table.push(reads(&get_line()));
    }
    table
}

fn get_line() -> String {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp).expect("read error");
    inp.trim().to_string()
}

fn reads<T>(input: &str) -> Vec<T>
where
    T: FromStr,
    T::Err: std::fmt::Debug,
{
    input
        .trim()
        .split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect()
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
long long n, k, c, ans;
int main() {
	cin>>n>>k;
	c = n/k;
	ans += c*c*c;
	if(k%2==0) {
		if(n%k >= k/2) c++;
		ans += c*c*c;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


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

    int t=1,te=0;
    // cin>>t;
    while(t--){
       int k,x;

       cin>>k>>x;

       if(k*500 >=x)printf("Yes\n");
       else{
        printf("No\n");
       } 


        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
    int N, i, j, k, v;
    
    scanf("%d", &N);
    
    int A[N];
    for(i = 0; i < N; i ++) scanf("%d", &A[i]);
    for(i = 0; i < N - 1; i ++) printf("%d ", A[i]);
    printf("%d\n", A[N-1]);
    
    for(i = 1; i < N; i ++) {
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v) {
            A[j+1] = A[j]; 
            j --;
            A[j+1] = v;
        }
        
        for(k = 0; k < N - 1; k ++) printf("%d ", A[k]);
        printf("%d\n", A[N-1]);
        
    }
    return 0;
}

Measured memory_bytes: 1756
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+5+5;

int n,R,C;
struct segment{
	int x,y;
	segment(const int x_=0,const int y_=0){x=x_;y=y_;}
	friend bool operator < (segment a,segment b){
		if (a.x!=b.x)return a.x<b.x;
		return a.y<b.y;
	}
}a[N*2];
int k;

int trs(int x,int y){
	if (x!=0&&x!=R&&y!=0&&y!=C)return -1;
	if (x==0)return y;
	if (y==C)return x+C;
	if (x==R)return R+C*2-y;
	return R*2+C*2-x;
}

int main(){
	R=get();C=get();n=get();
	fo(i,1,n){
		int x1=get(),y1=get(),x2=get(),y2=get();
		int s=trs(x1,y1),t=trs(x2,y2);
		if (s<0||t<0)continue;
		if (s>t)swap(s,t);
		a[++k]=segment(s,t);
		a[++k]=segment(t,s);
	}
	sort(a+1,a+1+k);
	set<int>s;
	s.clear();
	bool ans=1;
	fo(i,1,k)
	if (a[i].y>a[i].x){
		if (s.begin()!=s.end()&&(*s.begin())<a[i].y)ans=0;
		s.insert(a[i].y);
	}
	else
		s.erase(a[i].x);
	if (ans)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 2019;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  int N,M;
  cin>>N>>M;
  int k[M];
  vector<int> s[M];
  int p[M];
  rep(i,M){
    int a;
    cin>>a;
    k[i]=a;
    rep(j,k[i]){
      int b;
      cin>>b;
      s[i].push_back(b);
    }
  }
  rep(i,M){
    int c;
    cin>>c;
    p[i]=c;
  }
  
  int D[N+1];
  
  rep(i,N+1){
    D[i]=0;
  } //syokika
  int count=0;
  for (int bit=0; bit<(1<<N); bit++){
    rep(i,N){
      if(bit&(1<<i)){
        D[i+1]=1;
      }
    }
    bool ok=true;
    rep(i,M){
      int judge=0;
      rep(j,k[i]){
        judge+=D[s[i][j]];
      }
      if(judge%2!=p[i]) ok=false;
    }
    
    if(ok) count++;
    rep1(i,N){
      D[i]=0;
    }
  }
  
  cout<<count<<endl;
}
    
    
        
  

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

const int MAXM = 200;
const int MAXN = 5000;

typedef long long ll;

int N, M;
int lg[MAXN + 5], st[13][MAXM + 5][MAXN + 5];
void get_st() {
	for(int i=2;i<=N;i++)
		lg[i] = lg[i>>1] + 1;
	for(int p=1;p<=M;p++)
		for(int i=1;i<13;i++) {
			int k = (1 << (i - 1));
			for(int j=1;j<=N;j++)
				st[i][p][j] = max(st[i-1][p][j], st[i-1][p][j+k]);
		}
}
ll rmq(int id, int l, int r) {
	int k = lg[r - l + 1], p = (1<<k);
	return max(st[k][id][l], st[k][id][r-p+1]);
}
ll ans, A[MAXN + 5];
void solve(int opl, int opr, int l, int r) {
	if( l > r ) return ;
	int m = (l + r) >> 1, opm = opl;
	ll tmp = 0;
	for(int i=opl;i<=opr&&i<=m;i++) {
		ll x = 0;
		for(int j=1;j<=M;j++)
			x = (x + rmq(j, i, m));
		x -= (A[m] - A[i]);
		if( x > tmp )
			tmp = x, opm = i;
	}
	ans = max(ans, tmp);
	solve(opl, opm, l, m - 1);
	solve(opm, opr, m + 1, r);
}
int main() {
	scanf("%d%d", &N, &M);
	for(int i=2;i<=N;i++) scanf("%lld", &A[i]);
	for(int i=2;i<=N;i++) A[i] += A[i-1];
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++)
			scanf("%d", &st[0][j][i]);
	get_st(), solve(1, N, 1, N);
	printf("%lld\n", ans);
}

Measured memory_bytes: 52224
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <functional>
#include <random> 
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int

#define M_DEBUG 1
#define PI 3.141592653589793

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ull n;
    cin >> n;
    
    ull m = 1000000000000;
    for (ull i = 1; i <= sqrt(n); ++i) {
        if (n % i == 0) 
          if (m > n / i + i) 
            m = n / i + i;
    }

    cout << m - 2 << endl;

    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
import math


def isprime(target):

    dest = int(math.sqrt(target))
    for i in range(2, dest):
        if target % i == 0:
            return False
    return True


def main():

    i = int(input())

    while True:
        if isprime(i):
            print(i)
            break
        else:
            i += 1

    return 0

if __name__ == '__main__':
    main()


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

///////////////////////////
int main() {
  int n,ans=0,k=0;
  cin>>n;
  vector<int> v(n),a(n);
  rep(i,n) a[i]=1;
  rep(i,n) cin>>v[i];
  rep(i,n-1){
    
    if(v[i]==v[i+1]){
      a[k]++;
    }else{
      k++;
    }
    
  }
  rep(i,n){
    ans+=a[i]/2;
    
  }
  
  cout<<ans<<endl;
  
}
///////////////////////////



Measured memory_bytes: 256
import itertools
n, m = map(int, input().split())
P = [input().split() for i in range(m)]
P = list(itertools.chain.from_iterable(P))
ac_list = [0] * n
wa_list = [0] * n
counta = 0
countb = 0
for i in range(1, m * 2, 2):
    if P[i] == "AC" and ac_list[int(P[i - 1])-1] == 0:
        counta += 1
        ac_list[int(P[i - 1])-1] = 1
        countb += wa_list[int(P[i - 1]) - 1]
    elif P[i] == "WA":
        wa_list[int(P[i - 1]) - 1] += 1
    else:
        continue

print(counta, countb)


Measured memory_bytes: 33884
import sys
input = sys.stdin.readline

N, L, T = map(int, input().split())
gap = 0
X = [0] * N
for i in range(N):
    x, w = map(int, input().split())
    x += (-2*w+3) * T 
    gap += x // L
    X[i] = x % L
X.sort()
for i in range(N):
    print(X[(i+gap) % N])

Measured memory_bytes: 8136
#include<bits/stdc++.h>
using namespace std;
const int maxn=55;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n;
struct node{
	int x,y;
}a[maxn];
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i].x=read(),a[i].y=read();
	}
	int ans=n,p,q,tmp;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			p=a[j].x-a[i].x;q=a[j].y-a[i].y;
			if(p==0&&q==0)continue;
			tmp=n;
			for(int k=1;k<=n;k++){
				for(int v=1;v<=n;v++){
					if(a[v].x-a[k].x==p&&a[v].y-a[k].y==q)tmp--;
				}
			}
			ans=min(ans,tmp);
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

long long calc(int n, int c1, int c2, int s1, int s2, const vector<int>& options,
               int d, int nt, int ot) {
  int b1(d-1), a1(d+1), b2(d-1), a2(d+1);
  while (b1 >= 0 && options[b1] != nt) b1--;
  while (b2 >= 0 && options[b2] != ot) b2--;
  while (a1 < n && options[a1] != nt) a1++;
  while (a2 < n && options[a2] != ot) a2++;
  int x1(d-b1-1), y1(a1-d-1), z1(a1-b1-1), x2(d-b2-1), y2(a2-d-1), z2(a2-b2-1);
  int diff1 = z1*(z1+1)/2-x1*(x1+1)/2-y1*(y1+1)/2;
  int diff2 = z2*(z2+1)/2-x2*(x2+1)/2-y2*(y2+1)/2;
  return (long long) diff1 * c1 - (long long) diff2 * c2 + s1 - s2;
}

int main() {
  srand (time(NULL));
  int n;
  cin >> n;
  vector<int> c(26);
  vector<array<int, 26>> s(n);
  
  vector<int> last(26, -1);
  
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1);
    for (int j = 0; j < 26; ++j) {
      neg -= c[j] * (i - last[j]);
    }
    
    int max_score = -1e9;
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    options[i] = test;
    last[test] = i;
  }
  /* reversed: 109149564 */
  /* sorted: 110465449 */
  /* stocahstic */
  
  for (int t = 1; t <= 100000; ++t) {
    int dd = rand() % n;
    int tt = rand() % 26;
    int ot = options[dd];
    if (ot == tt) continue;
    long long ns = calc(n, c[tt], c[ot], s[dd][tt], s[dd][ot],
                        options, dd, tt, ot);
    if (ns > 0) {
      total += ns;
      options[dd] = tt;
    }
  }
  for (const int& i: options) cout << i + 1 << endl;
  
  return 0;
}

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

using namespace std;

const int N = 134567;

int n, a[N];

// comb(a, b  ) = (a!) / (b!     * (a-b)!  )
// comb(a, b+1) = (a!) / ((b+1)! * (a-b-1)!)
// comb(a, b) / comb(a, b+1) = (b+1) / (a-b) >= 1
// b+1 >= a-b
// b*2 >= a-1

// a=9,b=4
// a=10,b=5

int main() {

  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);

  int cur_v = min(a[0], a[n - 1] - a[0]), res = a[0]; 
  for (int i = 1; i < n - 1; ++i) {
    int v = min(a[i], a[n - 1] - a[i]);
    if (v > cur_v) { cur_v = v; res = a[i]; }
  }
  cout << a[n - 1] << " " << res << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string str;
    cin >> str;
    string alphabets("abcdefghijclmnopqrstuvwxyz");
    for(int i=0; i<alphabets.size(); i++){
        if(str.find(alphabets[i]) == string::npos){
            cout << alphabets[i];
            return 0;
        }
    }
    cout << "None";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N;
  int res{};
  for (int i = 0; i < N; ++i) {
    int a, b; cin >> a >> b;
    res += b - a + 1;
  }

  auto ans = res;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
#define dame {puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
template <class T>
map< T, int > prime_factor(T n) {
    map< T, int > ret;
    for(T i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

void Main(){
  ll n;
  cin>>n;
  ll ans = 2*(n/11);
  n%=11;
  if(0<n and n<=6) ans++;
  else if(6<n and n<11)ans+=2;
  cout<<ans<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int n;
int a[3100];

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

    int sum = 0;
    for (int j = 0; j < n; ++j) {
        sum += a[j];
    }
    cout << sum - n << endl;
}


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

using namespace std;

vector<int> make_primes( const int limit ) {
  vector<bool> isPrime( limit + 1 );
  fill( isPrime.begin(), isPrime.end(), true );
  for ( int i = 2; i * i <= limit; i++ ) {
    if ( isPrime[ i ] ) {
      for ( int j = i * i; j <= limit; j += i ) {
	isPrime[ j ] = false;
      }
    }
  }
  vector<int> ans;
  for ( int i = 2; i <= limit; i++ ) {
    if ( isPrime[ i ] ) {
      ans.push_back( i );
    }
  }
  return ans;
}

int main() {
  auto primes = make_primes( 1000000 );
  while( true ) {
    int a, d, n;
    cin >> a >> d >> n;
    if ( a == 0 and d == 0 and n == 0 ) break;
    int count = 0;
    a -= d;
    while( count < n ){
      a += d;
      if ( binary_search( primes.begin(), primes.end(), a ) ) {
	count++;
      }
    } 
    cout << a << endl;
  }
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    vector<int> v(N), c(N);
    for(int i=0; i<N; i++) cin >> v[i];
    for(int i=0; i<N; i++) cin >> c[i];

    int ans = 0;
    for(int i=0; i<N; i++) if(v[i]-c[i] > 0) ans += v[i]-c[i];

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	const int C[]={1000,500,100};
	int A,B;
	while(cin>>A>>B){
		if(A==0&&B==0)break;
		int coins[3];
		for(int i=0,remain=B-A;i<3;++i){
			coins[i]=remain/C[i];
			remain%=C[i];
		}
		for(int i=2;i>=0;--i)cout<<coins[i]<<((i==0)?"\n":" ");
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<cstdlib>

#define MAX 2000001
#define INF 2000000001

int H = 0; // the number of elements

void P(){
  printf("\ntest\n");
}

void swap(int *a, int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

int parent(int i){
  if(i == 1) return 0;
  return i / 2;
}

int left(int i){
  if(i * 2 > H) return 0;
  return i * 2;
}

int right(int i){
  if(i * 2 + 1 > H) return 0;
  return i * 2 + 1;
}

void PrintAllElement(int *A){
  int i;
  for(i = 1; i < H + 1; i++){
    printf("node %d: key = %d, ", i, A[i]);
    if(parent(i)){
      printf("parent key = %d, ", A[parent(i)]);
    }
    if(left(i)){
      printf("left key = %d, ", A[left(i)]);
    }
    if(right(i)){
      printf("right key = %d, ", A[right(i)]);
    }
    printf("\n");
  }
}

void maxHeapify(int *A, int i){
  int l, r, largest;
  l = left(i);
  r = right(i);
  // choose the largest node from [i], [l] and [r]
  if(l != 0 && A[l] > A[i]){
    largest = l; 
  }else{
    largest = i;
  }
  if(r != 0 && A[r] > A[largest]){
    largest = r;
  }

  // when largest = r or l
  if(largest != i){
    swap(&A[i], &A[largest]);
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int *A){
  for(int i = H/2; i > 0; i--){
    maxHeapify(A, i);
  }
}

int heapExtractMax(int *A){
  int max;
  if(H < 1){
    printf("error...\n");
    return 0;
  }
  max = A[1];
  A[1] = A[H];
  H--;
  maxHeapify(A, 1);
  return max;
}

void heapIncreaseKey(int *A, int i, int key){
  if(key < A[i]){
    printf("Error!\n");
    return;
  }
  A[i] = key;
  while(i > 1 && A[parent(i)] < A[i]){
    swap(&A[i], &A[parent(i)]);
    i = parent(i);
  }
}

void maxHeapInsert(int *A, int key){
  H++;
  A[H] = -INF; // used in heapIncreaseKey, line 1
  heapIncreaseKey(A, H, key);
}

int main(){
  int i, A[MAX], key;
  char c[7];

  while(scanf("%s", c) != EOF){

    if(c[0] == 'i'){
      scanf("%d", &key);
      maxHeapInsert(A, key);
    }else if(c[0] == 'e' && c[1] == 'x'){
      printf("%d\n", heapExtractMax(A));
    }else{
      #ifdef D
      for(i = 1; i < H+1; i++){
	printf(" %d", A[i]);
      }
      printf("\n");
      #endif
      return 0;
    }
    
  }

}



Measured memory_bytes: 6484