akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  queue<int> que;
  ll ans=0;
  for(int i=N-1;i>=0;i--){
    if(i!=N-1){
      ans+=que.front();
      que.pop();
      que.push(A[i]);
    }
    que.push(A[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4776
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long inv(long long now) {
	long long ans = 1;
	long long b = MAX_MOD - 2;
	while (b != 0) {
		if (b % 2) {
			ans *= now;
			ans %= MAX_MOD;
		}
		b /= 2;
		now *= now;
		now %= MAX_MOD;
	}
	return ans;
}
long long jun[30000000];
long long gyaku[30000000];
long long bobo[30000000];
long long comb(long long a, long long b) {
	long long ans = jun[a];
	ans *= gyaku[b];
	ans %= MAX_MOD;
	ans *= gyaku[a - b];
	ans %= MAX_MOD;
	return ans;
}
int main() {
	jun[0] = 1;
	gyaku[0] = 1;
	bobo[0] = 1;
	for (long long i = 1; i < 30000000; ++i) {
		jun[i] = jun[i - 1] * i;
		if (i == 1) {
			bobo[i] = 1;
		}
		else {
			bobo[i] = MAX_MOD - bobo[MAX_MOD % i] * (MAX_MOD / i) % MAX_MOD;
			bobo[i] %= MAX_MOD;
		}
		gyaku[i] = gyaku[i - 1] * bobo[i];
		jun[i] %= MAX_MOD;
		gyaku[i] %= MAX_MOD;
	}
	long long h, w, k;
	cin >> h >> w >> k;
	long long ans = 0;
	for (long long i = 1; i <= k; ++i) {
		long long geko = (i + 1) * comb(h + w, h);
		geko %= MAX_MOD;
		geko += (((i * (i - 1LL)) % MAX_MOD) * comb(h + w - 2, h - 1)) % MAX_MOD;
		geko %= MAX_MOD;
		ans += geko;
		ans %= MAX_MOD;
	}
	ans *= jun[h];
	ans %= MAX_MOD;
	ans *= jun[w];
	ans %= MAX_MOD;
	ans *= gyaku[h + w - k];
	ans %= MAX_MOD;
	cout << ans << endl;
}

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



int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  cout << c << " " << a << " " << b << endl;;
  return 0;
}

Measured memory_bytes: 3620
#!/usr/bin/env python3
import sys
import copy
sys.setrecursionlimit(10**8)
INF = float("inf")

MOD = 998244353  # type: int


def array(*args, initial=0):
    pre = "["*len(args)
    post = ""
    for a in args[::-1]:
        post += " for _ in range("+str(a)+")]"
    S = pre + str(initial) + post
    return eval(S)


def solve(N: int, S: int, A: "List[int]"):
    dp = array(S+1, 3, initial=0)
    dp_past = array(S+1, 3, initial=0)
    dp[0][0] = 1
    for i in range(N):
        dp_past, dp = dp, dp_past
        # t=0軸
        for s in range(S+1):
            dp[s][:] = dp_past[s]
            # A[i]を使う
            if s == A[i]:
                dp[s][1] += i+1
                dp[s][1] %= MOD
            if s-A[i] >= 0:
                dp[s][0] += dp_past[s-A[i]][0]
                dp[s][0] %= MOD
                dp[s][1] += dp_past[s-A[i]][1]
                dp[s][1] %= MOD
                dp[s][2] += (dp[s][1]-dp_past[s][1]) * (N-i)
                dp[s][2] %= MOD

    print(dp[S][2])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, S, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42608
import copy

n = int(input())
a = [int(input()) for i in range(n)]
b = copy.deepcopy(a)
b.sort(reverse=True)
c = b[0]
d = b[1]

for i in range(n):
    if a[i] == c:
        print(d)
    else:
        print(c)

Measured memory_bytes: 97004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e+9;
 
int main()
{
	int a, b = 0;
	cin >> a >> b;
 
	double ans = 0;

    if (a > 12)
    {
        ans = b;
    }
    else if (a >= 6 && a <= 12)
    {
        ans = b / 2;
    }
    else
    {
        ans = 0;
    }
    

	cout << ans << "\n";
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<ll> p(n), q(n), r(n);
  REP(i, n) cin >> p[i];
  REP(i, n) cin >> q[i];
  REP(i, n) r[i] = i + 1;

  ll cnt = 1;
  ll a, b;
  do {
    bool p_ok = true;
    REP(i, n) {
      if (p[i] != r[i]) p_ok = false;
    }
    if (p_ok) a = cnt;

    bool q_ok = true;
    REP(i, n) {
      if (q[i] != r[i]) q_ok = false;
    }
    if (q_ok) b = cnt;

    ++cnt;

  } while (next_permutation(ALL(r)));

  cout << abs(a - b) << endl;
  return 0;
}

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

int a, b;

void init() {
	cin >> a >> b;
	printf("%d", max(a+b, max(a-b, a*b)));
	return ;
}

void solve() {
	return ;
}

int main() {
	init();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

// 素因数分解
// 12 -> [(2,2), (3,1)] (2^2*3^1)

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main () {
  ll a, b;
  cin >> a >> b;
  auto fa = factorize(a);
  auto fb = factorize(b);
  ll cnt = 0;
  for (auto pa : fa) {
    for (auto pb : fb) {
      if (pa.fi == pb.fi) cnt++; 
    }
  }
  ll ans = cnt+1;

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

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    double x[23],y[23],d[5],ans,s;
    int i=0;
    while(scanf("%lf,%lf",&x[i],&y[i])!=EOF){
        if(i==1){
           d[2]=sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1]));
        }else if(i>1){
           d[0]=d[2];
           d[1]=sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1]));
           d[2]=sqrt((x[i]-x[0])*(x[i]-x[0])+(y[i]-y[0])*(y[i]-y[0]));
           s=(d[0]+d[1]+d[2])/2;
           ans+=sqrt(s*(s-d[0])*(s-d[1])*(s-d[2]));
        }
        i++;
    }
    printf("%lf\n",ans);
    return 0;
}


Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
int takHealth, takStrength, aokiHealth, aokiStrength;
int main() {
	cin >> takHealth >> takStrength >> aokiHealth >> aokiStrength;
	int i = 1;
	while(takHealth > 0 && aokiHealth > 0) {
		if(i & 1)	aokiHealth -= takStrength;
		else	takHealth -= aokiStrength;
		i++;
	}
	puts((takHealth <= 0) ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc118/tasks/abc118_c
 
// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
 
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
 
 
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;
 
int inputValue(){
  int a;
  std::cin >> a;
  return a;
}
 
void inputArray(int *p, int a){
    rep(i, a){
        std::cin >> p[i];
        // scanf("%d",p+i);
    }
}
 
void inputVector(std::vector<int> *p, int a){
  rep(i, a){
    int input;
    // std::cin >> input;
    scanf("%d",&input);
    p->push_back(input);
  }
}
 
template <typename T>
void output(T a, int precision){
  if (precision > 0){
    std::cout << std::setprecision(precision) << a << "\n";
  }else{
    std::cout << a << "\n";
  }
}
 
using namespace std;
 
int gcd(int a,int b){
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
 
 
int main(int argc ,char **argv){
 
  int N = inputValue();
  vector <int> v;
  inputVector(&v, N);
 
  // cout << gcd(5,13) << endl;
  int d = 0;
  EACH(k, v) {
    d = gcd(d, *k);
  }
  // cout << d << endl;
  printf("%d\n", d);
 
	return 0;
}



Measured memory_bytes: 892
def main():
    x,y=list(map(int,input().split(" ")))
    ans=0
    if x==1 and y==1:
        print(300000+300000+400000)
    else:
        if x==1:
            ans=300000
        elif x==2:
            ans=200000
        elif x==3:
            ans=100000
        if y==1:
            ans+=300000
        elif y==2:
            ans+=200000
        elif y==3:
            ans+=100000
        print(ans)

if __name__=="__main__":
    main()

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

int main() {
	int n;
	scanf("%d", &n);

	vector<double> dp(n + 1);

	dp[0] = 1;

	for (int coin = 0; coin < n; ++coin) {
		double p_heads;
		scanf("%lf", &p_heads);
		for (int i = coin + 1; i >= 0; --i) {
			dp[i] = (i == 0 ? 0 : dp[i - 1] * p_heads) + dp[i] * (1 - p_heads);
		}
	}

	double answer = 0;
	for (int heads = 0; heads <= n; ++heads) {
		int tails = n - heads;
		if (heads > tails) {
			answer += dp[heads];
		}
	}
	printf("%.10lf\n", answer);
}

Measured memory_bytes: 3776
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;
#define INF 0x3f3f3f
typedef long long LL;

LL gcd(LL x, LL y){
    LL tmp;
    do{
        tmp = y % x;
        y = x;
        x = tmp;
    }while(tmp != 0);
    return y;
}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define pp pair<int,int>
#define ppn pair<pp,int>
#define F first
#define S second
#define N 205
#define mod 1000000007
#define pi 3.14159265358979323846

using namespace std;



int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);



   int n, x, y, nas = 0, c = 0;
   cin>>n;
   for(int i=0; i<n; i++){
    cin>>x>>y;
    if(x==y)c++;
    else{
        nas = max(nas,c);
        c = 0;
    }
   }
   nas = max(nas,c);
   if(nas>=3)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
char s[N];
int a[N],c,n,qaq;
void add(){
	qaq-=a[1];a[1]++;qaq+=a[1];
	rep(i,1,n)if(a[i]>=10){
		qaq-=a[i+1]+a[i];	
		a[i+1]++,a[i]-=10;
		qaq+=a[i+1]+a[i];
	}else break;
	if(a[n+1])n++;
}
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	rep(i,1,n)a[i]=s[n-i+1]-'0';
	int d=0;
	rep(i,1,n)a[i]*=9;
	rep(i,1,n)a[i+1]+=a[i]/10,a[i]%=10;
	if(a[n+1])n++;
	qaq=0;
	rep(i,1,n)qaq+=a[i];
	rep(k,1,1e9){
		add();
		if(qaq<=k)return printf("%d",(k+8)/9),0;
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<int64_t> x(N),y(N);
  for(int i=0;i<N;i++){
    cin >> x.at(i) >> y.at(i);
  }
  map<pair<int64_t,int64_t>,int> m;
  int ma=0;
  pair<int64_t,int64_t> temp;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j){
        continue;
      }
      temp=make_pair(x.at(j)-x.at(i),y.at(j)-y.at(i));
      if(m.count(temp)){
        m.at(temp)++;
      }else{
        m[temp]=1;
      }
      ma=max(ma,m.at(temp));
    }
  }
  cout << N-ma << endl;
  return 0;
}


