akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    ll n;
    cin >> n;
    cout << 1110 - n << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
using System;

class E
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var s = Console.ReadLine();

		var dp = new int[n + 1, n + 1];
		var M = 0;
		for (var j = n - 1; j >= 0; j--)
			for (var i = j - 1; i >= 0; i--)
			{
				dp[i, j] = s[i] == s[j] ? Math.Min(dp[i + 1, j + 1] + 1, j - i) : 0;
				M = Math.Max(M, dp[i, j]);
			}
		Console.WriteLine(M);
	}
}


Measured memory_bytes: 108640
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int sum = 0;
    rep(i, 3)
    {
        int a;
        cin >> a;
        sum += a;
    }
    cout << (sum <= 21 ? "win" : "bust") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
  int A, B, len = 0;
  char s[12];
  
  scanf("%d %d", &A, &B);
  scanf("%s", s);
  
  while(s[len]){
    if(len == A && s[len] != '-'){
      break;
    } else if(len != A && (s[len] < '0' || s[len] > '9')){
      break;
    }
    len++;
  }
  
  if(len == strlen(s)){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
     int a,b,c;
     long long int k;
    scanf("%d%d%d%lld",&a,&b,&c,&k);
    int sum;
    if(k<=a)
    sum=k;
   else if((k>a)&&(k<=a+b))
    sum=a;
   else if((k>(a+b))&&(k<(a+b+c)))
    sum=a-(k-a-b);
    else if(k==a+b+c)
    sum=a-c;
    printf("%d",sum);
    return 0;
    
    
}

