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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define se          second
#define fi          first

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    vector<LL> x(n), y(m);
    inc(i, 0, n) cin >> x[i];
    inc(i, 0, m) cin >> y[i];
    LL X = 0;
    inc(i, 0, n){
        X += x[i]*i-x[i]*(n-i-1);
        X %= MOD;
    }
    LL Y = 0;
    inc(i, 0, m){
        Y += y[i]*i-y[i]*(m-i-1);
        Y %= MOD;
    }
    //cout << X << " " << Y << endl;
    cout << X*Y%MOD << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)  x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL)   root = z;
  else if(z->key < y->key) y->left = z;
  else y ->right = z;
}


void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
}



int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }    
  }

  return 0;
}

Measured memory_bytes: 24036
N,K = map(int,input().split())
cnt = 0
for b in range(K+1,N+1):
    n = N//b
    k = N%b
    cnt += n*(b-K)
    cnt += max(k-K+1,0)
if K==0:
    print(cnt-N)
else:
    print(cnt)

Measured memory_bytes: 3060
#include <iostream>

int main()
{
    int r, D, x2000;
    std::cin >> r >> D >> x2000;

    int before = x2000;
    for (int i = 0; i < 10; i++) {
        int x200i = r * before - D;
        std::cout << x200i << std::endl;
        before = x200i; 
    }
    
    return 0;
}

