akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
using namespace std;

priority_queue<double> que;

int main() {
	int n;
	cin >> n;
	double num;
	for(int i =1 ; i <= n ; i++ ){
		cin >> num ;
		que.push(-num);
	}
	while(que.size() > 1){
		double avg ;
		double t = que.top();
		que.pop();
		t += que.top();
		que.pop();
		avg = t/2.0;
		que.push(avg);
	}
	cout << -que.top() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))

using namespace std;

int main(){
	int N; cin >> N;
	int A[N];
	rep(i,0,N) cin >> A[i];
	sort(A,A+N);
	
	llong score=0;
	
	rep(i,1,N){
		score += A[N-1-i/2];
	}
	
	cout << score;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
using namespace std;
const int maxn = 100100;
ll x, y, a, b, c;
ll pa[maxn], pb[maxn], pc[maxn];

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

//	ifstream fin("test_case.in");

	cin>>x>>y>>a>>b>>c;
	for(int i=1;i<=a;i++) {
		cin>>pa[i];
	}
	for(int i=1;i<=b;i++) {
		cin>>pb[i];
	}
	for(int i=1;i<=c;i++) {
		cin>>pc[i];
	}

	sort(pa+1, pa+a+1);
	sort(pb+1, pb+b+1);

	ll sum = 0LL;
	multiset<ll>sta, stb;
	for(int i=a;i>=1;i--) {
		if(sz(sta) < x) {
			sum += pa[i];
			sta.insert(pa[i]);
		}
	}

	for(int i=b;i>=1;i--) {
		if(sz(stb) < y) { 
			sum += pb[i];
			stb.insert(pb[i]);
		}
	}

	for(int i=c;i>=1;i--) {
		ll mina = *(sta.begin());
		ll minb = *(stb.begin());

		//cout<<"Up to here "<<mina<<", "<<minb<<"\n";

		if(pc[i] <= min(mina, minb)) continue;

		//cout<<"Changing "<<pc[i]<<" with "<<mina<<" and "<<minb<<"\n";

		if(mina < minb) {
			sum -= mina;
			sum += pc[i];
			sta.erase(sta.find(mina));
			sta.insert(pc[i]);
		}
		else {
			sum -= minb;
			sum += pc[i];
			stb.erase(stb.find(minb));
			stb.insert(pc[i]);
		}
	}

	cout<<sum<<"\n";
}

Measured memory_bytes: 11008
import sys
from math import factorial
MOD = 10**9+7
h, w, k = [int(i) for i in sys.stdin.readline().split()]
# memo_ls[n] : n本の平行線に対し、あみだくじの条件を満たす組み合わせの数
memo_ls2 = [[0 for x in range(2)] for y in range(8)]
memo_ls2[1][0] = 1
for i in range(2,8):
    memo_ls2[i][0] = memo_ls2[i-1][1] + memo_ls2[i-1][0]
    memo_ls2[i][1] = memo_ls2[i-1][0]
memo_ls = [sum(i) for i in memo_ls2]
# memo_ls3[j][i] : j番目にiにいる通り数
memo_ls3 = [[0 for i in range(w)] for j in range(h+1)]
memo_ls3[0][0] = 1
for j in range(1,h+1):
    for i in range(w):
        if i > 0:
            memo_ls3[j][i] += memo_ls3[j-1][i-1] * memo_ls[max(1, i-1)] * memo_ls[max(1, w-1-i)]
        if i < w-1:
            memo_ls3[j][i] += memo_ls3[j - 1][i + 1] * memo_ls[max(1, i)] * memo_ls[max(1, w-i-2)]
        memo_ls3[j][i] += memo_ls3[j-1][i] * memo_ls[max(1, i)] * memo_ls[max(1, w-i-1)]
        memo_ls3[j][i] %= MOD
print(memo_ls3[-1][k-1])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}

int cost(vector<int> &v1,vector<vector<int> > &v,int x)
{
	vector<ll> ans(v[0].size(),0);
	for(int i=0;i<v.size();i++)
	{
		if(v1[i]!=0)
		{
			for(int j=0;j<v[0].size();j++)
			{
				ans[j] = ans[j]+v[i][j];
			}
		}
	}
	ll cost1 = -1;
	for(int i=1;i<ans.size();i++)
	{
		if(ans[i]<x)
		{
			return cost1;
		}
	}
	return ans[0];
}

vector<int> to_binary(int i,int n)
{
	int cnt = n-1;
	vector<int> t(n,0);
	while(i>0)
	{
		int x = i%2;
		t[cnt] = x;
		i = i/2;
		cnt--;
	}
	return t;
}

