akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

const int N = 1e5 + 10;
int p[N];
int n;

int get(int v) {
    return v == p[v] ? v : p[v] = get(p[v]);
}

vector<int> e[N];
int sum[N], used[N];

void addSum(int v, int val) {
    //cerr << val << ' ';
    int sgn = 2 * v > n;
    if (sgn) v = n - v;
    v = get(v);
    sum[v] += val;
}

void dfs(int u, bool& ok, vector<int>& sums, int color) {
    if (used[u]) {
        if (used[u] != color)
            ok = false;
        return;
    }
    used[u] = color;
    sums[color] += sum[u];
    for (int v : e[u])
        dfs(v, ok, sums, 3 - color);
}

bool solve(int v) {
    bool ok = true;
    vector<int> sums(3);
    dfs(v, ok, sums, 1);
    //cerr << "SOLVE:\n";
    //cerr << ok << ' ' << sums[1] << ' ' << sums[2] << '\n';
    /*
    if ((sums[1] + sums[2]) % 2)
        return false;
    if (ok && (sums[1] + sums[2]) % 26)
        return false;
    return true;
    */
    return (sums[1] + sums[2]) % 26 == 0;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    string s;
    cin >> s;
    n = s.length();
    forn(i, 0, n) p[i] = i;
    int m;
    cin >> m;
    vector<pair<int, int>> eds;
    while (m--) {
        int l, r;
        cin >> l >> r;
        --l;
        int sgn = (2 * l > n) == (2 * r > n);
        if (2 * l > n) l = n - l;
        if (2 * r > n) r = n - r;
        //cerr << l << ' ' << r << ' ' << sgn << '\n';
        /*if (sgn) {
            l = get(l);
            r = get(r);
            p[l] = r;
        } else*/ eds.eb(l, r);
    }
    for (auto q : eds) {
        int u = get(q.fs), v = get(q.sn);
        if (u == v) continue;
        e[u].eb(v);
        e[v].eb(u);
    }
    addSum(0, s[0] - 'a');
    forn(i, 1, n)
        addSum(i, s[i] - s[i - 1]);
    addSum(n, 'a' - s[n - 1]);
    //if (n % 2 == 0)
    //    addSum(n / 2, s[n / 2] - s[n / 2 - 1]);
    for (int i = 0; 2 * i <= n; ++i)
        if (get(i) == i && !used[i])
            if (!solve(i)) {
                cout << "NO\n";
                return 0;
            }
    cout << "YES\n";
}


Measured memory_bytes: 7748
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	ll N, L; cin >> N >> L;
	ll a[100100];
	ll sum = 0;
	REP(i, N)cin >> a[i];
	ll key;
	REP(i, N - 1) {
		if (sum < a[i] + a[i + 1]) {
			sum = a[i] + a[i + 1];
			key = i + 1;
		}
	}
	if (sum < L) {
		cout << "Impossible" << endl;
		return 0;
	}
	else {
		cout << "Possible" << endl;
		for (int i = N - 1; i > key; i--) {
			cout << i << endl;
		}
		for (int i = 1; i < key; ++i) {
			cout << i << endl;
		}
		cout << key << endl;
	}
	return 0;
}


Measured memory_bytes: 1536
n = int(input())
# 素数判定
import math
def is_prime(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False

    # 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    num_sqrt = math.sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step

    return True
  
# 素数列挙
def make_prime_list(num):
    if num < 2:
        return []

    prime_list = []
    for prime in range(2, num + 1):
        if is_prime(prime):
            prime_list.append(prime)
    return prime_list
  
prime_list = make_prime_list(n)
pcount={}
for p in prime_list:
    pcount[p]=0
for nn in range(2,n+1):
    for p in prime_list:
        n=nn
        if n<p:
            break
        while n%p==0:
            n//=p
            pcount[p]+=1

mcount = {}
for m in [3,5,15,25,75]:
    mcount[m]=0
for i in pcount.values():
    for j in mcount:
        if i >= j - 1:
            mcount[j] += 1
            
print(mcount[75] + mcount[5]*(mcount[5]-1)//2*(mcount[3]-2) + (mcount[3]-1)*mcount[25] + mcount[15] * (mcount[5] - 1))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    map< string,int > data;
    int n,m;
    string str;
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        cin>>str;
        if(data.find(str)==data.end()) data[str]=1;
        else data[str]++;
    }
    scanf("%d",&m);
    for(int i=0;i<m;++i){
        cin>>str;
        if(data.find(str)==data.end()) data[str]=-1;
        else data[str]--;
    }
    int maxv=0;
    for(auto itr=data.begin();itr!=data.end();++itr){
        maxv=max(itr->second,maxv);
    }
    printf("%d\n",maxv);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int A[MAX];

int partition(int p,int r) {
  int i, x, tmp;

  x = A[r];
  i = p-1;
  for (int j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      tmp=A[i]; A[i]=A[j]; A[j]=tmp;
    }
  }
  tmp=A[i+1]; A[i+1]=A[r]; A[r]=tmp;
  return i+1;
}

