akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
int n, a[100005];
vector<pair<int,int>> vec, vec2;
unordered_map<int,int> mp, mp2;
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef debug
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    cin >> n;
    for(int i = 1; i <= n; i++)cin >> a[i];
    for(int i = 1; i <= n; i+= 2)mp[a[i]]++;
    for(int i = 2; i <= n; i += 2)mp2[a[i]]++;
    for(auto i : mp)vec.pb({i.s, i.f});
    for(auto i : mp2)vec2.pb({i.s, i.f});
    sort(vec.begin(), vec.end()); sort(vec2.begin(), vec2.end());
    int cnt = 1e9;
    int delta = n/2;
    if(vec.size() == 1 && vec2.size() == 1){
        if(vec[0].s == vec2[0].s){
            cnt = delta;
        }
        else{
            cnt = 0;
        }
    }
    else{
        if(vec[vec.size()-1].s != vec2[vec2.size()-1].s){
            cnt = delta - vec[vec.size()-1].f + delta - vec2[vec2.size()-1].f;
        }
        else{
            if(vec.size() > 1)cnt = min(cnt, delta - vec2[vec2.size()-1].f + delta - vec[vec.size()-2].f);
            else cnt = min(cnt, delta + delta - vec2[vec2.size()-1].f);
            if(vec2.size() > 1)cnt = min(cnt, delta - vec2[vec2.size()-2].f + delta - vec[vec.size()-1].f);
            else cnt = min(cnt, delta + delta - vec[vec.size()-1].f);
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 8692
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;

int N;
vector<vector<int> > L;
vector<int> power;
vector<bool> ok;
int ans;
vector<int> total;

void calc(int now,int sum){

	ans=max(ans,sum);
	int t=0;

	for(int i=now;i<N;i++)
		t+=power[i];
	if(t+sum<=ans) return;

	if(now>=N) return;

	if(!ok[now]){calc(now+1,sum);return;}
	bool can_cut=true;

	for(int i=0;i<L[now].size();i++){//枝狩れるかチェック!
		if(ok[L[now][i]]){can_cut=false;break;}
	}

	vector<int> memo;
	for(int i=0;i<L[now].size();i++){
		if(ok[L[now][i]]){memo.push_back(L[now][i]);ok[L[now][i]]=false;}
	}


	calc(now+1,sum+power[now]);

	for(int i=0;i<memo.size();i++)
		ok[memo[i]]=true;

	if(!can_cut) calc(now+1,sum);//枝刈り
}

int main()
{
	while(cin>>N && N!=0){
		ans=0;
		int c=0;
		map<string,int> Idx;
		L.clear();L.resize(N,vector<int>());
		ok.clear();ok.resize(N,true);
		power.clear(); power.resize(N,0);
		for(int i=0;i<N;i++){
			string nation;
			cin>>nation;
			if(!Idx.count(nation))Idx[nation]=c++;
			cin>>power[Idx[nation]];
			int m=0;cin>>m;
			for(int j=0;j<m;j++){
				string s; cin>>s;
				if(!Idx.count(s))Idx[s]=c++;
				L[Idx[nation]].push_back(Idx[s]);
			}
		}

		total.clear();total.resize(N+1,0);
		for(int i=N-1;i>=0;i--){
			total[i]=total[i+1]+power[i];
		}


		ok[0]=false;
		ans+=power[0];
		for(int i=0;i<L[0].size();i++)
			ok[L[0][i]]=false;

		calc(1,ans);
		cout<<ans<<endl;
	}
}

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

int main(void)
{
    int n;
    cin>>n;
    unsigned long long sum=0,t0=2,t1=1;
    if(n==1)
    {
        cout <<1<<endl;
        return 0;
    }
    else
    {
        for(int i=2;i<=n;++i)
        {
            sum=t0+t1;
            t0=t1;
            t1=sum;
        }
        cout <<sum <<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=2e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N],f[N],ans=0;
int main() {
    n=gi();
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=n;i;i--) f[a[i]]=f[a[i]+1]+1,chkmax(ans,f[a[i]]);
    printf("%d\n",n-ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
using ll = long long;

int find(int a, vector<int>& parents, vector<ll>& costs){
    if(parents[a] == a)return a;
    else{
        int root = find(parents[a], parents, costs);
        costs[a] = costs[parents[a]] + costs[a];
        parents[a] = root;
        return root;
    }
}

bool unite(int from, int to, int cost, vector<int>& parents, vector<ll>& costs){
    int from_root = find(from,parents,costs);
    int to_root = find(to, parents, costs);
    // for(int i = 0;i < costs.size();i++){
    //     cout << costs[i] << " ";
    // }
    if(from_root == to_root){
        return costs[to] - costs[from] == cost;
    }
    costs[to_root] = cost - costs[to];
    parents[to_root] = from;
    // cout << "comb " << to_root << " to " << from << endl;
    
    // cout << endl;
    return true;
}

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> parents(N,-1);
    vector<ll> costs(N,0);
    for(int i = 0;i < N;i++)parents[i]=i;
    for(int i = 0;i < M;i++){
        int l,r,d;
        cin>>l>>r>>d;
        l--;
        r--;
        if(!unite(l,r,d,parents,costs)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n, s, w, q;
int a[1 << 17];
void generate() {
	int g = s;
	rep(i, n) {
		a[i] = (g / 7) % 10;
		if (g % 2 == 0)g /= 2;
		else g = (g / 2) ^ w;
	}
}
void ans2() {
	int c = 0;
	ll out = 0;
	rep(i, n) {
		if (a[i])c++;
		if (a[i] % 2 == 0)out += c;
	}
	cout << out << endl;
}
void ans5() {
	int c = 0;
	ll out = 0;
	rep(i, n) {
		if (a[i])c++;
		if (a[i] % 5 == 0)out += c;
	}
	cout << out << endl;
}
void ansp() {

}
int b[1 << 17];
void init() {
	int c = 1;
	per(i, n) {
		b[i] = c * a[i] % q;
		c = c * 10 % q;
	}
	b[n] = 0;
	per(i, n) {
		b[i] += b[i + 1]; b[i] %= q;
	}
	map<int, int> mp;
	mp[0] = 1;
	ll out = 0;
	per(i, n) {
		if (a[i]) {
			out += mp[b[i]];
		}
		mp[b[i]]++;
	}
	cout << out << endl;
}
int main() {
	while (cin >> n >> s >> w >> q, n) {
		generate();
		if (q == 2)ans2();
		else if (q == 5)ans5();
		else {
			init();
		}
	}
	return 0;
}


Measured memory_bytes: 8072
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<VI> a(2, VI(n));
  REP(i, 0, 2) {
    REP(j, 0, n) {
      cin >> a[i][j];
    }
  }
  REP(i, 1, n) {
    a[0][i] += a[0][i - 1];
  }
  for(int i = n - 2; i >= 0; --i) {
    a[1][i] += a[1][i + 1];
  }
  int ma = 0;
  REP(i, 0, n) {
    ma = max(ma, a[0][i] + a[1][i]);
  }
  cout << ma << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;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 all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    int ans=0;
    REP(i,n){
        int t;
        cin>>t;
        if(t%2){
            ans++;
        }
    }
    if(ans%2){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  vector<vector<int>> card(3, vector<int>(3));
  vector<vector<bool>> called(3, vector<bool>(3, false));
  int count;
  string ans = "No";
  REP(i, 3) {
    REP(n, 3) { cin >> card[i][n]; }
  }
  cin >> count;
  vector<int> call(count);
  REP(i, count) { cin >> call[i]; }
  REP(i, count) {
    REP(n, 3) {
      REP(m, 3) {
        if (call[i] == card[n][m]) {
          called[n][m] = true;
        }
      }
    }
  }
  REP(i, 3) {
    if ((called[i][0] && called[i][1] && called[i][2]) ||
        (called[0][i] && called[1][i] && called[2][i])) {
      ans = "Yes";
    }
  }
  if ((called[0][0] && called[1][1] && called[2][2]) ||
      (called[0][2] && called[1][1] && called[2][0])) {
    ans = "Yes";
  }
  cout << ans << endl;
}

signed main() {
  solve();

  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();
    let k: usize = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();

    for i in 0..n {
        if i <= k - 1 {
            continue;
        }
        let prev = a[i - k];
        let now = a[i];
        if prev < now {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int m, d;

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &m, &d);

  ans = 0;

  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= d; ++j) {
      int d1 = j / 10;
      int d2 = j % 10;

      if (i == d1 * d2 && d1 >= 2 && d2 >= 2) {
        ans += 1;
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin>>n;
    while(n>0)
    {
        ll num=n%10;
        if(num==7)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        n=n/10;
    }
    cout<<"No"<<endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;
  int ans = 0;
  if(s[0] == '1'){
    ans += 1;
  }
  if(s[1] == '1'){
    ans += 1;
  }
  if(s[2] == '1'){
    ans += 1;
  }
  
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static Scanner scan;

    public static void main(String[] args) {
        scan = new Scanner(System.in);
        System.out.println(comp(
                scan.nextInt() , scan.nextInt(), scan.nextInt(), scan.nextInt(), scan.nextInt()));
    }

    private static String comp(int w,int h,int x,int y,int r) {
        if (!(-100 <= x || y <=100 || 0 < w || r <= 100)) {
            return "";
        }
        if (circle_in_a_Rectangle(w,x,r) && circle_in_a_Rectangle(h,y,r)) {
            return "Yes";
        } else {
            return "No";
        }
    }

    // 水平方向 (垂直方向も同様)
    // x - r が0 より小さい、または、x + r がW より大きいならばNoと判定。
    // x - r が0 以上、かつ、x + r がW 以下ならばYesと判定。
    private static boolean circle_in_a_Rectangle(int w,int x,int r) {
        int a = x - r;
        int b = x + r;
        if (a < 0 || b > w) {
            return false;
        } else if (a >= 0 && b <= w) {
            return true;
        } else {
            return false;
        }
    }
}

Measured memory_bytes: 17324
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,k;
    cin >> n >> k;
    while(k--){
        int a,b;
        cin >> a >> b;
        int t = min(min(a-1,n-a),min(b-1,n-b));
        cout << t%3 + 1 << endl;
    }

}



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

using namespace std;


int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int k;
	cin >> k;
	k--;
	string answer = "";

	for (int i = 0; i < n; i++) {
		if (s.substr(i, 1) == s.substr(k, 1)) {
			answer += s.substr(k, 1);
		}
		else {
			answer += "*";
		}
	}

	cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN = 100000;
map<pair<int, int>, int>m;
long long ans[10 + 5];
pair<int, int>p[MAXN + 5];
int main() {
	int H, W, N;
	scanf("%d%d%d", &H, &W, &N);
	for(int i=1;i<=N;i++) {
		scanf("%d%d", &p[i].first, &p[i].second);
		for(int dx=-1;dx<=1;dx++)
			for(int dy=-1;dy<=1;dy++) 
				m[make_pair(p[i].first+dx, p[i].second+dy)]++;
	}
	ans[0] = 1LL * (H-2) * (W-2);
	for(map<pair<int, int>, int>::iterator it=m.begin();it!=m.end();it++) {
		if( it->first.first >= 2 && it->first.second >= 2 && it->first.first <= H-1 && it->first.second <= W-1 ) {
			ans[0]--; ans[it->second]++;
		}
	}
	for(int i=0;i<=9;i++)
		cout << ans[i] << endl;
}

Measured memory_bytes: 57216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll> > vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge> > Graph;
typedef vector<pii> vpii;
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;
}

signed main()
{
    string S;
    cin>>S;
    bool flg;
    for(char c='a';c<='z';c++){
        flg=false;
        REP(i,S.size()){
            flg |= (c==S[i]);
        }
        if(!flg){
            cout <<S+c<<endl;
            return 0;
        }
    }
    string ans=S;
    if(!next_permutation(ALL(ans))){
        cout<<-1<<endl;
        return 0;
    }
    REP(i,S.size()){
        cout << ans[i];
        if(S[i]!=ans[i]){
            cout<<endl;
            return 0;
        }
    }
}


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

using namespace std;
long long ans=0,mx=0;
vector<vector<long long> >edges;
map<long,bool>vis;
void solve(long n)
{
    mx++;
    vis[n]=true;
    for(long i=0;i<edges[n].size();i++){
    if(!vis[edges[n][i]]){
    solve(edges[n][i]);
    }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,m,x,z;
    cin>>n>>m;
    edges.resize(n+1);
    for(long i=0;i<m;i++){
    cin>>x>>z;
    edges[x].push_back(z);
    edges[z].push_back(x);
    }
    for(long i=1;i<=n;i++){
    if(!vis[i]){
    mx=0;
    solve(i);
    ans=max(ans,mx);
    }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 48572
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int main(){
  cin >> n;
  bool flag = false;
  for(int i=0; i<2; i++){
    if(n%10==9) flag = true;
    n /=10;
    }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
  }

Measured memory_bytes: 256
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
h1,s1,h2,s2=INPUT()
while(h1>0 and h2>0):
    h2-=s1
    if h2<=0:
        print("Yes")
        break
    h1-=s2
    if h1<=0:
        print("No")
        break
        


Measured memory_bytes: 61864
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

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

  string s; cin >> s;
  if (s == "RRR") {
    cout << 3 << endl;
  } else if (s == "RRS" || s == "SRR") {
    cout << 2 << endl;
  } else if (s == "SSS") {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }

  return 0;
}


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

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); cerr << fixed << setprecision(16); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

vector< int64 > divisor(int64 n) {
  vector< int64 > ret;
  for(int64 i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

void solver() {
  int N = input(), K = input();
  vector< int64 > A(N);

  cin >> A;

  int64 sum = whole(accumulate, A, 0ll);
  int64 ans = 1;

  auto div = divisor(sum);

  for (auto d : div) {
    int k = 0;
    vector< int64 > a = A;
    for (auto &s : a) s %= d;
    whole(sort, a);

    int l = 0, r = N - 1;
    while (l < r) {
      if (a[l] == 0) {
        l++;
        continue;
      }
      if (a[r] == d) {
        r--;
        continue;
      }

      int diff = min(a[l], d - a[r]);
      k += diff;
      a[l] -= diff;
      a[r] += diff;
    }

    if (k <= K) ans = d;
  }

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
 
    int n,i,j,x[4][13]={{0}},no,k;
    char cards;
    
    scanf("%d",&n);
     
     
 
    while(n>0)
    {
         
        scanf(" %c",&cards);
        scanf("%d",&no);
         
 
        if(cards =='S')
        {
            k=0;
 
             
             
        }
     
     
        if(cards =='H')
        {
            k=1;
 
             
             
        }
     
 
        if(cards =='C')
        {
            k=2;
 
             
             
        }
     
        if(cards =='D')
        {
            k=3;
 
             
             
        }
 
        x[k][no-1] =1;
        n--;
 
    }
     
    for(i=0;i<4;i++)
    {
         
         
 
        for(j=0;j<13;j++)
        {
            if(x[i][j] == 0)
            {
             
              
                if(i==0)
                {
                    cards = 'S';
                     
                }
 
                if(i==1)
                {
                    cards = 'H';
                     
                }
 
                if(i==2)
                {
                    cards = 'C';
                     
                }
                 
                if(i==3)
                {
                    cards = 'D';
                     
                }
 
                printf("%c %d\n",cards,j+1);
                 
             
         
        }
     
    }
 
    }
    return 0;
     
} 

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int ans;

    for(int i = 1; i <=9; i++) {
        int x;
        x = i * 100 + i * 10 + i;
        if(n <= x){
            ans = x;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

int main(){
    fast;
    
    ll x;
    cin>>x;
    
    cout<< ( x ? 0 : 1) <<endl;
    
    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

ll N;

int main() {
    cin >> N;
    int sum = 0;
    bool change = false;
    while(true) {
        if(N / 10 == 0) {
            if(change)
                sum += N % 10 - 1;
            else
                sum += N % 10;
            break;
        }
        if(N % 10 != 9) change = true;
        sum += 9;
        N /= 10;
    }
    cout << sum << "\n";
    return 0;
}

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    if(a==b&&b==c)
    {
        if(a&1) puts("0");
        else puts("-1");
        exit(0);
    }
    int cnt=0;
    int ta,tb,tc;
    while(a%2==0&&b%2==0&&c%2==0)
    {
        ta=b/2+c/2;
        tb=a/2+c/2;
        tc=a/2+b/2;
        cnt++;
        a=ta; b=tb; c=tc;
    }
    printf("%d\n",cnt);
    return 0;
}


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

signed main(){
	char b;
	scanf("%c", &b);
	if(b == 'A'){
		printf("T\n");
	}
	if(b == 'T'){
		printf("A\n");
	}
	if(b == 'C'){
		printf("G\n");
	}
	if(b == 'G'){
		printf("C\n");
	}
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>

#include <vector>
#include <stdio.h>
#include <string>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
int MOD = 1e9+7;

int main(){
   string s;
   cin >> s;
   int n=s.size();
   vector<vector<long long>> dp(1e5+5,vector<long long>(13));
   dp[0][0]=1;
   for(int i=0;i<n;i++){
       int c;
       if(s[i]=='?'){
           c=-1;
       }else{
           c=s[i]-'0';
       }
      for(int j=0;j<10;j++){
          if(c != -1 && c!=j){
              continue;
          }else{
              for(int k=0;k<13;k++){
                  dp[i+1][(k*10+j)%13] += dp[i][k]; 
              }
          }
      }
      for(int j=0;j<13;j++){
          dp[i+1][j] %= MOD;
      }
   }
   cout<<dp[n][5]<<endl;
}


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

int main()
{
    int n, t = 0, h = 0; cin >> n;
    string taro, hanako;
    while (cin >> taro >> hanako) {
        if (taro > hanako) t += 3;
        else if (taro < hanako) h += 3;
        else {
            t++;
            h++;
        }
    }
    cout << t << " " << h << endl;
}



Measured memory_bytes: 3164
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-08 20:32:41
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int n; cin >> n;
  vector<vector<int>> a(n, vector<int>(n, -1));
  // a[i][j] : i は j を正直だと証言

  for (int i = 0; i < n; ++i) {
    int A; cin >> A;
    for (int j = 0; j < A; ++j) {
      int x, y; cin >> x >> y;
      --x;
      if (y) {
        a[i][x] = 1;
      } else {
        a[i][x] = 0;
      }
    }
  }

  //debug(a);

  int ans = 0;

  for (int bit = 0; bit < (1 << n); ++bit) {
    bool flag = true;
    for (int i = 0; i < n; ++i) {
      if (bit & (1<<i)) { // i 番目が正直
        for (int j = 0; j < n; ++j) {
          if (a[i][j] == -1) continue;
          if (a[i][j] == 0 && (bit & (1<<j)) || a[i][j] == 1 && !(bit & (1<<j))) {
            flag = false;
            break;
          }
        }
      }
    }
    if (flag) {
      bitset<20> bs(bit);
      ans = max(ans, (int)bs.count());
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector

/*  <<bit全探索>>
 
    for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
        bitset<ビット数> s(tmp);
    }
*/
 
/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 
typedef long long ll;

///////////////////////////////////////////////////////////////////////////


int main() {

    int N;
    cin >> N;
    
    int x = 0;
    int y = 0;

    vec<int> A(N);
    rep(i, N){
        
        cin >> A.at(i);

        if(A.at(i) % 2 == 0){
            x++;
            if(A.at(i) % 3 == 0 || A.at(i) % 5 == 0){
                y++;
            }
            
        }
    }

    if(x == y){
        cout << "APPROVED" << endl;
    }

    else{
        cout << "DENIED" << endl;
    }
}

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

typedef struct D
{
	int n,r,l,d,p,dep,h,sub,deg;
}D;

D node[30];
int i,j,N,r,l,n;

int dfs(int p,int d)
{
	int a,b;
	if(p==-1)return -1;
	node[p].dep=d;
	a=dfs(node[p].r,d+1);
	b=dfs(node[p].l,d+1);
	if(a==-1&&b==-1)
		node[p].h=0;
	else
		node[p].h=(a>b?a:b)+1;
	return node[p].h;
}

int main()
{
	memset(node,-1,sizeof(node));
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d%d%d",&n,&l,&r);
		node[n].l=l;
		node[n].r=r;
		node[n].deg=(r!=-1)+(l!=-1);
		node[l].sub=r;
		node[r].sub=l;
		if(l!=-1)node[l].p=n;
		if(r!=-1)node[r].p=n;
	}
	for(i=0;i<N;i++)
		if(node[i].p==-1)
			dfs(i,0);

	for(i=0;i<N;i++)
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",
		i,node[i].p,node[i].sub,node[i].deg,node[i].dep,node[i].h,node[i].p==-1?"root":node[i].l==-1&&node[i].r==-1?"leaf":"internal node");
	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e6+5;
char s[N];
int f, n, k, bit[N];
int main()
{
    scanf("%s", s); n = strlen(s);
    for(int i = 0; i < n; ++i) bit[i] = (s[n-i-1]-'0')*9;
    for(int i = 0, k = 0; i < n||k; ++i) bit[i] += k, k = bit[i]/10, f += (bit[i] %= 10);
    for(int k = 1; k <= n; ++k)
    {
        for(int i = 0, d = 9; d; ++i) 
            f -= bit[i], bit[i] += d, d = bit[i]/10, f += (bit[i] %= 10);
        if(f <= 9*k) return printf("%d\n", k), 0;    
    }
    return 0;
}   

Measured memory_bytes: 4608
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        int[] a = ReadIntArray();
        int[] d = { Math.Abs(a[0] - a[1]),
                    Math.Abs(a[1] - a[2]),
                    Math.Abs(a[2] - a[0]) };
        Array.Sort(d);
        WriteLine(d[0]+d[1]);
    }
}


Measured memory_bytes: 13396
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main {
	static int[] diag;
	static ArrayList<ArrayList<Integer>> vector = new ArrayList<ArrayList<Integer>>();
	public static void topological(int v) {
		Deque<Integer> q = new ArrayDeque<Integer>();
		for(int i=0; i<v; i++) {
			if(diag[i] == 0) {
				q.addLast(i);
			}
		}

		while(!q.isEmpty()) {
			int n = q.removeFirst();
			System.out.println(n);
			ArrayList<Integer> lst = vector.get(n);
			for(int i=0; i<lst.size(); i++) {
				int k = lst.get(i);
				diag[k]--;
				if(diag[k] == 0) q.addLast(k);
			}
		}
	}

	public static void main(String[] args) {
		FS r = new FS();
		int v = r.nextInt();
		int e = r.nextInt();
		diag = new int[v];
		for(int i=0; i<v; i++) {
			vector.add(new ArrayList<Integer>());
		}
		for(int i=0; i<e; i++) {
			int s = r.nextInt();
			int t = r.nextInt();
			vector.get(s).add(t);
			diag[t]++;
		}
		topological(v);
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

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

#define Task "abc"
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll calc(ll X, ll div){
  if (X < 0) return 0;
  return X / div + 1;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  ll a, b, x;
  cin >> a >> b >> x;
  cout << calc(b, x) - calc(a-1, x);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];

void solve() {
	cin >> N;
	int lv = inf, rv = -1;
	rep(i, 0, N) {
		cin >> A[i];
		MIN(lv, A[i]);
		MAX(rv, A[i]);
	}
	if(rv - lv > 1) {
		cout << "No\n";
	}
	else {
		if(rv - lv == 0) {
			if(rv == N - 1) cout << "Yes\n";
			else if(rv * 2 <= N) cout << "Yes\n";
			else cout << "No\n";
		}
		else {
			int cnt = 0;
			rep(i, 0, N) {
				if(A[i] == lv) cnt++;
			}
			if(cnt + 1 <= rv && 2 * (rv - cnt) <= N - cnt) cout << "Yes\n";
			else cout << "No\n";
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}





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

int main(){
  int k, n;
  cin >> k >> n;
  int m = INT_MAX;
  vector<int> arr(n*2);
  for(int i = 0; i < n; i++){
    cin >> arr[i];
    arr[i+n] = arr[i] + k;
  }

  for(int i = 0; i < n; i++)
    m = min(m, arr[i+n-1] - arr[i]);

  cout << m << endl;
  return 0;
}

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

int main() {
    int N; cin >> N;
    long long mult=1;
    vector<long long> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
        if(A.at(i)==0){
            mult=0;
            break;
        }
    }
    if(mult!=0){
        for(int i=0; i<N; i++){
        if(A.at(i)<=(1000000000000000000/mult)) mult=mult*A.at(i);
        else{
            mult=-1;
            break;
        }
        }
    }
    cout << mult << endl;
}

Measured memory_bytes: 4032
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N;
int D[200010];

signed main()
{
	cin >> N;
	REP(i, N) cin >> D[i];

	ARY_SORT(D, N);

	int a = D[N / 2 - 1];
	int b = D[N / 2];

	cout << (b - a) << endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
  	string s,t; cin >> s >> t;
    rep(i,s.length()){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
return 0;
}




Measured memory_bytes: 3624
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll n,k,i,j,res,ans = MAX;
ll a[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>k;
    rep(i,1,n + 1) cin>>a[i];
    for(i = 1;i + k - 1 <= n;i++){
        j = i + k - 1;
        if(a[i] >= 0) res = llabs(a[j]);
        else{
            if(a[j] < 0)
                res = llabs(a[i]);
            else
                res = min(llabs(a[i]),llabs(a[j])) + llabs(a[j] - a[i]);
        }
        ans = min(ans,res);
    }
    cout<<ans;
    return 0;
}

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

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if ((double)(abs(b-a)) / (double)(v-w) <= (double)t and v > w) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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


int main() {
    int N,Y;
    cin>>N>>Y;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
                if(i*10000+j*5000+(N-i-j)*1000==Y){
                    cout<<i<<" "<<j<<" "<<N-i-j<<endl;
                    return 0;
                }
            }
        }
         cout<<-1<<" "<<-1<<" "<<-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();
    char[] s = sc.next().toCharArray();
    HashMap<String,Integer> map1 = new HashMap<>();
    HashMap<Integer,String> map2 = new HashMap<>();
    int p=0;
    for(char c='A';c<='Z';c++){
      map1.put(String.valueOf(c),p);
      map2.put(p,String.valueOf(c));
      p++;
    }
    for(int i=0;i<s.length;i++){
      int k = (map1.get(String.valueOf(s[i]))+n)%26;
      System.out.print(map2.get(k));
    }
    System.out.println("");
  }
}

Measured memory_bytes: 24276
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	ll n,ans=0;
	bool flg = false,isContinue=true;
	in(n);
	vll h(n);
	rep(i, 0, n) {
		in(h[i]);
	}

	while (isContinue) {
		isContinue = false;
		rep(i, 0, n) {
			if (h[i] > 0) {
				isContinue = true;
				flg = true;
				h[i]--;
			}
			else if (flg && h[i] == 0) {
				flg = false;
				ans++;
			}
		}
		if (flg) {
			ans++;
			flg = false;
		}
	}

	outn(ans);
	return 0;

}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
h = [int(input()) for _ in range(n)]

import math
def ok(x):
    t = 0
    for i in range(n):
        r = h[i] - b*x
        if r < 0:
            continue
        else:
            t += math.ceil(r/(a-b))
    if t <= x:
        return True
    else:
        return False

l = 0
r = 10**14+1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Measured memory_bytes: 7072
N = int(input())
x = [0] * N
x=map (int, input().split(' '))


def check(x, count):
    n=[]
    for d in x:
        if d%2 != 0:
            print(count)
            return False
        n.append(d/2)
    count+=1 
    check(n, count)
    
    

check(x, 0)

Measured memory_bytes: 3188
s,t=input(),input()
m,n=len(s),len(t)
l=[[0 for i in range(n+1)] for j in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        if s[i-1]==t[j-1]:
            l[i][j]=l[i-1][j-1]+1
        else:
            l[i][j]=max(l[i-1][j],l[i][j-1])
pos=l[m][n]
i,j,lcs=m,n,['']*(pos+1)
while i>0 and j>0:
    if s[i-1] == t[j-1]:
        lcs[pos-1]=s[i-1]
        i,j,pos=i-1,j-1,pos-1
    elif l[i-1][j]>l[i][j-1]:
        i-=1
    else:
        j-=1
print(''.join(lcs))


Measured memory_bytes: 119772