akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int n,w,weight[110],value[110];
int dp[110][100100] = { 0 };
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> w;
	for (int i = 0; i < n; i++)cin >> weight[i] >> value[i];
	for (int i = 0; i < n; i++) {
		for (int sum_w = 0; sum_w <= w; sum_w++) {
			if (sum_w - weight[i] >= 0) {
				chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
			}
			chmax(dp[i + 1][sum_w], dp[i][sum_w]);
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}

Measured memory_bytes: 79360
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */

int main() {
    ll A; cin >> A;
    string B; cin >> B;
    ll C = 0;
    rep(i, B.size()) {
        if(B[i] == '.') {
            continue;
        }else {
            C = C * 10 + (B[i] - '0');
        }
    }
    cout << ll((A * C) / 100)<< endl;
}


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

using namespace std;

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

  int ret=0;
  if(s[0]=='1')ret++;
  if(s[1]=='1')ret++;
  if(s[2]=='1')ret++;
  cout<< ret<< endl;

  return 0;
}


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

using namespace std;

string s;

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

	cin >> s;
	if (s[0] == 'M') cout << 6;
	else if (s[0] == 'T' && s[1] == 'U') cout << 5;
	else if (s[0] == 'W') cout << 4;
	else if (s[0] == 'T') cout << 3;
	else if (s[0] == 'F') cout << 2;
	else if (s[0] == 'S' && s[1] == 'A') cout << 1;
	else cout << 7;
}

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

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
if(op == '+') cout << a + b << endl;
else cout << a - b << endl;
}




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


int main() {
    int n, m;
    cin >> n >> m;
    bitset<31> b;
    b.flip();
    while (n--) {
        int k;
        cin >> k;
        bitset<31> bTry;
        for (int i = 0; i<= k - 1; i++) {
            int a;
            cin >> a;
            bTry[a] = 1;
        }

        b = (b&bTry);
        //cout << b << '\n';
    }
    cout << b.count() << '\n';
    return 0;
}

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

struct edge
{
	int from, to, cost;
};