int main(void){
    // Your code here!
    int n, q;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &A[i]);
    }

    q = partition(0, n-1);

    for (int i = 0; i < n; i++) {
      if (i == q) {
        printf("[");
        printf("%d", A[i]);
        printf("]");
      } else {
        printf("%d", A[i]);
      }
      if (i != n-1) {
        printf(" ");
      }
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 2112
import math

s = input()

ss = s.split(" ")

TAX_A = 0.08
TAX_B = 0.1

A = int(ss[0])
B = int(ss[1])

ans = 10000
re = False
for i in range(10000,0,-1):
  tax_a = math.floor( i * TAX_A ) 
  tax_b = math.floor( i * TAX_B )
  if tax_a == A and tax_b == B:
    if i < ans :
      ans = i
      re = True

if re == True:
  print( ans )
else:
  print(-1)



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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int N, M, X, Y;
  cin >> N >> M >> X >> Y;

  int Z = -INF;
  rep(i, N) {
    int x; cin >> x;
    chmax(Z, x);
  }

  ++Z;
  bool war = false;
  if (X >= Z) Z = X + 1;
  if (Z > Y) war = true;

  rep(i, M) {
    int y; cin >> y;
    if (y < Z) war = true;
  }

  cout << (war ? "War" : "No War") << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] numbers = new int[n];
		long sum = 0;


		for(int i = 0; i < n; i++){
			numbers[i] = scanner.nextInt();
			sum += numbers[i];
		}

		Arrays.sort(numbers);

		System.out.println(numbers[0] + " " + numbers[n-1] + " " + sum);
	}
}

Measured memory_bytes: 41440
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <assert.h>
#include <numeric>

using namespace std;

const bool TEST = false;

int solve() {
    int A, B, K;
    cin >> A >> B >> K;
    
    for (int i = A; i < min(A+K, B+1); i++) {
        cout << i << endl;
    }
    
    for (int i = max(B-K+1, A+K); i <= B; i++) {
        cout << i << endl;
    }
    return 0;
}

int main() {
    solve();
    while (TEST) {
        solve();
    }
}


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

int main() {
   int N, K;
   cin >> N >> K;
   vector<ll> v(K);
  for(int i = 1; i <= N; i++) { 
      v[i % K] += 1;  
   }
    ll ans = 0;
   for(int a = 0; a < K; a++) {
       int b = (K - a) % K;
       int c = (K - b) % K;
       if((c + a) % K != 0) continue;
       ans += v[a] * v[b] * v[c];
   }

   cout << ans;
    return 0;

}

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

