akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
using namespace std;

int main(void){
    int ans=0;
    for(int i=0; i<3; i++){
        char a;
        cin >> a;
        if(a == 'o') ans++;
    }
    cout << 700+ans*100 << endl;
    return 0;
}


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

int main() {
 int x;
 cin >> x;
 for (int i = 1; i < 1000; i++){
   ll a5 = 1;
   for (int j = 0; j < 5; j++){ a5 *= i;} 
  for (int t = -1000; t < 1000; t++){
    ll b5 = 1;
    for (int j = 0; j < 5; j++){ b5 *= t;} 
    if ((a5-b5) == x ){
      cout << i << " " << t << endl;
      return 0;
    }
  } 
 }
} 


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

int main()
{
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    for (int i=0; i<N; i++) cin >> p[i];

    vector<int> kouho(101, X);
    for (int i=1; i<=50; i++)
    {
        kouho[2*(i-1)+1] = X-i;
        kouho[2*i] = X+i;
    }
    //for (int i=0; i<101; i++) cout << kouho[i] << endl;

    int result;
    for (int i=0; i<101; i++)
    {
        bool exist=false;
        for (int j=0; j<N; j++)
        {
            if (kouho[i]==p[j]) exist=true;
        }
        if (!exist)
        {
            result = kouho[i];
            break;
        } 
    }

    cout << result << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 10000000000;
const ll MOD = 1000000007;

using namespace std;

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

int main() {
	int n, m; cin >> n >> m;
	vector<int>a(m);

	rep(i, m)cin >> a[i];

	vector<bool>safe;
	safe.assign(n + 1, true);
	rep(i, m) {
		safe[a[i]] = false;
	}

	vector<int>dp(n + 1, 0);

	dp[0] = 1;
	if (safe[1])dp[1] = 1;

	for (int i = 2; i <= n; i++) {
		if (safe[i - 1]) dp[i] += dp[i - 1];
		if (safe[i - 2]) dp[i] += dp[i - 2];
		dp[i] %= MOD;
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define N 200002
using namespace std;
int n,p[N],a[N],v[N*4][2],b[N];
vector <int> to[N];
set <int> s;
void build(int k,int l,int r){
	if(l==r){
		v[k][l&1]=p[l];
		v[k][(l&1)^1]=n+1;
		return;
	}
	int mid=(l+r)>>1;
	build(k*2,l,mid);
	build(k*2+1,mid+1,r);
	v[k][0]=min(v[k*2][0],v[k*2+1][0]);
	v[k][1]=min(v[k*2][1],v[k*2+1][1]);
}
int getmin(int k,int l,int r,int L,int R,int t){
	if(L<=l && r<=R)return v[k][t];
	int res=n+1,mid=(l+r)>>1;
	if(L<=mid)res=min(res,getmin(k*2,l,mid,L,R,t));
	if(R>mid)res=min(res,getmin(k*2+1,mid+1,r,L,R,t));
	return res;
}
int dfs(int l,int r,int t,int f){
	int x=a[getmin(1,1,n,l,r,t)];
	int y=a[getmin(1,1,n,x,r,t^1)];
	to[f].push_back(x);
	b[x]=y;
	if(l<x)dfs(l,x-1,t,f);
	if(x+1<y)dfs(x+1,y-1,t^1,x);
	if(y<r)dfs(y+1,r,t,f);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&p[i]);
		a[p[i]]=i;
	}
	build(1,1,n);
	dfs(1,n,1,0);
	for(int i=0;i<to[0].size();++i)s.insert(p[to[0][i]]);
	for(int i=1;i<=n/2;++i){
		int x=a[*s.begin()];
		s.erase(p[x]);
		printf("%d %d ",p[x],p[b[x]]);
		for(int j=0;j<to[x].size();++j)s.insert(p[to[x][j]]);
	}
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)


void solve(){
	string s;
	cin >> s;


	long long sum = 0;


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

	if (sum%9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

}



int main()
{
    FAST;
    int t;
   	t = 1;

    while(t--){
        solve();
    }
    return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  vector<string> mp(2 * n);
  rep(i, n) {
    cin >> mp[i];
    mp[i] += mp[i];
    mp[n + i] = mp[i];
  }

  ll ans = 0;
  repLRE(i, 0, n - 1) {
    ll cy = 0, cx = i;
    bool ok = true;
    rep(i, n) rep(j, n) {
      if (mp[cy + i][cx + j] != mp[cy + j][cx + i]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }

  cout << ans * n << endl;
}


Measured memory_bytes: 4124
#include<iostream>
#include<algorithm>
using namespace std;
 int n, s, a[20], b;
main()
{
	
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b, s += max(a[i] - b, 0);
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if (a1 + a2 + a3 >= 22) cout << "bust";
  else cout << "win";

  cout << endl;

  return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	double maxx = 0;
	int max0 = 0, max1 = 0;
	for (int i = 0; i <= f; i += a * 100)
	{
		for (int j = 0; i + j <= f; j += b * 100)
		{
			for (int k = 0; i + j + k <= f; k += c)
			{
				for (int l = 0; i + j + k + l <= f; l += d)
				{
					if (i + j + k + l == 0)
					{
						continue;
					}
					int s = k + l;
					if (e * (i + j) / 100 >= s)
					{
						double x = 100.0 * s / (double)(i + j + s);
						if (x > maxx)
						{
							maxx = x;
							max0 = i + j + s;
							max1 = s;					
						}
					}
				}
			}
		}
	}

	if (max0 == 0)
	{
		max0 = a * 100;
	}

	cout << max0 << " " << max1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,c,k;
    scanf("%d %d %d", &a, &b, &c);
    scanf("%d", &k);
    while(b <= a){
        if (k <= 0){
            printf("No");
            return 0;
        }
        b *= 2;
        k--;
    }
    while(c <= b){
        if (k <= 0){
            printf("No");
            return 0;
        }
        c *= 2;
        k--;
    }
    if (k >= 0){
        printf("Yes");
    }
    else{
        printf("No");
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=-10000000000;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	ll N,A,B; cin>>N>>A>>B;
	vector<ll> h(N);
	rep(i,N) cin>>h[i];
	ll l=1,r=1000000000;//r=10^9
	ll i;
	while(r-l>0){
		i=(l+r)/2;
		ll cnt=0;
		bool e=false;
		rep(j,N){
			if(h[j]>B*i){
				cnt+=myceil(h[j]-B*i,A-B);
			}
		}
		if(cnt<=i) e=true;

		if(e) r=i;
		else l=i+1;
	}
	//r,l
	cout<<l;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 1000020
using namespace std;
int read(){
	int nm=0,fh=1; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
int n,m,ans,s[M],dt;
char S[M],ch[M];
bool fg=false;
int main(){
	n=read(),scanf("%s%s",S+1,ch+1);
	for(int last=n,i=n;i>0;i--,fg=false){
		m+=s[i+dt];
		while(last>i||(S[last]!=ch[i]&&last)) last--,fg=true;
		if(last<=0){puts("-1");return 0;}
		if(fg&&last<i) m++,s[i+dt]=0,s[last+dt]--,dt++;
		ans=max(ans,m);
	}
	printf("%d\n",ans); return 0;
}

Measured memory_bytes: 6016
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

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

const int N = 16;
const int M = 16;
const int T = (1<<N);
const double INF = (1<<30);

int n,m;
double cat[N][M];
double memo[2][T][N];

void input(){
	cin>>n>>m;
	rep(i,n)rep(j,m)cin>>cat[i][j];
}

bool has(int state, int i){
	return (state&(1<<i))>0;
}

string bitstr(int state){
	string ret = "";
	rep(i,n) ret += has(state,i) ? "1" : "0";
	return ret;
}

void setEdge(int state, int e[N], int* esum){
	(*esum)=0;
	rep(i,n){
		if(has(state,i)){
			e[(*esum)]=i;
			(*esum)++;
		}
	}
}

double solve_dp(){
	rep(i,2)rep(j,T)rep(k,N)memo[i][j][k]=0;
	
	int t = (1<<n);
	for(int i=m-1;i>=0;i--){
		rep(j,T)rep(k,N)memo[i%2][j][k]=0;
		rep(j,t){
			int edge[N];
			int esum = 0;
			setEdge(j, edge, &esum);
			
			rep(k,n){
				if(!has(j,k))continue;
				double maxi = 0;
				double val1=0;
				double winrate = cat[k][i];
				
				if(i!=m-1)val1 = winrate * memo[(i+1)%2][j][k];
				else val1 = winrate;
				
				maxi = max(maxi, val1);
				
				int dstate = j^(1<<k);
				rep(p,esum){
					int e = edge[p];
					if(!has(dstate,e))continue;
					maxi = max(maxi, val1 + (1-winrate)*memo[i%2][dstate][e]);
				}
				memo[i%2][j][k] = maxi;
			}
		}
	}
	
	double ans = 0;
	rep(i,n) ans = max(ans, memo[0][t-1][i]);
	
	return ans;
}
double solve(){
	
	return solve_dp();
}

int main(){
	input();
	printf("%.12f\n",solve());
}

Measured memory_bytes: 17632
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b;
    cin>>a;
    if(a[0]=='S')
    {
        cout<<"Cloudy"<<endl;
    }
    else if(a[0]=='C')
    {
       cout<<"Rainy"<<endl;
    }
    else
    {
        cout<<"Sunny"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1e11;

int main() {
	ll N,W;
	cin >> N >> W;
	vector<ll> w(N),v(N);
	ll vmax = 0;
	for(ll i=0;i<N;i++) {
		cin >> w[i] >> v[i];
		vmax += v[i];
	}

	vector<vector<ll> > dp(N+1, vector<ll>(vmax+1, INF));
	dp[0][0] = 0;

	for(ll i=1;i<=N;i++) {
		for(ll j=0;j<=vmax;j++) {
			dp[i][j] = dp[i-1][j];
			if(j >= v[i-1]) {
				dp[i][j] = min(dp[i][j], dp[i-1][j-v[i-1]] + w[i-1]);
			}
		}
	}
	ll ans = 0;
	for(ll j=0;j<=vmax;j++) {
		if(dp[N][j] <= W)
			ans = j;
	}
	cout << ans << endl;
}

Measured memory_bytes: 80256
#include <iostream>
using namespace std;
const int N=50;
typedef long long int lli;

int main(){
	lli k;
	cin >> k;
	lli q = k/N;
	int rem = k%N;
	
	lli base = N+q-1;
	cout << N << endl;
	for(int i=0; i<N; i++){
		if(i<rem){
			cout << base-rem+51;
		}else{
			cout << base-rem;
		}
		if(i==N-1){
			cout << endl;
		}else{
			cout << " ";
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s,t,u;
	int a,b;
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	if(u==s)a--;
	if(u==t)b--;
	cout<<a<<' '<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
count = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1, N):
      if abs(L[j] - L[k]) < L[i] and L[i] < L[j] + L[k]:
        count += 1
        if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
          count -= 1
print(count)

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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif

void solve() {
    int h, w, m;
    cin >> h >> w >> m;

    vector<int> H(h), W(w);
    vector<pair<int, int>> points(m);

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        points[i] = {x, y};
        H[x]++, W[y]++;
    }
    int xmx = *max_element(H.begin(), H.end());
    int ymx = *max_element(W.begin(), W.end());

    int cnt = 0, xcnt = 0, ycnt = 0;
    for (int i = 0; i < m; i++) {
        if (H[points[i].first] == xmx && W[points[i].second] == ymx) {
            ++cnt;
        }
    }
    for (int i = 0; i < h; i++) {
        if (H[i] == xmx)
            ++xcnt;
    }
    for (int i = 0; i < w; i++) {
        if (W[i] == ymx)
            ++ycnt;
    }

    cout << xmx + ymx - (xcnt * 1LL * ycnt == cnt);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


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

int F[101][10];
int P[101][11];

int main() {
    int N;
    cin >> N;

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> F[i][j];
        }
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 11; j++) {
            cin >> P[i][j];
        }
    }

    int ans = -1e9;
    for(int i = 1; i < (1<<10); i++) {
        int j = 0;
        int sum = 0;
        for(int j = 0; j < N; j++) {
            int cnt = 0;
            for(int k = 0; k < 10; k++) {
                if((i>>k & 1) & F[j][k]) cnt++;
            }
            sum += P[j][cnt];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

struct UnionFind{
	vi parent,size;
	vl sum;
	map<tuple<int,int>,tuple<int,int,int>> logs;
	UnionFind(const vi& xs):parent(xs.size(),-1),size(xs.size(),1),sum(all(xs)){}
	int Find(int i){
		return parent[i]==-1?i:Find(parent[i]);
	}
	bool Unite(int a,int b){
		int ra=Find(a),rb=Find(b);
		if(ra==rb)
			return false;
		if(size[ra]<size[rb])
			swap(ra,rb);
		logs[mt(a,b)]=mt(ra,rb,parent[ra]);
		parent[rb]=ra;
		size[ra]+=size[rb];
		sum[ra]+=sum[rb];
		return true;
	}
	void Rollback(int a,int b){
		int ra,rb,pa; tie(ra,rb,pa)=logs[mt(a,b)];
		parent[rb]=pa;
		size[ra]-=size[rb];
		sum[ra]-=sum[rb];
	}
};

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,m;cin>>n>>m&&n|m;){
		vi xs(n);
		rep(i,n) cin>>xs[i];
		vi us(m),vs(m),ws(m);
		vector<tuple<int,int,int>> es(m);
		rep(i,m){
			int u,v,w; cin>>u>>v>>w; u--,v--;
			es[i]=mt(u,v,w);
		}
		sort(all(es),[](auto a,auto b){return get<2>(a)<get<2>(b);});

		UnionFind uf(xs);

		vi used(m);
		rep(i,m){
			int u,v,w; tie(u,v,w)=es[i];
			used[i]=uf.Unite(u,v);
		}

		int res=0;
		per(i,m){
			int u,v,w; tie(u,v,w)=es[i];
			int ra=uf.Find(u),rb=uf.Find(v);
			assert(ra==rb);
			if(uf.sum[ra]>=w)
				continue;
			res++;
			if(!used[i])
				continue;
			if(uf.sum[ra]<w)
				uf.Rollback(u,v);
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 11264
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
#include <set>

inline int getInt(){ int s; scanf("%d", &s); return s; }
inline double getDouble(){ double s; scanf("%lf", &s); return s; }

using namespace std;

int main(){
  const int n = getInt();

  const int base = n + 2;
  vector<double> ans(base * 2);
  ans[base] = 1;

  REP(i,n){
    const double p = getDouble();

    vector<double> next(base * 2);
    REP(j,base*2){
      if(j != 0) next[j - 1] += ans[j] * (1 - p);
      if(j != base * 2 - 1) next[j + 1] += ans[j] * p;
    }

    ans.swap(next);
  }

  double p = 0;
  for(int i = base + 1; i < base * 2; i++)
    p += ans[i];

  printf("%.12f\n", p);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int a[3][3], b[3][3] = {};
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> a[i][j];
    }
  }
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    for (int j = 0; j < 3; ++j) {
      for (int q = 0; q < 3; ++q) {
        b[j][q] |= a[j][q] == x;
      }
    }
  }
  char ok[8] = {};
  for (int i = 0; i < 3; ++i) {
    ok[0] += b[0][i];
    ok[1] += b[1][i];
    ok[2] += b[2][i];
    ok[3] += b[i][0];
    ok[4] += b[i][1];
    ok[5] += b[i][2];
    ok[6] += b[i][i];
    ok[7] += b[i][2 - i];
  }
  if (*max_element(begin(ok), end(ok)) == 3) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	long long n, ans;
	cin >> n;
	ans = n - 1;

	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			long long x = i + n / i - 2;
			if (ans ==-1 || x < ans) {
				ans = x;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = II()
    A = LI()

    j = {}
    for a in A:
        j[a] = j.setdefault(a, 0) + 1

    # j = sorted(j.items())
    # print(j)
    for i in range(n):
        print(j.get(i+1, 0))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 33484
d = str(input())
y = int(d[0:4])
m = int(d[5:7])
d = int(d[8:])
if y <= 2018:
    print("Heisei")
    exit()
else:
    if y == 2019 and m <= 4 and d <= 30:
        print("Heisei")
        exit()
print("TBD")

Measured memory_bytes: 3060
#include <cstdlib>
#include <iostream>
#include <queue>

using namespace std;

int count = 0;

int marge(int array[], int left, int mid, int right){
    queue<int> r;
    for(int i=left; i < mid; i++){
        r.push(array[i]);
    }
    r.push(1000000001);

    queue<int> l;
    for(int i=mid; i < right; i++){
        l.push(array[i]);
    }
    l.push(1000000001);

    int count = 0;
    for(int i=left; i<right; i++){
        if( l.front() < r.front() ){
            array[i] = l.front();
            l.pop();
        }else{
            array[i] = r.front();
            r.pop();
        }
        count++;
    }

    return count;
}

int margeSort(int array[], int left,int right){
    int count = 0;
    if(right - left >= 2){
        int mid = (left + right) / 2;
        count += margeSort(array,left,mid);
        count += margeSort(array,mid,right);
        count +=  marge(array,left,mid,right);
    }

    return count;
}
       

int main(){
    int n;
    int s[500000];
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s[i];
    }

    int count = margeSort(s,0,n);

    for(int i=0; i<n; i++){
        cout << s[i];
        if(i != (n-1)){
            cout << " ";
        }
    }
    cout << endl;
    cout << count << endl;

    return 0;
}


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

int w, h, s, g;
char f[100][100];

// デバッグ
void debug(){
	for(int x=0 ; x < w ; x++ ){
		cout << ((s*2-2 == x)? '*' : ' ');
	}
	cout << endl;
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			cout << f[y][x];
		}
		cout << endl;
	}
	for(int x=0 ; x < w ; x++ ){
		cout << ((g*2-2 == x)? '*' : ' ');
	}
	cout << endl;
}

bool move(int x, int y){
	if( y == h ){ // 一番下まできたとき
		return ( x == g * 2 - 2 )? true : false;
	}
	
	if( x-1 >= 0 && f[y][x-1] == '-' ){ // 左に横棒があるとき
		return move( x-2 , y+1 );
	}else if( f[y][x+1] == '-' ){ // 右に横棒があるとき
		return move( x+2 , y+1 );
	}
	// 下に進む
	return move( x , y+1 );
}

int main(){
	int n;
	while( cin >> n , n ){
		w = 2 * n; // 幅
		
		// 初期化
		for(int x=0 ; x < 100 ; x++ ){
			for(int y=0 ; y < 100 ; y++ ){
				if( x % 2 == 0 ){
					f[y][x] = '|';
				}else{
					f[y][x] = ' ';
				}
			}
		}
		
		// 入力
		cin >> s >> g >> h;
		for(int y=0 ; y < h ; y++ ){
			string s;
			cin >> s;
			for(int i=0 ; i < s.size() ; i++ ){
				int x = i * 2 + 1;
				if( s[i] == '1' ) f[y][x] = '-';
			}
		}
		
		if( move( s*2-2 , 0 ) ){ // 線を引かなくていいとき
			cout << 0 << endl;
		}else{ // 線を引くとき
			bool flag = false;
			for(int y=0 ; y < h ; y++ ){
				for(int x=1 ; x < w ; x += 2 ){
					if( f[y][x] == '-' ) continue;
					
					if( x == 1 ){
						if( f[y][x+2] == ' ' ){
							f[y][x] = '-';
							if( move( s*2-2 , 0 ) ){
								flag = true;
								f[y][x] = '+';
								cout << (y+1) << " " << (x/2 + 1) << endl;
								break;
							}
							f[y][x] = ' ';
						}
					}else if( x == w-3 ){
						if( f[y][x-2] == ' ' ){
							f[y][x] = '-';
							if( move( s*2-2 , 0 ) ){
								flag = true;
								f[y][x] = '+';
								cout << (y+1) << " " << (x/2 + 1) << endl;
								break;
							}
							f[y][x] = ' ';
						}
					}else{
						if( f[y][x-2] == ' ' && f[y][x+2] == ' ' ){
							f[y][x] = '-';
							if( move( s*2-2 , 0 ) ){
								flag = true;
								f[y][x] = '+';
								cout << (y+1) << " " << (x/2 + 1) << endl;
								break;
							}
							f[y][x] = ' ';
						}
					}
				}
				if( flag ) break;
			}
			// debug();
			// 解がないとき
			if( flag == false ){
				cout << 1 << endl;
			}
		}
	}
}

Measured memory_bytes: 0
#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 ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(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))
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 ll mod = 1e9+7;
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; }

template<class T> inline int sgn(T n) { if (n > 0) return 1; else if (n < 0) return -1; else return 0; }

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

int main () {
  ll n, m;
  cin >> n >> m;
  
  ll m2 = m/2;
  cout << (n <= m2 ? n+(m2-n)/2 : m2) << endl;
}

Measured memory_bytes: 256
using System;

class Bubble
{
    static void Main()
    {
        double sum = 0;
        while (true)
        {
            int n = int.Parse(Console.ReadLine());
            if (n == 0)
                break;
            else
            {
                double[] sToi= new double[n];
                string[] s = Console.ReadLine().Split(' ');
                for(int i =0;i<s.Length;i++)
                {
                    sToi[i] = double.Parse(s[i]);
                    sum += sToi[i];
                }
                double avr = (double)(sum / n);
                MAth math = new MAth();
                double ans = math.StandardDiviation(sToi, avr, n);
                Console.WriteLine("{0:f4}",ans);
            }
            sum = 0;
        }
    }
}
class MAth
{
    private double numerator; //??????
    //a^2 = ((s_1-m)^2+(s_n-m)^2)/m
    public double StandardDiviation(double[] Stoi, double avr, int n)
    {

        for (int i = 0; i < Stoi.Length; i++)
        {
            numerator += Math.Pow((Stoi[i] - avr),2);
        }
        double a = Math.Sqrt(numerator / (double)n);
        return a;
    }
}

Measured memory_bytes: 9424
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int K;
    cin >> K;
    cout << (K / 2) * ((K + 1) / 2) << endl;
}


Measured memory_bytes: 256
q = int(input())
def isPrime(n) :
    if (n <= 1) :
        return False
    if (n <= 3) :
        return True

    if (n % 2 == 0 or n % 3 == 0) :
        return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

isprime = [False] * (10**5 + 1)
for i in range(1, 10**5+1):
    if isPrime(i):
        isprime[i] = True
ans = [0] * (10**5 + 1)
v = 0
for i in range(1, 10**5+1):
    if i % 2 == 1 and isprime[i] and isprime[(i+1)//2]:
        v += 1
    ans[i] = v
for i in range(q):
    l, r = map(int, input().split())
    print(ans[r] - ans[l-1])

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

int main() {
  int N;
  cin >> N;
  
  int m = 0, s = 0, t = 0;
  for (int i = 0; i < N; i++) {
    cin >> t;
    s += t;
    m = max(m, t);
  }
  cout << (s-m/2) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main(){
	ll a,b,k;
  	cin >> a >> b >> k;
  	ll r1,r2;
  	if(k>=a){
      	r1=0;
      	k-=a;
    }else{
		r1=a-k;
      	k=0;
    }
  	if(k>=b){
      	r2=0;
    }else{
		r2=b-k;
    }
  	put(r1,r2);
  	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import numpy as np

x,n = map(int,input().split())

p = list(map(int,input().split()))

m = np.array(list(range(-200,400)))
m = (m-x)**2
for i in (np.argsort(m)-200):
    if p.count(i) == 0:
        print(i)
        break



Measured memory_bytes: 27216
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <string>
#include <cstdio>
#include <cmath>
#include <iostream>


#define vpii vector< pair<int,int> >
#define vi vector<int>

#define for0(i,a) for(int i=0;i<a;i++)
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define ull              unsigned long long
#define f                first
#define s                second
#define sqr(x)           (x)*(x)
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define intlim           2147483648
#define ull              unsigned long long
// #define gcd(a, b)        __gcd(a, b)
// #define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define mk(x1,y1) make_pair(x1, y1)
#define maxl 100000
#define psz 20
#define Fin      freopen("input.txt","r",stdin)
#define Fout     freopen("output.txt","w",stdout)


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}

//bool check(int N,int pos){return (bool)(N & (1<<pos));}
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
using namespace std;
// vector<ll>prime;

// void Prime(){

// 	bool sign[maxl + 10];
// 	memset(sign, true, sizeof sign);
// 	for(ll i = 3; i <= maxl; i += 2LL){
// 		if(sign[i])
// 			for(ll j = i * i; j <= maxl; j += (i * 2LL)) sign[j] = false;
// 	}
// 	prime.pb(2LL);
// 	for(int i = 3; i <= maxl; i += 2){
// 		if(sign[i]) prime.pb(i);
// 	}

// 	int tot[maxl + 2];

// 	memset(tot, )
// }



int main(){

	ll a, b;

	scanf("%lld%lld",&a, &b);
	printf("%lld\n", a * b);

    return 0;
}








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

int main() {
  //宣言
  int N;
  vector<int> A,B;
  int ans = 0;
  
  
  //入力
  cin >> N;
  A = vector<int>(N);
  for(int i=0;i<N;i++){
  cin >> A.at(i);
  }
  
  //処理
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  
  for(int i=0;i<N;i++){
    if(i%2== 0) ans += A.at(i);
    else ans -= A.at(i);
  }
  
  
  //出力
  cout << ans << endl;
  
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,d,w;
string s,t;
//vll a,b;
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN(ll _) {
	cin >> k;
	ll val = k/2;
	cout<<(val)*(k-val);
}

int main() {
	fastio;randomINT;
	//cin>>T;
	for(ll i=1;i<=T;i++) {
		MAIN(i);
	}
	return 0;
}



Measured memory_bytes: 3616
#include<stdio.h>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
int a[105];
int b[105]={0};
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int t,x=0;
    for(t=2;t<n;t++)
    {
        int s1=0,s2=0;
        for(int i=0;i<n;i++)
        {
            if(i<t)
            {
                s1+=a[i];
            }
            else
            {
                s2+=a[i];
            }
        }
        b[x++]=abs(s1-s2);
        //printf("%d\n",b[x-1]);
    }
    sort(b,b+n-2);
    printf("%d\n",b[0]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}

ll dp[3009][3009][2];
ll a[3009];
int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i = 1 ;i <= n; i++ ){
        for(int j=0; j + i - 1 <n;j++ ){
            if(i==1){
                dp[i][j][0] = (ll)a[j];
                dp[i][j][1] = (ll)-a[j];
            }
            else{
                dp[i][j][0] = maxx(dp[i-1][j][1] + a[j+i-1], dp[i-1][j+1][1] + a[j]); 
                dp[i][j][1] = minn(dp[i-1][j][0] - a[j+i-1], dp[i-1][j+1][0] - a[j]); 
            }
            // cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<endl;
        }
    }
    cout<<dp[n][0][0];
}

Measured memory_bytes: 141568
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
  cout << min({a * x + b * y, c * 2 * min(x, y) + a * (x - min(x, y)) + b * (y - min(x, y)), c * 2 * max(x, y)}) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int d,g,ans=10000000;
void dfs(int n,vector<vector<int>>pc,vector<int>v,int sum=0,int cnt=0){
    if(n==d){
        int m=d-1;
        while(m>=0){
            auto itr = find(v.begin(),v.end(),m);
            if(itr!=v.end())
                m--;
            else
                break;
        }
        if(m>=0){
            int i=pc.at(m).at(0);
            while(sum<g&&i>1){
                sum+=100*(m+1);
                i--;
                cnt++;
            }
        }
        if(sum>=g)
            ans=min(ans,cnt);
        return;
    }
    v.push_back(n);
        dfs(n+1,pc,v,sum+pc.at(n).at(0)*((n+1)*100)+pc.at(n).at(1),cnt+pc.at(n).at(0));
//        v.push_back(n);
v.pop_back();
        dfs(n+1,pc,v,sum,cnt);
//        v.pop_back();
}

int main(){
    int tp,tc;
    cin >> d >> g;
    vector<vector<int>> pc(d,vector<int>(2));
    for(int i=0;i<d;i++)
        cin >> pc.at(i).at(0) >> pc.at(i).at(1);
    vector<int>v;
    dfs(0,pc,v);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
template<typename T>
T gcd(T x,T y){
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}
int main() {
	int num;
	cin >> num;
	vector<int> hp(num);
	for (int i = 0; i < num; ++i) {
		cin >> hp[i];
	}
	for (int i = 0; i < num; ++i) {
		hp[0] = gcd(hp[0], hp[i]);
	}
	cout << hp[0] << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

#define MAX 200010
ll fac[MAX];
ll finv[MAX];
ll inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    repr(i,2,MAX){
        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 COM(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}


int main(){
    COMinit();
    ll N,M,K; cin >> N >> M >> K;
    ll ans = 0;
    repr(i,1,N){
        ans += i*(N-i)*M%MOD*M%MOD;
        ans %= MOD;
    }
    repr(i,1,M){
        ans += i*(M-i)*N%MOD*N%MOD;
        ans %= MOD;
    }
    ans *= COM(N*M-2,K-2);
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 4992
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素因数の種類の数＋１が答え

def main():
  a, b = sorted(list(map(int, input().split())), reverse = True)
  while b != 0:
    a, b = b, a % b
  print(num_facto(a) + 1)  
  
def num_facto(n):
  ans = 0
  max_n = int((n ** 0.5) // 1) + 1
  is_prime = [True for x in range(max_n + 1)]
  is_prime[0], is_prime[1] = False, False
  for cursor in two_and_odds(max_n):
    if is_prime[cursor]:
      if n % cursor == 0:
        ans += 1
        while n % cursor == 0:
          n = n // cursor
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    ans += 1
  return ans

def two_and_odds(max_n):
  if max_n >= 2:
  	yield 2
  for i in range(3, max_n, 2):
    yield i
    
if __name__ == "__main__":
  main()


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

int main() {
	
	int n, a[100000];
	
	cin>>n;
	int i;
	for(i=0; i<n; i++){
		cin>>a[i];
	}
	
	int r = a[i-1]; //???????°????
	
	int j=-1,k=-1;
	for(int l=0 ; l<i-1; l++){
		if(a[l] <= r){
			swap(a[j+1],a[l]);
			j++;
			k++;
		}else{
			k++;
		}
	}
	swap(a[j+1],a[i-1]);
	k++;
	
	for(int l=0 ; l<n ; l++){
		if(l) cout<<" ";
		if(l == j+1){
			cout<<"["<<a[l]<<"]";
		}else{
			cout<<a[l];
		}
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
 
int main (){
  int N, count = 0, sousa = 0;
  cin >> N;
  vector<int> A(N);
  
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  for(int i = 0; i < 200; i++){
    
    for(int j = 0; j < N; j++){
      
      if(A.at(j) % 2 == 0){
        count++;
      }
    }
    if(count == N){
      for(int k = 0; k < N; k++){
        A.at(k) = A.at(k) / 2;
      }
    }
    else break;
    
    sousa++;
    count = 0;
  }
  
  cout << sousa << endl;
}
      
  
  


Measured memory_bytes: 256