akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int dp[110][404][110];
int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  rep(i, 0, N) cin >> w[i] >> v[i];
  int b = w[0] - 1;
  rep(i, 0, N) w[i] -= b;
  rep(i, 0, N) rep(j, 0, 400) rep(k, 0, N + 1){
    chmax(dp[i + 1][j][k], dp[i][j][k]);
    if(j + w[i] <= 400)
      chmax(dp[i + 1][j + w[i]][k + 1], dp[i][j][k] + v[i]);
  }
  int ans = 0;
  rep(i, 0, 404) rep(j, 0, N + 1) {
    if(i + (ll)j * b > (ll)W) continue;
    chmax(ans, dp[N][i][j]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18560
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-k),i))
print(dp[n-1])


Measured memory_bytes: 53216
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

const ll mod = 1e9+7;

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

int main(){
    ll n,k;
    cin >> n>>k;
    vector<ll> di(k+1,0);
    
    
    for (ll i=1; i<=k; i++){
        di[i] = modpow( k/i, n, mod);
    }
    
    
    for (int i=k; i>0;i--){
        for (int j=2*i; j<=k; j+=i){
            di[i] += mod-di[j];
            if (di[i]<0) di[i] += mod;
            di[i] %= mod;
        }
    }
    
    //for (auto x:di) cout<<x<<" ";
    ll ans=0;
    for(int i=1; i<=k;i++){
        ans = ( ans+ i*di[i]) % mod;
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3888
#include<cstdio>
#define ljm 998244353
#define MAXN 200005
#define MAXM 1000006
#define endl putchar('\n')

int g[MAXM],f[MAXM],prime[MAXM],iv[MAXM];
bool vis[MAXM];


inline int max(int a,int b) {return a<b?b:a;}
int Mod(int a) {return a<ljm?a:a-ljm;}
long long fast_pow(long long a,int b)
{
	a%=ljm;
	long long ans=1;
	while(b) {
		if(b&1) ans=ans*a%ljm;
		b>>=1; a=a*a%ljm; 
	}
	return ans;
}
long long inv(int n)
{
	if(iv[n]) return iv[n];
	else return iv[n]=fast_pow(n,ljm-2);
}
void init(int n)
{
	static int cnt=0;
	long long k;
	g[1]=1;
	for(int i=2;i<=n;++i) {
		if(!vis[i]) prime[++cnt]=i,g[i]=inv(i)*(1ll-i+ljm)%ljm;
		for(int j=1;j<=cnt && (k=(long long)i*prime[j])<=n;++j) {
			vis[k]=true;
			if(i%prime[j]) g[k]=(long long)g[i]*g[prime[j]]%ljm;
			else {
				g[k]=(long long)g[i]*inv(prime[j])%ljm;
				break;
			}
		}
	}
	for(int i=1;i<=n;++i) {
		//if(!f[i]) continue; /* f[i]定义时并没有要求 i 一定在数列 {an} 中，所以这句不能写。 */
		for(int j=i<<1;j<=n;j+=i) f[i]=Mod(f[i]+f[j]);
	}
}
int read()
{
	char ch=getchar();int x=0;
	while(ch<'0' || ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') x=(x*10)+(ch^48),ch=getchar();
	return x;
}
int main()
{
	int n,s,m,ans;
	n=read();
	m=0;
	s=0;
	for(int i=1,a;i<=n;++i) {
		a=read();
		f[a]=Mod(f[a]+a);
		s=Mod(s+a);
		m=max(m,a);
	}
	init(m);
	/*for(int i=1;i<=m;++i) {
		printf("%d ",g[i]);
	}endl;
	for(int i=1;i<=m;++i) {
		printf("%d ",f[i]);
	}endl;*/
	ans=0;
	for(int i=1;i<=m;++i) {
		ans=(ans+(long long)g[i]*f[i]%ljm*f[i])%ljm;
	}
	//printf("%d\n",ans);
	printf("%lld",(ans-s+ljm)*inv(2)%ljm);
	return 0;
} 

Measured memory_bytes: 14608
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    ll k;
    cin >> k;
    ll cnt = 0;
    while (a >= b) {
        b *= 2;
        ++cnt;
    }
    while (b >= c) {
        c *= 2;
        ++cnt;
    }
    if (cnt <= k) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
	long long int test=1;
	//cin>>test;
	while(test--){
	    int n,m;
	    cin>>n>>m;
	    int a[m];
	    long int sum=0;
	    for(int i=0;i<m;i++){cin>>a[i];sum+=a[i];}
	    if(sum>n)cout<<"-1"<<endl;
	    else if(sum==n)cout<<"0"<<endl;
	    else cout<<n-sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 3624
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<char, int> mp;
    for(int i = 0; i < 4; i++){
        char c; cin >> c;
        mp[c]++;
    }
    cout << (mp.size() == 2 && mp.begin()->second == 2 && mp.rbegin()->second == 2 ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 888
N, K = [int(x) for x in input().split()]

def main():
    divisible = []
    indivisible = []
    for n in range(1, N + 1):
        if n % K == 0:
            divisible.append(n)
        else:
            indivisible.append(n)

    divisible_ans = len(divisible) ** 3

    passed = list(filter(lambda n: (n % K) * 2 == K, indivisible))
    indivisible_ans = len(passed) ** 3

    # print("({}, {})".format(divisible_ans, indivisible_ans))

    print(divisible_ans + indivisible_ans)

if __name__ == "__main__":
    main()


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> A(H);
  for(int i=0;i<H;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if((i!=0)&&(j!=0)){
        if((A.at(i-1).at(j)=='#')&&(A.at(i).at(j-1)=='#')){
          cout << "Impossible" << endl;
          return 0;
        }
      }
      if((i!=H-1)&&(j!=W-1)){
        if((A.at(i+1).at(j)=='#')&&(A.at(i).at(j+1)=='#')){
          cout << "Impossible" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Possible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define f first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
 
 
using namespace std;
 
const int N = 2e5 + 123;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const int M = 210;


ll n, q;
char a[N], s[N], d[N];


bool checkleft(ll x) {
	ll curpos = x;
	for (int i = 1; i <= q; i++) {
		if (curpos == 0 || curpos == n + 1)
			break;
		if (a[curpos] == s[i]) {
			if (d[i] == 'L')
				curpos--;
			else
				curpos++;
		}		
	}
	return (curpos == 0);
}


bool checkright(ll x) {
	ll curpos = x;
	for (int i = 1; i <= q; i++) {
		if (curpos == 0 || curpos == n + 1)
			break;
		if (a[curpos] == s[i]) {
			if (d[i] == 'L')
				curpos--;
			else
				curpos++;
		}		
	}
	return (curpos == n + 1);
}


int main() {
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
//	freopen("input.txt", "r", stdin);
	cin >> n >> q;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= q; i++)
		cin >> s[i] >> d[i];
	ll L = 1, R = n, M, a1 = 0, a2 = n + 1;
	while (L <= R) {
		M = (L + R) / 2;
		if (checkleft(M)) {
			a1 = max(a1, M);
			L = M + 1;
		} else {
			R = M - 1;
		}
	}
	L = 1; R = n;
	while (L <= R) {
		M = (L + R) / 2;
		if (checkright(M)) {
			a2 = min(a2, M);
			R = M - 1;
		} else {
			L = M + 1;
		}
	}
	a2 = n - a2 + 1;
	cout << n - a1 - a2;
	return 0;
}

Measured memory_bytes: 896
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>

using namespace std;

const int MAX_N = 10000;
const int MAX_K = 10;

int N, K;
int D[MAX_K];

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

    cin >> N >> K;

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

    int cost = N;
    while (true) {
        int a = cost;
        bool canpay = true;
        while (a >= 1) {
            int p = a / 10;
            int r = a - 10 * p;
            for (int i = 0; i < K; i++) {
                if (r == D[i]) {
                    canpay = false;
                    break;
                }
            }
            if (!canpay)
                break;
            a = p;
        }
        if (canpay) {
            break;
        }
        cost++;
    }

    cout << cost << "\n";

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int mod=998244353;
const int MN=3005;
int A,B,C,D,f[MN][MN][2];
bool vis[MN][MN][2];
int dfs(int n,int m,int k){
	if(vis[n][m][k])return f[n][m][k];
	vis[n][m][k]=true;
	if(A==n&&B==m)return f[n][m][k]=!k;
	if(A==n)return f[n][m][k]=1ll*(!k)*dfs(n,m-1,0)*n%mod;
	if(B==m)return f[n][m][k]=1ll*(!k)*dfs(n-1,m,0)*m%mod;
	if(!k){
		reg int res=1ll*dfs(n-1,m,0)*m%mod;
		res=(res+1ll*dfs(n,m-1,1)*(n-1)+dfs(n,m-1,0))%mod;
		return f[n][m][0]=res;
	}
	if(k)return f[n][m][1]=(dfs(n,m-1,0)+1ll*dfs(n,m-1,1)*(n-1))%mod;
}
int main(){
	scanf("%d%d%d%d",&A,&B,&C,&D);
	printf("%d\n",dfs(C,D,0));
	return 0;
}

Measured memory_bytes: 92232
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    fastio
    ll h,n,sum=0;
    cin>>h>>n;
    REP(i,0,n)
    {
        ll temp;
        cin>>temp;
        sum+=temp;
    }
    if(sum>=h)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int S;
    int h;
    int m;
    int s;

    scanf("%d\n", &S);
    h = S / 3600;
    m = (S / 60);
    m = m - (h * 60);
    s = S - (h * 3600) - (m * 60);

    printf("%d:%d:%d\n", h, m, s);
    return 0;
}

    

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

const int N = 220000;

int L[N], R[N], id[N];
long long C[N], t[N];

void add(int u, long long w) {
	for (; u; u -= u & -u) t[u] = min(t[u], w);
}

long long get(int u) {
	long long ret = LLONG_MAX;
	for (; u < N; u += u & -u) ret = min(ret, t[u]);
	return ret;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) cin >> L[i] >> R[i] >> C[i];
	for (int i = 0; i < m; i++) id[i] = i;
	sort(id, id + m, [&](int u, int v) {
		if (L[u] != L[v]) return L[u] < L[v];
		return R[u] < R[v];
	});
	for (int i = 0; i < N; i++) t[i] = LLONG_MAX;
	add(1, 0);
	for (int i = 0; i < m; i++) {
		int u = id[i];
		int st = L[u], en = R[u]; long long w = C[u];
		long long now = get(st);
		if (now != LLONG_MAX) add(en, now + w);
	}
	long long ans = get(n);
	if (ans == LLONG_MAX) ans = -1;
	cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 5120
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 1e9+7;
const ll INF= 1e18;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

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

vector<ll>v;
vector<ll>::iterator it;
map<ll,ll>mp;

void primeFactors(ll n)  
{  
    while (n % 2 == 0)  
    {  
        mp[2]++;
        n = n/2;  
    }  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            mp[i]++;
            n = n/i;  
        }  
    }  
    if (n > 2){ 
        mp[n]++; 
    } 
}  

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    #ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("out.tex", "w", stdout);
    #endif

    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll a,b;
        cin>>a>>b;
        for(ll x=0; x<=a; x++){
            if(b==4*x+2*(a-x)){
                cout<<"Yes\n";
                return 0;
            }
        }
        cout<<"No\n";
        mp.clear();  
        v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

Measured memory_bytes: 3668
def main():
    w = input()
    
    w_dic = dict()
    for i in w:
        w_dic[i] = w_dic.get(i, 0) + 1
    
    for i in w_dic:
        if w_dic[i] % 2 == 1:
            print("No")
            break
            
    else:
        print("Yes")
        
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
# AOJ 0557: A First Grader
# Python3 2018.6.30 bal4u

p = [[0 for j in range(21)] for i in range(2)]
n = int(input())
d = list(map(int, input().split()))
p[0][d[0]] = 1
s = d[n-1]
for i in range(1, n):
	x = d[i];
	for j in range(21): p[i&1][j] = 0
	for j in range(21-x): p[i&1][j+x] += p[1-(i&1)][j]
	for j in range(x, 21): p[i&1][j-x] += p[1-(i&1)][j];
print(p[n&1][s])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

ll dp[1<<16], cost[1<<16];

int main() {
    ll N;
    cin >> N;
    vvll a(N, vll(N));
    rep(i, N) rep(j, N) cin >> a[i][j];
    rep(bit, 1<<N) {
        rep(i, N) {
            if(!(bit>>i&1)) continue;
            rep(j, N) {
                if(!(bit>>j&1)) continue;
                if(i >= j) continue;
                cost[bit] += a[i][j];
            }
        }
    }

    dp[0] = 0;
    for(ll bit = 1; bit < 1<<N; bit++) {
        for(ll t = bit; t > 0; t = (t-1)&bit) {
            chmax(dp[bit], dp[bit - t] + cost[t]);
        }
    }
    cout << dp[(1<<N)-1] << endl;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <vector>
#define N 100002
#define p push_back
#define m make_pair
#define b begin()
#define sz size()
#define s second
#define f first
#define e end()
#define rx r[0]
#define ry r[1]
using namespace std;
typedef pair<int,int> P;
 
int main(){
  int n,w,h,x,y,ra,be,en,flag[2],k[2][N],t[2][N];
  vector<P> r[2];
  cin>>n>>w>>h;
  while(n--){
    cin>>x>>y>>ra;
    int xmax=x+ra,xmin=x-ra,ymax=y+ra,ymin=y-ra;
    if(xmax>w) xmax=w;
    if(xmin<0) xmin=0;
    if(ymax>h) ymax=h;
    if(ymin<0) ymin=0;
    rx.p(m(xmin,xmax));
    ry.p(m(ymin,ymax));
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<N;j++) k[i][j]=0;
    for(int j=0;j<r[i].size();j++) k[i][r[i][j].f]++,k[i][r[i][j].s]--;
    t[i][0]=k[i][0];
    for(int j=1;j<N;j++) t[i][j]=t[i][j-1]+k[i][j];
  }
  flag[0]=flag[1]=1;
  for(int i=0;i<w;i++)
    if(!t[0][i]) flag[0]=0;
  for(int i=0;i<h;i++)
    if(!t[1][i]) flag[1]=0;
  if(flag[0]||flag[1]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 4496
/*{{{*/
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

typedef long long ll;
typedef std::pair<int, int> pii;

std::string Name = __FILE__;
std::string iput = Name.substr(0, Name.length() - 4) + ".in";
std::string oput = Name.substr(0, Name.length() - 4) + ".out";

template <class T> inline bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }

template <class T> inline T &read(T &x)
{
    static int f;
    static char c; 
    for (f = 1; !isdigit(c = getchar()); ) {
        if (c == '-')
            f = -1;
    }
    for (x = 0; isdigit(c); c = getchar()) {
        x = x * 10 + c - 48;
    }
    return x *= f;
}
 
template <class T> inline void write(T x, const char p = '\n')
{
    static int top;
    static int s[30];
    if (x < 0) {
        x = -x;
        putchar('-');
    }
    do s[++ top] = x % 10 + 48;
    while (x /= 10);
    while (top)
        putchar(s[top --]);
    putchar(p);
}
/*}}}*/
 
const int maxn = 1e5 + 5;
 
int n;
int x;
int a[maxn];



void exec()
{
    read(n);
    read(x);
    for (int i = 1; i <= n; ++ i) read(a[i]);
    long long ans = 1e18;
    for (int i = 0; i < n; ++ i) {
        long long now = (long long)i * x;
        static pii q[maxn];
        int front = 1, rear = 0;
        for (int j = n + 1 - i; j <= n; ++ j) {
            while (front <= rear && q[rear].first >= a[j]) -- rear;
            q[++ rear] = pii(a[j], j - n);
        }
        for (int j = 1; j <= n; ++ j) {
            while (front <= rear && q[front].second < j - i) ++ front;
            while (front <= rear && q[rear].first >= a[j]) -- rear;
            q[++ rear] = pii(a[j], j);
            now += q[front].first;
        }
        chkmin(ans, now);
    }
    write(ans);
}

/*{{{*/
int main() 
{
    if (fopen(iput.c_str(), "r") != NULL) {
        freopen(iput.c_str(), "r", stdin);
        freopen(oput.c_str(), "w", stdout);
    }

    exec();

    fclose(stdin);
    fclose(stdout);

    return 0;
}
/*}}}*/




Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    String s = sc.next();
    if (s.length() <= k) {
      System.out.println(s);
    } else {
      System.out.println(s.substring(0, k) + "...");
    }
  }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if (a<=b){
    for (int i=0; i<b; i++){
      cout << a;
    }
  }
  else{
    for(int i=0; i<a; i++){
    cout << b;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long a[1000000],b[1000000];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    b[0]=a[0];
    for(int i=0;i<n;i++)
    {
        b[i]=b[i-1]+a[i];
    }
    int cnt=0;
    for(int i=n-1;i>=0;i--)
    {
        if(a[i]<=2*b[i-1]) ++cnt;
        else
        {
            break;
        }
    }
    printf("%d\n",cnt+1);
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>

using namespace std;

int main(void){
    int num;
    int count;
    while(cin >> num){
        count = 0;
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                for(int k=0;k<10;k++){
                    for(int l=0;l<10;l++){
                        if(num == i + j + k + l) count++;
                    }
                }
            }
        }
        cout << count << "\n";
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
 
const int N = 5e5 + 5;
const int mod = 1e9+7;
const ll INF = (ll)1e18;

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
 
    int n;
    cin >> n;
    vector<int> v(n+1, 1e9), dp(n+1, 1e9);
    cin >> v[1];
    dp[1] = 0;
    for(int j = 2; j <= n; j++){
        cin >> v[j];
        dp[j] = min(dp[j-1]+abs(v[j]-v[j-1]), dp[j-2]+abs(v[j]-v[j-2]));
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	s = list(S())
	t = list(S())
	count = 0
	for i in range(len(s)):
		if s[i] != t[i]:
			count += 1
	print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 29944
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	S := ReadInt()
	y2 := (S + 1e9 - 1) / 1e9
	x2 := 1e9*y2 - S
	fmt.Println(0, 0, x2, y2, int(1e9), 1)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}


Measured memory_bytes: 1844
// AOJ 1237: Shredding Company
// 2017.10.16 bal4u@uu

#include <stdio.h>
#include <string.h>

int calc(char *s, char *cut, int w)
{
	int i, k = 0, sum = 0;
	for (i = 0; i <= w; i++) {
		k = 10*k + (s[i] & 0xf);
		if (cut[i]) sum += k, k = 0;
	}
	return sum + k; 
}

int main()
{
	int t, i, j, k, w, lim, max, many;
	char s[8], cut[6], ans[6];

	while (scanf("%d%s", &t, s) && t > 0) {
		w = strlen(s)-1, lim = 1 << w;
		for (max = 0, i = 0; i < lim; i++) {
			memset(cut, 0, sizeof(cut));
			for (j = 0; j <= w; j++) if ((i >> j) & 1) cut[j] = 1;
			k = calc(s, cut, w);
			if (k <= t && k > max) {
				max = k, many = 0;
				memcpy(ans, cut, sizeof(ans)); 
			} else if (k == max) many = 1;
		}
		if (max == 0) puts("error");
		else if (many) puts("rejected");
		else {
			printf("%d ", max);
			for (j = 0; j <= w; j++) { putchar(s[j]); if (ans[j]) putchar(' ');	}
			putchar('\n');
		}
    }
	return 0;
}

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

using namespace std;

int main()
{
    int bx,ex,by,ey;
    scanf("%d%d%d%d",&bx,&by,&ex,&ey);
    int nx = bx,ny = by;
    while(nx < ex)
    {
        nx ++;
        printf("R");
    }
    while(ny < ey)
    {
        ny ++;
        printf("U");
    }
    nx = ex,ny = ey;
    while(nx > bx)
    {
        nx --;
        printf("L");
    }
    while(ny > by)
    {
        ny --;
        printf("D");
    }
    nx = bx,ny = by;
    printf("D");
    ny --;
    while(nx < ex)
    {
        nx ++;
        printf("R");
    }
    printf("R");
    while(ny < ey)
    {
        ny ++;
        printf("U");
    }
    printf("LU");
    nx = ex,ny = ey;
    ny ++;
    while(nx > bx - 1)
    {
        nx --;
        printf("L");
    }
    while(ny > by)
    {
        ny --;
        printf("D");
    }
    printf("R\n");
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

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

func main() {
	t := nextString()
	fmt.Println(strings.Replace(t, "?", "D", -1))
}

Measured memory_bytes: 2796
#include<iostream>

using namespace std;

#define Free -1
#define N_free 1
#define N 8

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool p[N][N];
void clear(){
  for(int i=0;i<N;i++){
    row[i]=Free;
    col[i]=Free;
  }
  for(int i=0;i<2*N-1;i++){
    dpos[i]=dneg[i]=Free;
}
}

void print(){
  for(int i=0;i< N;i++){
    for(int j=0; j<N;j++){
      if(p[i][j]== true){
	if(row[i]!= j){
	  return;
	}
      }
    }
  }
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	if(row[i]== j){
	  cout<<"Q";
	}
	else cout<<".";
      }
      cout<<endl;
    }
  }

  void recursive(int i){

    if(i==N){
      print();
      return ;
    }

    for(int j=0;j<N ;j++){
      if(col[j]== N_free || dpos[i+j]== N_free|| dneg[i-j+N-1]==N_free){
	continue;
      }
      row[i]=j;
      col[j]=dpos[i+j]=dneg[i-j+N-1]=N_free;
      recursive(i+1);
      row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]= Free;
    }
  }

int main(){
  clear();
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      p[i][j]=false;
    }
  }
  int n=0;
  cin>> n;
  for(int i=0; i< n;i++){
    int r,c;
    cin>> r>> c;
    p[r][c]=true;
  }
  recursive(0);

  return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  REP(i, n) cin >> p[i];
  SORT(p);
  int ans = 0;
  REP(i, k) ans += p[i];
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

using lint = int64_t;
#define bit(n) ((lint)1 << n);
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

class IoSetup {
    public:
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
        cerr << fixed << setprecision(12);
    }
} iosetup;

int main() {
    string s;
    cin >> s;
    bool good = true;
    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i + 1]) {
            good = false;
            break;
        }
    }

    if (good) {
        cout << "Good" << endl;
    } else {
        cout << "Bad" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vector<T>>;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    ull X; cin >> X;

    ull m = 100;
    ull c = 0;
    while (m < X)
    {
        m *= 1.01;
        ++c;
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define MOD 1000000007
#define N 1000006
#define INF 1000000000000000000
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define randright srand(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;
int my_rand(){ int a=rand(); int b=rand(); return a*(RAND_MAX+1)+b; }

void solve(){
    int n;
    cin>>n;
    if(n%2==0){
        cout<<(n/2)-1<<"\n";
    }
    else{
        cout<<(n/2)<<"\n";
    }
}

signed main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll n;cin>>n;
    repl(i,1,n+1){
        ll p=i;
        if(i%3==0){
            cout<<" "<<i;
            continue;
        }
        while(p){
            if(p%10==3){
                cout<<" "<<i;
                break;
            }
            p/=10;
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3112
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn = 100 + 10;

int n, m, a[maxn];
int main() {
	scanf("%d%d", &n, &m);
	int cnt = 0;
	for(int i = 1;i <= m;i ++) scanf("%d", &a[i]), cnt = cnt + ((a[i] & 1) ? (1) : (0));
	if(cnt > 2) puts("Impossible");
	else {
	  for(int i = 1;i <= m;i ++) {
	    if(a[i] & 1) {
	      if(a[1] & 1) swap(a[i],a[m]);
	      else swap(a[1],a[i]);
			}
		}
		for(int i = 1;i <= m;i ++) printf("%d ", a[i]);
		puts("");
		if(m == 1) a[++ m] = a[1], a[1] = 0;
		a[1] ++;
		a[m] --;
		if(!a[m]) m --;
		printf("%d\n", m);
		for(int i = 1;i <= m;i ++) printf("%d ", a[i]);
		puts("");
	}
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}

// head


int m,n,k,res,tmp,tmp2,tmp3,h,w,x,y;
VI a;
deque<PII> que;
string s;
//VI b;
vector<PII> g[2100600];
int b[2100000];
int c[210000] = {};
int za[55][2];
set<int> ch;



signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  if (k == 1){cout << 0 << '\n';exit(0);}
  cout << n-k << '\n';

  


}

Measured memory_bytes: 51200
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,x,y) for(int i=x;i<y;i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int a[101][101];

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    string s;
    cin>>s;
    int ans=0;
    for(int i=1;i<s.size();i++){
        if(s[i-1]!=s[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N;
  cin>>N;
  vector<vector<int> > data (2,vector<int>(N,0));
  vector<pair<int,int> > vp(N);
  for (int i = 0; i < N; i++)
  {
    int X,Y;cin>>X>>Y;
    data[0][i] = X;
    data[1][i] = Y;
    vp[i].first = X + Y;
    vp[i].second = i;
  }
  sort(ALL(vp));
  reverse(ALL(vp));
  vector<int> point (2,0);
  for (int i = 0; i < N; i++)
  {
    point[i%2] += data[i%2][vp[i].second];
  }
  cout<<point[0] - point[1]<<endl;
  
  

   
   

  return; 
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 6244
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  LL x, a, b;
  cin >> x >> a >> b;
  cout << min(a, b) << " " << max(0LL, a + b - x) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

bool check(vector<LL>& h){
    LL max_v = h[0];
    for(LL i = 1; i < h.size(); ++i){
        if(h[i] < max_v - 1) return false;
        max_v = max(max_v, h[i]);
    }
    return true;
}

int main(){
    LL n;
    cin >> n;
    vector<LL> h(n);
    for(LL i = 0; i < n; ++i){
        cin >> h[i];
    }
    if(check(h)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



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

int main(){
    int S, h, m, s;

    cin >> S;
	h = S / (3600);
	m = (S - (h*3600))/60;
	s = S % 60;

 	cout << h << ":" << m << ":" << s << endl;



    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int sum = 0;
  int num = 0;
  rep(i, n){
    int l;
    cin >> l;
    num = max(num, l);
    sum += l;
  }
  if (num < (sum - num)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3596
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut cumulative_sum = vec![0; n + 1];
    for i in 1..=n {
        cumulative_sum[i] = cumulative_sum[i - 1] + a[i - 1];
    }

    let mut min_abs = std::i64::MAX;
    for sunuke in 1..n {
        min_abs = std::cmp::min(
            min_abs,
            (cumulative_sum[sunuke] - (cumulative_sum[n] - cumulative_sum[sunuke])).abs(),
        );
    }

    println!("{}", min_abs);
}


Measured memory_bytes: 6400
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int N;
  cin >> N;

  string S[N];
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }

  map<string, int> ans;
  for (int i = 0; i < N; i++) {
    if (S[i] == "AC") ans["AC"]++;
    else if (S[i] == "WA") ans["WA"]++;
    else if (S[i] == "TLE") ans["TLE"]++;
    else if (S[i] == "RE") ans["RE"]++;
  }

  cout << "AC x " << ans["AC"] << endl;
  cout << "WA x " << ans["WA"] << endl;
  cout << "TLE x " << ans["TLE"] << endl;
  cout << "RE x " << ans["RE"] << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, ri, le, res = inf;
string s;

signed main() {
	cin >> n >> s;
	rep(i,n) if (s[i]=='E') ri++;
	rep(i,n) {
		if (s[i]=='E') ri--;
		chmin(res, ri+le);
		if (s[i]=='W') le++;
	}
	cout << res << ln;
}

Measured memory_bytes: 720
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAbcOfABC solver = new AAbcOfABC();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAbcOfABC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String[] arr = in.next().split("");
            Arrays.sort(arr);
            out.print(Arrays.equals(arr, new String[]{"a", "b", "c"}) ? "Yes" : "No");
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public void close() {
        }

    }
}



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

using pii = pair<int, int>;
using vi = vector<int>;
using ll = long long;

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    cout << min({a, b, c}) + min({d, e}) - 50 << endl;
}


Measured memory_bytes: 3068
#include <stdio.h>
#include <math.h>
#include <string>
const int MAX_V = 10000;
int prime[MAX_V+1];

int isprime(){
	int i, k, v;
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1;
	}
	for(i = 2; i*i <= MAX_V; i++) {
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0;
			}
		}
	}
}
int main(){
	int n,i;
	isprime();
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i = n;i>=2;i--){
			if(prime[i]==1&&prime[i-2]==1){
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1064
using System;

namespace AOJ.Volume3
{
    public class NewTown
    {
        public static int Main()
        {
            var input = Console.ReadLine().Split(' ');
            int w = int.Parse(input[0]);
            int h = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            // w??¨h????????§??¬?´???°????±???????
            int a = Math.Max(w, h);
            int b = Math.Min(w, h);
            while (b > 0)
            {
                int tmp = a % b;
                a = b;
                b = tmp;
            }

            // ???????????°????¨????
            int section = (w / a) * (h / a);
            Console.WriteLine(section * c);

            return 0;
        }
    }
}

Measured memory_bytes: 9192
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

ll f(ll x){
    ll s=1;
    while(x>0){
        s*=x;
        s%=mod;
        x-=1;
    }
    return s;
}

int main() {
    ll N,M;
    cin>>N>>M;
    ll ans;
    if(N+1<M || M+1<N){
        cout<<0<<endl;
        return 0;
    }
    else if(N==M){
        ans =1;
         ans*=f(N);
         ans%=mod;
         ans*=f(N);
         ans%=mod;
         ans*=2;
         ans%=mod;
    }
    else {
        ans =1;
        ans*=f(N);
        ans%=mod;
        ans*=f(M);
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256