akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn maxi(vs: Vec<usize>) -> (usize, usize) {
    let mut max = (0, 0);
    for (i, v) in vs.iter().enumerate() {
        if v > &max.1 {
            max = (i, *v);
        }
    }
    max
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut a = a;
    let mut alice = 0;
    let mut bob = 0;
    for i in 0..a.len() {
        let (j, k) = maxi(a.clone());
        a.remove(j);
        if i % 2 == 0 {
            alice+=k;
        } else {
            bob+=k;
        }
    }
    println!("{}", alice - bob);
}

Measured memory_bytes: 4352
from fractions import gcd
n = int(input())
lis = list(map(int, input().split()))
x = [lis[0]]
y = [lis[-1]]
for i in range(n - 1):
    x.append(gcd(x[-1], lis[i + 1]))
    y.append(gcd(y[-1], lis[n - i - 2]))
ans = max(x[-2], y[-2])
for i in range(1, n - 1):
    ans = max(ans, gcd(x[i - 1], y[-i - 2]))
print(ans)

Measured memory_bytes: 16148
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i++)

string itos(int n){
  string s="";
  while(n){
    s = char(n%10+'0') + s;
    n/=10;
  }
  return s;
}
string merge(int a,int b){
  return itos(a) + itos(b);
}
int stoi(string s){
  int r=0;
  rep(i,s.size())r = r * 10 + s[i] - '0';
  return r;
}
int main(void){
  int n;
  cin>>n;
  //cout<<itos(n)<<endl;
  vector<int> in(n);
  rep(i,n)cin>>in[i];
  sort(in.begin(),in.end());
  //rep(i,n)cout<<in[i]<<endl;
  int select[4];
  rep(i,4)select[i] = in[i];
  vector<int> result;
  for(int i = 0 ; i < 4 ; i ++){
    for(int j = 0 ; j < 4 ; j ++){
      if(i == j) continue;
      result.push_back(stoi(merge(select[i],select[j])));
    }
  }
  sort(result.begin(),result.end());
  cout<<result[2]<<endl;
  //*/
}

Measured memory_bytes: 1260
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] X = new long[N];
        for (int i = 0; i < N; i++) {
            X[i] = scan.nextLong() - i;
        }
        Arrays.sort(X);
        System.out.println(solve(N, X));
    }
    public static long solve(int N, long[] X) {
        long answer = (X[N-1] - X[0]) * N / 2;
        long left = X[0];
        long right = X[N-1];
        while (left + 2 < right) {
            long first_candidate = (right - left) / 3 + left;
            long second_candidate = (right - left) * 2 / 3 + left;
            long first_answer = cal(N, X, first_candidate);
            long second_answer = cal(N, X, second_candidate);
            if (first_answer < second_answer) {
                right = second_candidate;
                answer = second_answer;
            } else {
                left = first_candidate;
                answer = first_answer;
            }
        }
        answer = Math.min(answer, cal(N, X, left));
        answer = Math.min(answer, cal(N, X, left+1));
        answer = Math.min(answer, cal(N, X, left+2));
        return answer;
    }
    private static long cal(int N, long[] X, long b) {
        long answer = 0;
        for(long x : X) {
            answer += Math.abs(x - b);
        }
        return answer;
    }
}


Measured memory_bytes: 65112
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <utility>
#include <string>

#define loop(n) for(ll i=0;i<n;i++)

using namespace std;

typedef long long int ll;

constexpr int maxn = 100;

int main() {
    int n,m,d[maxn + 1][maxn + 1],e[maxn + 1][maxn + 1];
    for(int i = 0;i < maxn + 1;i++) for(int j = 0;j < maxn + 1;j++) d[i][j] = e[i][j] = 10000;
    scanf("%d %d",&n,&m);
    for(int i = 0;i < m;i++) {
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        d[a][b] = d[b][a] = e[a][b] = e[b][a] = c;
    }
    for(int i = 1;i <= n;i++) {
        d[i][i] = e[i][i] = 0;
    }
    for(int i = 1;i <= n;i++) for(int j = 1;j <= n;j++) for(int k = 1;k <= n;k++)
        e[j][k] = min(e[j][k],e[j][i]+e[i][k]);

    int cnt = 0;
    for(int i = 1;i <= n;i++) for(int j = 1;j <= n;j++) if(d[i][j] != 10000 && d[i][j] > e[i][j]) cnt++;

    printf("%d",cnt/2);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <bits/extc++.h>
#include <atcoder/all>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
const int maxn=500005;
//i_am_noob
int t,n,m,a,b;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> t;
  	while(t--){
      	cin >> n >> m >> a >> b;
      	print1(floor_sum(n,m,a,b));
    }
    return 0;
}