ll A, B, C;

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

    string ans = "NO";
    rep(i, B) {
        if (i * A % B == C) {
            ans = "YES";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,A,B;

int main(){
	cin>>n>>A>>B;
	if(A+B-1>n||n>(ll)A*B){
		cout<<-1<<endl;
		return 0;
	}
	int B_=(n+A-1)/A,T=n;
	B-=B_;
	vi a(n);
	for(int i=0;i<n;i++) a[i]=n-i;
	for(int i=0;i<B_;i++){
		reverse(a.begin()+i*A,a.begin()+i*A+min(A,T));
		T-=A;
	}
	for(int i=1;i<B_;i++){
		int t=min(A-1,B);
		reverse(a.begin()+i*A,a.begin()+i*A+t+1);
		B-=t;
	}
	for(int i=0;i<n;i++) cout<<a[i]<<" \n"[i==n-1?1:0];
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <string>

using Int = long long int;
using String = std::string;
template <class T>
using Vector = std::vector<T>;

struct {
    Vector<Int> var;
    String s;
    Int i;

    Int expr() {
        Int ret;
        if (s[i] == '(') {
            ++i;
            Int a = expr();
            char c = s[i];
            ++i;
            Int b = expr();
            ++i;

            if (c == '*') {
                ret = std::min(a, b);
            } else if (c == '+') {
                ret = std::max(a, b);
            }
        } else if (s[i] == '-') {
            ++i;
            Int a = expr();
            ret = 2 - a;
        } else if (isdigit(s[i])) {
            ret = s[i] - '0';
            ++i;
        } else if ('P' <= s[i] && s[i] <= 'R') {
            ret = var[s[i] - 'P'];
            ++i;
        }
        return ret;
    }

    Int operator()() {
        i = 0;
        return expr();
    }
} parser;

bool solve() {
    std::cin >> parser.s;
    if (parser.s == ".") return false;

    Int ans = 0;
    Vector<Int> v(3);
    for (v[0] = 0; v[0] <= 2; ++v[0]) {
        for (v[1] = 0; v[1] <= 2; ++v[1]) {
            for (v[2] = 0; v[2] <= 2; ++v[2]) {
                parser.var = v;
                if (parser() == 2) ++ans;
            }
        }
    }

    std::cout << ans << std::endl;
    return true;
}

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



Measured memory_bytes: 3220
chg={"A":0,"B":1,"C":2}
cup=[False]*3
cup[0]=True

while True:
    try:
        a,b=[ord(i)-65 for i in input().split(",")]
    except:
        break
    cup[a],cup[b]=cup[b],cup[a]
print(chr(65+cup.index(True)))

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[1<<18],S;
const ll mo=998244353;
vector<ll> V,W;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

vector<ll> hoge(vector<ll>& A,vector<ll>& B) {
	int n=A.size();
	vector<ll> R(n);
	
	if(n==1) {
		if(A[0]==0) {
			R[0]=0;
		}
		else {
			R[0]=B[0]*modpow(A[0])%mo;
		}
	}
	else {
		vector<ll> C[2],D[2],E[2];
		int i;
		FOR(i,2) C[i].resize(n/2),D[i].resize(n/2);
		FOR(i,n) {
			if(i%2==0) {
				C[0][i/2]+=A[i];
				D[0][i/2]+=B[i];
				C[1][i/2]+=A[i];
				D[1][i/2]+=B[i];
			}
			else {
				C[0][i/2]+=A[i];
				D[0][i/2]+=B[i];
				C[1][i/2]+=mo-A[i];
				D[1][i/2]+=mo-B[i];
				C[0][i/2]%=mo;
				D[0][i/2]%=mo;
				C[1][i/2]%=mo;
				D[1][i/2]%=mo;
			}
		}
		E[0]=hoge(C[0],D[0]);
		E[1]=hoge(C[1],D[1]);
		FOR(i,n) {
			if(i%2==0) {
				R[i]=(E[0][i/2]+E[1][i/2])*(mo+1)/2%mo;
			}
			else {
				R[i]=(E[0][i/2]+mo-E[1][i/2])*(mo+1)/2%mo;
			}
		}
		
	}
	
	return R;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,1<<N) {
		cin>>x;
		V.push_back(x);
		S+=x;
		if(i==0) {
			W.push_back((1<<N)-1);
		}
		else {
			W.push_back(mo-1);
		}
	}
	FOR(i,1<<N) {
		V[i]=V[i]*modpow(S)%mo;
		if(i==0) V[i]=(V[i]+mo-1)%mo;
	}
	
	auto R=hoge(V,W);
	FOR(i,1<<N) if(i) R[i]=(R[i]+mo-R[0])%mo;
	R[0]=0;
	
	FOR(i,1<<N) cout<<R[i]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 18776
#include <iostream>
#include <cmath>
using namespace std;
int x,n,a[110];
int main(void)
{
    cin>>x>>n;
    for(int i=1;i<=n;i++)
    {
        int y;
        cin>>y;
        a[y]=1;
    }
    int minn=110,now=110;
    for(int i=105;i>=0;i--)
    {
        if(!a[i]&&(fabs(i-x)<minn||fabs(i-x)==minn&&i<now))
        {
            minn=fabs(i-x);
            now=i;
        }
    }
    cout<<now<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)


int32_t main() { 
	boost;
	
	int n,x,y;
	cin>>n>>x>>y;
	int ans[n]={0};
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int d = min(j-i,abs(x-i)+abs(y-j)+1);
			ans[d]++;
		}
	}
	for(int i=1;i<n;i++)
		cout<<ans[i]<<endl;
}		     

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

int main(void){
    string s;
    int n1,n2;
    stack<int> Q;
    while (cin >> s) {
        if (s == "+"){
            n1 = Q.top();
            Q.pop();
            n2 = Q.top();
            Q.pop();
            Q.push(n1+n2);
        } else if (s == "-"){
            n1 = Q.top();
            Q.pop();
            n2 = Q.top();
            Q.pop();
            Q.push(n2-n1);
        } else if (s == "*"){
            n1 = Q.top();
            Q.pop();
            n2 = Q.top();
            Q.pop();
            Q.push(n1*n2);
        } else {
            Q.push(atoi(s.c_str()));
            
        }
    }
    cout << Q.top()<< endl;
    return 0;
}

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

int main() {
    int N,ans=0;
    cin >>N;
    vector<int> kachi(N);
    vector<int> cost(N);
    for(int i=0; i<N;i++){
        cin >> kachi.at(i);
    }
    for(int i=0; i<N;i++){
        cin >> cost.at(i);
    }
    for(int i=0;i<N;i++){
        if(kachi.at(i)-cost.at(i)>0) ans += kachi.at(i)-cost.at(i);
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
using namespace std;

int a[2000010],b[2000010],c[2000010],n;

int countingS(int a[],int b[],int k)
{
	for(int i=0;i<=k;i++)
	{
		c[i]=0;
	}
	for(int j=1;j<=n;j++)
	{
		c[a[j]]++;
	}
	for(int i=1;i<=k;i++)
	{
		c[i]+=c[i-1];
	}
	for(int j=n;j>=1;j--)
	{
		b[c[a[j]]]=a[j];
		c[a[j]]--;
	}
}

int main()
{
	cin>>n;
	for(int i=0;i<n;cin>>a[++i]);
	countingS(a,b,100000);
	for(int i=1;i<=n;i++)
	{
		if(i-1)cout<<" ";
		cout<<b[i];
	}
	cout<<endl;
	return 0;
}

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

int main() {
  // 入力
  int N;
  cin >> N;

  string tmp;

  unordered_map<string, int> s;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    // 入力をmap sに登録
    // 登録されるたびmap値を+1
    // 同じ文字列が登録された場合はmap値が増加
    s[tmp]++;
  }

  // 上と同様の処理
  int M;
  cin >> M;

  unordered_map<string, int> t;
  for (int i = 0; i < M; i++) {
    cin >> tmp;
    t[tmp]++;
  }
  // sに登録されている文字列をfor文で繰り返し処理
  int ans = 0;
  for (auto& d : s) {
    // 青カードと赤カードに登録された回数から貰える金額を計算
    ans = max(ans, d.second - t[d.first]);
  }

  // 出力
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

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

	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'P') {
			cout << 'P';
		}
		else {
			cout << 'D';
		}
	}

	return 0;
}