Measured memory_bytes: 1724
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y;
    cin>>x>>y;
    ll ans=x*y;
    if(y==1 || x==1){
        cout<<1;
        return 0;
    }
    if(y%2!=0){
    f(i,x){
        if(i%2==0){
            ans-=y/2;
        }
        else{
            ans=ans-(y/2 +1);
        }
    }
    }
    else{
        f(i,x){
            ans-=y/2;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif

string L;
int N;

ll memo[100005][2];
ll dfs(int n, int lower) {
  // l = a + b
  if (memo[n][lower] != -1)
    return memo[n][lower];
  if (n == N)
    return 1;
  if (lower == 1) {
    return memo[n][lower] = (3 * dfs(n+1, 1)) % MOD;
  }
  if (L[n] == '0')
    return memo[n][lower] = dfs(n+1, 0);
  return memo[n][lower] = (dfs(n+1, 1) + 2 * dfs(n+1, 0)) % MOD;
}

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

  cin >> L;
  N = L.size();
  rep(i, N+1)
    memo[i][0] = memo[i][1] = -1;

  cout << dfs(0, 0) << endl;

  return 0;
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

int main()
{

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

    string s,s2,s3,s4;
    cin >> s >> s2;
    s3=s , s4=s2;
    reverse(s3.begin() , s3.end());
    reverse(s4.begin() , s4.end());

    if (s4 == s && s3 == s2) cout << "YES\n";
    else cout << "NO\n";


    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
int c[25], v[25];

int main(void)
{
	cin >> n;
	for(int i = 1; i<= n; i++ ) cin >> v[i];
	for(int i = 1; i<= n; i++ ) cin >> c[i];
	
	int ans = 0;
	for(int i = 1; i<= n; i++ ) ans += max(0, v[i]-c[i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll 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()) 
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
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);

vector<int> createEratos(int n)
{
  vector<int> isprime(n+1, 1);
  isprime[0] = 0;
  isprime[1] = 0;

  for (int i = 2; i * i <= n; i++) {
    if (isprime[i]) {
      int j = i + i;
      while (j <= n) {
        isprime[j] = 0;
        j = j + i;
      }
    }
  }
  return isprime;
}

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

  int x;
  cin >> x;

  vector<int> eratos = createEratos(100003);

  for (int i = x; i <= 100003; i++) {
    if (eratos[i] == 1) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 640
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-14 20:55:16
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  long double a, b, c; cin >> a >> b >> c;

  if (c - a - b <= 0.0) {
    cout << "No" << endl; return 0;
  }

  if (a * b < ((c - a - b) / 2.0) * ((c - a - b) / 2.0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

struct s_t{
  ll x,y;
};
bool asc(s_t left,s_t right) {
  return left.x == right.x ? left.y < right.y : left.x < right.x;
}

int main(){
  ll n;
  cin>>n;
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  vector<s_t>v(n);
  s_t zz;
  for(ll i=0;i<n;i++){
    cin>>zz.x>>zz.y;
    v[i]=zz;
  }
  sort(v.begin(),v.end(),asc);
  ll p,q;
  ll tmp=0;
  ll ans=0;
  for(ll i=0;i<n-1;i++){
    for(ll j=i+1;j<n;j++){
      p=v[j].x-v[i].x;
      q=v[j].y-v[i].y;
      tmp=0;
      for(ll k=0;k<n-1;k++){
        for(ll l=k+1;l<n;l++){
          if(p==v[l].x-v[k].x&&q==v[l].y-v[k].y)tmp++;
        }
      }
      ans=max(ans,tmp);
    }
  }
  ans=n-ans;
  cout<<ans<<endl;
}


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

int main(){
     int n, m;
     cin >> n >> m;
     
     // 各頂点の位置を入力として受け取る
     vector<long long> x(m);
     for (int i = 0; i < m; i++) cin >> x[i];
     
     // コマの個数が配置場所の個数以上である場合は, 移動の必要性がない
     if (n >= m){
         cout << 0 << endl;
         return 0;
     }
     
     // 訪れられない開区間 の和を最大化するとよい
     // そのためにまずは現在のポジションを昇順にする
     sort(x.begin(),x.end());
     
     // 訪れられない開区間 の和を最大化するとよい
     // それぞれの点の間の距離を計算する
     // その後, 訪れなければならない区間の幅を小さい方から考える
     //　そのために, sortによって, 昇順に整列しておく
     vector<long long> diff(m-1);
     for (int i = 0; i < m-1; i++) diff[i] = x[i+1] - x[i];
     sort(diff.begin(),diff.end());
     
     // 大きい方からn個の区間は訪れなくて良い
     // m-n個の区間を小さい方から訪れる.
     long long ans = 0;
     for (int i = 0; i < m-n; i++) ans += diff[i];
     
     // 答えを出力しよう
    cout << ans << endl;
     return 0;
}



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

using namespace std;

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef V<pll> vpll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1
#define MAXN 100001

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

void solve()
{
	ll n , X = 0;
	cin >> n;

	ll a[n];
	fll(i, n) {
		cin >> a[i];

		X ^= a[i];
	}

	fll(i, n)
	{
		cout << ((X) ^ (a[i])) << " ";
	}
}

int main() {

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

	int t = 1;
	//cin >> t;

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


Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;


int main(){
    int n; cin >> n;
    int m=0;
    int sum=0;
    rep(i,n){
        int l; cin >> l;
        m=max(m,l);
        sum+=l;
    }
    if(sum-m>m) cout << "Yes" << endl;
    else cout << "No" << endl;
return 0;
}


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

int n;

#include <vector>
template <typename T>
void print(vector<T> vec)
{
    int n = vec.size();
    for (int i = 0; i < n; i++)
    {
        cout << vec[i] << (i == n - 1 ? "\n" : " ");
    }
}

void BubbleSort(vector<string> &C)
{
    int n = C.size();
    for (int i = 0; i < n; i++)
    {
        for (int j = n - 1; j > i; j--)
        {
            if (C[j][1] < C[j - 1][1])
            {
                swap(C[j], C[j - 1]);
            }
        }
    }
    print(C);
}

void SelectionSort(vector<string> &C)
{
    int n = C.size();
    for (int i = 0; i < n; i++)
    {
        int minj = i;
        for (int j = i; j < n; j++)
        {
            if (C[j][1] < C[minj][1])
            {
                minj = j;
            }
        }
        swap(C[i], C[minj]);
    }
    print(C);
}

int main()
{
    cin >> n;
    vector<string> v;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        v.push_back(s);
    }
    auto vv = v;
    BubbleSort(v);
    puts("Stable");
    SelectionSort(vv);
    if (v == vv)
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;
}


Measured memory_bytes: 3168
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int ans = 0;
        for(int i = 1; i<=n; i++) {
            int ic = i;
            int sum = 0;
            while(ic>0) {
                sum += ic % 10;
                ic = ic / 10;
            }
            if(sum >= a && sum <= b) {
                ans+=i;
            }
        }
        System.out.println(ans);
    }
}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 998244353
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, k = LI()
lr = []
for _ in range(k):
    l, r = LI()
    lr.append([l, r+1])
dp = [0] * (n+1)
dp[1] = 1
for i in range(1, n):
    dp[i+1] += dp[i]
    dp[i+1] %= mod
    for l, r in lr:
        dp[i+1] += dp[i+1-l] - dp[max(0, i+1-r)]
        dp[i+1] %= mod
print((dp[-1] - dp[-2]) % mod)

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

int main()
{
    int n;
    vector<int> d(3);
    cin >> n >> d[0] >> d[1] >> d[2];

    vector<pair<int, int>> q;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        int a = 0, b = 1;
        if (s == "AB")
            a = 0, b = 1;
        if (s == "AC")
            a = 0, b = 2;
        if (s == "BC")
            a = 1, b = 2;
        q.emplace_back(a, b);
    }
    string ans;
    auto add = [&](int a, int b) {
        d[a]++;
        d[b]--;
        ans += 'A' + a;
    };

    q.emplace_back(0, 1);
    for (int i = 0; i < n; i++)
    {
        int a = q[i].first;
        int b = q[i].second;
        if (!d[a] && !d[b])
        {
            cout << "No" << endl;
            return 0;
        }
        if (!d[a])
        {
            add(a, b);
        }
        else if (!d[b])
        {
            add(b, a);
        }
        else
        {
            int na = q[i + 1].first;
            int nb = q[i + 1].second;
            if (a == na || a == nb)
            {
                add(a, b);
            }
            else
            {
                add(b, a);
            }
        }
    }
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    cin >>n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i,n) cin >>s[i] >>t[i];

    string x;
    cin >>x;

    int idx = 0;
    while(s[idx] != x) ++idx;

    int ans = 0;
    for(int i=idx+1; i<n; ++i) ans += t[i];
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main(){

  ll N;
  cin >> N;
  ll a[N];
  ll sum = 0;
  ll half = 0;
  ll half_small;
  // ll half_medium;
  ll half_big;
  ll ans;
  REP(i, 0, N) {
    cin >> a[i];
    sum+=a[i];
  }
  REP(i, 0, N) {
    if (half*2 < sum) {
      half += a[i];
    }
    if (half*2 >= sum) {
      half_big = half;
      half_small = half - a[i];
      break;
    }
  }

  if (abs(sum-half_small*2) < abs(sum-half_big*2)) { // use small
    ans = (sum - half_small) - half_small;
  }
  else{ // use big
    ans = half_big - (sum - half_big);
  }

  cout << ans << endl;

  // cout << half_small << ", " << half_big << endl;

  // REP(i, 0, N)
  //   cout << a[i] << endl;

  // cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
MOD = 10 ** 9 + 7
N = int(input())
s1 = input()
s2 = input()
if s1[0] == s2[0]:
    i = 1
    ans = 3
else:
    i = 2
    ans = 6
while i < N:
    if s1[i] == s2[i]:
        if s1[i - 1] == s2[i - 1]:
            ans *= 2
        i += 1
    else:
        if s1[i - 1] == s2[i - 1]:  # 左が縦
            ans *= 2
        else:
            ans *= 3
        i += 2
    ans %= MOD
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
using namespace std;


int main() {
  int a, b;
  cin >> a >> b;
  cout << (b - a) * (b - a - 1) / 2 - a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
struct edge{int from,to,cost;};
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  vector<int> d(a),e(b);
  rep(i,a)
    cin>>d[i];
  rep(i,b)
    cin>>e[i];
  vector<int> f(c),g(c),h(c);
  rep(i,c)
    cin>>f[i]>>g[i]>>h[i];
  int ans=INF;
  rep(i,c){
  chmin(ans,d[f[i]-1]+e[g[i]-1]-h[i]);
  }
  sort(all(d));
  sort(all(e));
  chmin(ans,d[0]+e[0]);
  cout<<ans;
}

Measured memory_bytes: 5504
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

S = input()
L = len(S)

def cal(s): return ord(s)-97

bits = [0]*L
for i,s in enumerate(S):
	bits[i] = 1<<cal(s)

ans = 0
while True:
	#全部に立ってるものがあるか
	for x in range(26):
		flag = True
		for bit in bits:
			if not (bit>>x) & 1:
				flag = False
				break
		if flag:
			print(ans)
			sys.exit()

	#更新
	for i in range(L-1):
		bits[i] |= bits[i+1]
	bits.pop(-1)
	L -= 1
	ans += 1


Measured memory_bytes: 4208
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> up(N);
    vector<int> down(N);

    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if (i == 0)
            up.at(i) = a;
        else
            up.at(i) = a + up.at(i - 1);
    }
    for (int i = 0; i < N; i++)
    {
        cin >> down.at(i);
    }
    for (int i = N - 2; 0 <= i; i--)
    {
        down.at(i) += down.at(i + 1);
    }

    int m = 0;
    for (int i = 0; i < N; i++)
    {
        m = max(m, up.at(i) + down.at(i));
    }

    cout << m;
}

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

int N, A, B;

int main() {
  cin >> N >> A >> B;
  if (A < B) {
    swap(A, B);
  }
  
  if (abs(A - B) % 2 == 0) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;

  }
  
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

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

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

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

ll calccost(ll dp[],ll n,ll h[])
{
    if(dp[n]!=-1) return dp[n];
    else
    {
        if(dp[n-1]==-1) dp[n-1]=calccost(dp,n-1,h);
        if(dp[n-2]==-1) dp[n-2]=calccost(dp,n-2,h);
        return std::min(abs(h[n]-h[n-1])+dp[n-1],abs(h[n]-h[n-2])+dp[n-2]);
    }
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,f,t;
    cin >> n ;
    ll h[n+1],dp[n+1];
    repp(i,1,n+1) cin >> h[i] ;
    if(n==2) cout << h[2]-h[1];
    else
    {
        memset(dp,-1,sizeof(dp));
        dp[1]=0;
        dp[2]=abs(h[2]-h[1]);
        dp[3]=abs(h[3]-h[1]);
        cout << calccost(dp,n,h);
    }
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>

using namespace std;

void insertionSort(vector<int>& array, int N, int g, int& cnt)
{
    for(int i=g;i<N;++i)
    {
        int v = array[i];
        int j = i - g;
        while(j >= 0 && v < array[j])
        {
            array[j+g] = array[j];
            j -= g;
            ++cnt;
        }
        array[j+g] = v;
    }
}

void shell_sort(vector<int>& array, int N)
{
    vector<int> G(100);
    G[0] = 1;
    int m, count = 0;
    for(int i=0;i < 100;++i)
    {
        G[i+1] = 3 * G[i] + 1;
        if(G[i+1] > N)
        {
            m = i;
            break;
        }
    }
    cout << m+1 << endl;
    for(int i=m;i>=0;--i)
    {
        if(i != m) cout << " ";
        cout << G[i];
        insertionSort(array, N, G[i], count);
    }
    cout << endl << count << endl;
    for(int i=0;i<N;++i)
    {
        cout << array[i] << endl;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> array(N);
    for(int i=0;i<N;++i)
    {
        cin >> array[i];
    }
    shell_sort(array, N);
}



Measured memory_bytes: 6720
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
long IN(void)
{
  long x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
void Radix32(int A[],const int sz)
{
  int temp[200001];const int bit=0x8,mask=0xff;
  rep(k,0x4)
  {
    int u[0x100]={},v[0x100]={};
    rep(i,sz)u[A[i]>>bit*k&mask]++;
    rep(i,mask)u[i+1]+=u[i];
    rep(i,sz){temp[--u[A[sz-1-i]>>bit*k&mask]]=A[sz-1-i];}k++;
    rep(i,sz)v[temp[i]>>bit*k&mask]++;
    rep(i,mask)v[i+1]+=v[i];
    rep(i,sz)A[--v[temp[sz-1-i]>>bit*k&mask]]=temp[sz-1-i];
  }
}
int main(void)
{
  int N=IN(),x,p=0,m=0,z=0,minus=0,A[200000];
  long K=IN(),count=0,l=-2e18,r=-l,mid;
  rep(i,N){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  Radix32(A,m+p);
  rep(i,m)A[p+i]*=-1;
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  if(K<=1l*m*p)r=1l;else l=-1l;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
      rep(i,plus){while(1l*A[i]*A[plus]>mid){plus--;}if(i>=plus){break;}count+=1l*plus-i;}
      rep(i,minus){while(1l*A[m+p-1-i]*A[m+p-1-minus]>mid){minus--;}if(i>=minus){break;}count+=1l*minus-i;}
    }
    else{mid*=-1l;minus=1;int low=0;rep(i,m){while(1l*A[low]*A[p+i]<mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K){if(minus)r=-mid-1l;else r=mid-1l;}else{if(minus)l=-mid+1l;else l=mid+1l;}
  }
  return OUT(l),0;
}

Measured memory_bytes: 2956
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val vlist = readLine()!!.split(" ").map{it.toInt()}
    val clist = readLine()!!.split(" ").map{it.toInt()}

    var ans = 0

    for(i in 0 until n){
        if(vlist[i] - clist[i] > 0){
            ans += vlist[i] - clist[i]
        }
    }
    println(ans)
}


Measured memory_bytes: 38084
s=[13,1,2,3,4,5,6,7,8,9,10,11,12]
a,b=map(int,input().split())
if s[a-1]==s[b-1]:
  print("Draw")
elif s[a-1]<s[b-1]:
  print("Bob")
else:
  print("Alice")


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int a,b,m;
    cin>>a>>b>>m;
    vector<int>pa(a),pb(b);

    int mna = INT_MAX, mnb = INT_MAX;
    for(int i=0;i<a;i++)
        cin>>pa[i], mna = min( mna, pa[i] );
    for(int i=0;i<b;i++)
        cin>>pb[i], mnb = min( mnb, pb[i] );

    ll ans = mna + mnb;
    for(int i=0;i<m;i++)
    {
        int x,y,c;
        cin>>x>>y>>c;
        x--,y--;
        if( pa[x] + pb[y] - c < ans )
            ans = pa[x] + pb[y] - c;
    }
    cout<<ans,nl;


    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

int main() {
	int N;
	long long ans = 0;
	static pair<long long, pair<long long, long long> > PP[100000];
	cin >> N;
	for (int i = 0; i < N; i++) {
		long long A, B;
		cin >> A >> B;
		PP[i] = { A + B, {A, B} };
	}
	sort(PP, PP + N, greater<pair<long long, pair<long long, long long> > >());
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) ans += PP[i].second.first;
		else ans -= PP[i].second.second;
	}
	cout << ans;
}

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

const int MaxN = 100005;

int n, W;
long long f[MaxN];

int main() {
	scanf("%d%d", &n, &W);
	for (int i = 1; i <= n; ++ i) {
		int w, v; scanf("%d%d", &w, &v);
		for (int j = W; j - w >= 0; -- j)
			f[j] = max(f[j], f[j - w] + v);
	}
	long long Ans = 0;
	for (int i = 0; i <= W; ++ i)
		Ans = max(Ans, f[i]);
	printf("%lld\n", Ans);
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
#print(a)
sum_r = sum(a)
tmp = 0
#print(sum)
for i in range(n//2+1):
    #print(i*2)
    tmp += a[i*2]*2

b[0] = tmp-sum_r
#print(b[0])
for i in range(1,n):
    b[i] = a[i-1]*2-b[i-1]
    
print(" ".join([str(i) for i in b]))


Measured memory_bytes: 25128
while (st = $<.gets)
  xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = st.split.map(&:to_f)
  if !(xa1 > xb2 or xa2 < xb1 or ya1 > yb2 or ya2 < yb1)
    puts "YES"
  else
    puts "NO"
  end
end


Measured memory_bytes: 6848
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n;
  cin >> n;
  int a[n];
  LOOP(i,n){
    cin >> a[i];
  }
  sort(a,a+n);
  LOOP(i,n-1){
    if(a[i]==a[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm> 
#include <math.h>
#include <vector>
using namespace std;

int main(){
	
	long long x,k,d;
	cin >> x >> k >> d;
	if(abs(x)>=d && k>=abs(x)/d){
		k-=abs(x)/d;
		x%=d;
		if(k%2==1){
			x=abs(x)-d;
		}
	}
	else if (k<=abs(x)/d){
		x=abs(x)-k*d;
	}
	else{
		if(k%2==1){
			x=abs(x)-d;
		}
	}
	
	
	
	cout << abs(x);
}




Measured memory_bytes: 3148
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, P):
    P.sort()

    p1 = 0
    p2 = 0
    p3 = 0
    for p in P:
        if p <= A:
            p1 += 1
        elif p <= B:
            p2 += 1
        else:
            p3 += 1

    return min(p1, p2, p3)


def main():
    N = read_int()
    A, B = read_int_n()
    P = read_int_n()
    print(slv(N, A, B, P))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7740
#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 INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll n,m;
vector<ll> a;

int main(){
    ll n,m;
    cin>>n>>m;
    ll ans;

    //とりあえずあるだけでscc作る
    if(n*2>=m){
        ans=m/2;
        n-=m/2;
        m=m%2;
    }
    else{
        ans=n;
        m-=2*n;
        n=0;
    }
    cout<<ans+m/4<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int a[3];
	cin >> a[0]>> a[1]>> a[2];
    sort(a,a+3);
      cout << a[0]+a[2]-a[1] << endl;
}

Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<String,Map<Integer,Integer>> restaurants = new TreeMap<>();

		int N=sc.nextInt();


		for(int i=0;i<N;i++) {
			String str = sc.next();
			int n = sc.nextInt();
			if(!restaurants.containsKey(str)) {
				restaurants.put(str, new TreeMap<>(Comparator.reverseOrder()));
			}
			restaurants.get(str).put(n,i+1);
		}

		for(Map.Entry<String,Map<Integer,Integer>> e: restaurants.entrySet()) {
			for(Map.Entry<Integer,Integer> ee : e.getValue().entrySet()) {
				System.out.println(ee.getValue());
			}
		}
	}
}


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

int main() {
    
    long long int n,k;
    cin>>n>>k;
     long long int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h,h+n);
     long long int sum=0;
    for(int i=0;i<n;i++){
        sum=sum+h[i];
    }
    if(k==0){
        cout<<sum<<endl;
    }else if(k>=n){
        cout<<"0"<<endl;
        
    }else{
        for(int i=n-1;i>=n-k;i--){
            sum=sum-h[i];
        }
        cout<<sum<<endl;
    }
    
    
    
    
	return 0;
}

Measured memory_bytes: 1792
import math
n = int(input())
x = list(map(int,input().split()))
k = sum(x)/n
h = 0
if (math.ceil(k)-k)**2 <= (math.ceil(k)-k-1)**2:
    h = math.ceil(k)
else:
    h = math.ceil(k)-1
def m(a,h):
    return((a-h)**2)

y = []
for i in range(n):
    y.append((x[i]-h)**2)

print(sum(y))

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

class Amondai
{
    static void Main()
    {
        var line = new List<int>();
        for (int i=0;i<6;++i)
        {
            line.Add(Int32.Parse(Console.ReadLine()));
        }
        var canable = true;
        for (int i=0;i<4;++i)
        {
            for (int j=i+1;j<5;++j)
            {
                if (line[5] < Math.Abs(line[j] - line[i])) canable = false;
            }
        }
        Console.WriteLine(canable? "Yay!":":(");
    }
}

Measured memory_bytes: 11092
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B, C = get_ints

if A + B >= C
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 14528
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int a[100001];
int main(){
    int n,x;
    while(cin>>n>>x){
        for(int i=0;i<n;i++){
            scanf("%d",a+i);
        }
        long long int sum=0,t;
        for(int i=1;i<n;i++){
            t=a[i]+a[i-1]-x;
            if(t>0){
                sum+=t;
                if(t>a[i])a[i]=0;
                else a[i]-=t;
            }
        }
        cout<<sum<<endl;
    }
return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

class Main {

    public static void main(String[] args) throws IOException {
        ReaderB.init(System.in);
        int n = ReaderB.nextInt();
        Integer[] a = new Integer[n];
        for (int i = 0; i < a.length; i++) a[i] = ReaderB.nextInt();
        Arrays.sort(a, Comparator.reverseOrder());
        int alice = 0, bob = 0;
        for (int i = 0; i < a.length; i++) {
            if (i % 2 == 0) alice += a[i];
            else bob += a[i];
        }
        System.out.println(alice - bob);
    }
}

/**
 * Reader class based on the article at "https://www.cpe.ku.ac.th/~jim/java-io.html"
 */
class ReaderB {
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    static void init(InputStream inputStream) {
        reader = new BufferedReader(new InputStreamReader(inputStream));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

//    static long nextLong() throws IOException {
//        return Long.parseLong(next());
//    }
//
//    //    Get a whole line.
//    static String line() throws IOException {
//        return reader.readLine();
//    }
//
//    static double nextDouble() throws IOException {
//        return Double.parseDouble(next());
//    }
}



Measured memory_bytes: 24532
from itertools import permutations
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(m)]
MAP=[[] for _ in range(n)]
for a,b in AB:
    MAP[a-1].append(b-1)
    MAP[b-1].append(a-1)

ans=0
for A in permutations(range(n),n):
    if A[0]==0:
        for i in range(n):
            if i==n-1:
                ans +=1
                break
            if A[i+1] not in MAP[A[i]]:break
print(ans)

Measured memory_bytes: 73112
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
      int[] b = new int[a];
      int c = sc.nextInt();
      int d = 0;
      for(int i = 0; i < a; i++){
      	b[i] = sc.nextInt();
      }
        for (int i = 0; i < a- 1; i++) {
            for (int j = a - 1; j > i; j--) {
                if (b[j - 1] > b[j]) {
                    // 入れ替え
                    int tmp = b[j - 1];
                    b[j - 1] = b[j];
                    b[j] = tmp;
                }
             }
        }
      for(int i = 0; i < c; i++){
      	d += b[i];
      }
  
      System.out.println(d);
	}
}

Measured memory_bytes: 38884
N = int(input())
s = [100] * 15
k = 0
for i in range (15):
    if N == 0:
        break
    s[i] = N%26
    N = (N - 1)//26
    k += 1
for i in range(k):
    if s[i] == 0:
        s[i] = 122
    else:
        s[i] = s[i] + 96
for i in range(k):
    print(chr(s[k - 1 - i]),end = "")
print()

Measured memory_bytes: 9192
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String T = sc.nextLine();
	    int N = S.length();
	    if (S.equals(T)) {
	    	System.out.println("Yes");
	    	return;
	    }
	    
	    for (int i = 0; i < N; i++) {
	    	char last = S.charAt(N - 1);
	    	S = last + S.substring(0, N - 1);
		    if (S.equals(T)) {
		    	System.out.println("Yes");
		    	return;
		    }
	    }
	    
    	System.out.println("No");
	}
}

Measured memory_bytes: 25044
N, M, K = map(int, input().split())

flag = False
for i in range(M+1):
  for j in range(N+1):
    tmp = N*i + M*j - 2*i*j
    if tmp == K:
      flag = True
      break
      
if flag:
  print('Yes')
else:
  print('No')

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

const ll mod = 1e9 + 7;

ll powmod(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b % 2) {
      ans *= a;
      ans %= mod;
    }
    a *= a;
    a %= mod;
    b /= 2;
  }
  return ans;
}