int h, w;
int a[15];
edge es[95];
int cnt;
long long d[15];
int main() {
	std::cin >> h >> w;
	for (int i = 0; i < 10; ++i)
		for (int j = 0; j < 10; ++j) {
			int tmp;
			std::cin >> tmp;
			if (i != j) {
				edge e;
				e.from = i;
				e.to = j;
				e.cost = tmp;
				es[cnt++] = e;
			}
		}

	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			int in;
			std::cin >> in;
			if (in != -1 && in != 1)
				++a[in];
		}

	std::fill(d, d + 10, 999999999);
	d[1] = 0;
	while (true)
	{
		bool update = false;
		for (int i = 0; i < 90; ++i) {
			auto e = es[i];
			if (d[e.to] != 999999999 && d[e.from] > d[e.to] + e.cost) {
				d[e.from] = d[e.to] + e.cost;
				update = true;
			}
		}

		if (!update)
			break;
	}

	long long ans = 0;
	for (int i = 0; i < 10; ++i)
		ans += d[i] * a[i];

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
  
	set<int> s;
	int q;
	cin >> q;
	while(q--){
		int op, el;
		cin >> op >> el;
		if(op == 1)cout << s.count(el) << '\n';
		else if(op == 2)s.erase(el);
		else if(op == 3){
			int r;cin >> r;
			auto lef = s.lower_bound(el);
			auto right = s.upper_bound(r);
			while(lef != right)cout << *lef << '\n', lef++;
			
		}
		else s.insert(el), cout << s.size() << '\n';
	}
    return 0;
}



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

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    
    int ans = 0;
    for (int i = 1; i < N-1; i++) {
        if ((P[i-1] < P[i] && P[i] < P[i+1]) || (P[i-1] > P[i] && P[i] > P[i+1]) ) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/agc005/tasks/agc005_b
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 200005;
int n, a[N];
stack<pii> s;

int main(){
    io;
    //freopen("input.txt", "r", stdin);
    cin >> n;
    rep(i, 1, n){
        cin >> a[i];
    }
    ll ans = a[n];
    ll cur = a[n];
    s.push(mp(a[n], 1));
    rrep(i, n - 1, 1){
        int min = a[i], cnt = 1;
        while(!s.empty() && s.top().ff > a[i]){
            pii p = s.top();
            s.pop();
            cur -= 1LL * p.ff * p.ss;
            cnt += p.ss;
        }
        cur += 1ll * min * cnt;
        ans += cur;
        s.push(mp(min, cnt));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 2688
import math

a, b, h, m = map(float, input().split())
hour = 30 * h + 0.5 * m
minute = 6 * m

radian = abs(hour - minute)
if radian > 180:
    radian = 360 - abs(hour - minute)

dist = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(radian))
print(math.sqrt(dist))


Measured memory_bytes: 9292
#include <bits/stdc++.h>
#define fast std::ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;

void solve(){
    fast
    string s;
    cin>>s;
    cout<<s[0]<<(s.size()-2)<<s[s.size()-1];   
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
/*input
1 1 3
1
10000000000
2
9999999999
5000000000
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=80000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[maxn],b[maxn];

int main()
{
	int n,m,q;
	cin>>n>>m>>q;
	a[0]=b[0]=-INF64;
	REP(i,n) cin>>a[i+1];
	REP(i,m) cin>>b[i+1];
	a[n+1]=b[m+1]=INF64;
	n+=2,m+=2;
	while(q--){
		ll ans=INF64;
		ll x;
		cin>>x;

		int it1=lower_bound(a,a+n,x)-a;
		int it2=lower_bound(b,b+m,x)-b;

		ans=min(ans,max(a[it1],b[it2])-x);
		ans=min(ans,x-min(a[it1-1],b[it2-1]));
		ans=min(ans,a[it1]-b[it2-1]+min(abs(a[it1]-x),abs(b[it2-1]-x)));
		ans=min(ans,b[it2]-a[it1-1]+min(abs(a[it1-1]-x),abs(b[it2]-x)));
		cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 4096
a, b, m = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
money = []

for _ in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    total = a_list[x] +b_list[y] - c
    money.append(total)
money.append(min(a_list) + min(b_list))
print(min(money))

Measured memory_bytes: 18488
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    string s;
    cin >> s;
    int ans=0;
    rep(i,s.size()/2){
        if (s[i]!=s[s.size()-1-i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  int n,ans=0;
  cin>>s>>t;
  n=s.length();
  for(int i=0;i<n;i++) if(s.at(i)!=t.at(i)) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3916
from collections import Counter

def solve(n, V):
    odds = V[0::2]
    evens = V[1::2]
    o2 = [k for k, c in Counter(odds).most_common(2)]
    e2 = [k for k, c in Counter(evens).most_common(2)]
    if len(o2) == 1 and o2 == e2:
        return n // 2
    return min(
        len(odds) - odds.count(o) + len(evens) - evens.count(e)
        for o in o2
        for e in e2
        if o != e
    )

_n = int(input())
_V = list(map(int, input().split()))
print(solve(_n, _V))


Measured memory_bytes: 15964
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));


int main(){
  long long int MX =  1e18;
  int n;
  cin>>n;
  long long int a;
  long long int ans= 1;
   bool ng = false;
  rep(i,n){
    cin>>a;
    if(a==0){
      cout<<'0';
      return 0;
    }
   
    if( ng||(MX+1)/ans<a||ans*a>MX){
      ng=true;
    }
    ans *= a;
  }
  if(ng)cout<<"-1";
  else cout<<ans;



}


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

typedef long long ll;

const ll MAXN = 100 * 1000 + 10;
ll c1[2000000],c2[2000000];


void ns(ll b[], ll n)
{
    stack<ll> s;
    for (ll i=n-1; i>=0; i--)
    {
        while (!s.empty() && s.top() >= b[i])
            s.pop();
        if (s.empty())
            c1[i]=0;
        else
            c1[i]=s.top();
        s.push(b[i]);
    }
}

void ps(ll b[], ll n)
{
    stack<ll> s;
    for (ll i=0; i<n; i++)
    {
        while (!s.empty() && s.top() >= b[i])
            s.pop();
        if (s.empty())
            c2[i]=0;
        else
            c2[i]=s.top();
        s.push(b[i]);
    }
}

int main()
{
    ll n;
    cin>>n;
    ll b[n],d[200000],pe,ne,v,cu,s=0;
    for(ll i=0;i<n;i++){
        cin>>b[i];
        d[b[i]]=i;
    }
    ps(b,n);
    ns(b,n);
    for(ll i=0;i<n;i++){
        cu=d[b[i]]+1;
        if(c1[i]==0){
            ne=n;
        }
        else{
            ne=d[c1[i]];
        }
        if(c2[i]==0){
            pe=1;
        }
        else{
            pe=d[c2[i]]+2;
        }
        v=(cu-(pe-1))*(ne-(cu-1));
        //cout<<d[c1[i]]<<" "<<d[c1[i]];
        //cout<<endl;
        s+=v*b[i];
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
using namespace std;
//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

typedef long long int ll;
int main(){
    init;
    ll h,w,i,j,k,l;
    ll MOD = 1e9 + 7;
    cin>>h>>w;
    string s[h];
    for(i=0;i<h;i++)
        cin>>s[i];
    ll dp[h][w];
    memset(dp,0,sizeof(dp));
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(s[i][j] == '.'){
                if(i == 0 && j == 0)
                    dp[i][j] = 1;
                else if(i == 0)
                    dp[i][j] = dp[i][j-1];
                else if(j == 0)
                    dp[i][j] = dp[i-1][j];
                else dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
            }
            else dp[i][j] = 0;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 9088
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for(ll i = a; i < (ll)(n); ++i)
#define repr(i, a, n) for(ll i = n - 1; (ll)a <= i; --i)
#define ENDL '\n'
typedef pair<int, int> Pi;
typedef pair<ll, ll> PL;
constexpr ll mod = 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 + 99);
const ld PI = acos((ld)-1);
const vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T, typename U> inline bool chmin(T& t, const U& u) {
  if(t > u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T, typename U> inline bool chmax(T& t, const U& u) {
  if(t < u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template <typename T, typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(; n; n >>= 1) {
    if(n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T, typename Y>
ostream& operator<<(ostream& os, const pair<T, Y>& p) {
  return os << "{" << p.fs << "," << p.sc << "}";
}
template <typename T> ostream& operator<<(ostream& os, const V<T>& v) {
  os << "{";
  for(auto e : v) os << e << ",";
  return os << "}";
}
template <typename... Args> void debug(Args&... args) {
  for(auto const& x : {args...}) { cerr << x << ' '; }
  cerr << ENDL;
}

signed main() {
  cin.tie(0);
  cerr.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  V<PL> v(n);
  rep(i, 0, n) cin >> v[i].fs >> v[i].sc;

  sort(all(v));
  reverse(all(v));

  ll ans = 1;
  stack<tuple<ll, ll, ll>> st;
  rep(i, 0, n) {
    ll x = 1, y = 1;
    while(st.size() && get<0>(st.top()) < v[i].fs + v[i].sc) {
      ll a, b, c;
      tie(a, b, c) = st.top();
      st.pop();

      y *= b+c;
      y %= mod;
    }

    st.push(mt(v[i].fs, x, y));
  }

  while(st.size()) {
    ll a, b, c;
    tie(a, b, c) = st.top();
    st.pop();
    
    ans*=(b+c);
    ans%=mod;
  }
  cout << ans << ENDL;
}
//! ( . _ . ) !
// CHECK overflow,vector_size,what to output?

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N[4];
  for (int i = 0; i < 4; i++)
    cin >> N[i];
  sort(N, N + 4);
  if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9)
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  ll N;
  cin >>N;
  vl A(N);
  rep(i,N) {
cin >>A.at(i);
  }
 vl B(N);
  rep(i,N) {
    B.at(i)=A.at(i);
  }
  
 sort(all(A));
  ll xMax=A.at(N-1);
  ll xSMax=A.at(N-2);
  
  rep(i,N) {
    if(B.at(i)!=xMax) {
cout<<xMax<<endl;
    }
    else {
cout<<xSMax<<endl;
    }
  }
  
  
  
}
  
  
 

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

int main ()
{
    int n,m,c=0;
    double s=0;
    cin>>n>>m;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
        s+=x[i];
    }
    s=s/(4.0*m*1.0);
    sort(x,x+n);
    for(int i=n-1;i>=0;i--)
    {
        if(x[i]>=s)c++;
        else break;
    }

    if(c>=m)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(x) x.begin(),x.end();
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
using namespace std;
int main() {
	ll a, b, c, d, e, ans = 0, v[100010] = {};
	string s, ss, sss;

	cin >>a>>b>>c;
	a -= b;
	while (a >= c) {
		a -= c;
	}
	cout<< a<<endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;
use std::collections::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        sa: Chars,
        sb: Chars,
        sc: Chars,
    }
    let mut sa_deq: VecDeque<char> = VecDeque::new();
    let mut sb_deq: VecDeque<char> = VecDeque::new();
    let mut sc_deq: VecDeque<char> = VecDeque::new();
    for i in sa {
        sa_deq.push_back(i);
    }
    for i in sb {
        sb_deq.push_back(i);
    }
    for i in sc {
        sc_deq.push_back(i);
    }

    // let mut turn: char = sa_deq.pop_front().unwrap();
    let mut turn: char = 'a';
    loop {
        if sa_deq.is_empty() && turn=='a' {
            println!("A");
            return;
        }
        if sb_deq.is_empty() && turn=='b' {
            println!("B");
            return;
        }
        if sc_deq.is_empty() && turn=='c' {
            println!("C");
            return;
        }
        match turn {
            'a' => turn = sa_deq.pop_front().unwrap(),
            'b' => turn = sb_deq.pop_front().unwrap(),
            'c' => turn = sc_deq.pop_front().unwrap(),
            _ => return,
        }
        debug!(sa_deq);
        debug!(sb_deq);
        debug!(sc_deq);
    }

}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
using namespace std;
 
int main() {

  int X,N;
  cin >> X >> N;
  vector<bool> P(100,true);
  for( int i=0; i<N; i++){
    int t;
    cin >> t;
    P[t] = false;
  }

  for( int i = 0; i < 110; i++){
  
    if( P[ X-i ] ){
    cout << X-i << endl;
    return 0;
    }

    if( P[ X+i ] ){
    cout << X+i << endl;
    return 0;
    }
    
  }

  return 0;

}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10**7)

n = int(input())
e = [[] for i in range(n+1)]
mod = 10**9+7

for i in range(n-1):
    a,b = map(int,input().split())
    e[a].append(b)
    e[b].append(a)

def dfs(x,bef):
    w = 1
    b = 1
    for nex in e[x]:
        if nex == bef:
            continue
        nw,nb = dfs(nex,x)
        w *= (nw+nb)%mod
        b *= nw%mod
        w %= mod
        b %= mod
    return w,b

a,b = dfs(1,-1)
print((a+b)%mod)


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

int main(){
    int64_t a,b;
    cin >> a >> b;
    int64_t n = 1;
    for(int64_t i=1;i <=max(a,b) ;i++){
        if(a%i == 0 && b%i == 0){
            n = max(n,i);
        }
    }
    cout << (a/n)*(b/n)*n << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;


signed main()
{
    int x, y;
    while(cin >> x >> y, x || y){
        printf("%d %d\n", min(x, y), max(x, y));
    }

    return 0;
}

/*



*/



Measured memory_bytes: 3032
#include <iostream>
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int INF = 100000;


int main() {
    string s;
    cin >> s;
    ll ans = 0;
    ll num = 0;
    int n = s.size();
    for(int i=0;i<(1<<(n-1));i++){
        num = s[0]-'0';
        for (int j =0;j<n-1;j++){
            if(i&(1<<j)){
                ans += num;
                num = 0;
            }
            num = num * 10 + s[j+1] - '0';
        }
        ans += num ;
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N+2);
    A[0] = 0;
    A[N+1] = 0;
    int sum = 0;
    for(int i=1; i<=N; i++){
        cin >> A[i];
        sum += abs(A[i] - A[i-1]);
    }
    sum += abs(A[N]);
    
    for(int i=1; i<=N; i++){
        if((A[i] - A[i-1]) * (A[i+1] - A[i]) < 0) cout <<sum + abs(A[i+1]-A[i-1]) - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) << endl;
        else cout << sum << endl;
    }

    return 0;
}


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

using namespace std;

int main(){
  int n;
  cin>>n;
  map<string,int> m;
  string s;
  for(int i=0;i<n;i++){
    cin>>s;
    m[s]++;
  }
  cout<<"AC x ";
  if(m.find("AC")!=m.end())
    cout<<m["AC"];
  else
    cout<<0;
  cout<<endl;
  cout<<"WA x ";
  if(m.find("WA")!=m.end())
    cout<<m["WA"];
  else
    cout<<0;
  cout<<endl;
  cout<<"TLE x ";
  if(m.find("TLE")!=m.end())
    cout<<m["TLE"];
  else
    cout<<0;
  cout<<endl;
  cout<<"RE x ";
  if(m.find("RE")!=m.end())
    cout<<m["RE"];
  else
    cout<<0;

  return 0;
}

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

 int main() {
 int N, X; cin >> N >> X;
 vector<int> D(N + 1);
 D[0] = 0;
for (int i = 0; i < N; ++i) {
 int x; 
 cin >> x;
 D[i + 1] = D[i] + x;
 }
int ans = 0;
for (int i = 0; i <= N; ++i) {
if (D[i] <= X) {
ans++;
}
}
cout << ans << endl;
}

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

using namespace std;

const int maxn = 200010;
long long n, m;
int tem, cnt[maxn] = {0};

int read()
{
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * w;
}

inline void write(int x)
{
  static int sta[35];
  int top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[-- top] + 48);
}

int main()
{
	n = read();
	m = n;
	n --;
	while(n --) {
		tem = read();
		cnt[tem] ++;
	}
	for(int i = 1; i <= m; i ++) {
		printf("%d\n", cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 4544
M, K = map(int, input().split())

if K >= 2**M:
  print(-1)
elif M == 0:
  print(0,0)
elif M == 1:
  if K == 0:
    print(0,0,1,1)
  elif K == 1:
    print(-1)
else:
  ans = list(range(2**M))
  del ans[K]
  rev = list(reversed(ans))
  ans.append(K)
  ans.extend(rev)
  ans.append(K)
  print(' '.join(map(str, ans)))

Measured memory_bytes: 28452
N = int(input())
result = N

for i in range(N+1):
    count = 0
    t = i
    
    while (t>0):
        count += t%6
        t = int(t/6)
        
    t = N - i
        
    while (t>0):
        count += t%9
        t = int(t/9)
        
    if(result > count):
        result = count
           

print(result)
        

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const long long md=998244353;
const int maxn=200100;
long long fac[maxn],inv[maxn];
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
long long C(int x,int y){
	if(x<0||y<0||x<y) return 0;
	return fac[x]*inv[y]%md*inv[x-y]%md;
}
long long f[maxn],g[maxn],h[maxn];
int rev[maxn];
long long wn[100],rwn[100];
int csh(int n){
	int l=1,ws=0;
	while(l<n) l<<=1,ws++;
	n=l;
	for(int i=0;i<n;i++)
		rev[i]=(rev[i>>1]>>1)|((i&1)<<(ws-1));
	for(int i=1;i<=ws;i++){
		wn[i]=powd(3,(md-1)>>i);
		rwn[i]=powd(wn[i],md-2);
	}
	return n;
}
void NTT(long long *a,int n,int op){
	for(int i=0;i<n;i++)
		if(i<rev[i])
			swap(a[i],a[rev[i]]);
	long long w,t1,t2;
	int id=0;
	for(int l=2;l<=n;l<<=1){
		id++;
		for(int i=0;i<n;i+=l){
			w=1;
			for(int j=i;j<i+(l>>1);j++){
				t1=a[j],t2=a[j+(l>>1)]*w%md;
				a[j]=(t1+t2)%md;
				a[j+(l>>1)]=(t1-t2+md)%md;
				w=w*(op==1?wn[id]:rwn[id])%md;
			}
		}
	}
	if(op==-1){
		w=powd(n,md-2);
		for(int i=0;i<n;i++)
			a[i]=a[i]*w%md;
	}
}
void Mult(long long *a,long long *b,int n,long long *c){
	static long long dA[maxn],dB[maxn];
	n=csh(n);
	for(int i=0;i<n;i++)
		dA[i]=a[i],dB[i]=b[i];
	NTT(dA,n,1);
	NTT(dB,n,1);
	for(int i=0;i<n;i++)
		c[i]=dA[i]*dB[i]%md;
	NTT(c,n,-1);
}
int main(){
//	freopen("F.in","r",stdin);
//	freopen("F.out","w",stdout);

	int n,m;
	scanf("%d%d",&n,&m);
	fac[0]=1;
	for(int i=1;i<maxn;i++)
		fac[i]=fac[i-1]*i%md;
	inv[maxn-1]=powd(fac[maxn-1],md-2);
	for(int i=maxn-1;i>=1;i--)
		inv[i-1]=inv[i]*i%md;

	f[0]=1;
	for(int i=1;i<=n;i++)
		g[i]=inv[i+2];
	for(int i=1;i<=m;i++){
		for(int j=0;j<=n*2+2;j++)
			h[j]=0;
		Mult(f,g,n*2+2,h);
		for(int j=0;j<=n;j++)
			h[j]=(h[j]*fac[j+2]+f[j]*(C(j+1,2)+1)%md*fac[j]%md)%md;
		for(int j=0;j<=n;j++)
			f[j]=h[j]*inv[j]%md;
	}
	long long ans=0;
	for(int i=0;i<=n;i++)
		ans=(ans+h[i]*C(n,i))%md;
	printf("%lld\n",ans);
	return 0;
}


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

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

const int INF = 1001001001;

int main() {
    int N,M,X;
    int C[12];
    int A[12][12];
    int ed[12];
    int re;
    int ans=10001000;
    cin >>N>>M>>X;
    rep(i,N){
        cin >>C[i];
        rep(j,M){
            cin>>A[i][j];
        }
    }

    rep(i,1<<N){
        int cost =0;
        int re=0;
        rep(k,M){
                    ed[k]=0;
                }
        rep(j,N){
            if(i>>j&1){
                cost +=C[j];
                rep(k,M){
                    ed[k]+=A[j][k];                   
                }
            }
        }
        rep(k,M){
                    if(ed[k]<X)re++;
                }
            if(re==0)ans=min(ans,cost);
        
    }

if(ans==10001000)cout <<-1;
else cout<<ans;

return 0;
}

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vector<char> v(N);
    rep(i,N) {
        cin>>v[i];
    }
    bool answer=false;
    rep(i,N) {
        if(v[i]=='Y') answer=true;
    }
    if(answer) cout<<"Four"<<endl;
    else cout<<"Three"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 500000
#define INFTY 2000000000

int L[(MAX/2)+2],R[(MAX/2)+2],count;

void merge(int A[], int n, int left, int mid, int right){

  int i,j,k,n1,n2;

  n1 = mid - left;
  n2 = right - mid;

  for(i=0;i<n1;i++){
    L[i] = A[left + i];
  }

  for(i=0;i<n2;i++){
    R[i] = A[mid + i];
  }

  L[n1] = R[n2] = INFTY;

  i = j = 0;

  for(k=left;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int n, int left, int right){

  int mid;

  if((left + 1) < right){
    mid = (left + right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){

  int A[MAX], n ,i;

  scanf("%d",&n);

  count = 0;
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i] >= INFTY){
      return 1;
    } 
  }

  mergeSort(A,n,0,n);

  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    printf("%d",A[i]);
  }
  printf("\n");

  printf("%d\n",count);

  return 0;

}



Measured memory_bytes: 5604
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

struct range {
    int start;
    int end;
};

#define NUM_MAX 100000

int asc_by_end(const void *a1, const void *a2) {
    struct range *ra1 = (struct range*)a1;
    struct range *ra2 = (struct range*)a2;
    return ra1->end - ra2->end;
}

int main(void) {
    int num = get_int();
    int i;
    static struct range rs[NUM_MAX];
    for(i = 0; i < num; i++) {
        get_int2(&rs[i].start, &rs[i].end);
    }

    qsort(rs, num, sizeof(struct range), asc_by_end);

    int cur_end = 0;
    int ans = 0;
    for(i = 0; i < num; i++) {
        if(rs[i].start <= cur_end) continue;
        ans++;
        cur_end = rs[i].end;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll INF = 1e9+7;
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++)
    {
        for(int j = 1; j <= 9; j++)
        {
            if(n == i * j)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
import numpy as np

N,M,X=map(int,input().split())
CA=[]
for i in range(N):
  CA.append(list(map(int,input().split())))
#print(CA)

m=[i+1 for i in range(N)]

from itertools import combinations

minmoney=float('inf')
for k in range(N):
  for i in combinations(m,k+1):
      #print(i)
      money=0
      r=[0]*M
      for j in range(len(i)):
          money+=CA[i[j]-1][0]
          #print("-------")
          #print(r)
          #print(CA[i[j]-1][1:])
          
          r=np.array(r)+np.array(CA[i[j]-1][1:])
          #print(CA[i[j]-1][0])
      #print(r)   
      n = sum(x>=X for x in r)
      #print(n)
      if n==M and money<minmoney:
          minmoney=money
if minmoney==float('inf'):
  print(-1)
else:
  print(minmoney)

Measured memory_bytes: 27020
#define DigLim  1000000000 //10 digit (10^9)
#include<stdio.h>
int main(){
    int n, a, i=1, j, k, min, max, sum[2]={0};
    max=-1000000; min=-max;
    scanf("%d\n", &n);
    for(;i<=n;i++){
        scanf("%d ", &a);
        if(a>max)max=a;
        if(a<min)min=a;
        if(sum[0]+a>=DigLim){
            sum[0] += a - DigLim;
            sum[1]++;
        }
        else sum[0]+=a;
    }
    printf("%d %d ", min, max);
    if(sum[1]>0){
        printf("%d", sum[1]);
        j=sum[0];
        for(k=1;j/10>0;k++)j/=10;
        for(j=0;j<9-k;j++)putchar('0');
    }
    printf("%d\n", sum[0]);
    return 0;
}


Measured memory_bytes: 2752
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        long tmp = 0;
        for (int i = 0; i < n; i++) tmp = tmp ^ a[i];

        for(int i = 0; i < n; i++)
        {
            if (i != n - 1) Console.Write((tmp ^ a[i]) + " ");
            else Console.WriteLine(tmp ^ a[i]);
        }
    }
}

Measured memory_bytes: 61112
#include <bits/stdc++.h>
#define mp std::make_pair

typedef long long ll;

std::pair<int, int> E[100001];
int arr[100001], rank[100001];
ll sze[100001], ans[100001];

class dsu
{
	public: int root(int x);
			void find_union(int x, int y); 
};

int dsu::root(int x)
{
	return (x == arr[x]) ? x : (arr[x] = root(arr[x]));
}

void dsu::find_union(int x, int y)
{
	int rx = root(x);
	int ry = root(y);
	if(rx == ry)
	return;
	if(rank[ry] > rank[rx])
	{
		int tmp = ry;
		ry = rx;
		rx = tmp;
	}	
	arr[ry] = rx;
	if(rank[rx] == rank[ry])
	rank[rx]++;	
	return;
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	int n, m;
	std::cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int s,d;
		std::cin>>s>>d;
		E[i] = mp(s, d);
	}
	dsu T;
	for(int i=1;i<=n;i++)
	{
		arr[i] = i;
		rank[i] = 0;
		sze[i] = 1;
	}
	ans[m-1] = ((1LL*n) * (n-1))/2LL;
	for(int i=m-1;i>0;i--)
	{
		int rx = T.root(E[i].first);
		int ry = T.root(E[i].second);
		T.find_union(E[i].first, E[i].second);
		if(rx != ry)
		{	
			ans[i-1] = ans[i] - (sze[rx] * sze[ry]);
			int rz = T.root(E[i].first);
			if(rz == rx)
			sze[rx] += sze[ry];
			else sze[ry] += sze[rx];	
		}
		else ans[i-1] = ans[i];	
	}
	for(int i=0;i<m;i++)
	std::cout<<ans[i]<<"\n";
	return 0;	
}

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

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;

	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];

	int dp[n];
	dp[0]=0;

	for(int i=1;i<n;i++)
	{
		int mn=2000000000;
		for(int j=i-1;j>=max(i-k,0);j--)
			mn=min(dp[j]+abs(arr[i]-arr[j]),mn);
		dp[i]=mn;
	}

	cout<<dp[n-1];

	return 0;
}

Measured memory_bytes: 4400
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())))[-x:]
q=sorted(list(map(int,input().split())))[-y:]
r=sorted(list(map(int,input().split())))
for i in range(len(p)):
  r.append(p[i])
