akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int A =scan.nextInt();
        int B=scan.nextInt();
        int C =scan.nextInt();
        int X =scan.nextInt();
        int Y=scan.nextInt();

        int ans = (int) 1e9;
        for (int i = 0; i < 2 * (X + Y) + 1; i++) {
            int ABpizza = i;
            int Apizza = Math.max(X-i/2,0);
            int Bpizza = Math.max(Y-i/2,0);
                    ans = Math.min(ans, Apizza * A + Bpizza * B + ABpizza * C);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 24020
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> a(n); cin >> a;
  vector<ll> S(n+1, 0);
  rep(i, n) S[i+1] = S[i] + a[i];
  vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
  rep(w, 1, n+1) rep(l, n) {
    ll r = l + w;
    if (r > n) break;
    chmax(dp[l][r], a[l] + (S[r] - S[l+1]) - dp[l+1][r]);
    chmax(dp[l][r], a[r-1] + (S[r-1] - S[l]) - dp[l][r-1]);
  }
  ll X = dp[0][n], Y = S[n] - S[0] - X;
  cout << X - Y << endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
int n;
ii L[200005], R[200005];
vector<ii> S[200005];
ll V;
void dfs(int u){
    if (L[u].first == 0){
        S[u].push_back({0ll,0ll});
        return;
    }
    int l = L[u].first, cl = L[u].second;
    int r = R[u].first, cr = R[u].second;
    dfs(l);
    dfs(r);
    if (S[l].size() < S[r].size()){
        swap(l,r);
        swap(cl,cr);
    }
    vector<ii> P;
    int cur = S[r].size()-1;
    for (auto x : S[l]){
        while (cur >= 0 && S[r][cur].first + x.first + cl + cr > V) cur--;
        if (cur == -1) break;
        P.push_back({cl+x.second,cr+S[r][cur].second});
        P.push_back({cr+S[r][cur].second,cl+x.second});
    }
    sort(P.begin(),P.end());
    for (auto x : P){
        if (S[u].empty() || S[u].back().second > x.second) S[u].push_back(x);
    }
}
bool test(ll x){
    V = x;
    for (int i = 1; i <= n; i++) S[i].clear();
    dfs(1);
    if (S[1].size()) return true;
    else return false;
}
int main(){
    scanf("%d",&n);
    for (int i = 2; i <= n; i++){
        int a,v;
        scanf("%d%d",&a,&v);
        if (L[a].first == 0){
            L[a] = ii(i,v);
        }
        else{
            R[a] = ii(i,v);
        }
    }
    ll lo = 0, hi = 131072ll*131072;
    while (lo < hi){
        ll mid = (lo+hi)/2;
        if (test(mid)) hi = mid;
        else lo = mid+1;
    }
    printf("%lld",lo);
}


Measured memory_bytes: 39084
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    int D, T, S;
    cin >> D >> T >> S;
    cout << YN(D <= S*T) << endl;
}    

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
bool ok[100010];
int n,m;
int a[110];
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>a[i];
	sort(a,a+n);
	for (int i=0;i<=100000;i++)
	{
		if (ok[i]) continue;
		for (int j=0;j<n;j++)
		{
			if (i+a[j]>m) break;
			ok[i+a[j]]=1;
		}
	}
	cout <<(ok[m] ? "First" : "Second");
	return 0;
}

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

/**
 * Created by Santa on 2016/10/16.
 */
public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long[] map = new long[N];

        for (int i = 0; i < N; i++) {
            map[i] = scanner.nextLong();
        }

        Arrays.sort(map);

        long ans = -1;
        int ok = 0;
        for (int i = 1; i < N; i++) {

            if(map[N - i] == map[N - i - 1]){
                if(ans != -1){
                    ans *= map[N - i];
                    ok = 1;
                    break;
                }else{
                    ans = map[N - i];
                    i++;
                }
            }
        }
        if(ok != 0) {
            System.out.println(ans);
        }else{
            System.out.println(0);
        }

    }


}

Measured memory_bytes: 50528
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>
#include <cassert>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<lint>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
using si = set<int>;
#define mii = map<int, int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20
#define yes "Yes"
#define no "No"