Measured memory_bytes: 3516
#include<stdio.h>
  
int main(){
  int i,j,n;
  int x,y,z,num = 0;
  int k;
  char c[12];
  scanf("%d",&n);
   int a[n];
  for(i = 0;i < n;i ++){
      scanf("%s %d",c,&k);
      if(c[0] == 'i')a[i] = k;
    else if(c[6] == 'F'){
      i -= 2;
      n -= 2;
    }else if(c[6] == 'L'){
    i --;
    n --;
    num ++;
      }else{
    i --;
    n --;
    x = 0;
    for(j = i;j >= 0;j --){
      if(x > 0)break;
      if(k == a[j]){
        y = i - j;
        z = 0;
        x ++;
        while(y != z){
          z ++;
          a[j + z - 1] = a[j + 1 + z - 1];
        }
        i --;
        n --;
      }
    }
      }
    }
   
  for(i = 0;i < n - num;i ++) {
      if(i == n - num - 1)printf("%d\n",a[n - 1 - i]);
      else printf("%d ",a[n - 1 - i]);
    }
  return 0;
}

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

using namespace std;

int main()
{
    int64_t a, b;
    cin >> a >> b;
    if (b % 2 == 0 && a * 2 <= b && a * 4 >= b) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void solve1();
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
int main()
{
    solve1();
    return 0;
}
void solve1()
{
    ll n;
    string a;
    cin>>n>>a;
    ll m=(((ll)a[0]-48)*100)+(((ll)a[2]-48)*10)+((ll)a[3]-48);
    //cout<<m<<endl;
    ll ans=n*m;
    ans/=100;
    cout<<ans<<endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)

int n, m;

bool can(mat& g) {
    for (int i = 1; i < n - 1; i++) {
        bool a = false, b = false;
        for (auto&& j : g[i]) {
            if (j == 0) a = true;
            if (j == n - 1) b = true;
        }
        if (a && b) return true;
    }
    return false;
}

int main() {
    FASTIO;
    cin >> n >> m;
    vector<vector<int>> g(n);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    cout << (can(g) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}

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

int main(){
    vector<vector<int>> a(3,vector<int>(3));
    vector<vector<bool>> tf(3,vector<bool>(3,false));
    rep(i,3)rep(j,3) cin >> a[i][j];
    int n;
    bool flag=false;

    cin >> n;
    for(int s=0;s<n;s++){
        int b;
        cin >> b;
        rep(i,3){
            rep(j,3){
                if(a[i][j]==b) tf[i][j]=true;
            }
        }
    }
    if(tf[0][0]==true&&tf[0][1]==true&&tf[0][2]==true) flag=true;
    if(tf[1][0]==true&&tf[1][1]==true&&tf[1][2]==true) flag=true;
    if(tf[2][0]==true&&tf[2][1]==true&&tf[2][2]==true) flag=true;

    if(tf[0][0]==true&&tf[1][0]==true&&tf[2][0]==true) flag=true;
    if(tf[0][1]==true&&tf[1][1]==true&&tf[2][1]==true) flag=true;
    if(tf[0][2]==true&&tf[1][2]==true&&tf[2][2]==true) flag=true;

    if(tf[0][0]==true&&tf[1][1]==true&&tf[2][2]==true) flag=true;
    if(tf[0][2]==true&&tf[1][1]==true&&tf[2][0]==true) flag=true;
    if(flag) cout << "Yes" << endl;
    else cout<<"No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  int N,K,x;
  double p1;
  cin >> N >> K;
  double p = 0.0;
  REP(i,N){
    x = i+1;
    p1 = 1.0;
    while(K > x){
      x *= 2;
      p1 /= 2;
    }
    p += p1;
  }
  p /= N;
  cout <<setprecision(12)<< p << endl;

  return 0;
}

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

int main() {
  int A,B,C,D,E;
  cin >>A>>B>>C>>D>>E;
  cout << ((A+9)/10+(B+9)/10+(C+9)/10+(D+9)/10+(E+9)/10)*10 
  +( min({(A-1)%10,(B-1)%10,(C-1)%10,(D-1)%10,(E-1)%10}) +1) -10 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

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

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    string S;
    cin >>S;
    ll flag=0;

    if(S=="AKIHABAR")flag++;
    if(S=="AKIHABARA")flag++;
    if(S=="AKIHABR")flag++;
    if(S=="AKIHABRA")flag++;

    if(S=="AKIHBAR")flag++;
    if(S=="AKIHBARA")flag++;
    if(S=="AKIHBR")flag++;
    if(S=="AKIHBRA")flag++;

    if(S=="KIHABAR")flag++;
    if(S=="KIHABARA")flag++;
    if(S=="KIHABR")flag++;
    if(S=="KIHABRA")flag++;

    if(S=="KIHBAR")flag++;
    if(S=="KIHBARA")flag++;
    if(S=="KIHBR")flag++;
    if(S=="KIHBRA")flag++;

    if(flag==1){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }

  return 0;
}
 


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace test
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			List<int> resultList = new List<int> ();
			string input;
			while ((input = Console.ReadLine()) != null) {
				int n = int.Parse (input);
				int answer = (n * n + n + 2) / 2;

				resultList.Add (answer);

			}

			foreach (int a in resultList) {
				Console.WriteLine (a);
			}


		}


	}
	
}

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