int main(void)
{
	fast();
	int n,m,x;
	cin>>n>>m>>x;

	vector<vector<int> > v;

	for(int i=0;i<n;i++)
	{
		vector<int> dummy;
		for(int j=0;j<m+1;j++)
		{
			int x1;
			cin>>x1;
			dummy.push_back(x1);
		}
		v.push_back(dummy);
	}
	int r = (1<<n)-1;
	int mini = INT_MAX;
	for(int i=1;i<=r;i++)
	{
		vector<int> v1;
		v1 = to_binary(i,n);
		int xy = cost(v1,v,x);
		if(xy!=-1)
		{
			mini = min(xy,mini);
		}
	}
	if(mini == INT_MAX)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<mini<<endl;
	}
}

Measured memory_bytes: 3672
def setM():
    K2 = K // 2
    k = K // 2
    while k:
        m = int(("1" * (K2 - k) + "0" * (K2 + k)) * 3001, 2)
        M.append((k, m))
        k //= 2

def modp(n):
    K2 = K // 2
    k = K // 2
    for k, m in M:
        n = (n & (~m)) + ((n & m) >> (K2 + k)) * ((1 << K2 + k) % P)
    return n

K = 64
P = 998244353
mm = (1 << K * 3001) - 1
mmm = (1 << K) - 1
M = []
setM()
N, S = map(int, input().split())
A = [int(a) for a in input().split()]
s = 0
ans = 0
for a in A:
    s += 1
    s += s << a * K
    s &= mm
    s = modp(s)
    ans += (s >> S * K) & mmm

print(ans % P)

Measured memory_bytes: 64044
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
     
    // https://youtu.be/L8grWxBlIZ4?t=9858
    // https://youtu.be/ERZuLAxZffQ?t=4765
    const int mod = 1000000007;
    struct mint {
      ll x;
      mint(ll x=0):x(x%mod){}
      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 c[4005][4005];
    void init() {
      c[0][0] = 1;
      for (int i = 0; i <= 4000; i++) {
        for (int j = 0; j <= i; j++) {
          c[i+1][j] += c[i][j];
          c[i+1][j+1] += c[i][j];
        }
      }
    }
    mint comb(int n, int k) {
      return c[n][k];
    }
    mint f2(int n, int k) {
      return comb(n+k-1,k-1);
    }
    mint f(int n, int k) {
      if (n < k) return 0;
      if (n == 0 && k == 0) return 1;
      if (k < 1) return 0;
      return f2(n-k,k);
    }
     
    int main() {
      init();
      int n, k;
      cin >> n >> k;
     
      for (int i = 1; i <= k; i++) {
        mint blue = f(k,i);
        mint red = 0;
        {
          red += f(n-k,i-1);
          red += f(n-k,i);
          red += f(n-k,i);
          red += f(n-k,i+1);
        }
        mint ans = blue*red;
        printf("%lld\n", ans.x);
      }
      return 0;
    }

Measured memory_bytes: 125696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    ll N;
    cin >> N;
    ll A,B;
    cin >> A >> B;
    cout << N / (A + B) * A + min(N % (A + B),A) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define max 200000
using namespace std;
int main(){
	int n,m,i,k=0,j,h=0,c,b;
	int a[max]={0};
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>c>>b;
		if(c==1)a[b]++;
		else if(b==1)a[c]++;
		else if(b==n)a[c]++;
		else if(c==n)a[b]++;
	}
	
	for(i=0;i<n;i++){
	if(a[i]==2){
	cout<<"POSSIBLE"<<endl;
	return 0;
   }
	
	
}
    cout<<"IMPOSSIBLE"<<endl;
	return 0;
} 

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

str S;
int hugs = 0;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> S;
    F0R(i, sz(S) / 2) {
        hugs += (S[i] != S[sz(S) - 1 - i]);
    }
    cout << hugs;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
typedef struct{
    int top,front,right,left,back,bottom;
}Dice;
 
void roll(char c,Dice* d){
    int tmp;
    switch(c){
        case 'N':
        tmp=d->top;
        d->top=d->front;
        d->front=d->bottom;
        d->bottom=d->back;
        d->back=tmp;
        break;
        case 'S':
        tmp=d->top;
        d->top=d->back;
        d->back=d->bottom;
        d->bottom=d->front;
        d->front=tmp;
        break;
        case 'E':
        tmp=d->top;
        d->top=d->left;
        d->left=d->bottom;
        d->bottom=d->right;
        d->right=tmp;
        break;
        case 'W':
        tmp=d->top;
        d->top=d->right;
        d->right=d->bottom;
        d->bottom=d->left;
        d->left=tmp;
        break;
    }
    return;
}
 
