akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int ll;

int euclidean_gcd(int a, int b) {
    while(1) {
        if(a < b) swap(a, b);
        if(!b) break;
        a %= b;
    }
    return a;
}

int main(void){
    int n,X;
    cin >> n >> X;
    vector<int> x;
    x.push_back(X);
    rep(i,n){
        int a;
        cin >> a;
        x.push_back(a);
    }
    sort(x.begin(),x.end());
  
    vector<int> dist;
  	int b = x[1]-x[0];
  	dist.push_back(b);
    for(int i=1;i<x.size()-1;i++){
        int a = x[i+1]-x[i];
      	if(a){
       	 dist.push_back(a);
        }
    }
  
  	int a = 0;
  	if(dist.size()==1){
       a = dist[0];
    }
  	else{
       a = euclidean_gcd(dist[0], dist[1]);
      for(int i=1;i<dist.size()-2;i++){
          a = euclidean_gcd(a, dist[i+1]);
      }
    }
    cout << a <<endl;
    
    
    
    
    return 0;
}















































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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MAX = 1e5 + 5;

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int x, y;
		cin >> x >> y;
		if(y >= 2 * x && y <= 4 * x && y % 2 == 0) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}


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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(), v.end()
const int MOD = 1e9+7;

int main(){
    FasterIO;

    int a, b;
    while(cin>>a>>b){
        if(a>=6 && a<13)
            b/=2;
        if(a<6)
            b=0;
        
        cout<<b<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	cin >> N;
	if(N==2){
		ll x,y;
		cin >> x >> y;
		cout << abs(x-y) << endl;
		return 0;
	}
	vector<ll> wa(N);
	FOR(i,0,N){
		cin >> wa[i];
		if(i!=0)wa[i]+=wa[i-1];
	}
	ll ans = INF;
	FOR(i,1,N-1){
		ll x = wa[i];
		ll y = wa[N-1] - wa[i];
		ans = min(ans,abs(x-y));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T>;
void in() {}; template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin>>x; in(move(xs)...); };
template <typename T> void _out(const char *sep, const char *end, T &&x) { cout<<x<<end; };
template <typename T, typename...TS> void _out(const char *sep, const char *end, T &&x, TS &&...xs) { cout<<x<<sep; _out(sep, end, move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t _; cin >> _; return _; }()
#define put(...) _out("", "", __VA_ARGS__)
#define out(...) _out(" ", "\n", __VA_ARGS__)
#define times(n, i) for (i32 i =  0 ; i <  (n); ++i)
#define range(a, b, i) for (i32 i = (a); i <  (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 r,g,b;

i32 main()
{
    in(r, g, b);
    r = (r-'0')*100;
    g = (g-'0')*10;
    b = (b-'0')*1;
    i64 n = r+g+b;
    out((n % 4) == 0 ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner  yomi = new Scanner(System.in);
        int n[] = new int[5];
        for (byte i=0; i<5; i++){
            n[i] = yomi.nextInt();
        }
        for (byte i=0; i<5; i++){
            if(n[i] == 0){
                System.out.println(i+1);
                break;
            }
        }
        }

}

Measured memory_bytes: 35760
n,p = map(int, input().split())
if n==1:
    print(p)
    exit()
elif p==1 or n >=60:
    print(1)
    exit()

for i in range(int(p**(1/n))+2)[::-1]:
    if p%(i**n)==0:
        print(i)
        exit()

Measured memory_bytes: 9436
import java.util.*;

class Main {

    static int n;
    static char [][] field;
    static int [][] greatestSize;

    static void solve () {

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (field[i][j] == '*') {
                    greatestSize[i][j] = 0;
                } else if ( i == 0 || j == 0 ) {
                    greatestSize[i][j] = 1;
                } else {
                    greatestSize[i][j] = Math.min(greatestSize[i-1][j-1], Math.min(greatestSize[i-1][j], greatestSize[i][j-1])) + 1;
                }
            }
        }

        int result = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                result = Math.max(result, greatestSize[i][j]);
            }
        }

        System.out.println(result);
    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        while(true) {
            n = sc.nextInt();

            if (n == 0) break;

            field = new char[n][n];
            greatestSize = new int [n][n];
            for (int i = 0; i < n; i++) {
                field[i] = sc.next().toCharArray();
                for(int j = 0; j < n; j++) {
                    greatestSize[i][j] = 0;
                }
            }
            
            solve();
        }

    }
}

