akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
	VI P(A), Q(B), R(C);
	REP(i, A)cin >> P[i];
	REP(i, B)cin >> Q[i];
	REP(i, C)cin >> R[i];

	rSORT(P);
	rSORT(Q);
	rSORT(R);

	int ans = 0;
	priority_queue<int, vector<int>, greater<int> > cho;
	REP(i, X) {
		ans += P[i];
		cho.push(P[i]);
	}
	REP(i, Y) {
		ans += Q[i];
		cho.push(Q[i]);
	}
	//cout << ans << endl;
	REP(i, min(C, X + Y)) {
		if (cho.top() > R[i])break;
		else {
			//cout << cho.top() << endl;
			ans -= cho.top();
			cho.pop();
			ans += R[i];
		}
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 4852
#include <stdio.h>

int main(void){
	int w, h, x, y, r;

	scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);

	if(x>=r && y>=r && x<=w-r && y<=h-r)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 584
N,M = map(int,input().split())
yi= [[] for i in range(N)]

for i in range(M):
    pp,yy = map(int,input().split())
    yi[pp-1].append((yy,i))

code = ['' for _ in range(M)]

for pp,d in enumerate(yi):
    d.sort()
    for x, (yy,i) in enumerate(d):
        code[i] = "%06d%06d"%(pp+1,x+1)
    
print(*code,sep='\n')

Measured memory_bytes: 37480
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  R n;
  string s[n];
  rep(i,n) R s[i];
  R m;
  string t[m];
  rep(i,m) R t[i];
  map<string,ll> ma[2];
  rep(i,n) ma[0][s[i]]++;
  rep(i,m) ma[1][t[i]]++;
  ll ans=0;
  tr(it,ma[0]) {
    ll x=it->S-ma[1][it->F];
    ans=max(ans,x);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
	int N, buf, answer;
	bool adjacent;
	answer = 0;
	adjacent = false;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> buf;
		if (buf == i) {
			if (!adjacent) answer++;
			adjacent = !adjacent;
		} else {
			adjacent = false;
		}
	}
	cout << answer << endl;
}

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

/******************** START OF CRAPS ********************/

#define fin             freopen("input/in.txt","r",stdin);
#define fout            freopen("input/out.txt","w",stdout);
#define ri(x)           scanf("%d", &x)
#define r2i(x,y)        scanf("%d %d", &x, &y)
#define rll(x)          scanf("%lld", &x)
#define r2ll(x,y)       scanf("%lld %lld", &x, &y)
#define imax            INT_MAX
#define imin            INT_MIN
#define pb              push_back
#define mp              make_pair
#define pi              acos(-1.0)
#define newl            "\n"
#define newlChar        '\n'
#define spChar          ' '
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define pCase(cs,ch)    printf("Case %d:%c", cs,ch)
#define iterAll(x)      x.begin(),x.end()
#define rIterAll(x)     x.rbegin(),x.rend()
#define fastreader      ios_base::sync_with_stdio(false); cin.tie(0)

typedef long long               ll;
typedef unsigned long long      ull;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<double>          vd;
typedef vector<string>          vs;
typedef vector<char>            vc;
typedef pair<int,int>           pii;
typedef map<int,int>            mapii;
typedef map<char,int>           mapci;
typedef map<string,int>         mapsi;

/******************** END OF CRAPS ********************/

int main()
{
    //fin; fout;

    int r;

    while(ri(r) != EOF)
    {
        r<1200?printf("ABC\n"):r<2800?printf("ARC\n"):printf("AGC\n");
    }

    return 0;
}


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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,k;
    cin >> n >> k;
    if(k <= (n+1)/2) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

char itoa(int x){
    char c='a'+x;
    return c;
}

//DFSによる全探索

int main()
{ 
    /*ここから*/

    int n;
    cin>>n;
    //深さnとする。
    int L=n;
    //探索深度。基本はnに等しい
    int M[n];
    //for(int i=0;i<n;i++){M[i]=2;}
    M[0]=1;M[1]=2;
    //各場所における深さ関数,全て2ならbit全探索
    vector<int> vec;
    vec.push_back(0);
    while(!vec.empty()){
        int S=vec.size();
        if(vec[S-1]>=M[S-1]){vec.pop_back();if(S>=2){vec[S-2]++;}continue;}
        if(S<L){
            vec.push_back(0);
            int cnt=0;
            for(int i=0;i<S;i++){if(vec[i]>cnt){cnt=vec[i];}}
            M[S]=cnt+2;
            continue;
        }
        //S==Lかつvec[i]<M[i]forall i
        /*ここに作業文を入れます。*/
        for(int i=0;i<S;i++){cout<<itoa(vec[i]);}
        cout<<endl;
        /*ここまでが作業文です。*/
        vec[S-1]++;
    }

    /*ここまで*/

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main () {
    int a, b, c, d;
    cin >> a >> b >> c;
    
    if (a > b){
        swap(a,b);
    }
    if (b > c){
        swap (b,c);
    }
    if (a > b){
        swap (a,b);
    }
    cout<< a<< " "<< b <<" "<< c <<endl;
}


Measured memory_bytes: 3104
//////////////////////////////////*STRIKER(Devesh Ranjan)*////////////////////////////////////////////////////////////////////

#include<bits/stdc++.h>

using namespace std;
using ull=unsigned long long;
using ll=long long int;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 10000007
#define mod1 1000003
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define fr1(i,a,b) for(ll i=a;i<=b;i++)

/*BINARY EXPONENTIATION*/

ll binpow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
        {
            res=res*a;
        }
        a=a*a;
        b>>=1;
    }
    return res;
}

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