Measured memory_bytes: 256
// Rust わからん
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let (A, B, T) = {
        let mut ws = s.split_whitespace();
        let A: i32 = ws.next().unwrap().parse().unwrap();
        let B: i32 = ws.next().unwrap().parse().unwrap();
        let T: f32 = ws.next().unwrap().parse().unwrap();
        (A, B, T)
    };

    let T = T + 0.5;
    let ans = ((T / (A as f32)) as i32) * B;
    println!("{}", ans);
    
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a,b,c; cin >> a >> b >> c;
	for (int i = a; i <= a+b; i++){
		if ((i*a)%b == c){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def Find(x, par):
  if par[x] < 0:
    return x
  else:
    # 経路圧縮
    par[x] = Find(par[x], par)
    return par[x]

def Unite(x, y, par, rank):
  x = Find(x, par)
  y = Find(y, par)
  
  if x != y:
    # rankの低い方を高い方につなげる
    if rank[x] < rank[y]:
      par[y] += par[x]
      par[x] = y
    else:
      par[x] += par[y]
      par[y] = x
      if rank[x] == rank[y]:
        rank[x] += 1
    
def Same(x, y, par):
  return Find(x, par) == Find(y, par)
 
def Size(x, par):
  return -par[Find(x)]

n, k, l = map(int, input().split())
rpar = [-1]* n
tpar = [-1]* n
rrank = [0]*n
trank = [0]*n

for i in range(k):
  p, q = map(int, input().split())
  p, q =p-1, q-1
  Unite(p,q, rpar, rrank) 

for i_ in range(l):
  p, q = map(int, input().split())
  p, q =p-1, q-1
  Unite(p,q, tpar, trank)

d = {}
IDs = [0]*n
for j in range(n):
  ID = Find(j, rpar)+(Find(j, tpar)+1)*10**8
  IDs[j] = ID
  if ID in d:
    d[ID] += 1
  else:
    d[ID] = 1

ans = ''
for j_ in range(n):
  if j_ != 0:
    ans += ' '
  ans += str(d[IDs[j_]])
print(ans)

    



  
  
    
    

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


int main() {
    int H;

    cin >> H;

    if(H%10==2||H%10==4||H%10==5||H%10==7||H%10==9)cout << "hon" << endl;
    else if(H%10==0||H%10==1||H%10==6||H%10==8)cout << "pon" << endl;
    else if(H%10==3)cout << "bon" << endl;

    
    

}




Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int64 n, m, ret;
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (n == 1) {
    if (m == 1) {
      ret = 1;
    } else if (m == 2) {
      ret = 0;
    } else {
      ret = m - 2;
    }
  } else if (n == 2) {
    ret = 0;
  } else {
    ret = (n - 2) * (m - 2);
  }
  cout << ret << endl;
  return 0;
}


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

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
ll L[55], P[55];
ll dfs(ll n,ll x) {
	if (n == 0)return 1;
	else if (x == 1)return 0;
	else if (x <= L[n - 1] + 1) {
		return dfs(n - 1, x - 1);
	}
	else if (x == L[n - 1] + 2) {
		return P[n-1]+1;
	}
	else if (x < L[n - 1] * 2 + 2) {
		return P[n - 1] + 1 + dfs(n - 1, x - 2 - L[n - 1]);
	}
	else {
		return 2 * P[n - 1] + 1;
	}
}
int main() {
	ll N, X;
	cin >> N >> X;
	L[0] = 1;
	P[0] = 1;
	for (int i = 0; i < N; ++i) {
		L[i + 1] = 2 * L[i] + 3;
		P[i + 1] = 2 * P[i] + 1;
	}
	cout << dfs(N, X) << endl;
	return 0;
}



Measured memory_bytes: 256
// C - Marks
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int N,K; cin>>N>>K;
	vector<int> A(N);
	rp(i, 0, K) cin>>A[i];
	rp(i, K, N){
		cin>>A[i];
		if(A[i-K] < A[i]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 4032
n=int(input())
a=[]
for i in range(n):
    x,y=map(int,input().split())
    a.append((x,y))
ok=False
for i in range(n-2):
    if a[i][0]==a[i][1] and a[i+1][0]==a[i+1][1] and a[i+2][0]==a[i+2][1]:
        ok=True
if ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9104
n = int(input())
ratio_array = [tuple(map(int, input().split())) for _ in range(n)]

t, a = 1, 1

for x, y in ratio_array:
    m = max((t+x-1)//x, (a+y-1)//y)
    t, a = m*x, m*y

print(t + a)

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

template<int MOD>
struct mod_int {
	static const int mod = MOD;
	unsigned x;
	mod_int() : x(0) { }
	mod_int(int sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	mod_int(long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	mod_int &operator+=(mod_int that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator-=(mod_int that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator*=(mod_int that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	mod_int &operator/=(mod_int that) { return *this *= that.inverse(); }

	mod_int operator+(mod_int that) const { return mod_int(*this) += that; }
	mod_int operator-(mod_int that) const { return mod_int(*this) -= that; }
	mod_int operator*(mod_int that) const { return mod_int(*this) *= that; }
	mod_int operator/(mod_int that) const { return mod_int(*this) /= that; }

	mod_int inverse() const {
		long long a = x, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		return mod_int(u);
	}
};

template<int MOD>
istream& operator >> (istream& is, mod_int<MOD>& val) {
	long long x;
	is >> x; val = x;
	return is;
}

template<int MOD>
ostream& operator << (ostream& os, const mod_int<MOD>& val) {
	os << val.get();
	return os;
}

using mint = mod_int<1000000007>;

const int MAX = 2e6;

bool inited = false;
mint fac[MAX + 1];
mint rfac[MAX + 1];

void init() {
	inited = true;
	fac[0] = 1;
	for (int i = 1; i <= MAX; i++) {
		fac[i] = fac[i - 1] * i;
	}
	rfac[MAX] = fac[MAX].inverse();
	for (int i = MAX; i >= 1; i--) {
		rfac[i - 1] = rfac[i] * i;
	}
}

mint nPr(int n, int r) {
	if (!inited) init();
	return r < 0 || n < r ? 0 : fac[n] * rfac[n - r];
}

mint nCr(int n, int r) {
	if (!inited) init();
	return r < 0 || n < r ? 0 : fac[n] * rfac[n - r] * rfac[r];
}

mint nHr(int n, int r) {
	if (!inited) init();
	return r == 0 ? 1 : nCr(n + r - 1, r);
}

int main()
{
	int H, W, N;
	cin >> H >> W >> N; --H, --W;
	vector<pair<int, int>> rc;
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y; --x, --y;
		rc.emplace_back(x, y);
	}
	sort(rc.begin(), rc.end());
	vector<mint> dp(N);
	for (int i = 0; i < N; i++) {
		int x, y;
		tie(x, y) = rc[i];
		dp[i] = nCr(x + y, x);
		for (int j = 0; j < i; j++) {
			int tx, ty;
			tie(tx, ty) = rc[j];
			if (tx > x || ty > y) continue;
			dp[i] -= dp[j] * nCr((x + y) - (tx + ty), x - tx);
		}
	}
	mint res = nCr(H + W, H);
	for (int i = 0; i < N; i++) {
		int x, y;
		tie(x, y) = rc[i];
		res -= dp[i] * nCr((H + W) - (x + y), H - x);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 15872
#include <cstdio>
#include <set>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int n;
    char str[5123];

    scanf("%d", &n);
    scanf("%s", str);
    string strstr = string(str);
    // n = strlen(str);
    // printf("%d\n", n);

    int res = 0;
    int left = 1;
    int right = n/2 + 1;
    while(true){
        int l = (left + right)/2;
        if(l == left || l == right){
            break;
        }
        // is it possible to make the string of length i?
        bool possible = false;

        map<string, int> str2pos;
        for(int i=0; i < n - l + 1; i++){
            // check the existence
            // string substr = string(str, i, l);
            string substr = strstr.substr(i, l);
            // printf("%s\n", substr.c_str());
            auto res_find = str2pos.find(substr);
            if(res_find != str2pos.end()){
                int firstpos = res_find->second;
                // overwrap?
                if(firstpos + l <= i){
                    possible = true;
                    break;
                }
            }else{
                //add
                str2pos.insert(make_pair(substr, i));
            }
        }

        // update
        if(possible){
            res = max(l, res);
            left = l;
        }else{
            right = l;
        }
        // printf("hoge\n");
    }

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

    return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<numeric>
using namespace std;
int main() {
	long long  a = 0, b = 0, x = 0, max = 0;
	long long  n = 0, ans = 0, k = 0;
	long long left = 0, right = 0, count = 0;
	string s, t, u;
	vector<double> z(3,0), zz;
	vector<long long int>::iterator position;
	bool q = false;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 0) {
			if (a % 3 != 0 && a % 5 != 0) {
				q = true;
				break;
			}
		}
	}
	if (q==true)cout << "DENIED" << endl;
	else  cout << "APPROVED" << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
long long dp[3005][3005];
void lcs(int n, int m)
{
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0||j==0)
            {
                dp[i][j]=0;
            }
            else if(a[i-1]==b[j-1])
            dp[i][j]=dp[i-1][j-1]+1;
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }    
        }
    }
    int ans=dp[n][m];
    char lcs[ans+1]; 
    lcs[ans]='\0';
  
   int i = n, j = m; 
   while (i > 0 && j > 0) 
   { 
      if (a[i-1] == b[j-1]) 
      { 
          lcs[ans-1] = a[i-1];
          i--; j--; ans--;    
      } 
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   cout<<lcs;
}

int main()
{
    cin>>a>>b;
    int n=a.length();
    int m=b.length();
    lcs(n,m);  

    return 0;
}

Measured memory_bytes: 70784
/*
AIZU ONLINE 0001
List of Top 3 Hills
*/
#include <stdio.h>
main()
{
	int	mountain[10];
	int	i,j,highest,pos,work;

	for(i=0;i<10;i++)
		scanf("%d",&(mountain[i]));

	for(i=0;i<3;i++)
	{	highest = mountain[i];
		pos     = i;
		for(j=i+1;j<10;j++)
		{	
			if(highest <mountain[j])
			{	pos = j;
				highest=mountain[j];
			}
		}
		if(i != pos)
		{	work = mountain[i];
			mountain[i] = mountain[pos];
 			mountain[pos] = work;
		}
		printf ("%d\n",highest);
	}

	return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}

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

  ll A,B,C,D,E,F;
  cin >> A >>B >> C >> D >> E >> F;

  
  ll maxwater,maxsugar;
  vector<ld> water,sugar;

  
  maxwater = F;


  ll ans = 0;
  rep(i,F/A+10){
    rep(j,F/B+10){
      if((i*100*A+j*100*B)<=F)
	water.pb(i*100*A+j*100*B);
      else break;
    }
  }

  rmsame(water);//こんな水が作れますよ
  
  rep(k,water.size()){
    maxsugar = min(water[k]/100*E, F-water[k]);
    
    ans = 0;
    rep(i,maxsugar/C+2){
      rep(j,maxsugar/D+2){
	if((i*C+j*D)<=maxsugar)
	  ans = max(ans, i*C+j*D);
	else break;
      }
    }
    sugar.pb(ans);
  }
  


  ll index=water.size()-1;
  ld maxrate = 0;
  rep(i,water.size()){
    if((sugar[i]+water[i])<=F){
      if((ld)(sugar[i]/water[i]) > maxrate){
	index = i;
	maxrate = (ld)(sugar[i]/water[i]);
      }
    }
  }
    
  cout << water[index]+sugar[index] << " " << sugar[index]<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    ans = LLINF;
    vector<ll> a(N);
    cin >> a;
    ll sum = accumulate(ALL(a), 0LL);
    ll tmp = 0;
    REP(i, N - 1) {
        tmp += a[i];
        ans = min(ans, (ll)abs(2 * tmp - sum));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4848
#include<iostream>
using namespace std;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int v = 0;
	int s = 0;
	for (int i = 0; i < 100; i++) {
		if (C-B > 0) {
			v++;
			C -= B;
		}
		else break;
	}
	for (int i = 0; i < 100; i++) {
		if (A-D > 0) {
			s++;
			A -= D;
		}
		else break;
	}

	if (v > s)cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    cin >> N;
    vector<int> B(N+1);
    B[0] = INF;
    B[N] = INF;
    repX(i,N,1)cin >> B[i];
    ll ans = 0;
    rep(i,N){
        ans += min(B[i],B[i+1]);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
    int n;
    cin >> n;
    cout << 1-n;
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow

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

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

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	vector<int> v(32);
	v.at(0) = 1;
	v.at(1) = 1;
	v.at(2) = 1;
	v.at(3) = 2;
	v.at(4) = 1;
	v.at(5) = 2;
	v.at(6) = 1;
	v.at(7) = 5;
	v.at(8) = 2;
	v.at(9) = 2;
	v.at(10) = 1;
	v.at(11) = 5;
	v.at(12) = 1;
	v.at(13) = 2;
	v.at(14) = 1;
	v.at(15) = 14;
	v.at(16) = 1;
	v.at(17) = 5;
	v.at(18) = 1;
	v.at(19) = 5;
	v.at(20) = 2;
	v.at(21) = 2;
	v.at(22) = 1;
	v.at(23) = 15;
	v.at(24) = 2;
	v.at(25) = 2;
	v.at(26) = 5;
	v.at(27) = 4;
	v.at(28) = 1;
	v.at(29) = 4;
	v.at(30) = 11;
	v.at(31) = 51;
	cin>>k;
	cout<<v.at(k-1)<<endl;
}


Measured memory_bytes: 256
L=[]
M=[]
A=list(map(str,input().split()))
B=len(A)

for i in range(B):
    C=A.count(A[i])
    L.append(C)
D=max(L)
E=L.index(D)
print(A[E],end=" ")

for j in range(B):
    F=len(A[j])
    M.append(F)
G=max(M)
H=M.index(G)
print(A[H])


Measured memory_bytes: 5556
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef pair<int,int> P;

int dh[4] = {0,1,0,-1};
int dw[4] = {1,0,-1,0};
char out[4] ={'R','D','L','U'};
int H, W;
char brd[10][10];
int x[10][10];
int cnt;
vector<int> ans;

int dfs(int hh, int ww, int dir, int counter){
	if(counter == cnt){
		return 0;
	}
	int ret = INF;
	bool end = false;
	rep(i,4){
		if(i == (dir+2)%4) continue;
		int h = hh, w = ww;
		while(true){
			h += dh[i]; w += dw[i];
			if(h >= H || h < 0 || w >= W || w < 0) break;
			if(brd[h][w] == 'o'){
				brd[h][w] = '.';
				ret = min(dfs(h,w,i,counter+1),ret);
				brd[h][w] = 'o';
				if(ret < INF){
					ans.push_back(i);
					end = true;
				}
				break;
			}
		}
		if(end) break;
	}
	return ret;
}

int main(){
	int sh, sw, sdir;
	cin >> H >> W;
	rep(i,H) rep(j,W){
		cin >> brd[i][j];
		if(brd[i][j] == 'o') cnt++;
		if(brd[i][j] == 'U'){ sh = i; sw = j; sdir = 3;}
		if(brd[i][j] == 'D'){ sh = i; sw = j; sdir = 1;}
		if(brd[i][j] == 'R'){ sh = i; sw = j; sdir = 0;}
		if(brd[i][j] == 'L'){ sh = i; sw = j; sdir = 2;}
	}
	rep(i,H) rep(j,W){
		if(brd[i][j] == 'o'){
			rep(k,H){
				if(k == i) continue;
				if(brd[k][j] == 'o'){
					x[i][j]++;
				}
			}
			rep(k,W){
				if(k == j) continue;
				if(brd[i][k] == 'o'){
					x[i][j]++;
				}
			}
		}
	}
	int tmp = dfs(sh,sw,sdir,0);
	for(int i = ans.size()-1; i >= 0; i--){
		cout << out[ans[i]];
	}
	cout << endl;
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 1e5 + 5;

int pai[T];
int peso[T];
bool ok[T];

void init(int n) {
    for(int i = 1; i <= n; i++) {
        pai[i] = i;
        peso[i] = 1;
    }
}

int find(int x) {
    return (pai[x] == x? x : pai[x] = find(pai[x]));
}

void join(int x, int y) {
    x = find(x);
    y = find(y);

    if(x == y) return;
    if(peso[x] < peso[y]) swap(x,y);

    pai[y] = x;
    peso[x] += peso[y];
}

int main() {
    ios_base::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    int ans = 0;
    init(n);

    while(m--) {
        int a,b,z; cin >> a >> b >> z;
        join(a,b);
    }

    for(int i = 1; i <= n; i++) if(!ok[find(i)]) ans++, ok[find(i)] = 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    HashSet<Integer> list = new HashSet<Integer>();
    for (int i = 0; i < A; i++) {
      list.add(sc.nextInt());
    }
    sc.close();
    if (list.size() == A) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 100520
import java.util.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
        BigInteger sum =  BigInteger.valueOf(0);
        BigInteger bi = BigInteger.valueOf(1);
        int[] list = new int[n];
        for (int i = 0; i < n; i++) {
          int value = sc.nextInt();
          list[i] = value;
          bi = bi.multiply(BigInteger.valueOf(value));
        }
        for (int i = 0; i < n; i++) {
          BigInteger bi2 = BigInteger.valueOf(1);
          for (int count = 0; count < n; count++) {
            if (i != count) {
              bi2 = bi2.multiply(BigInteger.valueOf(list[count]));
            }
          }
          sum = sum.add(bi2);
        }
        BigInteger[] ans = bi.divideAndRemainder(sum);
        double seisu = ans[0].doubleValue();
        double amari = ans[1].doubleValue();
        double bunbo = sum.doubleValue();
        double shousu = amari / bunbo;
        
        System.out.println(seisu + shousu);
	}
}

Measured memory_bytes: 24276
from sys import setrecursionlimit; setrecursionlimit(10**9)
N, M = map(int, input().split())
edge = {i:[] for i in range(1, N+1)}
starts = set(i for i in range(1, N+1))
for _ in range(M):
    x, y = map(int, input().split())
    edge[x].append(y)
    starts -= {y}

memo = [-1] * (N+1)

def rec(e):
    if memo[e] != -1:
        return memo[e]
    ret = 0
    for f in edge[e]:
        ret = max(ret, rec(f) + 1)
    memo[e] = ret
    return ret

max_d = 0
for s in starts:
    max_d = max(max_d, rec(s))
print(max_d)


Measured memory_bytes: 181092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 3e3+5, inf = 1e9+7;
int n, k, i, j;
int A[N];
double dp[N], p;

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n;
    dp[0] = 1;
    rep(i, 1, n+1){
        cin>>p;
        sep(j, i, -1) {
            dp[j] = dp[j]*(1-p);
            if(j) dp[j] += dp[j-1]*p;
        }
    }
    double res=0;
    rep(i, 0, n+1) if(i*2>=n) res += dp[i];
    cout<<fixed<<setprecision(10)<<res;
}

Measured memory_bytes: 256
n,k = map(int,input().split())

l = list(map(int,input()))
ll = []
p = l[0]
co = 1
ppp = 0
su = 0
lll = []
for i in range(n-1):
    if p == l[i+1]:
        co += 1
    else:
        if p == 0:
            ppp += 1
        ll.append([p,co])
        p = l[i+1]
        co = 1
if p == 0:
    ppp += 1
ll.append([p,co])
co = 0
if ll[0][0] == 0:
    ll.insert(0,[1,0])
if len(ll) == 1:
    print(n)
    exit(0)
if ppp <= k:
    print(n)
    exit(0)
co = 0
if ll[-1][0] == 1:
    for i in range(2*k+1):
        co += ll[i][1]
    lll.append(co)
    co -= ll[0][1] + ll[1][1]
    for i in range(ppp-k):
        if i == 0:
            co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1]
            lll.append(co)
        else:
            co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1] - (ll[i*2][1] + ll[i*2+1][1])
            lll.append(co)
else:
    for i in range(2*k+1):
        co += ll[i][1]
    lll.append(co)
    co -= ll[0][1] + ll[1][1]
    for i in range(ppp-k):
        if ppp-k-1 == i and i == 0:
            co += ll[-1][1]
            lll.append(co)
        elif ppp-k-1 == i:
            co += ll[-1][1] - (ll[i*2][1] + ll[i*2+1][1])
            lll.append(co)
        elif i == 0:
            co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1]
            lll.append(co)
        else:
            co += ll[i*2+1+2*k][1] + ll[i*2+2+2*k][1] - (ll[i*2][1] + ll[i*2+1][1])
            lll.append(co)
print(max(lll))



Measured memory_bytes: 56924
#include<stdio.h>
#include<malloc.h>
int main()
{
    int n,i,j,t,*s,x=0;
    scanf("%d",&n);
    s=(int *)malloc(sizeof(int)*n);
    for(i=0;i<n;i++)
        scanf("%d",&s[i]);
    for(i=0;i<n-1;i++)
        for(j=0;j<n-1-i;j++)
            if(s[j]>s[j+1])
            {
                t=s[j];
                s[j]=s[j+1];
                s[j+1]=t;
                x++;
            }
    for(i=0;i<n-1;i++)
        printf("%d ",s[i]);
    printf("%d\n%d\n",s[n-1],x);

    return 0;
}


Measured memory_bytes: 2048
import math
H,W = map(int,input().split())

if H%3==0 or W%3==0:
    print(0)
elif H==2 and W==2:
    print(1)
else:
    def cal2(h,w):
        x1,x2 = math.floor(w/2),math.ceil(w/2)
        y1,y2 = math.floor((2*h)/3),math.ceil((2*h)/3)
        def cal(x,y):
            return max(x*y,(w-x)*y,(h-y)*w) - min(x*y,(w-x)*y,(h-y)*w)
        return min(cal(x1,y1),cal(x2,y1),cal(x1,y2),cal(x2,y2))

    if H==2 or W ==2:
        print(min(cal2(H,W),cal2(W,H),max(H,W)))
    else:
        print(min(cal2(H,W),cal2(W,H),H,W))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

struct UFNode {
    UFNode *parent;
    int height;
    int dist;

    UFNode(): parent(nullptr), height(1), dist(0) {}

    UFNode * getA() {
        if(parent == nullptr) {
            return this;
        } else {
            return parent->getA();
        }
    }

    int getD() {
        if(parent == nullptr) {
            return 0;
        } else {
            return dist + parent->getD();
        }
    }
};

int main(int argc, const char * argv[]) {
    int entityCount, queryCount;
    scanf("%d%d", &entityCount, &queryCount);

    UFNode uf[100000];

    for (int i = 0; i < queryCount; ++i) {
        int l, r, dist;
        scanf("%d%d%d", &l, &r, &dist);

        l--;
        r--;
        UFNode *pl, *pr;
        pl = uf[l].getA();
        pr = uf[r].getA();
        int dl = uf[l].getD();
        int dr = uf[r].getD();
        if (pl != pr) {
            if(pl->height < pr->height) {
                pl->parent = pr;
                pr->height = max(pr->height, pl->height + 1);
                pl->dist = - dl - dist + dr;
            } else {
                pr->parent = pl;
                pl->height = max(pl->height, pr->height + 1);
                pr->dist = dl + dist - dr;
            }
        } else {
            if (- dl + dr != dist) {
                printf("No\n");
                return 0;
            }
        }
    }

    printf("Yes\n");

    return 0;
}


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

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

xll = []
for _ in range(n):
    xl = list(map(int,input().split()))
    xll.append(xl)
    
ans = 0
for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for x1, x2 in zip(xll[i], xll[j]):
            tmp += (x1-x2)**2
        tmp = tmp ** (1/2)
        if tmp == int(tmp):
            ans += 1
print(ans)



Measured memory_bytes: 38512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        int[] A = new int[N];
        for (int i=0;i<N;i++) {
            A[i] = sc.nextInt()-1;
        }

        int index = 0;
        int double_num = -1;
        int[] nums = new int[N];
        ArrayList<Integer> list = new ArrayList<Integer>();
        nums[index]++;
        list.add(index);
        while (true) {
            index = A[index];
            if (nums[index] == 1) {
                double_num = index;
                break;
            }
            nums[index]++;
            list.add(index);
        }

        ArrayList<Integer> before = new ArrayList<Integer>();
        ArrayList<Integer> after = new ArrayList<Integer>();
        boolean flag = false;
        int bound = -1;
        for (int i=0;i<list.size();i++) {
            if (list.get(i) == double_num) {
                bound = i;
                flag = true;
            }

            if (!flag) before.add(list.get(i));
            else after.add(list.get(i));
        }

        int ans = -1;
        if (K<bound) ans = before.get((int)K);
        else ans = after.get((int)((K-bound)%after.size()));
        System.out.println(ans+1);
    }
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

using P = pair<ll, ll>;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
    int n;
    vector<T> d;

    BIT(int n = 0) : n(n), d(n + 1) {}

    void add(int i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }

    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }
};