for i in range(len(q)):
  r.append(q[i])
r=sorted(r)[-x-y:]
print(sum(r))



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

typedef long long ll;
typedef pair<int,int> P;

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    ll N;
    cin >> N;
    int ans=0;
    for(int i=1;i<N;i++){
        ans+=(N-1)/i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int a, b;
	cin >> a >> b;
	
	cout << (a + b) / 2 + (a + b) % 2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


typedef long long ll;


int main(){
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    vector<int> cum(N, 0);
    vector<bool> status_list(101000, false);
    int cnt = 0, status = 0;
    for(int i = 0; i < N; i++){
        if(status == 0 && s[i] == '1'){
            cum[i] = cnt;
            continue;
        }
        else if(status == 0 && s[i] == '0'){
            cum[i] = ++cnt;
            status = 1;
            status_list[i] = true;
        }
        else if(status == 1 && s[i] == '1'){
            cum[i] = cnt;
            status = 0;
            status_list[i] = true;
        }
        else if(status == 1 && s[i] == '0'){
            cum[i] = cnt;
        }
    }

    int ma = upper_bound(cum.begin(), cum.end(), K) - cum.begin();
    for(int i = 1; i < N; i++){
        if(!status_list[i]){
            continue;
        }
        ma = max(ma, (int)(upper_bound(cum.begin(), cum.end(), K + cum[i-1]) - cum.begin() - i));
    }
    cout << ma << endl;

    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const int MAX_V = 10000;

vector<int> g[MAX_V]; //??°??????
vector<int> rg[MAX_V]; //??????????????°??????
vector<int> vs; //??°?????????????????????
bool used[MAX_V];
int cmp[MAX_V]; //?±????????????£????????????????????????????????????

void addEdge(int from, int to){
    g[from].emplace_back(to);
    rg[to].emplace_back(from);
}

void dfs(int v){
    used[v] = true;
    rep(i,g[v].size()){
        if(not used[g[v][i]]) dfs(g[v][i]);
    }
    vs.emplace_back(v);
}

void rdfs(int v, int k){
    used[v] = true;
    cmp[v] = k;
    rep(i,rg[v].size()){
        if(not used[rg[v][i]]) rdfs(rg[v][i], k);
    }
}

int scc(int v){
    memset(used, 0, sizeof(used));
    vs.clear();
    rep(i,v){
        if(not used[i]) dfs(i);
    }
    memset(used, 0, sizeof(used));
    int k = 0;
    for(int i = vs.size() - 1; i >= 0; i--){
        if(not used[vs[i]]) rdfs(vs[i], k++);
    }
    return k;
}

int main(){
    int v, e;
    cin >> v >> e;
    rep(i,e){
        int s, t;
        cin >> s >> t;
        addEdge(s, t);
    }
    scc(v);

    int q;
    cin >> q;
    rep(i,q){
        int a, b;
        cin >> a >> b;
        if(cmp[a] == cmp[b]) cout << 1 << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 4624
a,b = map(str,input().split())
if a == 'H' and b == 'H':
  print('H')
elif a == 'H' and b == 'D':
  print('D')
elif a == 'D' and b == 'H':
  print('D')
elif a == 'D' and b == 'D':
  print('H')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define all(v) (v).begin(), (v).end()
using namespace std;
const int N = 3e3+3;
ll dp[N][N][5],v[N][N];

void solve()
{
    ll n, m, k, x, y, z;
    cin >> n >> m >> k;
    for(int i = 0; i < k; i++)
    {
        cin >> x >> y >> z;
        v[x][y] = z;
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            for(int k = 0; k < 4; k++)
            {
                dp[i][j+1][k]=max(dp[i][j][k],dp[i][j+1][k]);
                if(k < 3)
                    dp[i][j + 1][k + 1] = max({dp[i][j + 1][k + 1], dp[i][j][k] + v[i][j]});
                
                dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k] + v[i][j]*(k==3?0:1));
            }

        }
    }
    cout << max({dp[n][m][3], dp[n][m][2]+v[n][m], dp[n][m][1]+v[n][m], dp[n][m][0]+v[n][m]});

}


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


    int TESTS = 1;
    // cin >> TESTS;
    while(TESTS--)
    {
        solve();
        cout << endl;

    }
    return 0;
}

