akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 ans = 0;

	cin >> N;

	vector<SINT32> DATA(N+1);
	
	rep(i,0,N) {
		SINT32 buf;
		cin >> buf;
		if (buf > N) {
			ans++;
		} else {
			DATA[buf]++;
		}
	}
	rep(i,1,N+1) {
		if (DATA[i] > i) {
			ans += DATA[i] - i;
		}
		if (DATA[i] < i) {
			ans += DATA[i];
		}
	}

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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 640
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			
			int mansID[] = new int[n];
			long mansValue[] = new long[n];
			int last = 0;
			
			for (int i = 0; i < n; i++)
			{
				int id = sc.nextInt();
				EXIST :
				{
					for (int j = 0; j < last; j++)
					{
						if (mansID[j] == id)
						{
							mansValue[j] += sc.nextLong() * sc.nextLong();
							break EXIST;
						}
					}
					mansID[last] = id;
					mansValue[last] = sc.nextLong() * sc.nextLong();
					last++;
				}
			}
			
			boolean flg = true;
			for (int i = 0; i < last; i++)
			{
				if (mansValue[i] >= 1000000)
				{
					System.out.println(Long.toString(mansID[i]));
					flg = false;
				}
			}
			if (flg)
				System.out.println("NA");
		}
	}
}

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