constexpr lint MOD = 1e9 + 7;
const double PI = acos(-1);
lint A, B, C, D, E, F, G, H, I, J, K, L, M, N;
lint O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
lint ans = INT32_MAX;
vvi n;
vi m;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N >> M >> X;
	n.resize(N, vi(M));

	rep(i, N) {
		rep(j, M + 1) {
			cin >> n[i][j];
		}
	}

	rep(i, pow(2, N)) {
		lint sum = 0;
		m.assign(M, 0);
		rep(j, N) {
			if (i & (1 << j)) {
				sum += n[j][0];
				rep(k, M) {
					m[k] += n[j][k + 1];
				}
			}
		}

		bool tmp = true;
		rep(j, M) {
			if (m[j] < X) {
				tmp = false;
				break;
			}
		}
		if (tmp) {
			ans = min(ans, sum);
		}
	}

	cout << (ans != INT32_MAX ? ans : -1) << endl;
    return 0;
}

Measured memory_bytes: 4052
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        int[] num = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        if(num[0] < num[1] && num[1] < num[2])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

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

int main(){
  int A,B,a,n,x1,x2,x3,x4;
  int count=0;
  cin >> A >> B;
  n = B - A + 1;
  a=A;
  for (int i = 0;i< n; i++){
    x4=a%10;
    a=a/10;
    x3=a%10;
    a=a/100;
    x2=a%10;
    a=a/10;
    x1=a%10;
    if(!(x1-x4||x2-x3)){
      count +=1;
    }
    a=A+i+1;
  }
  cout << count;
}


Measured memory_bytes: 256
from collections import Counter
s = Counter(input())

if s["N"]>=1 and s["S"]>=1 and s["W"]>=1 and s["E"]>=1:
    print('Yes')
    exit()
elif s["N"]>=1 and s["S"]>=1 and s["W"]==0 and s["E"]==0:
    print('Yes')
    exit()
elif s["N"]==0 and s["S"]==0 and s["W"]>=1 and s["E"]>=1:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3316
N,M = map(int,raw_input().split())

def factorize(n):
	fct = []  # prime factor
	b, e = 2, 0  # base, exponent
	while b * b <= n:
		while n % b == 0:
			n = n / b
			e = e + 1
		if e > 0:
			fct.append((b, e))
		b, e = b + 1, 0
	if n > 1:
		fct.append((n, 1))
	return fct

def comb(n,r):
	ans = 1
	for i in range(r):
		ans=ans*(n-i)
		ans=ans/(i+1)
	return ans%(10**9 + 7)

fct= factorize(M)

ans = 1

for f in fct:
	ans=(ans *comb(f[1]+N-1,f[1]))%(10**9+7)

print ans

Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
vector<int> vec;
int a;
void up(int a){
  vec.push_back(a);
  int i=vec.size()-1;
  int flag=1;
  while(flag){
    flag=0;
    if(vec[i]>vec[(i-1)/2]){
      swap(vec[i],vec[(i-1)/2]);
      i=(i-1)/2;
      flag=1;
    }
  }
}

void down(){
  vec[0]=vec[vec.size()-1];
  vec.erase(vec.begin()+vec.size()-1);
  int flag=1;
  int i=0;
  while(flag){
    flag=0;
    if(i*2+1>=vec.size()) break;
    else if(i*2+1==vec.size()-1){
      if(vec[i]<vec[i*2+1]){
	swap(vec[i],vec[i*2+1]);
	i=i*2+1;
	flag=1;
      }
    }
    else if(vec[i]<max(vec[i*2+1],vec[i*2+2])){
	  if(vec[i*2+1]>vec[i*2+2]){
	    swap(vec[i],vec[i*2+1]);
	    i=i*2+1;
	    flag=1;
	  }
	  else{
	    swap(vec[i],vec[i*2+2]);
	    i=i*2+2;
	    flag=1;
	  }
    }
  }
}
int main(){
  string str;
  
  while(1){
    cin>>str;
    if(str=="end")break;

    else if(str=="insert"){
      cin>>a;
      up(a);
    }
    
    else if(str=="extract"){
      cout<<vec[0]<<endl;
      down();
    }

  }

  return 0;
}
    