#define pb push_back
#define ll long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	f1(3){
		if(s[i]==s[i-1]){
			cout<<"Bad"<<endl;
			exit(0);
		}
	}
	cout << "Good" << endl;
}

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

using namespace std;

using ll = long long;

const int INF = 1145141919;

int solve(vector<int>& v) {
    if (v.size() <= 1) return 0;
    vector< vector<int> > dp(v.size(), vector<int>(4, 0));
    for (int i = 0; i + 1 < v.size(); i++) {
        dp[i + 1][0] = *max_element(dp[i].begin(), dp[i].end());
        dp[i + 1][1] = dp[i][0] + v[i];
        if (v[i] > 1) dp[i + 1][1] = max({dp[i + 1][1], dp[i][1] + v[i] - 1, dp[i][2] + 1});
        if (v[i + 1] > 1) {
            dp[i + 1][2] = dp[i][0] + v[i + 1] - 1;
            if (v[i] > 1) dp[i + 1][2] = max({dp[i + 1][2], dp[i][1] + v[i + 1] - 1, dp[i][2] + v[i + 1] - 1});
        } else {
            dp[i + 1][2] = dp[i + 1][0];
        }
        dp[i + 1][3] = dp[i][0] + v[i + 1];
        if (v[i] > 1) dp[i + 1][3] = max({dp[i + 1][3], dp[i][1] + v[i + 1], dp[i][2] + v[i + 1]});        
    }
    return *max_element(dp.back().begin(), dp.back().end());
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> v;
    v.push_back(0);
    bool flag0 = true;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '0') {
            if (flag0) {
                v.pop_back();
                ans += solve(v);
                v.clear();
                v.push_back(0);
            } else {
                v.push_back(0);
                flag0 = true;
            }
        } else {
            v.back()++;
            flag0 = false;
        }
    }
    if (flag0) v.pop_back();
    ans += solve(v);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    map<string,ll> v;
    v["AC"]=0;
    v["WA"]=0;
    v["TLE"]=0;
    v["RE"]=0;
    REP(i,n){
        string r;cin>>r;
        v.at(r)++;
    }

    vector<string> w={"AC","WA","TLE","RE"};
    REP(i,4){
        cout<<w[i]<<" x "<<v.at(w[i])<<endl;
    }
    return 0;
}


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

