akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;


/* BIEN CUC BO BEGIN*/
	int n, m;
/* BIEN CUC BO END*/

void solve(){	
	cin >> n;
	int su = 0;
	for (int i=1; i<=n; ++i){
		int x; cin >> x;
		su += x;
		m = max(m,x);
	}
	cout << (su-m>m?"Yes":"No");
}	

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename T>
void printvec(vector<T> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main(){
    int n; cin >> n;
    vector<int> ar(n);
    rep(i,n) cin >> ar[i];
    sort(ar.begin(), ar.end());
    int cnt = 0;
    int al = 0;
    int bo = 0;
    while (cnt < n){
        if (cnt % 2 == 0) al += ar[n-1-cnt];
        else bo += ar[n-1-cnt];
        cnt++;
    }
    cout << al - bo << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
signed main(){
    int d;cin>>d;
    if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
    else if(d==23)cout<<"Christmas Eve Eve"<<endl;
    else if(d==24)cout<<"Christmas Eve"<<endl;
    else if(d==25)cout<<"Christmas"<<endl;return 0;
}

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

void trace(int A[],int N){
    rep(i,N-1) cout << A[i] << " ";
    cout << A[N-1] << endl;
}

void InsertionSort(int A[],int N){
    for (int i = 1; i < N; i++)
    {
        int temp = A[i];
        int j = i-1;
        while(j >= 0 && A[j] > temp){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = temp;
        trace(A,N);
    }
}
int main(){
    int N; cin >> N;
    int A[N]; rep(i,N) cin >> A[i];
    trace(A,N);
    InsertionSort(A,N);
    return 0;
}


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

int dp[3][3][3];//dokokara dokomade kyori

int main() {
  int m,n;
  cin >> m >> n;
  if(m<n) swap(m,n);
  string s;
  rep(i,m) s+=(n+'0');
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static long mod = 1000000007;
	static long INF = Long.MAX_VALUE;

	public static void main(String[] args) {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int K = sc.nextInt();
		int H[] = new int[N];
		long DP[] = new long[N];
		Arrays.fill(H, 0);
		Arrays.fill(DP, INF);

		for(int i=0; i<N; i++) {
			H[i] = sc.nextInt();
		}
	    // Scannerクラスのインスタンスをクローズ
		sc.close();

		DP[0] = 0;

		for(int now=1; now<N; now++) {
			for(int i=1; i<=K; i++) {
				if(now < i) break;
				DP[now] = Math.min(DP[now], DP[now-i]+Math.abs(H[now]-H[now-i]));
			}
		}

		// 出力
		System.out.println(DP[N-1]);
	}
}


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

aa = [0]
bb = [0]
for i in range(n):
    aa.append(a[i]+aa[-1])
for i in range(m):
    bb.append(b[i]+bb[-1])
ans = 0
j = m
for i in range(n+1):
    r = k - aa[i]
    while bb[j] > r and j >= 0:
        j -= 1
    if j >= 0:
        ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47260
using System;
using System.ComponentModel;

namespace AtCoder.ABC092
{
    public class A
    {
        public static void Solve()
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());

            var train = a;
            if (a >= b)
            {
                train = b;
            }
            var bus = c;
            if (c >= d)
            {
                bus = d;
            }

            var p = bus + train;
        
            Console.WriteLine(p);
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC092.A.Solve();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

string s;
int cur,val[12];

int formula(){
	if(islower(s[cur])){
		int res=val[s[cur++]-'a'];
		return res;
	}
	if(s[cur]=='T'){
		cur++;
		return 1;
	}
	if(s[cur]=='F'){
		cur++;
		return 0;
	}
	if(s[cur]=='-'){
		cur++;
		return !formula();
	}
	cur++;
	int res1=formula();
	if(s[cur]=='*'){
		cur++;
		int res2=formula();
		cur++;
		return res1&res2;
	}
	if(s[cur]=='+'){
		cur++;
		int res2=formula();
		cur++;
		return res1|res2;
	}
	cur+=2;
	int res2=formula();
	cur++;
	return !res1|res2;
}

int main(){
	string in;
	while(cin>>in && in!="#"){
		string s1,s2;
		int equal=0;
		rep(i,in.sz){
			if(in[i]=='=')equal=1;
			else if(equal==0)s1+=in[i];
			else s2+=in[i];
		}
		int ans=1;
		rep(i,1<<11){
			rep(j,11)val[j]=i>>j&1;
			s=s1;
			cur=0;
			int res1=formula();
			s=s2;
			cur=0;
			int res2=formula();
			if(res1!=res2){
				ans=0;break;
			}
		}
		cout<<(ans ? "YES":"NO")<<endl;
	}
}

Measured memory_bytes: 932
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n, m;

int main(void){
    cin >> n >> m;
    vector<vector<lli>> v(n);
    rep(i, m){
        lli a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vector<lli> d(n, -1);
    d[0] = 0;
    queue<lli> q;
    q.push(0);
    while(!q.empty()){
        lli x = q.front();
        q.pop();
        for(auto to : v[x]){
            if(d[to] >= 0) continue;
            d[to] = x;
            q.push(to);
        }
    }
    bool ok = true;
    rep(i, n) if(d[i] < 0) ok = false;
    if(!ok) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        rep(i, n-1){
            cout << d[i+1]+1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 13004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26));
    vector<int> last(26, 0);
    rep(i, 26) cin >> c[i];
    rep(i, d) rep(j, 26) cin >> s[i][j];
    rep(i, d) {
        auto a = s[i];
        map<int, int, greater<int>> m;
        rep(j, 26) { m.emplace(a[j] + (d - last[j]) * c[j], j); }
        cout << (*m.begin()).second + 1 << endl;
    }
}

Measured memory_bytes: 3712
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            // Input
            int N = Integer.parseInt(sc.next());
            long[] a = new long[N];
            for (int i = 0; i < N; i++) {
                a[i] = Long.parseLong(sc.next());
                if (a[i] == 0) {
                    System.out.println(0);
                    return;
                }
            }

            // Calc
            long total = 1L;
            long LIMIT = 1000000000000000000L;
            for (int i = 0; i < N; i++) {
                if (a[i] <= LIMIT / total) {
                    total *= a[i];
                } else {
                    System.out.println(-1);
                    return;
                }
            }
            System.out.println(total);
        }
    }
}

Measured memory_bytes: 60628
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;


#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long
#define  vi               std::vector<int>
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define  pi               acos(-1)


int main () {
    ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
    End
}
/* pray for me
Do before die
*/


Measured memory_bytes: 256
#include <algorithm>
#include <string.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9 + 7;
const int N = 3e5 + 10;
ll x[N], p[64], sum1[N], sum0[N];
int main()
{
    p[0] = 1;
    for (int i = 1; i < 63; i++)
        p[i] = (p[i - 1]) * 2ll;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> x[i];
    ll ans = 0;
    for (int i = 0; i < 63; i++)
    {
        memset(sum1, 0, sizeof(sum1));
        memset(sum0, 0, sizeof(sum0));
        for (int j = n; j >= 1; j--)
        {
            sum1[j] = sum1[j + 1];
            sum0[j] = sum0[j + 1];
            if ((x[j] >> i) & 1)
                sum1[j]++;
            else
                sum0[j]++;
            if ((x[j] >> i) & 1)
            {
                ll temp = (sum0[j + 1] % mod * (p[i] % mod)) % mod;
                ans = (ans % mod + temp % mod) % mod;
            }
            else
            {
                ll temp = (sum1[j + 1] % mod * (p[i] % mod)) % mod;
                ans = (ans % mod + temp % mod) % mod;
            }
        }
    }
    cout << ans % mod << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
string s;


int main() {
	cin >> s;
	int end = 1 << (s.size()-1);
	ll ans = 0;

	for (int i = 0; i < end; i++) {
        ll add = s[0] - '0';
        for (int j = 1; j < s.size(); j++) {
            if (i & (1 << (j-1))) {
                ans += add;
                add = s[j] - '0';
            } else {
                add = add*10 + s[j] - '0';
            }
        }
        ans += add;
	}
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a==b)
    cout<<"0\n";
  else if((a+b)%2==0)
  	cout<<(a+b)/2<<endl;
  else
    cout<<"IMPOSSIBLE\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,n,c=0;
  cin>>n;
  rep(i,0,n){
    cin>>a;
    while(1){
      if(a%2==0){c++; a/=2;}
      else break;
    }
  }
  co(c);
  
  return 0;
}

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

bool isup[20][20],isri[20][20];
int ans[20][20];
int main(){
    int N;
    scanf("%d",&N);
    for(int ix=0;ix<N;ix++){
        int gx,gy;
        scanf("%d%d",&gx,&gy);
        for(int i=0;i<=gx;i++){
            for(int j=0;j<=gy;j++){
                isup[i][j]=isri[i][j]=true;
            }
        }
        int p;
        scanf("%d",&p);
        int x1,y1,x2,y2;
        for(int i=0;i<p;i++){
            scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
            if(x1>x2) swap(x1,x2);
            if(y1>y2) swap(y1,y2);
            if(x1<x2) isri[x1+1][y1]=false;
            if(y1<y2) isup[x1][y1+1]=false;
        }
        ans[0][0]=1;
        for(int i=1;i<=gx;i++){
            if(isri[i][0]) ans[i][0]=ans[i-1][0];
            else ans[i][0]=0;
        }
        for(int i=1;i<=gy;i++){
            if(isup[0][i]) ans[0][i]=ans[0][i-1];
            else ans[0][i]=0;
        }
        for(int i=1;i<=gx;i++){
            for(int j=1;j<=gy;j++){
                ans[i][j]=0;
                if(isri[i][j]) ans[i][j]+=ans[i-1][j];
                if(isup[i][j]) ans[i][j]+=ans[i][j-1];
            }
        }
        if(ans[gx][gy]>0) printf("%d\n",ans[gx][gy]);
        else printf("Miserable Hokusai!\n");
    }
}

Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main()
{
	int N, X, L, D = 0, answer = 1;
	cin >> N >> X;
	for(int i = 0; i < N; i++)
	{
		cin >> L;
		if((D += L) > X)
		{
			break;
		}

		answer++;
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<numeric>


#define FOR(i, a, b) for(int i=a; i<b; i++)
#define COUT(a) cout << a << endl;

using namespace std;
using Int = long long;
using P = pair<Int, Int>;


int main(){
    Int N;
    cin >> N;
    
    vector<Int> cnt_o(100010), cnt_e(100010);
    
    FOR(i, 0, N){
        Int v;
        cin >> v;
        if ( i % 2 ==0){
            cnt_e[v]++;
        }else{
            cnt_o[v]++;
        }
    }
 
 
    auto it_max_o = max_element(begin(cnt_o), end(cnt_o));
    auto it_max_e = max_element(begin(cnt_e), end(cnt_e));
    Int max_o = *it_max_o;
    Int max_e = *it_max_e;
    Int ans = 0;
 
    if (it_max_o - begin(cnt_o) != it_max_e - begin(cnt_e)){
        Int sum_o = accumulate(begin(cnt_o), end(cnt_o), 0);
        Int sum_e = accumulate(begin(cnt_e), end(cnt_e), 0);
        ans = sum_o + sum_e - (max_o + max_e);
    }else{
        Int sum_o = accumulate(begin(cnt_o), end(cnt_o), 0);
        Int sum_e = accumulate(begin(cnt_e), end(cnt_e), 0);


        if (sum_o == max_o && sum_e != max_e){
            sort(begin(cnt_e), end(cnt_e), greater<Int>());        
            ans = sum_o + sum_e - (max_o + cnt_e[1]);

        }else if (sum_o != max_o && sum_e == max_e){
            sort(begin(cnt_o), end(cnt_o), greater<Int>());        
            ans = sum_o + sum_e - (cnt_o[1] + max_e);

        }else{
            sort(begin(cnt_e), end(cnt_e), greater<Int>());   
            sort(begin(cnt_o), end(cnt_o), greater<Int>());      

            ans = sum_o + sum_e - (max(max_o, max_e) + max(cnt_e[1], cnt_o[1]));

        }
    }
    

    COUT(ans);


}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    vector<int>x,y;
    if(a[0]<=0&&a[n-1]>=0){
        int c = 0;
        rep(i,n){
            if(a[i]>=0){
                c = i;
                break;
            }
        }
        if(c!=0)c--;
        int k = a[c];
        for(int i=c+1;i<n-1;i++){
            x.push_back(k);
            y.push_back(a[i]);
            k -= a[i];
        }
        x.push_back(a[n-1]);
        y.push_back(k);
        a[n-1] -=k;
        for(int i=0;i<c;i++){
            x.push_back(a[n-1]);
            y.push_back(a[i]);
            a[n-1]-=a[i];
        }
        cout << a[n-1] << endl;
        rep(i,n-1){
            cout << x[i] << " " << y[i] << endl;
        }
    }else if(a[0]>=0){
        for(int i=1;i<n-1;i++){
            x.push_back(a[0]);
            y.push_back(a[i]);
            a[0]-=a[i];
        }
        x.push_back(a[n-1]);
        y.push_back(a[0]);
        a[n-1] -= a[0];
        cout << a[n-1] << endl;
        rep(i,n-1){
            cout << x[i] << " " << y[i] << endl;
        }
    }else{
        x.push_back(a[n-1]);
        y.push_back(a[n-2]);
        a[n-1] -= a[n-2];
        for(int i=0;i<n-2;i++){
            x.push_back(a[n-1]);
            y.push_back(a[i]);
            a[n-1]-=a[i];
        }
        cout << a[n-1] << endl;
        rep(i,n-1){
            cout << x[i] << " " << y[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3316
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
ll dp[1000001];
ll solve(ll i, ll a[], ll n)
{
	if (i == n - 1)
		return 0;
	if (dp[i] != -1)
		return dp[i];
	ll x, y = INT_MAX;
	x = abs(a[i] - a[i + 1]) + solve(i + 1, a, n);
	if (i + 2 < n)
		y = abs(a[i] - a[i + 2]) + solve(i + 2, a, n);
	return dp[i] = min(x, y);
}
int main()
{
	fast;
	ll n;
	cin >> n;
	ll a[n];
	rep(i, 0, n)
	cin >> a[i];
	mems(dp, -1);
	cout << solve(0, a, n);
	return 0;
}

Measured memory_bytes: 18440
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <iostream>
#include <functional>
using namespace std;



vector < int > a;
vector < int > b;

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		int x;scanf("%d",&x);
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	int t  = 1;
	int k = a[0];
	for(int i=1;i<=n;i++){
		if(i==n){
			b.push_back(t);
			break;
		}
		if(a[i]==k){
			++t;
		}
		else{
			b.push_back(t);
			t = 1;
			k = a[i];
		}
	}
	if(b.size()<=m){
		puts("0");
	}
	else{
		sort(b.begin(),b.end());
		int ans = 0;
		for(int i=0;i<(b.size()-m);i++){
			ans += b[i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2548
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int N, K;
	cin >> N >> K;
	vector<int> vec(N+1);
	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int tmp;
			cin >> tmp;
			vec.at(tmp)++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (vec.at(i) == 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
N, M = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort()

cnt = 0

yukohyo = sum(listA)/(4*M)

for i in listA:
    if i >= yukohyo:
        cnt += 1

if cnt >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n; cin >> n;
  vector<int> data(n); REP(i,n) cin >> data[i];
  vector<int> uni; 
  copy(ALL(data), back_inserter(uni));
  sort(ALL(uni));
  uni.erase(unique(ALL(uni)),uni.end());

  if(uni.size() == data.size())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

int main() {
  int K;
  cin >> K;
  int now = 0;
  for (int i = 1; i < 200000000; i++) {
    now = (now * 10 + 7) % K;
    if (now == 0) return cout << i << "\n", 0;
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 3532
package main

import "fmt"
import "strings"

func main() {
	var s string
	a := 'a'
	fmt.Scan(&s)
	for i := 0; i < len(s); i++ {
		if strings.Compare(fmt.Sprintf("%c", s[i]), fmt.Sprintf("%c", a)) == 0 {
			if a == 'z' {
				fmt.Println("None")
				return
			}
			a++
			i = 0
		}
	}
	fmt.Printf("%c\n", a)
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int A, B, C, D;
    int x;
    cin >> x;
    D = x % 10;
    x /= 10;
    C = x % 10;
    x /= 10;
    B = x % 10;
    x /= 10;
    A = x % 10;

    int s[3];
    REP(i, 1 << 3){
        s[0] = i & 1;
        s[1] = (i >> 1) & 1;
        s[2] = (i >> 2) & 1;

        int tmp = A;
        if(s[0] == 0){
            tmp += B;
        }else{
            tmp -= B;
        }
        if(s[1] == 0){
            tmp += C;
        }else{
            tmp -= C;
        }
        if(s[2] == 0){
            tmp += D;
        }else{
            tmp -= D;
        }
        if(tmp == 7) break;
    }

    cout << A;
    if(s[0] == 0){
        cout << "+";
    }else{
        cout << "-";
    }
    cout << B;
    if(s[1] == 0){
        cout << "+";
    }else{
        cout << "-";
    }
    cout << C;
    if(s[2] == 0){
        cout << "+";
    }else{
        cout << "-";
    }
    cout << D << "=7";

    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    int a[q];
    for(int b=0;b<q;b++){
        scanf("%d",&a[b]);
    }
    int d[n];
    for(int e=0;e<n;e++){d[e]=0;}
    for(int c=0;c<q;c++){
        d[a[c]-1]++;
    }
    for(int f=0;f<n;f++){
        if(k-q+d[f]<=0){printf("No\n");}
        else{printf("Yes\n");}
    }
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 998244353ll;
const ll MAXN = (ll) 1e6 + 10;
const ll INF = (ll) 9223372036854775;
const ld EPS = (ld) 1e-8;

vector<ll> pr;

bool isp(ll n){
	for(int i = 2; i < n; i++){
		if(n % i == 0) return false;
	}
	return true;
}

ll cntdiv(ll n, ll s){
	if(n <= 1) return 0;
	return (n / s) + cntdiv(n / s, s);
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	for(int i = 2;i < 100; i++){
		if(isp(i)) pr.pb(i);
	}
	ll n;
	cin >> n;
	ll ans = 0;
	
	ll prc = pr.size();
	ll f,s,t;
	for(int i = 0; i < prc; i++){
		for(int j = i + 1; j < prc; j++){
			for(int k = j + 1; k < prc; k++){
				f = cntdiv(n, pr[i]);
				s = cntdiv(n, pr[j]);
				t = cntdiv(n, pr[k]);
				if(f >= 4 and s >= 4 and t >= 2) ans ++;
				if(f >= 4 and s >= 2 and t >= 4) ans ++;
				if(f >= 2 and s >= 4 and t >= 4) ans ++;
			}
			f = cntdiv(n, pr[i]);
			s = cntdiv(n, pr[j]);
			if(f >= 24 and s >= 2) ans ++;
			if(f >= 14 and s >= 4) ans ++;
			f = cntdiv(n, pr[j]);
			s = cntdiv(n, pr[i]);
			if(f >= 24 and s >= 2) ans ++;
			if(f >= 14 and s >= 4) ans ++;
		}
		if(cntdiv(n, pr[i]) >= 74) ans ++;
	}
	cout << ans;
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/




Measured memory_bytes: 256
N,A,B = list(map(int,input().split()))

def findSumOfDigits(n):
    s = 0
    while n>0:
        s += n%10
        n //= 10
    return s 

total = 0
for i in range(1,N+1):
    if A <= findSumOfDigits(i) <= B:
        total += i
print(total)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> p(n);
	rep(i,n) cin >> p.at(i);
	int ans=0;
	for(int i=1;i<n-1;++i){
		if((p.at(i)>p.at(i+1) && p.at(i)<p.at(i-1)) || (p.at(i)<p.at(i+1) && p.at(i)>p.at(i-1))) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main() {
	string S;
	cin >> S;
	//SUN,MON,TUE,WED,THU,FRI,SAT
	if (S == "SUN") {
		cout << 7 << endl;
	} 
	if (S == "MON") {
		cout << 6 << endl;
	}
	if (S == "TUE") {
		cout << 5 << endl;
	}
	if (S == "WED") {
		cout << 4 << endl;
	}
	if (S == "THU") {
		cout << 3 << endl;
	}
	if (S == "FRI") {
		cout << 2 << endl;
	}
	if (S == "SAT") {
		cout << 1 << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  if(n <= 111)System.out.println("111");
  else if(n <= 222)System.out.println("222");
  else if(n <= 333)System.out.println("333");
  else if(n <= 444)System.out.println("444");
  else if(n <= 555)System.out.println("555");
  else if(n <= 666)System.out.println("666");
  else if(n <= 777)System.out.println("777");
  else if(n <= 888)System.out.println("888");
  else if(n <= 999)System.out.println("999");
}}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	string s;
	cin >> s;
	int x = 0;
	for (auto ch : s) {
		if (ch == 'x') ++x;
	}
	if (x > 7) cout << "NO\n";
	else cout << "YES\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>
#define L(_i,_N) for(int _i=0;_i<_N;_i++)
typedef long long int lli;
using namespace std;

int main() {
	vector<int> Mountain(10);
	L(i, 10) cin >> Mountain[i];
	sort(Mountain.begin(),Mountain.end(),greater<int>());
	L(i, 3) cout << Mountain[i] << endl;
	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;cin>>h>>w;
    vector<vector<char>> a(h,vector<char>(w));
    vector<bool> row(h,true);
    vector<bool> col(w,true);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a.at(i).at(j);
            if(a.at(i).at(j)=='#'){
                row[i]=false;
                col[j]=false;
            }
        }
    }
    for(int i=0;i<h;i++){
        if(row[i]==false){
            for(int j=0;j<w;j++){
                if(col[j]==false){
                    cout<<a.at(i).at(j);
                }
            }
            cout<<endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

bool done(vector<int> &A, int N) {
	for (auto x : A)
		if(x!=N)
			return false;
	return true;
}

vector<int> eval(vector<int> &A, int N) {
	vector<int> cumul(2*N,0);
	for (int i=0; i<N; i++)
		cumul[max(0,i-A[i])]++, cumul[i+A[i]+1]--;
	vector<int> ret(N,0);
	ret[0]=cumul[0];
	for (int i=1; i<N; i++)
		ret[i]=ret[i-1]+cumul[i];
	return ret;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,K; cin>>N>>K;
	vector<int> A(N);
	for (int i=0; i<N; i++)
		cin>>A[i];
	for (int i=0; i<K; i++) {
		if(done(A,N)) break;
		A=eval(A,N);
	}
	for (int i=0; i<N; i++)
		cout<<A[i]<<" ";
	cout<<"\n";
	return 0;
}

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

int ary[100010]={};
int main(){
	int N,M,m,mm,hog,puy,a,b,c;
	long long res;
	cin>>N>>M;
	cin>>m;
	for(int i=1;i<M;i++){
		cin>>mm;
		hog=max(m,mm);
		puy=min(m,mm);
		for(int j=puy;j<hog;j++){
			ary[j]++;
		}
		m=mm;
	}
	res=0;
	for(int i=1;i<N;i++){
		cin>>a>>b>>c;
		res+=min((long long)a*(long long)ary[i],(long long)b*(long long)ary[i]+c);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1548
#include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  if(a==22){
    printf("Christmas Eve Eve Eve");
  }
  if(a==23){
    printf("Christmas Eve Eve");
  }
  if(a==24){
    printf("Christmas Eve");
  }
  if(a==25){
    printf("Christmas");
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, k;
int a[maxn], b[maxn], c[maxn];
set<int> s;
int main() {
	scanf("%d%d", &n, &k);
	if(2 * k > n + 1) return puts("-1"), 0;
	for(int i = 0; i < n; i++) a[i] = k + i;
	for(int i = 0; i < n; i++) b[i] = k + n + i;
	for(int i = 0; i < n; i++) s.insert(k + n + n + i);	
	for(int i = 0; i < n; i++) {
		int A = a[i], B = b[(i + k - 1) % n];
		int C = A + B;
		auto it = s.lower_bound(C);
		s.erase(it);
		printf("%d %d %d\n", A, B, *it);
	}
	return 0;
}



Measured memory_bytes: 7680
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(); ios::sync_with_stdio(false);
	int n, r;
	while (true) {
		cin >> n >> r;
		if (n == 0 && r == 0) break;
		vector<int> card(n);
		iota(card.rbegin(), card.rend(), 1);

		vector<int> temp(n);
		int p, c;
		for (int i = 0; i < r;i++) {
			cin >> p >> c;
			for (int j = p - 1; j < p - 1 + c;j++) {
				temp[j - (p - 1)] = card[j];
			}
			for (int j = 0; j < p - 1;j++) {
				temp[j + c] = card[j];
			}
			for (int j = p + c - 1; j < n; j++) {
				temp[j] = card[j];
			}
			card = temp;
		}
		cout << card[0] << endl;
	}
}

Measured memory_bytes: 3024
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

n = int(input())
d = len(str(n))
count = 0
ans = n

for i in range(d):
    if i%2 == 0: count += min(ans, 9*(10**i))
    ans -= 9*(10**i)

print(count)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 1; i = 0) {
          String line = sc.nextLine();
          String[] l = line.split("");

          int len = l.length;
          int ans = 0;
          for(int j = 0; j < len; j++) {
            ans += Integer.parseInt(l[j]);
          }

          if(ans == 0) {
            break;
          }

          System.out.println(ans);
        }
    }
}

Measured memory_bytes: 27476
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int e;
	while(1){
		cin>>e;
		if(e==0) break;
		int m=10000000;
		for(int i=0;i*i*i<=e;i++){
			for(int j=0;j*j<=e-i*i*i;j++){
				m=min(m,e-i*i*i-j*j+i+j);
			}
		}
		o(m);
	}
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a=1,b=1;
    while(true){
      a=sc.nextInt();
      b=sc.nextInt();
      if(a==0) break;
      for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
          if(i==0||i==a-1)System.out.print("#");
          else if(j==0||j==b-1)System.out.print("#");
          else System.out.print(".");
        }
        System.out.print("\n");
      }
      System.out.print("\n");
    }
    sc.close();
  }
}


Measured memory_bytes: 36472
#include <iostream>
#include <string>

using namespace std;

int size=0;
long long int heap[2000000];

int parent(int i){
  int return_num;
  if(i%2==0){
    return_num = (i-2)/2;
  }else{
    return_num = (i-1)/2;
  }
  return return_num;
}

int left_child(int i){
  return 2*i+1;
}

int right_child(int i){
  return 2*i+2;
}

int pop(){
  int ret = heap[0];
  int x = heap[--size];
  
  int i=0;
  while (left_child(i)<size){
    int l = left_child(i), r=right_child(i);
    if(r < size && heap[r] > heap[l]){
      l = r;
    }
    if(heap[l] <= x){
      break;
    }
    heap[i] = heap[l];
    i=l;
  }
    heap[i] = x;
    return ret;
}

void push(int x){
  int i = size++;
  while (i > 0){
    int p = parent(i);
    if( heap[p] >= x ){
      break;
    }else{
      heap[i] = heap[p];
      i=p;
    }
  }
  heap[i] = x;
}


int chenger(string str){
  if(str=="insert"){
    return 0;
  }else if (str == "extract"){
    return 1;
  }else if (str == "end"){
    return 2;
  }
  return -1;
}


int main(){
  string input_str;
  int input_num;
  int output_num;
  while(1){
    cin >> input_str;
    int a = chenger(input_str);
    switch(a){
    case 0:
      cin >> input_num;
      push(input_num);
      break;
    case 1:
      output_num = pop();
      cout << output_num << endl;
      break;
    case 2:
      return 0;
    }
  }
}

Measured memory_bytes: 10924
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
const ll infty = 10000000000000007;

int N;
ll a[300010];
ll plusscore[300010];
ll minusscore[300010];

int main () {
  cin >> N;
  for (auto i = 0; i < 3*N; ++i) {
    cin >> a[i];
  }
  fill(plusscore, plusscore+300010, -infty);
  fill(minusscore, minusscore+300010, infty);
  priority_queue<ll, vector<ll>, greater<ll> > Q;
  ll sum = 0;
  for (auto i = 0; i < 2*N; ++i) {
    Q.push(a[i]);
    sum += a[i];
    while ((int)Q.size() > N) {
      sum -= Q.top();
      Q.pop();      
    }
    plusscore[i] = sum;
  }
  priority_queue<ll> QQ;
  sum = 0;
  for (auto i = 3*N-1; i >= N; --i) {
    QQ.push(a[i]);
    sum += a[i];
    // cerr << "a[" << i << "] = " << a[i] << endl;
    while ((int)QQ.size() > N) {
      sum -= QQ.top();
      QQ.pop();
    }
    minusscore[i] = sum;
  }
  ll ans = -infty * 3;
  /*
  for (auto i = 0; i < 3*N; ++i) {
    cerr << "plusscore[" << i << "] = " << plusscore[i] << endl;
  }
  for (auto i = 0; i < 3*N; ++i) {
    cerr << "minusscore[" << i << "] = " << minusscore[i] << endl;
  }
  */
  for (auto i = N-1; i < 2*N; ++i) {
    ans = max(ans, plusscore[i] - minusscore[i+1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 9588
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int n = s.length();
	for (int i = 0; i < n; i++) {
		char x = s[i];
		x = (((x - 'A') +23) % 26) + 'A';
		cout << x;
	}
	cout << endl;
}


Measured memory_bytes: 3204
N, M = list(map(int, input().split()))
picture = [input() for i in range(N)]
template = [input() for i in range(M)]

for i in range(N - M + 1):
    for j in range(N - M + 1):
        subpicture = [picture[row][j:j + M] for row in range(i, i + M)]
        if subpicture == template:
            print('Yes')
            break
    else:
        continue
    break
else:
    print('No')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] cc = new String[h+1];
		for (int i = 1; i <= h; i++) {
			cc[i] = sc.next();
		}

		for (int i = 1; i <= 2 * h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(cc[(i+1)/2].charAt(j));
			}
			System.out.println();
		}
	}

}


Measured memory_bytes: 31284
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String w = sc.nextLine();
		String t = "";
		int cnt = 0;
		
		w = w.toUpperCase();
		while(!(t.equals("END_OF_TEXT"))) {
			t = sc.next();
			if(!(t.equals("end_of_text"))) {
				t = t.toUpperCase();
			}
			String[] tTbl = t.split(" ", 0);
			for(int i = 0; i < tTbl.length; i++) {
				if(tTbl[i].equals(w)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26292
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define M 1000000000

int main()
{

	string s,t;
	cin>>s>>t;
	ll sl = s.length();
	ll tl = t.length();
	ll ar[sl+1][tl+1];
	for(ll x=0;x<=sl;x++)
	{
		for(ll y=0;y<=tl;y++)
		{
			ar[x][y]=0;
		}
	}
	for(ll x=1;x<=sl;x++)
	{
		for(ll y=1;y<=tl;y++)
		{
			if(s[x-1] == t[y-1])
			{
				ar[x][y] = ar[x-1][y-1]+1;
			}
			else
			{
				ar[x][y] = max(ar[x-1][y],ar[x][y-1]);
			}
		}
	}
	
	ll i = sl;
	ll j = tl;
	string ans = "";
	ll z = ar[i][j];
	while(i!=0 && j!=0 && ar[i][j]!=0)
	{
		while(i!=0 && ar[i-1][j] == ar[i][j])
		{
			i--;
		}

		while(j!=0 && ar[i][j-1] == ar[i][j])
		{
			j--;
		}
		if(i>=1)
			ans = s[i-1] + ans;
		i--;
		j--;
	}
	cout<<ans;

}

	 	

Measured memory_bytes: 70656
#include<stdio.h>

int main()
{
  int  a, b;

  scanf("%d %d", &a, &b);

  if(a%3==0 || b%3==0 || (a+b)%3==0)
    printf("Possible\n");
  else 
    printf("Impossible\n");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    int k;  
    cin >> k; 
    vector<int> p = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << p[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	char c; cin >> c;
	if('A' <= c and c <= 'Z') {
		cout << 'A' << '\n';
	} else {
		cout << 'a' << '\n';
	}
	return 0;
}


Measured memory_bytes: 3596
from collections import deque
N=int(input())
A=[i for i in input().split()]
s=deque()
s.append(A[0])
if N%2==1:
    for i in range(1,N):
        if i%2==1:
            s.append(A[i])
        else:
            s.appendleft(A[i])
else:
    for i in range(1,N):
        if i%2==0:
            s.append(A[i])
        else:
            s.appendleft(A[i])
print(' '.join(map(str,s)))

Measured memory_bytes: 27072
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
  string s; cin>>s;

  if(n>=3200) cout << s << endl;
  else cout << "red" << endl;

  return 0;
}


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

typedef struct{
  char suit;
  int value;
}Card;

void bubble(Card A[], int N)
{
  for( int i = 0; i < N; i++)
    {
      for(int j = N - 1; j >= i + 1; j--)
        {
          if( A[j].value < A[j - 1].value )
            {
              Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}

void selection(Card A[], int N)
{
  for( int i = 0; i < N; i++)
    {
      int minj = i;
      for(int j = i; j < N; j++)
        {
          if( A[j].value < A[minj].value ) minj = j;
        }
      Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(Card A[], int N)
{
  for( int i = 0; i < N; i++)
    {
      if( i > 0 ) cout << " ";
      cout << A[i].suit << A[i].value;
    }
  cout << endl;
}

bool isStable(Card C1[], Card C2[], int N)
{
  for( int i = 0; i < N; i++)
    {
      if( C1[i].suit != C2[i].suit ) return false;
    }
  return true;
}

int main()
{
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for( int i = 0; i < N; i++)
    {
      cin >> C1[i].suit >> C1[i].value;
      C2[i] = C1[i];
    }

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if( isStable(C1, C2, N) ) cout << "Stable" << endl;
  else cout << "Not stable" << endl;

  return 0;
}



Measured memory_bytes: 3100