int main(){
    int d; cin >> d;
    string s = "Christmas";
    string emp = "";
    string eve = "Eve";
    for(int i = 0; i < 25-d; i++){
        emp += eve + " ";
    }
    cout << s + " " + emp << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   char a[5];
   cin>>a;
   if((a[0]==a[1])&&(a[1]==a[2]))
   cout<<"Yes"<<endl;
   else if((a[1]==a[2])&&(a[2]==a[3]))
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    while (true) {
        cin >> n >> m;
        if (n == 0 && m == 0) break;
        Vi cs(m);
        REP(i, m) cin >> cs[i];
        Vi x(n);
        REP(i, n) cin >> x[i];

        VVl dp(n+1, Vl(256, 1e18));
        dp[0][128] = 0;
        REP2(i, 1, n+1) {
            REP(j, m) {
                int c = cs[j];
                REP(k, 256) {
                    int l = k+c;
                    l = l >= 256 ? 255 : l;
                    l = l < 0 ? 0 : l;
                    dp[i][l] = min(dp[i][l], dp[i-1][k] + (ll)pow(x[i-1] - l, 2));
                }
            }
        }
        std::cout << *min_element(ALL(dp[n])) << '\n';
    }

    return 0;
}



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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int x, a, b;
  while (cin >> x >> a >> b) {
    if (b <= a) {
      cout << "delicious" << endl;
    } else {
      if (b - a <= x) {
        cout << "safe" << endl;
      } else {
        cout << "dangerous" << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
N, M = tuple(map(int, input().split(' ')))
cond2_list = {}
key_is_duplicate = False
for _ in range(M):
	s, c = tuple(map(int, input().split(' ')))
	if s in cond2_list and cond2_list[s] != c:
		key_is_duplicate = True
	cond2_list[s] = c

if key_is_duplicate:
	print('-1')
else:
	ans = '-1'
	for i in range(1000):
		keta = len(str(i))
		if keta != N:
			continue

		cond2 = True
		for s, c in cond2_list.items():
			if int(str(i)[s-1]) != c:
				cond2 = False
				continue
		if not cond2:
			continue

		ans = i
		break

	print(ans)

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

int main() {
  vector<int> s(3);
  rep(i, 3) cin>>s[i];
  sort(s.begin(), s.end());
  cout<<s[2]-s[0]<<endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
list=[0]*(N-1)
list1=[0]*N
for i in range(1,N):
    list[i-1]=A[i-1]
    list1[A[i-1]-1]+=1
list1.append(0)
for j in range(N):
    print(list1[j])

Measured memory_bytes: 32372
#include<stdio.h>

int main() {
	int a, b;
	int max = 0;
	int min = 0;
	long sum = 0;

	scanf("%d\n", &a);

	for (int i = 0; i < a ;i++) {
		scanf("%d",&b);

		if (max < b || i == 0) {
			max = b;
		}
		if (min > b || i == 0) {
			min = b;
		}
		sum += (long)b;
	}

	printf("%d %d %ld\n" ,min ,max ,sum);

	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb emplace_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
char n[1000005];
vector<int> dig;
int main(){
        while(~scanf("%s",n)){
                ll ans=0;
                dig.clear();
                int l=strlen(n),cnt=0;
                dig.pb(0);
                F(i,0,l) dig.pb(n[i]-'0');
                for(int i=l;i>=0;i--){
                        int now=dig[i];
                        if(now==5){
                                //cnt++;
                                if(dig[i-1]>=5){
                                        dig[i-1]++;
                                        ans+=10-now;
                                }else ans+=now;
                        }else if(now<=5){//pay now
                                ans+=now;
                        }else{// get change
                                dig[i-1]++;
                                ans+=10-now;
                        }
                }
                //debug(cnt);
                printf("%lld\n",ans);
        }
}

Measured memory_bytes: 7408
N = int(input())
L = list(map(int,input().split()))

INF = 99999
dp = [INF]*N
dp[0] = 0

for i in range(1,N):
    if i==1:
        dp[i] = dp[i-1] + abs(L[i]-L[i-1])
    elif i > 1:
        dp[i] = min(dp[i-1] + abs(L[i]-L[i-1]),dp[i-2] + abs(L[i]-L[i-2]))

print(dp[N-1])


Measured memory_bytes: 13924
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>

using namespace std;

void q86() {
	int a, b;
	for (; cin >> a >> b;) {
		int road[101] = { 0 };
		road[a]++; road[b]++;
		for (; cin >> a >> b;) {
			if (!a && !b) break;
			road[a]++; road[b]++;
		}

		bool flag = true;

		if (!(road[1] & 1)) flag = false;
		if (!(road[2] & 1)) flag = false;

		for (int i = 3; i < 101; i++) {
			if (road[i] & 1) flag = false;
		}

		cout << (flag ? "OK" : "NG") << endl;
	}
}

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

Measured memory_bytes: 3052
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }

    }
}





Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int n; cin >> n;
    vector<int> A(n, 0);
    for(int i = 0; i < n; ++i) cin >> A.at(i);

    ll ggg = A.at(0);
    for(int i = 1; i < n; ++i) ggg = GCD(ggg, A.at(i));

    cout << ggg << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

typedef long long ll;
const ll infl = 1LL << 60;
ll mul(ll a, ll b)
{
    if (infl / a < b)
        return infl;
    return min(infl, a * b);
}
ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b)
{
    if (a == infl || b == infl)
        return infl;
    return mul(a / gcd(a, b), b);
}

int main(void)
{
    int n;
    cin >> n;
    long long ct, ca;
    REP(i, n)
    {
        long long t, a;
        cin >> t >> a;
        if (i == 0)
        {
            ct = t;
            ca = a;
            continue;
        }
        if (ct <= t and ca <= a)
        {
            ct = t;
            ca = a;
        }
        else if (ct > t and ca <= a)
        {
            swap(ct, ca);
            swap(t, a);

            if (a < ca)
            {
                long long multiple = (ca + a - 1) / a;
                ca = multiple * a;
                ct = multiple * t;
            }
            else
            {
                ca = a;
                ct = t;
            }
            swap(ct, ca);
            swap(t, a);
        }
        else if (ct <= t and ca > a)
        {

            if (a < ca)
            {
                long long multiple = (ca + a - 1) / a;
                ca = multiple * a;
                ct = multiple * t;
            }
            else
            {
                ca = a;
                ct = t;
            }
        }
        else
        {
            // 両方減少
            // t,aをx倍する xはxt, xaが両方ともそれぞれct caを超えるようなx
            long long x = (ct + t - 1) / t;
            long long y = (ca + a - 1) / a;
            long long maxv = max(x, y);
            ct = maxv * t;
            ca = maxv * a;
        }
        // cout << ct << " " << ca << endl;
    }
    cout << ct + ca << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
unordered_map<string,int> m;
int n; string a;
cin>>n; 
for(int i=0; i<n; ++i) {
	cin>>a; m[a]++;
}
		printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",m["AC"], m["WA"], m["TLE"], m["RE"]);


	return 0;
}


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

#define mp          make_pair
#define pb          push_back
#define ff          first
#define ss          second
#define ii          pair<int,int>
#define mod         1e9+7
#define inf         1e18

typedef long long int lli;
typedef long double ld;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int dp[100005];
bool vis[100005];

    void dfs(vector<int> g[],int dp[],bool vis[],int i)
{
    if(vis[i])
        return ;
    vis[i]=true;

    for(int j=0;j<g[i].size();j++)
    {
        int nei=g[i][j];
        if(!vis[nei])
            dfs(g,dp,vis,nei);

        dp[i]=max(dp[i],dp[nei]+1);
    }
}


void solve()
{
    int n,m;
    cin>>n>>m;

    vector<int> g[100005];

    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        g[a].pb(b);
    }

    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(g,dp,vis,i);
        }
    }

    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,dp[i]);
    }

    cout<<ans<<endl;
}