using namespace std;
int n, r, p, c;

int main(){
	while (cin >> n >> r && n){
		int a[55] = {};
		for (int i = 0; i < n; i++){
			a[i] = i + 1;
		}
		for (int j = 0; j < r; j++){
			cin >> p >> c;
			rotate(a + n - p - c + 1, a + n - p + 1, a + n);
		}
		cout << a[n - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
//
//  main.cpp
//  rough
//
//  Created by abhishek kumar on 22/04/20.
//  Copyright © 2020 abhishek kumar. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

bool fun(pair<ll,ll>& a,pair<ll,ll>& b)
{
    if(a.first<b.first) return true;
    if(a.first==b.first && a.second > b.second) return true;
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll items,weight,value,target;
    cin>>items>>target;
    vector<pair<ll,ll>> arr;
    arr.push_back(make_pair(0, 0));
    for(auto i=1;i<=items;i++)
    {
        cin>>weight>>value;
        arr.push_back(make_pair(weight,value));
    }
    
    sort(arr.begin(),arr.end(),fun);
    vector<vector<ll>> knapsack(items+1,vector<ll>(target+1,0));
    
    for(auto i=1;i<=items;i++)
    {
        for(auto j=1;j<=target;j++)
        {
            if(arr[i].first > j)
                knapsack[i][j]=knapsack[i-1][j];
            else
            {
                knapsack[i][j]=max(knapsack[i-1][j],arr[i].second + knapsack[i-1][j-arr[i].first]);
            }
                
        }
    }
    
    cout<<knapsack[items][target];
    
    return 0;
}

Measured memory_bytes: 80256
def upper_bound(arr, v)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    if arr[m] <= v then l = m
    else r = m
    end
  end
  r
end

EPS = 1e-9
Factorial = (1..50).each_with_object([1]) { |i, arr| arr << arr[-1] * i }

n, m, l = gets.split.map(&:to_i)
p, t, v = n.times.map{ gets.split.map(&:to_i) }.transpose
time_set = n.times.map{ [0] * (m + 1) }
prob_set = n.times.map{ [0] * (m + 1) }
n.times do |i|
  s = v[i] == 0 ? Float::INFINITY : l / v[i].to_f
  (m + 1).times do |j|
    time_set[i][j] = s + t[i] * j
    prob_set[i][j] = (p[i] / 100.0) ** j * (1 - p[i] / 100.0) ** (m - j) * Factorial[m] / Factorial[m - j] / Factorial[j]
  end
end
prob_sum = prob_set.map{ |ps| ps.reverse.each_with_object([0]){ |p, arr| arr << arr[-1] + p }[1..-1].reverse }

n.times do |i|
  ret = 0
  (m + 1).times do |j|
    prob = prob_set[i][j]
    n.times do |k|
      next if i == k
      idx = upper_bound(time_set[k], time_set[i][j] + EPS)
      if idx == m + 1
        prob = 0
        break
      end
      prob *= prob_sum[k][idx]
    end
    ret += prob
  end
  puts '%.8f' % ret
end

Measured memory_bytes: 9264
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

#define SENTINEL (1000000001)
#define putChar(c) ; *p = (char)(c); ++p;

int c = 0;
int S[500000];
int L[250001];
int R[250001];
char str[5500010];
char *p = str;

int getNum(void) {
	int n = 0;
	while ((*p >= '0') && (*p <= '9')) {
		n = n * 10 + (int)(*p - '0');
		++p;
	} 
	++p;
	return n;
}

void putNum(int n) {
	int d;
	if (n < 10) {
		putChar( '0' + n );
		return;
	}
	d = n / 10;
	if (d) putNum(d);
	putChar( '0' + (n % 10) );
}

void Merge(int A[], int left, int mid, int right) {
	int i = 0, j = 0, k = left;
	int n1 = mid - left;
	int n2 = right - mid;
	memcpy(L, A + left, n1 * sizeof(int));
	memcpy(R, A + mid, n2 * sizeof(int));
	L[n1] = R[n2] = SENTINEL;
	for (; k < right; ++k) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			++i;
		} else {
			A[k] = R[j];
			++j;
		}
	}
}

void MergeSort(int A[], int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) >> 1;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
		c += right - left;
	}
}

int main(void) {
	register int i;
	int n;
	
	fread(str, 1, 5500000, stdin);
	n = getNum();
	for (i = 0; i < n; ++i) {
		S[i] = getNum();
	}
	
	MergeSort(S, 0, n);
	
	--n;
	p = str;
	for (i = 0; i < n; ++i) {
		putNum(S[i]);
		putChar( ' ' );
	}
	putNum(S[i]);
	putChar( '\n' );
	
	putNum(c);
	putChar( '\0' );
	
	puts(str);

	return 0;
}

Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
using namespace std;
int n;