Measured memory_bytes: 7156
#include <stdio.h>

int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a < b){
		printf("a < b\n");	
	}else if(a > b){
		printf("a > b\n");
	}else {
		printf("a == b\n");
	}

return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>

int gcd(int a,int b) {
	return b==0?a:gcd(b,a%b);
}

int main(void) {
	int p,n;
	int x,y,u,v;
	int i,nowb,nows,g;
	int left,right,mid;
	while(scanf("%d%d",&p,&n)==2 && (p|n)!=0) {
		x=n;y=1;u=1;v=n;
		for(i=1;i<=n;i++) {
			/* search x/y */
			left=1;right=n;
			while(left<=right) {
				mid=(left+right)/2;
				if((long long)i*i*p<mid*mid) {
					right=mid-1;
				} else {
					left=mid+1;
				}
			}
			nows=right+1;
			if(0<nows && nows<=n) {
				g=gcd(nows,i);
				nows/=g;nowb=i/g;
				if(nows*y<x*nowb){x=nows;y=nowb;}
			}
			/* search u/v */
			left=1;right=n;
			while(left<=right) {
				mid=(left+right)/2;
				if(mid*mid<(long long)i*i*p) {
					left=mid+1;
				} else {
					right=mid-1;
				}
			}
			nows=left-1;
			if(0<nows && nows<=n) {
				g=gcd(nows,i);
				nows/=g;nowb=i/g;
				if(u*nowb<nows*v){u=nows;v=nowb;}
			}
		}
		printf("%d/%d %d/%d\n",x,y,u,v);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <ctime>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	int n, m;
	cin >> n >> m;
	cout << n - m - 1 << endl; 
    return 0;
}

Measured memory_bytes: 3040
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 262144
long long ans[400][400] = {};
int main() {
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	REP(i, n) {
		REP(q, n) {
			cin >> ans[i][q];
		}
	}
	for (int i = 0;i < n;++i) {
		long long slower[400] = {};
		long long cnt[400] = {};
		long long visited[400] = {};
		for (int q = 0;q < n;++q) {
			slower[q] = LONG_INF;
		}
		slower[i] = 0;
		priority_queue<pair<int, int>,vector<pair<int,int>>,greater<pair<int,int>>> geko;
		geko.push(make_pair(0, i));
		while (geko.empty() == false) {
			long long now = geko.top().second;
			geko.pop();
			if (visited[now] == false) {
				visited[now] = true;
				for (int j = 0;j < n;++j) {
					if (j != now) {
						if (slower[now] + ans[now][j] < slower[j]) {
							cnt[j] = 1;
							slower[j] = slower[now] + ans[now][j];
							geko.push(make_pair(slower[j], j));
						}
						else if (slower[now] + ans[now][j] == slower[j]) {
							cnt[j]++;
						}
					}
				}
			}
		}
		for (int q = 0;q < n;++q) {
			if (ans[i][q] != slower[q]) {
				cout << -1 << endl;
				return 0;
			}
			if (cnt[q] > 1) {
				ans[i][q] = LONG_INF;
			}
		}
	}
	long long final_ans = 0;
	for (int i = 0;i < n;++i) {
		for (int q = 0;q < n;++q) {
			if (ans[i][q] != LONG_INF) {
				final_ans += ans[i][q];
			}
		}
	}
	final_ans /= (long long)2;
	cout << final_ans << endl;
	return 0;
}

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


int main(void){
    vector<bool> array(1299800, true);

    for(int i = 2; i < 1299750; i++){
        if(array[i] == true){
            for(int j = 2*i; j < 1299750; j += i){
                array[j] = false;
            }
        }
    }

    while(1){
        int n; cin >> n;
        if(n == 0) break;
        int up = n, down = n;
        
        while(1){
            if(array[up] == true) break;
            up++;
        }

        while(1){
            if(array[down] == true) break;
            down--;
        }

        cout << up - down << endl;
    }

    return 0;
}

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

def count(s):
    ans = 0
    for i, a in enumerate(A):
        if i == 0:
            continue
        if s < 0:
            if 1-s-a >= 0:
                ans += 1-s-a
                s = 1
            else:
                s += a
        elif s > 0:
            if s+a+1 >= 0:
                ans += s+a+1
                s = -1
            else:
                s += a
    return ans

b = A[0]
ans1 = count(b)
if b > 0:
    ans2 = count(-1)+b+1
elif b < 0:
    ans2 = count(1)+1-b
else:
    ans1 = count(1)+1
    ans2 = count(-1)+1
print(min(ans1, ans2))

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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int N = 2e+5 + 5;

int n;
int dat[N];
ll freq[N];

ll comb2(ll n) {
	return n*(n-1)/2;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &dat[i]);
		freq[dat[i]]++;
	}
	ll ans_all = 0;
	for (int i = 0; i < N; i++) {
		ans_all += comb2(freq[i]);
	}

	for (int i = 0; i < n; i++) {
		ll cur_ans = ans_all - comb2(freq[dat[i]]);
		cur_ans += comb2(freq[dat[i]] - 1);
		printf("%lld\n", cur_ans);
	}
	return 0;
}

