akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int dp[1000010][2];
signed main()
{
    string s;
    cin >> s;
    int n = (int)s.size();
    vector<int> v((int)s.size());
    for (int i = 0; i < 1000010; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for (size_t i = 0; i < n; i++)
    {
        v[i] = s[i] - '0';
    }
    v.push_back(0);
    for (int i = 0; i < n+1; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            if(j==0){
                dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + v[i]);
                dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + 10 - v[i]);
            }
            else{
                dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + v[i] + 1);
                dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 10 - v[i] - 1);
            }
        }
    }
    cout << min(dp[n + 1][0], dp[n + 1][1]) << endl;

    return 0;
}

Measured memory_bytes: 34180
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
//using
using namespace std;
/*using vi = vector <int>;
using vs = vector <string>;
using vc = vector <char>;*/
//vector<vector<char> > hyou(N, vector<char>(N));
//define
#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
//グローバル変数宣言
int a=0,b=0,c=0,d=0,n;

signed main(){
   cin>>n;
   if(n<2)print(1)
   else if(n<4)print(2)
   else if(n<8)print(4)
   else if(n<16)print(8)
   else if(n<32)print(16)
   else if(n<64)print(32)
   else if(n<128)print(64)
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>		
using namespace std;
int main (void){
	int N;
	string s;
	cin >> N;

	for(int i=0; i < N; i++){
		
		cin >> s;
		if(s =="Y"){
		cout << "Four" << endl;	
		break;
		}
	
	}
	if(s !="Y"){
		cout << "Three" << endl;
		}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin>>a>>b;
    string s = to_string(a) + to_string(b);
    int sq = stoi(s);
    int sqt = sqrt(sq);
    if(sqt*sqt==sq)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3740
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int cars[20010];

int main() {
	int a,b;
	while(a=in(),b=in(),a||b){
		a+=b;
		int i;
		for(i=0;i<a;i++){
			cin>>cars[i];
		}
		cars[a]=0;
		sort(cars,cars+a+1);
		int mx=0;
		for(i=0;i<a;i++){
			chmax(mx,cars[i+1]-cars[i]);
		}
		cout<<mx<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(M);

  for(int i = 0; i < M; i++){
    cin >> X.at(i);
  }

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

  vector<int> dis;
  for(int i = 0; i < M-1; i++){
    dis.push_back(X.at(i+1) - X.at(i));
  }

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

  int ans = 0;

  for(int i = 0; i < M - N; i++){
    ans += dis.at(i);
  }

  cout << ans << endl;

}


Measured memory_bytes: 1276
//全然閃かない・・・
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int P[200001], P1[200001];
int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}
int Find1(int A) {
	if (P1[A] < 0) return A;
	return P1[A] = Find1(P1[A]);
}

ll root[200001];
ll tmp[200001];
void pakuripair_sort(int N, ll A[], int B[]) {
	const int b = 6;
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			P1[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = P1[i];
		}
	}
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int N = getint(), K = getint(), L = getint();
	rep1(i, N) P[i] = -1;
	rep(i, K) {
		int p = getint(), q = getint();
		p = Find(p);
		q = Find(q);
		if (p != q) {
			if (P[p] > P[q]) swap(p, q);
			P[p] += P[q];
			P[q] = p;
		}
	}

	rep1(i, N) P1[i] = -1;
	rep(i, L) {
		int p = getint(), q = getint();
		p = Find1(p);
		q = Find1(q);
		if (p != q) {
			if (P1[p] > P1[q]) swap(p, q);
			P1[p] += P1[q];
			P1[q] = p;
		}
	}
	rep1(i, N) root[i] = Find(i) + ((ll)Find1(i) << 18);

	rep1(i, N) P[i] = i;
	pakuripair_sort(N, root + 1, P + 1);

	int mae = 1;
	for (int i = 2; i <= N; i++) {
		if (root[mae] != root[i]) {
			for (int j = mae; j < i; j++) P1[P[j]] = i - mae;
			mae = i;
		}
	}
	for (int j = mae; j <= N; j++) P1[P[j]] = N + 1 - mae;

	rep1(i, N) putint(P1[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 6016
N = gets.chomp.to_i
word = gets.chomp.split("")
first_half = []
result = true

if N % 2 == 0
  (N/2).times do |e|
    first_half << word[e]
  end
  (N/2).times do |e|
    if word[N/2+e] != first_half[e]
      result = false
  	end
  end
else
  result = false
end

if result == true
  puts "Yes"
else
  puts "No"
end

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

l=list(map(int,input().split()))

s=sum(l)
d={}
for i in l:
    d[i]=d.get(i,0)+1

for i in range(int(input())):

    a,b=map(int,input().split())
    if a not in d:
        print(s)
        continue
    
    x=d[a]
    d[a]-=x
    d[b]=d.get(b,0)+x
    s-=x*a
    s+=x*b
    print(s)


Measured memory_bytes: 21060
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	int ans = n*800 - n/15*200;
	
	cout << ans << "\n";

	return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
int ans;
int n,m,q;
vector<int> a,b,c,d;

void dfs(vector<int> arr, int pos) {
    if(arr.size()==n) {
        int total_cost=0;
        for(int i=0;i<q;i++) {
            if(arr[b[i]]-arr[a[i]]==c[i]) {
                //cout<<"this is necessary info: "<<endl;
                //cout<<arr[b[i]]<<' '<<arr[a[i]]<<' '<<c[i]<<endl;
                //cout<<'[';
                //for(int z=0;z<arr.size();z++) {
                //    cout<<arr[z]<<',';
                //}
                //cout<<']'<<endl;
                total_cost+=d[i];
            }
        }
        ans=max(ans,total_cost);

        return;
    }

    for(int i=pos;i<=m;i++) {
        arr.push_back(i);



        dfs(arr,i);
        arr.pop_back();
    }

    return;
}

int main() {
    fast_io;
    cin>>n>>m>>q;

    a=b=c=d=vector<int>(q);

    for(int i=0;i<q;i++) {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }

    ans=0;

    vector<int> arr(0);

    dfs(arr,1);
    cout<<ans<<endl;
}




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

#define N 100001

typedef long long ll;

using namespace std;

int n, m;
vector<int> g[N];
vector<int> tree[N];
ll in[N];
ll out[N];

void dfs1(int u, int p)
{
	in[u] = 1;
	for (int v : g[u])
	{
		if (v == p)
			continue;
		tree[u].push_back(v);
		dfs1(v, u);
		in[u] = (in[u] * ((1 + in[v]) % m)) % m;
	}
}

void dfs2(int u, int p)
{
	int len = tree[u].size();
	ll left[len], right[len];
	for (int i = 0; i < len; i++)
	{
		int v = tree[u][i];
		left[i] = (i == 0) ? ((1 + in[v]) % m) : ((left[i - 1] * ((1 + in[v]) % m)) % m);
	}
	for (int i = len - 1; i >= 0; i--)
	{
		int v = tree[u][i];
		right[i] = (i == len - 1) ? ((1 + in[v]) % m) : ((((1 + in[v]) % m) * right[i + 1]) % m);
	}
	//cout << u << " " << len << endl;
	for (int i = 0; i < len; i++)
	{
		int v = tree[u][i];
		//cout << len << " ";
		//cout << ((i == 0 ? 1 : (1 + left[i - 1])) * ((i == len - 1 ? 1 : (1 + right[i + 1])) * (1 + out[p]))) << endl;
		out[v] = (1 + ((((i == 0 ? 1 : left[i - 1]) * (i == len - 1 ? 1 : right[i + 1])) % m) * (out[u])%m) % m) % m;
		dfs2(v, u);
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n - 1; i++)
	{
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs1(1, 0);
	out[1] = 1;
	dfs2(1, 0);
	for (int i = 1; i <= n; i++)
	{
		//cout << in[i] << " " << out[i] << " ";
		cout << (in[i]*out[i]) % m << endl;
	}
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S;
	cin >> S;
	S[3] = '8';
	cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long
using namespace std;
int main() {
   ll n;
   cin>>n;
   if(to_string(n).size()==1){
     cout<<n<<"\n";
   }

  else if(to_string(n).size()==2){
     cout<<"9"<<"\n";
   }
else if(to_string(n).size()==3){
  cout<< 10+n-100<<"\n";
   }

else if(to_string(n).size()==4){
  cout<<909<<"\n";
   }
   else if(to_string(n).size()==5){
  cout<<909 + n - 10000 + 1<<"\n";
   }
 else if(to_string(n).size()==6){
  cout<<909 + 90000 <<"\n";
   }

}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from functools import reduce

def gcd(n, m):
    if n > m: # require n <= m
        n, m = m, n
    o = m % n
    if o == 0:
        return n
    else:
        m = n
        n = o
        return gcd(n, m)

def gcds(ns):
    return reduce(gcd, ns)

def solve(N: int, A: "List[int]"):
    """
    [思考]
    体力最小のものを Amin とおく．
    すると，試行の結果体力が Amin より小さくなる可能性がある場合はそれが答え，さもなくば Amin が答え．
    問題はその可能性をどう探索するか．
    """
    print(gcds(A))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15880
from sys import stdin, setrecursionlimit
# input = stdin.readline
setrecursionlimit(200000)
N, M = map(int, input().split())
# d = [0] * (N + 1)
adj = [[] for _ in range(N + 1)]
for _ in range(M):
    x, y = map(int, input().split())
    adj[x].append(y)
    # d[y] += 1

dp = [-1] * (N + 1)


def lp(x: 'int') -> 'int':
    if dp[x] >= 0:
        return dp[x]
    else:
        dp[x] = 0
        for y in adj[x]:
            dp[x] = max(dp[x], lp(y) + 1)
        return dp[x]


print(max(lp(i) for i in range(1, N + 1)))


Measured memory_bytes: 118092
#include<iostream>
#include<cstdio>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>
#include<utility>
#include<cctype>
#include<bitset>
#include<stdio.h>
#include<time.h>
#define ll long long
#define mp make_pair
using namespace std;
const int INF=1e9;
/*--------main part---------*/
inline int read(){
    int X = 0,w = 0 ;
	char ch = 0;
    while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
    while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
    return w ? -X : X;
}
int n;
int dat[10005];
bool vis[10005];
vector<int> ans[10005];
bool edg[2005][2005];
int a[100005];
void dfs(int x)
{
	if(vis[x])
		return;
	vis[x]=true;
	vector<int> chi;
	for(int i=0;i<n;i++)
	{
		if(edg[x][i] and !vis[i])
		{
			chi.push_back(i);
			dfs(i);
		}
	}
	memset(a,0,sizeof(a));
	ans[x].push_back(dat[x]);
	while(true)
	{
		int mx=0;
		int pos;
		for(int i=0;i<chi.size();i++)
		{
			if(a[i]<ans[chi[i]].size() and ans[chi[i]][a[i]]>mx)
			{
				mx=ans[chi[i]][a[i]];
				pos=i;
			}
		}
		if(mx==0)
			break;
		ans[x].push_back(mx);
		a[pos]++;
	}
}
int gcd(int x,int y)
{
	if(x==0)
	{
		return y;
	}
	else
	{
		return gcd(y%x,x);
	}
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>dat[i];
	}
	sort(dat,dat+n);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<i;j++)
		{
			if(gcd(dat[i],dat[j])!=1)
			{
				edg[i][j]=edg[j][i]=true;
			}
		}
		edg[i][n]=edg[n][i]=true;
	}
	dfs(n);
	for(int i=1;i<=n;i++)
	{
		cout<<ans[n][i]<<' ';
	}
	return 0;
}

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


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;


int N, M;
vector<int> S, T;
mint dp[2100][2100];
mint sdp[2100][2100];

int main() {
    cin >> N >> M;
    S.resize(N), T.resize(M);
    for (int i = 0; i < N; ++i) cin >> S[i];
    for (int i = 0; i < M; ++i) cin >> T[i];

    memset(dp, 0, sizeof(dp));
    memset(sdp, 0, sizeof(dp));
    dp[0][0] = 1;
    sdp[1][1] = 1;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= M; ++j) {
            if (i == 0 && j == 0) continue;
            if (i-1 >= 0 && j-1 >= 0 && S[i-1] == T[j-1]) {
                dp[i][j] = sdp[i][j];
            }
            sdp[i+1][j+1] = sdp[i+1][j] + sdp[i][j+1] - sdp[i][j] + dp[i][j];
        }
    }
    cout << sdp[N+1][M+1] << endl;
}

Measured memory_bytes: 72560
# 貪欲法 + 山登り法 + 3点スワップ操作
import time
s__ = time.time()
limit = 1.9
#limit = 10

from numba import njit
import numpy as np

d = int(input())
cs = list(map(int, input().split()))
cs = np.array(cs, dtype=np.int64)
sm = [list(map(int, input().split())) for _ in range(d)]
sm = np.array(sm, dtype=np.int64)

@njit('i8(i8[:], i8)', cache=True)
def total_satisfaction(ts, d):
    ls = np.zeros(26, dtype=np.int64)
    s = 0
    for i in range(d):
        t = ts[i]
        t -= 1
        s += sm[i][t]
        ls[t] = i + 1

        dv = cs * ((i+1) - ls)
        s -= dv.sum()
    return s

@njit('i8[:]()', cache=True)
def greedy():
    ts = np.array([0] * d, dtype=np.int64)
    for i in range(d):
        mx = -1e10
        mxt = None
        for t in range(1, 26+1):
            ts[i] = t
            s = total_satisfaction(ts, i + 1)
            if s > mx:
                mx = s
                mxt = t
        ts[i] = mxt
    return ts

@njit('i8(i8, i8[:])', cache=True)
def loop(mxsc, ts):
    it = 50
    rds = np.random.randint(0, 6, (it,))
    rdd = np.random.randint(1, d, (it,))
    rdq = np.random.randint(1, 26, (it,))
    rdx = np.random.randint(1, 12, (it,))
    rdy = np.random.randint(1, 12, (it,))
    c1 = 0
    c2 = 3
    for i in range(it):
        bk1 = 0
        bk2 = 0
        bk3 = 0
        if rds[0] <= c1:
            # trailing
            di = rdd[i]
            qi = rdq[i]

            bk1 = ts[di]
            ts[di] = qi
        elif rds[0] <= c2:
            # swap
            di = rdd[i]
            xi = rdx[i]
            if di + xi >= d:
                xi = di - xi
            else:
                xi = di + xi
            
            bk1 = ts[di]
            bk2 = ts[xi]
            ts[di] = bk2
            ts[xi] = bk1
        else:
            # triswap
            di = rdd[i]
            xi = rdx[i]
            if di + xi >= d:
                xi = di - xi
            else:
                xi = di + xi
            yi = rdy[i]
            if xi + yi >= d:
                yi = xi - yi
            else:
                yi = xi + yi
            
            bk1 = ts[di]
            bk2 = ts[xi]
            bk3 = ts[yi]
            ts[di] = bk2
            ts[xi] = bk3
            ts[yi] = bk1

        sc = total_satisfaction(ts, d)

        if sc > mxsc:
            #print(mxsc, '->', sc)
            mxsc = sc
        else:
            # 最大値を更新しなかったら戻す
            if rds[0] <= c1:
                ts[di] = bk1
            elif rds[0] <= c2:
                ts[di] = bk1
                ts[xi] = bk2
            else:
                ts[di] = bk1
                ts[xi] = bk2
                ts[yi] = bk3

    return mxsc

ts = greedy()
mxsc = total_satisfaction(ts, d)
mxbk = mxsc

s_ = time.time()
mxsc = loop(mxsc, ts)
e_ = time.time()

consume = s_ - s__
elapsed = e_ - s_
#print('consume:', consume)
#print('elapsed:', elapsed)

if consume < limit:
    lp = int((limit - consume) / elapsed)
    #print('loop', lp)
    for _ in range(lp):
        mxsc = loop(mxsc, ts)

for t in ts:    print(t)
#print(mxbk, mxsc)
#print(time.time() - s__)


Measured memory_bytes: 123600
#include<iostream>
#include<string>
#include<vector>

int main () {
    int a[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            std::cin >> a[i][j];
        }
    }

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if(b[i] == a[j][k]) {
                    a[j][k] = -1;
                }
            }
        }
    }

    bool f = false;
    for (int i = 0; i < 3; i++) {
        int cnt = 0;
        for (int j = 0; j < 3; j++)
        {
            if(a[i][j] == -1) {
                cnt++;
            }
        }

        if(cnt == 3) {
            f = true;
        }
    }

    for (int i = 0; i < 3; i++)
    {
        int cnt = 0;
        for (int j = 0; j < 3; j++)
        {
            if (a[j][i] == -1)
            {
                cnt++;
            }
        }

        if (cnt == 3)
        {
            f = true;
        }
    }

    if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1 ) {
        f = true;
    }

    if (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1)
    {
        f = true;
    }

    std::string ans = f ? "Yes" : "No";
    std::cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,mod=1e9+7;
