akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	string s; int w; cin >> s >> w;
	string ans;
	for (int i = 0; i < s.size(); i += w) ans.push_back(s[i]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from subprocess import*
call(('pypy3','-c',"""
def main():
  def update(k,x):
    k+=N0-1
    data_min[k]=data_max[k]=x
    while k>=0:
      k=(k-1)//2
      a,b=data_min[2*k+1],data_min[2*k+2]
      data_min[k]=a if a<b else b
      a,b=data_max[2*k+1],data_max[2*k+2]
      data_max[k]=a if a>b else b
  def query_min(l,r):
    L,R=l+N0,r+N0
    s=INF
    while L<R:
      if R&1:
        R-=1
        t=data_min[R-1]
        if t<s:s=t
      if L&1:
        t=data_min[L-1]
        if t<s:s=t
        L+=1
      L//=2
      R//=2
    return s
  def query_max(l,r):
    L,R=l+N0,r+N0
    s=0
    while L<R:
      if R&1:
        R-=1
        t=data_max[R-1]
        if t>s:s=t
      if L&1:
        t=data_max[L-1]
        if t>s:s=t
        L+=1
      L//=2
      R//=2
    return s
  n,k,*p=map(int,open(0).read().split())
  N0=2**(n-1).bit_length()
  INF=10**18
  data_min=[INF]*2*N0
  data_max=[0]*2*N0
  c=[0]
  for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
  *c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
  x=not f
  for i,q in enumerate(p):update(i,q)
  for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    if not c and(a!=query_min(i,i+k)or b!=query_max(i+1,i+k+1)):x+=1
  print(x+f)
main()
"""))

Measured memory_bytes: 106920
#include<iostream>
#include<stack>
using namespace std;
int main(){
		stack<int>s;
		int a;
		while(cin>>a){
				if(a==0){
						//if(s.size()==0)break;
						cout<<s.top()<<endl;
						s.pop();
				}
				else{
						s.push(a);
				}
		}
		return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;
// 変数初期化
vector<ll> bsv; // binary_search用のvector
ll a,b,c,n,m;
typedef pair<ll, ll> Pll;
vector<Pll> facts; // 素因数分解の結果格納用(基数:乗数)
vector<vector<ll> > bit_search_v; //nit全探索の結果格納用

// index が条件を満たすかどうか
bool isOK(ll index, ll key) {
    if (bsv[index] >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(int key) {
    int ng = -1;
    int ok = (ll)bsv.size();

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    // OK(key以上となる)のindex番号を返す
    return ok;
}

// 最大公約数
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

// 最小公倍数
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

//　素因数分解
void prime_fact(ll target){
    ll base=2, exp=0;
    while (base*base<=target) {
        while (target%base==0) {
            target /= base; exp++;
        }
        if (exp>0) {
            facts.push_back(make_pair(base, exp));
        }
        base++; exp=0;
    }
    if (target>1) facts.push_back(make_pair(target,1));
}
// prime_factの結果の確認用
void print_facts(){
    for (int i=0; i<facts.size(); i++) {
        cout << facts[i].first << " " << facts[i].second << endl;
    }
}

// bit全探索
void bit_search(ll target){
    for (ll i=0; i<(1<<target); ++i) {
        if (i==0) continue;
        vector<ll> v;
        for (ll j=0; j<target; ++j) {
            if (i&(1<<j)) v.push_back(j);
            if (i&(1<<j)) cout << i << "  :  " << j << endl;
        }
        bit_search_v.push_back(v);
    }
}
// bit全探索の結果確認用
void print_bit_search(){
    for (ll i=0; i<bit_search_v.size(); ++i) {
        for (ll j=0; j<bit_search_v[i].size(); ++j) {
            cout << bit_search_v[i][j] << " ";
        }
        cout << endl;
    }
}



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

    ll n,k;
    cin >> n >> k;
    vector<ll> A(n);
    for(ll i = 0; i < n;i++){
        cin >> A[i];
    }
    vector<ll> s(n,-1);
    ll cnt = n;
    ll nn = 1;
    ll a = 0;
    for(ll i = 0; i < n+1;i++){
        if(s[nn-1] != -1){
            a = s[nn-1];
            cnt = i-s[nn-1];
            break;
        }
        if(i == k) break;
        s[nn-1] = i;
        nn = A[nn-1];
    }


    k = (k-a)%(cnt);
    ll now = 1;
    for(ll i = 0; i < a;i++){
        now = A[now-1];
    }
    for(ll i = 0; i < k;i++){
        now = A[now-1];
    }

    cout << now << endl;

    return 0;
}

Measured memory_bytes: 5984
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
  }
  
  macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
  
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
  }
  
  macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
  
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
  
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
  
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
  
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
  }