Measured memory_bytes: 3968
N = gets.to_i
T = gets.split.map{|i|i.to_i}
total = T.inject(0){|r, i|r + i}
M = gets.to_i
M.times{
    p, x = gets.split.map{|i|i.to_i}
    puts total - T[p - 1] + x
}


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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int N_MAX = 2999;

int main(){
    int N; cin >> N;
    vector<double> p(N, 0);
    rep(i, N) cin >> p[i];

    vector<vector<double> > dp(N_MAX+1, vector<double>(N_MAX+1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) dp[i][0] = dp[i - 1][0] * (1 - p[i - 1]);
    for (int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1]);
        }
    }
    
    double ans;
    for(int j = N / 2 + 1; j <= N; j++) {

        ans += dp[N][j];
    }
    cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<long long> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int a,b,c,x,y;
	int ans=0;
	int bc=0;
	cin >>a>>b>>c>>x>>y;
	if((a+b)> c*2){
		bc=min(x,y);
		ans=+bc*2*c;
		//cout<<ans<<endl;
		x-=bc;
		y-=bc;
		if(x==0){
			if(b >c*2){
				ans+=y*2*c;
				//cout << ans << endl;
				y=0;
			}
		}else{
			if(a>c*2){
				ans+=x*2*c;
			//	cout << ans << endl;
				x=0;
			}
		}
	}
	ans+=x*a;
	//cout << ans << endl;
	ans+=y*b;
	//cout << ans << endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