Measured memory_bytes: 3640
N,M  = [int(x)for x in input().split()]

a = [0 for i in range(N+8)]

for i in range(M):
    a[int(input())] = 1

DP = [0 for i in range(N+8)]
DP[0] = 1
DP[1] = 1
if a[1] == 1:
    DP[1] = 0
for i in range(2,N+1):
    if a[i] == 0:
        DP[i] = (DP[i-2]+DP[i-1])
        if DP[i] >1000000007:
            DP[i] %=1000000007
    else:
        pass
#print(DP)
print(DP[N])


Measured memory_bytes: 7880
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(long L, long R)
        {
            R = Math.Min(L + 2019, R);
            long min = long.MaxValue;
            for (long i = L; i <= R; ++i)
            {
                for (long j = i + 1; j <= R; ++j)
                {
                    min = Math.Min(i * j % 2019, min);
                }
            }
            return min;
        }

        static void Main(string[] args)
        {
            var V = ReadLongs();
            Console.WriteLine(Solve(V[0], V[1]));
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[1000005],L=-1e18,R=1e18,mod=1e9+7,Mid;
long long check(long long x){
	long long res=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]<0)
		{
			long long L=i,R=n;
			while(R-L>1)
			{
				long long mid=L+R>>1;
				if(a[i]*a[mid]<=x) R=mid;
				else L=mid;
			}
			res+=n-R;
		}
		else
		{
			long long L=i,R=n;
			while(R-L>1)
			{
				long long mid=L+R>>1;
				if(a[i]*a[mid]<=x) L=mid;
				else R=mid;
			}
			res+=L-i;
		}
	}
	return res;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	while(R-L>1)
	{
		Mid=L+R>>1;
		if(check(Mid)<k) L=Mid;
		else R=Mid;
	}
	cout<<R;
	return 0;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define TASK "C-large"
#pragma comment(linker, "/STACK:1710886400")
#include <stdio.h>
#include <iostream>
#include <iomanip> 
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <assert.h>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <complex>
using namespace std;

const int MOD = 1000000007;
const int INF = 1000000007;
const long double EPS = 1e-6;
const int HASH_POW = 29;
const long double PI = acos(-1.0);
mt19937_64 rnd(1);

double workTime() {
	return double(clock()) / CLOCKS_PER_SEC;
}

void my_return(int code) {
#ifdef MYDEBUG
	cout << "\nTime = " << fixed << setprecision(3) << workTime() << endl;
#endif
	exit(code);
}

int n;
bool used[100010];
vector <int> G[100010];

int dfs(int v) {
	used[v] = true;
	int ans = 0;
	for (int i = 0; i < G[v].size(); ++i) {
		int to = G[v][i];
		if (!used[to]) {
			ans ^= dfs(to) + 1;
		}
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef MYDEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	/*freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);*/
#endif

	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d %d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}

	int res = dfs(1);
	if (res != 0) {
		printf("Alice\n");
	}
	else {
		printf("Bob\n");
	}

	my_return(0);
}

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

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

  int n;
  cin >> n;
  vector<ll> L(n);
  rep(i, 0, n) cin >> L[i];
  sort(L.begin(), L.end());

  ll ans = 0;
  rep(b, 0, n) {
    rep(a, 0, b) {
      int ab = L[a] + L[b];
      int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
      int l = b + 1;
      ans += max(0, r - l);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    sx, sy, tx, ty = input_int_list()
    dx, dy = tx - sx, ty - sy
    ans = "R" * dx + "U" * dy + "L" * dx + "D" * dy + "L" + "U" * (dy + 1) + "R" * (dx + 1) + "DR" + "D" * (dy + 1) + "L" * (dx + 1) + "U"
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61712
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <fstream>

using namespace std;

int main()
{
    int N;

    cin >> N;

    int rest;
    int N_500 = N / 500;
    rest = N - N_500 * 500;

    int N_5 = rest / 5;

    cout << N_500 * 1000 + N_5 * 5 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1){
		int n, k, m;
		cin >> n >> k >> m;
		if ( n == 0 && k == 0 && m == 0 ) break;

		int ans = 0;
		for(int i = 1; i < n; i++) {
			ans = ( ans + k ) % ( i );
		}
		ans = ( ans + m ) % n + 1 ;
		cout << ans << endl;
 	}

	//while(1){}
    return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int a = in.nextInt();
        int b = in.nextInt();

        int aa = a + a - 1;
        int ab = a + b;
        int bb = b + b - 1;
        int answer = Math.max(aa, Math.max(ab, bb));
        out.println(answer);
    }
}


