akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
map<int,int>mp;
int ans[200000];
vector<int>g[200000];
int k[200000];
void dfs(int s, int p, int sum){
    ans[s] = sum;
    for(int x : g[s]){
        if(x != p)dfs(x,s,sum+k[x]);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    while(q--){
        int a, b;
        cin >> a >> b;
        a--;
        k[a] += b;
    }
    dfs(0,-1,k[0]);
    rep(i,n)cout << ans[i] << " \n"[i == n - 1];
}

Measured memory_bytes: 24064
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

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

#define endl '\n'
#define int long long

const int inf = 1e18 + 5;

void solve()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << endl;
}

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

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

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

int gcd(int x, int y){
  return y ? gcd(y, x%y) : x;
}

int print(int x, int y){
  int g = gcd(x, y);
  printf("%d/%d\n", x/g, y/g);
}

int main(){
  char in[10], all[10], sub[10];
  scanf("%s", in);
  int o, p, l, r, d, i, all_i = 0;
  p = -1;

  for ( i = 0; i < strlen(in); i++ ){
    if ( in[i] == '.' ){
      o = i;
    } else if ( in[i] == '(' ) {
      p = i;
      strncpy(sub, all, all_i);
      sub[all_i] = '\0';
    } else if ( in[i] == ')' ) {
    } else {
      all[all_i++] = in[i];
    }
  }
  all[all_i] = '\0';

  d = strlen(in) - o - 1;
  l = p - o - 1;
  if ( p == -1 ){
    print(atoi(all), pow(10, d));
  }else {
    d -= 2; // for ()
    print(atoi(all) - atoi(sub), pow(10, d) - pow(10, l) );
  }
  return 0;
}





Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++)
        if(s[i]!=s[s.size()-i-1]) ans++;
    cout<<ans/2<<'\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, end) for (int i = begin; i > end; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int N, K;
int V[200];