typedef long long ll;
int mul(int a,int b){return (ll)a*b%mod;}
int qpow(int a,int b){
	int ret=1;
	for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);
	return ret;
}
int n;
int f[1000010];
char s[1000010];
int cnt[N];


int main()
{
	cin >> n;
	scanf("%s",s+1);
	for(int j=1;j<=n;j++){
		cnt[s[j]-'a']++;
	}
	int ans=1;
	for(int i=0;i<26;i++){
		ans=mul(ans,cnt[i]+1);
	}
	ans--;
	if(ans<0)ans+=mod;
	cout << ans <<endl;
}

Measured memory_bytes: 384
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(x, y, a, b, c) = in.readLine().split("\\s+").map(_.toInt)
    val ps = in.readLine().split("\\s+").map(_.toLong).sorted(Ordering[Long].reverse)
    val qs = in.readLine().split("\\s+").map(_.toLong).sorted(Ordering[Long].reverse)
    val rs = in.readLine().split("\\s+").map(_.toLong).sorted(Ordering[Long].reverse)

    out.println((ps.take(x) ++ qs.take(y) ++ rs).sorted(Ordering[Long].reverse).take(x + y).sum)
    out.flush()
  }
}


Measured memory_bytes: 96792
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> ar[i];
  for(int i = 1; i <= n; i++)
    for(int j = i + 1; j <= n; j++)
      ans += ar[i] * ar[j];
  cout << ans;
}

Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

        int N; cin >> N;

        vector<long long> a(N, 0);

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

        vector<long long> s(N+1, 0);

        for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

        std::sort(s.begin(), s.end());

        long long count = 0;

        long long res = 0;


        for (int i = 0; i < N+1; ++i){
                if (i > 0) {
                        if (s[i] == s[i-1]) {
                                count += 1;
                                res += count;
                        }
                        else count = 0;
                }
        }

        cout << res << endl;
}