Measured memory_bytes: 21844
#include <cstdio>

constexpr int mod = 1000000007;
int t;

int inv[16];

int binom(int n, int k){
  long long int r = 1;
  for(int i = 0; i < k; i++){
    r = r * (n-i) % mod;
    r = r * inv[i+1] % mod;
  }
  return r;
}


/*
[x^N] 1 / [(1-x)^16(1+x)^5]
[x^N] 1 / [(1-x)^11(1-x^2)^5]
[x^N] (1+x)^11 / (1-x^2)^16
*/


int main(){
  scanf("%d", &t);
  inv[1] = 1;
  for(int i = 2; i <= 15; ++i){
    inv[i] = mod - (long long) inv[mod % i] * (mod / i) % mod;
  }
  while(t--){
    int n;
    scanf("%d", &n);
    if(n < 5){
      puts("0");
      continue;
    }
    n -= 5;
    long long int r = 0;
    for(int i = n/2; 2*i >= n-11; --i){
      r = (r + (long long) binom(i+15, 15) * binom(11, n-2*i)) % mod;
    }
    printf("%lld\n", r);
  }

  return 0;
}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  while (n) {
    n /= k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node();
    int u = scanner.nextInt() - 1;
    int v = scanner.nextInt() - 1;
    for (int i = 0; i < N - 1; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nodes[a].adjacent.add(nodes[b]);
      nodes[b].adjacent.add(nodes[a]);
    }

    dfs(nodes[v], null);
    List<Node> path = dfs2(nodes[v], null, nodes[u]);
    Collections.reverse(path);
    int max = 0;
    for (int i = path.size() - path.size() / 2; i < path.size(); i++) {
      max = Math.max(max, i + path.get(i).level - 1);
    }
    System.out.println(max);
  }

  private static int dfs(Node node, Node from) {
    int level = -1;
    for (Node a : node.adjacent) {
      if (a != from) {
        level = Math.max(level, dfs(a, node));
      }
    }
    node.level = level + 1;
    return node.level;
  }

  private static List<Node> dfs2(Node node, Node from, Node target) {
    if (node == target) {
      List<Node> list = new ArrayList<>();
      list.add(target);
      return list;
    }
    for (Node a : node.adjacent) {
      if (a != from) {
        List<Node> list = dfs2(a, node, target);
        if (list != null) {
          list.add(node);
          return list;
        }
      }
    }
    return null;
  }

  private static class Node {
    private final List<Node> adjacent = new ArrayList<>();
    private int level;
  }
}