int main() {
  ll n;
  cin >> n;

  vector<ll> c(n);
  for (ll i = 0; i < n; i++) {
    cin >> c[i];
  }
  
  sort(c.begin(), c.end(), greater<ll>());

  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ans += ((c[i] * (i + 2)) % mod * powmod(4, n - 1)) % mod;
    ans %= mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
string ans = "Yes";

int main()
{
string s ;
cin >> s ;
rep(i,s.size()){
  if(s[i]!=s[s.size()-1-i])ans = "No";
}
rep(i,s.size()/2){
  if(s[i]!=s[s.size()/2-1-i])ans = "No";
}
rep(i,s.size()/2){
  if(s[i+s.size()/2+1]!=s[s.size()-1-i])ans = "No";
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];


int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    int cnt = 0;
    rep(i,n){
        if(i%2==0&&a[i]%2==1) cnt++;
    }
    cout << cnt <<endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int d, t, s;
  cin >> d >> t >> s;
  if (s*t >= d)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 3648
n, m = map(int, input().split())
l, r = [0] * m, [0] * m

for i in range(m):
    l[i], r[i] = map(int, input().split())

lma, rmi = max(l), min(r)

if lma > rmi:
    print(0)
else:
    if rmi <= n:
        print(rmi - lma + 1)
    elif lma <= n:
        print(n - lma + 1)
    else:
        print(0)


Measured memory_bytes: 10868
from itertools import*
from fractions import*
n,*a=map(int,open(0).read().split())
b=list(accumulate([0]+a,gcd))
c=list(accumulate([0]+a[::-1],gcd))
print(max(gcd(s,t)for s,t in zip(b,c[::-1][1:])))

Measured memory_bytes: 16124
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	int flag = 0;
	cin >> n;
	for(int i = 1; i <= 9; ++i) {
		if(n % i == 0 && n / i <= 9) {
			flag = 1;
			break;	
		}
	}
	if(flag)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
	return 0;
}


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H;
    cin >> H;
    int h = 0;
    while (H > 0) {
        H >>= 1;
        h++;
    }
    cout << (1ll << h) - 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
void solve(int w, int sti, int counts[], int *ans){
	if( w < 0 ) return ;
	if( w == 0 ){
		int value = 0;
		const int dv[] = {380,550,850};
		const double ar[] = {0.80, 0.85, 0.88};
		for(int i = 0; i < sizeof(dv)/sizeof(*dv); i++){
			value += (counts[i]%(5-i)) * dv[i];
			value += (int)ceil(dv[i] * ( counts[i] - (counts[i]%(5-i)) ) * ar[i]);
		}
		*ans = min(*ans, value);
	}else{
		int dw[] = {200,300,500};
		for(int i = sti; i < sizeof(dw)/sizeof(dw[0]); i++){
			w -= dw[i];
			counts[i]++;
			solve(w, i, counts, ans);
			counts[i]--;
			w += dw[i];
		}
	}
}
int main(void){
	while(true){
		int w, ans = 10000, cnts[3]={0,};

		cin>>w;
		if(w==0)break;

		solve(w, 0, cnts, &ans);
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 0