Measured memory_bytes: 6400
# h wの読み込み
h, w = map(int, input().split())
# 行列作成
mat = [input() for _ in range(h)]

# #が含まれていない行を削除
[mat.remove(row) for row in mat[::-1] if ("#" not in row)]
# #が含まれている列のインデックスを取得
showCol = [i for i in range(w) if "#" in [row[i] for row in mat]]

# 表示
print("\n".join(["".join([row[c] for c in showCol]) for row in mat]))


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>

int main() {
    int N, M, L, R;
    std::cin >> N >> M;
    int L_max = 1;
    int R_min = N;
    for (int i = 0; i < M; ++i) {
        std::cin >> L >> R;
        L_max = std::max(L_max, L);
        R_min = std::min(R_min, R);
    }
    int ans = std::max(0, R_min - L_max + 1);
    std::cout << ans << "\n";
    return 0;
}


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

int main()
{
	int Nn,Mn;
  	cin>>Nn>>Mn;
  	int i,sumn=0,A[Mn];
  	for(i=0;i<Mn;i++)
    {
    	cin>>A[i];
      	sumn=sumn+A[i];
    }
  	if(sumn<=Nn)
    {
      cout<<Nn-sumn;
    }
  	else
    {
    	cout<<-1;
    }
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(n) for(int i=0;i<(n);i++)
#define rep1(n) for(int i=1;i<=(n);i++)
#define all(n) n.begin(),n.end()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define pb push_back
ll dp[70000];
ll mat[18][18];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        cin>>mat[i][j];
      }
    }
    int all = 1<<n;

    for(int i=0;i<all;i++){
        ll tmp = 0;
        for(int j=0;j<n;j++){
          if(!(i&(1<<j)))continue;
          for(int k=j+1;k<n;k++){
            if(!(i&(1<<k)))continue;
            tmp += mat[j][k];
          }
        }
        dp[i] = tmp;
        for(int mas =(i-1)&i;mas;mas=(mas-1)&i){
           //cout<<i<<" "<<mas<<'\n';
           dp[i] = max(dp[i],dp[mas]+dp[i^mas]);
        }
    }

    cout<<dp[all-1]<<'\n';


}