int main()
{
    fio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
//    cin>>t;
    for(int i=0;i<t;i++)
    {
        solve();
    }
    return 0;
} 

Measured memory_bytes: 12984
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int l,ans,j1,j0,o1,o0;
char s[100000];
int main(){
	scanf("%s",&s);
	l=strlen(s);
	for(register int i=0;i<l;i++){
		if(i%2&&s[i]=='0')j0++;//,break;
		if(i%2&&s[i]=='1')j1++;//,break;
		if(i%2==0&&s[i]=='0')o0++;//,break;
		if(i%2==0&&s[i]=='1')o1++;//,break;
	}
	printf("%d",min(l-j0-o1,l-j1-o0));
}

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;
using ll = long long;
using Graph = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

// bool dp[110000];

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> dp(k + 1, 0);

    for (int i=1;i<=k;++i) {
        for (int j=0;j<n;++j) {
            if (i - a[j] >= 0) dp[i] |= !dp[i - a[j]];
            // if (i - a[j] >= 0) {
            //     if (!dp[i - a[j]]) {
            //         dp[i] = 1;
            //         break;
            //     }
            // }
        }
    }

    cout << ((dp[k]) ? "First" : "Second") << endl;
}


Measured memory_bytes: 640
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 3005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],dp[N][N][2];
string s,s1;
//Variables End

ll compute(ll l,ll r,ll st)
{
	if(dp[l][r][st]!=-inf)return dp[l][r][st];
	if(l==r && st)return ar[l];
	if(l==r && !st)return -ar[l];

	if(st)
	{
		dp[l][r][st]=max(compute(l+1,r,1-st)+ar[l],compute(l,r-1,1-st)+ar[r]);
	}
	else
	{
		dp[l][r][st]=min(compute(l+1,r,1-st)-ar[l],compute(l,r-1,1-st)-ar[r]);
	}

	return dp[l][r][st];
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n;
		rep(i,0,n+1)rep(j,0,n+1)rep(k,0,2)dp[i][j][k]=-inf;

		rep(i,0,n)cin>>ar[i];
		cout<<compute(0,n-1,1);
    }
    return 0;
        
}

Measured memory_bytes: 141440
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def r_sort(a) a.sort{|a,b|b<=>a} end

n =gets.to_i
t = ARGF.map(&:to_i)
max = t.max
m_i = t.index(max)
t.delete_at(m_i)
max2 = t.max
n.times do |i|
  puts (i==m_i)? max2:max
end