int main() {
    cin >> n;
    if(n==10||n==100||n==1000||n==10000||n==100000||n==1000000) cout << 10 << endl;
    else{
        int cnt=0;
        while(n){
            cnt += n%10;
            n/=10;
        }
        cout << cnt <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <deque>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main()
{
    int N = 0;
    int ans = 0;

    cin >> N;

    int a[N] = {};

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        if ((a[i] % 2 != 0) && ((i + 1) % 2 != 0))
            ans++;
    }

    cout << ans << endl;

    return 0;
}


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

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; }
const ll INF = 1LL << 60;

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

    int ans = A*B;    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define INF 1e12
#define all(x) (x).begin(),(x).end()
#define sz(x) int((x).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	double n; cin>>n;
	cout<<(floor(n/2)*ceil(n/2))<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

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

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

  ll n;
  cin >> n;
  ll x[n+1];
  cin >> x[n];
  rep(i,n) cin >> x[i];
  sort(x,x+n+1);
  ll s=x[n]-x[n-1];
  rep1(i,n-1){
    s = gcd(s, x[i]-x[i-1]);
  }
  cout << s << endl;
  
  return 0;
    

}


Measured memory_bytes: 1024
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n;
    cin >> n;
    int a[n],b[n];
    memset(b,-1,sizeof(b));
    int c=1;
    cin >> a[0];
    b[0]=a[0];
    for(int i=1;i<n;i++) {
        cin >> a[i];
        b[i]=min(a[i],b[i-1]);
        //cout << b[i] << " ";
        if(a[i]<=b[i])
        c++;
    }
    //cout << endl;
    cout << c;
	return 0;
    
}

Measured memory_bytes: 12032
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < a.length; ++i) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(a));

        sc.close();
    }

    static int solve(int[] a) {
        int[] sorted = Arrays.stream(a).boxed().sorted(Collections.reverseOrder()).mapToInt(x -> x).toArray();

        int aliceScore = IntStream.range(0, sorted.length).filter(i -> i % 2 == 0).map(i -> sorted[i]).sum();
        int bobScore = Arrays.stream(sorted).sum() - aliceScore;

        return aliceScore - bobScore;
    }
}