int main()
{
    cin >> N >> K;
    rep(i, 0, N)
    {
        cin >> V[i];
    }

    ll ans = -1;
    for (int a = 0; a <= min(N, K); a++)
    {
        for (int b = 0; b <= min(N, K) - a; b++)
        {
            priority_queue<int, vector<int>, greater<int>> have;
            for (int i = 0; i < a; i++)
            {
                have.push(V[i]);
            }
            for (int i = 0; i < b; i++)
            {
                have.push(V[N - 1 - i]);
            }
            ll sum = 0;
            for (int i = 0; i < K - a - b; i++)
            {
                if (have.empty())
                {
                    break;
                }
                if (have.top() >= 0)
                {
                    break;
                }
                have.pop();
            }
            while (!have.empty())
            {
                sum += have.top();
                have.pop();
            }
            ans = max(ans, sum);
        }
    }

    printf("%lld", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
long long INF = 1e18;
int main(void){
	int A,B,Q;
	cin >> A >> B >> Q;
	vector<long long> s(A+2);
	vector<long long> t(B+2);
	vector<long long> x(Q);
	s[0]=(-1)*INF;
	t[0]=(-1)*INF;
	s[A+1]=INF;
	t[B+1]=INF;
	for(int i=0;i<A;i++)cin >> s[i+1];
	sort(ALL(s));
	for(int i=0;i<B;i++)cin >> t[i+1];
	sort(ALL(t));
	for(int i=0;i<Q;i++)cin >> x[i];
	for(int i=0;i<Q;i++){
		long long start = x[i];
		long long ans = INF;
		auto it = lower_bound(ALL(s),x[i]);
		it--;
		long long left = *it;
		it++;
		long long right= *it;
		it = lower_bound(ALL(t),left);
		it --;
		long long a = *it;
		it ++;
		long long b = *it;
		ans = abs(start-left)+min(abs(left-a),abs(left-b));
		it = lower_bound(ALL(t),right);
		it --;
		a = *it;
		it ++;
		b = *it;
		long long ans2 = abs(start-right)+min(abs(right-a),abs(right-b));
		ans = min(ans,ans2);
		it = lower_bound(ALL(t),start);
		it--;
		left = *it;
		it++;
		right= *it;
		it = lower_bound(ALL(s),left);
		it--;
		a = *it;
		it++;
		b = *it;
		long long ans3 = abs(start-left)+min(abs(left-a),abs(left-b));
		it = lower_bound(ALL(s),right);
		it--;
		a = *it;
		it++;
		b = *it;
		ans2 = abs(start-right)+min(abs(right-a),abs(right-b));
		ans2 = min(ans2,ans3);
		cout << min(ans,ans2) << endl;
	}
}

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

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

    int use[26] = {0};
    for (int i = 0; i < s.size(); i++)
    {
        use[s[i] - 'a']++;
    }

    for (int i = 0; i < 26; i++)
    {
        if (use[i] == 0)
        {
            char ans = 'a' + i;
            cout << ans << endl;
            return 0;
        }
    }

    cout << "None" << endl;

    return 0;
}

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

int main(void) {
  int n, k, x, y;
  scanf("%d %d %d %d", &n, &k, &x, &y);
  if (n <= k) printf("%d\n", n * x);
  else printf("%d\n", x*k + (n-k)*y);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3*1e3;
string s, t;
int dp[N+1][N+1];
int f(unsigned int i, unsigned int j){
    if( i == s.size() || j == t.size() )
        return 0;
    if( dp[i][j] != -1 )
        return dp[i][j];
    if( s[i] == t[j] )
        return dp[i][j] = f(i+1, j+1) + 1;
    return dp[i][j] = max(f(i+1, j), f(i, j+1));
}
void p(unsigned int i, unsigned int j){
    if( i == s.size() || j == t.size() )
        return;
    if( s[i] == t[j] ){
        cout << s[i];
        p(i+1, j+1);
        return;
    }
    if( i == s.size() - 1 )
        return p(i, j+1);
    if( j == t.size() - 1 )
        return p(i+1, j);
    if( dp[i+1][j] > dp[i][j+1] )
        return p(i+1, j);
    return p(i, j+1);
}
int main() {
    cin >> s >> t;
    memset(dp, -1, sizeof dp);
    f(0, 0);
    p(0, 0);
    return 0;
}


Measured memory_bytes: 35840
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
char a,b;
cin>>a>>b;
if(a=='H'){
    cout<<b<<endl;
}
else{
    if(b=='H')cout<<'D'<<endl;
    else cout<<'H'<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#include <deque>

#define INF_LL 1e18
#define INF 1e9

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

using namespace std;

using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

const ll MOD = 1e9+7;

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

template<typename T>
void chmax(T &a, T &b){
	a = max(a, b);
}

template<typename T>
void chmin(T &a, T &b){
	a = min(a, b);
}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

class RMQ{
	int n;
	vector<int> dat;
public:
	RMQ(int n_){
		n = 1;
		while(n < n_) n *= 2;
		REP(i, n*2-1){
			dat.push_back(INF);
		}
	}

	void update(int x, int i){
		i += n-1;
		dat[i] = x;
		while(i > 0){
			i = (i-1)/2;
			dat[i] = min(dat[i*2+1], dat[i*2+2]);
		}
	}

	int query(int a, int b, int l, int r, int x){
		if(a <= l && r <= b) return dat[x];
		if(r <= a || b <= l) return INF;

		int res = INF;
		res = min(query(a, b, l, (l+r)/2, x*2+1), query(a, b, (l+r)/2, r, x*2+2));
		return res;
	}
	int query(int a, int b){
		return query(a, b, 0, n, 0);
	}
};

const ll mod = 1e9+7;

int main(void){
	int dp[51414][2] = {};
	string s;
	int N;
	cin >> s;
	int p = 0, g = 0;
	/*
	N = s.size();
	dp[0][0] = 0;
	FOR(i, 1, s.size()){
		REP(j, i/2+2){
			if(s[i] == 'p')
				dp[j][i%2] = max(dp[j][1-(i%2)]-1, j > 0 ? dp[j-1][1-(i%2)] : (int)-INF);
			else
				dp[j][i%2] = max(dp[j][1-(i%2)], j > 0 ? dp[j-1][1-(i%2)]+1 : (int)-INF);
		}
	}
	cout << dp[N/2][1-(N%2)] << endl;
	*/
	REP(i, s.size()){
		if(s[i] == 'p')
			p++;
		else
			g++;
	}
	cout << max((g-p)/2, 0) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define rep1(i,n) for (int i=1; i<=(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fst first
#define scd second
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m;
  map<string,int> ms;
  cin >> n;
  rep(i,n) { string s; cin >> s; ms[s]++; }
  cin >> m;
  rep(i,m) { string s; cin >> s; ms[s]--; }
  int ans = 0;
  for (auto p : ms) {
    ans = max(ans, p.scd);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#define mk make_pair
#define pb push_back
#define ll long long 
using namespace std;
const int maxn =2e5+50;
vector<ll> arr;
int n;
ll a, b;
bool is_enough(ll x) {
  vector<ll> h = arr;
  ll cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (h[i] > x * b) {
      cnt += ceil((double)(h[i] - x * b) / (a - b));
    }
  }
  return cnt <= x;
}

int main() {
  cin>>n>>a>>b;
  ll ma = 0;
  for (int i = 0; i < n; ++i) {
   ll h;
    cin>>h;
    arr.pb(h);
    ma = max(h, ma);
  }
 
  ll l = -1, r = ma;
  while (l + 1 < r) {
    ll mid = (l + r) / 2;
    if (is_enough(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout<<r;
  return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	string s; cin >> s;
	for (int i = 0; i < 3; i++)
		cout << s[i];
	cout << endl;
}


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

int main()
{
	int t;
	while(cin>>t&&t)
	{
		int n;
		cin>>n;
		for(int i=0;i<n;i++)
		{
			int a,b;
			cin>>a>>b;
			t-=b-a;
		}
		
		if(t>0)cout<<t<<endl;
		else cout<<"OK"<<endl;
	}
	
	
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<ll> vl;
const int INF=1e+9;
const ll INFLL=1e+17;
ll K;
vl snuke,snuke_ans,snuke2;
ll digit_sum(ll x){
  ll res=0;
  while(x>=10){
    res+=x%10;
    x/=10;
  }
  res+=x;
  return res;
}
double snuke_num(ll x){
  return (double)(x)/(double)(digit_sum(x));
}
void make_snuke(){
  rep1(i,9) snuke.push_back(i);
  rep1(i,9) snuke.push_back(i*10+9);
  ll x=100;
  rep(i,13){
    for(ll j=2;j<=200;j++){
      snuke.push_back(j*x-1);
    }
    x*=10;
  }
  std::sort(snuke.begin(),snuke.end());
  int ss=snuke.size();
  snuke.push_back(0);
  rep(i,ss){
    if(snuke[i]!=snuke[i+1]) snuke2.push_back(snuke[i]);
  }
  double min=1e+16;
  for(ll i=snuke2.size()-1;i>=0;i--){
    if(snuke_num(snuke2[i])<=min){
      min=snuke_num(snuke2[i]);
      snuke_ans.push_back(snuke2[i]);
    }
  }
  std::sort(snuke_ans.begin(),snuke_ans.end());  
}
void solve(){
  make_snuke();
  rep(i,K) prin(snuke_ans[i]);
}
int main(){
  cin>>K;
  solve();
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
  char str[5];

  scanf("%s", str);

  if(str[0]==str[1]&&str[1]==str[2]&&str[2]==str[3]){
    printf("No\n");
  }else if(str[0]==str[2]&&str[1]==str[3]){
    printf("Yes\n");
  }else if(str[0]==str[3]&&str[1]==str[2]){
    printf("Yes\n");
  }else if(str[0]==str[1]&&str[2]==str[3]){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


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

using namespace std;
using namespace std;
typedef long long ll;
#define endl "\n";
#define MAX 10000001+9   //Maximum array size;
#define loop(n) for(ll i=0;i<n;i++)
#define loop2(n) for(ll i=0;i<n;i+=2)
#define all(v) v.begin(),v.end()
#define sz(v)  v.size()
typedef vector<ll> vi;
typedef set<ll> si;

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}

int pow(int a, int b) {
    int pow = 1;
    loop(b)pow *= a;
    return pow;
    //thanks m7md :)
}

int solution(vector<int> &A) {
sort(A.begin(),A.end());
int n=A.size();
int l=0,r=n-1,solu=2*(1e9+1);
while(l<n){
    if(abs(A[r-1]-A[l])>=abs(A[l+1]-A[r])){
        solu=min(solu,abs(A[r-1]-A[l]));
        r--;
    }else{
       solu=min(solu,abs(A[l+1]-A[r]));
       l++;
    }
}
    for (int i = 0; i <n ; ++i) {
        solu=min(solu,abs(A[i]+A[i]));
    }
return solu;
}

int main() {
    fast();
    int n;cin>>n;
    int c[n];
    int solu=1e9;
    for (int i = 0; i <n ; ++i) {
        cin>>c[i];
    }
    for (int j = -100; j <=100 ; ++j) {
        int total=0;
        for (int i = 0; i <n ; ++i) {
            total+=(pow(c[i]-j,2));
        }
        solu=min(solu,total);
    }
    cout<<solu;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Main {

    void countingSort(int[] A, int[] B, int k) {
        int[] C = new int[k + 1];
        for (int i = 0; i < A.length; i++)
            C[A[i]]++;
        for (int i = 1; i <= k; i++)
            C[i] = C[i] + C[i - 1];

        for (int i = A.length - 1; i >= 0; i--) {
            B[C[A[i]] - 1] = A[i];
            C[A[i]]--;
        }
    }

    void solve() {
        int n = io.nextInt();
        int[] A = new int[n];
        int[] B = new int[n];
        for (int i = 0; i < n; i++) {
            A[i] = io.nextInt();
        }
        countingSort(A, B, Arrays.stream(A).max().getAsInt());
        System.out.println(Arrays.stream(B).mapToObj(Integer::toString).collect(Collectors.joining(" ")));
    }

    public static void main(final String[] args) {
        new Main().solve();
    }

    IO io = new IO();

    class IO {
        private final int SIZE = 1 << 12;
        private final InputStream stream = System.in;
        private final byte[] buffer = new byte[SIZE];
        private int ptr = 0, buffLen = 0;

        private boolean hasNextByte() {
            if (ptr < buffLen) return true;
            ptr = 0;
            try {
                buffLen = stream.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return buffLen > 0;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isAscii(byte i) {
            return '!' <= i && i <= '~';
        }

        public char nextChar() {
            byte b = readByte();
            while (!isAscii(b)) b = readByte();
            return (char) b;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();
            byte b = readByte();
            while (isAscii(b)) {
                sb.append((char) b);
                b = readByte();
            }
            return sb.toString();
        }

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

        public long nextLong() {
            return Long.valueOf(next());
        }

        public double nextDouble() {
            return Double.valueOf(next());
        }
    }
}



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

int main(){
    int n;
    cin >> n;
    vector<int> p(n), need_trans;
    rep(i, n) {
        cin >> p[i];
        if (p[i]==i+1) need_trans.push_back(i+1);
    }
    int prev = -1, ans = 0;
    for (auto x: need_trans) {
        if (prev+1 != x) {
            prev = x;
            ans++;
        } else {
            prev = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long n,k,l,m;
    vector<unsigned long long>v;
    cin>>n>>k;
    if(n%k==0)
    {
        cout<<"0"<<endl;
    }
    else
    {
       l=n%k;
       m=k-l;
       if(m>l)
       {
           cout<<l<<endl;
       }
       else
        cout<<m<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const ll MAX_N = 1e5 + 10;
const int MAX_K = 1e3+10;

int main(int argc, const char * argv[]){
  int N, K;
  ll x[MAX_N], y[MAX_N], sum[2*MAX_K][2*MAX_K]={0};
  char c[MAX_N];
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
  	cin >> x[i] >> y[i] >> c[i];
  	if (c[i]=='W') {
  		c[i] = 'B';
  		y[i] += K;
  	}
  	x[i] %= 2*K;
  	y[i] %= 2*K;
  }

  for (int i = 0; i < N; ++i) {
    sum[x[i]][y[i]]++;
    sum[(x[i]+K)%(2*K)][(y[i]+K)%(2*K)]++;
  }
  ll ans = 0;

  for (int sx = 0; sx < 2*K; ++sx) {
    for (int sy = 0; sy < 2*K; ++sy) {
      sum[sx+1][sy+1] += sum[sx+1][sy] + sum[sx][sy+1] - sum[sx][sy];
    }
  }

  for (int sx = 0; sx < K; ++sx) {
    for (int sy = 0; sy < K; ++sy) {
      ll cnt = sum[sx][sy]+sum[sx+K][sy+K] - sum[sx+K][sy] - sum[sx][sy+K];
      ans = max(ans, max(cnt,N-cnt));
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
}

int main(){
    go();

    // code here
    int n,m,k;cin>>n>>m>>k;
    long long arr1[n+1] = {0ll},arr2[m+1] = {0ll};
    forn(1,n+1,1) cin>>arr1[i];
    forn(1,m+1,1) cin>>arr2[i];
    forn(2,n+1,1) arr1[i] += arr1[i-1]; 
    forn(2,m+1,1) arr2[i] += arr2[i-1];
    int ans = 0;
    for(int i = 0;i < n+1; i++){
        int start = 0,end = m;
        while(start<=end){
            int mid = start + (end - start)/2;
            if(arr2[mid]<=(k-arr1[i])){
                ans = max(ans,mid+i);
                start = mid + 1;
            }else{
                end = mid - 1;
            }
        } 
    }
    cout<<ans;
   
    
}






Measured memory_bytes: 6768
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 6)


def main():
    N = int(readline())
    edge = [[] for _ in range(N + 1)]

    for _ in range(N - 1):
        a, b, c = map(int, readline().split())
        edge[a].append((b, c))
        edge[b].append((a, c))

    Q, K = map(int, readline().split())

    distance = [None] * (N + 1)


    def measure_distance(v, d):
        distance[v] = d
        for vv, dd in edge[v]:
            if distance[vv] is not None:
                continue
            measure_distance(vv, d + dd)


    measure_distance(K, 0)

    xy = map(int, read().split())
    for x, y in zip(xy, xy):
        print(distance[x] + distance[y])


if __name__ == '__main__':
    main()

Measured memory_bytes: 153552
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
    double x[100], y[100];
    int n;
    cin >> n;
    for(int i = 0; i<n; i++){
        cin >> x[i];
    } 
    for(int i = 0; i<n; i++){
        cin >> y[i];
    } 
    
    double a,b=0.0,c=0.0,d=0.0,e=0.0;
    for (int i = 0; i < n; i++){
        a = fabs(y[i] - x[i]);
        b += a;
        c += a*a;
        d += a*a*a;
        e = max(e, a);
    }
    c = sqrt(c);
    d = pow(d, 1.0 / 3.0);
    cout<<fixed<<setprecision(10)<<b<<endl<<c<<endl<<d<<endl<<e<<endl;
    return 0;
}


Measured memory_bytes: 3440
#include <iostream>
#include <vector>

using namespace std;
vector<int> G[200010];
int d[200010],p[200010];
vector<int> num[3];
void dfs(int s, int p){
	for(int v:G[s]){
		if(v==p) continue;
		d[v] = d[s] + 1;
		dfs(v,s);
	}
}

int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n - 1;i++){
		int a,b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	d[0] = 0;
	dfs(0,-1);
	int od = 0,ev = 0;
	for(i=0;i<n;i++){
		if(d[i]&1) od++;
		else ev++;
	}
	for(i=1;i<=n;i++){
		num[i%3].push_back(i);
	}
	if(od<=num[0].size()){
		for(i=0;i<n;i++){
			if(d[i]&1){
				p[i] = num[0].back();
				num[0].pop_back();
			}else{
				if(num[1].size()){
					p[i] = num[1].back();
					num[1].pop_back();
				}else if(num[2].size()){
					p[i] = num[2].back();
					num[2].pop_back();
				}else{
					p[i] = num[0].back();
					num[0].pop_back();
				}
			}
		}
	}else if(ev<=num[0].size()){
		for(i=0;i<n;i++){
			if(d[i]&1){
				if(num[1].size()){
					p[i] = num[1].back();
					num[1].pop_back();
				}else if(num[2].size()){
					p[i] = num[2].back();
					num[2].pop_back();
				}else{
					p[i] = num[0].back();
					num[0].pop_back();
				}
			}else{
				p[i] = num[0].back();
				num[0].pop_back();
			}
		}
	}else{
		for(i=0;i<n;i++){
			if(d[i]&1){
				if(num[1].size()){
					p[i] = num[1].back();
					num[1].pop_back();
				}else{
					p[i] = num[0].back();
					num[0].pop_back();
				}
			}else{
				if(num[2].size()){
					p[i] = num[2].back();
					num[2].pop_back();
				}else{
					p[i] = num[0].back();
					num[0].pop_back();
				}
			}
		}
	}
	for(i=0;i<n;i++){
		cout << p[i] << " ";
	}
	cout << endl;
}

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

int main() {
    int n;
    long long c;
    cin >> n >> c;
    vector<long long> x(n), v(n);
    long long mx1=0, mx2=0, xs=0, ys=0;
    for (int i=0; i<n; i++) {
        cin >> x[i] >> v[i];
        ys+=v[i];
    }
    long long ans=0;
    for (int i=0; i<=n; i++) {
        if ( i>0 ) xs+=v[i-1];
        if ( i>0 ) ys-=v[i-1];
        if ( i>0 ) ans=max(ans,xs-x[i-1]);
        if ( i<n ) ans=max(ans,ys-(c-x[i]));
        if ( i>0 ) mx1=max(mx1,xs-x[i-1]);
        if ( i>0 ) mx2=max(mx2,xs-x[i-1]*2);
        if ( i<n ) ans=max(ans,ys-(c-x[i])*2+mx1);
        if ( i<n ) ans=max(ans,ys-(c-x[i])+mx2);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  long K,X;
  cin>>K>>X;
  
  for(long i = X - K + 1;i < X + K ;i++)
  {
    if( i <= 1000000 && i >= -1000000)
    {
      cout<<i<<" ";
    }
  }
  return 0;
}
  

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();
        
        if((n<1000) && (n>0)){
            System.out.println("ABC");
        }else{
            System.out.println("ABD");
        }

    }

}


Measured memory_bytes: 21716
while True:
    m,f,r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif 80 <= m + f:
        print("A")
    elif 65 <= m + f <= 79:
        print("B")
    elif 50 <= m + f <= 64:
        print("C")
    elif 30 > m + f:
        print("F")
    else:
        if r >= 50:
            print("C")
        else:
            print("D")



Measured memory_bytes: 5596
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	int n;
	int x;
	
	while (scanf("%d", &n) != EOF){
		x = 0;
		
		for (a = 0; a <= 9; a++){
			for (b = 0; b <= 9; b++){
				for (c = 0; c <= 9; c++){
					for (d = 0; d <= 9; d++){
						if (a + b + c + d == n){
							x++;
						}
					}
				}
			}
		}
		
		printf("%d\n", x);
	}
	
	return (0);
}

Measured memory_bytes: 596
def opt(N, S):
    if N == 1:
        return 0
    else:
        split = int(N/2)
        return min(opt(split,S[:split])+S[split:].count('E'),S[:split].count('W')+opt(N - split,S[split:]))

Num = int(raw_input())
Str = str(raw_input())
print(opt(Num, Str))


Measured memory_bytes: 3260
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
	int N, ANS = 0;
	vector<int> A;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		int t;
		cin >> t;
		A.push_back(t);
	}
	
	for (int i = 0; i < N-1; i++)
	{
		int j = 0;
		j=min(A[i], A[i + 1]);
		ANS = ANS + j;
	}
	ANS = ANS + A[0];
	cout << ANS << endl;

}

Measured memory_bytes: 256
import * as fs from 'fs';

const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).split('\n');

const n = +input[0];
const li = input[1].split(' ').map((x: string): number => +x);

let ans: string = 'APPROVED';
li.forEach(num => {
    if(num % 2 === 0){
        if(num % 3 !== 0 && num % 5 !== 0){
            ans = 'DENIED';
        }
    }
})

console.log(ans);

Measured memory_bytes: 7372
# coding: utf-8
N=input()
lst=list(N)
#+++
if (int(lst[0])+int(lst[1])+int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'+'+lst[2]+'+'+lst[3]+'=7')
#---
elif (int(lst[0])-int(lst[1])-int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'-'+lst[2]+'-'+lst[3]+'=7')
#-+-    
elif (int(lst[0])-int(lst[1])+int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'+'+lst[2]+'-'+lst[3]+'=7')
#+-+    
elif (int(lst[0])+int(lst[1])-int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'-'+lst[2]+'+'+lst[3]+'=7')

#++-
elif (int(lst[0])+int(lst[1])+int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'+'+lst[2]+'-'+lst[3]+'=7')
#+--    
elif (int(lst[0])+int(lst[1])-int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'-'+lst[2]+'-'+lst[3]+'=7')
#-++    
elif (int(lst[0])-int(lst[1])+int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'+'+lst[2]+'+'+lst[3]+'=7')
#--+   
elif (int(lst[0])-int(lst[1])-int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'-'+lst[2]+'+'+lst[3]+'=7')

Measured memory_bytes: 3192
#include<iostream>
#include<cmath>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  li n; cin >>n;
  li k=sqrt(n);
  for(;k>0;k--){
    if(n%k==0)break;
  }
  printf("%ld",k+n/k-2);
}

/// confirm df==0 ///


Measured memory_bytes: 256
n = int(input())
s = input()
list_abc = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans = ''
for i in s:
    if list_abc.index(i) + n < 25:
        ans += list_abc[list_abc.index(i) + n]
    else:
        ans += list_abc[list_abc.index(i) + n- 26]
print(ans)

Measured memory_bytes: 3064
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
long long MOD;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

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

long long A,B;

bool ok(long long key,long long index){
    string S = to_string(index);
    long long nagasa = S.size();
    if(index*A+nagasa*B > key) return true;
    else if(index*A+nagasa*B <= key) return false;
}

long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}



int main() {
    int A;cin >> A;
    int ans = 0;
    while(A > 0){
        if(A % 10 == 2) ans++;
        A /= 10;
    }

    cout << ans << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint T;
llint n, a, b, c, d;
map<llint, llint> mp;

llint dfs(llint x)
{
	if(mp.count(x)) return mp[x];
	if(x == 0) return mp[0] = 0;
	if(x == 1) return mp[1] = d;
	
	llint ret = inf;
	if(x <= n / d) ret = min(ret, x*d);
	ret = min(ret, dfs(x/2)+a+x%2*d);
	ret = min(ret, dfs((x+1)/2)+a+(2-x%2)*d);
	ret = min(ret, dfs(x/3)+b+x%3*d);
	ret = min(ret, dfs((x+2)/3)+b+(3-x%3)*d);
	ret = min(ret, dfs(x/5)+c+x%5*d);
	ret = min(ret, dfs((x+4)/5)+c+(5-x%5)*d);
	return mp[x] = ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> T;
	for(int t = 0; t < T; t++){
		cin >> n >> a >> b >> c >> d;
		
		mp.clear();
		cout << dfs(n) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4368
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    x = 1
    for i in a:
        x *= i
    y = 0
    for i in a:
        y += x // i
    print(x / y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var RGBN = ReadLine().Split().Select(int.Parse).ToArray();
        var R = RGBN[0];
        var G = RGBN[1];
        var B = RGBN[2];
        var N = RGBN[3];

        var a = 0;
        var I=N/R;
        for (int i = 0; i <= I; i++)
        {
            var J=(N-R*i)/G;
            for (int j = 0; j <= J; j++)
            {
                var m = N - i * R - j * G;
                if (m % B == 0) a++;
            }
        }

        WriteLine(a);
    }
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        
        while(a > 0 && c > 0) {
            c -= b;
            if(c <= 0) {
                System.out.println("Yes");
                break;
            }
            a -= d;
            if(a <= 0) {
                System.out.println("No");
                break;
            }
        }
    }
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (abs(a - b) <= d && abs(b - c) <= d || abs(a - c) <= d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}




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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int max_n = 1e5 + 5;
int n, m;
VI g[max_n];
VI gT[max_n];
int indeg[max_n];
int dp[max_n];

int main () {
	read2(n, m);
	FOR(i,0,m) {
		make2(a, b); a--; b--;
		g[a].pb(b);
		gT[b].pb(a);
		indeg[b]++;
	}
	VI kol;
	FOR(i,0,n) if (indeg[i]==0) {
		kol.pb(i);
	}
	int pos = 0;
	while (kol.size() != n) {
		int v = kol[pos]; pos++;
		FORE(i, g[v]) {
			indeg[*i]--;
			if (indeg[*i] == 0) kol.pb(*i);
		}
	}
	int ans = 0;
	FORD(i,n-1,0) {
		int v = kol[i];
		dp[v] = 0;
		FORE(j, g[v]) {
			dp[v] = max(dp[v], 1 + dp[*j]);
		}
		ans = max(ans, dp[v]);
	}
	printf("%d\n", ans);


}	





Measured memory_bytes: 12540
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    uint32_t array[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    uint32_t nn;
    std::cin >> nn;

    
    std::cout << array[nn - 1] << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





vector<int> zal(string s) {
    vector<int> a(s.size());
    int c = 0;
    for (int i = 1; i < s.size(); ++i) {
        if (i + a[i - c] < c + a[c]) {
            a[i] = a[i - c];
            
        } else {
            int j = max(0, c + a[c] - i);
            while (i + j < s.size() && s[j] == s[i + j]) ++j;
            a[i] = j;
            c = i;
        }
    }
    a[0] = (int)s.size();
    
    // rep(i, sz(a)) cout << a[i] << " "; cout << endl;
    return a;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int ans = 0;
    rep(i, sz(s)) {
        string t = s.substr(i, sz(s) - i);
        // cout << t << endl;
        auto v = zal(t);
        for (int j = i; j < sz(s); ++j) {
            if (i + v[j - i] > j) continue;
            chmax(ans, v[j - i]);
        }
        // cout << "ans " << ans << endl;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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


    int N, Y; cin >> N >> Y;

    int a = -1, b = -1, c = -1;
    bool found = false;
    REP(i,N+1) {
        FOR(j,0,N+1-i) {
            int k = N - i - j;
            if (k>=0 && 10000*i+5000*j+1000*k==Y) {
                a = i; b = j; c = k;
                found = true;
                break;
            }
        }
        if (found) break;
    }

    cout << a << " " << b << " " << c << endl;


    return 0;
}

Measured memory_bytes: 256
//Atcoder contest 142
//https://atcoder.jp/contests/abc142/tasks/abc142_a
#include<bits/stdc++.h>
using namespace std;
#define aakriti int
aakriti main()
{
        aakriti n , count{0};
        cin >> n ;
        for(int i = 0 ; i <= n ; i++ )
        {
                if(i % 2 != 0)
                {
                        count++;
                }
        }
        std::cout << float(count) / float(n) << endl ;

}

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

int main(){
  char c[4];
  int plus,minus;
  plus = minus = 0;
  for(int i=0;i<4;i++){
    cin >> c[i];
    if(c[i]== '+'){
      plus = plus + 1;
    }else{
      minus = minus + 1;
    }
    
  }
  cout << plus - minus << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

#define ll long long

int main(void){

    int k,a,b;
    cin>>k>>a>>b;

    ll bis = 1;
    ll m = 0;
    for(ll i = 0;i<k;i++){
        if(m>0){
            bis+=b;
            m--;
        }
        else if(bis>=a&&a<b-1&&k-i>1){
            bis-=a;
            m++;
        }
        else{
            bis++;
        }
    }
    cout<<bis<<endl;

    return 0;
}

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

namespace abc072
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = new int[N];
            int ans = 0;
            string[] str = Console.ReadLine().Split(' ');
            for(int k = 0; k < N; k++)
            {
                a[k] = int.Parse(str[k]);
            }
            Array.Sort(a);
            int i = 0;
            int j = 0;
            while (i < N)
            {
                int temp = 0;
                for (int k = 0; k + i < N; k++)
                {
                    if (i + k == N - 1)
                    {
                        j = i + k;
                    }
                    if (a[i + k] - a[i] == 1 && j == i)
                    {
                        j = i + k;
                        temp++;
                    }else if (a[i + k] - a[i] <= 2)
                    {
                        temp++;
                    }else
                    {
                        break;
                    }
                }
                ans = Math.Max(ans, temp);
                if (i == j)
                {
                    i++;
                    j=i;
                }else
                {
                    i = j;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18912
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int a, b, k;
    vector<int> v;
    cin >> a >> b >> k;
    for (int i=a; i<=b; i++) {
        if (i<a+k or i>b-k) {
            v.push_back(i);
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define int long long
using namespace std;
int N, M;
map<int, int>t;
map<int, int>p;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	int i;
	for (i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		t[a - i]++;
		p[a + i]++;
	}
	int ans = 0;
	for (auto j = t.begin(); j != t.end(); j++)
	{
		int r = (*j).first;
		ans += (*j).second * p[-r];
	}
	cout << ans;
}

Measured memory_bytes: 37864
N,M = gets.split.map(&:to_f)
prefs = Hash[(1..N).map{ |n| [n, []] }]
Cities = (0...M).map{
  p,y = gets.split.map(&:to_i)
  prefs[p] << y
  [p,y]
}

years = Hash[prefs.map{ |n,ys| 
  [n, Hash[ys.sort.map.with_index{ |y,k| [y,k+1] }]]
}]

Cities.each{ |p,y|
  puts sprintf("%06d%06d", p, years[p][y])
}

Measured memory_bytes: 83708
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a , b;
  	cin >> a >> b;
  	if(1 <= a && a <= 9 && b >= 1 && b <= 9)
      cout << a * b << endl;
  	else
      cout << -1 << endl;
 	return 0; 
}


Measured memory_bytes: 256
// BubbleSort
// 入力：
//	数列の要素数 n　と　数列
// 出力：
//  昇順でソート後の数列と試行回数

#include<iostream>

int main() {
	int i, j, n, v,a[100],c=0,tmp;

	std::cin >> n;

	// Input
	for (i = 0; i < n; i++) {
		std::cin >> a[i];
	}

	// Sorting
	for (j = 0; j < n-1; j++) {
		for (i = n-1; i > j; i--) {
			if (a[i] < a[i - 1]) {
				tmp = a[i];
				a[i] = a[i - 1];
				a[i - 1] = tmp;
				c++;
			}
		}
	}

	for (i = 0; i < n; i++) {
		std::cout << a[i];
		if (i != n - 1) {
			std::cout << " ";
		}
	}

	std::cout << std::endl;

	std::cout << c << std::endl;

	return 0;
	}




Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n;
	cin >> n;
	VL v(n);
	cin >> v;

	ll ans = 0;
	SORT(v);
	REP(i, *v.rbegin() + 1) {
		auto p = std::lower_bound(ALL(v), i) - v.begin();
		// dump(p, n - p - 1);
		if (p == n - p) {
			++ans;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024