Measured memory_bytes: 768
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner (System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a>=-1000&&a<=1000&&b>=-1000&&b<=1000)
		{
			if(a<b)
				System.out.println("a < b");
			else if(a>b)
				System.out.println("a > b");
			else System.out.println("a == b");
		
		}
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

vector<int> d{-1,0,1};

int main() {
    ll H,W,N; cin >> H >> W >> N;
    map<pair<ll,ll>, int> G;
    REP(i,N){
        ll x,y; cin >> x >> y;
        x--;
        y--;
        REP(j,3){
            REP(k,3){
                G[{x+d[j],y+d[k]}] ++;
            }
        }
    }
    vector<ll> ans(10);
    ans[0] = (W-2)*(H-2);
    for(auto g: G){
        int a,b;
        a = g.first.first;
        b = g.first.second;
        if(1<=a && a<=H-2 && 1<=b && b<=W-2){
            ans[g.second]++;
            ans[0]--;
        }
    }
    REP(i,10){
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int count = 0;
  int m = N;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    m = min(m, A);
    if(A==m) count++;
  }
  cout << count << endl;
}

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

int main()
{
  int n, r;
  while(cin >> n >> r and (n > 0 or r > 0)){
    vector<int> card(n);
    for (int i = 0; i < n; i++) {
      card[i] = n - i;
    }
    for (int i = 0; i < r; i++) {
      int p, c;
      cin >> p >> c;
      rotate(card.begin(),card.begin() + p - 1, card.begin() + p + c - 1);
    }
    cout << card[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int; 

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

LL n;
bool sym(LL x) {
  LL k = n;
  while (k >= x) {
    if (k % x == 0) {
      k /= x;
    } else {
      k -= x;
    }
  }
  return (k == 1);
}

LL pom(LL x) {
  LL ret = 0;
  for (LL i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      ++ret;
      debug(i);
      if (x / i != i) {
        debug(x / i);
        ++ret;
      }
    }
  }
  return ret + 2;
}

int main() {
  cin >> n;
  LL res = 0;
  if (n == 2) {
    cout << 1 << endl;
    return 0;
  }
  for (LL i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      LL pom = n;
      while (pom % i == 0) {
        pom /= i;
      }
      if (pom > i && pom % i == 1) {
        // debug(i);
        ++res;
      }
      if (pom == 1) {
        ++res;
      }
    } else {
      // if (n % i == 1) {
      //   debug(i);
      //   ++res;
      // }
    }
  }
  // int res2 = 0;
  // for (int i = 2; i <= n; ++i) {
  //   if (sym(i) == 1) {
  //     int kkk = i;
  //     debug(kkk);
  //     ++res2;
  //   }
  // }
  debug(res, pom(n - 1));
  cout << pom(n - 1) + res << endl;
  // assert(pom(n - 1) + res == res2);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,a,i,j;
    int x[7];
    while(1){
        scanf("%d",&n);
        if(n==0){
            break;
        }
        for(j=0;j<7;j++){
            x[j]=0;
        }
        for(i=0;i<n;i++){
        scanf("%d",&a);
        if(a<10){
            x[0]++;
        }else if(a<20){
            x[1]++;
        }else if(a<30){
            x[2]++;
        }else if(a<40){
            x[3]++;
        }else if(a<50){
            x[4]++;
        }else if(a<60){
            x[5]++;
        }else{
            x[6]++;
        }
    }
    for(j=0;j<7;j++){
      printf("%d\n",x[j]);
    }
  }
  return 0;
}


Measured memory_bytes: 1984
#include<cstdio>
#include<vector>

using namespace std;

int main(void)
{
	vector<int> ans;
	int N;
	vector<int> b;
	int tmp;
	int i, j;
	bool failed_flag = false;

	// 入力を基に数列bを作成する
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &tmp);
		b.push_back(tmp);
	}

	// 
	for (j = 0; j < N; j++) {
		for (i = b.size() - 1; i >= 0; i--) {
			if (b[i] == i + 1) {
				ans.push_back(b[i]);
				b.erase(b.begin() + i);
				break;
			}
		}
		if (i == -1) {
			failed_flag = true;
		}
	}

	if (failed_flag == false) {
		for (i = N - 1; i >= 0; i--) {
			printf("%d\n", ans[i]);
		}
	}
	else {
		printf("-1\n");
	}
		
	return 0;
}