int main() {
    ll N, D, A;
    cin >> N >> D >> A;
    vector<P> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());

    ll ans = 0;
    BIT<ll> bit(N + 1);
    rep(i, N) {
        ll x = p[i].first;
        ll h = p[i].second;
        h -= bit.sum(i);
        if (h <= 0) continue;

        ll cnt = (h + A - 1) / A;
        ans += cnt;
        ll damage = A * cnt;
        bit.add(i, damage);
        int rx = min(x + D * 2, 1001001001ll);
        int j = upper_bound(p.begin(), p.end(), P(rx + 1, -1)) - p.begin();
        bit.add(j, -damage);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

void fin(bool b){
	if(b) cout << "Yes" << endl;
	else cout << "No" << endl;
	exit(0);
}

int main(){
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	string s;
	cin >> s;
	if(c < b){
		rep2(i, a, c){
			if(s.at(i) == '#' && s.at(i+1) == '#') fin(false);
		}
		rep2(i, b, d){
			if(s.at(i) == '#' && s.at(i+1) == '#') fin(false);
		}
	}else if(c < d){
		rep2(i, a, d){
			if(s.at(i) == '#' && s.at(i+1) == '#') fin(false);
		}
	}else{
		bool flag = false;
		rep2(i, a, c){
			if(s.at(i) == '#' && s.at(i+1) == '#') fin(false);
			if(b <= i && i <= d){
				if(s.at(i) == '.' && s.at(i-1) == '.' && s.at(i+1) == '.') flag = true;
			}
		}
		if(flag == false) fin(false);
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
'''import urllib
link = 'http://llkhqwdlkdyhq.llruj.uk2.gsr.awhoer.net/amakano-episode-3'
urllib.urlretrieve(link,"lala.mp4")
'''
ss = raw_input().split()

print ss[0][0]+ss[1][0]+ss[2][0]

Measured memory_bytes: 8816
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  REP(i,s.size()-1){
    if(s[i]==s[i+1]){
      cout << i+1 << " " << i+2 << '\n';
      return 0;
    }
  }
  REP(i,s.size()-2){
    if(s[i]==s[i+2]){
      cout << i+1 << " " << i+3 << '\n';
      return 0;
    }
  }
  puts("-1 -1");
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define modul 998244353
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll x,y;
int32_t main(){
CODE_START;
cin>>x>>y;
if(y>x*4){
    cout<<"No"<<endl;
    return 0;
}else if(y<x*2){
cout<<"No"<<endl;
return 0;
}else if(y%2==1){
cout<<"No"<<endl;
}else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3636
import java.io.*;
import java.util.*;
import java.lang.*;

class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        String line  = scan.nextLine();
        
        for(int i = 0; i < line.length(); ++i){
            if(Character.isLowerCase(line.charAt(i))){
                System.out.print(Character.toUpperCase(line.charAt(i)));
            }
            
            else if(Character.isUpperCase(line.charAt(i))){
                System.out.print(Character.toLowerCase(line.charAt(i)));
            }
            
            else {
                System.out.print(line.charAt(i));
            }
        }
        
        System.out.println();
    }
}


Measured memory_bytes: 26704
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long int gcd( long long int c, long long int d) {
  if (max(c,d) % min(c,d) == 0) return min(c,d);

  return gcd(min(c,d),max(c,d) % min(c,d));
}

long long int LCM(long long int c, long long int d) {
  return c * d / gcd(c,d);
}

long long int devide(long long int a, long long int s) {
  if (a % s == 0) return a/s;
  else return a/s + 1;
}

long long int solv(long long int a, long long int b, long long int c, long long int d) {
  long long int min_c, min_d, max_c,max_d, min_lcm, max_lcm, lcm;
  lcm = LCM(c,d);
  min_c = devide(a,c);
  max_c = b/c;
  min_d = devide(a,d);
  max_d = b/d;
  min_lcm = devide(a,lcm);
  max_lcm = b/lcm;
  return max_c + max_d - max_lcm - min_c - min_d + min_lcm + 1;
}

int main(int argc, char const *argv[]) {
  long long int a,b,c,d;
  std::cin >> a >> b >> c >> d;

  std::cout << b-a-solv(a, b, c, d) + 1 << '\n';
  return 0;
}







// std::cout << "min_c" << min_c << '\n';
// std::cout << "max_c" << max_c << '\n';
// std::cout << "min_d" << min_d << '\n';
// std::cout << "max_d" << max_d << '\n';
// std::cout << "lcm" << lcm << '\n';
// std::cout << "min_lcm" << min_lcm << '\n';
// std::cout << "max_lcm" << max_lcm << '\n';


Measured memory_bytes: 256
using namespace std;

#include <bits/stdc++.h>

int main(){
    int N;
    cin >> N;
    int a[N+7] = { 0 };
    for ( int i = 0; i < N; i ++ ){
        int k;
        cin >> k;
        a[k - 1] = i + 1;
    }
    for ( int i = 0; i < N; i ++ ){
        cout << a[i] << " ";
    }
    return 0;
}


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

const int MAXN = 110;
int a[MAXN];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; ++i)
        scanf("%d",&a[i]);
    sort(a, a+n, greater<int>());
    int sum0 = 0, sum1 = 0;
    for(int i = 0; i < n; ++i)
        if(i&1) sum1 += a[i];
        else sum0 += a[i];
    printf("%d\n", sum0 - sum1);
    return 0;
}


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

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

	int n,a,b;

	cin >> n;
	cin >> a >> b;

	for(int i=a;i<=b;i++)
	{
		if(i%n==0)
		{
			cout << "OK" << '\n';
			return 0;
		}
	}

	cout << "NG" << '\n';
	
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
map <int, int> m;
int jl[100005];
int main() {
	int n, x, bj = 0;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &x);
		if(m[x] == 0)
			jl[bj++] = x;
		m[x]++;
	}
	long long ans = 0;
	for(int i = 0; i < bj; i++)
		if(m[jl[i]] < jl[i])
			ans += m[jl[i]];
		else
			ans += m[jl[i]] - jl[i];
	cout << ans << endl;
	return 0;
}


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