Measured memory_bytes: 3684
def counter(rest, n, acc, to):
  if rest == 0:return acc == to
  if n == 10:return 0 
  return counter(rest - 1, n + 1, acc + n , to) + counter(rest, n + 1, acc, to)
 
while True:
  n, s = map(int, input().split())
  if not n:
    break
  print(counter(n, 0, 0, s))


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


int main()
{
	int N;
	long long power=1;
	cin	>> N;
	for(int i=1;i<N+1;++i){
		power = ((power%1000000007) * (i % 1000000007)) % 1000000007;
	}
	
	cout << power << endl;
	return 0;

}



Measured memory_bytes: 256
import sys
from collections import deque
s=sys.stdin.readlines()
q=int(s[0].split()[1])
f=lambda x,y:(x,int(y))
d=deque(f(*e.split())for e in s[1:])
t=0
while d:
 k,v=d.popleft()
 if v>q:
  v-=q
  t+=q
  d.append([k,v])
 else:
  t+=v
  print(k,t)


Measured memory_bytes: 16300
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n,x;
  cin>>n>>x;

  vector<int> v;

  REP(i,n){
    int t;
    cin>>t;
    v.pb(abs(x-t));
  }

  VSORT(v);

  int ans,miniX;
  ans = 0;
  miniX = v[0];

  for(int i=1;i<=(int)sqrt(miniX);i++){
    if(miniX%i==0){
      int sho = (int)miniX/i;
      REP(j,n){
        //全部割り切れたらいいよね
        if(v[j]%i!=0){
          break;
        }
        if(j==n-1){
          ans = max(ans,i);
        }
      }
      REP(j,n){
        //shoでもやろうね
        if(v[j]%sho!=0){
          break;
        }
        if(j==n-1){
          ans = max(ans,sho);
        }
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}

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

using namespace std;

using ll = long long;

int main()
{

	int N;
	int K;
	cin>>N>>K;
	vector<ll> H(N);
	for (auto &x : H) {
		cin>>x;
	}

	sort(H.begin(), H.end(), greater<ll>());

	int i = 0;
	for (i = 0;i < K && i < H.size();++i);

	ll ans = accumulate(H.begin() + i, H.end(), (ll)0);
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1792
package main

import(
  "fmt"
)

func main() {
  wether_slice := []string{"Sunny", "Cloudy", "Rainy"}
  var s string
  fmt.Scan(&s)
  
  for i, w := range wether_slice {
    if w == s {
      if i != len(wether_slice) - 1 {
        fmt.Println(wether_slice[i+1])
      } else {
        fmt.Println(wether_slice[0])
      }
    }
  }
}

Measured memory_bytes: 512
N = int(input())
t = [0]*(N+1)
x = [0]*(N+1)
y = [0]*(N+1)
dt = [0]*N
dist = [0]*N
for i in range(1,N+1):
    t[i], x[i], y[i] = map(int, input().rstrip().split())

for j in range(1,N+1):
    dt[j-1] = t[j] - t[j-1]
    dist[j-1] = abs(x[j] - x[j-1]) + abs(y[j] - y[j-1])

Flag = "OK"
for k in range(N):
    if dt[k] < dist[k]:
        Flag = "NG"
    else:
        if (dt[k]-dist[k]) % 2 != 0:
            Flag = "NG"

if Flag == "OK":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14848
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 998244353
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int main()
{
    char c;
    int i=0;
    for(;;)
    {
        scanf("%c",&c);
        if(!('0'<=c&&c<='9')) break;
        i=i+(c-'0');
    }
    i=i%9;
    if(i)
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }
    return 0;
}


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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define ll long long 
#define endl '\n'
#define inf INT_MAX

int main()
{
	int t, arr[1005];
	int flag = 0;
	cin >>t;
    for(int i = 1; i  <= t; i++)
    {
		cin >> arr[i];
		if(arr[i]%2 == 0)
		{
			if(arr[i]%3 == 0 || arr[i]%5 == 0) continue;
			else flag = 1;
		}
	}
	if(flag == 0) cout << "APPROVED\n";
	else cout<< "DENIED\n";
	return 0;
	
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve() {
  int n;cin>>n;
  ll arr[n];
  fo(i,n) cin>>arr[i];
  sort(arr,arr+n);
  ll res=0;
  fo(i,n)
  { Fo(j,i+1,n)
    {   Fo(k,j+1,n)
        {   set<ll>vals;
            vals.insert(arr[i]);
            vals.insert(arr[j]);
            vals.insert(arr[k]);
            if(arr[i]+arr[j]>arr[k]&&vals.size()==3)
            res++;
        }
    }
  }
  cout<<res<<"\n";
}
            

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

int main()
{

    char c;
    std::stack<int> st;
    std::stack <std::pair<int, int> > st2;

    int m, l, sum = 0;

    for (int i = 0; std::cin >> c; i++) {
        if (c == '.') break;
        if (c == '\\') st.push(i);
        else if (c == '/' && st.size() > 0) {
            l = st.top(); st.pop();
            sum += i - l;
            m = i -l;
            while (st2.size() > 0 && st2.top().first > l) {
                m += st2.top().second; st2.pop();
            }
            st2.push({l, m});
        }
    }

    std::vector<int> ans;
    while ( !st2.empty() ) {
        ans.push_back(st2.top().second);
        st2.pop();
    }
    std::reverse(ans.begin(), ans.end());
    std::cout << sum << std::endl;
    std::cout << ans.size();
    for (unsigned long i = 0; i < ans.size(); i++) std::cout << " " << ans[i];
    std::cout << std::endl;
    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
ll dp[2005][2005];

 
int main(){
  int N;
  cin >> N;
  vector<pair<ll,int>> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.emplace_back(a,i);
  }
  sort(ALLOF(v));
  reverse(ALLOF(v));

  rep(i,N){
    rep(j,i+1){
      int a = j;
      int b = i-j;
      dp[a+1][b] = max(dp[a+1][b], dp[a][b] + v[i].first * (v[i].second-a));
      dp[a][b+1] = max(dp[a][b+1], dp[a][b] + v[i].first * ((N-1-b)-v[i].second));
    }
  }

  ll ret = 0;
  rep(i,N){
    ret = max(ret, dp[i][N-i]);
  }
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 26340
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=4e5;
struct nd{int u,f,t,val;
	friend bool operator < (nd a,nd b){
	if(1.0*a.t/a.f!=1.0*b.t/b.f)return 1.0*a.t/a.f>1.0*b.t/b.f;
	if(a.f!=b.f)return a.f>b.f;
	if(a.t!=b.t)return a.t>b.t;
	if(a.u!=b.u)return a.u>b.u;
	return a.val>b.val;
	}
	friend nd operator + (nd a,nd b)
	{
		return (nd){b.u,a.f+b.f,a.t+b.t,a.val+b.val};
	}
	friend bool operator == (nd a,nd b){
		if(a<b)return 0;if(b<a)return 0;return 1;
	}
}e[N];
int fa[N],n,a[N],p[N];
int fd(int x){return x==fa[x]?x:fa[x]=fd(fa[x]);}
void mg(int x,int y)
{
	x=fd(x),y=fd(y);//cout<<x<<" "<<y<<endl;cout<<e[y].t*e[x].f<<" "<<e[y].t<<" "<<e[x].f<<endl;
	e[y].val+=e[y].t*e[x].f;e[y]=e[x]+e[y];
	fa[x]=y;
}
main()
{
	scanf("%lld",&n);for(int i=2;i<=n;i++)scanf("%lld",&p[i]);
	for(int i=1;i<=n;i++)fa[i]=i,scanf("%lld",&a[i]);
	priority_queue<nd>q;
	for(int i=1;i<=n;i++)
	{
		if(a[i])e[i].t++;else e[i].f++;e[i].u=i;
		q.push(e[i]);
	}
	while(!q.empty())
	{
		nd x=q.top();
		int u=x.u,y=p[u];q.pop();if(u==1)continue;
		//cout<<u<<" "<<e[u].t<<" "<<e[u].f<<" "<<e[u].val<<endl;
		if(e[u]==x)y=fd(y),
		mg(u,y),q.push(e[y]);
		//cout<<e[1].t<<" "<<e[1].f<<" "<<e[1].val<<endl;
	}
	cout<<e[1].val;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,k;cin>>n>>k;
  int ans=0,x;
  for (int i = 0; i < n; ++i){
  	cin>>x;
  	x<k-x ? ans+=x*2 : ans+=(k-x)*2;
  }
  cout<<ans<<endl;
}


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

int main(int argc, char const* argv[])
{
    int n, x;
    std::cin >> n >> x;

    auto vec = std::vector<int>(n);
    for(auto &child: vec)
    {
        std::cin >> child;
    }
    std::sort(vec.begin(), vec.end());

    int result = 0;
    for(auto num: vec)
    {
        if(num <= x)
        {
            x -= num;
            result++;
        }
        else
        {
            x = 0;
            break;
        }
    }
    if(x != 0)
    {
        result--;
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,a,b,c;
    cin>>n;
    for(int i=0;i<n;i++){
        bool t=false;
        cin>>a>>b>>c;
        if(a*a+b*b==c*c)
            t=true;
        if(a*a+c*c==b*b)
            t=true;
        if(b*b+c*c==a*a)
            t=true;
        if(t==true)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#define rep(i,N) for( i = 1; i <= N; i++ )
using namespace std;

int n;
int data[102][102];
int rui[102][102];		//rui[i][j] = (1,1)を左上とするi*j行列の要素和

int main(){
	int i,j,k,l;
	cin >> n;
	rep(i,n){
		rep(j,n){
			cin >> data[i][j];
		}
	}
	
	//左→右
	rep(i,n){
		rep(j,n){
			rui[i][j] = rui[i][j-1] + data[i][j];
		}
	}
	//上→下
	rep(j,n){
		rep(i,n){
			rui[i][j] = rui[i-1][j] + rui[i][j];
		}
	}
	
	int ans = -1145141919;
	rep(i,n){
		rep(j,n){
			for(k = i; k <= n; k++){
				for(l = j; l <= n; l++){
					//左上(i,j), 右下(k,l)とする行列の要素和を求める
					int mats = rui[k][l] - rui[k][j-1] - rui[i-1][l] + rui[i-1][j-1];
					ans = max( ans, mats );
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

/*Σ(k=a, k=b)A[k]を知りたい！
愚直に計算O(b-a)

先に
Σ(k=1, k=n)A[k] = rui[n]としておく.
すると、
Σ(k=a, k=b)A[k] = rui[b] - rui[a];
で計算できる。
O(1)
*/

Measured memory_bytes: 1244
from heapq import heappush, heappop
import queue
import re
import math
import functools

def s_raw():
    return input().rstrip("\r")

def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return list(map(int, ss_raw()))


INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    

def main():
    a = int_raw()
    s = s_raw()
    if a >=3200:
        return s
    else:
        return "red"

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 38636
#include <cstdio>
int main(){
    int a,b,c;
    std::scanf("%d %d %d",&a,&b,&c);
    if(a<=b&&b<=c) std::printf("%d\n",a+b);
    else if(a<=c&&c<=b) std::printf("%d\n",a+c);
    else if(b<=a&&a<=c) std::printf("%d\n",b+a);
    else if(b<=c&&c<=a) std::printf("%d\n",b+c);
    else if(c<=a&&a<=b) std::printf("%d\n",c+a);
    else std::printf("%d\n",c+b);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#define IL inline
using namespace std;

int r[4005],g[4005],b[4005];
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	string s;
	int len;
	long long sum=0;
	cin>>len;
	cin>>s;
	for(int i=len-1;i>=0;i--){
		r[i]=r[i+1];
		g[i]=g[i+1];
		b[i]=b[i+1];
		if(s[i]=='R'){
			r[i]++;
		}
		if(s[i]=='G'){
			g[i]++;
		}
		if(s[i]=='B'){
			b[i]++;
		}
	}
	for(int i=0;i<len;i++){
		if(s[i]=='R'){
			for(int j=i+1;j<len;j++){
				if(s[j]=='G'){
					sum+=b[j];
					if(s[j+j-i]=='B')sum--;
				}
				if(s[j]=='B'){
					sum+=g[j];
					if(s[j+j-i]=='G')sum--;
				}
			}
		}
	}
	for(int i=0;i<len;i++){
		if(s[i]=='G'){
			for(int j=i+1;j<len;j++){
				if(s[j]=='R'){
					sum+=b[j];
					if(s[j+j-i]=='B')sum--;
				}
				if(s[j]=='B'){
					sum+=r[j];
					if(s[j+j-i]=='R')sum--;
				}
			}
		}
	}
	for(int i=0;i<len;i++){
		if(s[i]=='B'){
			for(int j=i+1;j<len;j++){
				if(s[j]=='G'){
					sum+=r[j];
					if(s[j+j-i]=='R')sum--;
				}
				if(s[j]=='R'){
					sum+=g[j];
					if(s[j+j-i]=='G')sum--;
				}
			}
		}
	}
	cout<<sum;
    return 0;
}



Measured memory_bytes: 3680
#include<cstdio>
#include<algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const static int MOD = 1000000007;

int main(){
	int N;
	scanf("%d", &N);
	ull A[N], B[N];
	for (int i = 0; i < N; ++i){
		scanf("%llu %llu", A + i, B + i);
		if(!(N&1)){
			A[i] <<= 1;
			B[i] <<= 1;
		}
	}
	sort(A, A + N);
	sort(B, B + N);
	if(N&1){
		printf("%llu\n", B[N-1>>1] - A[N-1>>1] + 1);
		return 0;
	}
	printf("%llu\n", (B[N/2 - 1] + B[N/2] >> 1) - (A[N/2 - 1] + A[N/2] >> 1) + 1);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p )
{
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v )
{
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu ()
{
    cerr << endl;
}

template <typename T>
void faltu( T a[], int n )
{
    for(int i = 0; i < n; ++i)
        cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}


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

void f()
{
    string s,t,p;
    cin>>s>>t;

    int s1=sz(s),t1=sz(t),mn=INT_MAX,cnt;

    for(int i=0; i<s1; i++)
    {
        p=s.substr(i,t1);
        if(sz(p)==t1)
        {
            cnt=0;
            for(int j=0; j<t1; j++)
            {
                if(t[j]!=p[j])
                {
                    cnt++;
                }
            }
            mn=min(mn,cnt);
        }
    }
    cout<<mn<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] A = new long[N];
        for(int i = 0; i < N; i++) A[i] = sc.nextLong();
        int[] cnt = new int[50];
        // Aの各桁に1がいくつ立っているか数える
        for(int i = 0; i < 50; i++){
            for(int j = 0; j < N; j++){
                cnt[i] += (A[j] >> i) & 1;
            }
        }
        long ans = 0;
        boolean free = false;
        for(int i = 49; i >= 0; i--){
            // Kのｉ桁目が１の場合、ｉ桁目は１でも０でもよく、
            // Ａのｉ桁目に１が立っている方が少なければｉ桁目は１を立てる
            // Ａのｉ桁目に１が立っている方が多ければ（同数含む）ｉ桁目は０とする
            // ｉ桁目を０とすると、ｉ-１桁目以降は１でも０でも自由に選べる
            if(((K >> i) & 1) == 1L){
                if(cnt[i] < N - cnt[i]){
                    ans += (long)Math.pow(2, i) * (long)(N - cnt[i]);
                }else{
                    ans += (long)Math.pow(2, i) * (long)cnt[i];
                    free = true;
                }
            }else{
                // Kのｉ桁目が０の場合、それまでに自由に選べるようになっていなければ０しか選べない
                if(free){
                    ans += (long)Math.pow(2, i) * (long)Math.max(cnt[i], N - cnt[i]);
                }else{
                    ans += (long)Math.pow(2, i) * (long)cnt[i];
                }
            }
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 63212
<?php
$scores = array();
$n;$k;$q;$init=true;
    while(true)
    {
        $in = trim(fgets(STDIN));
        if($init) {$init=false;
                   list($n,$k,$q) = explode(" ", $in);
                   $scores = array_fill(0, $n, ($k-$q)); 
                   continue;
                  }
        else {
          $scores[$in-1] ++;
          $q --;
          if ($q == 0) {
          	for ($i =0; $i < count($scores); $i ++ ) {
              echo ($scores[$i] > 0 ) ? "Yes\n":"No\n";
            }
            break;
          }
        }
    }

Measured memory_bytes: 9080
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author KY2001
 */


#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

class DCardEater {
public:
  int solve(std::istream &cin, std::ostream &cout) {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> cum_sum_A(100000 + 1, 0);
    int num = 0;
    rep(i, N) {
      cin >> A[i];
      if (cum_sum_A[A[i]] == 0) {
        num += 1;
      }
      cum_sum_A[A[i]] += 1;
    }
    rep(i, 100000 + 1) {
      if (cum_sum_A[i]>=2 && cum_sum_A[i]%2 == 0){
        cum_sum_A[i] = 2;
      }else if (cum_sum_A[i] >= 2 && cum_sum_A[i]%2 == 1){
        cum_sum_A[i] %= 2;
      }
      if (cum_sum_A[i]) {
        cum_sum_A[i] -= 1;
      }
    }
    rep(i, 100000) {
      cum_sum_A[i + 1] += cum_sum_A[i];
    }
    if (cum_sum_A[100000]%2 == 0){
      cout<<num<<endl;
    }else{
      cout<<num-1<<endl;
    }
  }
};


signed main() {
	DCardEater solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var strs = str.Split(' ');

            var n = int.Parse(strs[0]);
            var m = int.Parse(strs[1]);

            var fullLike = Enumerable.Range(1, m).ToList();
            for (int i = 0; i < n; i++)
            {
                str = Console.ReadLine();
                strs = str.Split(' ');

                var like = new List<int>();
                for (int j = 1; j < strs.Length; j++)
                {
                    like.Add(int.Parse(strs[j]));
                }

                for (int j = 1; j <= m; j++)
                {
                    if (!like.Contains(j))
                    {
                        fullLike.Remove(j);
                    }
                }
            }

            Console.WriteLine(fullLike.Count);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>

using namespace std;

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

	int maxNum = max({ A, max({ B, C }) });
	
	if (A == maxNum) {
		for (int i = 0; i < K; i++) {
			A =  2 * A;
		}
	}
	else if (B == maxNum) {
		for (int i = 0; i < K; i++) {
			B =  2 * B;
		}
	}
	else if (C == maxNum) {
		for (int i = 0; i < K; i++) {
			C =  2 * C;
		}
	}

	cout << A + B + C << endl;
}
	


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	
	ll ans = 0LL;
	
	if( k >= a ) {
		ans += a;
		k -= a;
	} else {
		ans += k;
		k = 0;
	}	
	
	if( k > 0 && k >= b ) {
		if( k >= b ) k -= b;
		else k = 0;
	}
	
	if( k > 0 ) ans += -1 * k;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3592
def main():
    sc = {}
    N,M = map(int,input().split())
    for _ in range(M):
        s,c = input().split()
        s = int(s)
        if s not in sc:
            sc[s] = c
        else:
            if sc[s] != c:
                return -1

    if 1 in sc and sc[1] == '0' and N != 1:
        return -1

    ans = ["0"] * N

    for k,n in sc.items():
        ans[k-1] = n

    result = ''.join(ans)
    if result[0] != '0' or result == '0':
        return result
    else:
        result = '1' + result[1:]    
        return int(result)


print(main())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
int h,w,k,l,m,a,b,s,t,u,v,i,j,x[999][999];main(){while(1){memset(x,0,1<<21);v=0;std::cin>>k;if(!k){break;}std::cin>>w>>h;for(i=0;i<k;i++){std::cin>>a>>b;x[a][b]=1;}std::cin>>s>>t;for(i=1;i<=w;i++){for(j=1;j<=h;j++){u=0;for(l=0;l<s;l++){for(m=0;m<t;m++){if(x[i+l][j+m]){u++;}}}v=v>u?v:u;}}printf("%d\n",v);}}

Measured memory_bytes: 3204
IDENTIFICATION DIVISION.
PROGRAM-ID. 130B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP  PIC X(400).
01 N    PIC 9(3).
01 X    PIC 9(5).
01 CNT  PIC 9(5). 
01 Z    PIC 9(5).
01 ZO   PIC 9(5).
01 TBL.
   03 L PIC 9(3) OCCURS 100.
01 I    PIC 9(3).
01 P1   PIC 9(3).
01 P2   PIC 9(3). 
01 OUT  PIC ZZ9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO N X.
*>
  ACCEPT INP.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO L(I)
    COMPUTE P1 = P2 + 1
  END-PERFORM.  
*>
  MOVE 0 TO Z ZO CNT.
  PERFORM UNTIL (Z > X) OR (N < CNT)
    ADD 1 TO CNT
    COMPUTE Z = ZO + L(CNT)
    MOVE Z TO ZO
  END-PERFORM.  
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
*>
  STOP RUN.


Measured memory_bytes: 384
#include <stdio.h>
#define INFINITY 1000000
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

void abx()
{
  int i, u, v, minv;
  int d[MAX], color[MAX];

  for( i=0; i<n; i++ )
    {
      d[i] = INFINITY;
      color[i] = WHITE;
    }

  d[0] = 0;
  color[0] = GRAY;               
  while(1)
    {
      minv = INFINITY;          
      for( i=0; i<n; i++ )
	{
	  if( minv > d[i] && color[i] != BLACK )   
	    {
	      u = i;
	      minv = d[i];
	    }
	}
      if( minv == INFINITY ) break;
      color[u] = BLACK;
      for( v=0; v<n; v++ )
	{
	  if( color[v] != BLACK && M[u][v] != INFINITY )
	    {
	      if( d[v] > d[u] + M[u][v] )
		{
		  d[v] = d[u] + M[u][v];
		  color[v] = GRAY;
		}
	    }
	}
    }

  for( i=0; i<n; i++ )
    {
      printf("%d %d\n", i, d[i]);
    }
  
}


int main()
{
  int i, j,u, k, v, c;
  
  scanf("%d", &n);

  for( i=0; i<n; i++ )
    {
      for( j=0; j<n; j++ )
	{
	  M[i][j] = INFINITY;
	}
    }
  
  for( i=0; i<n; i++ )
    {
      scanf("%d%d", &u, &k);

      for( j=0; j<k; j++ )
	{
	  scanf("%d%d", &v, &c);
	  M[u][v] = c;
	}
    }

  abx();

  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<pair<int, int> > p;
	p.resize(n);
	for(int i = 0; i < n; ++i) {
		cin >> p[i].second >> p[i].first;
	}
	sort(p.begin(), p.end());
	multiset<int> s;
	for(int i = 1; i < n; ++i) {
		s.emplace(p[i].second);
	}
	int ans = p[0].first - p[0].second + 1;
	int low = p[0].second;
	for(int i = 1; i < n; ++i) {
		int l = p[i].second;
		s.erase(s.find(l));
		ans = max(ans, p[i].first - p[i].second + 1 + max(0, p[0].first - max(low, s.empty() ? 0 : *s.rbegin()) + 1));
		int tmp = max(p[0].first - low + 1, 0);
		tmp += max(p[i].first - max(p[i].second, s.empty() ? 0 : *s.rbegin()) + 1, 0);
		ans = max(ans, tmp);
		low = max(low, l);
	}
	/*
	 1 4 x
	 2 5 x
	 4 7 -
	 5 8 -
	 */
	cout << ans << '\n';
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

typedef pair<int, int> P;

int di[] = {1, 0, -1, 0};
int dj[] = {0, 1, 0, -1};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) { cin >> s[i]; }
    int ans = 0;
    rep(si, h)
    {
        rep(sj, w)
        {
            if (s[si][sj] == '#')
                continue;
            vector<vector<int>> dist(h, vector<int>(w, INF));
            queue<P> q;
            auto update = [&](int i, int j, int x) {
                if (dist[i][j] != INF)
                {
                    return;
                }
                dist[i][j] = x;
                q.push(P(i, j));
            };
            update(si, sj, 0);
            while (!q.empty())
            {
                int i = q.front().first;
                int j = q.front().second;
                q.pop();
                rep(dir, 4)
                {
                    int ni = i + di[dir], nj = j + dj[dir];
                    if (ni < 0 || ni >= h || nj < 0 || nj >= w)
                        continue;
                    if (s[ni][nj] == '#')
                        continue;
                    update(ni, nj, dist[i][j] + 1);
                }
            }
            rep(i, h)
            {
                rep(j, w)
                {
                    if (dist[i][j] == INF)
                        continue;
                    ans = max(ans, dist[i][j]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int h[100001];
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		int res = 0;
		while(i + res + 1 < n && h[i + res + 1] <= h[i + res]) res++;
		ans = max(ans, res);
		i += res;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640