akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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 gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
struct func{
  int num, denom;
  func(int num, int denom=1)
    : num(num), denom(denom)
    {

    }
  ~func(){

  }
};
func operator +(func const &l, func const &r){
  if(l.denom==r.denom) return func(l.num+r.num, l.denom);
  return func(l.num*r.denom+r.num*l.denom, l.denom*r.denom);
}
struct IntLike{
  int data;
  IntLike(int data)
    : data(data)
    {}
  IntLike operator +(IntLike const & right){
    return IntLike{data + right.data};
  }
};
struct array3{
  int storage[3];
  int & operator [](size_t i){
    return storage[i];
  }
};
int main(){
  int N;  string s;
  cin>>N>>s;
  ll ans = 1;
  sort(all(s));
  rep(i,0,N){
    int j=i;
    while(s[i]==s[j]) j++;
    ans *= (j-i+1);
    ans %= mod;
    i = j-1;
  }
  cout << ans-1 << endl;
  return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,M;
    cin >> N >> M;
    vector<ll> x(N),y(N),z(N);
    Rep(i,N){
        cin >> x[i] >> y[i] >> z[i];
    }

    vector<ll> s000(N),s001(N),s010(N);
    vector<ll> s011(N),s100(N),s101(N);
    vector<ll> s111(N),s110(N);

    Rep(i,N){
        s000[i] = x[i] + y[i] + z[i];
        s001[i] = x[i] + y[i] - z[i];
        s010[i] = x[i] - y[i] + z[i];
        s011[i] = x[i] - y[i] - z[i];
        s100[i] = - x[i] + y[i] + z[i];
        s101[i] = - x[i] + y[i] - z[i];
        s110[i] = - x[i] - y[i] + z[i];
        s111[i] = - x[i] - y[i] - z[i];
    }
    sort( s000.begin(), s000.end(), greater<ll>() );
    sort( s001.begin(), s001.end(), greater<ll>() );
    sort( s010.begin(), s010.end(), greater<ll>() );
    sort( s011.begin(), s011.end(), greater<ll>() );
    sort( s100.begin(), s100.end(), greater<ll>() );
    sort( s101.begin(), s101.end(), greater<ll>() );
    sort( s110.begin(), s110.end(), greater<ll>() );
    sort( s111.begin(), s111.end(), greater<ll>() );

    ll ans = 0;
    Rep(i,M){
        s000[i+1] += s000[i];
        s001[i+1] += s001[i];
        s010[i+1] += s010[i];
        s011[i+1] += s011[i];
        s100[i+1] += s100[i];
        s101[i+1] += s101[i];
        s110[i+1] += s110[i];
        s111[i+1] += s111[i];
    }

    if( M == 0){
        printf ("%lld\n", ans);
        return 0;
    }
    M--;
    ans = max( ans , s000[M] );
    ans = max( ans , s001[M] );
    ans = max( ans , s010[M] );
    ans = max( ans , s011[M] );
    ans = max( ans , s100[M] );
    ans = max( ans , s101[M] );
    ans = max( ans , s110[M] );
    ans = max( ans , s111[M] );

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

    return 0;
}



Measured memory_bytes: 384
import sys
from collections import deque
input = sys.stdin.readline

N, M = map(int, input().split())
A = deque()
ans = [[0]*M for i in range(N)]
counter = [0 for i in range(M)]
counter2 = 0
for _ in range(N):
    A.append(list(map(int, input().split())))

for i in range(N):
    for j in range(1, len(A[i])):
        counter[A[i][j]-1] += 1

for i in range(len(counter)):
    if counter[i] == N:
        counter2 += 1
print(counter2)

Measured memory_bytes: 3444
#!/usr/bin/env python3



# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    l = list(map(int,input().split()))
    l.sort()
    print(int(l[0]*l[1]/2))
    return 

if __name__ == '__main__':
    main()


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

int n, m, x, c[20], a[20][20];
int minn = INT_MAX;

void dfs(int p, int va){
    if(p == n){
        int cnt = va;
        int sum[20];
        for(int i = 1; i <= m; i++)sum[i] = 0;
        int pos = 0;
        int ans = 0;
        while(cnt){
            if(cnt & 1){
                for(int i = 1; i <= m; i++){
                    sum[i] += a[pos][i];
                }
                ans += c[pos];
            }
            pos++;
            cnt /= 2;

        }
        int f = 0;
        for(int i = 1; i <= m; i++){
            if(x > sum[i]){
                f = 1;
                break;
            }
        }
        if(f == 0){
            minn = min(minn, ans);
        }
        return;
    }
    dfs(p + 1, va+(1<<(p + 1)));
    dfs(p + 1, va);
}