fn main() {
    input!{
        d: i64,
        t: i64,
        s: i64
    }
    println!("{}", if d <= t*s {"Yes"} else {"No"})
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;
typedef pair<ll, ll> pint;

const int MOD = 1000000007;
void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll A[N+1];
    A[0] = 0;
    rep(i, N) {
        cin >> A[i+1];
    }

    vector<ll> tmp;
    bool prev[N+1];
    rep(i, N+1) {
        prev[i] = false;
    }
    ll ind = 1;
    while(!prev[ind]) {
        prev[ind] = true;
        tmp.push_back(ind);
        ind = A[ind];
    }

    ll indd;
    rep(i, tmp.size()) {
        if (tmp[i] == ind) {
            indd = i;
        }
    }

    if (K <= indd) {
        cout << tmp[K] << endl;
    } else{
        K -= indd;
        ll length = tmp.size() - indd;
//        cout << length << endl;
//        cout << m << endl;
//        cout << K << endl;
//        cout << K % length << endl;
        int m = K % length;
//        cout << m << endl;
        cout << tmp[indd + m] << endl;
    };



}

Measured memory_bytes: 7064
n = gets.to_i
ss = gets.chomp.chars
ans = ss.count("R") * ss.count("G") * ss.count("B")

0.upto(n) do |i|
  1.upto(n) do |j|
    k = i + 2 * j
    next unless k < n

    a = ss[i]
    b = ss[i + j]
    c = ss[k]
    ans -= 1 if a != b && b != c && c != a
  end
end

puts ans