Measured memory_bytes: 28996
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
char ch[100];
string str;
int main(){
	stack<double> std;
	int i,c,j,size;
	bool flag = false;
	double a,b;
	while(getline(cin,str)){
		c = 0;
		size = str.size();
		if(str[size - 1] != '+' && str[size - 1] != '-' && str[size - 1] != '/' && str[size - 1] != '*'){
			for(i = 0;i < size;i++){
				ch[c] = str[i];
				c++;
			}
			std.push(atof(ch));
			c = 0;
		}
		else {
			for(i = 0;i < size;i++){
				if(str[i] != ' ' && str[i] != '\0'){
					if(str[i] == '+'){
						a = std.top();
						std.pop();
						b = std.top();
						std.pop();
						std.push(a+b);
						flag = true;
					}
					else if(str[i] == '/'){
						a = std.top();
						std.pop();
						b = std.top();
						std.pop();
						std.push(b/a);
						flag = true;
					}
					else if(str[i] == '*'){
						a = std.top();
						std.pop();
						b = std.top();
						std.pop();
						std.push(a*b);
						flag = true;
					}
					else if(str[i] == '-'){
						if(str[i+1] == ' ' || str[i+1] == '\0'){
							a = std.top();
							std.pop();
							b = std.top();
							std.pop();
							std.push(b-(a));
							flag = true;
						}
						else{
							ch[c] = str[i];
							c++;
							flag = false;
						}
					}
					else{
						ch[c] = str[i];
						c++;
						flag = false;
					}
				}
				else {
					if(i+1 < size){
						if(!flag) std.push(atof(ch));
						for(j = 0;j < c;j++) ch[j] = '\0';
						c = 0;
					}
				}

			}
		}
		printf("%.6f\n",std.top());
		std.pop();
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	string s;
	cin >> s;

	int min = INF;
	int x;

	REP(i, (int)s.size() - 2){
		x = stoi(s.substr(i, 3));
		if (min > abs(x - 753)) min = abs(x - 753);
	}

	cout << min << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
using namespace std;

int n,a[1000]; char s[1000009];
int main(){
	scanf("%d%s",&n,s+1);
	int i;
	for (i=1; i<=n; i++) a[s[i]]++;
	puts(a['R']>a['B']?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 2000000

int partition(int,int);
int a[MAX];

int main(){
  
  int i,n,q;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  q = partition(0,n-1);

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

  return 0;
}

int partition(int p,int r){
  int i,j,x,temp;

  x=a[r];
  i=p-1;

  for(j=p;j<r;j++){
    if(a[j]<=x){
      i=i+1;
      
      temp=a[i];
      a[i]=a[j];
      a[j]=temp;
    }
  }

  temp=a[i+1];
  a[i+1]=a[r];
  a[r]=temp;
  
  return i+1;
}

Measured memory_bytes: 996
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

ll mod_pow(ll x,ll n,ll m){
    if(n==0) return 1;
    ll res=mod_pow(x*x%m,n/2,m);
    if(n&1) res=res*x%m;
    return res;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}

int main(){
    ll n;
    cin>>n;
    V<ll> a(n);
    cinf(n,a);
    ll ans=0;
    map<ll,ll> mp;
    rep(i,n){
        map<ll,ll> res=prime_factor(a[i]);
        for(auto p:res){
            chmax(mp[p.ft],p.sc);
        }
    }
    ll L=1;
    for(auto p:mp){
        L=(L*mod_pow(p.ft,p.sc,mod))%mod;
    }
    rep(i,n){
        ans=(ans+L*mod_pow(a[i],mod-2,mod))%mod;
    }
    cout<<ans<<endl;
}

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

#define ll long long
#define P pair<int, int>
#define F first
#define S second

const ll mod = 1000000007LL;

ll dp[405][405];
ll a[405];

ll s(ll l, ll r) {
  ll sum = 0;
  for (int i = l; i <= r; i++) {
    sum += a[i];
  }
  return sum;
}

void solve() {
  ll n;
  cin >> n;

  for (int i = 0; i < n; i++) cin >> a[i];

  for (ll l = n - 1; l >= 0; l--) {
    for (ll r = l; r <= n - 1; r++) {
      if (l == r) {
        dp[l][r] = 0;
      } else {
        dp[l][r] = INTMAX_MAX;
        ll sum = s(l, r);
        for (int pivot = l; pivot < r; pivot++) {
          dp[l][r] = min(dp[l][r], dp[l][pivot] + dp[pivot + 1][r] + sum);
        }
      }
    }
  }

  cout << dp[0][n - 1];
}

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int T = 1;
  while (T--) {
    solve();
  }

  return 0;
}

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

int main(){
  unsigned long long n;
  unsigned long long c = 0;
  cin >> n;
  if (n == 1){
    cout << 1 << endl;
    return 0;
  }
  for (unsigned long long i=0;i<100000000000000;i++){
    n = n/2;
    c += pow(2,i);
    if (n == 1){
      c += pow(2,i+1);
      cout << c << endl;
      return 0;
    }
  }
  cout << "error" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 50 + 5;
const ll INF = 1ll << maxn;
ll f[maxn][maxn]; 
ll in[maxn];
ll ans;
int n;
int a[maxn], b[maxn];
int main()
{
	for(int i = 0; i <= 50; ++i) in[i] = 1;
	for(int i = 0; i <= 50; ++i)
		for(int j = 0; j <= 50; ++j)
			f[i][j] = i == j ? 0 : INF;
	for(int i = 0; i <= 50; ++i)
		for(int j = 2 * i + 1; j <= 50; ++j)
		{
			for(int k = i + 1; k <= j; ++k)
				f[i][j] = min(f[i][j], f[i][j % k] + (in[k] << k));
		}
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &b[i]);
		if(f[b[i]][a[i]] == INF)
		{
			puts("-1");
			return 0;
		}
	}
	while(true)
	{
		ll ret = 0;
		for(int i = 1; i <= n; ++i) ret = max(f[b[i]][a[i]], ret);
		if(!ret) break;
		for(int i = 50; ~i; --i) if(ret & (1ll << i)) { ans |= (1ll << i); in[i] = 0; break;}
		for(int i = 0; i <= 50; ++i)
		for(int j = 0; j <= 50; ++j)
			f[i][j] = i == j ? 0 : INF;
		for(int i = 0; i <= 50; ++i)
			for(int j = 2 * i + 1; j <= 50; ++j)
			{
				for(int k = i + 1; k <= j; ++k)
					for(int k = i + 1; k <= j; ++k)
						f[i][j] = min(f[i][j], f[i][j % k] + (in[k] << k));
			}
	}
	printf("%lld\n", ans);
	return 0;
}
				

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

map<LL,LL> S;

int main(){
	LL N,M; cin >> N >> M;
	LL x = 0;
	++S[x];
	repp(i,0,N){
		int A; cin >> A;
		x = (x+A)%M;
		++S[x];
	}
	LL ans = 0;
	for(auto u : S){
		ans += u.second * (u.second-1);
	}
	cout << ans/2 << endl;
	return 0;
}


Measured memory_bytes: 4224