akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<long long int> A(N);
    vector<int> sum(N);
    vector<int> ka(N);
    for(int i = 0;i < N;i++){
        cin >> A.at(i);
        while(A.at(i) % 2 == 0){
            A.at(i) /= 2;
            sum.at(i)++;
        }
    }
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            if(sum.at(i) <= sum.at(j)){
                ka.at(i) ++;
            }
        }
    }
    for(int i = 0;i < N;i++){
        if(ka.at(i) == N){
            cout << sum.at(i) << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
let group x =
	if List.exists ((=) x) [1; 3; 5; 7; 8; 10; 12] then
		`A
	else if List.exists ((=) x) [4; 6; 9; 11] then
		`B
	else
		`C

let () =
	let x, y = Scanf.scanf "%d %d" (fun x y -> (x, y)) in
	if group x = group y then
		Printf.printf "Yes\n"
	else
		Printf.printf "No\n"


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	int n, i;
	while( scanf(" %d", &n) * n != 0){
		int c = 1000-n;
		int ans=0;
		int a[6]={500,100,50,10,5,1};
		
		for(i=0; i<6; i++){
			while(c>=a[i]){
				c-=a[i];
				++ans;
			}
		}
	
		printf("%d\n", ans);
	}

	return 0;
}

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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll a,b,c,d;cin>>a>>b>>c>>d;
  ll ans;
  --a;
  ans = (b / c) + (b / d) - (b / lcm(c,d));
  ans -= (a / c) + (a / d) - (a / lcm(c,d));

  ans = (b - a) - ans;
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}


int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, k, a[200000];
int ans;

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n - k; i++)ans += a[i];
	cout << ans << endl;
}


Measured memory_bytes: 1792
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
Point2D p2d=new Point2D.Double(d1,d2);
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int n=sc.nextInt();
        int k=sc.nextInt();
        out.println(k==1?0:n-k);
        out.close();
    }

    //Union Find木(0-indexed)
    static class UF {
        static int[] d;

        static void Init(int size) {
            d = new int[size];
            for (int i = 0; i < size; i++) {
                d[i] = -1;
            }
        }

        static boolean unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) return false;
            if (d[x] > d[y]) {
                int t = d[y];
                d[y] = d[x];
                d[x] = t;
            }
            d[x] += d[y];
            d[y] = x;
            return true;
        }

        static boolean same(int x, int y) {
            return find(x) == find(y);
        }

        static int find(int k) {
            return d[k] < 0 ? k : (d[k] = find(d[k]));
        }

        static int size(int k) {
            return -d[find(k)];
        }
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static String nextLine() {
            return s.nextLine();
        }

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

        static long nextLong() {
            return Long.parseLong(s.next());
        }

        static double nextDouble() {
            return Double.parseDouble(s.next());
        }

        static boolean hasNext() {
            return s.hasNext();
        }

        static boolean hasNextInt() {
            return s.hasNextInt();
        }

    }

}

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

using namespace std;

int main() {
    int X, Y;
    int ans_reward = 0;
    int reward[] = {300000, 200000, 100000};
    cin >> X >> Y;
    if (X <= 3) {
        ans_reward += reward[X - 1];
    }
    if (Y <= 3) {
        ans_reward += reward[Y - 1];
    }
    if (X == 1 && Y == 1) {
        ans_reward += 400000;
    }
    cout << ans_reward << "\n";

    return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=5005;const ll inf=1e18;
int a[N],q[N],n,x,k;ll res;
void solve(){
	int h=1,t=0;ll sum=0;
	fp(i,1,n){
		while(h<=t&&a[i]<=a[q[t]])--t;
		q[++t]=i;
	}
	fp(i,n+1,n<<1){
		while(h<=t&&i-q[h]>k)++h;
		while(h<=t&&a[i]<=a[q[t]])--t;
		q[++t]=i,sum+=a[q[h]];
	}
	cmin(res,sum+1ll*k*x);
}
int main(){
	scanf("%d%d",&n,&x);res=inf;
	fp(i,1,n)scanf("%d",&a[i]),a[i+n]=a[i];
	for(k=0;k<n;++k)solve();
	printf("%lld\n",res);
	return 0;
}

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

vector<pair<ll, ll>> prime_factorize(ll N) {
  vector<pair<ll, ll>> res;
  for (ll a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    ll ex = 0;
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    res.push_back({a, ex});
  }

  if (N != 1) res.push_back({N, 1});
  return res;
}

int main() {
  ll n, p;
  cin >> n >> p;

  auto f = prime_factorize(p);

  ll ans = 1;
  for (auto d : f) {
    int num = d.second;
    while (num >= n) {
      ans *= d.first;
      num -= n;
    }
  }
  cout << ans << endl;
}


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

const int N = 100005;

int n, head[N], tot, deg[N];
struct edge { int to, nxt; } e[N << 1];

void link(int x, int y) {
	e[++tot] = (edge) { y, head[x] }, head[x] = tot, ++deg[x];
	e[++tot] = (edge) { x, head[y] }, head[y] = tot, ++deg[y];
}

int f[N], max, root, p;
bool vis[N];

void dfs(int x, int dep = 0) {
	if (dep >= max) max = dep, p = x;
	for (int i = head[x]; i; i = e[i].nxt)
		if (e[i].to != f[x]) f[e[i].to] = x, dfs(e[i].to, dep + 1);
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1, x, y; i < n; ++i)
		std::cin >> x >> y, link(x, y);
	dfs(1), max = 0, root = p; f[p] = 0, dfs(p);
	for (int i = p; i != root; i = f[i]) vis[i] = 1; vis[root] = 1;
	for (int i = f[p]; i != root; i = f[i]) deg[i] -= 2; deg[p] -= 1, deg[root] -= 1;
	for (int i = 1; i <= n; ++i) if (!vis[i] && !vis[f[i]])
		return std::cout << "-1\n", 0;
	std::vector<int> d, ans;
	for (int i = p; i != root; i = f[i]) d.emplace_back(deg[i]); d.emplace_back(0);
	d = std::min(d, std::vector<int>(d.rbegin(), d.rend()));
	int now = 1;
	for (int i = 0; i < d.size(); ++i) {
		for (int j = 0; j < d[i]; ++j) ans.emplace_back(now + j + 1);
		ans.emplace_back(now);
		now += d[i] + 1;
	}
	for (int i = 0; i < n; ++i)
		std::cout << ans[i] << ' ';
	std::cout << '\n';
	return 0;
}

Measured memory_bytes: 9584
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  int n, m;
  cin >> n >> m;
  vector<pair <int, int>> p(n), c(m);
  rep (i, n) {
    cin >> p[i].first >> p[i].second;
  }
  rep (i, m) {
    cin >> c[i].first >> c[i].second;
  }

  rep (i, n) {
    int ans = 0;
    int dis = INF;
    rep (j, m) {
      int tmpDis = abs(p[i].first - c[j].first) + abs(p[i].second - c[j].second);
      // cout << "p:" << i << " c: " << j  << " => " << tmpDis << endl;
      if (tmpDis < dis) {
        dis = tmpDis;
        ans = j + 1;
      }
    }
    P(ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i < n + 1; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int n = 0;
    int m = 0;
    REP1(i, INF)
    {
        if (b > a)
        {
            n = i;
            break;
        }
        b = b * 2;
    }
    //cout << b << endl;
    REP1(j, INF)
    {
        if (c > b)
        {
            m = j;
            break;
        }
        c = c * 2;
    }
    //cout << n << m << endl;
    if (n + m - 2 <= k)
        cout << "Yes" << endl;

    else
        cout << "No" << endl;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>
#include <bitset>
#include <numeric>

using namespace std;
typedef long long ll;
ll MOD = 1000000007;
ll ai[100010], ti[100010];
int main()
{
    int n;
    cin >> n;
    ll t[n], a[n];
    for (int i = 0; i < n; i++)
        cin >> t[i];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    if (t[n - 1] != a[0])
    {
        cout << 0 << endl;
        return 0;
    }

    ti[0] = t[0];
    for (int i = 0; i < n - 1; i++)
    {
        if (t[i] == t[i + 1])
        {
            ti[i + 1] = 0;
        }
        else
        {
            ti[i + 1] = t[i + 1];
        }
    }

    ai[n - 1] = a[n - 1];
    for (int i = n - 1; i > 0; i--)
    {
        if (a[i] == a[i - 1])
        {
            ai[i - 1] = 0;
        }
        else
        {
            ai[i - 1] = a[i - 1];
        }
    }

    ll ans = 1;
    for (int i = 0; i < n; i++)
    {
        if (ti[i] == 0 || ai[i] == 0)//山の高さが確定
        {
            if ((ti[i] == 0 && ai[i] == 0))
            {
                ans = (ans * min(t[i], a[i])) % MOD;
            }
            else
            {
                if (ti[i] == 0)
                    ti[i] = ai[i];
                else
                    ai[i] = ti[i];
            }
        }
        else if (ti[i] != ai[i]) //山の高さが確定していて、等しくない時
        {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i = 1; i < n; i++)
    {
        if (ti[i] == 0 && ai[i] == 0)
        {
            continue;
        }
        if (ti[i] > t[i] || ai[i] > a[i])//確定した山の高さが、記録した最大値より大きい時
        {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << ans % MOD << endl;

}

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

#define SIZE 256

int main(void){
	char str[SIZE];
	char reversestr[SIZE];
	int i;
	int length;
	scanf("%s", str);
	length = strlen(str);
	for (i = 0; i < length; i++) {
		reversestr[(length - 1) - i] = str[i];
	}
	for (i = 0; i < length; i++) {
		printf("%c", reversestr[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

    ll ar[3];
    cin>>ar[0]>>ar[1]>>ar[2];
    sort(ar,ar+3);
    ll ans=10*ar[2]+ar[1];
    ans+=ar[0];
    cout<<ans;

    return (0);
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
int main() {
	llint n, m, x;
	cin >> n >> m >> x;
	hei(llint) c(n);
	whei(llint) a(n, hei(llint)(m));
	rep(i, 0, n) {
		cin >> c[i];
		rep(j, 0, m)cin >> a[i][j];
	}
	llint ans = (int)INF;
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top(); st.pop();
		if (now.size() == n) {
			llint S = 0;
			hei(llint) sum(m);
			bool z = true;
			rep(i, 0, now.size()) {
				if (now[i] == '1') {
					S += c[i];
					rep(j, 0, m)sum[j] += a[i][j];
				}
			}
			rep(i, 0, m)if (sum[i] < x)z = false;
			if (z)ans = min(ans, S);
		}
		else {
			for (int i = 1; i >= 0; i--) {
				string Next = now + to_string(i);
				st.push(Next);
			}
		}
	}
	if (ans == (int)INF)ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3696
import sys
sys.setrecursionlimit(10 ** 9)

first = True
while True:
    W, H = map(int, sys.stdin.readline().strip().split())
    if (W == 0) and (H == 0):
        break

    fp = [True] * (W * H)  # 探索可能示す

    M = []
    for h in range(H):
        m = list(map(int, sys.stdin.readline().strip().split()))
        M.append(m)
        for i, j in enumerate(m):
            if j == 0:
                fp[h * W + i] = False


    def dfs(u):  # u は座標
        x, y = u
        fp[y * W + x] = False  # 探索済みを示す

        for i in [-1, 0, 1]:
            x_next = x + i
            if (x_next < 0) or (x_next > W - 1):
                continue
            for j in [-1, 0, 1]:
                y_next = y + j
                if (y_next < 0) or (y_next > H - 1):
                    continue
                # print(f'y_next: {y_next}, x_next: {x_next}')
                # print(f'{fp[y_next * W + x_next]}')
                # print(f'{M[y][x]}')
                if fp[y_next * W + x_next] and (M[y][x] == 1):
                    dfs((x_next, y_next))


    count = 0
    while True in fp:
        count += 1
        # print(f'count : {count}')
        # print(f'fp: {fp}')

        y = int((fp.index(True) / W))
        x = int((fp.index(True) - y * W))
        # print(f'x: {x}, y: {y}')
        dfs((x, y))

    # if first:
    #     first = False
    # else:
    #     print('\n', end='')
    print(count, end='\n')



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

int main() {
	int n;
	cin >> n;
	vector<ll> v(n);
	rep(i, n) {
		cin >> v.at(i);
	}
	ll ans = 0;
	for (int j = 0; j < 60; j++) {
		ll n0 = 0;
		ll n1 = 0;
		rep(i, n) {
			if (v.at(i) & (1LL << j)) n1++;
			else n0++;
		}
		ans += ((n1 * n0)%mod) *((1LL << j)%mod);
	}
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a[];
        a=new int[3];
        for(int i=0;i<3;i++) a[i]=sc.nextInt();
        Arrays.sort(a);
        for(int i=0;i<3;i++){
            System.out.print(a[i]);
            System.out.print(i==2?"\n":" ");
        }

        sc.close();
    }
}


Measured memory_bytes: 26432
/**
 *    author        : Saurav Paul 
 *    created       : August 07, 2020 11:27 AM
 *    Problem Name  : D - Knapsack 1
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/dp/tasks/dp_d
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    int N , W ;
    cin >> N >> W ;

    vector<long long> dp(W+1) ;

    for(int item = 0 ; item < N ; item++){
        int w , value;
        cin >> w >> value ;
        for(int weights = W ; weights - w >= 0 ; weights --){
            if(weights-w == 0 or dp[weights-w] > 0)
                dp[weights] = max(dp[weights] , dp[weights-w] + value) ;
        }
    }

    long long answer = 0 ;
    for(auto value : dp) answer = max(answer, value) ;

    cout << answer << endl ;

    return 0 ;
}


Measured memory_bytes: 4012
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 5000001
#define INF 1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);
#define pi 3.1415926535897

ll power(ll x, ll n, ll d) {
    if(n==0) return 1;
    if(n==1) return (x%d+d)%d;

    ll val = power(x,n/2,d);
    if(n%2) return ((((val*val)%d)*x)%d+d)%d;
    return (val*val)%d;
}

int main() {
 
    get(n);

    map<ll,ll> ma;
    ll maxi=-1;

    rep(i,n){
        get(a);
        if(i==0 && a!=0) {
            printf("0\n");
            return 0;
        }
        ma[a]++;
        maxi = max(a,maxi);
    }


    if(ma[0]!=1) {
        printf("0\n");
        return 0;
    }

    ll res = 1;
    rep2(i,1,maxi+1) {
        if(ma[i]==0) {
            res=0;
            break;
        }
        res = (res*power(ma[i-1],ma[i],N2))%N2;
    }

    printf("%lld\n",res);
    
    return 0;  
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[2010];
int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	rep(i,0,n)scanf("%lld",a+i);
	ll ans=0;
	rep(i,0,n){
		ll x=0,y=0;
		rep(j,0,i)if(a[j]>a[i])x++,y++;
		rep(j,i,n)if(a[j]>a[i])y++;
		ans=(ans+x*k+(k-1)*k/2%MOD*y)%MOD;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
n, x, m = map(int, input().split())
a = x
dup = [0]*(10**5+10)
mod = [a]
loop = []
cnt = 0
while cnt < n:
    a = a**2 % m
    if dup[a]==1:
        i = mod.index(a)
        before = mod[:i]
        loop = mod[i:]
        break
    mod.append(a)
    dup[a] = 1
    cnt += 1

length = len(loop)
if length == 0:
    print(sum(mod[:n]))
else:
    t = (n-i)//length
    amari = (n-i) % length
    ans = sum(before) + t * sum(loop) + sum(loop[:amari])
    print(ans)


Measured memory_bytes: 12460
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<set>
using namespace std;
int main()
{
    long long n,k,i,t=0,j=0,m,a,b,x=0,y=0;
    char s1[50],s2[50],s3[102];
    cin>>s1>>s2;
    for(i=0;i<sizeof(s1);i++)
       {
           s3[j++]=s1[i];
           if(i==sizeof(s1)-1&&sizeof(s1)!=sizeof(s2))
             s3[j]=s2[i];
           else     
             s3[j++]=s2[i];
       }
    if(sizeof(s1)==sizeof(s2))
      s3[j]='\0';
    cout<<s3;   
    return 0;
}

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

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;

const int N = 1000 + 10;
vector<int> adj[N * N];
int dist[N * N], deg[N * N], match[N * N], occ[N * N], vis[N * N];

int main() {
  #ifdef LOCAL
  freopen("in", "r", stdin);
  #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int fin = (n - 1) * (n - 1);
  queue<int> q;
  rep(i, 0, n) {
    rep(j, 0, n - 1) {
      cin >> match[j];
      --match[j];
    }
    rep(j, 0, n - 2) {
      int u = min(i, match[j]) * (n) + max(i, match[j]);
      int v = (n) * min(i, match[j + 1]) + max(i, match[j + 1]);
      adj[u].pb(v);
      ++deg[v];
      if (j == 0 && ++occ[u] == 2) q.push(u);
      if (j == n - 3) {
        adj[v].pb(fin);
        ++deg[fin];
      }
    }
  }
  
  // rep(i, 0, n * n) {
    // cout << i << ", ";
    // for (auto v : adj[i]) cout << v << ' '; cout << endl;
  // }
  
  // function<bool(int, int)> check = [&](int x, int o) {
    // cout << x << endl;
    // vis[x] = 1;
    // for (int v : adj[x]) {
      // if (v == o) return false;
      // if (!vis[v] && !check(v, o)) return false;
    // }
    // return true;
  // };
  
  // for (int i = 0; i < n * n; ++i) {
    // if (vis[i]) continue;
    // if (!check(i, i)) {
      // cout << -1;
      // return 0;
    // }
  // }
  
  int ok = 0;
  while (!q.empty()) {
    int u = q.front();
    // cout << u << endl;
    q.pop();
    if (u == fin) {
      cout << dist[fin];
      ok = 1;
      return 0;
    }
    for (int v : adj[u]) {
      if (--deg[v] == 0) {
        dist[v] = max(dist[v], dist[u] + 1);
        q.push(v);
      }
    }
  }
  if (!ok) cout << -1;
  return 0;
}


Measured memory_bytes: 55680
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

l, r, d= rm()
r //= d
l = (l-1)//d
print(r-l)



Measured memory_bytes: 27156
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;
long long int gcd(long long int a,long long int b);
long long int gcd(long long int a,long long int b){
        if(a%b==0){
            return b;
        }
        else{
            return gcd(b,a%b);
        }
    }


int main(){
	long long int a,b,c,d,e,f;
	cin>>a>>b>>c>>d;
	e=gcd(d,c);
	f=(c*d)/e;
	cout<<b-b/c-b/d+b/f+(a-1)/c+(a-1)/d-(a-1)/f-a+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;


int main()
{
	long H, W, x, y;
	cin >> H >> W;
	long ans;

	if (H == 1 || W == 1)
	{
		cout << 1;
		return 0;
	}

	if (H % 2 == 0)
	{
		ans = W * long(H / 2);
		cout << ans;
		return 0;
	}

	if (H % 2 == 1)
	{
		if (W % 2 == 0)
		{
			ans = W * long(H / 2) + long(W / 2);
			cout << ans;
			return 0;
		}
		if (W % 2 == 1)
		{
			ans = W * long(H / 2) + long(W / 2) + 1;
			cout << ans;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s;

int main(){
	cin>>s;
	int A=atoi(s.substr(0,2).c_str());
	int B=atoi(s.substr(2,2).c_str());
	bool a=0,b=0;
	if(0<A&&A<13) a=1;
	if(0<B&&B<13) b=1;
	if(a&&b) cout<<"AMBIGUOUS"<<endl;
	else if(a) cout<<"MMYY"<<endl;
	else if(b) cout<<"YYMM"<<endl;
	else cout<<"NA"<<endl;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N){
		cin >> A[i];
	}
	
	bool ok = true;
	
	rep(i,N){
		if(A[i] % 2 == 0){
			if(A[i] % 3 != 0 && A[i] % 5 != 0){
				ok = false;
			}
		}
	}
	
	if(ok){
		cout <<"APPROVED" << endl;
	}else{
		cout << "DENIED" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>
#include <climits>
#include <numeric>

//usings
using namespace std;

//type def
typedef long long int64;
typedef pair<int, int> ii;

//consts
const int mod = 1e9 + 7;

//methods
template<typename T>
bool chmax(T& source, const T& compare_to) {
    if(source < compare_to) {
        source = compare_to;
        return true;
    }
    return false;
}

int modpow(int64 base, int n) {
    int64 ret = 1;
    while(n) {
        if(n & 1) ret = ret * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return ret;
}


class Solution {
private:
public:
    int solve(string& s) {
        int n = s.size(), ret = 0, p0 = 1;
        int64 sum = 0;
        unordered_map<int, int> cnt;
        cnt[0] = 1;
        for(int i = n - 1; i >= 0; --i) {
            int cur = s[i] - '0';
            (sum += cur * p0 % 2019) %= 2019;
            (p0 *= 10) %= 2019;
            ret += cnt[sum];
            ++cnt[sum];
        }
        return ret;
    }
};

int main() {
    string s;
    cin >> s;
    Solution sol;
    auto ret = sol.solve(s);
    cout << ret << endl;
    
}

Measured memory_bytes: 3768
S = int(input())
lim = 10**9
x1,y1 = 0,0
x2,y2 = 10**9, 1
x3 = (lim-S%lim)%lim
y3 = (S+x3)//lim
print("%d %d %d %d %d %d" % (x1,y1,x2,y2,x3,y3))

Measured memory_bytes: 3060
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
A = inintl()

prev = A[0]

ans = 0

for i in range(1,n):
    ans += max(prev-A[i],0)
    if prev < A[i]:
        prev = A[i]

print(ans)

Measured memory_bytes: 31476
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, k, p[200010];
int a[200010], b[200010];
signed main() {
	cin >> n >> k;
	int cnt = 0;
	rep(i, n) {
		cin >> p[i];
		if (p[i - 1] < p[i])a[i] = cnt;
		else {
			cnt++;
			a[i] = cnt;
		}
	}
	REP(i, n - 1) {
		if (a[i - 1] == a[i])b[i] = b[i - 1] + 1;
		else b[i] = 0;
	}
	int ma = 0;
	set<int> st;
	rep(i, k) {
		st.insert(p[i]);
		ma = max(ma, b[i]);
	}
	int ans = n - k + 1;
	for (int i = k; i < n; i++) {
		if (b[i] >= k - 1 && ma >= k - 1)ans--;
		else if (p[i - k] == *st.begin()) {
			st.erase(p[i - k]);
			st.insert(p[i]);
			if (p[i] == *st.rbegin())ans--;
		}
		st.erase(p[i - k]);
		st.insert(p[i]);
		ma = max(ma, b[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 14336
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int width = x2 - x1;
		int height = y2 - y1;

		int x3 = x2 - height;
		int y3 = y2 + width;
		int x4 = x1 - height;
		int y4 = y1 + width;

		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);

	}
}

Measured memory_bytes: 23124
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

void solve1() {
	int N, A;
	cin >> N >> A;
	cout << N*N - A << endl;
}

void solve2() {
	int N, K;
	cin >> N >> K;
	vector<int> v;
	for (int i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		v.push_back(x);
	}
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += min(v[i], K - v[i]) * 2;
	}
	cout << ans << endl;
}

void solve3() {

}

void solve4() {

}

int main() {
	//solve1();
	solve2();
	//solve3();
	//solve4();

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double lb;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


int main() {
    ll N;
    cin >> N;
    vector<string> W(N);
    rep(i,N){
        cin >> W[i];
    }

    map<string,ll> countSiritori;
    bool ans = true;
    rep(i,N){
        if(countSiritori[W[i]] == 1){
            ans = false;
            break;
        }else{
            countSiritori[W[i]] = 1;
        }

        if(i != 0){
            if(W[i].at(0) != W[i-1].at(W[i-1].size()-1)){
                ans = false;
                break;
            }
        }
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll n,e,t;cin>>n>>e>>t;
  vector<ll> X;
  X.push_back(0);
  rep(i,n){
    ll x;cin>>x;
    X.push_back(x);
  }
  X.push_back(e);
  vector<ll> dp;
  rep(i,n+2){
    dp.push_back(LINF);
  }
  dp[0] = 0;
  dp[1] = 0;

  int memo = 0;
  vector<ll> mins;
  mins.push_back(0);

  reps(i,n+1){
    if(i != 1){

      int j;
      j = lower_bound(all(X), X[i-1] - t/2.0) - X.begin();
      chmin(dp[i], dp[j] + t);

      if(j-1 >= 0){
        j = mins[j-1];
        chmin(dp[i], dp[j] + (X[i-1] - X[j]) * 2);      
      }
    }

    if((e-X[memo])*2+dp[memo] > (e-X[i])*2 + dp[i]){
      memo = i;
    }
    mins.push_back(memo);
  }

  rep(i,n+2){
    //cout<<dp[i]<<" "<<mins[i]<<endl;
  }

  cout<<dp[n+1] + e<<endl;
  return 0;
}


Measured memory_bytes: 3316
import java.io.*;

class Main
{
    public static void main (String[ ] args) throws Exception
    {
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        //StringBuffer sb = new StringBuffer();
        
        String[] strAry = (br.readLine()).split(" ");
        int a = Integer.parseInt(strAry[0]);
        int b = Integer.parseInt(strAry[1]);
        
        int d = a / b;
        int r = a % b;
        double f = (double)a / b;

        System.out.printf("%d %d %.5f\n", d, r, f);
    }
}

Measured memory_bytes: 24564
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#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 fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n;
    cin>>n;
    vi d(n);
    rep(i,n)cin>>d[i];
    Sort(d);
    if(d[n/2]==d[n/2-1]){
        cout<<0<<endl;
        return 0;
    }
    cout<<d[n/2]-d[n/2-1]<<endl;
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 640
#include <cctype>
#include <string>
#include <iostream>

using namespace std;

int main()
{
	string S; int C = 0;

	while (getline(cin, S))
	{
		for (int i = 0; i < 26; i++)
		{
			if (!(S.find("this") == string::npos && S.find("that") == string::npos && S.find("the") == string::npos))
			{
				cout << S << endl;

				goto Exit;
			}

			for (string::size_type j = 0; j < S.size(); j++)
			{
				if (isalpha(static_cast<int>(S[j])))
				{
					if (S[j] == 'z')
					{
						S[j] = 'a';
					}
					else
					{
						S[j]++;
					}
				}
			}
		}

	Exit:;

	}

	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  int n;
  cin >> n;
  const LL prime=1000000007ll;
  vector<LL> a(n),b(n),m(n,1ll),M(n,1000000000ll);
  REP(i,n) cin >> a[i];
  REP(i,n) cin >> b[i];
  LL answer=1ll;
  LL tmp=0ll;
  REP(i,n){
    if(a[i]>tmp) m[i]=max(m[i],a[i]);
    if(a[i]<tmp) answer=0ll;
    M[i]=min(M[i],a[i]);
    tmp=a[i];
  }
  tmp=0ll;
  for(int i=n-1;i>=0;--i){
    if(b[i]>tmp) m[i]=max(m[i],b[i]);
    if(b[i]<tmp) answer=0ll;
    M[i]=min(M[i],b[i]);
    tmp=b[i];
  }
  REP(i,n){
    if(m[i]>M[i]) answer=0;
    answer*=M[i]-m[i]+1;
    answer%=prime;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            String T = sc.next();

            int count = 0;
            for (int i = 0; i < S.length(); i++) {
                if (S.charAt(i) != T.charAt(i)) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 32060
def sort_str(s):
  temp = sorted(list(s))
  return ''.join(list(temp))

n = int(input())
s = [input() for _ in range(n)]

s_dict = {}
count = 0

for s_i in s:
  k = sort_str(s_i)
  if k in s_dict:
    count += s_dict[k]
    s_dict[k] += 1
  else:
    s_dict[k] = 1
    
print(count)

Measured memory_bytes: 24980
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

N,K = Ints()
Have = [0]*N

for i in range(K):
    d = Int()
    A = IntList()
    for j in A:
        Have[j-1]+=1
ans = 0

for i in Have:
    if i==0:
        ans += 1
print(ans)

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

using namespace std;
#define int long long
typedef long long ll;

std::vector<std::string> split(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

signed main() {
    int a, b, x;
    cin >> a >> b >> x;
    if (a <= x && a + b >= x) cout << "YES" << endl;
    else cout << "NO" << endl;
}



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

using namespace std;

template< typename T, typename E = T >
struct SkewHeap
{
  using G = function< T(T, E) >;
  using H = function< E(E, E) >;

  struct Node
  {
    T key;
    E lazy;
    Node *l, *r;
  } *root = nullptr;

  const bool rev;
  const G g;
  const H h;

  SkewHeap(bool rev = false) : g([](const T &a, const E &b) { return a + b; }),
                               h([](const E &a, const E &b) { return a + b; }), rev(rev) {}

  SkewHeap(const G &g, const H &h, bool rev = false) : g(g), h(h), rev(rev) {}

  Node *propagate(Node *t)
  {
    if(t->lazy != 0) {
      if(t->l) t->l->lazy = h(t->l->lazy, t->lazy);
      if(t->r) t->r->lazy = h(t->r->lazy, t->lazy);
      t->key = g(t->key, t->lazy);
      t->lazy = 0;
    }
    return t;
  }

  Node *merge(Node *x, Node *y)
  {
    if(!x || !y) return x ? x : y;
    propagate(x), propagate(y);
    if((x->key > y->key) ^ rev) swap(x, y);
    x->r = merge(y, x->r);
    swap(x->l, x->r);
    return x;
  }

  Node *push(const T &key)
  {
    auto t = new Node({key, 0, nullptr, nullptr});
    root = merge(root, t);
  }

  T top()
  {
    return propagate(root)->key;
  }

  void pop()
  {
    propagate(root);
    auto *temp = root;
    root = merge(root->l, root->r);
    delete temp;
  }

  bool empty() const
  {
    return !root;
  }

  void add(const T &lazy)
  {
    if(root) {
      root->lazy = h(root->lazy, lazy);
      propagate(root);
    }
  }

  void merge(SkewHeap< T, E > &p)
  {
    root = merge(root, p.root);
  }
};

int main()
{
  char buff[100];
  int key;

  SkewHeap< int > que(true);
  for(;;) {
    scanf("%s", buff);
    if(buff[0] == 'e' && buff[1] == 'n') break;
    if(buff[0] == 'i') {
      scanf("%d", &key);
      que.push(key);
    } else {
      printf("%d\n", que.top()), que.pop();
    }
  }
}


Measured memory_bytes: 34428
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
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; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    string s; cin >> s;
    rep(i,s.size()) {
        if(s[i]+n>'Z') s[i] = 'A'+(s[i]+n-'Z'-1);
        else s[i] = s[i]+n;
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    int sum = 0;
    map<int, int> m;
    for (int i = 0; i < n; i++)
    {
        int foo;
        cin >> foo;
        sum += foo;
        m[foo]++;
    }
    int q;
    cin >> q;
    while (q--)
    {
        //a->b
        int a, b;
        cin >> a >> b;
        sum -= a * m[a];
        sum += b * m[a];
        m[b] += m[a];
        m[a] = 0;
        cout << sum << "\n";
    }
    return 0;
}

Measured memory_bytes: 9576