int main(void){
    int i,l;
    char d[101];
    Dice dice;
    scanf("%d%d%d%d%d%d",&dice.top,&dice.front,&dice.right,&dice.left,&dice.back,&dice.bottom);
    getchar();
    scanf("%s",d);
    l=strlen(d);
    for(i=0;i<l;i++){
        roll(d[i],&dice);
    }
    printf("%d\n",dice.top);
    return 0;
}


Measured memory_bytes: 1992
#include<bits/stdc++.h>
using namespace std;
template<class T = int> using V = vector<T>; 
template<class T = int> using VV = V< V<T> >;

template<class T> struct Dinic {
    struct Edge {
        int to, rev;
        T cap;
    };
    const int n;
    const T inf = numeric_limits<T>::max();
    VV<Edge> g;
    V<> dist, i;
    Dinic(int n) : n(n), g(n), dist(n), i(n) {}
    void add_edge(int from, int to, T cap) {
        g[from].emplace_back(Edge{to, (int) g[to].size(), cap});
        g[to].emplace_back(Edge{from, (int) g[from].size() - 1, 0});
    }
    void bfs(int s) {
        fill(begin(dist), end(dist), -1);
        queue<int> que;
        dist[s] = 0;
        que.push(s);
        while (!que.empty()) {
            int v = que.front(); que.pop();
            for (const auto& e : g[v]) {
                if (dist[e.to] != -1 or e.cap <= 0) continue;
                dist[e.to] = dist[v] + 1;
                que.push(e.to);
            }
        }
    }
    T dfs(int v, int s, T f) {
        if (v == s) return f;
        for (; i[v] < g[v].size(); ++i[v]) {
            Edge& e = g[v][i[v]];
            if (dist[e.to] >= dist[v] or g[e.to][e.rev].cap <= 0) continue;
            T d = dfs(e.to, s, min(f, g[e.to][e.rev].cap));
            if (d > 0) {
                g[e.to][e.rev].cap -= d;
                e.cap += d;
                return d;
            }
        }
        return 0;
    }
    T max_flow(int s, int t) {
        T res = 0;
        while (true) {
            bfs(s);
            if (dist[t] == -1) return res;
            fill(begin(i), end(i), 0);
            while (true) {
                T f = dfs(t, s, inf);
                if (f == 0) break;
                res += f;
            }
        }
    }
};
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    string U; cin >> U;
    V<> A(n); for (auto&& e : A) cin >> e;
    Dinic<int> g(n + 2);
    int S = n, T = n + 1;
    for (int i = 0; i < n; ++i) {
        if (U[i] == 'L') {
            g.add_edge(S, i, A[i]);
            g.add_edge(i, T, 0);
        } else {
            g.add_edge(S, i, 0);
            g.add_edge(i, T, A[i]);
        }
    }
    while (m--) {
        int i, j, B; cin >> i >> j >> B, --i, --j;
        if (i > j) swap(i, j);
        g.add_edge(j, i, B);
    }
    cout << g.max_flow(S, T) << '\n';
    return 0;
}