Measured memory_bytes: 425960
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		boolean count2 = false;
		int count4 = 0;
		int countodd = 0;
		boolean ok = false;
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
			if (a[i] % 2 == 0 && a[i] % 4 != 0) {
				count2 = true;
			}
			if (a[i] % 4 == 0) {
				count4++;
			}
			if (a[i] % 2 != 0) {
				countodd++;
			}
		}

		if (count2) {
			if (count4 >= countodd) {
				ok = true;
			}
		} else {
			if ((count4 + 1) >= countodd ) {
				ok = true;
			}
		}

		if (ok) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		System.out.println("");
	}
}


Measured memory_bytes: 52064
#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define mp make_pair
#define M 1000000007
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define endl "\n"
#define BRISK ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
signed main()
{
    BRISK;
    string s;
    cin>>s;
    int one=0;
    for(int i=0;i<3;i++){
        if(s[i]=='A')one++;
    }

    if(one==0 || one==3)cout<<"No";
    else cout<<"Yes";
}

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

class Dice{
public:
  //Dice();
  void input();
  void routen(char ch);
  int upnum(){
    return d[0];
  }
  int find(int, int);
  void get(int [6]);
private:
  int tmp[6], d[6];
};

void Dice::input(){
  for(int i=0;i<6;i++){
    cin >> d[i];
  }
}