void solve()
{
    //Start Here:
    ll n,w;
    cin>>n>>w;
    ll wt[n+1],val[n+1];
    fr(i,0,n)
    {
        cin>>wt[i]>>val[i];
    }
    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    fr1(i,0,n)
    {
        fr1(j,0,w)
        {
            if((i==0)||(j==0))
            {
                // cout<<"!";
                dp[i][j]=0;
            }
            else if(wt[i-1]<=j)
            {
                // cout<<"@";
                dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
            }
            else
            {
                // cout<<"#";
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w]<<endl;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main()
{
    fastio;
    solve();
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n; i64 a, b;
    std::cin >> n >> a >> b;
    std::vector<int> p(n + 1);
    for (int i = 1; i <= n; i++) {
        int in;
        std::cin >> in;
        p[in] = i * 2 - 1;
    }
    std::vector<std::vector<i64>> dp(n + 1, std::vector<i64>(2 * n + 2));
    std::vector<i64> v(2 * n + 2);
    for (int i = 1; i <= n; i++) {
        v[0] = dp[i - 1][0];
        for (int j = 0; j < 2 * n + 1; j++) {
            v[j + 1] = std::min(v[j], dp[i - 1][j + 1]);
        }
        for (int j = 0; j <= 2 * n + 1; j++) {
            dp[i][j] = v[j] + (p[i] < j ? a : p[i] == j ? 0 : b);
        }
    }
    std::cout << *std::min_element(dp[n].begin(), dp[n].end()) << std::endl;

    return 0;
}


Measured memory_bytes: 391296
#include<iostream>
#include<algorithm>
using namespace std;
int h[1501];
int w[1501];

int widths[2000000];
int heights[2000000];

int main(){
  while(true){
    int n,m;
    cin >> n >> m;
    if(n == 0 && m == 0)break;
    fill(widths, widths+2000000,0);
    fill(heights,heights+2000000,0);
    fill(w,w+1501,0);
    fill(w,w+1501,0);
    for(int i = 0,acc = 0;i < n;i++){
      cin >> h[i+1];
      h[i+1] += h[i];
    }
    for(int j = 0,acc = 0;j < m;j++){
      cin >> w[j+1];
      w[j+1] += w[j];
    }

    for(int i = 0;i < n+1;i++){
      for(int j = i+1;j < n+1;j++){
        //cout << h[j] << ',' << h[i] << endl;
        heights[h[j] - h[i]] ++;
      }
    }
    for(int i = 0;i < m+1;i++){
      for(int j = i+1;j < m+1;j++){
        //cout << w[j] << ',' << w[i] << endl;
        widths[w[j] - w[i]]++;
      }
    }
    int ans = 0;
    int maxsize = min(n,m) * 1000;
    for(int i = 0;i < maxsize;i++){
      ans += widths[i] * heights[i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 16796
#include<stdio.h>
int main(void)
{
	int i,x,y;
	for(i=1;i<=3000;i++){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;
		if(x<y){
			printf("%d %d\n",x,y);
		}
		else{
			printf("%d %d\n",y,x);
		}
	}
	
	return 0;
}



Measured memory_bytes: 2708
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let mut s: Vec<char> = read::<String>().chars().collect();
    let mut ans = Vec::new();

    for c in s {
      let new = convert(c, n);
      ans.push(new);
    }

    let ans: String = ans.into_iter().collect();
    println!("{}", ans);
}

fn convert(c: char, n: usize) -> char {
  let mut abc = (b'A'..b'Z').map(|c| c as char)
                    .collect::<Vec<_>>();
  abc.push('Z');
  let mut index = 0;
  for i in 0..abc.len() {
    if abc[i] == c {
      index = i;
    }
  }

  let new_index = (index + n) % 26;
  return abc[new_index]
}

Measured memory_bytes: 4352
while (a ,b = gets.split(' ').map(&:to_i)) != [0, 0]
    even_string = "#." * (b / 2) + "#" * (b % 2)
    odd_string = ".#" * (b / 2) + "." * (b % 2)
    a.times { |n|
        if n.odd?
            puts odd_string 
        else
            puts even_string
        end
    }
    puts
end


Measured memory_bytes: 6876
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int T = 0, X = 0, Y = 0;
  for(int i = 0; i < n; i++){
    int t, x, y;
    cin >> t >> x >> y;
    int z = abs(X-x) + abs(Y-y);
    if((z > (t-T)) || (z%2 != (t-T)%2)){
      cout << "No" << endl;
      return 0;
    }
    X = x;
    Y = y;
    T = t;
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    
    cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int h,m,s,n;
	scanf("%d",&n);
	h=n/3600;
	n=n%3600;
	m=n/60;
	s=n%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}
	
	
	
	


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2==0){
    	cout<<a-b;
    }
    else{
    	cout<<b-a;
    }
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		class DoubleInteger implements Comparable<DoubleInteger>{

			long a;
			long b;

			public int compareTo(DoubleInteger ab) {return ab.a<this.a ? 1 : ab.a==this.a ? 0 : -1;}

			public DoubleInteger(long a, long b) {
				this.a=a;
				this.b=b;
			}

		}

		List<DoubleInteger> AB = new ArrayList<>();

		for(int i=0;i<N;i++) {

			long a =sc.nextInt();
			long b =sc.nextInt();
			AB.add(new DoubleInteger(a,b));

		}

		Collections.sort(AB);

		long result = 0;
		int i = 0;
		for(;M>0;i++) {
			result += AB.get(i).a * AB.get(i).b;
			M -= AB.get(i).b;
		}
		i--;

		result -= Math.abs(M) * AB.get(i).a;
		System.out.println(result);

	}

}

Measured memory_bytes: 67828
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

vec<ll> memo(90);
ll f(ll n){
    if(memo[n] != 0){
        return memo[n];
    }
    memo[n] = f(n-1) + f(n-2);
    return memo[n];
}

void Main(){
    memo[0] = 2;
    memo[1] = 1;
    ll n;
    cin >> n;
    cout << f(n) << el;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
constexpr ll INF = 1ll<<30;
constexpr ll MOD = 1000000007;
//---------------------------------//

int main() {
	int N, C;
	cin >> N >> C;
	vector<int> a(N), b(N), c(N);
	REP(i, N) scanf("%d %d %d", &a[i], &b[i], &c[i]);
	
	vector<vector<vector<int>>> dp(2, vector<vector<int>>(101, vector<int>(10001, INF)));
	
	dp[0][0][0] = 0;
	REP(i, N) {
		int cur = i & 1;
		int nex = cur ^ 1;
		REP(j, C + 1) REP(k, 10001) dp[nex][j][k] = INF;
		
		REP(j, C + 1) REP(k, 10001) {
			if (dp[cur][j][k] == INF) continue;
			if (j + c[i] <= C) {
				REP(t, 2) {
					int ka = max(k + a[i], k - dp[cur][j][k] + b[i]), kb = min(k + a[i], k - dp[cur][j][k] + b[i]);
					chmin(dp[nex][j + c[i]][ka], ka - kb);
					swap(a[i], b[i]);
				}
			}
			chmin(dp[nex][j][k], dp[cur][j][k]);
		}
	}
	int ans = 0;
	REP(j, C + 1) REP(k, 10001) {
		if (dp[N & 1][j][k] == INF) continue;
		chmax(ans, k - dp[N & 1][j][k]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 14824
#include <stdio.h>

int main(void)
{
    int n, m, p;

    while (scanf("%d %d %d", &n, &m, &p), n || m || p){
        int x[128];
        int i;
        int sum = 0;

        for (i = 0; i < n; i++){
            scanf("%d", x + i);
            sum += x[i];
        }
        printf("%d\n", x[m - 1] ? sum * (100 - p) / x[m - 1] : 0);
    }

    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define re register
#define LL long long
#define SIZE 1005
using namespace std;
int n;
struct Node
{
	LL w,s,v;
}bl[SIZE];
LL dp[20005],ans=0;
inline bool cmp(Node x,Node y)
{
	return x.w+x.s<y.w+y.s;
}
int main()
{
	cin>>n;
	for(re int i=1;i<=n;++i)
		cin>>bl[i].w>>bl[i].s>>bl[i].v;
	sort(bl+1,bl+n+1,cmp);
	for(re int i=1;i<=n;++i)
		for(re int j=20001;j>=bl[i].w;--j)
			if(bl[i].s+bl[i].w>=j)
				dp[j]=max(dp[j],dp[j-bl[i].w]+bl[i].v),ans=max(ans,dp[j]);	
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 384
import java.io.*;
import java.util.*;


/**
 * AIZU ONLINE JUDGE
 * 3130
 *  2020/5/3
 */
public class Main {


    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        long N = sc.nextLong();
        int A = sc.nextInt();
        int B = sc.nextInt();

        N = N % 12;
        for(int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                A = A - B;
            }
            else {
                B = A + B;
            }
        }
        System.out.printf("%d %d\n", A, B);

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();

        instance.systemin.close();
    }


}




Measured memory_bytes: 26560
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;


int main() {
	int a, b, k;

	cin >> a >> b >> k;

	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			if (a % 2 == 1) a--;
			a /= 2;
			b += a;
		}
		else {
			if (b % 2 == 1) b--;
			b /= 2;
			a += b;
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
   
   int N,K,c=0;
   cin >> N >> K;
   
   for(int i=0;i<N;i++){
       int h_i;
       cin >> h_i;
       if(h_i >= K) c++;
   }
   cout << c <<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x; cin >> x;
  int ans = 1;
  for(int i=2; i<=x; i++) {
    int tmp = i*i;
    if(tmp > x) continue;
    while(tmp*i <= x) tmp *= i;
    chmax(ans, tmp);
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
typedef long long ll;

int N,M,S;
int inf = 1e5;
int dp[2][2010][3010] = {};
int main(){
    while(cin >> N >> M >> S && N>0){
        for(int i=0;i<=M;i++){
            for(int j=0;j<=S;j++){
                dp[0][i][j] = 0;
                dp[1][i][j] = 0;
            }
        }
        dp[0][0][0] = 1;
        for(int i=1;i<=N*N;i++){
            for(int j=1;j<=M;j++){
                for(int k=1;k<=S;k++){
                    if(k-(N*N-i+1)>=0) dp[i%2][j][k] = (dp[i%2][j-1][k-(N*N-i+1)]+dp[(i+1)%2][j-1][k-(N*N-i+1)])%inf;
                }
            }
            for(int j=0;j<=M;j++) for(int k=0;k<=S;k++) dp[(i+1)%2][j][k] = 0;
        }
        int ans = 0;
        for(int j=1;j<=M;j++){
            (ans += dp[(N*N)%2][j][S])%=inf;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 50100
#include<iostream>
using namespace std;
static const int N = 100;

int main(){
    int M[N][N]; //0オリジンの隣接行列
    int n, u, k, v;

    cin >> n;

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) M[i][j] = 0;
    }

    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--; //0オリジンへ変換
        for(int j=0; j<k; j++){
            cin >> v;
            v--; //0オリジンへ変換
            M[u][v] = 1; //uとvの間に辺を張る
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,m,c,ans;
void solve()
{
    cin>>n>>m;
    string s;cin>>s;
    ll ar[n];
    ar[0]=0;
    for(int i=1;i<n;i++)
    {
        ar[i]=ar[i-1];
        if(s[i]=='C'&&s[i-1]=='A')
            ar[i]++;
    }
    for(int i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
            cout<<ar[b-1]-ar[a-1]<<endl;
    }
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1872
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e20;

signed main(){
    int N;cin>>N;
    bool ok=false;
    REP(i,26){
        REP(j,15){
            if(i*4+j*7==N)ok=true;
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
def String2List(s):
    L = []
    flag = True
    l = len(s)
    for i in range(l):
        if s[i].isdigit() and flag:
            t = ""
            j = 0
            while s[i+j].isdigit():
                t += s[i+j]
                if i+j == l-1:
                    break
                j += 1
            L.append(t)
            flag = False
 
        elif not s[i].isdigit():
            L.append(s[i])
            flag = True
 
    return L
 

def RPN_list(L):
    S, L2 = [], []
    table = {"*": 1, "/": 1, "+": 0, "-": 0, "(": -1, ")": -1}
    for i in L:
        if i.isdigit():
            L2.append(i)
        elif i == "(":
            S.append(i)
        elif i == ")":
            while S[-1] != "(":
                L2.append(S.pop())
            S.pop()
        else:
            while len(S) != 0 and (table[S[-1]] >= table[i]):
                L2.append(S.pop())
            S.append(i)
 
    while len(S) != 0:
        L2.append(S.pop())
 
    return L2
 
 
def RPN_cal(L):
    St = []
 
    for i in L:
        if i == '+':
            St.append(int(St.pop()) + int(St.pop()))
        elif i == '-':
            St.append(-int(St.pop()) + int(St.pop()))
        elif i == '*':
            St.append(int(St.pop()) * int(St.pop()))
        elif i == '/':
            a = int(St.pop())
            b = float(St.pop())
            St.append(b/a)
        else:
            St.append(i)
 
    return St[0]
 
 
N = int(raw_input())
 
for i in range(N):
    s = raw_input()
    L = String2List(s[:-1])
    L = RPN_list(L)
    print int(RPN_cal(L))

Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

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

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

// N^P mod M（ただしM == -1の時はmodを取らない）
template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

/* RMQ：[0,n-1] について、区間ごとの最小値を管理する構造体
    update(i,x): i 番目の要素を x に更新。O(log(n))
    query(a,b): [a,b) での最小の要素を取得。O(log(n))
*/
template <typename T>
struct SegmentTree {
    const T INF = numeric_limits<T>::max();
    int n;         // 葉の数
    vector<T> dat; // 完全二分木の配列
    SegmentTree(int n_) : n(), dat(n_ * 4, INF) { // 葉の数は 2^x の形
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
    void update(int i, T x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  // parent
            dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }
    // the minimum element of [a,b)
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    T query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return INF;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

int main() {
    int N;
    cin >> N;
    ll x;
    cin >> x;
    vector<ll> vec(N);
    SegmentTree<ll> seg(2 * N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
        seg.update(i,vec.at(i));
        seg.update(i + N,vec.at(i));
    }
    ll cnt = INF;
    int min_id = -1;
    for(int i = 0;i < N;i++) {
        if(cnt > vec.at(i)) {
            cnt = vec.at(i);
            min_id = i;
        }
    }
    ll ret = INF;
    for(ll i = 0;i < N;i++) {
        ll count = cnt + x * i;
        for(int j = 0;j < N;j++) {
            if(j != min_id) {
                count += seg.query(j,j + i + 1);
            }
        }
        chmin(ret,count);
        min_id--;
        min_id %= N;
        if(min_id < 0) {
            min_id += N;
        }
    }
    cout << ret << endl;
}       

Measured memory_bytes: 3792
#include<cstdio>
typedef long long ll;
const int N=8024,D=203,M=998244353,G=3,K=14;
inline int Pow(int a,int m){int s=1;for(;m;m>>=1)m&1?s=(ll)s*a%M:0,a=(ll)a*a%M;return s;}
int n,m,f[N],fac[N],invf[N],ans,a[1<<K],b[1<<K],rev[1<<K];
inline int C(int n,int m){
	if(n<m||m<0)return 0;
	return(ll)fac[n]*invf[m]%M*invf[n-m]%M;
}
inline void Init(){
	for(int i=0;i<(1<<K);i++)rev[i]=rev[i>>1]>>1|(i&1)<<K-1;
}
inline void Ntt(int*a,int f){
	int tmp,s,w;
	for(int i=0;i<(1<<K);i++)if(i<rev[i])
	  tmp=a[i],a[i]=a[rev[i]],a[rev[i]]=tmp;
	for(int k=1;k<(1<<K);k<<=1){
	  w=Pow(G,f>0?M/2/k:M-1-M/2/k);
	  for(int i=0;i<(1<<K);i+=k+k){
		s=1;
		for(int j=0;j<k;j++,s=(ll)s*w%M){
		  tmp=(ll)s*a[i+k+j]%M;
		  (a[i+k+j]=a[i+j]-tmp)<0&&(a[i+k+j]+=M);
		  (a[i+j]+=tmp)>=M&&(a[i+j]-=M);
		}
	  }
	}
	if(f<0){
	  tmp=Pow(1<<K,M-2);
	  for(int i=0;i<(1<<K);i++)a[i]=(ll)a[i]*tmp%M;
	}
}
int main(){
	fac[0]=1;
	for(int i=1;i<N;i++)fac[i]=(ll)fac[i-1]*i%M;
	invf[N-1]=Pow(fac[N-1],M-2);
	for(int i=N-1;i;i--)invf[i-1]=(ll)invf[i]*i%M;
	scanf("%d%d",&n,&m);
	Init();
	for(int i=1;i<=n;i++)b[i]=invf[i+2];
	Ntt(b,1);
	f[0]=1;
	for(int j=1;j<=m;j++){
	  for(int i=0;i<(1<<K);i++)a[i]=0;
	  for(int i=0;i<=n;i++)a[i]=(ll)f[i]*invf[i]%M;
	  Ntt(a,1);
	  for(int i=0;i<(1<<K);i++)a[i]=(ll)a[i]*b[i]%M;
	  Ntt(a,-1);
	  for(int i=0;i<=n;i++)f[i]=((ll)f[i]*(C(i,2)+i+1)+(ll)fac[i+2]*a[i])%M;
	}
	for(int k=0;k<=n;k++)
	  ans=(ans+(ll)f[k]*C(n,k))%M;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2016
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const LL M=1e9+7;
LL S[200];

map<int,LL> mem[100*1000+1];
LL g(int i,int v){
	v%=S[i];
	if(mem[v].count(i)){
		return mem[v][i];
	}
	if(i==0){
		return mem[v][i]=v;
	}
	LL c=1;
	LL ret=0;
	for(int j=i-1;j>=0;j--){
		ret+=c*g(j,v)%M;
		ret%=M;
		c*=j;
		c%=M;
	}
	//cerr << i << ", " << v << ": " << ret<< endl;
	return mem[v][i]=ret;
}
int main() {
	LL N,X;
	cin >> N >> X;
	for(int i=0;i<N;i++){
		cin >> S[i];
	}
	sort(S,S+N);
	LL c=1;
	LL ret=0;
	for(int j=N-1;j>=0;j--){
		ret+=c*g(j,X)%M;
		ret%=M;
		c*=j;
		c%=M;
	}
	cout << ret << endl;

	return 0;
}




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

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

string s;
int n;

int main()
{
	cin >> n >> s;
	int len = s.size();
	for (int i = 0; i < len; i+=1)
	{
		if (s[i] + n >= 'A' && s[i] + n <= 'Z') printf("%c", s[i] + n);
		else printf("%c", s[i] + n - 26);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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 (b<a) { a=b; return 1; } return 0; }

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

int main(){
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s[n];
    rep(i,n){
        cin >> s[i];
    }
    map<string,int> mp;
    int max=0;
    set<string> t;
    rep(i,n){
        mp[s[i]]++;
        if(max<mp[s[i]]){
            max=mp[s[i]];
        }
    }
    rep(i,n){
        if(max==mp[s[i]]){
           t.insert(s[i]);
        }
    }
    auto itr=t.begin();
    for(auto itr=t.begin();itr!=t.end();itr++){
        cout << *itr << endl;
    }
    return 0;
}

Measured memory_bytes: 34816
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;
const int MAX = 510000;
const int MOD = 1000000007;
 
 
 
int main(){
ll N,A,B;
  cin>>N>>B>>A;

  if(A%2==B%2) cout<<abs(A-B)/2;
  else{
    
  ll ans=min(B+(A-B-1)/2,N-A+1+(A-B-1)/2);
  cout<<ans;
  
  }
  
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N, K; cin >> N >> K;
  vector<int> d(K);
  for (int i = 0; i < K; i++) cin >> d[i];
  
  int ans = N;
  while(true) {
    int n = ans;
    bool can = true;
    while (n != 0) {
      int k = n % 10;
      for (int i = 0; i < K; i++) {
        if (k == d[i]) can = false;
      }
      n /= 10;
    }
    if (can) break;
    else ans++;
  }
  
  cout << ans << endl;     
}

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

typedef long int				int32;
typedef unsigned long int		uint32;
typedef long long int			int64;
typedef unsigned long long int  uint64;
typedef pair<int, int>			PII;
typedef vector<int>				VI;
typedef vector<long long>		VLL;
typedef vector<string>			VS;
typedef vector<PII>				VII;
typedef vector<VI>				VVI;

#define MEM(a, b)				memset(a, (b), sizeof(a))
#define calctime				std::cout << setprecision(5) << fixed << "Time to completed program: " << (double)(clock() - start)/(CLOCKS_PER_SEC) << "s.\n";
#define FOR(i, j, k, in)		for (int i = (j); i < (k); i += (in))
#define FORW(i, j, k, in)		for (int i = (j); i <= (k); i += (in))
#define RFOR(i, j, k, in)		for (int i = (j); i >= (k); i -= (in))
#define RFORW(i, j, k, in)		for (int i = (j); i > (k); i -= (in))
#define aint64(cont)			cont.begin(), cont.end()
#define raint64(cont)			cont.end(), cont.begin()
#define sz(cont)				int((cont).size())
#define PB						push_back
#define MP						make_pair
#define EPS						1e-9
#define MOD						1000000007
#define PI						3.1415926535897932384626433832795
#define Ff						first
#define Ss						second
#define FastIO					ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define fileIO(name)			ifstream iFs(name".inp"); ofstream oFs(name".out");
#define fileio(name)			ifstream cin(name".inp"); ofstream cout(name".out");
#define endl					'\n'

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

int64 w_[100006] = {}, v[100006] = {};
int64 dp[105][100006] = {};

int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	fileio("input");		//Remember to change this
#endif

	int n, w; cin >> n >> w;

	FOR(i, 0, n, 1) cin >> w_[i] >> v[i]; 
	
	FORW(i, 0, n, 1) {
		FORW(w__, 0, w, 1){
			if (i == 0 || w__ == 0) continue;
			if (w_[i - 1] <= w__) {
				if (v[i - 1] + dp[i - 1][w__ - w_[i - 1]]) {
					dp[i][w__] = max(dp[i-1][w__], v[i - 1] + dp[i - 1][w__ - w_[i - 1]]);
				}
				else {
					dp[i][w__] = dp[i - 1][w__];
				}
			}
			else {
				dp[i][w__] = dp[i - 1][w__];
			}
		}
	}

	cout << dp[n][w] << endl;


	//calctime
	return 0;
}

Measured memory_bytes: 81716
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
string S; int a[26], n; vector<int>p;
int main() {
	cin >> n >> S; for (int i = 0; i < S.size(); i += 2) { a[S[i] - 'a']++; }
	for (int i = 0; i < 26; i++) { if (a[i] >= 1)p.push_back(a[i]); }
	sort(p.begin(), p.end()); int cnt = 0;
	while (p.size() >= 1) {
		int i = p.size() - 1;
		int F = 0;
		for (int j = i; j >= 0; j--) {
			if (p[j] != p[i]) { F = j + 1; break; }
		}
		if (p[i] != 1) { cnt += 2; if (i != F)cnt += 2; }
		for (int j = i; j >= F; j--) {
			p[j] -= min(9, p[j]); cnt += 2;
		}
		sort(p.begin(), p.end());
		while (p.size() >= 1 && p[p.size() - 1] == 0)p.pop_back();
	}
	cout << cnt - 1 << endl;
	return 0;
}

Measured memory_bytes: 3128
def traveling():
	N = int(input())
	t = [0] * (N + 1)
	x = [0] * (N + 1)
	y = [0] * (N + 1)
	for i in range(1, N + 1):
		t[i], x[i], y[i] = map(int, input().split())
	
	flag = True
	for i in range(1, N + 1):
		dt = t[i] - t[i - 1]
		dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])
		if dist > dt:
			flag = False
		if dist % 2 != dt % 2:
			flag = False
		
	
	if flag:
		print('Yes')
	else:
		print('No')

traveling()

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

#define       sf                 scanf
#define       pf                 printf
#define       pb                 push_back
#define       sz                 200005
#define       inf                0x3f3f3f3f
#define       MOD                1000000007
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);

using namespace std;

typedef       long long int      ll;

int main()
{
    // READ
    optimize

    ll n, x, d;

    cin >> n >> x >> d;

    n = abs(n);

    ll cn = n/d;

    if(cn>=x) cout << n-(x*d) << endl;
    else
    {
    	ll xx = n-(cn*d);
    	ll yy = abs(xx-d);

    	x-= cn+1ll;

    	if(x%2ll) cout << xx << endl;
    	else cout << yy << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;
const int INF = 1 << 30;
typedef pair<int, int> P1;
typedef pair<int, P1> P2;
int B[200000], X[200000], Y[200000];
struct Seg {
	int *Min, *Max;
	int size;
	Seg(int n,int *X) {
		size = 1;
		while (n > size) size *= 2;
		Min = (int*)malloc(sizeof(int)*(2 * size - 1));
		Max = (int*)malloc(sizeof(int)*(2 * size - 1));
		fill(Min, Min + (2 * size - 1), INF);
		fill(Max, Max + (2 * size - 1), 0);
		for (int i = 0; i < n; i++) {
			Min[i+(size-1)] = Max[i+(size-1)] = X[i];
		}
		for (int i = size - 2; i >= 0; i--) {
			Min[i] = min(Min[i * 2 + 1], Min[i * 2 + 2]);
			Max[i] = max(Max[i * 2 + 1], Max[i * 2 + 2]);
		}
	}
	int max_q(int a, int b, int k, int l, int r) {
		if (a <= l&&r <= b) {
			return Max[k];
		}
		else if (r <= a || b <= l) {
			return 0;
		}
		return max(max_q(a, b, k * 2 + 1, l, (l + r) / 2), max_q(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	int min_q(int a, int b, int k, int l, int r) {
		if (a <= l&&r <= b) {
			return Min[k];
		}
		else if (r <= a || b <= l) {
			return INF;
		}
		return min(min_q(a, b, k * 2 + 1, l, (l + r) / 2), min_q(a, b, k * 2 + 2, (l + r) / 2, r));
	}
};
int main() {
	int N, d;
	scanf("%d %d", &N, &d);
	vector<P2> star;
	for (int i = 0; i < N; i++) {
		int x, y, b;
		scanf("%d %d %d", &x, &y, &b);
		star.push_back(P2(b, P1(x, y)));
	}
	sort(star.begin(), star.end());
	for (int i = 0; i < N; i++) {
		B[i] = star[i].first;
		X[i] = star[i].second.first;
		Y[i] = star[i].second.second;
	}
	Seg segX(N, X), segY(N, Y);
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		int pos = upper_bound(B, B + N, B[i] + d) - B;
		int minX = segX.min_q(i, pos, 0, 0, segX.size);
		int maxX = segX.max_q(i, pos, 0, 0, segX.size);
		int minY = segY.min_q(i, pos, 0, 0, segY.size);
		int maxY = segY.max_q(i, pos, 0, 0, segY.size);
		ans = max(ans, (long long)(maxX - minX)*(maxY - minY));
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 14732
#include<bits/stdc++.h>		
using namespace std;
typedef long long ll;
#define ff first
#define ss second
#define forl(n) for(int i=0;i<n;i++)
#define forp(i,n) for(int i=0;i<n;i++)
#define fort(i,m,n) for(int i=m;i<n;i++)
#define fora(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define begud(k) cout<<"\t-->"<<#k<<" = "<<k<<"\n";
#define endl "\n";
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll res = power(a,b/2);
	if(b%2==0)
		return res*res;
	return a*res*res;
}
// bool cust(const pair<int,int> &a,const pair<int,int> &b)                
// {
//     return (a.first > b.first); 
// } 

//const int MX = 100005;
#define inf 10000000000
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	int n;
 	cin>>n;
 	int a[n][3];
 	fort(i,0,n)
 	{
 		fort(j,0,3)
 		{
 			cin>>a[i][j];
 		}
 	}
 	ll dp[n][3] = {};
 	fort(i,0,3)
 	{
 		dp[0][i] = a[0][i];
 	}
 	fort(i,1,n)
 	{
		fort(j,0,3)
		{
			dp[i][j] = a[i][j] + max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
		}
 	}
 	ll p = 0;
 	fort(i,0,3)
 	{
 		p = max(p,dp[n-1][i]);
 	}
 	cout<<p<<endl;
    //cout<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
void bs(int n,string Q[]){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(Q[j][1]<Q[j-1][1]) swap(Q[j],Q[j-1]);
        }
    }
}
void ss(int n,string Q[]){
    for(int i=0;i<n;i++){
        int mini = i;
        for(int j=i+1;j<n;j++){
            if(Q[mini][1]>Q[j][1]) mini = j;
        }
        swap(Q[i],Q[mini]);
    }
}
void pp(string A[],int n){
    for(int i=0;i<n;i++){
        if(i==0) cout<<A[i];
        else cout<<' '<<A[i];
    }
    cout<<endl;
}
int main()
{
    int n;
    cin>>n;
    string A[n],B[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
        B[i] = A[i];
    }
    bs(n,A);
    ss(n,B);
    bool is_stable = 1;
    for(int i=0;i<n;i++){
        if(A[i]!=B[i]){
            is_stable = 0;
            break;
        }
    }
    pp(A,n);
    cout<<"Stable\n";
    pp(B,n);
    cout<<(is_stable ? "Stable":"Not stable")<<endl;
    return 0;
}



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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    unordered_map<int, int> m;
    rep(i, N){
        int a; cin >> a;
        m[a]++;
    }
    int cnt=0, res=0;
    for(auto a: m){
        if(a.second%2 == 0) cnt++;
        res++;
    }
    if(cnt%2) res--;

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 8484
#include<iostream>

int main(){
  int N;
  int T;

  std::cin >> N >> T;

  int feasible_min = 1000;

  bool is_feasible = false;

  for(int i=0; i < N; i++){
    int c, t;
    std::cin >> c >> t;

    if(t <= T && c <= feasible_min){
      is_feasible = true;
      feasible_min = c;
    }
  }

  if(is_feasible){
    std::cout << feasible_min << std::endl;
  } else{
    std::cout << "TLE" << std::endl;
  }



  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i+1, n):
        if l[i] == l[j]:
            continue
        for k in range(j+1, n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            a = l[i]
            b = l[j]
            c = l[k]
            if a+b > c and b+c > a and c+a > b:
                ans += 1

print(ans)

Measured memory_bytes: 9216
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = new int[N];
        for(int i = 0; i < N; i++)
        {
            A[i] = int.Parse(Console.ReadLine());
        }
        int MaxA = A.Max();
        int count = 0;
        int secondMax = 0;
        for(int i = 0; i < N; i++)
        {
            if(A[i] == MaxA)
            {
                count += 1;
            }
            if(A[i] < MaxA && secondMax < A[i])
            {
                secondMax = A[i];
            }
        }
        for (int i = 0; i < N; i++)
        {
            if(A[i] == MaxA && count > 1)
            {
                Console.WriteLine(MaxA);
            }
            else if(A[i] == MaxA && count <= 1)
            {
                Console.WriteLine(secondMax);
            }
            else
            {
                Console.WriteLine(MaxA);
            }
        }
    }
}


Measured memory_bytes: 17236
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1e5 + 7;
int x[MAXN], y[MAXN], c[MAXN];
int f[MAXN], cnt0, cnt1, used;
int find(int x) {return x == f[x] ? f[x] : f[x] = find(f[x]);}
void unite(int x, int y)
{
    x = find(x), y = find(y);
    if (x != y) f[x] = y, cnt0--, used++;
}
int main()
{
    int n, q; ll m; scanf("%d%lld%d", &n, &m, &q);
    cnt0 = n; used = 0; cnt1 = 0;
    for (int i = 1; i <= n; i++) f[i] = i;
    for (int i = 1; i <= q; i++)
    {
        scanf("%d%d%d", &x[i], &y[i], &c[i]);
        x[i]++; y[i]++;
        if (!c[i]) unite(x[i], y[i]);
        else 
        {
            cnt1++;
            if (m == n - 1) {puts("No"); return 0;}
        }
    }
    m -= used;
    if (!cnt1)
    {
        (m >= cnt0 - 1 && m <= (ll)cnt0 * (cnt0 - 1) / 2) ? puts("Yes") : puts("No");
        return 0;
    }
    else 
    {
        if (cnt0 == 2) {puts("No"); return 0;}
        for (int i = 1; i <= q; i++) if (c[i])
            if (find(x[i]) == find(y[i])) {puts("No"); return 0;}
        (m >= cnt0 && m <= (ll)cnt0 * (cnt0 - 1) / 2) ? puts("Yes") : puts("No");
    }
    return 0;
}

Measured memory_bytes: 1792