Measured memory_bytes: 3284
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
int main()
{
  int n; cin >> n;
  ll d; cin >> d;
  int res = 0;
  rep(i,n) {
    ll x,y; cin >> x >> y;
    if(d*d >= x*x + y*y) res++;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 3620
N = int(input())
S = input()

p = 1
ccnt = [0]*26
MOD = 10**9 + 7

for i in range(N):
    index = ord(S[i])-ord("a")
    ccnt[index] += 1
for i in range(26):
    ccnt[i] += 1

ans = 1
for i in range(26):
    ans *= ccnt[i]
    ans = ans % MOD

print(ans-1)

Measured memory_bytes: 40176
def SumReturn(num):
    total=0
    while num!=0:
        total += num%10
        num //= 10
        
    return total

if __name__ == '__main__':
    
    n = int(input())
    min = 10000
    
    for i in range(1,n):
        if(min > SumReturn(i)+SumReturn(n-i)):
            min = SumReturn(i)+SumReturn(n-i)
        
        
    print(min)

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

struct Segtree{
	typedef ll sgT;
	vector<sgT> seg;
	int nbn; sgT INF;
	void init(int n){
		for(nbn=1; nbn<n+2; nbn<<=1); INF=1LL<<29; // min:+inf,max:-inf
		seg.assign(nbn*2, INF);
	}
	sgT comp(sgT l, sgT r){return min(l, r);}  //min<->max
	void update(int k,sgT x){
		k+=nbn-1; seg[k]=x;
		while(k>0){ k=(k-1)/2; seg[k]=comp(seg[k*2+1],seg[k*2+2]); }
	}
	sgT query2(int a,int b,int l,int r,int k){
		if(b<=l||r<=a) return INF;
		if(a<=l&&r<=b) return seg[k];
		return comp(query2(a,b,l,(l+r)/2,k*2+1), query2(a,b,(l+r)/2,r,k*2+2));
	}
	sgT query(int a,int b){ return query2(a,b,0,nbn,0); }
	sgT get(int a){return seg[nbn+a-1];}  // =query(a,a+1)
};

struct Sts{
	int v,l,r,a,b;
	Sts(int v,int l,int r,int a,int b):v(v),l(l),r(r),a(a),b(b){}
	bool operator>(const Sts& b) const {
		return v > b.v; 
	}

};

Segtree sgg, sgk;


int gtps(int l, int r, int v,  Segtree& sgt){
	
	int lo=l-1, hi=r;
	while(hi - lo >1){
		int md = (hi + lo) >> 1;
		if( sgt.query(lo, md+1) <= v ) hi = md; else lo = md; 
	}

	return hi;
}

Sts f(int l, int r){
	//cout <<"l="<<l <<"  ";
	int v,a,b;
	if(l%2){
		v = sgk.query(l,r);
		a = gtps(l,r,v,sgk);
		int t = sgg.query(a+1,r);
		b = gtps(a+1,r,t,sgg);
	}else{
		v = sgg.query(l,r);
		a = gtps(l,r,v,sgg);
		int t = sgk.query(a+1,r);
		b = gtps(a+1,r,t,sgk);
	}
	
	return Sts(v,l,r,a,b);
}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	VI p(n);
	sgg.init(n+2); sgk.init(n+2);

	rep(i,n){
		int c; cin >>c;
		p[i] = c;
		if(i%2) sgk.update(i,c);
		else sgg.update(i,c);
	}
	Sts sta = f(0,n);
	priority_queue<Sts, vector<Sts>, greater<Sts> > pq;
	pq.push(sta);
	VI ans;
	while(!pq.empty()){
		auto cr = pq.top(); pq.pop();
		//printf("%d:%d:%d:%d:%d   ",cr.v,cr.l,cr.r,cr.a,cr.b);
		//if(cr.v > n) continue;
		ans.push_back(p[cr.a]);
		ans.push_back(p[cr.b]);
		if(cr.a - cr.l > 1){
			auto nx = f(cr.l, cr.a);
			pq.push(nx);
		}
		if(cr.b - cr.a > 1){
			auto nx = f(cr.a+1, cr.b);
			pq.push(nx);
		}
		if(cr.r - cr.b > 1){
			auto nx = f(cr.b+1, cr.r);
			pq.push(nx);
		}
	}
	
	for(auto x :ans) printf("%d ",x); puts("");
	return 0;
}


Measured memory_bytes: 13076
import sys
from itertools import count

def f(plus, minus, zero, val):
    t = 0
    if val > 0:
        t += len(plus) * len(minus) + zero * (len(plus) + len(minus)) + zero * (zero - 1) // 2
        # print(f'    zero {len(plus) * len(minus) + zero * (len(plus) + len(minus)) + zero * (zero - 1) // 2=}')
        if len(plus) >= 2:
            right_index = len(plus) -1
            for left_index, left in enumerate(plus):
                while left_index < right_index and left * plus[right_index] > val:
                    right_index -= 1
                t += max(0, right_index - left_index)
                # print(f'    plus {right_index-left_index=}')
        if len(minus) >= 2:
            left_index = 0
            for right_index, right in zip(count(len(minus) - 1, -1), reversed(minus)):
                while left_index < right_index and minus[left_index] * right > val:
                    left_index += 1
                t += max(0, right_index - left_index)
                # print(f'    minus {right_index-left_index=} {right_index=} {right=}')
    elif val < 0:
        if plus:
            plus_index = 0
            for m in minus:
                while plus_index < len(plus) and plus[plus_index] * m > val:
                    plus_index += 1
                t += len(plus) - plus_index
                # print(f'    mix {len(plus) - plus_index=}')
    else:
        t += len(plus) * len(minus) + zero * (len(plus) + len(minus)) + zero * (zero - 1) // 2
        # print(f'    zero {len(plus) * len(minus) + zero * (len(plus) + len(minus)) + zero * (zero - 1) // 2=}')
    # print(f'  {val=}, {t=}')
    return t


def resolve(in_):
    N, K = map(int, in_.readline().split())
    plus = []
    minus = []
    zero = 0
    for a in map(int, in_.readline().split()):
        if a > 0:
            plus.append(a)
        elif a < 0:
            minus.append(a)
        else:
            zero += 1

    plus.sort()
    minus.sort()

    ng = -(10 ** 18) - 1
    ok = 10 ** 18
    while ok - ng > 1:
        mid = (ok + ng) // 2
        # print(f'{ok=} {ng=} {mid=}')

        if f(plus, minus, zero, mid) >= K:
            ok = mid
        else:
            ng = mid

    # print(f'{ok=} {ng=} {mid=}')
    return ok


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 97260
import sys
import collections
N = int(input())
input = sys.stdin.readline
d = collections.defaultdict(int)
for i in range(N):
    a = int(input())
    d[a] += 1
ans = 0
for x in d:
    if d[x] % 2 == 1:
        ans += 1
print(ans)


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

long long mINF=-9999999999999999LL;

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(auto &i:A)cin >> i;
	
	long long dp[N+1][3];
	for(int i=0;i<N+1;i++)for(int j=0;j<3;j++)dp[i][j]=mINF;
	dp[0][0]=dp[0][1]=dp[0][2]=dp[0][1]=dp[0][2]=dp[1][2]=0;
	dp[1][0]=A[0];
	dp[2][1]=A[1];
	if(N%2==1)dp[3][2]=A[2];
	
	for(int i=2;i<N;i++){
		dp[i+1][0]=max(dp[i+1][0],dp[i-1][0]+A[i]);
		dp[i+1][1]=max(dp[i+1][1],dp[i-1][1]+A[i]);
		dp[i+1][1]=max(dp[i+1][1],dp[i-2][0]+A[i]);
		if(N%2==1 && i>2){
			dp[i+1][2]=max(dp[i+1][2],dp[i-1][2]+A[i]);
			dp[i+1][2]=max(dp[i+1][2],dp[i-2][1]+A[i]);
			dp[i+1][2]=max(dp[i+1][2],dp[i-3][0]+A[i]);
		}
	}
	long long ans;
	if(N%2==0)ans=max(dp[N-1][0],dp[N][1]);
	if(N%2==1)ans=max(max(dp[N-2][0],dp[N-1][1]),dp[N][2]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int ac = 0;
            int wa = 0;
            int tle = 0;
            int re = 0;

            for(int i=0; i<N; i++)
            {
                String S = Console.ReadLine();
                if (S.Equals("AC"))
                {
                    ac++;
                }
                else if (S.Equals("WA"))
                {
                    wa++;
                }
                else if (S.Equals("TLE"))
                {
                    tle++;
                }
                else if (S.Equals("RE"))
                {
                    re++;
                }
            }

            Console.WriteLine("AC x " + ac);
            Console.WriteLine("WA x " + wa);
            Console.WriteLine("TLE x " + tle);
            Console.WriteLine("RE x " + re);

        }
    }
}