int Dice::find(int up, int forward){
  char v[5] = "SSSW";
  for(int k=0;k<7;k++){
    for(int i=0;i<4;i++){
      if(d[0] == up && d[1] == forward){
        return d[2];
      }else if(d[1] == up && d[0] == forward){
        return d[3];
      }
      routen(v[i]);
    }
  }
  return 0;
}

void Dice::get(int dice[6]){
  for(int i=0;i<6;i++){
    dice[i] = d[i];
  }
}

void Dice::routen(char ch){
  for(int i=0;i<6;i++){
    tmp[i] = d[i];
  }
  switch(ch){
    case 'E':
      d[0] = tmp[3];
      d[2] = tmp[0];
      d[3] = tmp[5];
      d[5] = tmp[2];
    break;
    case 'W':
      d[0] = tmp[2];
      d[2] = tmp[5];
      d[3] = tmp[0];
      d[5] = tmp[3];
    break;
    case 'S':
      d[0] = tmp[4];
      d[1] = tmp[0];
      d[5] = tmp[1];
      d[4] = tmp[5];
    break;
    case 'N':
      d[0] = tmp[1];
      d[1] = tmp[5];
      d[5] = tmp[4];
      d[4] = tmp[0];
    break;
  };
}

bool check(int d1[], int d2[]){
  for(int i=0;i<6;i++){
    if(d1[i] != d2[i]){
      return false;
    }
  }
  return true;
}

int main(){
  Dice dice1, dice2;
  int N, forward, up;
  int d1[6], d2[6];
  vector<int> v;

  dice1.input();
  dice2.input();

  //cin >> N;
  dice1.get(d1);

  char str[] = "WWWWSWWWW";
  for(int i=0;i<9;i++){
    dice2.get(d2);
    if(d2[0] == d1[0] && d2[5] == d1[5]){
      break;
    }
    if(i == 8){
      cout << "No" << endl;
      return 0;
    }
    dice2.routen(str[i]);
  }
  char str1[] = "SWN";
  for(int i=0;i<4;i++){
    dice2.get(d2);
    if(check(d1, d2)){
      cout << "Yes" << endl;
      return 0;
    }
    for(int j=0;j<3;j++){
      dice2.routen(str1[j]);
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 1160
#template
def inputlist(): return [int(j) for j in input().split()]
#template
X,N = inputlist()
ans = 0
m = 10**9+7
p = inputlist()
for i in range(110):
    flag = 0
    for j in range(N):
        if i == p[j]:
            flag = 1
            break
    if flag:
        continue
    d = abs(X-i)
    if d < m:
        m = d
        ans = i
print(ans)

Measured memory_bytes: 9188