Measured memory_bytes: 14396
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    while(1)
    {
        int n,m;
        cin>>n>>m;if(!n)return 0;
        int v[1000];
        for(int i=0;i<n;++i){
            cin>>v[i];
        }
        sort(v,v+n);
        reverse(v,v+n);
        int res=0;
        for(int i=0;i<n;){
            if(n-i>=m){
                for(int j=0;j<m-1;++j){
                    res+=v[i];
                    i++;
                }
                i++;
            }else{
                res+=v[i];
                i++;
            }
        }
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 1176
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;
  
public class Main {  
    public static void main(String[] args) throws IOException { 
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
		StringTokenizer st = new StringTokenizer(br.readLine()); 
		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());
		if (n==k) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

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

string s;

int main(){
	cin >> s;
	if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad" << endl;
	else cout << "Good" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class FactInvMOD:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        # 階乗テーブル
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        # 階乗の逆元テーブル
        inverse = [1] * MAX
        # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, 0, -1):
            # 最後から戻っていくこのループならMAX回powするより処理が速い
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせの数 (必要な階乗と逆元のテーブルを事前に作っておく) """

        if n < r: return 0
        # 10C7 = 10C3
        r = min(r, n-r)
        # 分子の計算
        numerator = self.fact[n]
        # 分母の計算
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

    def nPr(self, n, r):
        """ 順列 """

        if n < r: return 0
        return self.fact[n] * self.inv[n-r] % self.MOD

    def nHr(self, n, r):
        """ 重複組み合わせ """

        # r個選ぶところにN-1個の仕切りを入れる
        return self.nCr(r+n-1, r)

x, y = MAP()

x, y = min(x, y), max(x, y)
sm = x + y
if sm % 3 != 0:
    print(0)
    exit()
if y - x > sm // 3:
    print(0)
    exit()

# 連立方程式から式変形
a = (2*y-x) // 3
b = (2*x-y) // 3

fim = FactInvMOD(a+b, MOD)
print(fim.nCr(a+b, a))


Measured memory_bytes: 49136
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy";
    else if(s=="Cloudy") cout<<"Rainy";
    else cout<<"Sunny";
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    if(s == "ABC") print("ARC");
    else print("ABC");


}




Measured memory_bytes: 3660
N = int(input())
r_stars = [tuple(map(int, input().split())) for _ in range(N)]
b_stars = [tuple(map(int, input().split())) for _ in range(N)]

r_stars.sort()
b_stars.sort()
cnt = 0
r_paired = {}
for bs in b_stars:
  rx = ry = -1
  for rs in r_stars:
    if rs[0] < bs[0] and rs[1] < bs[1] and not rs in r_paired:
      if ry < rs[1]:
        rx, ry = rs[0], rs[1]
  if rx != -1:
    cnt += 1
    r_paired[(rx, ry)] = 1
print(cnt)
    

Measured memory_bytes: 3064
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> color;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    auto itr = lower_bound(color.begin(), color.end(), a, greater_equal<int>());
    if (itr == color.end())
      color.push_back(a);
    else
      *itr = a;
  }
  cout << color.size() << endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u)
        a--;
    else
        b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
# include<iostream>
# include<algorithm>
# include<cctype>
# include<cstdio>
# include<cstring>
# include<cmath>
using namespace std;
int main()
{
      string s;
      cin >> s;
      int a[256];
      memset(a, 0, sizeof(a));
      int flag = 0;
      for (int i=0; i<4; i++)
      {
            if (a[s[i]]>=1) a[s[i]]++;
            if (a[s[i]]==0) a[s[i]]++;
            if (a[s[i]]==2) flag++;
      }
      if (flag==2) 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)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int facctorialMethod(int k) {
  int sum = 1;
  for (int i = 1; i <= k; ++i) {
    sum *= i;
  }
  return sum;
}

int main() {
  int n;
  cin >> n;
  vector<P> p;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    p.push_back(make_pair(x, y));
  }

  vector<vector<double> > dist(n, vector<double>(n));  // 各都市間の所要時間
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int x = p[i].first - p[j].first;
      int y = p[i].second - p[j].second;
      dist[i][j] = sqrt(x * x + y * y);
    }
  }

  vector<int> order(n);
  rep(i, n) order[i] = i;

  double ans = 0;
  do {
    /* 順序 order についての所要時間を計算 */
    double temp_dist = 0;
    for (int i = 1; i < n; ++i) {
      temp_dist += dist[order[i - 1]][order[i]];
    }
    ans += temp_dist;
  } while (next_permutation(order.begin(), order.end()));

  ans = ans / facctorialMethod(n);

  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 3800
#include <cstdio>
#include <vector>

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

  std::vector<int> V(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &V[i]);
  }
  for (int i = 0; i < N; ++i) {
    int C;
    scanf("%d", &C);
    V[i] -= C;
  }

  int result = 0;
  for (int v: V) {
    if (v >= 0) result += v;
  }

  printf("%d\n", result);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	string S;
	cin >> S;
	REP(i, S.size()) S[i] = 'x';
	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<climits>//上限値
// #include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#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)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


void printVector(const std::vector<double>& vec) {
	for (double value : vec) {
		std::cout << value << " ";
	}
	std::cout << std::endl;
}
int main()
{
	std::string S,ans = "";
	std::cin >> S;
	for ( int i = 0 ; i < 3 ; i++ ) {
		ans += S[i];
	}
	std::cout << ans << std::endl;
	return 0;
}










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

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

    if(n[0]==n[1]&&n[1]==n[2]){
            cout<<"Yes"<<endl;

    }
    else if(n[1]==n[2]&&n[2]==n[3]){
          cout<<"Yes"<<endl;


    }else{
          cout<<"No"<<endl;



    }



}


Measured memory_bytes: 256
Up, Frnt, Rt, Lft, Bk, Dwn = *(0...6)

def check(d)
  4.times.map{
    d = [d[Rt], d[Frnt], d[Dwn], d[Up], d[Bk], d[Lft]]
    4.times.map {
      d = [d[Up], d[Rt], d[Bk], d[Frnt], d[Lft], d[Dwn]]
      4.times.map {
        d = [d[Frnt], d[Dwn], d[Rt], d[Lft], d[Up], d[Bk]]
      }
    }
  }.flatten(2).uniq
end

@dir = check((0...6).to_a)

Conn = [[],
        [[0, Lft, Rt]],
        [[0, Bk, Frnt]],
        [[1, Bk, Frnt], [2, Lft, Rt]],
        [[0, Up, Dwn]],
        [[1, Up, Dwn], [4, Lft, Rt]],
        [[2, Up, Dwn], [4, Bk, Frnt]],
        [[3, Up, Dwn], [5, Bk, Frnt], [6, Lft, Rt]]
]

def dfs(pos)
  return true if pos == 8
  (1...8).each do |to|
    next if @index[0,pos].include?(to)
    @dir.each do |d|
      ok = true
      Conn[pos].each do |from, to_d, from_d|
        a = @dice[to][d[to_d]]
        b = @dice[@index[from]][@layout[from][from_d]]
        if (a.ord - b.ord).abs != 32
          ok = false
          break
        end
      end
      if ok
        @layout[pos] = d
        @index[pos] = to
        return true if dfs(pos + 1)
      end
    end
  end
  false
end

def solve
  @dir.each do |d|
    @layout = [d]
    return true if dfs(1)
  end
  false
end

while (l = gets.chomp) != '0'
  @dice = [l.split(''), *7.times.map{gets.chomp.split('')}]
  @index = [0]
  puts solve ? 'YES' : 'NO'
end

Measured memory_bytes: 8744
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define pi 3.141592653589793238462
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll k;
 cin>>k;
 ll a,b;
 cin>>a>>b;
 bool ff=0;
 for(ll i=a;i<=b;i++)
 {
  if(i%k==0)
    ff=1;
 }
 if(ff)
     cout<<"OK";
 else
    cout<<"NG";
 cout<<"\n";
 return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007



ll n, ans = 1,now = 0;
string a, b;

int main() {
	cin >> n;
	cin >> a >> b;
	REP(i, a.size()) {
		if (a[i] == b[i]) {
			if (now == 0) ans *= 3;
			else if (now == 2) ans *= 2;
			now = 2;
		}
		else {
			if (now == 0)ans *= 6;
			else if (now == 1)ans *= 3;
			else ans *= 2;
			now = 1;
			i++;
		}
		ans %= MOD;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>

#define numof(array) (sizeof (array) / sizeof *(array))
using namespace std;

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

#define MAX_X 100
#define MAX_Y 100

int H, W;
char field[MAX_Y][MAX_X];

void dfs(const int x, const int y, const char fruit_now)//現在位置(x,y) つながっているところを全部'.'にする
{
    field[y][x] = '.';

    for (int i = 0; i < 4; i++) {
        //移動後の座標
        int x_new = x + dx[i];
        int y_new = y + dy[i];
        
        if (0 <= x_new && x_new < W && 0 <= y_new && y_new < H && field[y_new][x_new] == fruit_now) dfs(x_new, y_new, fruit_now);

    }
}
               
int main(void)
{
    while (true) {
        cin >> H >> W;
    
        if (H == 0 && W == 0) break;

        int cnt = 0;
        for (int j = 0; j < MAX_Y; j++) {
            for (int i = 0; i < MAX_X; i++) {
                field[j][i] = '.';//初期化
            }
        }

        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                scanf(" %c ", &field[y][x]);//入力
            }
        
        }   

        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                if (field[y][x] != '.') {
                    dfs(x, y, field[y][x]);
                    cnt++;
                }
            }
        }

        cout << cnt << endl;
    }
	return 0;
}

Measured memory_bytes: 1668
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		int a = Integer.parseInt(reader.readLine());
		int b = 100000;
		for (int i = 0; i < a; i++) {
			b += (int) (Math.ceil(b * 0.05 / 1000) * 1000);
		}
		System.out.println(b);

	}

}

Measured memory_bytes: 16852
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
#include <limits>
#include <climits>
#include <functional>
#include <numeric>

using namespace std;

#define alloc(type,n) (type*)calloc(sizeof(type),(n));
typedef long long lli;


int main(){
    int a,b;
    cin >> a >> b;
    a = (a + 14 - 2) % 14;
    b = (b + 14 - 2) % 14;
    if(a<b){
        cout << "Bob" << endl;
    }else if(a > b){
        cout << "Alice" << endl;
    }else{
        cout << "Draw" << endl;
    }
	return 0;
}


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

using namespace std;
using ll = long long;

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

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

  auto isok = [&](int m) -> bool {
    int sum = 0;
    for (auto aa : a)
      sum += (aa + m - 1) / m - 1;
    return sum <= k;
  };

  int l = 0;
  int r = 1e9;
  while (r - l > 1) {
    int m = l + (r - l) / 2;
    if (isok(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << r << endl;

  return 0;
}


Measured memory_bytes: 3936
import java.util.Scanner;

/***/

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

        int in = sc.nextInt();

        String out = "Christmas";

        int count = Math.abs(25 - in);
        while (count != 0) {
            out += " Eve";
            count--;
        }

        System.out.println(out);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[2][9] = {{0, 1, -1, 2, -2, 0, 1, -1, 0}, {0, 1, -1, 2, -2, 0, 1, -1, 0}};
const int dx[2][9] = {{1, 1, 1, 1, 1, 2, 2, 2, 3}, {-1, -1, -1, -1, -1, -2, -2, -2, -3}};
const int MAX_N = 70;
char field[MAX_N][MAX_N];
int dist[MAX_N][MAX_N][2];
int h, w;
struct edge 
{
    int cost;
    int y, x;
    bool flag;
    bool operator > (const edge &d) const
    {
        return d.cost < cost;
    }
};
int dijkstra(int y, int x, bool foot)
{
    priority_queue<edge, vector<edge>, greater<edge>> que;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) for(int k = 0; k < 2; k++) dist[i][j][k] = INF;
    dist[y][x][foot] = 0;
    edge v = {0, y, x, foot};
    que.push(v);
    while(!que.empty())
    {
        edge p = que.top();
        que.pop();
        int ty = p.y;
        int tx = p.x;
        bool flag = (p.flag ? false : true);
        if(dist[ty][tx][p.flag] < p.cost) continue;
        for(int i = 0; i < 9; i++)
        {
            int ny = ty + dy[flag][i];
            int nx = tx + dx[flag][i];
            if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
            if(field[ny][nx] == 'X' || field[ny][nx] == 'S') continue; 
            int cost = 0;
            if(field[ny][nx] != 'T') cost = field[ny][nx] - '0';
            if(dist[ny][nx][flag] > dist[ty][tx][p.flag] + cost)
            {
                dist[ny][nx][flag] = dist[ty][tx][p.flag] + cost;
                edge tmp = {cost, ny, nx, flag};
                que.push(tmp);
            }
        }
    }
    int ret = INF;
    for(int j = 0; j < w; j++)
    {
        if(field[0][j] != 'T') continue;
        for(int k = 0; k < 2; k++) ret = min(dist[0][j][k], ret);
    }
    return ret;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> w >> h, w | h)
    {
        int ans = INF;
        vector<P> start;
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                char ch;
                cin >> ch;
                if(ch == 'S') start.push_back(P(i, j));
                field[i][j] = ch;
            }
        }
        for(int i = 0; i < start.size(); i++)
        {
            for(int j = 0; j < 2; j++)
            {
                ans = min(dijkstra(start[i].first, start[i].second, j), ans);
            }
        }
        cout << (ans == INF ? -1 : ans) << endl;
    }
    return 0;
}


Measured memory_bytes: 3972
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n, m = LI()
num = LI()

ans = 0
D = defaultdict(int)
D[0] += 1
ret = 0
for i in range(n):
    ret = (ret + num[i]) % m
    ans += D[ret]
    D[ret] += 1


print(ans)

Measured memory_bytes: 57584
import math
import numpy as np
x = int(input())
for i in range(1, 10**6):
	b_tmp = np.power(i, 5) - x
	b = round(np.power(max(b_tmp, -b_tmp), 0.2), 10)
	if float.is_integer(b):
		if b_tmp < 0:
			print(i, int(-b))
			break
		else:
			print(i, int(b))
			break

Measured memory_bytes: 27224
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 100050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n, m;
char s[N];
pii dp[N];
int pre[N];
multiset<pair<int, int>> S;
vector<int> ans;

void solve()
{
    scanf("%d%d", &n, &m);
    scanf("%s", s);
    for (int i = 0; i <= n; ++i)
        dp[i] = {inf, i};
    dp[0].first = 0;
    dp[0].second = 0;
    S.insert({0, 0});
    int L = 0;
    pre[0] = -1;
    for (int i = 1; i <= n; ++i)
    {
        while (i - L > m)
            S.erase(S.find(dp[L])), L++;
        if (s[i] == '0')
        {
            dp[i] = mp((*S.begin()).first + 1, i);
            pre[i] = (*S.begin()).second;
        }
        S.insert(dp[i]);
    }

    // for (int i = 0; i <= n; ++i)
    //     printf("%d ", dp[i]);
    if (dp[n].first >= inf)
        return puts("-1"), void();
    for (int i = n; ~i; i = pre[i])
        if (pre[i] != -1)
            ans.pb(i - pre[i]);
    for (int i = ans.size() - 1; i >= 0; --i)
        printf("%d ", ans[i]);
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

ll n;
cin >> n;

ll a=0;
ll b=0;
ll min_num;
ll min_ans=10000000000000;
ll A=0;
ll B=0;

for(int i=2;i<1000001;i++){
    if(n%i==0){
        a=i;
        b=n/i;
        min_num=a+b-2;
        if(min_num<min_ans){
            min_ans=min_num;
            A=a;B=b;
        }
    }
}

if(min_ans==10000000000000)cout<<n-1<<endl;
else cout << A+B-2 << endl;



return 0;
}



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

using namespace std;

#ifndef errOut
#define errOut(s)
#endif

int calc(const std::string& s) {
  int const n = static_cast<int>(s.length());
  int ret = 0;
  for (int i = 1; i < n; ++i) {
    if (s[i] == 'W') {
      continue;
    }
    ++ret;
  }
  if (ret == 0) {
    return 0;
  }
  int turn = ret;
  for (int leader = 1; leader < n; ++leader) {
    if (s[leader - 1] == 'W') {
      ++turn;
    }
    if (s[leader] == 'E') {
      --turn;
    }
    if (turn == 0) {
      return 0;
    }
    ret = std::min(turn, ret);
  }
  return ret;
}

int main() {
  int n;
  std::string s;
  std::cin >> n >> s;
  int ret = calc(s);
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, ans = 0;
  cin >> n;
  vector<int> v(n), c(n);
  for(int i=0;i<n;i++) cin >> v[i];
  for(int i=0;i<n;i++) cin >> c[i];
  for(int i=0;i<n;i++) ans += max(0, v[i] - c[i]);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


struct con{
    ll s,a,b,c;
};
bool comp(con x,con y){
    return x.s<y.s;
}
 
int main(){fastio
    ll n,k;cin>>n>>k;
    if(2*k-1>n){
        cout<<-1<<endl;return 0;
    }
    vector<con>v;
    ll p=n/2;
    rep(i,0,p-1){
        con d;
        d.a=k+i;
        d.b=k+2*n-p+i;
        v.pb(d);
    }
    rep(i,p,n-1){
        con d;
        d.a=k+i;
        d.b=k+n-p+i;
        v.pb(d);
    }
    rep(i,0,n-1){
        v[i].s=v[i].a+v[i].b;
    }
    sort(v.begin(),v.end(),comp);
    //for(auto x:v)cout<<x.a<<" "<<x.b<<endl;
    
    rep(i,0,n-1){
        v[i].c=k+2*n+i;
    }
    rep(i,0,n-1){
        cout<<v[i].a<<" "<<v[i].b<<" "<<v[i].c<<endl;
    }
    
    
    
    return 0;
}




Measured memory_bytes: 6384
import java.util.*;
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<N; i++ ){
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		long ans = 0;      
		if( N%2==1 ){
			if( N==1 && a[0]==0 ){
				ans = 1;              
            }           
			for( int i=1; i<N; i+=2 ){
				if( a[i]!=a[i+1] && a[i]!=i+1 ){
					ans = 0;		
					break;
				}      
				if( i==N-2 && a[0]==0 ){
					ans = 2;
					for( int j=0; j<N/2-1; j++ ){
						ans = 2*ans;
							ans = ans%1000000007L; 
					}             
				}
			}  
		}
		if( N%2==0 ){
			for( int i=0; i<N; i+=2 ){
				if( !( a[i]==a[i+1] && a[i]==i+1 ) ){
					ans = 0;
					break;
				}
				if( i==N-2 ){
					ans = 2;
					for( int j=0; j<N/2-1; j++ ){
						ans = 2*ans;
							ans = ans%1000000007L;
					}                 
				}
			}
		}  
		System.out.println(ans);
	}
}


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

int main(){
    string s;
    cin >> s;
    
    for ( int i = 0; i < 3; i++ ) {
        cout << (s[i] == '1' ? '9' : '1' ) ;
    }
    cout << endl;
    
    return (0);
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e13;
const ll MOD = 1000000007;  // 1e9 + 7

const ll MAX_V = (ll)1e5 + 5;

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, w;
  cin >> n >> w;
  vector<ll> dp(MAX_V+1, INF); // dp[v] .. minimum cost for achive v.
  dp[0] = 0;
  rep(i, n) {
    ll wi, vi;
    cin >> wi >> vi;
    for (ll j = MAX_V; j >= 0; --j) { // loop all value
      if (j-vi >= 0) {
        chmin(dp[j], dp[j-vi] + wi);
      }
    }
  }
  // Here, all cost is calculated
  ll ans = 0;
  rep(i, MAX_V+1) {
    if (dp[i] <= w) {
      chmax(ans, i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int,int>;

void solve_8(){//7m
    string a, b;
    cin >> a >> b;
    string tmp =  a+b;
    int c = atoi(tmp.c_str());
    //cout << c << endl;
    int c_square = sqrt(c);
    cout << (c_square * c_square == c? "Yes": "No") << endl;
    
}

void solve_8re(){
    string a, b;
    cin >> a >> b;
    //stoi -> int
    //stol -> long
    //stof -> float
    int c = stoi(a+b);
    int c_square = sqrt(c);
    cout << (c_square * c_square == c? "Yes": "No")<< endl;
}

void solve_9(){//12m
    int n,k;
    cin >> n >> k;
    int sum_distance = 0;
    rep(i, n){
        int x;
        cin >> x;
        sum_distance += 2 * min(x, k-x);
    }
    cout << sum_distance;
}

void solve_10(){
    int n;
    cin >> n;
    priority_queue<int> pq;
    int a;
    rep(i, n){
        cin >> a;
        pq.push(a);
    }
    int alice = 0, bob = 0;
    int turn = 0;
    while(!pq.empty()){
        a = pq.top();
        pq.pop();
        if (turn % 2 == 0){
            alice += a;
        }
        else{
            bob+=a;
        }
        turn += 1;
    }
    cout << alice - bob;
    
}

void solve_D(){
    
}

void solve_E(){
    
}

void solve_F(){
    
}

int main(){
    //solve_8re();
    //solve_9();
    solve_10();
    //solve_D();
    //solve_E();
    //solve_F();
    return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10;
char s[N];
int nxt[N],n;
ll l,r,cnt[26],sum[N][26];
vector<ll> len;
vector<vector<ll> > S;

vector<ll> solve(ll x){
    if(x <= n) return vector<ll>(sum[x],sum[x]+26);
    int p = upper_bound(all(len) , x) - len.begin() - 1;
    vector<ll> res = S[p] , gt = solve(x - len[p]);
    rep(i,0,26) res[i] += gt[i];
    return res;
}

int main(){
    scanf("%s%lld%lld",s+1,&l,&r);
    n=strlen(s+1) / 2;
    nxt[1]=0;
    for(int i=2,j=0;i<=n;++i){
        while(j&&s[j+1]!=s[i]) j=nxt[j];
        nxt[i]=s[j+1]==s[i]?++j:j;
    }
    rep(i,1,n+1) rep(j,0,26) sum[i][j]=sum[i-1][j]+(s[i]-'a'==j);
    int period = n - nxt[n];
    if(n % period == 0) {
        rep(i,1,period+1) {
            cnt[s[i] - 'a'] += (r + period - i) / period - (l - 1 + period - i) / period;
        }
    } else {
        vector<ll> A(sum[n],sum[n]+26);
        len.pb(n);S.pb(A);
        rep(i,0,26) A[i]+=sum[period][i];
        len.pb(n+period);S.pb(A);
        while(len[sz(len)-1]<r) {
            len.pb(len[sz(len)-1]+len[sz(len)-2]);
            A=*S.rbegin();
            rep(i,0,26) A[i]+=S[sz(S)-2][i];
            S.pb(A);
        }
        vector<ll> L = solve(l - 1) , R = solve(r);
        rep(i,0,26) cnt[i] = R[i] - L[i];
    }
    rep(i,0,26) printf("%lld%c",cnt[i]," \n"[i==25]);
    return 0;
}


Measured memory_bytes: 23040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		int max = 0;
		for(int i = 0; i < n; i++) {
			num[i] = sc.nextInt();
			max += num[i];
		}
		int m = sc.nextInt();
		for(int i = 0; i < m; i++) {
			System.out.println(max - num[sc.nextInt()-1] + sc.nextInt());
		}
	}
}

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)

#define long long long
template<class T> using PQ = priority_queue<T>;
template<class T> using PQg = priority_queue<T, vector<T>, greater<T>>;

#define all(v) begin(v), end(v)
#define ln << endl
const int MOD = 1e9 + 7;


int main() {
    int N; cin >> N;
    vector<long> A(N); times(N, i) cin >> A[i];

    set<long> s0 = {0};
    times(N, i) s0.insert(A[i]);
    int s = s0.size();
    vector<long> vs;
    for(auto& v: s0) vs.push_back(v);
    map<long, int> vm;
    times(s, j) vm[vs[j]] = j;

    vector<int> g(s, 0);
    times(N, i) g[vm[A[i]]]++;
    rtimes(s-1, j) g[j] += g[j+1];

    if(0) {
        times(s, j) cout << vs[j] << ' '; cout ln;
        times(s, j) cout << g[j] << ' '; cout ln;
    }

    long now = 0;
    times(N, i) {
        if(A[i] <= now)
            cout << 0 ln;
        else {
            long a = 0;
            upto(vm[now]+1, vm[A[i]], k) {
                a += g[k] * (vs[k] - vs[k-1]); //cout << k << a ln;
            }
            cout << a ln;
            now = A[i];
        }
    }

    return 0;
}


Measured memory_bytes: 13944