Measured memory_bytes: 30544
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}


const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    int n;
    cin >> n;
    int h[n];
    rep(i,n) cin >> h[i];

    int mx = 0;
    rep(i,n) mx = max(mx, h[i]);

    int ans = 0;
    bool flag;
    for (int i=1; i <= mx; i++) {
        flag = false;
        for (int j=0; j < n; j++) {
            if (flag == false && i <= h[j]) {
                ans++;
                flag = true;
            }
            else if (h[j] < i) {
                flag = false;
            }
        }
    }


    cout << ans << endl;

    
    
}





//              g++ -std=c++1z


Measured memory_bytes: 384
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
const int INT_MAX = 1000000000;

int n, arr[100005],k;
int dp[100005];
int f(int ind){ 
    if(ind==n-1) return 0;
    if(ind>=n) return INT_MAX;
    if(dp[ind]!=-1) return dp[ind];
    int ans=INT_MAX;
    for(int x=1;x<=k;x++){
        int left=INT_MAX;
        if(ind+x<n)  left = abs(arr[ind]-arr[ind+x])+f(ind+x);
        ans=min(ans,left);
}
    return dp[ind]=ans;
}
signed main(){
   
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    

    cout<<f(0);
}

Measured memory_bytes: 12184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B;
    cin >>A>>B;
    ll ansA=0,ansB=0;
    rep3(i,2,55){
        if((A/(ll(1)<<(i-1)))%2==1){
            if(A%2 == 0){
                ansA+=(ll(1)<<(i-1));
            }
        }

        if((B/(ll(1)<<(i-1)))%2==1){
            if(B%2 == 0){
                ansB+=(ll(1)<<(i-1));
            }
        }
    }

    if((A%4)==1 || (A%4)==2){
        ansA++;
    }

    if((B%4)==1 || (B%4)==2){
        ansB++;
    }

    cout << (ansA^ansB^A) << endl;


    return 0;
    

}

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

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

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