Measured memory_bytes: 17000
import sys

if __name__ == "__main__":
    args = sys.stdin.read().split()
    N, A = int(args[0]), list(map(int, args[1:]))  # N = len(A)
    A.sort(reverse=True)

    alice = sum(A[0::2])
    bob = sum(A[1::2])
    print(alice - bob)


Measured memory_bytes: 2940
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    int N;
    cin >> N;
    
    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            if (N == i * j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;    
    return 0;    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
//5桁であることを利用する
int main(){
    int a,b; cin>>a>>b;
    int ans=0;
    int s1,s2,t1,t2;
    for(int i=a;i<=b;i++){
        s1=i%10,
        s2=i/10000%10;
        t1=i/10%10;
        t2=i/1000%10;
        if(s1==s2&&t1==t2) ans++;
    }
    cout <<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
class combination():
    #素数のmod取るときのみ　速い
    def __init__(self, n, mod):
        self.n = n
        self.fac = [1] * (n + 1)
        self.inv = [1] * (n + 1)
        for j in range(1, n + 1):
            self.fac[j] = self.fac[j - 1] * j % mod

        self.inv[n] = pow(self.fac[n], mod - 2, mod)
        for j in range(n - 1, -1, -1):
            self.inv[j] = self.inv[j + 1] * (j + 1) % mod

    def comb(self, n, r, mod):
        if r > n or n < 0 or r < 0:
            return 0
        return self.fac[n] * self.inv[n - r] * self.inv[r] % mod


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, M, K = LI()

cou = int(0)
#maxL = N + M -2
L = int(0)
#距離i+1の組み合わせ

#for i in range(maxL):
for j in range(N):
    L += (N - j - 1) * (M ** 2) * (j + 1)
    L %= mod
for j in range(M):
    L += (M - j - 1) * (N ** 2) * (j + 1)
    L %= mod
#    for j in range(i+2):
#        if i>1 and i+1>j>0:
#            L[i] += max((N-j)*(M-(1+i)+j),0)*(i+1)*2
#        else:
#            L[i] += max(((N - j) * (M - (1 + i) + j)), 0) * (i + 1)
C = combination(N*M-2,mod)
cou = C.comb(N*M-2,K-2,mod)*L%mod

print(cou)

Measured memory_bytes: 42096
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

const int maxn = 1e5 + 5;

int n;
vector<int> G[maxn];
vector<int> G1[maxn];

typedef long long LL;
LL dp[maxn];
LL dp1[maxn];
LL mod;

void dfs(int u, int fa){
    dp[u] = 1;
    for(auto v : G[u]){
        if(v == fa)
            continue;
        dfs(v, u);
        G1[u].push_back(v);
        dp[u] = 1LL * dp[u] * (dp[v] + 1) % mod;
    }
}

LL pre[maxn], suf[maxn];

void dfs1(int u){
    int sz = G1[u].size();
    pre[0] = 1;
    suf[sz + 1] = 1;
    for(int i = 0;i < sz;i++){
        int v = G1[u][i];
        pre[i + 1] = pre[i] * (dp[v] + 1) % mod;
    }
    for(int i = sz - 1;i >= 0;i--){
        int v = G1[u][i];
        suf[i + 1] = suf[i + 2] * (dp[v] + 1) % mod;
    }
    for(int i = 0;i < sz;i++){
        int v = G1[u][i];
        LL tmp = pre[i] * suf[i + 2] % mod * (dp1[u] + 1) % mod;
        dp1[v] = tmp;
    }
    for(int i = 0;i < sz;i++){
        int v = G1[u][i];
        dfs1(v);
    }
}

int main(){
    cin >> n >> mod;
    for(int i = 1;i < n;i++){
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1, 1);
    dfs1(1);
    for(int i = 1;i <= n;i++){
        printf("%lld\n", dp[i] * (dp1[i] + 1) % mod);
    }
    return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	i64 l; cin >> l;
	
	int n = 20, m = 0;
	std::vector<std::vector<std::pair<int, i64>>> vec(n);
	{
		i64 tmp = 1;
		for(int i = 0; i < n - 2; i++) {
			vec[i].push_back({i + 1, 0});
			vec[i].push_back({i + 1, tmp});
			tmp *= 2; m += 2;
		}
	}
	
	i64 tmp = 0; l -= 1;
	while(l - tmp >= 0) {
		i64 k = 1;
		while((1LL << k) - 1 <= l - tmp && k < n - 1) k++; k--;
		if(tmp) vec[k].push_back({n - 1, tmp});
		else vec[k].push_back({n - 1, 0});
		m++;
		if(l - tmp == 0) break;
		tmp += (1LL << k);
	}
	
	assert(m <= 60 && n <= 20);
	cout << n << " " << m << endl;
	for(int i = 0; i < n; i++) {
		for(auto v : vec[i]) cout << i + 1 << " " << v.first + 1 << " " << v.second << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
count = 0

for _ in range(2 ** n):
    pattern = list(map(int, list(bin(_)[2:].zfill(n))))
    if all(sum(pattern[sw2 - 1] for sw2 in ss ) % 2 == pp for ss, pp in zip(s, p)):
        count += 1
print(count)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int C[20], V[20];
  for(int i=0; i<N; i++) cin >> V[i];
  for(int i=0; i<N; i++) cin >> C[i];
  int ans = 0;
  for(int i=0; i<N; i++){
    if(V[i] - C[i] > 0) ans += V[i] - C[i];
  }
  cout << ans << endl;
  return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>

#define rep(p,q) for(int i = p;i < q;i++)

using namespace std;

//A
int main(void) {
	char str;
	cin >> str;
	if (str == 'A') cout << 'T' << endl;
	else if (str == 'T') cout << 'A' << endl;
	else  if (str == 'G') cout << 'C' << endl;
	else if (str == 'C') cout << 'G' << endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;
    vector<ll> A(N),B(N);
    REP(i,N){
        cin >> A.at(i) >> B.at(i);
    }

    ll ans = 0;

    RREP(i,N){
        if ((A.at(i) + ans) % B.at(i) == 0)
        {
        }
        else{
            ll tmp = (A.at(i)+ans) % B.at(i);
            ans += B.at(i) - tmp;
        }
    }

    cout << ans << endl;
}


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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> using iodef_rng_t = typename enable_if<decltype(declval<C>().begin(), true_type{})::value && !is_same<C, string>::value>::type;
template<class C, class = iodef_rng_t<C>> istream& operator>>(istream& in, C& c) { for (auto& v : c) { in >> v; } return in; }
template<class C, class = iodef_rng_t<C>> ostream& operator<<(ostream& out, const C& c) { int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    string s;
    int k;
    cin >> s >> k;
    for (char& c : s) {
        auto to_a = (26 - (c - 'a')) % 26;
        if (to_a <= k) {
            k -= to_a;
            c = 'a';
        }
    }
    s.back() += k % 26;
    cout << s << '\n';
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

int a[26];
 
int32_t main()
{
    fast;
    int f = 0;
    string s; cin >> s;
    For(i, 0, s.size()) ++a[s[i] - 'a'];
    for(auto x : a) if(x > 1) f = 1;
    cout << (f == 1 ? "no" : "yes");


    
    
    
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

void solve(){
  set<int>s;
  rep(i,3){
    int a;
    cin>>a;
    s.emplace(a);
  }
  cout<<s.size();
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>

using namespace std;
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; }

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

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

	ll N, W;

	cin >> N >> W;

	vector<P> wv(N);
	for (ll i = 0; i < N; ++i) cin >> wv[i].first >> wv[i].second;
	
	vector<vector<ll>> dp(N+1, vector<ll>(W+1, 0));

	for (ll i = 0; i < N; ++i)
	{
		for (ll sum_w = 0; sum_w <= W; ++sum_w)
		{
			if (sum_w - wv[i].first >= 0)
			{
				chmax(dp[i + 1][sum_w], dp[i][sum_w - wv[i].first] + wv[i].second);
			}
			chmax(dp[i + 1][sum_w], dp[i][sum_w]);
		}
	}

	cout << dp[N][W] << endl;
	//system("pause");
}


Measured memory_bytes: 80256
input = readlines()

h, w, m = input.shift().chomp().split("\s").map{|x| x.to_i}

h_list = {}
w_list = {}
h_rev = {}
w_rev = {}
pos_list = {}
h_key_max = 0
w_key_max = 0

input.each do |vals|
  ch, cw = vals.chomp.split("\s").map{|x| x.to_i}
  h_list[ch] = 0 if h_list[ch].nil?
  h_list[ch] += 1
  w_list[cw] = 0 if w_list[cw].nil?
  w_list[cw] += 1
  pos_list["#{ch}-#{cw}"] = true

  h_key = h_list[ch]
  w_key = w_list[cw]
  h_rev[h_key] = [] if h_rev[h_key].nil?
  w_rev[w_key] = [] if w_rev[w_key].nil?
  h_rev[h_key].push(ch)
  w_rev[w_key].push(cw)
  h_key_max = h_key if h_key > h_key_max
  w_key_max = w_key if w_key > w_key_max
end

res = [0]
h_rev[h_key_max].each do |tmp_h|
  w_rev[w_key_max].each do |tmp_w|
    cnt = h_list[tmp_h] + w_list[tmp_w]
    if pos_list["#{tmp_h}-#{tmp_w}"] == true
      cnt -= 1
      res.push(cnt)
    else
      puts cnt
      exit()
    end
  end
end

puts res.max


Measured memory_bytes: 126060
#include <cstdio>
#include <cctype>
#include <utility>
#include <string>
#include <vector>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int, in){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}

struct range{
	int _e, _b = 0, _s = 1;
	range(int b, int e, int s): _e(e), _b(b), _s(s) {}
	range(int b, int e): _e(e), _b(b) {}
	range(int e) : _e(e) {}
	struct it {
		int _v, _s;
		it (int v, int s) : _v(v), _s(s) {}
		operator int () const {return _v;}
		operator int& () {return _v;}
		int operator* () const {return _v;}
		it& operator++ () {_v+=_s;return *this;}
	};
	it begin() {return {_b, _s};}
	it end() {return {_e, _s};}
};

using V = vector<int>;

int main() {
	string s1, s2;
	scan(s1, s2);
	range r1(s1.size() + 1), r2(s2.size() + 1);
	vector<V> dp(r2._e, V(r1._e));
	for (int i: r2)
		for (int j: r1)
			dp[i][j] = min(i, j) ?
				min(dp[i][j - 1] + 1,
					min(dp[i - 1][j] + 1,
						dp[i - 1][j - 1] + (s1[j - 1] != s2[i - 1]))) :
				max(i, j);
	outl(dp.back().back());
}


Measured memory_bytes: 6416
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long ans = 0;
  int n, m;
  cin >> n >> m;
  int work = 0;
  
  for(int i=0; i<m; i++){
    int temp;
    cin >> temp;
    work += temp;
  }
  
  if(work<=n){
    cout << n - work << endl;
  }
  else{
    cout << -1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3656
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static AtCoder.Program;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC132().SolveC(new ConsoleInput(Console.In, ' '));
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }

    }
  class ABC132
  {
    public void SolveC(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var D = cin.ReadIntArray(n);
            var sortedD = D.OrderBy(x => x).ToArray();
            WriteLine(sortedD[n/2] - sortedD[n/2-1]);
            ReadLine();
        }
  }
}

Measured memory_bytes: 25696
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int N, M;
int k[20], s[20][20], p[20];
vector<string> S;

void sw (string W) {
	if (W.size() == N) {
		S.push_back(W);
	}
	else {
		for (int i = 0; i <= 1; i++) {
			string tmp = W;
			tmp.push_back(i + '0');
			sw(tmp);
		}
	}
}
int main()
{
	string T;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> p[i];
	}
	sw(T);
	int ans = 0;
	bool on[15] = { false }, ok = true;
	for (int i = 0; i < S.size(); i++) {
		ok = true;
		for (int j = 0; j < N; j++) {
			if (S[i][j] == '0') {
				on[j] = false;
			}
			else {
				on[j] = true;
			}
		}
		for (int j = 0; j < M; j++) {
			int cnt = 0;
			for (int l = 0; l < k[j]; l++) {
				if (on[s[j][l]]) {
					cnt++;
				}
			}
			if (cnt % 2 != p[j]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
def main():

    N = int(input())
    s = input()
    if s[0] == "o":
        cand = [["S", "S", "S"], ["W", "S", "W"], ["W", "W", "S"], ["S", "W", "W"]]
    else:
        cand = [["S", "S", "W"], ["W", "S", "S"], ["W", "W", "W"], ["S", "W", "S"]]

    for cd in cand:
        for i in range(1, N):
            if s[i] == "o" and cd[-1] == "S":
                if cd[-2] == "S": cd.append("S")
                else: cd.append("W")
            elif s[i] == "x" and cd[-1] == "S":
                if cd[-2] == "S": cd.append("W")
                else: cd.append("S")
            elif s[i] == "o" and cd[-1] == "W":
                if cd[-2] == "S": cd.append("W")
                else: cd.append("S")
            elif s[i] == "x" and cd[-1] == "W":
                if cd[-2] == "S": cd.append("S")
                else: cd.append("W")
        # print(cd)
        if cd[:2] == cd[-2:]:
            return "".join(cd[1:-1])
    return -1

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 7176
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define pai 3.1415926535


int main(void) {
	
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	int sum = 0;
	if (B >= C) {
		sum += B + C;
		printf("%d", sum);
		return 0;
	}
	else {
		sum += 2*B;
		C-= B;
	}

	if (A >= C) {
		sum += C;
		
	}
	else {
		sum += A;
		sum++;
	}
	
	printf("%d", sum);




	return 0;


}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <queue>

using namespace std;


int main()
{
	int N;
	cin >> N;

	vector<long long int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}

	int cnt = 0;
	int mx = 0;
	long long int buff = H[N - 1];
	for (int i = N - 2; i >= 0; i--)
	{
		if (buff <= H[i])
		{
			cnt++;
		}
		else
		{
			mx = max(cnt, mx);	
			cnt = 0;
		}

		buff = H[i];
	}

	if (mx == 0 && cnt != 0)
	{
		mx = cnt;
	}

	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
#include<iomanip>
#include<bitset>
#include<math.h>
using namespace std;
 
 
int main(){
 
	int n;
	cin >> n;
	vector<double> v(n);

	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	
	sort(v.begin(),v.end());

	double sum = 0;
	for (int i = 0; i < n-1; i++)
	{
		v[i+1] = (v[i] + v[i+1]) / 2;
	}
	
	cout << v[n-1] << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = (long)Math.pow(10,9) + 7;
        long p = 1;
        for (int i=1; i<=n; i++) {
            p = (p%x) * (i%x);
        }
        System.out.println(p%x);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
set<int> multi;
bool tell(string str){
	if(str.size() == 0)return false;
 int z = std::stoll(str);
 if(z%2019 == 0)return true;
 return false;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin>>str;
int n = (int)str.length();
int dp[2020];
memset(dp , 0 , sizeof(dp));
int ans = 0;
dp[str[0]-'0'] = 1;
for(int i = 1 ;  i < n ; i++){
	int dp2[2019] = {0};
	dp2[str[i]-'0']++;
	  for(int j = 0 ; j < 2019 ;j++){
			 if(dp[j] > 0){
			     dp2[(j*10 + (str[i]-'0'))%2019] += dp[j];
			     //dp2[(j*10 + (str[i]-'0'))%2019]++;
			  }
	  }
	 // cout<<endl;
	 // dp[str[i]-'0']++;
	 ans += dp2[0];
	 for(int i = 0 ; i < 2019 ; i++)dp[i] = dp2[i];
}
//return 0;
cout<<ans<<endl;
}


Measured memory_bytes: 3816
#include <stdio.h>
#include <math.h>

#define INF 1e20

#define min(a, b) (((a) < (b)) ? (a) : (b))

int main(void) {
	int i;
	int n, f[100], a[100], t[100], x[100], y[100];
	double ans_d[2], ans_t[2];

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d %d %d %d %d", f + i, a + i, t + i, x + i, y + i);

	ans_d[0] = ans_d[1] = -INF;
	ans_t[0] = ans_t[1] = INF;
	for (i = 1; i < n; i++)
		if (t[i] == t[i - 1] && a[i] != a[i - 1]) {
			double dist = hypot(x[i] - x[i - 1], y[i] - y[i - 1]);
			if (dist == ans_d[t[i]])
				ans_t[t[i]] = min(ans_t[t[i]], (f[i] - f[i - 1]) / 60.0);
			else if (dist > ans_d[t[i]]) {
				ans_d[t[i]] = dist;
				ans_t[t[i]] = (f[i] - f[i - 1]) / 60.0;
			}
		}

	printf("%.15g %.15g\n", ans_d[0] == -INF ? -1 : ans_d[0], ans_d[0] == -INF ? -1 : ans_t[0]);
	printf("%.15g %.15g\n", ans_d[1] == -INF ? -1 : ans_d[1], ans_d[1] == -INF ? -1 : ans_t[1]);

	return 0;
}

Measured memory_bytes: 656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <iomanip>

using namespace std;

int main() {
	int n; cin >> n;
	vector<double> p(n);
	for (int i = 0; i < n; ++i) cin >> p[i];
	vector<vector<double> > dp(n + 1, vector<double>(n + 1));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1 - p[i]);
		}
	}
	double ans = 0;
	for (int i = 0; i <= n / 2; ++i) ans += dp[n][n - i];
	printf("%.10f\n", ans);

	return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int acnt = 0, bcnt = 0, ccnt = 0;
    
    rep(i, N) {
        if (S[i] == 'a') {
            if ((A + B) > (acnt + bcnt)) {
                cout << "Yes" << endl;
                acnt++;
            }
            else {
                cout << "No" << endl;
            }
        }
        else if (S[i] == 'b') {
            if (((A + B) > (acnt + bcnt)) && (B > bcnt)) {
                cout << "Yes" << endl;
                bcnt++;
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            ccnt++;
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 848
from collections import deque

s = input()
s = list(s)
q = int(input())
query = list(list(input().split()) for _ in range(q))

d = deque(s)

rs = False

for i in range(q):
    qry = query[i]
    if qry[0] == '1':
        rs = not rs
    else:
        if qry[1] == '1':
            if not rs:
                d.appendleft(qry[2])
            else:
                d.append(qry[2])
        else:
            if not rs:
                d.append(qry[2])
            else:
                d.appendleft(qry[2])
                
d = list(d)
if rs:
    d.reverse()
                
d = ''.join(d)
print(d)

Measured memory_bytes: 114680
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 105;
int N, W;
int w[MAX_N], v[MAX_N];

const int MAX_V = 100005;
int dp[MAX_N][MAX_V];

signed main()
{
  cin >> N >> W;
  REP(n,N) {
    cin >> w[n] >> v[n];
  }

  REP(n,MAX_N) {
    REP(vv,MAX_V) {
      dp[n][vv] = INF_LL_MAX;
    }
  }

  dp[0][0] = 0;
  REP(n,N) {
    REP(vv,MAX_V) {
      dp[n+1][vv] = min(dp[n+1][vv], dp[n][vv]);
      if(dp[n][vv] == INF_LL_MAX) {
        continue;
      }
      dp[n+1][vv+v[n]] = min(dp[n+1][vv+v[n]], dp[n][vv]+w[n]);
    }
  }

  int ans = 0;
  REP(ww,MAX_V) {
    if(dp[N][ww]<=W) {
      ans = max(ans, ww);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 82304
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    ll x,n;
    cin>>x>>n;
    vector<ll> a(n);
    for(auto &I:a){cin>>I;}
    for(ll i=n-1;i>0;i--){a[i]=a[i]-a[i-1];}
    vector<pair<pll,pll>> dp(n+1);
    dp[0]={{0,0},{x,x}};
    for(int i=0;i<n;i++){
        if(i&1){
            if(dp[i].S.S+a[i]>x){
                dp[i+1].S={max(dp[i].S.F-abs(dp[i].S.S+a[i]-x),0LL),x};
            }
            else{
                dp[i+1].S={dp[i].S.F,dp[i].S.S+a[i]};
            }
            if(dp[i].F.S+a[i]>x){dp[i+1].F=dp[i+1].S;}
            else{dp[i+1].F={dp[i].F.F,dp[i].F.S+a[i]};}
        }
        else{
            if(dp[i].F.S-a[i]<0){
                dp[i+1].F={min(dp[i].F.F+abs(dp[i].F.S-a[i]),x),0};
            }
            else{
                dp[i+1].F={dp[i].F.F,dp[i].F.S-a[i]};
            }
            if(dp[i].S.S-a[i]<0){dp[i+1].S=dp[i+1].F;}
            else{dp[i+1].S={dp[i].S.F,dp[i].S.S-a[i]};}
        }
    }
    for(int i=1;i<n;i++){a[i]+=a[i-1];}
    for(int i=0;i<=n;i++){
        //cout<<i<<" "<<dp[i].F.F<<" "<<dp[i].F.S<<" "<<dp[i].S.F<<" "<<dp[i].S.S<<endl;
    }
    ll q;
    cin>>q;
    while(q--){
        ll t,A;
        cin>>t>>A;
        ll w=upper_bound(a.begin(),a.end(),t)-a.begin();
        if(w!=0){t-=a[w-1];}
        //cout<<w<<" "<<t<<endl;
        if(w&1){
            if(dp[w].F.F>=A){cout<<min(dp[w].F.S+t,x)<<endl;}
            else if(dp[w].S.F<=A){cout<<min(dp[w].S.S+t,x)<<endl;}
            else{cout<<min(dp[w].F.S+abs(dp[w].F.F-A)+t,x)<<endl;}
        }
        else{
            if(dp[w].F.F>=A){cout<<max(dp[w].F.S-t,0LL)<<endl;}
            else if(dp[w].S.F<=A){cout<<max(dp[w].S.S-t,0LL)<<endl;}
            else{cout<<max(dp[w].S.S-abs(dp[w].S.F-A)-t,0LL)<<endl;}
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>
#include <string.h>

int main (){
	long long int a;
	scanf("%lld", &a);
	int count = 0;
	char out[255] = {0};
	a--;
	while (a >= 0){
		out[count] = (a % 26) + 'a';
		a /= 26;
		count++;
		a--;
	}
	for(int i = strlen(out)-1; i >= 0; i--){
		printf("%c", out[i]);
	}
	puts("");

	return 0;
}


Measured memory_bytes: 1648
import itertools

N,MA,MB = map(int,input().split())
arr = []

for i in range(N):
  l = list(map(int,input().split()))
  arr.append(l)
  
dp = [ [ [50000 for k in range(401)] for j in range(401)] for i in range(N+1) ]
dp[0][0][0] = 0
ans = 50000

for i,a,b in itertools.product(range(1,N+1),range(401),range(401)):
  A = arr[i-1][0]
  B = arr[i-1][1]
  C = arr[i-1][2]
  
  if A <= a and B <= b and dp[i-1][a-A][b-B] != 50000:
    dp[i][a][b] = min(dp[i-1][a][b],dp[i-1][a-A][b-B] + C)
  else:
    dp[i][a][b] = dp[i-1][a][b]

for a,b in itertools.product(range(401),range(401)):
    if a * MB == b * MA and a != 0 and b != 0:
      ans = min(ans,dp[-1][a][b])
    
if ans == 50000:
  print(-1)
else:
  print(int(ans))

Measured memory_bytes: 100956
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    pll a[100010];
    cin>>n;
    rep(i,n){
        ll b;
        cin>>b;
        a[i]=pll(b,i);
    }
    sort(a,a+n);
    rep(i,n){
        cout<<a[i].second+1<<" ";
    }
    cout<<endl;
    return 0;
}

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

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n,-1),b(n-1);
    rep(i,n-1)cin>>b[i];
    a[0]=b[0];
    rep(i,n-1){
        if(i==n-2){
            a[n-1]=b[n-2];
        }else{
            a[i+1]=min(b[i],b[i+1]);
        }
    }
    ll sum=0;
    rep(i,n)sum+=a[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a)		cerr << #a << ": "; for (auto x: a) cerr << x << ' '; cerr << endl;
#define debugm(a) 		cerr << #a << ":\n"; \
						for (auto v: a) { for(auto x: v) cout << x << ' '; cerr << "\n"; }
 
#define int long long
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

int32_t main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a+b+c >= 22) {
		cout << "bust" << endl;
	} else
		cout << "win" << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 998244353ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
int main(){
    ll n,m;
    std::cin >> n>>m;
    std::vector<int> w(n),v(n);
    rep(i,n)std::cin >> w[i]>>v[i];
    ll dd=w[0];
    irep(i,n){
        w[i]-=dd;
        w[i]+=300;
    }
    erep(i,w){
     //   std::cout << i <<' ';
    }
    std::cout << std::endl;
    vvector(dp,ll,n+1,40000,0);
    rep(i,n){
        rep(j,30500){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }
            else{
                dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
            }
        }
    }
    ll ans=0;
    rep(i,n+1){
        rep(j,30500){
            if(j/300*dd+j%300<=m&&(i==0||dp[i][j]!=dp[i][j-1])){
                if(chmax(ans,dp[i][j])){
         //           pppri(i,j,dp[i][j]);
                }
            }
        }
    }
    std::cout << ans<< std::endl;
}

Measured memory_bytes: 32512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  ll n,k; cin >> n >> k;
  vector<ll> a(n);
  ll r=0;
  rep(i,n){
    cin >> a[i];
    chmax(r,a[i]);
  }
  ll l=0;
  while(r-l!=1){
    ll mid=(l+r)/2;
    bool ok=0;
    int cnt=0;
    rep(i,n){
      cnt+=ceil((double)a[i]/mid)-1;
    }
    if(cnt<=k) ok=1;
    if(ok) r=mid;
    else l=mid;
  }
  cout << r << endl;
}

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

int main(){
int N;
int d[110];
cin >> N;
for(int i = 0;i < N; ++i) cin >> d[i];

int num[110] = {0};
for(int i = 0;i< N;++i){
num[d[i]]++;
}

int res = 0;
for(int i = 1;i <=100;++i){

if(num[i]){
++res;
}
}
cout << res << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll n,ans=INF;
	cin >> n;
	vector<ll>arr(n);
	rep(i, n)cin >> arr[i];
	rep(i, n-1) {
		ans = min(ans,gcd(arr[i], arr[i + 1]));
	}
	cout << ans << endl;
	return 0;
}



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

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t s = 0;
    int64_t q = 0;
    for (int64_t n = 0; n < N; ++n)
    {
        int64_t A;
        std::cin >> A;
        if (s > A) {
            q += s - A;
        }
        else {
            s = A;
        }
    }

    std::cout << q << std::endl;

    return 0;
}



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

bool linear_search(int A[], int n, int m) {
    int i = 0;
    A[n] = m;
    while(A[i] != m) {
        i++;
    }
    return i != n;
}

int main() {
    int n;
    cin >> n;
    int S[n];
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }
    int q;
    int count = 0;
    cin >> q;
    int t;
    for (int j = 0; j < q; ++j) {
        cin >> t;
//        for (int i = 0; i < n; ++i) {
//           if(S[i] == t) {
//               count++;
//           }
//        }
        if(linear_search(S, n, t)){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3124