Measured memory_bytes: 4860
#include<stdio.h>
#include<string.h>
int main(){
    char s[100];
    scanf("%s",s);
    int l =strlen(s);
    //printf("%d\n",l);
    int i;
    for(i=0;i<l;i++){
        if(i%2==0){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D'){
            }
            else{
                printf("No\n");
                return 0;
            }
        }
        else{
            if(s[i]=='L'||s[i]=='U'||s[i]=='D'){
            }
            else{
                printf("No\n");
                return 0;
        }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            List<long> lstA = new List<long>();
            List<long> lstB = new List<long>();
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++) { lstA.Add(long.Parse(sS[i])); }
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++) { lstB.Add(long.Parse(sS[i])); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            long lASm = lstA.Sum();
            long lBSm = lstB.Sum();
            if (lASm < lBSm) { iOut = -1; }                                                 // やりくり不可能
            else                                                                            // どうにかやりくり可能
            {
                List<long> lstD = new List<long>();                                         // 不足の情報
                List<long> lstU = new List<long>();                                         // 余裕の情報
                for (int i = 0; i < lstA.Count; i++)
                {
                    if (lstA[i] < lstB[i]) { lstD.Add(lstB[i] - lstA[i]); iOut += 1; }      // 不足情報保持 不足箇所加算
                    else { lstU.Add(lstA[i] - lstB[i]); }                                   // 余裕の情報
                }
                if (iOut > 0)                                                               // 不足箇所があれば以下処理
                {
                    long lDSm = lstD.Sum();                                                 // 不足箇所の不足分合計
                    lstU.Sort();
                    lstU.Reverse();                                                         // 余裕箇所の大きい順に
                    long lUSm = 0L;
                    for (int i = 0; i < lstU.Count; i++)
                    {
                        lUSm += lstU[i];                                                    // 余裕分でまかない
                        iOut += 1;                                                          // まかない数加算
                        if (lUSm >= lDSm) { break; }                                        // まかない完了で終了
                    }
                }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 32480
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    vector<int> v(3, 0);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    int k;
    cin >> k;
    cout << v[0] + v[1] + v[2] * (1 << k) << endl;
}


Measured memory_bytes: 3632
/*input
1 2 3 4


*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;

int fast_exp(int base, int exp) {
    int res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       exp/=2;
    }
    return res%mod;
}

int32_t main() {
    IOS;
	int a,b,c,k;cin>>a>>b>>c>>k;
	int ans = 0;
	ans+=min(a,k);
	k-=min(a,k);
	k-=min(b,k);
	if(k>0)ans-=min(c,k);
	cout<<ans<<endl;
	return 0;
}






Measured memory_bytes: 3652
import os, sys, re, math

s = input()
a,b = int(s[0:2]) , int(s[2:])

def isMM(n):
    if n >= 1 and n <= 12:
        return True
    else:
        return False

if isMM(a) and isMM(b):
    print('AMBIGUOUS')
elif isMM(a):
    print('MMYY')
elif isMM(b):
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 38384
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b] <- getInts
  print $ solve a b

solve :: Int -> Int -> Int
solve a b = length $ filter isPalindromic [a .. b]

isPalindromic :: Int -> Bool
isPalindromic n = s == reverse s where
  s = show n

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


Measured memory_bytes: 892
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int A, B, X; cin >> A >> B >> X;
    bool TF=true;
    if(A>X  ){ TF=false; }
    if(A+B<X){ TF=false; }
    cout << (TF ? "YES":"NO") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,s;
    cin >> n >> k >> s;
    int t = (s==1e+9?1:1e+9);
    for(int i=0;i<n;i++){
        cout << (i<k?s:t) << endl;
    }
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<stdlib.h>

#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int len=1<<n;
  int *a=(int *)calloc(len,sizeof(int));
  int i;
  for(i=0;i<len;i++) scanf("%d",a+i);
  while(len>1){
    for(i=0;2*i<len;i++){
      int x=a[2*i];
      int y=a[2*i+1];
      if(x==y){
	a[i]=x;
      } else {
	a[i]=ABS(x-y);
      }
    }
    len/=2;
  }
  printf("%d\n",a[0]);
}

int main(void){
  run();
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9
 
int main() {

    int n;
    cin >> n;
    vector<float> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());

    float sum;

    rep(i,n-1){
        sum = (v[i+1]+v[i])/2;
        v[i+1] = sum;
    }

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 3760
h, w, d = gets.split.map(&:to_i)

mp = Array.new(h*w+1){[0, 0]}

h.times do |i|
  r = gets.split.map(&:to_i)
  w.times do |j|
    mp[r[j]] = [i, j]
  end
  r
end

t = Array.new(h*w+1){0}

((1+d)...(h*w+1)).each do |i|
  t[i] = t[i-d]+(mp[i-d][0]-mp[i][0]).abs+(mp[i-d][1]-mp[i][1]).abs
end

gets.to_i.times do
  l, r = gets.split.map(&:to_i)
  puts t[r]-t[l]
end


Measured memory_bytes: 17148
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private static <T extends Comparable<T>> boolean nextPermutation(List<T> l) {
		for (int i = l.size() - 2; i >= 0; i--) {
			// 辞書順に並んでいるところを探す
			if (l.get(i).compareTo(l.get(i + 1)) < 0) { // l[i] < l[i+1]
				int idx = i + 1;
				T min = l.get(i + 1);
				// l[i]より大きくて、そのうち最小を、i+1以降で探す
				for (int j = i + 1; j < l.size(); j++) {
					if (l.get(j).compareTo(l.get(i)) > 0) {
						if (l.get(j).compareTo(min) < 0) {
							idx = j;
							min = l.get(j);
						}
					}
				}

				Collections.swap(l, i, idx);
				Collections.sort(l.subList(i + 1, l.size()));
				return true;
			}
		}
		return false;
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		List<Integer> P = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			P.add(sc.nextInt());
		}
		List<Integer> Q = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			Q.add(sc.nextInt());
		}

		sc.close();

		List<Integer> l = new ArrayList<>();
		for (int i = 1; i <= N; i++) {
			l.add(i);
		}

		int n = 1;
		int a = 0;
		int b = 0;
		do {

			if (l.equals(P)) {
				a = n;
			}
			if (l.equals(Q)) {
				b = n;
			}
			n++;

		} while (nextPermutation(l));

		out.println(Math.abs(a - b));

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 34972
# include <bits/stdc++.h>
using namespace std;
# define ll long long
const int N = 2e5 + 10;
ll a[N] , b[N] , diff[N] , ans , k , n;
bool check(ll x){
	ll res = 0;
	for(int i = 0; i < n; i ++)
		res += max(0ll, a[i] - x / b[i]);
	return res <= k;
}
int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i ++) cin >> a[i];
	for(int i = 0; i < n; i ++) cin >> b[i];
	sort(a , a + n);
	sort(b , b + n);
	reverse(b , b + n);
	ll l = 0 , r = a[n - 1] * b[0];
	while(l <= r){
		ll m = (l + r) >> 1;
		if(check(m)) r = m - 1 , ans = m;
		else l = m + 1;
	}
	cout << ans << "\n";
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  for(int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if(s == "AC") {
      ac++;
    }
    else if(s == "WA") {
      wa++;
    }
    else if(s == "TLE") {
      tle++;
    }
    else {
      re++;
    }
  }
  cout << "AC" << " x " << ac << endl;
  cout << "WA" << " x " << wa << endl;
  cout << "TLE" << " x " << tle << endl;
  cout << "RE" << " x " << re << endl;   
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
      using namespace std;
       int main(){
           int k,n;
           cin>>k>>n;
           int a[n];
           int res=0;
           for(int i=0;i<n;i++)cin>>a[i];
           int length[n];
           for(int i=0;i<n-1;i++){
		   length[i]=a[i+1]-a[i];
	   }
	   length[n-1]=k-a[n-1]+a[0];
	   int max = length[0];
           for (int i = 1; i <n; ++i) {
           	if (max < length[i]) {
            		max = length[i];
           	}
           }
	   for(int i=0;i<n;i++) res+=length[i];
	   res=res-max;
	   cout<<res<<endl;
       }


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

int main() {
  int A, B,C,D;
 
cin>>A>>B>>C>>D;
    
  if(A+B==C+D){
   cout<<"Balanced"<<endl; 
  }
  else if(A+B<C+D){
   cout<<"Right"<<endl; 
  }
  else{ 
  cout<<"Left"<<endl; 
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;cin>>n;
	for(int i=0;i<n/4+1;++i){
		for(int j=0;j<n/7+1;++j){
			if(i*4+j*7==n){
				cout<<"Yes";return 0;
			}
		}
	}
	cout<<"No";
}

Measured memory_bytes: 3612
import heapq
X,Y,A,B,C = map(int,input().split())

qa = list(map(int,input().split()))
qb = list(map(int,input().split()))
r = list(map(int,input().split()))

qa.sort(reverse=True)
qb.sort(reverse=True)
r.sort(reverse=True)

qa_ans = qa[:X]
qb_ans = qb[:Y]

heapq.heapify(qa_ans)
heapq.heapify(qb_ans)

for i in range(C):
    r_max = r[i]

    qa_min = heapq.heappop(qa_ans)
    qb_min = heapq.heappop(qb_ans)

    if (r_max>qa_min) or (r_max>qb_min):
        if qa_min >qb_min:
            heapq.heappush(qa_ans,qa_min)
            heapq.heappush(qb_ans,r_max)
        else:
            heapq.heappush(qa_ans,r_max)
            heapq.heappush(qb_ans,qb_min)

    else:
        heapq.heappush(qa_ans, qa_min)
        heapq.heappush(qb_ans, qb_min)
        break

print(sum(qa_ans)+sum(qb_ans))

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

void main_()
{
    ll N;
    vector<ll> as;
    cin >> N;
    copy_n(istream_iterator<ll>(cin), N, back_inserter(as));

    vector<ll> asc(100000);
    for (auto a : as) {
        asc[a]++;
    }

    ll ans = 0;
    for (int i = 0; i < asc.size() - 2; ++i) {
        auto three = asc[i] + asc[i + 1] + asc[i + 2];
        ans = max(ans, three);
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1908
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int a, b, c;

int main() {
    cin >> a >> b >> c;

    cout << max(0, c - (a - b)) << '\n';

    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    ll n; cin >> n;
    if ((n & 1) == 1) { 
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    for (ll i = 10; i <= n; i *= 5) {
        ans += n / i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
    int n;
    cin>>n;

    while(1){
        if(n%10==9){
            cout<<"Yes"<<endl;
            return 0;
        }
        n=n/10;
        if(n==0)break;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void) {
 
  int n;
  cin >> n;
  
  long long ans = 0;
  
  for (int i = 1; i <= n; i++) {
  	if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;
using ll = long long;
using vi = vector <int>;
inline int read() {
    int x = 0, f = 1, c = getchar();
    for (;!isdigit(c);c = getchar()) if (c == '-') f = 0;
    for (; isdigit(c);c = getchar()) x = x * 10 + c - 48;
    return f ? x : -x;
}
inline void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    int stk[25], tp = 0;
    if (!x) stk[tp ++] = 0;
    for (; x; x /= 10) stk[tp ++] = x % 10;
    for (; tp; putchar(48 + stk[-- tp]));
}
char s[200005];
int main() {
    int n = read();
    int a = read() - 1, b = read() - 1;
    int c = read() - 1, d = read() - 1;
    scanf("%s", s);
    for (int i = a; i < c; ++ i) {
        if (s[i] == '#') {
            puts("No");
            return 0;
        }
        if (s[i + 1] == '#') ++ i;
    }
    for (int i = b; i < d; ++ i) {
        if (s[i] == '#') {
            puts("No");
            return 0;
        }
        if (s[i + 1] == '#') ++ i;
    }
    if (c > d) {
        bool ok = 0;
        for (int i = b; i <= d; ++ i) {
            if (i && i < n - 1 && s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
                ok = 1;
            }
        }
        if (!ok) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 384
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<cmath>
#define ll long long
using namespace std;
const int N=1e5+5;
const ll Max=1e18+1000;

int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	ll d=c-a-b;
	ll f=4*a*b;
	if(c<=a+b)
	cout<<"No"<<endl;
	else
	{
		if(d*d>f)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
  int n;
  scanf("%d",&n);
  char str[10001];
  scanf("%s",str);
  int length=strlen(str);
  for(int i=0;i<length;i++){
    str[i]+=n;
    if(str[i]>90) str[i]-=26;
  }
  printf("%s",str);
  return 0;
}

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

int N, K;
double sum;

double test(int n){
    double res;
    double two=1;
    for(int i=1; ;i++){        
        if(K<=two*n){
            return 1/(double)N/two;
        }
        two *= 2;
    }
}


int main(){
    cin >> N >>K;
    for(int i=1; i<=N; i++){
        sum += test(i);
    }
    printf("%.10f\n", sum);
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int n,k,ans,a;
int x;
int main(){
  cin>>n;
  cin>>k;
  a=k/2;ans=0;
  for(int i=0;i<n;i++){
    cin>>x;
    if(x>a)ans+=2*(k-x);
    else ans+=2*x;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def check(n, k):
    tmp = n
    while tmp % k == 0:
        tmp = tmp // k
    return tmp % k == 1


def main():
    input = stdin.buffer.readline
    n = int(input())
    ans = 1
    if n > 2:
        ans += 1
    for i in range(2, int((n - 1) ** 0.5) + 1):
        if (n - 1) % i == 0:
            ans += 1
            if i != (n - 1) // i:
                ans += 1
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            if check(n, i):
                ans += 1
            if check(n, n // i) and i != n // i:
                ans += 1
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 67524
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include<climits>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
int n;
ll a[200001];
ll d[200001][3];
ll go(int x, int y) { // x까지 왔을 때 거를 수 있는 횟수가 y
	if (x >= n - y) {
		return 0;
	}
	ll &ret = d[x][y];
	if (ret != -1)return ret;
	ret = 0;
	ret = go(x + 2, y) + a[x];
	if (y > 0) {
		ret = max(ret, go(x + 1, y - 1));
		ret = max(ret, go(x + 3, y - 1) + a[x]);
	}
	if (y > 1) {
		ret = max(ret, go(x + 4, y - 2) + a[x]);
	}
	return ret;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> a[i]; }
	memset(d, -1, sizeof(d));
	if (n & 1) {
		cout << go(0, 2) << '\n';
	}
	else {
		cout << go(0, 1) << '\n';
	}


}

Measured memory_bytes: 17712
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    long m, a, r, c, h;
    foreach (_; 0..N) {
        switch (readln[0]) {
            case 'M': ++m; break;
            case 'A': ++a; break;
            case 'R': ++r; break;
            case 'C': ++c; break;
            case 'H': ++h; break;
            default:
        }
    }
    writeln(
        m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h +
        a*r*c + a*r*h + a*c*h +
        r*c*h
    );
}

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

int gcd(int x, int y) {
    while (y) swap(x = x % y, y); return x;
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int lcm = 1;
    for (int i = 0; i < n; i++) lcm = lcm / gcd(lcm, a[i]) * a[i];
    cout << lcm << endl;
    return 0;
}


Measured memory_bytes: 3100
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x,vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout <<#x<<" "<< x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a,b,c) min(a,min(b,c))
#define max(a,b,c) max(a,max(b,c))
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	cout<<(ll)ceil((float)n/2)-1;
}
	

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int a[n];
    int b[m];
    for(int i=0;i<n;i++)
    	cin>>a[i];
    for(int i=0;i<m;i++)
    	cin>>b[i];
    sort(a,a+n);
    sort(b,b+m);
    int xx,yy;
    xx = max(x,a[n-1]);
    yy = min(y,b[0]);
    if (yy-xx>=1)
    	cout<<"No War";
    else
    	cout<<"War";
	return 0;
} 

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
int a[114514];
signed main(){
	ic(n)
	rep(0,i,n)cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]<<" ";
	if(a[0]*2>a[n-1]){
		c(a[0])
		return 0;
	}	
	if(a[n-2]*2<a[n-1]){
		c(a[n-2])
		return 0;
	}	
	rep(1,i,n-2){
		if(a[i]*2>=a[n-1]){
			if(a[i]*2-a[n-1]<a[n-1]-a[i-1]*2){
				c(a[i])
				return 0;
			}
			else{
				c(a[i-1])
				return 0;
			}
		}
	}			
}	

Measured memory_bytes: 1024
from collections import deque

N, X, Y = map(int, input().split())

ret = [0] * N

vec = [[] for _ in range(N)]
for i in range(N - 1) :
  vec[i].append(i + 1)
  vec[i + 1].append(i)
vec[X - 1].append(Y - 1)
vec[Y - 1].append(X - 1)
  
for i in range(N) :
  dist = [-1] * N
  dist[i] = 0
  q = deque([i])
  while q :
    cur = q.popleft()
    cd = dist[cur]
    for nex in vec[cur] :
      if dist[nex] != -1 : continue
      q.append(nex)
      dist[nex] = cd + 1
  
  for i in range(N) :
    ret[dist[i]] += 1
    
    
for i in range(1, N) :
  print(ret[i] // 2)

Measured memory_bytes: 48988
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int N,C;
int D[31][100001]={};
int main() {
	cin>>N>>C;
int S,T,C1;
	for(int i=0;i<N;i++){
		cin>>S>>T>>C1;
		for(int j=S-1;j<T;j++){
			D[C1][j]=1;
		}
	}

	int k;
	int total=0;
	for(int i=0;i<100001;i++){
		k=0;
		for(int j=1;j<31;j++){
			if(D[j][i]==1)k+=1;
		}
		total=max(total,k);
	}

	cout<<total<<endl;

	return 0;
}


Measured memory_bytes: 12032
while True:
    w, h = map(int, input().split())
    vart = []
    hori = []
    if w == 0 and h ==0:
        break
    for i in range(2*h-1):
        if i % 2 == 0:
            vart.append(list(map(int, input().split())))
        else:
            hori.append(list(map(int, input().split())))
    node = [[0 for i in range(h)] for i in range(w)]
    queue = [(0,0,1)]
    res = 0
    while queue:
        p = queue.pop(0)
        x, y, z = p[0], p[1], p[2]
        if x == w-1 and y == h-1:
            res = z
            break
        node[x][y] += 1
        if y-1 >= 0 and hori[y-1][x] == 0 and node[x][y-1] == 0:
            node[x][y-1] = node[x][y]
            queue.append((x,y-1,z+1))
        if y+1 < h and hori[y][x] == 0 and node[x][y+1] == 0:
            node[x][y+1] = node[x][y]
            queue.append((x,y+1,z+1))
        if x-1 >= 0 and vart[y][x-1] == 0 and node[x-1][y] == 0:
            node[x-1][y] = node[x][y]
            queue.append((x-1,y,z+1))
        if x+1 < w and vart[y][x] == 0 and node[x+1][y] == 0:
            node[x+1][y] = node[x][y]
            queue.append((x+1,y,z+1))
    print(res)

Measured memory_bytes: 7804
module IO = struct

  (* @since 4.04.0 *)
  let split_on_char sep s =
    let open String in
    let r = ref [] in
    let j = ref (length s) in
    for i = length s - 1 downto 0 do
      if get s i = sep then begin
        r := sub s (i + 1) (!j - i - 1) :: !r;
        j := i
      end
    done;
    sub s 0 !j :: !r

  let read_ss () = read_line () |> split_on_char ' '

end

let () =
  let l = IO.read_ss () |> List.fast_sort compare in
  let f =
    List.fold_left (fun acc s -> match acc with
      | [] -> [(0, s)]
      | (n, w) :: tl when w = s -> (n + 1, w) :: tl
      | acc -> (0, s) :: acc)
      [] l
    |> List.fast_sort (fun (a, _) (b, _) -> b - a)
    |> List.hd |> snd in
  List.sort (fun a b -> String.length b - String.length a) l
  |> List.hd |> Printf.printf "%s %s\n" f;

Measured memory_bytes: 2100