LL mod = 1000000007;

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

  LL N,K;
  cin >> N >> K;
  vector<LL> V(N);
  REP(i,N){
    cin >> V[i];
  }

  LL max = LONG_MIN;

  REP(i,50){
    REP(j,50){
      REP(k,50){
        if(i+j+k<=K){
          vector<LL> h;
          LL sum = 0;
          REP(ii, N)
          {
            if(ii<i||N-j<=ii){
              h.push_back(V[ii]);
              sum += V[ii];
            }
          }
          SORT(h);
          REP(kk,k){
            if(h.size()<=kk){
              break;
            }
            if(h[kk]>=0){
              break;
            }
            sum -= h[kk];
          }
          if(max<sum){
            max = sum;
          }
        }
      }
    }
  }

  cout << max << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    ld x=pi/(ld)30*m;
    ld y=(60*h+m)*pi/360;
    ld ra=min(abs(x-y),2*pi-abs(x-y));
    ld ans=a*a+b*b-2*a*b*cosl(ra);
    cout<<sqrtl(ans)<<endl;

    return false;   
}

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


Measured memory_bytes: 3868
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
using namespace std;
int main(){
	int n,m,ans=0;
	cin>>n>>m;
	if(n>1){
		ans+=n*(n-1)/2;
	}
	if(m>1){
		ans+=m*(m-1)/2;
	}
	cout<<ans;
	return 0;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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




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



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  cout<<fixed<<setprecision(10);

  ll a,b; cin>>a>>b;

  if((a*b)%2)puts("Yes");
  else puts("No");


}






Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>

using namespace std;

#define ll long long
#define ull unsigned long long
const ll MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

	for (int ii = 0; ii < S.size(); ++ii){
	cout << "x";
	}
	cout  << "\n";

	return 0;
}


Measured memory_bytes: 3624
/* D */

#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

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

	string s;
	cin >> s;

	std::vector<int> v(n+1, 0);
	char pre = '1';

	int q = 0;

	for(int i = 0; i < n; i++){
		if(s[i] != pre){
			q++;
		}
		v[q]++;
		pre = s[i];
	}

	int saka = 1;

	for(int l = 0; l + 2 * k < n; l += 2 ){
		int p = 0;
		for(int t = l; t <= l + 2 * k; t++){
			p += v[t];
		}

		saka = max(p, saka);
	}

	if(2 * k >= n) saka = n;

	cout << saka << endl;


}

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

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Problem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            if (N % 1000 == 0)
                out.println(0);
            else
                out.println(1000 - (N % 1000));
        }

    }

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

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 25668
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod=1000000007
def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y: x*y%mod, range(n, n - r, -1), 1)
    denom = pow( reduce(lambda x,y: x*y%mod, range(1, r + 1), 1) , mod-2, mod)
    return numer * denom % mod


def main():
    x = int(input().strip())
    if x>=30:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 78320
#include <iostream>

using namespace std;

int main() {
    int n;
    long long a;
    long long maxValue = -1000000;
    long long minValue = 1000000;
    long long sum = 0;

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>a;
        if(a < minValue) minValue = a;
        if(a > maxValue) maxValue = a;
        sum += a;
    }

    cout<< minValue <<" "<< maxValue <<" "<< sum << endl;

    return 0;}

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

int main() {
  int N,M;
  cin >> N >> M ;
  vector<int> A(N,0);
  int a;
  
  for (int i=0;i<M*2;i++){
    cin >> a;
    A.at(a-1)++;
  }  

  for (int j=0;j<N;j++){
    cout << A.at(j) << endl;
  }
}

Measured memory_bytes: 3568
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(vector<string>& M) {
        int n = M.size();
        int m = M[0].length();

        const int INF = 1 << 20;
        vector<vector<int>> dis(n, vector<int>(m, INF));

        vector<int> X{0, -1, 0, 1};
        vector<int> Y{-1, 0, 1, 0};
        auto bfs = [&](int sx, int sy) {
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    dis[i][j] = INF;
                }
            }
            dis[sx][sy] = 0;
            queue<pair<int,int>> que;
            que.emplace(sx, sy);

            int res = 0;
            while (!que.empty()) {
                int x = que.front().first;
                int y = que.front().second;
                que.pop();
                int d = dis[x][y];
                res = max(res, d);

                for (int i = 0; i < X.size(); ++i) {
                    int nx = x + X[i];
                    int ny = y + Y[i];
                    if (nx >= 0 && nx < n && ny >= 0 && ny < m && M[nx][ny] != '#') {
                        if (dis[nx][ny] > d + 1) {
                            dis[nx][ny] = d + 1;
                            que.emplace(nx, ny);
                        }
                    }
                }
            }
            return res;
        };

        int res = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if (M[i][j] != '#') {
                    res = max(res, bfs(i, j));
                }
            }
        }

        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, w;
    cin >> h >> w;
    vector<string> M(h);
    for (int i = 0; i < h; ++i) {
        cin >> M[i];
    }

    Solution sol;
    cout << sol.solve(M) << "\n";

    return 0;
}