Measured memory_bytes: 384
package main
import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func main() {
	sc.Split(bufio.ScanWords)
	N, S := nextInt(), nextLine()
	if N % 2 != 0 {
		fmt.Println("No")
	} else {
		for i := 0; i < N / 2; i++ {
			if S[i] != S[i+N/2] {
				fmt.Println("No")
				break
			}
			if i == N / 2 - 1 {
				fmt.Println("Yes")
			}
		}
	}
}

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

int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = k < a ? k : a;
  int l = k - a - b;
  if (l > 0)
  {
    ans -= l;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
n = int(raw_input())

d = [0 for i in range(n)]
f = [0 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
st = [0 for i in range(n)]
t = [0]

def DFS_visit(s):
    st[s] = 1
    t[0] += 1
    d[s] = t[0]
    for e in range(n):
        if M[s][e] == 1 and st[e] == 0:
            DFS_visit(e)
    st[s] == 2
    t[0] += 1
    f[s] = t[0]

def DFS():
    for s in range(n):
        if st[s] == 0:
            DFS_visit(s)
    for s in range(n):
        print'{0} {1} {2}'.format(s+1, d[s], f[s])
    
for i in range(n):
    G = map(int, raw_input().split())
    for j in range(G[1]):
        M[G[0]-1][G[2+j]-1] = 1

DFS()

Measured memory_bytes: 6480
S=input()

flag_1=0
for i in range(int(len(S)/2)):
    if S[i]==S[len(S)-i-1]:
        flag_1+=1
        
if flag_1==int((len(S)-1)/2):
    if S[int(len(S)/2)-1]==S[0] and S[int(len(S)/2)+1]==S[len(S)-1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,x,a=0,b=0,c=0;
    cin>>n;

    map<int,int> m,m2;

    for(int i=1; i<=n; i++){
        cin>>x;
        if(i&1)
            m[x]++;
        else m2[x]++;

    }
    for(auto it: m){
        if(it.second>a){
            a = it.second;
            b = it.first;
        }
    }
    for(auto it: m2){
        if(it.second>c && it.first!=b){
            c = it.second;
        }
    }
    int ans = n-(a+c);

    a=b=c=0;

    for(auto it: m2){
        if(it.second>a){
            a = it.second;
            b = it.first;
        }
    }
    for(auto it: m){
        if(it.second>c && it.first!=b){
            c = it.second;
        }
    }

    cout<<min(ans,n-(a+c))<<endl;
    return 0;
}

Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int a;
    string s;
    cin >> a >> s;
    int b = 0;
    [&] {
        rep(i, sz(s)) {
            if (s[i] == '.') {
                b = stoi(s.substr(0, i));
                b *= 100;
                b += stoi(s.substr(i + 1));
                return;
            }
        }
        b = stoi(s);
        b *= 100;
    }();
    cout << a * b / 100 << endl;
}

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

Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    int a, b, c, d;
    int ans = 0;
    cin >> a >> b >> c >> d;
    ans = min(b, d) - max(a, c);
    if(ans < 0) {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
#define chmin(a,b) a=min(a,b);
typedef long long ll;

using namespace std;
#define N 200010
ll n,d[N],t,e;
ll BN(ll key){
    ll l=-1,r=n,m=(l+r)/2;
    for(;l<r-1;m=(l+r)/2){
	if(d[m]*2<key)l=m;
	else r=m;
    }
    return l;
}
ll f[N],g[N];
int main(){
    cin>>n>>e>>t;
    lol(i,n)cin>>d[i];
    lol(i,N)f[i]=1e18; f[0]=0,g[0]=-2*d[0];
    for(ll i=1;i<=n;i++){
	ll surf=BN(d[i-1]*2-t);
	ll res=1e17;
	if(surf+1<i)chmin(res,f[surf+1]+t);
	if(~surf)chmin(res,g[surf]+2*d[i-1]);
	f[i]=res;
	g[i]=min(g[i-1],f[i]-2*d[i]);
    }
    cout<<f[n]+e<<endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int f[100][14], p[100][15];
    rep(i, n) {
        rep(j, 10) {
            cin >> f[i][j];
        }
    }
    rep(i, n) {
        rep(j, 11) {
            cin >> p[i][j];
        }
    }

    int res = -(1 << 30);
    for(int b = 1; b < (1 << 10); b++) {

        int ans = 0;
        rep(i, n) {

            int cnt = 0;
            rep(j, 10) {
                if( (b >> j & 1) && f[i][j] ) {
                    cnt++;
                }
            }

            ans += p[i][cnt];
        }

        if(res < ans) {
            res = ans;
        }
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 1000000000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 150001
const int LG = 22;

int power(int x,int y)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2);
    p = (p * p);
 
    return (y%2 == 0)? p : (x * p);
}

#undef int
int main()
{
#define int long long int

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
	
	int n,p;
	cin>>n>>p;
	int c=1;

	for(int i=2;i*i<=p;i++)
	{
		
		int oo;
		oo=(double)log(p)/(double)log(i);

		if(oo<n) break;


		if(p%i==0 && p%power(i,n)==0)
		{
			if(power(i,n)<=p) c=i;
			else break;

		}
	}
//	cout<<power(c,n)<<' ';
	if(n==1) cout<<p<<endl;
	else cout<<c<<endl;


return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
int a,b,c,d;
int e,f,g,h;
signed main(){
    cin>>a>>b>>c>>d;
    int n=c-a,m=d-b;
    e=c-m;
    f=d+n;
    g=e-n;
    h=f-m;
    cout<<e<<" "<<f<<" "<<g<<" "<<h<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll n,k, a[200];
ll dp[1000000][110], pref[1000000];

ll sum(int l, int r)
{
  if(l <= 0)
    return pref[r];
  return ((pref[r] - pref[l-1]) % mod + mod) % mod;
}

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

  for(int i = 0; i < n; i++)
    dp[0][i] = 1;

  for(int cand = 1; cand <= k; cand++)
    dp[cand][0] = a[0] < cand ? 0 : 1;

  pref[0] = dp[0][0];
  for(int j = 1; j <= k; j++)
    pref[j] = (pref[j-1] + dp[j][0]) % mod;
  
  for(int i = 1;i < n; i++)
    {
      for(int cand = 1; cand <= k; cand++)
	dp[cand][i] = sum(cand - a[i], cand);
      
      pref[0] = dp[0][i];
      for(int j = 1; j <= k; j++)
	pref[j] = (pref[j-1] + dp[j][i]) % mod;
    }
  
  cout << dp[k][n-1];
  return 0;
}


Measured memory_bytes: 89088
# x_(i+1) = x_i * r - D を x_(2010)まで計算し、出力する
# 単純に上の式でループを回すだけ
r,d,x = map(int,input().split()) 
x_i = [x]*11 # x_(2000~2010)
for i in range(1,11,1):
  x_i[i] = x_i[i-1]*r - d
  print(x_i[i])

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };



int S[20010];

int main() {
	int N;
	cin >> N;
	if (N == 3) {
		cout << 2 << " " << 5 << " " << 63 << endl;
		return 0;
	}
	if (N == 4) {
		cout << 2 << " " << 5 << " " << 20 << " " << 63 << endl;
		return 0;
	}
	else {
		S[0] = 2; S[1] = 3; S[2] = 9; S[3] = 6;
		int cnt =4;
		FOR(i, 4, N) {
			while (cnt % 2 != 0 && cnt % 3 != 0)cnt++;
			if (cnt == 6)cnt = 8;
			if (cnt == 9)cnt = 10;

			S[i] = cnt;
			cnt++;
		}
		ll sum = 0;
		REP(i, N)sum += S[i];
		if (sum % 6 == 1)S[2] = 29996;
		if (sum % 6 == 2)S[3] = 29998;
		if (sum % 6 == 3)S[2] = 30000;
		if (sum % 6 == 4)S[3] = 29996;
		if (sum % 6 == 5)S[2] = 29998;
		REP(i, N) {
			cout << S[i] << " ";
		}
	}
}

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

int a[12] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

int main() {
    int x, y;
    cin >> x >> y;

    if (a[x-1] == a[y-1]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int count = 0;
  for(int i = 0; i < n; i++)
  {
    int l, r;
    cin >> l >> r;
    count += (r - l) + 1;
  }
  cout << count << endl;
}

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

const int MOD1=1000000007;
const int MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const int dx[]={0,1,0,-1,1,-1,1,-1};
const int dy[]={1,0,-1,0,1,1,-1,-1};

#define unless(a) if(!(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(n);i++)
#define bitrep(i,s,n) for(int i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
long long cutup(long long a,long long b){return (a+b-1)/b;}
long long popcnt(long long a){return __builtin_popcountll(a);}
template<class T,class U> inline bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template<class T,class U> inline bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

struct edge{long long to,cost;};
struct edge2{long long from,to,cost;};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x;
    cin>>x;
    cout<<cutup(x,11)*2-(int)(x%11<=6&&x%11!=0)<<endl;
}

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

int main() {
    int N;
    int prev = 0;
    long long ans = 0;
    cin >> N;
    while(N--) {
        int curr;
        cin >> curr;
        if(curr < prev) {
            ans += (prev - curr);
        } else {
            prev = curr;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3636