int main(){
	double xp1,yp1,xp2,yp2,x0,y0,x,y,a;
	int i,q;
	
	cin>>xp1>>yp1>>xp2>>yp2;
	cin>>q;
	
	if(xp1==xp2){
		for(i=0;i<q;i++){
			cin>>x0>>y0;
			cout<<fixed<<setprecision(10)<<xp1;
			cout<<" "<<fixed<<setprecision(10)<<y0<<endl;
		}
	}else{
		a=(yp2-yp1)/(xp2-xp1);
		for(i=0;i<q;i++){
			cin>>x0>>y0;
			x=a*((y0-yp1)-a*(x0-xp1))/(1+a*a)+x0;
        	y=(a*(a*y0+x0-xp1)+yp1)/(1+a*a);
			cout<<fixed<<setprecision(10)<<x;
			cout<<" "<<fixed<<setprecision(10)<<y<<endl;
		}
	}
}


Measured memory_bytes: 3264
#include<iostream>
using namespace std;
int main(){
    
    while(true){
        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++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
    
}


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

int main()
{
	int a;
	cin >> a;
	int arr1[a+10];
	int arr2[a+10];
	int total=0,harga=0;
	
	for(int i=0;i<a;i++)
	{
		cin >> arr1[i];
	}
	for(int i=0;i<a;i++)
	{
		cin >> arr2[i];
	}
	for(int i=0;i<a;i++)
	{
		if(arr1[i]>=arr2[i])
		{
			total+=arr1[i];
			harga+=arr2[i];
		}
	}
	cout << total-harga << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

bool G[21][21];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	memset(G, 0, sizeof(G));
	rep(i, m) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a][b] = G[b][a] = true;
	}
	int res = 0;
	vector<int>ord;
	rep(i, n)ord.push_back(i);
	do {
		if (ord[0] != 0)continue;
		bool ok = true;
		for (int i = 0; i + 1 < ord.size(); i++) {
			if (!G[ord[i]][ord[i + 1]])ok = false;
		}
		if (ok)res++;
	} while (next_permutation(ord.begin(), ord.end()));
	cout << res << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  vector<int> b(n);
  for(int i=0; i<n; i++) cin >> b[i];
  
  int ans = 0;
  int c = 0;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(j==i) c += b[j];
      if(j<=i) c += a[j];
      else c += b[j];
    }
    if(ans<c) ans = c;
    c = 0;
  }
  
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

using namespace std;

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

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    int card = 100*r + 10*g + b;
    if(card%4==0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return  0;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (a + b == c || a + c == b || b + c == a) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int n = reader.nextInt();
        int[] P = new int[n];
        for (int i=0; i<n; i++) P[i] = reader.nextInt();
        int ans = 0;
        for (int i=1; i<n-1; i++) {
            if (P[i-1]<P[i] && P[i]<P[i+1]) ans++;
            if (P[i-1]>P[i] && P[i]>P[i+1]) ans++;
        }
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 22740