int main(){
    scanf("%d %d %d", &n, &m, &x);
    for(int i = 1; i <= n; i++){
        scanf("%d", &c[i]);
        for(int j = 1; j <= m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    dfs(1, 2);
    dfs(1, 0);
    if(minn == INT_MAX){
        printf("-1\n");
    }else{
        printf("%d\n", minn);
    }

}

Measured memory_bytes: 3840
# a*a と aaの２パターンを探せばよい？
s = input()
n = len(s)
for i in range(n-1):
  if s[i] == s[i + 1]:
    print(i + 1, i + 2)
    exit()
  
for i in range(n-2):
  if s[i] == s[i + 2]:
    print(i + 1, i + 3)
    exit()
  
print(-1, -1)


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

#define f(i,a,b) for( ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter   ios::sync_with_stdio(false);cin.tie(0)

// policy-based



using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;



 
const ll MAX = 1e5 + 100;
const ll inf = 1e9;
const ll mod = 1e9+7;

ll a[MAX],c[MAX];
ll mul(ll x,ll y){
	return (x*y)%mod;
}
int main(){
	fastio;
	ll n,k,ans = 0;
	cin >> n >> k;
	f(i,0,n) cin >> a[i], c[a[i]]++;
	f(i,0,n){
		f(j,i+1,n){
			if(a[i] > a[j]) ans++;
		}
	}
	ans *= k;
	ll cant = n;
	af(i,2000,1){
		cant -= c[i];
	 
		ans +=   mul( mul(  ((k*(k-1)) /2)%mod , cant),c[i] )  ; 
		ans = ans%mod;
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
    string line;
    cin >> line;
    
    int o = 0;
    
    for(int i = 0; i < line.size(); i++){
       if(line.at(i) == 'o'){
           o++;
       } 
    }
    
    if(((15 - line.size()) >= (8-o))){
    cout << "YES";
    }
    else {
        cout << "NO";
    }

    return 0;
}


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

using namespace std;

const int mod = (int) 1e9 + 7;
int mul(int a, int b) {
  return (long long) a * b % mod;
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> color;
  for (auto c : s) {
    color.push_back(c == 'B');
  }

  int res = 1, choices = 0;
  for (auto c : color) {
    c ^= (choices & 1);
    if (c == 0) { // white
      if (choices == 0) {
        res = 0;
        break;
      }
      else {
        res = mul(res, choices);
        choices--;
      }
    }
    if (c == 1) { // black
      choices++;
    }
  }

  int ans = (choices == 0) ? res : 0;
  for (int i = 1; i <= n; i++) {
    ans = mul(ans, i);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pi 3.14159265358979323846264338327950288
using namespace std;
typedef long long ll;


int main()
{

    //#ifndef oj
    //freopen("in", "r", stdin);
    //freopen("out.txt","w",stdout);
    //#endif
    //system("cls");
    //getchar();
    ll n;
    cin>>n;
    cout<<setprecision(20)<<2*pi*n<<endl;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin>>h>>w;
	ll ans1 = (h + 1) / 2;
	ans1 *= (w + 1) / 2;
	ll ans2 = h - (h + 1) / 2;
	ans2 *= w - (w + 1) / 2;
	if(h == 1 || w == 1){
		cout<<1<<endl;
	}
	else{
		cout<<ans1 + ans2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define lowbit(x) x&(-x)
#define PA pair<int, int>
#define MK make_pair
using namespace std;
typedef long long LL;
inline int read()
{
	int l = 0, f = 1;
	char a = getchar();
	for (; a < '0' || a > '9'; a = getchar())
		if (a == '-') f = -1;
	for (; a >= '0' && a <= '9'; a = getchar())
		l = l*10+a-48;
	return l*f;
}
const int N = 100005;
int n, a[N], b[N];
LL sum1, sum2;
int main(int argc, char const *argv[])
{
	n = read();
	for (int i = 1; i <= n; ++i) a[i] = read();
	for (int i = 1; i <= n; ++i)
	{
		b[i] = read();
		if ((a[i]&1) != (b[i]&1)) sum2++, b[i]++;
		sum1 += max(0, (b[i]-a[i])/2);
		sum2 += max(0, a[i]-b[i]);
	}
	if (sum1 < sum2) printf("No\n");
	else printf("Yes\n");
	return 0;
}

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

int a[110];

int main(){
	int n, min1, sum1, sum;
	min1 = 120;
	sum1 = sum = 0;
	cin>>n;
	for(int i = 0; i < n ; i++){
		cin>>a[i];
	}
	for(int i = 0; i < n; i++){
		if(a[i] % 10 != 0){
			if(min1 > a[i])min1 = a[i];
			sum1 = sum1+ a[i];
		}
		else sum = sum + a[i];
	}
	if(sum1 == 0)cout<<0;
	else if(sum1 % 10 == 0){
		sum1 = sum1 - min1;
		cout<<sum1 + sum;
	}
	else cout<<sum1 + sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>

using namespace std;


int main(){
  int n;
  long long ans = 0;
  int B =0;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }

  for(int i = 0; i < n; ++i){
    b[i] =  a[i] - (i + 1);
  }
  sort(b.begin(), b.end());

  B = b[n / 2];

  for(int i = 0; i < n; ++i){
    ans += abs(b[i] - B);
  }

  cout << ans << endl;

}


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

const int MAXP = 1e4 + 4;

int n, mod;
string s;
int cnt[MAXP];

int main() {
	cin >> n >> mod >> s;
	reverse(s.begin(), s.end());
	long long res = 0;
	if (mod == 2 || mod == 5) {
		for (int i = 0; i < n; i++) {
			if ((s[i] - '0') % mod == 0) {
				res += n - i;
			}
		}
	} else {
		cnt[0] = 1;
		long long p = 1, cur = 0;
		for (int i = 0; i < n; i++) {
			cur = (cur + (s[i] - '0') * p % mod) % mod;
			p = (p * 10) % mod;
			res += cnt[cur]++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 644
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, k, s = ril()
res = [s] * k
if s == 10**9:
    res.extend([s - 1] * (n - k))
else:
    res.extend([10**9] * (n - k))
print(*res)

Measured memory_bytes: 6780
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cassert>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool ok(ll a, ll b) {
    if (a < 0 && b > 0) return true;
    if (a > 0 && b < 0) return true;
    return false;
}

int n;
vector<ll> a;
ll f(vector<ll> a, ll d) {
    a[0] -= d;
    ll sum = a[0];
    ll ans = abs(d);
    if (sum == 0) return INF;
    rep(i, n) if (i) {
        if (!ok(sum, sum + a[i])) {
            if (sum + a[i] == 0) {
                ll t;
                if (sum > 0)
                    t = sum + a[i] + 1;
                else
                    t = sum + a[i] - 1;
                ans += abs(t);
                a[i] -= t;
            } else if (sum + a[i] > 0) {
                ll t = sum + 1 + a[i];
                ans += abs(t);
                a[i] -= t;
            } else {
                ll t = sum + a[i] - 1;
                ans += abs(t);
                a[i] -= t;
            }
        }
        sum += a[i];
        assert(sum != 0);
    }
    // rep(i, n) cout << a[i] << " ";
    // cout << endl;
    // cout << ans << endl;
    return ans;
}
int main() {
    cin >> n;
    a.resize(n);
    rep(i, n) cin >> a[i];
    ll ans = f(a, 0);
    ans = min(ans, f(a, a[0] + 1));
    ans = min(ans, f(a, a[0] - 1));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1804
#include<stdio.h>
#include<math.h>

int main(){
	double a,b,c,S,L,h,x,rad;
	double PI = acos(-1);
	
	scanf("%lf %lf %lf", &a, &b, &c);
	rad = c * PI / 180;
	
	S=a*b/2*sin(rad);
	x=pow(a,2.0)+pow(b,2.0)-2*a*b*cos(rad);
	x=sqrt(x);
	L=a+b+x;
	h=2*S/a;
	
	printf("%0.8f\n%0.8f\n%0.8f\n",S,L,h);
	
    return 0;
}


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

typedef long long ll; 
typedef pair<int,int > pp;

 
#define sz(x) (int)x.size() 
#define PI acos(-1)
int const N=5e5;
int  mod = 998244353,oo = 1e9;
ll OO = 3e18;

int dp[1<<10][1<<13];
int what[1<<10],n,m,cost[1<<10];

int rec(int idx,int msk){
	if(idx==m)return msk == (1<<n)-1 ? 0: oo; 
	int &ret=dp[idx][msk];
	if(ret!=-1)return ret;
	return ret=min(rec(idx+1,msk),rec(idx+1,msk|what[idx])+cost[idx]);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int b;
		cin>>cost[i]>>b;
		while(b--){
			int c;
			cin>>c;
			c--;
			what[i]|=1<<c;
		}
	}
	memset(dp,-1,sizeof dp);
	if(rec(0,0)>=oo)cout<<-1;
	else cout<<rec(0,0);
	return 0;
}



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

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

int main(){
	int n;
	int m;
	int x;
	cin>>n;
	int k=0;
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int l=1;l<=n;l++){
			m=gcd(i,j);
			x=gcd(m,l);
			k+=x;
		    // cout<<i<<j<<l<<x<<endl;
			m=0;
			x=0;
			}
		}
	}
	
	cout<<k<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<utility>
#include<queue>
#include<algorithm>
using namespace std;

typedef pair<int,int> P;

int main(){
  int n,m;
  int s,t;
  int x,y;
  int grid[101][101];

  while(cin >> n && n){
    cin >> m;
    for(int i=0;i<=n;i++)
      for(int j=0;j<=m;j++)grid[i][j] = 1<<25;

    cin >> s;
    for(int i=0;i<s;i++){
      cin >> x >> y;
      grid[x][y] = 0;
      queue<P> q;
      q.push(P(x,y));
      while(q.size()){
	P p = q.front();q.pop();
	x=p.first, y=p.second;

	int dx[6]={1,0,-1,1,0,1},dy[6] = {-1,-1,0,0,1,1};
	if(y&1)dx[0] = dx[5] = -1;
	for(int i=0;i<6;i++){
	  int sx = x+dx[i],sy = y+dy[i];
	  if(sx<=0 || sy<=0 || n<sx || m<sy)continue;
	  if(grid[sx][sy]>grid[x][y]+1){
	    grid[sx][sy] = grid[x][y] + 1;
	    q.push(P(sx,sy));
	  }
	}
      }
    }

    int ans = 0;
    cin >> t;
    for(int i=0;i<t;i++){
      cin >> x >> y;
      int hoge = 1;
      int tmp[101][101];
      for(int j=0;j<=n;j++)
	for(int k=0;k<=m;k++)tmp[j][k] = grid[j][k];

      grid[x][y] = 0;
      queue<P> q;
      q.push(P(x,y));
      while(q.size()){
	P p = q.front();q.pop();
	x=p.first, y=p.second;

	int dx[6]={1,0,-1,1,0,1},dy[6] = {-1,-1,0,0,1,1};
	if(y&1)dx[0] = dx[5] = -1;
	for(int i=0;i<6;i++){
	  int sx = x+dx[i],sy = y+dy[i];
	  if(sx<=0 || sy<=0 || n<sx || m<sy)continue;
	  if(grid[sx][sy]>grid[x][y]+1){
	    grid[sx][sy] = grid[x][y] + 1;
	    hoge++;
	    q.push(P(sx,sy));
	  }
	}
      }
      ans = max(ans,hoge);
      for(int j=0;j<=n;j++)
	for(int k=0;k<=m;k++)grid[j][k] = tmp[j][k];
    }
    cout << ans << endl;
  }
}

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



int main() {
int n; cin >>n;
vector<int>a(n);
rep(i,n) cin >> a[i];
int f,t,odd;
rep(i,n){
    if(a[i]%4==0) f++;
    else if(a[i]%2==1) odd++;
} 
t = n-f-odd;

if(f==odd) {cout << "Yes" << endl;
return 0;}
if(n==t)
{cout << "Yes" << endl;
return 0;}
if(n%2==1&&n/2==f&&n/2+1==odd)
{cout << "Yes" << endl;
return 0;}

if(odd==0)
{cout << "Yes" << endl;
return 0;}
cout  << "No" << endl;
return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
using ll = long long;

int main(){
    ll k,a,b;
    cin>>k>>a>>b;
    ll ans=1;
    if(b-a<=2) ans+=k;
    else{
        k-=a-1;
        ans=a;
        ans+=(b-a)*(k/2);
        if(k%2) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+7, LINF = 1e18;


int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    a=a+b;
    rep(i,n){
        char c;
        cin>>c;
        if(c=='b'&&a>0&&b>0)cout<<"Yes\n",a--,b--;
        else if(c=='a'&&a>0)cout<<"Yes\n",a--;
        else cout<<"No\n";
    }
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/

class Data
{
public:
	
	string term;
	int freq;
	
	Data(string _term, int _freq)
	{
		term = _term;
		freq = _freq;
	}
	
	bool operator<(const Data& d) const
	{
		if (freq == d.freq) return term < d.term;
		else return freq > d.freq;
	}
};

int main()
{
	int n;
	string str;
	
	while (cin >> n, n)
	{
		cin.ignore();
		
		map<string, int> freq;
		map<char, vector<string> > dict;
		
		REP(n)
		{
			getline(cin, str);
			stringstream ss(str);
			string s;
			while (ss >> s)
			{
				freq[s]++;
			}
		}
		
		getline(cin, str);
		
		vector<Data> data;
		for (map<string, int>::iterator it=freq.begin(); it!=freq.end(); it++)
		{
			if (it->first[0] == str[0])
			{
				data.push_back(Data(it->first, it->second));
			}
		}
		
		if (data.size() == 0)
		{
			cout << "NA" << endl;
		} else {
			sort(data.begin(), data.end());
			for (int i=0; i<data.size()&&i<5; i++)
			{
				if (i != 0)
				{
					cout << " ";
				}
				cout << data[i].term;
			}
			cout << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define sorted(a) sort(a.begin(), a.end());
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen(".testcase", "r", stdin);
#endif

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

  int N;
  cin >> N;
  vector<int> L(N, 0);
  rep(i, N) {
    cin >> L[i];
  }
  sorted(L);
  int n = 0;
  for (auto x : L) {
    n += x;
  }
  if (n - L[N-1] > L[N-1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
  ll n,m;
  cin>>n>>m;
  vector<ll> a(m);
  rep(i,m) cin>>a[i];
  ll sum=0;
  rep(i,m) sum+=a[i];
  if(sum<=n) cout<<n-sum<<endl;
 else cout<<-1<<endl;
return 0;
}


Measured memory_bytes: 3712
S = input()
T = ['dream', 'dreamer', 'erase', 'eraser']

rS = str(S[:: -1])
rT = [str(t[:: -1]) for t in T]

now = 0
while now < len(S):
    for t in rT:
        if t == rS[now: now + len(t)]:
            now += len(t)
            break
    else:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 3188
from collections import Counter
N,M=map(int, input().split())
Q=[]
for _ in range(M):
    a,b=map(int, input().split())
    Q.append(a)
    Q.append(b)
C=Counter(Q)
for c in C.values():
    if c&1:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 16380
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100000
using namespace std;

int n, m;
vector< int > graph[MAX_N];

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

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

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

void dfs(int v, bool visited[]){
  if(visited[v]) return;
  visited[v] = true;
  for(int w: graph[v]){
    dfs(w, visited);
  }
}

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

  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int x, y, z;
    cin >> x >> y >> z;
    --x; --y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }

  int count = 0;
  bool visited[n];
  fill(visited, visited + n, false);
  for(int v = 0; v < n; v++){
    if(!visited[v]){
      dfs(v, visited);
      ++count;
    }
  }

  cout << count << endl;

  return 0;
}


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

int main()
{
	int l, b, n;
	cin >> l >> b >> n;
	int e_top = 0, e_bottom = 0, e_left = 0, e_right = 0;
  	// eliminating length of top, bottom, left, right.
	
	for(int i = 0; i < n; i++) {
		int x, y, a;
		cin >> x >> y >> a;
		if(a == 1) {
			e_left = max(e_left, x);
		} else if(a == 2) {
			e_right = max(e_right, l - x);
		} else if(a == 3) {
			e_bottom = max(e_bottom, y);
		} else {
			e_top = max(e_top, b - y);
		}
	}
	
	l = max(0, l - e_left - e_right);
	b = max(0, b - e_top - e_bottom);
	
	cout << l * b;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int l, r;

int chk(int x) {
	if(x < 0) return -1;
	else if(x > 0) return 1;
	else return 0;
}

int main() {
	cin >> l >> r;
	int ans = 1;
	for(int i = l; i <= r; i++) {
		ans *= chk(i);
	}
	if(ans < 0) puts("Negative");
	else if(ans > 0) puts("Positive");
	else puts("Zero");
}

Measured memory_bytes: 256
array=[[0 for i in range(10)]for j in range(12)]
n=int(input())

for i in range(n):
    call=list(map(int,input().split()))
    array[(call[0]-1)*3-1+call[1]][call[2]-1]+=call[3]
for i in range(0,12):
    if i%3==0 and i!=0:
        for j in range(20):
            print("#",end="")
        print()
    for j in range(10):
        print(" "+str(array[i][j]),end="")
    print()

Measured memory_bytes: 7688
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main() {
	int n, m;
	long long x[1010], y[1010], z[1010], sum[8][1010], ans[8];

	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> z[i];
		sum[0][i] = x[i] + y[i] + z[i];
		sum[1][i] = x[i] - y[i] + z[i];
		sum[2][i] = x[i] + y[i] - z[i];
		sum[3][i] = x[i] - y[i] - z[i];
		sum[4][i] = -x[i] + y[i] + z[i];
		sum[5][i] = -x[i] - y[i] + z[i];
		sum[6][i] = -x[i] + y[i] - z[i];
		sum[7][i] = -x[i] - y[i] - z[i];
	}
	for (int i = 0; i < 8; i++) {
		sort(sum[i], sum[i] + n, greater<long long>());
	}

	for (int i = 0; i < 8; i++) {
		ans[i] = 0;
	}

	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < m; j++) {
			ans[i] += sum[i][j];
		}
	}

	sort(ans, ans + m, greater <long long>());

	cout << ans[0] << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define check system("pause")
#define all(x) (x).begin(),(x).end()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lowbit(a) ((a)&-(a))
#define INF 0x3f3f3f3f
const ll mod = 1e9+7;
const int N = 1e5+20;
#define dep(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define mes(p,b) memset(p,b,sizeof(p))
#define sz(x) int(x.size())
ll dp[N][14];int a[N];
ll dfs(int pos,int res){
	if(pos==0) return res==5; 
	if(dp[pos][res]!=-1) return dp[pos][res];

	ll ans=0; 
	if(a[pos]!=-1) ans+=dfs(pos-1,(res*10+a[pos])%13),ans%=mod;
	else
	rep(i,0,9){
		ans+=dfs(pos-1,(res*10+i)%13);
		ans%=mod;
	}
	return dp[pos][res]=ans;
}
int main()
{
  	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	int ss=sz(s);
	mes(dp,-1);
	rep(i,1,ss){
		a[i]=s[ss-i]-'0';
		if(!(a[i]>=0&&a[i]<=9)) a[i]=-1;
	}
	dfs(ss,0);
	cout<<dp[ss][0];
  	return 0;
}



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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i = 0; i< n; i++){
    cin >> vec.at(i);
  }
  
  int num = n;
  
  for (int i = 0; i < n; i++){
    if (vec.at(i) < k){
      num--;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int d,n;
    cin>>d>>n;
    if(d==0){
        if(n!=100)cout<<n<<endl;
        else cout<<101<<endl;
    }
    if(d==1){
        if(n!=100)cout<<n*100<<endl;
        else cout<<10100<<endl;
    }
    if(d==2){
        if(n!=100)cout<<n*10000<<endl;
        else cout<<1010000<<endl;
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> p(N);
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    p.at(i) = make_pair(a,i+1);
  }
  std::sort(p.begin(), p.end());
  for(int i=0; i<N; i++){
    cout << p.at(i).second << " ";
  }
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dp[3002][3002];
int main(){
    string s;
    string t;
    cin>>s>>t;
    int l1=s.size();
    int l2=t.size();
    memset(dp,0,sizeof(dp));
    for(int i=0;i<(int)s.length();i++){
        for(int j=0;j<(int)t.length();j++){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }
            else{
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            }
        }}
   int i=l1,j=l2;
    string res;
    while(i>0&&j>0){
        if(s[i-1]==t[j-1]){
            res=s[i-1]+res;
            i--;
            j--;
        }
        else if(dp[i][j-1]>dp[i-1][j]){
            j--;
        }
        else{
            i--;
        }

    }
    cout<<res<<endl;
}



Measured memory_bytes: 35456
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int a[M];
 main()

{
    fast
    int n,x;
    cin>>n>>x;
    f(i,1,n)
    {
       cin>>a[i];
    }
    int ses=0;
    f(i,2,n)
    {
       int u=a[i-1];
       int v=a[i];
       if(u+v<=x)continue;
       int gap=(u+v)-x;
       if(v>=gap)
       {
           v=v-gap;
           ses+=gap;
           a[i]=v;
       }
       else
       {
           ses+=v;
           a[i]=0;
           gap-=v;
           u=u-gap;
           ses+=gap;
           a[i-1]=u;
       }
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 4400
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
using Int = long long;

signed main(){
    vector<Int> pqr;
    for (int i = 0; i < 3; i++){
        Int tmp;
        cin >> tmp;
        pqr.push_back(tmp);
    }
    sort(pqr.begin(), pqr.end());
    cout << pqr[0] + pqr[1] << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
d=defaultdict(set)
for i in range(1, 101):
    for j in range(1,101):
        for k in range(1,101):
            cur = i * i + j * j + k * k + i * k + i * j + j * k
            d[cur].add(tuple(sorted([i, j, k])))


resd = {}
resl = []
for i in range(1, N+1):
    if i < 6:
        resl.append(0)
        continue
    if i not in d:
        resl.append(0)
    else:
        count = 0
        for i, j, k in d[i]:
            if i == j and j == k:
                count += 1
            elif i == j or j == k or i == k:
                count += 3
            else:
                count += 6
        resl.append(count)
                


for i in resl:
    print(i)
            



Measured memory_bytes: 39920
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n;
	in(n);
	vector<int> a(n);
	for(int i=0;i<n;i++) {
		in(a[i]);
	}
	sort(a.rbegin(), a.rend());
	
	priority_queue<pi> pq;
	LL ans = a[0];
	pq.push(MP(a[1], a[0]));
	pq.push(MP(a[1], a[0]));
	
	for(int i=2;i<n;i++) {
		pi t = pq.top();
		pq.pop();
		
		ans += t.X;
		pq.push(MP(a[i], t.X));
		pq.push(MP(a[i], t.Y));
	}
	cout<<ans<<en;
}

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


Measured memory_bytes: 6164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
int d,g;
int p[15],c[15],cmp[15];
int ans=INF;
void dfs(int i, int sum, int cnt, int unused){
    if(i==d){
        if(sum>=g){
            ans=min(ans,cnt);
        }else{
            if(unused!=-1){
                int tmp=(g-sum+(unused+1)*100-1)/((unused+1)*100);
                if(tmp<p[unused]){
                    ans=min(ans,cnt+tmp);
                }
            }
        }
    }else{
        dfs(i+1,sum+cmp[i],cnt+p[i],unused);
        dfs(i+1,sum,cnt,i);
    }
}

signed main(){
    cin>>d>>g;
    rep(i,d){
        cin>>p[i]>>c[i];
        cmp[i]=100*(i+1)*p[i]+c[i];
    }
    dfs(0,0,0,-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
    int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t||(x+y)%2==0&&t%2==1||(x+y)%2==1&&t%2==0)
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

ll bit[200010];
//ll kai[3010];
ll Cnt[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }



/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/



void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

void makePrimeList(ll x) {
	ll X = x;
	for (ll j = 2; j * j <= x; j++) {
		ll cnt = 0;
		while (X % j == 0) {
			cnt++;
			X /= j;
		}
		if (cnt) {
			Cnt[j] = max(Cnt[j], cnt);
		}
	}
	if (X != 1) Cnt[X] = max(Cnt[X], 1LL);
}

ll N, A[10010];
set<ll> used;
ll sum;

void solve() {
	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, N) {
		ll X = A[i];
		for (ll j = 2; j * j <= A[i]; j++) {
			ll cnt = 0;
			while (X % j == 0) {
				cnt++;
				X /= j;
			}
			if (cnt) {
				Cnt[j] = max(Cnt[j], cnt);
				used.insert(j);
			}
		}
		if (X != 1) {
			Cnt[X] = max(Cnt[X], 1LL);
			used.insert(X);
		}
	}
	ll ans = 1;
	for (ll a : used) {
		(ans *= pow_mod(a, Cnt[a])) %= mod;
	}
	rep(i, N) {
		(sum += ans * div_mod(A[i]) % mod) %= mod;
	}
	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

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

int main (){
  int N, K, x;
  cin >> N >> K;
  x = 1;
  for (int i = 0 ; i < N ; i++){
    if ( x * 2 <= x + K){
      x *= 2;
    }
    else {
      x += K;
    }
  }
  cout << x << endl ;
}

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

using namespace std;

int main()
{
  int N;
  vector<int> a; 

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    int temp;
    cin >> temp;
    a.push_back(temp);
  }

  sort(a.begin(), a.end(), greater<int>()); //降順ソート

  int sumAlice = 0;
  int sumBob = 0;

  for (int i = 0; i < N; i+=2)
  {
    sumAlice += a[i];
    if (i + 1 < N) sumBob += a[i+1];
  }
  
  std::cout << sumAlice  - sumBob<< endl;
};

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){

        Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int hoz = 0;
		if(a > b){
			hoz = a;
			a = b;
			b = hoz;
			if(b > c){
				hoz = b;
				b = c;
				c = hoz;
				if(a > b){	
					hoz = a;
					a = b;
					b = hoz;
				}
			}
		}else if(b > c){
			hoz = b;
			b = c;
			c = hoz;
			if(a > b){
				hoz = a;
				a = b;
				b = hoz;
			}
		}
		System.out.println(a+" "+b+" "+c);
    }
}

Measured memory_bytes: 17292
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define MEM(x) memset(x,0,sizeof(x))
#define vc vector<int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define inf 0x3f3f3f3f
#define t_case int tt; cin>>tt; while (tt--)
#define lnginf 9223372036854775807
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define For(i,j,k) for (int i=(int)(j);i<(int)(k);i++)
#define ins insert
#define in(x); { for (auto &i : x) cin >> i; }
#define out(x); { for (auto i : x) cout<<i<<' ' ; }
#define PI 3.14159265359
const long long LL_INF = (long long) 2e18 + 5;
using namespace std;
void solve() {
	map<string, int> m;
	vector<string> v = {"AC", "WA", "TLE", "RE"};
	t_case{
		string s; cin >> s;
		m[s]++;
	}
	For(i, 0, 4) {
		cout << v[i] << " x " << m[v[i]] << '\n';
	}


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


	fastio solve();


}


Measured memory_bytes: 3660
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a*b % 2 == 0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}
	}

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll N;
    cin>>N;
    ll h[N],ans=0,c=0;
    rep(0,i,N)cin>>h[i];
    rep(1,i,N){
        cin>>h[i];
        if((h[i]-h[i-1])<=0){
            ++c;
        }else{
            ans=max(ans,c);
            c=0;
        }
    }
    ans=max(ans,c);
    cout<<ans<<endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef set<int> si;
typedef set<ll, ll> sll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<int, int> mii;
typedef map<int, ll> mil;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort((c).begin(),(c).end())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define PB push_back

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int main(){
	REP(i, 7){
		int a, b;
		cin >> a >> b;
		cout << a-b << endl;
	}
}

Measured memory_bytes: 1164
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

INF = 2**30
n = int(input())
P = list(map(int, input().split()))
T = [[] for _ in range(n)]
for i, p in enumerate(P, 1):
  T[p-1].append(i)
X = tuple(map(int, input().split()))
D = [-1]*n
def dfs(v):
  if D[v] != -1:
    return D[v]
  l = len(T[v])
  x = X[v]
  dp = [INF]*(x+1)
  dp[0] = 0
  for nv in T[v]:
    k = [INF]*(x+1)
    d = dfs(nv)
    for j in range(x+1):
      if j >= X[nv]:
        k[j] = min(k[j], dp[j-X[nv]]+d)
      if j >= d:
        k[j] = min(k[j], dp[j-d]+X[nv])
    dp = tuple(k)
  res = min(dp)
  D[v] = res
  return res
ans = dfs(0)
if ans == INF:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Measured memory_bytes: 25096
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

typedef pair<ll,ll> P;
const ll MO = 1000000007;

int main(){
    ll x;
    cin >> x;
    vector<ll> ks;
    for(ll i = 1; i*i <=x; i++){
        if(x%i==0){
            ks.push_back(i);
            ks.push_back(x/i);
        }
    }
    for(ll ele : ks){
        for(ll a=1;a*a*a*a<=x;++a){
            ll b = a - ele;
            ll res = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4);
            if(res*ele==x){
                cout<< a << " "<<b<<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main(){
	int a;
	string S;
	cin >> a >> S;
	if(a >= 3200) cout << S << endl;
	else cout << "red" << endl;
}

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

public class Don
{
    public Don() { }
    private Reader r = new Reader();

    public void Solve()
    {
        var s = r.next();

        int st = -1, ed = -1;

        for(var i = 0; i < s.Length; i++)
        {
            if (s[i] == 'A' && st == -1) st = i;
            if (s[i] == 'Z' && st != -1) ed = i;
        }

        Console.WriteLine(ed - st + 1);

    }

    public static void Main(string[] args)
    {
        new Don().Solve();
    }

}

class Reader
{
    string[] s;
    int i;
    char[] cs = new char[] { ' ' };

    public Reader()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length)
            return s[i++];
        var input = Console.ReadLine();
        while (input == "")
            input = Console.ReadLine();
        s = input.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}


Measured memory_bytes: 4184
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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



int main() {

	ll A, B, K;
	cin >> A >> B >> K;

	set<ll> st;
	
	rep(i, min(K,B-A+1)) {
		st.insert(A + i);
		st.insert(B - i);
	}

	for (ll i : st) {
		cout << i << endl;
	}
	

	system("PAUSE");

	

}


Measured memory_bytes: 504