Measured memory_bytes: 112048
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
typedef pair<int,int> P;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
	int x;
	cin>>x;
	rep(i,-300,301){
		rep(j,-300,301){
			int a=i*i*i*i*i;
			int b=j*j*j*j*j;
			if(a-b==x){
				cout<<i<<' '<<j<<endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3520
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    T.append(int(input()))
T = sorted(T)

cnt = 0
t = 0

while t < N:
    cnt += 1
    s = t
    while t < N and T[t] - T[s] <= K and t - s < C:
        t += 1
print(cnt)

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

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int64_t r=0,g=0,b=0;
  for(int i=0;i<n;i++)
  {
    if(s.at(i)=='R')
      r++;
    else if(s.at(i)=='G')
      g++;
    else
      b++;
  }
  int64_t sum=r*g*b;
  
 
      for (int j = 1; j <= n; j++)
      {
        for (int i = 1; i < n-1; i++)
        {
            if (i-j<0||i+j>n-1) continue;
            if (s[i-j]!=s[i+j] && s[i-j]!=s[i] && s[i]!=s[i+j]) sum--;
        }
      }
          cout<<sum<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    string s, t, r;
    cin >> s >> t;
    r = t + s;
    cout << r;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld n;
  cin >> n;
  cout << n + n * n + n * n * n << "\n";
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  ll n;cin>>n;
  ll r[3] = {2,1,3};
  if(n<=2){
    cout<<r[n];
    return 0;
  }
  rep(i,n-2){
    ll t = r[1]+r[2];
    r[0]=r[1];
    r[1]=r[2];
    r[2]=t;
  }

  cout<<r[2];
  return 0;
}

Measured memory_bytes: 384
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define mk make_pair
# define fr first
# define sc second

using namespace std;
int n,ans;
int main(){
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		int x=i,z=0;
		while(x>0)
		x/=10,z++;
		if(z%2)ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 256
import sys

A = [i+1 for i in range(100)]
B = [0 for i in range(100)]

a = [0 for i in range(100)]

for l in sys.stdin:
    a.append(int(l))

# for i in range(4):
#     a[i] = int(input())

for x in a:
    if x in A:
        B[x-1] += 1

max = max(B)

for i in range(100):
    if  B[i] == max:
        print(i+1)


Measured memory_bytes: 5608
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scan(&x)
	max := 1
	for i := 2; i < x; i++ {
		xx := i * i
		for xx <= x {
			if xx > max {
				max = xx
			}
			xx *= i
		}
	}
	fmt.Println(max)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LL long long
using namespace std;
#define inf 0x3fffffff

int n,m;
struct data
{
    int c[500010];
    void init()
    {
        memset(c,0,sizeof(c));
    }
    void change(int x,int y)
    {
        for (;x<=n;x+=x&-x)
            c[x]+=y;
    }
    int query(int x)
    {
        int res=0;
        for (;x;x-=x&-x)
            res+=c[x];
        return res;
    }
}a[26];
char s[500010],t[10];
int q;

int main()
{
    scanf("%d%s%d",&n,s+1,&q);
    for (int i=0;i<26;i++)
        a[i].init();
    for (int i=1;i<=n;i++)
        a[s[i]-'a'].change(i,1);
    int x,l,r;
    while(q--)
    {
        scanf("%d",&x);
        if (x==1)
        {
            scanf("%d%s",&x,t+1);
            a[s[x]-'a'].change(x,-1);
            s[x]=t[1];
            a[s[x]-'a'].change(x,1);
        }
        else
        {
            scanf("%d%d",&l,&r);
            int ans=0;
            for (int i=0;i<26;i++)
            {
                if (a[i].query(r)-a[i].query(l-1)>0) ans++;
            }
            printf("%d\n",ans);
        }
        
    }
    return 0;
}

Measured memory_bytes: 51584
// Contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include"iostream"
#include"string"
#include"vector"
#include"algorithm"

using namespace std;

int main()
{
	/*int n,k;
	cin >> n;
	vector<char>s(n);
	for (int j = 0; j < n; j++)  cin >> s[j];
	cin >> k;
	for (int i = 0; i < n; i++)
	{
		if (s[i] != s[k-1]) {
			s[i] = '*';
		}
	}

	for (int l = 0; l < n; l++)
	{
		cout << s[l] ;
	}*/
	int n;
	cin >> n;
	cout<<3*n*n<<endl;
	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

ll dp[100000 + 1];

int main(void) {
    int N, W;
    cin >> N >> W;

    for (int i = 0; i < N; i++) {
        int w, v;
        cin >> w >> v;
        for (int j = W; j >= w; j--) {
            chmax(dp[j], dp[j - w] + v);
        }
    }

    cout << dp[W] << endl;
    return 0;
}

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

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

    int sam=0;
    for(int i=0;i<C;i++){
        int a;
        cin >> a;
        sam += a;
    }
    if(N>=sam){
        cout << 1 << endl;
    }
    else if(sam%(N+1)!=0){
        cout << (sam/(N+1)) + 1 << endl;
    }
    else{
        cout << sam/(N+1) << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
#define M 100

int k = 0;

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/* バブルソート */
void bubble_sort(int A[], int N) {
  int i, j;

  for (i = 0; i < N - 1; i++){
    for (j = N - 1; j >= i + 1; j--){   //　右から左に操作
      if (A[j] < A[j-1]) { swap(&A[j], &A[j-1]); k += 1; }
    }
  }
}

int main (void) {
  int A[M];
  int i;
  int N;
  scanf("%d", &N);
  for(i = 0; i < N; i++){scanf("%d", &A[i]);}

  bubble_sort(A, N);

  for (i = 0; i < N; i++){
    if(i == 0)printf("%d", A[i]);
    else printf(" %d", A[i]);}
  printf("\n%d\n", k);

  return 0;
}



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

#define REP(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
    int n, ans = 0; cin >> n;
    int array[n - 1]; REP(i, n - 1) cin >> array[i];
                                                                       
    ans += array[0] + array[n - 2]; 

    for(int i = 0; i < n - 2; i++)
        ans += min(array[i], array[i + 1]);
    cout << ans;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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()){
        cout << "x";
    }
    cout << "\n";

return 0;
}

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

template<typename T>
struct SegTree {
  typedef function<T(T, T)> F;
  int n;
  vector<T> d;
  T def;
  F f;
  F g;

  SegTree(int _n, T def, F f, F g, string v="")
      : def(def), f(f), g(g) {
    init(_n);
    build(_n, v);
  }
  void init(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    d = vector<T>(2*n-1, def);
  }
  void build(int _n, string v) {
    if (_n != (int)v.size()) return;
    for (int i=0; i<_n; i++) d[i+n-1] = v[i];
    for (int i=n-2; i>=0; i--) d[i] = f(d[2*i+1], d[2*i+2]);
  }
  void update(int k, T a) {
    k += n-1;
    d[k] = g(d[k], a);
    while (k > 0) {
      k = (k-1)/2;
      d[k] = f(d[k*2+1], d[k*2+2]);
    }
  }
  T _query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return def;
    if (a <= l && r <= b) return d[k];
    else {
      T vl = _query(a, b, k*2+1, l, (l+r)/2);
      T vr = _query(a, b, k*2+2, (l+r)/2, r);
      return f(vl, vr);
    }
  }
  T query(int a, int b) {
    return _query(a, b, 0, 0, n);
  }
  T operator[](int i) {
    return d[i+n-1];
  }
};

int main()
{
  int n; cin>>n;
  string s; cin>>s;
  SegTree<string> st(n, "",
    [](string a, string b){
      string t = a+b;
      sort(t.begin(),t.end());
      t.erase(unique(t.begin(), t.end()), t.end());
      return t;
    },
    [](string a, string b){return b;},
    s
  );
  int q; cin>>q;
  vector<int> ans;
  rep(i, q) {
    int a; cin >> a;
    if (a==1) {
      int b; cin >> b; b--;
      string c; cin >> c;
      st.update(b, c);
    } else {
      int b, c; cin>>b>>c; b--; c--;
      string t = st.query(b, c+1);
      ans.push_back(t.size());
    }
  }
  for (auto v:ans) cout << v << endl;

  return 0;
}


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

int main () {

    int a, b;
    cin >> a >> b;

    if (a + b == 15) cout << "+" << endl;
    else if (a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;

    return 0;
}

Measured memory_bytes: 256
N,X = map(int,input().split())
m =[]
count = N
for n in range(N):
    m.append(int(input()))

X = X-sum(m) #残りはX


while True:
    if X >= min(m):
        X -= min(m)
        count += 1
    else:
        break

print(count)


Measured memory_bytes: 3060
N = int(input())
A = [int(i) for i in input().split()]
ave = sum(A)//len(A)


def cost(A,ave):
    return sum(map(lambda x: (x - ave)**2, A))


c = cost(A, ave)
c1 = cost(A,ave+1)
if c < c1:
    while c < c1:
        ave -= 1
        c, c1 = cost(A, ave), c
    print(c1)
else:
    while c > c1:
        ave += 1
        c, c1 = c1, cost(A, ave)
    print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	string S, T;

	cin >> S >> T;
	int ans = 0;

	for (int i = 0; i < 3; i++)
	{
		S[i] == T[i] ? ans++ : 0;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <math.h>
#include <iomanip>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define _USE_MATH_DEFINES
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}

// head

int main() {
    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double xm, ym, xh, yh;
    xm = b*sin(((m*(long double)M_PI )/(long double)30));
    ym = b*cos(((m*(long double)M_PI )/(long double)30));

    xh = a*sin(((60*h + m)*(long double)M_PI )/(long double)(360));
    yh = a*cos(((60*h + m)*(long double)M_PI )/(long double)(360));

        //cout << xm << " " << ym << " " << xh << " " << yh << "\n"; 

    long double dist = ((xm-xh)*(xm-xh) + (ym-yh)*(ym-yh));
    cout << std::setprecision(20) << sqrt(dist) << "\n";
}



Measured memory_bytes: 4200
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
using namespace std;
string x;
int main()
{
	cin>>x;
	cout<<x[0]<<x.length()-2<<x[x.length()-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using lint = long long;
using namespace std;
using pi = pair<int, int>;
const int mod = 1e6 + 3;

lint fact[mod + 69];
lint invf[mod + 69];

lint ipow(lint x, lint p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret % mod;
}

lint query(int s, int e){
	int zeroCnt = (e + mod) / mod - (s - 1 + mod) / mod;
	if(zeroCnt) return 0;
	s %= mod;
	e %= mod;
	return fact[e] * invf[s - 1] % mod;
}

int main(){
	fact[0] = invf[0] = 1;
	for(int i=1; i<mod; i++){
		fact[i] = fact[i-1] * i % mod;
		invf[i] = ipow(fact[i], mod - 2);
	}
	int q;
	scanf("%d",&q);
	while(q--){
		int x, d, n;
		scanf("%d %d %d",&x,&d,&n);
		if(d == 0){
			printf("%lld\n", ipow(x, n));
			continue;
		}
		lint quer = x * ipow(d, mod - 2) % mod;
		printf("%lld\n", query(quer, quer + n - 1) * ipow(d, n) % mod);
	}
}


Measured memory_bytes: 16512
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<algorithm>
#include<string.h>
#include<map>

using namespace std;
typedef pair<int,int> P;

int main(int argc, char* argv[]){
  int n;
  scanf("%d",&n);
  vector<int>l(n+1);
  vector<int>r(n+1);
  int t1,t2;
  for(int i=0;i<n;i++){
    scanf("%d%d",&t1,&t2);
    l[i]=t1;
    r[i]=t2;
  }
  l[n]=0;
  r[n]=0;
  sort(l.begin(),l.end(),greater<int>());
  sort(r.begin(),r.end());
  long long int ans=0;
  long long int temp=0;
  for(int i=0;i<n;i++){
    temp+=2*l[i]-2*r[i];
    if(temp>ans)ans=temp;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  string S;
  cin >> S;
  ll maxlen{};
  rep(i, 0, S.size()){
    rep(j, i, S.size()){
      if(S.at(j) == 'A' || S.at(j) == 'T' || S.at(j) == 'G' || S.at(j) == 'C'){
        maxlen = max(j - i + 1, maxlen);
      }
      else{
        break;
      }
    }
  }
  cout << maxlen << rt;
}

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

int main(){
    for (;;){
        int H, W;
        cin >> H >> W;
        if (H==0 && W==0) break;
        for (int i=0; i<H; i++){
            for (int j=0; j<W; j++){
                if ((i%2==1 && j%2==1) || (i%2==0 && j%2==0)) cout << "#";
                else cout <<".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

bool isFinished(int* h, int N)
{
    for (int i = 0; i < N; ++i) {
        if (h[i] != 0) {
            return false;
        }
    }

    return true;
}

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

    int h[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> h[i];
    }

    int cnt = 0;
    while (true) {
        bool start = false;
        for (int i = 0; i < N; ++i) {
            if (h[i] >= 1) {
                if (start == false) {
                    ++cnt;
                    start = true;
                }
                --(h[i]);
            } else {
                if (start == true) {
                    break;
                }
            }
        }

        if (true == isFinished(h, N)) {
            std::cout << cnt << std::endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

count = 0

for i in range(0, N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                Li = [L[i], L[j], L[k]]
                max_Li = max(Li)
                Li.remove(max_Li)
                if max_Li < Li[0] + Li[1]:
                    count += 1

print(count)


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  double x1, y1, x2, y2;
  fscanf(stdin, "%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
  fprintf(stdout, "%.9f\n", hypot(x1 - x2, y1 - y2));
  return 0;
}

Measured memory_bytes: 1256
/*
 * Click `Run` to execute the snippet below!
 */
 
import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  
  static long numPatties[] = new long[100];
  static long length[] = new long [100];
  
  //Finds the number of patties for the first X letters
  //And for the level L patty.
  static long solve(int L, long X){
    if(X == 0){
      return 0;
    }
    if(L == 0){
      return 1; 
    }
    //Case 1 When X == 1
    if(X == 1){
      return 0;
    }
    //Case 2
    else if(X > 1 && X <= 1 + length[L-1]){
      return solve(L-1, X-1);
    }
    //Case 3
    else if(X == 2 + length[L-1]){
      return numPatties[L-1] + 1;
    }
    //Case 4
    else if(X > 2 + length[L-1] && X <= 2 + 2*length[L-1]){
      return numPatties[L-1] + 1 + solve(L-1, X - 2 - length[L-1]);
    }
    //Case 5
    else{
      return numPatties[L];
    }
  }
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long X = sc.nextLong();
    for(int i = 0; i<=N; i++){
      numPatties[i] = 1;
      //2^(L+1)
      for(int j = 1; j<=i+1; j++){
        numPatties[i] *= 2L; 
      }
      numPatties[i]--;
      length[i] = 1;
      //2^(L+2)
      for(int j = 1; j<=i+2; j++){
        length[i] *= 2L; 
      }
      length[i] -= 3;
    }
    System.out.println(solve(N, X));
  }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> A(100100);
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
    }

    int btn_now = 1;
    int cnt = 0;
    while (btn_now != 2) {
        if (A[btn_now] == btn_now) {
            cout << -1 << endl;
            return 0;
        }
        else {
            btn_now = A[btn_now];
            cnt++;
            if (cnt == 100005) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


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

using LL = long long;

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

  int ans = 700;
  string S;
  cin >> S;

  for (int i = 0; i < 3; i++) {
    if (S[i] == 'o') {
      ans += 100;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int temp;
	cin>>n;
	vector <vector <int > > arr(n,vector <int> (3,0));
	vector <vector <int > > DP(n,vector <int> (3,0));
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>temp;
			arr[i][j]=temp;
		}
	}
	for(int i=0;i<n;i++){
		if(i==0){
			for(int j:{0,1,2}){
				DP[i][j]=arr[i][j];
			}
			continue;
		}	
		for(int j=0;j<3;j++){
			for(int k:{0,1,2}){
				if(j!=k)
					DP[i][j]=max(DP[i][j],DP[i-1][k]+arr[i][j]);
			}
		}
	}
	int res=0;
	for(int i:{0,1,2})
			res=max(res,DP[n-1][i]);
	cout<<res<<endl;

}

Measured memory_bytes: 11136
#import <Foundation/Foundation.h>
#import <stdio.h>

int main(int argc, char **argv) {
  NSInteger amount;
  scanf("%ld", &amount);
  NSInteger fiveHundred = amount / 500;
  amount %= 500;
  NSInteger five = amount / 5;
  NSInteger happy = fiveHundred * 1000 + five * 5;
  
  printf("%ld", happy);
  return 0;
}

Measured memory_bytes: 128
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  n <- readLn :: IO Int
  let cakesAndDonuts = length [(x,y)|x<-[0..25], y<-[0..14], 4*x+7*y==n]
  putStrLn $ if cakesAndDonuts==0 then "No" else "Yes"

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

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

  int ans = 1000 - n % 1000;

  if (ans == 1000) ans = 0;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main() {
    int e, y; cin >> e >> y;
    if(e==0) {//if seireki
        if(y <= 1911)
            cout << 'M' << 44 - (1911 - y) << endl;
        else if(y <= 1925)
            cout << 'T' << 14 - (1925 - y) << endl;
        else if(y <= 1988)
            cout << 'S' << 63 - (1988 - y) << endl;
        else
            cout << 'H' << 28 - (2016 - y) << endl;
    }
    else {//if wareki
        switch(e) {
            case 1:
                cout << 1867+y << endl;
                break;
            case 2:
                cout << 1911 + y << endl;
                break;
            case 3:
                cout << 1925 + y << endl;
                break;
            default:
                cout << 1988 + y << endl;
        }
    }
    return 0;
}


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

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());

  vector<int> p(2);
  for (int i = 0; i < n; i++) {
    p[i % 2] += a[i];
  }
  cout << p[0] - p[1] << endl;
  return 0;
}

Measured memory_bytes: 256
/*---- enazuma11-------  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define F first
#define S second
#define M 1000000007
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	string s,t;
	cin>>s>>t;
	int n=s.size();
	map<char,char> m;
	//int f=0;
	for(int i=0;i<n;i++){
		if(!m[s[i]])
		m[s[i]]=t[i];
		else if(m[s[i]]!=t[i]){
			cout<<"No";
			return 0;
		}
	}
	set<char> st;
	for(auto i=m.begin();i!=m.end();i++){
		st.insert(i->second);
	}
	if(st.size()!=m.size()){
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

pii mix(pii a, pii b){
	if(max(a.first, b.first) < min(a.second, b.second))
		return { max(a.first, b.first) , min(a.second, b.second) };
	else return {-1, -1};
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	vector<pii> a(m);
	priority_queue<pii> que;
	REP(i, m){
		cin >> a[i].first >> a[i].second;
		a[i].first--; a[i].second--;
		que.push(a[i]);
	}
	pii c = {-1, INF};
	int cnt = 0;
	while(!que.empty()){
		pii b = que.top(); que.pop();
		c = mix(b, c);
		if(c == pii({-1, -1})){
			c = b;
			cnt++;
		}
	}
	cout << cnt + 1 << "\n";
	return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int H, W, M;
    cin >> H >> W >> M;

    vector<int> h(M), w(M);
    rep(i, M) {
        cin >> h[i] >> w[i];
        --h[i];
        --w[i];
    }

    int mh = 0;
    int mw = 0;
    vector<int> ch(H), cw(W);

    rep(i, M) {
        ++ch[h[i]];
        ++cw[w[i]];
        mh = max(mh, ch[h[i]]);
        mw = max(mw, cw[w[i]]);
    }

    vector<bool> candH(H);
    vector<bool> candW(W);
    LL candHCount = 0;
    LL candWCount = 0;
    rep(y, H) {
        if (ch[y] == mh) {
            candH[y] = true;
            ++candHCount;
        }
    }
    rep(x, W) {
        if (cw[x] == mw) {
            candW[x] = true;
            ++candWCount;
        }
    }

    LL bothCount = 0;
    rep(i, M) {
        if (candH[h[i]] && candW[w[i]]) ++bothCount;
    }

    bool hasEmptyIntersection = (bothCount < candHCount * candWCount);

    int ans = mh + mw - (hasEmptyIntersection ? 0 : 1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7932
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(N); //スイッチのvector
    // input処理
    // 電球に関してループ
    for (int i = 0; i < M; i++)
    {
        int k;
        cin >> k;
        // 電球iと繋がっているスイッチでループ
        for (int j = 0; j < k; j++)
        {
            int s;
            cin >> s;
            s--;
            // 各スイッチについて、電球iと繋がっていれば1を
            // 繋がっていなければ0を入れる
            a[s] |= 1 << i;
        }
    }
    int P = 0;
    for (int i = 0; i < M; i++)
    {
        int x;
        cin >> x;
        P |= x << i;
    }
    // スイッチの押し方を全部試す
    int ans = 0;
    for (int s = 0; s < (1 << N); s++)
    {
        int t = 0;
        // スイッチでループ
        for (int i = 0; i < N; i++)
        {
            // i番めのスイッチがonのとき
            if (s >> i & 1)
            {
                t ^= a[i];
            }
        }
        if (t == P)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n,Y;
    int ans[3];
    for(int i=0;i<3;i++) ans[i] = -1;

    cin >> n >> Y;
    Y /= 1000;
    for(int x=0;x<=n;x++){
        for(int y=0;y<=n-x;y++){
            int z = n - x - y;
            if (10*x+5*y+z == Y){
                cout << x << ' ' << y << ' ' << z << ' ';
                return 0;
            }
        }
    }

    for(int i=0;i<3;i++) cout << ans[i] <<" ";
}

Measured memory_bytes: 256