/* エラトステネスのふるい

   O(n log log n) だいたい線形。 10万とかは余裕
*/
template<typename T>
std::vector<T> sieve(T n)
{
    std::vector<T> primes;
    std::vector<bool> is_prime(n, true);
    is_prime[0] = is_prime[1] = false;

    for (T i = 2; i <= n; ++i) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (T j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return primes;
}



int main()
{
    int X;
    std::cin >> X;

    std::vector<bool> a(X+1);

    if (X == 1) {
        std::cout << 1 <<  std::endl;
        return 0;
    }

    for (int64_t i = 2; i <= sqrt(X); ++i) {
        auto m = i*i;
        for (;;) {
            if (m <= X) {
                a[m] = true;
                m *= i;
            }
            else {
                break;
            }
        }
    }

    for (size_t i = X; i > 1; --i) {
        if (a[i]) {
            std::cout << i <<  std::endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var n = (int)Math.Sqrt(N);
            Console.WriteLine(n * n);
        }
    }
}


Measured memory_bytes: 27400
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int count = 0;
    int x;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x;
        if (k <= x)
            count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll a,b; cin >> a >> b;
  if( a < 10 && b < 10) cout << a*b << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

const ll mod = 1e9+7;

//フィボナッチ f(n) = f(n-1) + f(n-2)
void solve() {
    int n, m; cin >> n >> m;
    vector<bool> A(n+1, true);
    rep(i, 0, m){
        ll a; cin >> a;
        A[a] = false;
    }
    
    ll dp[110000] = {0};
    dp[0] = 1;
    rep(now, 0, n){
        for(int next = now+1; next <= min(n, now+2); next++){
            if(A[next]){
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
        // cout << dp[now] << endl;
    }
    
    cout << dp[n] << endl;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 1152
// abc050_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int A, B;
    char op;
    cin >> A >> op >> B;

    if (op == '+') {
        print(A+B);
    } else {
        print(A-B);
    }

    return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d  long double
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

 
signed main()
{
    haha
    int n;
    cin>>n;
    cout<<(n+1)/2;
  
 
    
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int i, j;
	int n, x;
	int ans=0x7fffffff;
	
	scanf("%d %d", &n, &x);
	i=0;
	j=n;
	while(i<=n){
		ans=min(ans, (1<<i)+j*x);
		i++;
		j--;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [0] * n
for i in range(n):
  a[i] = int(input())
c = 0
for i in range(n-1):
  c += a[i] // 2
  if a[i] % 2 == 1:
    if a[i+1] != 0:
      c += 1
      a[i+1] -= 1
c += a[-1] // 2
print(c)

Measured memory_bytes: 6900
h,*s=open(0)
h,w=map(int,h.split())
r=range
a,b,c,d=[[[0]*w for _ in r(h)]for i in r(4)]
for i in r(h*w):
    i,j=i//w,i%w
    a[i][j]=-~a[i][j-1]*(s[i][j]=='.')
    b[i][~j]=-~b[i][-j]*(s[i][-j-2]=='.')
    c[i][j]=-~c[i-1][j]*(s[i][j]=='.')
    d[~i][j]=-~d[-i][j]*(s[~i][j]=='.')
print(max(a[i][j]+b[i][j]+c[i][j]+d[i][j]-3for i in r(h)for j in r(w)))

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
vector<int> p(10000);
bool isPrime(int a){
  if(a<2){
    return false;
  }
  if(a==2){
    return true;
  }
  for(int i=3;i<a;i+=2){
    if(a%i==0){
      return false;
    }
  }
  return true;
}
int main() {
  int x;cin>>x;
  int ans;
  if(x==2){
    cout << x << endl;
    return 0;
  }
  p[0]=2;
  int j=1;
  for(int i=3;i<x;i+=2){
    if(isPrime(i)){
      p[j]=i;
    }
  }
  ans=(x%2==0)?x+1:x;
  while(true){
    if(isPrime(ans)){
      break;
    }
    ans+=2;
  }
  cout << ans << endl;
}

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

using int64 = long long;

int main() {
  const int64 kThreashold = 1000000000000000000;
  int64 a, b, c, k;
  cin >> a >> b >> c >> k;
  int64 diff = a - b;
  if (k % 2)
    diff = -diff;
  if (diff > kThreashold || diff < -kThreashold) {
    cout << "Unfair\n";
  } else {
    cout << diff << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
//wrong answer on test inf
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define ld long double
#define inf 1000000000
using namespace std;
#define N 1005
#define mod 1000000007
int n,a,b,c,d,f[N][N],C[N][N],w[N][N];
void upd(int &x,int y){ x+=y;x-=x>=mod?mod:0; }
int main(){
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	rep (i,0,n) C[i][0]=1;
	rep (i,1,n) rep (j,1,i) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	rep (i,a,b){
		w[i][0]=1;
		for (int j=1;j<=d&&i*j<=n;j++) w[i][j]=(ll)w[i][j-1]*C[i*j-1][i-1]%mod;
	}
	int nk=0,k=1;f[0][0]=1;
	rep (t,a,b){//以每一种人数作为状态
		nk^=1,k^=1;memset(f[nk],0,sizeof(f[nk]));
		rep (i,0,n){
			upd(f[nk][i],f[k][i]);
			for (int j=c;j<=d&&i+j*t<=n;j++) upd(f[nk][i+j*t],(ll)f[k][i]*w[t][j]%mod*C[i+j*t][i]%mod);
		}
	}
	cout<<f[nk][n]<<endl;
	return 0;
}

Measured memory_bytes: 8448
A, B = map(int, input().split())
a = int(A // 0.08)
ans_lst = []
for i in range(20):
    # print(a, int(a * 0.08) == A)
    if int(a * 0.08) == A:
        ans_lst.append(a)
    a += 1
for i in ans_lst:
    if int(i * 0.1) == B:
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 3060
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
mod = 10**9+7
count = [0]*1000
for i in range(1,n+1):
    arr = factorization(i)
    for so in arr:
        count[so[0]]+=so[1]

ans = 1
count = count[2:]

for i in count:
    ans = ans * (i+1)
    ans %= mod
print(ans)




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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int timer = (h2-h1)*60+(m2-m1);
    COUT(timer-k);
    return 0;
}


Measured memory_bytes: 3636
//file_name:ABC58_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n,m,l;
    scanf("%d%d%d",&n,&m,&l);


    if(n-m==m-l)yn;
    return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			int L = scanner.nextInt();
			// input
			List<String> strings = new ArrayList<String>();
			for (int i = 0; i < N; i++) {
				strings.add(scanner.next());
			}
			// sort・concat
			System.out.println(concatStringOrderbyAsc(strings));
		}
	}

	private static String concatStringOrderbyAsc(List<String> strings) {
		StringBuilder sb = new StringBuilder();
		Collections.sort(strings);

		for (String s : strings) {
			sb.append(s);
		}

		return sb.toString();
	}
}

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

using namespace std;

#define MAX_TASK_SIZE 100000

struct Task {
    string name;
    int time;
};

Task* Q[MAX_TASK_SIZE+1];
int head, tail, n;

int elaps = 0;

void enqueue(Task* x) {
    Q[tail] = x;
    tail = (tail + 1) % MAX_TASK_SIZE;
}

Task* dequeue() {
    Task* task = Q[head];
    head = (head + 1) % MAX_TASK_SIZE;
    return task;
}

bool isEmpty() {
    return head == tail;
}

void update (int dt) {

    Task* t = dequeue();
    if (t->time > dt) {
        t->time -= dt;
        elaps += dt;
        enqueue(t);
    }
    else {
        elaps += t->time;
        printf("%s %d\n", t->name.c_str(), elaps);
    }
}

void execute (int dt) {
    while (!isEmpty()) {
        update(dt);
    }
}

int main(){
    int q;
    scanf("%d %d", &n, &q);

    head = 1;
    tail = 1;
    for ( int i = 1; i <= n; i++) {
        char c[100];
        int t;
        scanf("%s", c);
        scanf("%d", &t);

        Task* task = new Task;
        task->name = c;
        task->time = t;

        enqueue(task);
    }

    execute(q);

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  rep(i, n) cin >> arr[i];

  sort(arr.rbegin(), arr.rend());
  int res = 0;
  rep(i, n) {
    if (i % 2 == 0) {
      res += arr[i];
    } else {
      res -= arr[i];
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(void){
    int N, result = 1;
    char prev, now;

    scanf("%d\n", &N);
    scanf("%c", &prev);

    for(int i = 0; i < N - 1; i++){
        scanf("%c", &now);
        if(now != prev){
            result++;
            prev = now;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Control.Applicative
import Data.Char
import Control.Monad.ST

solve :: VU.Vector Int -> Int
solve hs =
  runST $ do
    table <- VUM.new (l+1)
    VUM.write table 0 0
    forM_ [1..l-1] $ \i -> 
      if i==1 then
        VUM.write table i (h i 1)
      else do
        a1 <- VUM.read table (i-1)
        a2 <- VUM.read table (i-2)
        VUM.write table i $ min (a1 + h i 1) (a2 + h i 2)
    VUM.read table (l-1) 
  where
    l = VU.length hs
    h x n = abs $ (hs VU.! x) - (hs VU.! (x-n)) 

main = do
  n <- readLn :: IO Int
  (hs :: VU.Vector Int) <- VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ solve hs

Measured memory_bytes: 3580
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <queue>

using namespace std;

int main() {
    int n;
    int a[1000000];

    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        int t;
        scanf("%d", &t);
        a[i] = t;
    }

    sort(a, a + n);

    int c = a[0], d = min(c, a[n - 1] - c);
    for(int i = 1; i < n - 1; i++) {
        int t = min(a[i], a[n - 1] - a[i]);
        if(d < t) {
            d = t;
            c = a[i];
        }
    }

    cout << a[n - 1] << " " << c << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const int MX = 1000005;
const int MM = 1000000007;

char A[MX], B[MX];
ll X[MX], Y[MX];
int N;

int main()
{
	scanf("%d", &N);
	X[0] = Y[0] = 1; X[1] = N; Y[1] = N + 1; 
	for(int i = 2; i <= N; i++){
		ll t = (i >= 3 ? Y[i-3] : 0) + (N-i+1);
		X[i] = (X[i-1] + t + (ll)(N-1) * (N-1)) % MM;
		Y[i] = (Y[i-1] + X[i]) % MM;
	}
	printf("%lld\n", X[N]);
}


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

// input
int N;
vector<int> X, Y;

const ll INF = 1e15;

vector<P> xlist, ylist;
vp link;
vector<ll> w;
vector<bool> vis;
priority_queue<P, vector<P>, greater<P>> pq;


void input() {
    cin >> N;
    X = Y = vector<int>(N);
    rep(i, N) cin >> X[i] >> Y[i];
}


ll solve() {
    w = vector<ll>(N, INF);
    vis = vector<bool>(N, false);
    w[0] = 0;
    pq.push(P(0, 0));
    int n = 0;
    while (!pq.empty()) {
        ll cost = pq.top().first;
        int s = pq.top().second;
        pq.pop();
        if (vis[s]) continue;
        vis[s] = true;
        n++;
        if (n == N) break;
        for (P p : link[s]) {
            ll c = p.second;
            int t = p.first;
            if (!vis[t] && c < w[t]) {
                w[t] = c;
                pq.push(P(c, t));
            }
        }
    }
    ll ret = 0;
    rep(i, N) ret += w[i];
    return ret;
}


int main() {
    input();
    rep(i, N) {
        xlist.push_back(P(X[i], i));
        ylist.push_back(P(Y[i], i));
    }
    sort(xlist.begin(), xlist.end());
    sort(ylist.begin(), ylist.end());
    link = vp(N);
    rep(i, N - 1) {
        int s, t, v;
        s = xlist[i].second;
        t = xlist[i + 1].second;
        v = xlist[i + 1].first - xlist[i].first;
        link[s].push_back(P(t, v));
        link[t].push_back(P(s, v));
        s = ylist[i].second;
        t = ylist[i + 1].second;
        v = ylist[i + 1].first - ylist[i].first;
        link[s].push_back(P(t, v));
        link[t].push_back(P(s, v));
    }
    ll ans = solve();
    cout << ans << endl;
}


Measured memory_bytes: 21976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> h(n);
    rep(i,n) cin >> h[i]; //高さ
    
    vector<int> good(n,1);

    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        if(h[a-1] < h[b-1]){
            good[a-1] = 0;
        }
        else if(h[a-1] > h[b-1]){
            good[b-1] = 0;
        }
        else{
            good[a-1] =0;
            good[b-1] =0;
        }
    }

    int res=0;
    for(int i=0; i<n; i++){
        if(good[i]==1) res ++;
    }
    cout << res << endl;
    
}

Measured memory_bytes: 4512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    string s;
    cin>>s;
    vector<int>v;
    for(int i=0; i<s.size(); i++){
        v.push_back(s[i]-'0');
    }
     int x=0;
    for( int i=0; i<v.size(); i++)
    x=x+v[i];
    if(x%9==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 4440
#include<iostream>
#include<string>
#include<math.h>

using namespace std;
int main() {

	int X,A,B,C;
	char str[3][3];
	
	
	/*
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> str[i][j];
			
		}
	}

	cout << str[0][0] << str[1][1] << str[2][2] << endl;
	*/
	

	cin >> A >> B;
	if ((A+B)%2!=0)
	{
		cout << (A + B + 1) / 2 << endl;
	}

	if ((A + B) % 2 == 0)
	{
		cout << (A + B) / 2 << endl;
	}
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int k,x; cin>>k>>x;
    for(int i=x-k+1; i<=x+k-1; i++){
        if(i==x+k-1){
            cout<<i<<endl;
            continue;
        }
        cout<<i<<" ";
    }
}

Measured memory_bytes: 256
def solution():
    s = input()
    acgt = ['A','C','G','T']
    st = None
    ed = None
    cnt = 0
    ans = 0
    for i in range(len(s)):
        cnt = 0
        for ss in s[i:]:
            if ss in acgt:
                cnt += 1
            else:
                break
        ans = max(cnt, ans)
    print(ans)

solution()

Measured memory_bytes: 3060
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n,m;

int main(){
  cin>>n>>m;
  if(n==m)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
from collections import Counter
N=int(input())
E=[set() for _ in range(N)]
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    E[a].add((b,i))
    E[b].add((a,i))
M=int(input())
P=[tuple(map(lambda x:int(x)-1,input().split())) for _ in range(M)]

pc=[set() for _ in range(M)] #各制約で使用する辺の集合

def bfs(S,G,p):
    q=deque([S])
    parent=[(-1,-1)]*N
    while q:
        n=q.popleft()
        for to,i in E[n]:
            if parent[to][0]!=-1:
                continue
            parent[to]=(n,i)
            if to==G:
                break
            q.append(to)
    n=G
    while n!=S:
        n,i=parent[n]
        pc[p].add(i)

for i,p in enumerate(P):
    bfs(p[0],p[1],i)

ans=0
for i in range(1<<M):
    whiteset=set()
    sign=1
    for j in range(M):
        if i>>j&1:
            whiteset|=pc[j]
            sign*=-1
    ans+=sign*(1<<(N-1-len(whiteset)))

print(ans)


Measured memory_bytes: 43996
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	x, n := sc.Int(), sc.Int()
	p := make(map[int]interface{})

	for i := 0; i < n; i++ {
		p[sc.Int()] = struct{}{}
	}

	for i := 0; ; i++ {
		if _, ok := p[x-i]; !ok {
			fmt.Println(x - i)
			return
		}

		if _, ok := p[x+i]; !ok {
			fmt.Println(x + i)
			return
		}
	}
}

type Scanner struct{ *bufio.Scanner }

func NewScanner(r io.Reader) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &Scanner{Scanner: s}
}

func (s *Scanner) next() []byte { s.Scan(); return s.Scanner.Bytes() }

func (s *Scanner) Int() int { return ParseInt(s.next()) }

func ParseInt(b []byte) (n int) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		n *= 10
		n += int(b[i] - '0')
	}
	if b[0] == '-' {
		return -n
	}
	return
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b){ if (a > b) { a = b; } }

int main() {
    int n, k, p[1000];
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> p[i];
    sort(p, p + n);
    cout << accumulate(p, p + k, 0) << endl;

    return 0;
}

Measured memory_bytes: 3612
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let b: char = iterator.next().unwrap().chars().next().unwrap();

    if b == 'A' {
        return "T".to_string();
    }

    if b == 'T' {
        return "A".to_string();
    }

    if b == 'C' {
        return "G".to_string();
    }

    return "C".to_string();
}


Measured memory_bytes: 2096
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>


 
using namespace std;

bool pointsort(pair<int , pair<string, int>> a, pair<int , pair<string, int>> b){
    if(a.second.first == b.second.first){
        return b.second.second < a.second.second;
    }else{
        return b.second.first > a.second.first;
    }
}
 
int main(){
    int N;

    cin >> N;
    vector<pair<int , pair<string, int>>> shop(N); 

    for(int i=0; i<N; i++){
        cin >> shop.at(i).second.first >> shop.at(i).second.second;
        shop.at(i).first = i+1;
    }

    sort(shop.begin(),shop.end(),pointsort);

    for(int i=0; i<N; i++){
        cout << shop.at(i).first << endl;
    }





    return 0;
}

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

int main()
{
  string S;
  string T;
  int ans = 0;
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] != T[i])
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3920