Measured memory_bytes: 256
ab= input().split()

a = int(ab[0])
b = int(ab[1])

ans = 0
x = []
for i in range(a, b+1):
	for j in str(i):
		x.append(j)
	x.reverse()
	y = ''.join(x)
	if int(i) == int(y):
		ans += 1
	x.clear()#配列の中身を全消しする


print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    char a, b;
    scanf("%c %c", &a, &b);
    if(a=='H')printf("%c\n", b);
    else if(b=='H') printf("D\n");
    else printf("H\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    ll int x;
    cin >> x;
    ll int ans = 0;
    ll int mon = 100;

    while(1){
        if(mon >= x){
            break;
        }
        mon = (1.01)*mon;
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main() {
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
	cout<<"Yes"<<"\n";
	else
	cout<<"No"<<"\n";
	
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char **argv){
    int N;
    std::string S, T;
    std::cin >> N >> S >> T;
    for(int i = 0; i < N; i++){
        std::cout << S.at(i) << T.at(i);
    }
    std::cout << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
vector <int> vec[100005];
bool vis[100005];
int sg[100005];
void dfs(int x)
{sg[x]=0;vis[x]=1;
for (int i=0;i<vec[x].size();i++)
{if (!vis[vec[x][i]])
{dfs(vec[x][i]);sg[x]^=(sg[vec[x][i]]+1);}
}
}
int main (){
	int i,a,b;
	scanf ("%d",&n);
	for (i=1;i<n;i++)
	{scanf ("%d%d",&a,&b);
	vec[a].push_back(b);
	vec[b].push_back(a);
	}
	dfs(1);
	if (sg[1]==0)
	{puts("Bob");}
	else {puts("Alice");}
	return 0;
}

Measured memory_bytes: 10880
#include <iostream>

using namespace std;
int main()
{
    int N, L;

    cin >> N >> L;

    int taste = 0;
    int minabs = 1000;
    for ( int i = 1; i <= N; i ++ ) {
        // cout << L + i - 1 << " ";
        taste += (L + i - 1);
        if ( abs(L + i - 1) < abs(minabs) ) minabs = L+i-1;   
    }
    // cout << endl;
    taste -= minabs;
    cout << taste << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	long long p=a*c, q=a*d, r=b*c, s=b*d;
	cout << max(max(max(p,q), r), s);
	return 0;
}

Measured memory_bytes: 3128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #include <C:\include\boost\multiprecision\cpp_int.hpp>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// using namespace boost::multiprecision;
ll mod = 1000000007;

int main(){
    ll n;
    cin>>n;
    ll mi=mod*100,ans=-100*mod;
    rep(i,n){
        ll a;
        cin>>a;
        ans = max(ans,a-mi);
        mi=min(a,mi);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3092
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

ll n, m, q, ans = 0;
vector<vector<int>> a;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> q;
	a.resize(q, vector<int>(4));
	for (int i = 0; i < q; i++) {
		for (int j = 0; j < 4; j++)cin >> a[i][j];
	}
	vector<int> b(n, 1);
	while (true) {
		ll temp = 0;
		for (int i = 0; i < q; i++) {
			if (b[a[i][1] - 1] - b[a[i][0] - 1] == a[i][2]) temp += a[i][3];
		}
		ans = max(ans, temp);
		bool ok = false;
		for (int i = n - 1; i >= 0; i--) {
			if (b[i] != m) {
				b[i]++;
				ok = true;
				for (int j = i + 1; j < n; j++) {
					b[j] = b[i];
				}
				break;
			}
		}
		if (!ok)break;
	}
	cout << ans;
}

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 2000 + 123;                                          
const int PRI = 555557;
const int pri = 997;

int tests = 1;

vector < int > g[N];
int root;
int d[N];
int dd[N];
bool u[N];
int n, k, mx;

void dfs (int v, int lvl) {
	u[v] = 1;
	for (auto to : g[v]) {
		if(!u[to]) {
			dfs(to, lvl + 1);
			if(v == root) 
				dd[v] = max(dd[v], dd[to]);
			else
				dd[v] += dd[to];
			d[v] += d[to];
		}
	}
	if(lvl <= k / 2) d[v] ++;
	if(lvl == (k / 2 + 1)) dd[v] ++;
}

inline void Solve () {
	//easy
	cin >> n >> k;	
	for (int i = 1; i < n; i ++) {
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	int now = 1;
	for (int i = 1; i <= n; i ++) {
		memset(u, 0, sizeof u);
		memset(d, 0, sizeof d);
		memset(dd, 0, sizeof dd);
		root = i;
		dfs(i, 0);

		if (k & 1)
			now = max(now, d[i] + dd[i]);
		else
			now = max(now, d[i]);
	}

	cout << max(n - now, 0);
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
	int N,M,load[50],a,b,i;
	scanf("%d%d",&N,&M);
	for(i=0;i<N;i++)load[i]=0;
	for(i=0;i<M;i++){
		scanf("%d%d",&a,&b);
		load[a-1]++;
		load[b-1]++;
	}
	for(i=0;i<N;i++)printf("%d\n",load[i]);
}

Measured memory_bytes: 128
a = [int(i) for i in input().split()]
s = input()
data = []
for i in range(a[0]):
    if s[i] == "L":
        data.append(0)
    else:
        data.append(1)
        
#print(data)
count = 1
for i in range(a[0]-1):
    count += (data[i] + data[i+1])%2

#print(count)

if count > a[1]*2:
    print(a[0]+a[1]*2-count)
else:
    print(a[0]-1)

Measured memory_bytes: 4084
N = int(input())
M = 30001
if N == 3:
  print(2, 5, 63)
  exit()

L = [3, 9]

N -= 2
if N % 2 == 1:
  L.append(6)
  N -= 1

if N != 0:
  for i in range(2, M, 2):
    if i % 6 == 0: continue
    L.append(i)
    N -= 1
    if N == 0:
      break
  if N % 2 == 1:
    N += 1
    L.pop()

if N != 0:
  for i in range(15, M, 6):
    L.append(i)
    N -= 1
    if N == 0:
      break
if N % 2 == 1:
  N += 1
  L.pop()

if N != 0:
  for i in range(12, M, 6):
    N -= 1
    L.append(i)
    if N == 0:
      break

if N == 1:
  L.append(6)

print(" ".join(list(map(str, L))))


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

const int MAXN = 100005;

struct node {
	int to, next;
} edge[MAXN*2];
int head[MAXN], top = 0;
inline void push(int i, int j)
{
	edge[++top] = (node) {j, head[i]}, head[i] = top;
}

int siz[MAXN], fa[MAXN];
void dfs(int nd, int f)
{
	siz[nd] = 1, fa[nd] = f;
	for (int i = head[nd]; i; i = edge[i].next) {
		int to = edge[i].to;
		if (to == f) continue;
		dfs(to, nd), siz[nd] += siz[to]; 
	}
}

int n, u, v;
int a[MAXN], atp = 0;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &u, &v);
		push(u, v), push(v, u);
	}
	dfs(1, 0);
	for (int i = n; fa[i] != 1; i = fa[i]) a[++atp] = fa[i];
	int len = atp/2, nd = n;
	for (int i = 1; i <= len; i++) nd = fa[nd];
	int sec_able = siz[nd]-1-len, fst_able = n-siz[nd]-1-(atp-len);
	if (atp&1) {
		if (fst_able >= sec_able) puts("Fennec");
		else puts("Snuke");
	} else {
		if (fst_able > sec_able) puts("Fennec");
		else puts("Snuke");
	}
	return 0;
}


Measured memory_bytes: 8064
inputs = list(map(lambda i: int(i), input().split()))
N, A, B = inputs[0], inputs[1], inputs[2]
total_sum = 0

for n in range(N+1):
    n_sum = sum(list(map(lambda m: int(m), list(str(n)))))
    if n_sum in range(A, B+1):
        total_sum += n

print(total_sum)

Measured memory_bytes: 3064
x,n=map(int, input().split())
if n == 0:
  print(x)
  exit()
p=list(map(int, input().split()))
all=set(range(-100,102))
s_p=set(p)
kouho=sorted(all-s_p)

min_dis=201
for i in kouho:
  dis=abs(i-x)
  if min_dis > dis:
    min_i=i
    min_dis=dis
print(min_i)


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

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

    vector<int> a(m);
    rep(i,0,m){
        cin>>a.at(i);
        n-=a.at(i);
    }

    if(n<0) n=-1;
    cout<<n<<endl;
}

Measured memory_bytes: 3640