akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    ll k,n;
    ll dp[200005];
    ll h[200005];
   // ll mini=1e9;
    ll recurse(ll pos){
      if(pos==n)
      return 0;
      ll i;
      if(dp[pos]!=-1)
      return dp[pos];
      ll mini=1e9;
      for(i=1;i<=k&&pos+i<=n;i++){
        mini=min(mini,recurse(pos+i)+abs(h[pos]-h[pos+i]));
      }
      return dp[pos]=mini;
    }
    int main()
    {
        fastread;
        ll i,j,l,m,t,q,r,c;
        for(i=1;i<=200005;i++)
        dp[i]=-1;
        cin>>n>>k;
        for(i=1;i<=n;i++)
        cin>>h[i];
        cout<<recurse(1);
        return 0;
    }

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int sum = 0;
  for(int i=0,x;i<m;cin>>x,sum+=x,i++);
  if(sum>n)cout<<-1<<endl;
  else cout<< n-sum<<endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

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

signed main(){

    int H, W, K; cin >> H >> W >> K;
    vector<string> A(H); readv(A);

    mat m(H, vec(W, -1));
    queue<Pii> que;
    REP(i, H) REP(j, W){
        if(A[i][j] == 'S'){
            que.push(Pii(i, j));
            m[i][j] = 0;
            break;
        }
        if(!que.empty()) break; 
    }

    while(!que.empty()){
        Pii p = que.front(); que.pop();
        if(m[p.first][p.second] == K) continue;
        REP(i, 4){
            int x = p.first + dx[i];
            int y = p.second + dy[i];
            if(0 <= x && x < H && 0 <= y && y < W && A[x][y] == '.' && m[x][y] == -1){
                m[x][y] = m[p.first][p.second] + 1;
                que.push(Pii(x, y));
            }
        }
    }
    //debug(m);

    int ans = INF;
    REP(i, H) REP(j, W){
        if(m[i][j] > -1){
            if(i == 0 || j == 0 || i == H - 1 || j == W - 1) ans = 1;
            else{
                ans = min(ans, 2 + (i - 1) / K);
                ans = min(ans, 2 + (H - 2 - i) / K);
                ans = min(ans, 2 + (j - 1) / K);
                ans = min(ans, 2 + (W - 2 - j) / K);
            }
        }
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 6144
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;
using pii = pair<int, int>;

int main() {
    int n, m;
    while (cin >> n >> m, n) {
        vector<pii> all(n), only(n);    // score, person
        for (int j = 0; j < n; j++) {
            all[j].second = j; only[j].second = j;
        }
        for (int i = 0; i < m; i++) {
            int s, k; cin >> s >> k;
            if (k == 1) {
                int c; cin >> c; c--;
                only[c].first += s;
                all[c].first += s;
                continue;
            }
            while (k--) {
                int c; cin >> c; c--;
                all[c].first += s;
            }
        }
        sort(all.begin(), all.end());
        sort(only.begin(), only.end());
        if (all[n - 1].second != only[0].second) {
            cout << all[n - 1].first - only[0].first + 1 << endl;
        } else {
            cout << max(
                all[n - 1].first - only[1].first,
                all[n - 2].first - only[0].first
            ) + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3196
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)

//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

using alpha = bitset<26>;

struct Segtree
{
    int n;
    vector<alpha> v;

    Segtree(int n)
    {
        int k = 1;
        while(k < n) k *= 2;
        this->n = k;
        v.resize(2*k-1, 0);
    }

    //i番目の値をxに変更する。
    void update(int i, int x)
    {
        i += n-1;
        v[i] = 0;
        v[i][x] = 1;
        while (i > 0)
        {
            i = (i-1)/2;
            v[i] = v[i*2+1] | v[i*2+2];
        }
    }

    //要求区間[a,b)に対するクエリを処理する
    //kは自分のいるインデックス
    //[l,r)は自分が管轄する区間
    alpha find(int a, int b, int k=0, int l=0, int r=-1)
    {
        if (r < 0) r = n;
        //交わらない
        if (r <= a || b <= l) return 0;
        //完全に被覆
        if (a <= l && r <= b) return v[k];
        //部分被覆
        alpha lv = find(a, b, 2*k+1, l, (l+r)/2);
        alpha rv = find(a, b, 2*k+2, (l+r)/2, r);
        return lv | rv;
    }
};

void solve()
{
    IN(n);
    Segtree st(n);
    string s;cin >> s;
    rep(i, n)
    {
        st.update(i, s[i] - 'a');
    }
    IN(q);
    rep(i, q)
    {
        IN(t);
        if (t == 1)
        {
            IN(l); char c; cin >> c;
            st.update(l-1, c - 'a');
        }
        else
        {
            IN(l, r);
            cout << st.find(l-1, r).count() << endl;
        }
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int areaA = a*b, areaB = c*d;
  if(areaA>areaB){
    cout << areaA << endl;
  }else{
    cout << areaB << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N,M,C;
    cin>>N>>M>>C;
    int B[20];
    int ans=0;
    for (int i=0;i<M;i++){
        cin>>B[i];
    }
    for(int j=0;j<N;j++){
        int tmp=C;
        int a;
        for(int i=0;i<M;i++){
            cin>>a;
            tmp+=a*B[i];
        }
        if (tmp>0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int n,k;
vin x(100010);
vin diff(100010);

int countryroad(){
    cin>>n>>k;
    rep(i,n)cin>>x[i];
    if(n<=k)return 0;
    int sum=x[n-1]-x[0];
    rep(i,n-1)diff[i]=x[i+1]-x[i];
    sort(all(diff),greater<int>());
    int sumdiff=0;
    rep(i,k-1)sumdiff+=diff[i];
    return sum-sumdiff;
}

int main(){
    int t;cin>>t;
    vin ans(t);
    rep(i,t)ans[i]=countryroad();
    rep(i,t)cout<<ans[i]<<endl;
}


Measured memory_bytes: 3436
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    while (a > 0) {
        c -= b;
        if (c <= 0) {
            printf("Yes");
            return 0;
        }
        a -= d;
        if (a <= 0) {
            printf("No");
            return 0;
        }
        
        
    }
        
    
}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

void yesno(bool ok, string yes="Yes", string no="No"){
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

// Paste snippets here!!

//

void solve(long long N) {
  bool ok = false;
  while(N>0){
    if(N%10==7) ok = true;
    N /= 10;
  }
  yesno(ok);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
long long n,d[100001];
string a;
 int main()
 {
cin>>a;
cout<<a[0]<<a.size()-2<<a[a.size()-1];
 }

Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int n ,h, w;
	while ( scanf("%d %d %d", &n, &h, &w) != EOF )
	{
		int ans = 0;
		for (int i = 0; i < n; ++i)
		{
			int num_a, num_b;
			scanf("%d %d", &num_a, &num_b);
			if ( num_a >= h and num_b >= w ) ans++ ;
		}
		
		printf("%d\n", ans);
	}
	return 0;
}








Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define reg register
using namespace std;
ll a,b;
int main()
{
    scanf("%lld%lld",&a,&b);
    if(a>0)puts("Positive");
    else if(b>=0)puts("Zero");
    else if((a&1)^(b&1))puts("Positive");
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


class cumulative_sum_2d():
    def __init__(self, a):
        self.H = len(a)
        self.W = len(a[0])
        self.s = [[0]*(self.W+1) for _ in range(self.H+1)]
        for y in range(self.H):
            for x in range(self.W):
                self.s[y+1][x+1] = self.s[y][x+1] + \
                    self.s[y+1][x] - self.s[y][x] + a[y][x]

    def calc_sum(self, yh, yt, xh, xt):
        return self.s[yt][xt] - self.s[yt][xh-1] - self.s[yh-1][xt] + self.s[yh-1][xh-1]


N, M, Q = map(int, input().split())
table = [[0] * (N) for _ in range(N)]
for i in range(M):
    L, R = map(int, input().split())
    table[L-1][R-1] += 1
Sum = cumulative_sum_2d(table)
for i in range(Q):
    p, q = map(int, input().split())
    print(Sum.calc_sum(p, q, p, q))


Measured memory_bytes: 15656
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int N = sc.nextInt();

		ArrayList<Integer> time = new ArrayList<>();
		int sum = 0;
		for(int i = 0; i < N; i++) {
			int t = sc.nextInt();
			time.add(t);
			sum += t;
		}

		int M = sc.nextInt();

		ArrayList<Integer> numList = new ArrayList<>();
		ArrayList<Integer> timeList = new ArrayList<>();

		for(int i = 0; i < M; i++) {
			int p = sc.nextInt();
			int x = sc.nextInt();
			numList.add(p);
			timeList.add(x);

			int answer = sum;
			answer = answer - (time.get(p-1) - x);
			System.out.println(answer);
		}

		sc.close();

	}

}


Measured memory_bytes: 21972
require 'prime'


def ncr(n, r)
  r = [r, n - r].min
  return 1 if r == 0
  return n if r == 1
  numerator = (n - r + 1..n).to_a
  denominator = (1..r).to_a
  (2..r).each{|p|
    pivot = denominator[p - 1]
    if pivot > 1
      offset = (n - r) % p
      (p - 1).step(r - 1, p){|k|
        numerator[k - offset] /= pivot
        denominator[k] /= pivot
      }
    end
  }
  result = 1
  (0..r - 1).each{|k|
    result *= numerator[k] if numerator[k] > 1
  }
  return result
end

n, m = gets.split
n = n.to_i
m = m.to_i

factors = m.prime_division
as = factors.map { |x| x[1] }


ans = 1
for a in as
    ans = ans * ncr(a + n - 1, n - 1) % 1000000007
end

puts ans

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

ll N;

int main() {
    cin >> N;

    if (N % 2 == 1) cout << 0 << endl;
    else {
        ll ans = 0;
        ll k = 10;
        while (N / k > 0) {
            ans += N/k;
            k *= 5;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define MAX_HEIGHT 1000
#define MOD 1000000007

using namespace std;

char grid[MAX_HEIGHT][MAX_HEIGHT];
unsigned long long dp[MAX_HEIGHT][MAX_HEIGHT];

void addWithMod(unsigned long long &a, unsigned long long b)
{
    a += b;
    if(a >= MOD) 
        a -= MOD;
}

int main()
{
    int h, w;
    string line;
    cin >> h >> w;
    for(int i = 0; i < h; i++)
    {
        cin >> line;
        for(int j = 0; j < line.size(); j++)
            grid[i][j] = line[j];
    }
    dp[0][0] = 1;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            for(int i2 : {i, i + 1})
            {
                int j2 = j;
                if(i2 == i)
                    j2 = j+1;
                if(i2 < h && j2 < w && grid[i2][j2] == '.')
                    addWithMod(dp[i2][j2], dp[i][j]);
            }
        }
    }

    cout << dp[h-1][w-1] % MOD;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;

#define MAX_N 1002020

typedef long long int64;

const int64 mod = 1e9 + 7;

inline int64 extgcd(int64 a, int64 b, int64 &x, int64 &y)
{
  int64 d = a;
  if(b != 0) d = extgcd(b, a % b, y, x), y -= (a / b) * x;
  else x = 1, y = 0;
  return d;
}

inline int64 modPow(int64 x, int64 n)
{
  if(n == 0) return 1;
  int64 ret = modPow(x, n/2);
  (ret *= ret) %= mod;
  if(n & 1) (ret *= x) %= mod;
  return ret;
}

inline int64 modInv(int64 a)
{
  return modPow(a, mod - 2);
}

inline int64 modFact(int n)
{
  int64 ret = 1;
  while(n > 1) (ret *= n--) %= mod;
  return ret;
}

inline int64 modComb(int64 n, int64 r)
{
  static int64 fact[MAX_N], invfact[MAX_N];
  if(fact[0] == 0) {
    fact[0] = invfact[0] = 1;
    for(int i = 1; i < MAX_N; i++) {
      fact[i] = fact[i-1] * i % mod;
      invfact[i] = modInv(fact[i]);
    }
  }
  if(r < 0 || n < r) return 0;
  return fact[n] * invfact[r] % mod * invfact[n-r] % mod;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int h, w, a, b;
  cin >> h >> w >> a >> b;
  int ans = 0;
  reps(i, b, w) {
    int x = modComb(i+h-a-1, i) % mod;
    int y = modComb(w-i-1+a-1, a-1) % mod;
    (ans += (x*y)%mod) %= mod;
  }
  cout << ans << endl;

  return 0;
}

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

int main()
{
    int N, K; //number of integers and integers to choose
    cin >> N >> K;
    if(N % 2 == 0)
    {
        int x = (N - 1) / 2 + 1;
        if(K > x)
        {
            cout << "NO";
        }
        else
        {
            cout << "YES";
        }
    }
    else
    {
        int x = N / 2 + 1;
        if(K > x)
        {
            cout << "NO";
        }
        else
        {
            cout << "YES";
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    ll d=y2-y1;
    ll q=x2-x1;
    ll x3=x2-d;
    ll x4=x1-d;
    ll y3=y2+q;
    ll y4=y1+q;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;


}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> v(m);
  REP(i, m){
    int a, b;
    cin >> a >> b;
    v[i] = make_pair(a - 1, b - 2);
  }
  sort(ALL(v));
  int ans = 0, now = -1;
  vector<pair<int, int>> w;
  REP(i, m){
    if(now < v[i].first){
      w.pb(v[i]);
    }
  }
  reverse(ALL(w));
  now = 100001;
  int x = w.size();
  REP(i, x){
    if(w[i].second < now){
      ans++;
      now = w[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2296
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>

using namespace std;

int main() {
	int i, j, cnt = 0;
	char ch;
	string S;

	cin >> S;

	ch = S[0];
	for (i = 1; i < S.length(); i++) {
		if (ch != S[i]) {
			cnt++;
			ch = S[i];
		}

	}

	cout << cnt << endl;



	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

int n, m;
vector<int> as;
bool ok;
void dfs(int cnt, int deg) {
    if (cnt == n) {
        if (deg % 360 == 0) ok = true;
        return;
    }
    dfs(cnt + 1, deg + as[cnt]);
    dfs(cnt + 1, deg - as[cnt]);
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
popcntsum = ((1<<64) - 1)
Fa = [0] + [popcntsum//((1<<(1<<(i-1)))+1) for i in range(1,7)]
Fb = [0] + [Fa[i]<<(1<<(i-1)) for i in range(1,7)]
fila1 = Fa[1]
filb1 = Fb[1]
fila2 = Fa[2]
filb2 = Fb[2]
fila3 = Fa[3]
filb3 = Fb[3]
fila4 = Fa[4]
filb4 = Fb[4]
fila5 = Fa[5]
filb5 = Fb[5]
fila6 = Fa[6]
filb6 = Fb[6]
def popcount(x):
    x = (x&fila1) + ((x&filb1)>>1)
    x = (x&fila2) + ((x&filb2)>>2)
    x = (x&fila3) + ((x&filb3)>>4)
    x = (x&fila4) + ((x&filb4)>>8)
    x = (x&fila5) + ((x&filb5)>>16)
    x = (x&fila6) + ((x&filb6)>>32)
    return x

def parorder(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[p] = -1
    stack = [p]
    order = []
    Enum = [None]*N
    visited = set([p])
    ast = stack.append
    apo = order.append
    while stack:
        vn = stack.pop()
        apo(vn)
        for vf, num in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            Enum[vf] = num
            ast(vf)
    return par, order, Enum

def getcld(p):
    res = [[] for _ in range(len(p))]
    for i, v in enumerate(p[1:], 1):
        res[v].append(i)
    return res


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

root = 0
P, L, Enum = parorder(Edge, root)
#C = getcld(P)

M = int(readline())
Q = [tuple(map(int, readline().split())) for _ in range(M)]

dp = [0]*(1<<M)
ans = pow(2, N-1)
for S in range(1, 1<<M):
    pc = popcount(S)
    if pc == 1:
        i = (-S&S).bit_length() - 1
        table = [False]*(N-1)
        u, v = Q[i]
        u -= 1
        v -= 1
        while u != root:
            table[Enum[u]] = not table[Enum[u]]
            u = P[u]
        while v != root:
            table[Enum[v]] = not table[Enum[v]]
            v = P[v]
        res = 0
        for t in table:
            res <<= 1
            res |= t
        dp[S] = res
    else:
        dp[S] = dp[S^(-S&S)]|dp[-S&S]
    
    ans += (-1)**(pc%2)*pow(2, N-1-popcount(dp[S]))
print(ans)


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

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    string s; cin >> s;
    ll n = s.length();

    ll ans = 0;
    ll w_idx = 0;
    for (ll i = 0; i < n; i++) {
        if (s[i] == 'W') {
            ans += i - w_idx;
            w_idx++;
        }
    }
    cout << ans << '\n';

    return 0;
}


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

int main(int argc, char const *argv[]) {
	int n; cin >> n;
	vector<int> d(n); rep(i, n) cin >> d[i];
	sort(d.begin(), d.end());

	printf("%d\n", d[n / 2] - d[n / 2 - 1]);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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




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




int a[5][5]={0};
map<int,pii>mp;
for(int i=1;i<=3;i++)for(int j=1;j<=3;j++){ cin>>a[i][j];mp[a[i][j]]={i,j};}
int n;
cin>>n;

for(int i=1;i<=n;i++)
{
  int x;
  cin>>x;
  if(mp.find(x)!=mp.end())
  {
    a[mp[x].first][mp[x].second]=-1;
  }
}

for(int i=1;i<=3;i++)
{
  for(int j=1;j<=3;j++)
  {
     if(a[i][j]==-1)
     {
       if(a[i-1][j]==-1&&a[i+1][j]==-1)
       {
         cout<<"Yes\n"; return 0;
       }
       if(a[i][j-1]==-1&&a[i][j+1]==-1)
       {
         cout<<"Yes\n"; return 0;
       }
       if(a[i-1][j-1]==-1&&a[i+1][j+1]==-1)
       {
         cout<<"Yes\n"; return 0;
       }
       if(a[i-1][j+1]==-1&&a[i+1][j-1]==-1)
       {
          cout<<"Yes\n"; return 0;
       }
     }
  }
}
cout<<"No\n";



  
}



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

int main() {
	int N;
	cin>>N;
	int arr[N];
	int sum=0;
	for (int i=0; i<N; i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	int d;
	cin>>d;
	for (int i=0; i<d; i++){
		int total = sum;
		int p, min;
		cin>>p>>min;
		total -= arr[p-1];
		total += min;
		cout << total << endl;
		
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=998244353;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=1e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e6+10;
	//------------------FIXED------------------
	char str[N];
	int son[N][2],id=1,dep[N];
	ll getSG(ll i){ ll ret=1;while(i%ret==0) ret*=2;return ret; }
	void main()
	{
		int n=qread();ll L=qread();
		while(n--)
		{
			scanf("%s",str+1);int m=strlen(str+1);
			for(int now=1,i=1;i<=m;i++)
			{
				int wt=str[i]-'0';
				if(!son[now][wt]) son[now][wt]=++id,dep[id]=dep[now]+1;
				now=son[now][wt];
			}
		}
		ll ans=0;fo(i,1,id) if((son[i][0]>0)^(son[i][1]>0)) ans^=getSG(L-dep[i]);puts(ans?"Alice":"Bob");
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 30592
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll n,m;cin>>n>>m;
    string s;cin>>s;
    vector<vector<ll> >G(n);
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i,n){
        sort(all(G[i]));
        REP(j,1,G[i].size()){
            if(G[i][j]==G[i][j-1]){
                G[i].erase(G[i].begin()+j);
            }
        }
    }
    vector<ll>a(n),b(n);
    queue<ll>q;
    vector<ll>used(n);
    rep(i,n){
        for(auto e:G[i]){
            if(s[e]=='A')a[i]++;
            if(s[e]=='B')b[i]++;
        }
        if(a[i]>0&&b[i]>0)continue;
        q.push(i);
        used[i]=1;
    }
    while(!q.empty()){
        ll k=q.front();
        q.pop();
        for(auto e:G[k]){
            if(used[e])continue;
            if(e==k)continue;
            if(s[k]=='A')a[e]--;
            if(s[k]=='B')b[e]--;
            if(a[e]>0&&b[e]>0)continue;
            used[e]=1;
            q.push(e);
        }
    }
    bool f=0;
    rep(i,n){
        if(used[i]==0)f=1;
    }
    cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 17028
use std::collections::HashSet;

/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).ok();
    let nm: Vec<_> = input
        .trim()
        .split(' ')
        .map(|s| s.parse().ok().unwrap())
        .collect();
    let n: usize = nm[0];
    let m: usize = nm[1];

    let mut input = String::new();
    std::io::stdin().read_line(&mut input).ok();
    let mut amap: HashSet<u64> = input
        .trim()
        .split(' ')
        .skip(1)
        .map(|s| s.parse().ok().unwrap())
        .collect();

    for _ in 1..n {
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).ok();
        let amap_new: HashSet<u64> = input
            .trim()
            .split(' ')
            .skip(1)
            .map(|s| s.parse().ok().unwrap())
            .collect();

        amap = amap.intersection(&amap_new).map(|&a| a).collect();
    }

    println!("{}", amap.len());
}


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

const int INF=1001001001;
vector<int> to[100005];

int main () {
	int n, m;
	cin >> n >> m;
	rep(i,m) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	queue<int> q;
	vector<int> dist(n,INF);
	vector<int> pre(n,-1);
	dist[0]=0;
	q.push(0);
	while(!q.empty()) {
		int v=q.front(); q.pop();
		for (int u:to[v]) {
			if (dist[u]!=INF) continue;
			dist[u]=dist[v]+1;
			pre[u]=v;
			q.push(u);
		}
	}

	cout << "Yes" << endl;
	rep(i,n) {
		if(i==0) continue;
		int ans=pre[i];
		++ans;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 10608
#include <stdio.h>

int main(void){

 int n , m , x , y;
  scanf("%d %d %d %d",&n,&m,&x,&y);
  
  int X[n+1] , Y[m+1];
  int max = -101 , min = 101;
  
  for(int i = 0;i < n;i ++){
    scanf("%d",&X[i]);
    if(max < X[i]){
      max = X[i];
  }
  }
  
  for(int i = 0;i < m;i ++){
    scanf("%d",&Y[i]); 
    if(min > Y[i]){
      min = Y[i];
  }
  }
  
  
  for(int i = 0;i <= y;i ++){
  if(max < i && i <= min){
    if(x < i && i <= y){
      printf("No War");
      return 0;
    }
  }
  }
  
  printf("War");
  
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = LLONG_MAX;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int x[N];
int arr[N];
int pre[N];
void solve(){
	int n;
	cin >> n;
	set<int> se;
	for(int i=1;i<=n;i++){
		int a;
		cin >> a;
		se.in(a);
	}
	if(se.size()%2 == 0) cout << se.size()-1<<endl;
	else cout<<se.size() << endl;
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 8208
#!/usr/bin/env python3
(n, k), *q = [[*map(int, i.split())] for i in open(0)]
bucket = [0] * (10**5 + 1)
for a, b in q:
    bucket[a] += b
for n, i in enumerate(bucket):
    k -= i
    if k <= 0:
        print(n)
        break


Measured memory_bytes: 29804
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		HashMap<String, Integer> map = new HashMap<String, Integer>();
		map.put("A", 0);
		map.put("B", 0);
		map.put("O", 0);
		map.put("AB", 0);
		
		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			String[] tmpArray = str.split(",");
			String type = tmpArray[1];
			map.put(type, map.get(type)+1);
			
		}
		
		System.out.println(map.get("A"));
		System.out.println(map.get("B"));
		System.out.println(map.get("AB"));
		System.out.println(map.get("O"));

	}

}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
#include <numeric>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i, n) for(int i = 1; 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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	string A, B; cin >> A >> B;
	vector<string> a(3), b(3);
	REP(i, 3) a[i] = A[i];
	REP(j, 3) b[j] = B[j];
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  string S;
  cin>>S;
  int ans=0;
  rep(i,4){
    if(S[i]=='+')ans+=1;
    else ans-=1;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main () {
    int N, answer = 1;
    cin >> N;
    vector <int> d (N);
    for(int i=0; i < N; i++){
        cin >> d .at(i);
        }
    
    for (int i=0; i < N; i++){
        for (int l=0; l < N-1; l++){
            if(d .at(l) > d .at(l+1)){

                int s=d.at(l);
                d.at(l) = d.at(l+1);
                d.at(l+1) = s;

            }
        }
    }

    for(int i = 0; i < N-1; i++){
        if(!(d.at(i) == d.at(i+1))){
            answer += 1;
        }
    }

    cout << answer << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <iomanip>
#include <math.h>
#include <algorithm>
#define oo 1000000007
#define maxN 200007
using namespace std;

int x[maxN], y[maxN];
pair <int, int> add[maxN], sub[maxN];
int ans = 0;

void findAns(int best_x, int best_y, int n) {
    for (int i = 1; i <= n; ++i) {
        ans = max(ans, (int)abs(best_x-x[i])+(int)abs(best_y-y[i]));
    }
}

int main() {

    int n;
    cin >> n;

    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> y[i];
        add[i] = make_pair(x[i]+y[i], i);
        sub[i] = make_pair(x[i]-y[i], i);
    }

    sort(add+1, add+n+1);
    sort(sub+1, sub+n+1);

    int best_x, best_y;
    best_x = x[add[1].second], best_y = y[add[1].second];
    findAns(best_x, best_y, n);
    best_x = x[add[n].second], best_y = y[add[n].second];
    findAns(best_x, best_y, n);
    best_x = x[sub[1].second], best_y = y[sub[1].second];
    findAns(best_x, best_y, n);
    best_x = x[sub[n].second], best_y = y[sub[n].second];
    findAns(best_x, best_y, n);


    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7916
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    bool maps[64][64];
    REP(i,64) REP(j,64) maps[i][j]=false;
    REP(i,64) maps[i][i]=true;
    bool sch[64][64];
    REP(i,64) REP(j,64) sch[i][j]=false;
    cin >> n;
    if(!n) break;
    REP(i,n){
      int schs;
      cin >> schs;
      REP(j,schs){
	int tmp;
	cin >> tmp;
	sch[i][tmp]=true;
      }
    }
    REP(day,31){
      REP(i,n){
	REP(j,n){
	  if(sch[i][day]&&sch[j][day])
	    REP(k,n){
	      maps[i][k]=maps[j][k]=maps[i][k]||maps[j][k];
	    }
	}
      }
      REP(i,n){
	bool tmp=true;
	REP(k,n){
	  if(!maps[i][k]) tmp=false;
	}
	if(tmp){
	  cout << day << endl;
	  main();
	  return 0;
	}
      }
    }
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 6676
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <utility>
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; ++i) {
    if (i > 0) cout << ' ';
    cout << v[i];
  }
  cout << '\n';
}

int main() {
  ll n;
  cin >> n;
  // a >= b
  ll sq = sqrt(n);
  ll cnt = 0;
  for (ll i = 1; i <= sq; ++i) {
    if (i * i < n) ++cnt;
    for (ll j = i + 1; j <= n; ++j) {
      if (i * j >= n) break;
      cnt += 2;
    }
  }
  cout << cnt << '\n';

  return 0;
}


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

int main()
{
  ll n;
  bool f=true;
  cin>>n;
  vector<ll>a(n);
  for(ll i=0;i<n;i++) cin>>a[i];
  for(ll i=0;i<n;i++)
  {
    if(a[i]%2==0 && !(a[i]%3==0 || a[i]%5==0))
    {
      f=false;
      break;
    }
  }
  if(f)
    cout<<"APPROVED";
  else
    cout<<"DENIED";
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

var a, b, c, d int

func main() {
	var s string
	fmt.Scan(&s)
	a, _ = strconv.Atoi(string(s[0]))
	b, _ = strconv.Atoi(string(s[1]))
	c, _ = strconv.Atoi(string(s[2]))
	d, _ = strconv.Atoi(string(s[3]))

	ans := dfs(0, 3)
	op1, op2, op3 := "-", "-", "-"
	if ans&4 == 0 {
		op1 = "+"
	}
	if ans&2 == 0 {
		op2 = "+"
	}
	if ans&1 == 0 {
		op3 = "+"
	}
	fmt.Printf("%d%s%d%s%d%s%d=7", a, op1, b, op2, c, op3, d)
}

func dfs(flag int, depth int) int {
	if depth == 0 {
		if calc(flag) == 7 {
			return flag
		}
		return -1
	}

	return max(dfs(flag, depth-1), dfs(flag|(1<<uint(depth-1)), depth-1))
}

func calc(flag int) int {
	ans := a
	ans += (1 - 2*(flag&4/4)) * b
	ans += (1 - 2*(flag&2/2)) * c
	ans += (1 - 2*(flag&1)) * d
	return ans
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


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

int eval(const string& s, int& k){
	if( s[k] == '0' || s[k] =='1' || s[k] == '2' ){
		int r = s[k] - '0';
		k++;
		return r;
	}else if( s[k] == '-' ){
		++k;
		int r = eval(s, k);
		r = 2 - r;
		return r;
	}else if( s[k] == '(' ){
		++k;
		int a = eval(s, k);
		char op = s[k++];
		int b = eval(s, k);
		++k;
		int r;
		if( op == '+' ){
			r = max(a, b);
		}else if( op == '*' ){
			r = (a * b + 1) / 2;
		}
		return r;
	}
}

int main(){
	string s;
	while( cin >> s ){
		if( s == "." ) break;
		
		int ans=0;
		for(char p='0' ; p <= '2' ; p++ ){
			for(char q='0' ; q <= '2' ; q++ ){
				for(char r='0' ; r <= '2' ; r++ ){
					string ex = s;
					for(int i=0 ; i < ex.size() ; i++ ){
						if( ex[i] == 'P' ) ex[i] = p; 
						if( ex[i] == 'Q' ) ex[i] = q;
						if( ex[i] == 'R' ) ex[i] = r;
					}
					int t=0;
					int res = eval(ex, t);
					if( res == 2 ) ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s1 = sc.nextLine().split(" ");
        int k = Integer.parseInt(sc.nextLine());

        int a = Integer.parseInt(s1[0]);
        int b = Integer.parseInt(s1[1]);
        int c = Integer.parseInt(s1[2]);


        int result=0;


        int max = Math.max(a, Math.max(b, c));
        double tmp = Math.pow((double)2, (double)k);
        result = max *(int)tmp  + a + b + c -max;

        System.out.println(result);
    }
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen ("myOutput.txt","w",stdout);
    int n; cin >> n;
    vector <int> arr;
    while (n--)
    {
        int x; cin >> x; arr.push_back(x);
    }
    sort(arr.begin(), arr.end());
    n = arr.size();
    int height = 0; int width = 0;
    for (int i=n-1; i>=1; i--)
    {
        if(height >0 and width >0) break;
        //cout << arr[i] << " ";
        if (arr[i] == arr[i-1])
        {
          if (height == 0) {height = arr[i]; i--;}
          else width = arr[i];
        }
    }
    cout << (long long)height* (long long) width <<endl;
}




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

int main(void){
    int n;
    cin >> n;
    vector<long long> a(n+10);
    vector<long long> wa(n+10, 0);
    for(int i=0;i<n;++i){
        cin >> a[i];
        wa[i+1] = wa[i] + a[i];
    }
    int mid = 0, left=0, right=2;
    long long sum = wa[n]-wa[0], lsum=0, rsum=0, tmpl=0, tmpr=0;
    long long ans = sum;
    for(mid=2;mid<n;++mid){
        lsum = wa[mid];
        rsum = sum - lsum;
        //cout << lsum << " " << rsum << " " << sum << endl;
        while(tmpl<lsum/2){
            if(left+1==mid) break;
            ++left;
            tmpl = wa[left];
        }
        if(abs(tmpl-lsum/2) > abs(wa[left-1]-lsum/2)){
            --left;
            tmpl = wa[left];
        }
        tmpr = wa[right]-wa[mid];
        while(tmpr<rsum/2){
            if(right+1==n) break;
            ++right;
            tmpr = wa[right]-wa[mid];
        }
        if(abs(tmpr-rsum/2) > abs((wa[right-1]-wa[mid])-rsum/2)){
            --right;
            tmpr = wa[right]-wa[mid];
        }
        //cout << tmpl << " " << lsum-tmpl << " " << tmpr << " " << rsum-tmpr << endl;
        long long tmpans = max(tmpl, max(lsum-tmpl, max(tmpr, rsum-tmpr))) - min(tmpl, min(lsum-tmpl, min(tmpr, rsum-tmpr)));
        if(ans > tmpans)ans = tmpans;
    }
    cout << ans << endl;
}

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

int main()
{
    int A, B;
    cin >> A >> B;

    int a = A + B;
    int b = A - B;
    int c = A * B;

    cout << max({a, b, c}) << endl;

    return 0;
}

Measured memory_bytes: 256