akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using pii = pair<int, int>;

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

//pow(llpow,modpow)
template <class T>
ll llpow(ll x, T n)
{
    ll ans = 1;
    if (x == 0)
        ans = 0;
    while (n)
    {
        if (n & 1)
            ans *= x;
        x *= x;
        n >>= 1;
    }
    return ans;
}
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
template <class T>
inline T gcd(T x, T y)
{
    if (y == 0)
        return x;
    else
    {
        return gcd(y, x % y);
    }
}
//最小公倍数
template <class T>
inline T lcm(T x, T y) { return x / gcd(x, y) * y; }
//逆元
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i - 1; i >= (ll)end_i; i--)

long long INF = 1LL << 60;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi kind[3];
    rep(i, 0, n)
    {
        if (s[i] == 'R')
            kind[0].push_back(i);
        else if (s[i] == 'G')
            kind[1].push_back(i);
        else if(s[i]=='B')
            kind[2].push_back(i);
    }
    ll cnt = 0;
    rep(i, 0, 3)
    {
        for (int ii : kind[i])
        {
            rep(j, 0, 3)
            {
                if (i == j)
                    continue;
                auto p = upper_bound(kind[j].begin(), kind[j].end(), ii);
                if (p == kind[j].end())
                    continue;
                else
                {
                    for (auto ji = p; ji != kind[j].end(); ji++)
                    {
                        ll k = (3 - i - j);
                        auto pk = upper_bound(kind[k].begin(), kind[k].end(), *ji);
                        if (pk == kind[k].end())
                            break;
                        else
                        {
                            auto ki = pk;
                            cnt += distance(ki, kind[k].end());
                            if(*lower_bound(kind[k].begin(), kind[k].end(), *(ji)+(*ji-ii))==*(ji)+(*ji-ii))cnt--;
                        }
                    }
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    input_init();
    int n,m; cin>>n>>m;
    vector<int> a(n+1);
    rep(i,m) {
        int l,r; cin>>l>>r;
        --l;
        a[l]++; a[r]--;
    }
    rep(i,n) a[i+1] += a[i];
    int ans = 0;
    rep(i,n) if (a[i]>=m) ans++;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	char a[N + 1];
	long long b[N][20];
	f(i, N + 1)a[i] = 0;
	f(i, N) {
		f(j, 20)b[i][j] = 0;
	}
	int n;
	int x, y, z;
	scanf("%s", a);
	n = strlen(a);
	f(i, 13)b[n][i] = 0;
	b[n][0] = 1;
	x = 1;
	for(int i=n-1;i>=0;i--){
		if (a[i] != '?') {
			y = a[i] - '0';
			f(j, 13) {
				z = (j + (x*y)) % 13;
				b[i][z] = (b[i][z] + b[i + 1][j]) % MOD;
			}
		}
		else {
			f(ii, 10) {
				f(j, 13) {
					z = (j + (x*ii)) % 13;
					b[i][z] = (b[i + 1][j] + b[i][z]) % MOD;
				}
			}
		}
		x = (x * 10) % 13;
	}

	printf("%lld\n",b[0][5]);


	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,num)for(int i=0;i<(num);++i)
#define ll long long
using namespace std;
unordered_map<int, string> mp;
ll N;

int main() {
    ios::sync_with_stdio(false);
    cin >> N;
    if (N == 0) {
        cout<<"0";return 0;
    }
    string ans="";
    while(N!=1) {
        if(N<0){
            if(N%2!=0){
                ans+="1";
                N--;
            }else ans+="0";
        }else if(N>0) {
            if(N%2==0)ans+="0";
            else ans+="1";
        }
        N/=-2;
    }
    ans+="1";
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int k,n;
    cin >> k >> n;
    int a[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    vector<int> v;
    for(int i = 0;i + 1 < n;i++)
    {
        v.push_back(a[i + 1] - a[i]);
    }
    v.push_back(a[0] + k - a[n - 1]);
    sort(v.begin(),v.end(),greater<int>());
    cout << k - v[0] << "\n";

    return 0;
}

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

using namespace std;


#define int long long


int n, k;


bool is(int m, vector <int> &a, vector <int> &f){

	int current = k;
	// auto it = lower_bound(a.begin(), a.end(), m, greater<int>()) - a.begin();


	// if(it == 0) return true;

	// return p[it - 1] - it * m <= k;


	for(int i = 0; i < n; i++){
		if(a[i] * f[i] > m){
			current -= a[i] - m / f[i];
		}

		if(current < 0) return false; 
	}


	return true;

}




main(){


	cin >> n >> k;
	

	vector <int> a(n), f(n), p(n);

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

	for(int i = 0; i < n; i++){
		cin >> f[i];
	}


	sort(a.rbegin(), a.rend());

	sort(f.begin(), f.end());


	// for(int i = 0; i < n; i++){
	// 	cout << a[i] << " ";
	// }
	// cout << endl;


	// for(int i = 0; i < n; i++){
	// 	cout << f[i] << " ";
	// }
	// cout << endl;

	// for(int i = 0; i < n; i++){
	// 	cout << a[i] * f[i] << " ";
	// }
	// cout << endl;



	p[0] = a[0];

	for(int i = 1; i < n; i++){
		p[i] = p[i - 1] + a[i];
	}


	int r = 1e13, l = 0;

	while(r > l){
		int m = (r + l) / 2;

		if(is(m, a, f)){
			r = m;
		}else{
			l = m + 1;
		}
	}


	cout << l << endl;

	// for(int i = 0; i < n; i++){
	// 	a[i] = min(a[i], r);
	// }


	// int ans = 0;	

	// for(int i = 0; i < n; i++){
	// 	ans = max(ans, a[i] * f[i]);
	// }


	// cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
/*
* @Author: _dp95
* @Date:   2020-04-12 09:54:32
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

map<ll,ll>mpp ;

ll exp( ll x, ll y ){
  ll ans = 1 ;
  while( y ){
    if(y&1)
      ans = ans*x % MOD ;
    x = x*x % MOD ;
    y >>= 1 ;
  }
  return ans ;
}

signed main( ){
  timesaver ;
  ll n ;
  cin >> n ;
  vector< ll > v(n) ;
  for( ll &i : v )
    cin >> i ;
  for( ll i = 1 ; i <= n ; i++ ){
    ll l = i-1 ;
    ll r = n-i ;
    mpp[abs(l-r)]++ ;
  }
  for( ll i : v )
    mpp[i]-- ;
  ll f = 1 ;
  for( auto i : mpp ){
    if( i.S != 0 )
      f = 0 ;
  }
  if( !f )
    return cout << 0 << nl, 0 ;
  n = n/2 ;
  cout << exp( 2, n ) << nl ;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 330030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main() {
ll n;
cin>>n;
ll arr[n];
rep(i,0,n)
cin>>arr[i];
ll ans=1e16;
sort(arr,arr+n);
ll mn=arr[0];
ll mx=arr[n-1];
rep(i,mn,mx+1)
{
	ll x=0;
	rep(j,0,n)
	{
		x+=abs(i-arr[j])*(abs(i-arr[j]));
		
	}
	if(x<ans)
	ans=x;
}
cout<<ans;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a[200001], ans = 0;
  map<int, int> mp;
  cin >> n;
  rep(i, n) cin >> a[i];
  FOR(i, 1, n) {
    a[i] += a[i - 1];
    mp[a[i]]++;
  }
  mp[a[0]]++;
  for(auto it = mp.begin(); it != mp.end(); it++) {
    if(it->second > 1) {
      rep(i, it->second - 1) ans += i + 1;
    }
  }

  ans += mp[0];
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16384
#include<stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    long long a, ans=1;

    for(int i=0; i<n; i++)
    {
        scanf("%lld", &a);
        if(a==0)
        {
            ans=0;
            break;
        }
        if(a>1000000000000000000/ans)
            ans=-1;

        if(ans!=-1)
            ans*=a;
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1708
#include <stdio.h>
#include <queue>
#include <utility>

using namespace std;


int main(void){
	int h, w, i, j;
	int gx, gy, nx, ny;
	const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}, INF = 0x7FFFFFFF;
	char maze[59][60];
	int sl[59][59];
	pair<int,int> p;
	queue<pair<int,int> > que;

	scanf("%d%d%*c",&w,&h);

	while(h != 0 || w != 0){

		for(i = 0;i < 2 * h - 1;i++){
			for(j = 0;j < 2 * w - 2;j++)
				maze[i][j] = getchar();
			if(i % 2 == 0)
				maze[i][j] = ' ';
			else
				maze[i][j] = getchar();
			getchar();
		}

		for(i = 0;i < 2 * h - 1;i++){
			for(j = 0;j < 2 * w - 1;j++)
				sl[i][j] = INF;
		}
		sl[0][0] = 1;
		que.push(pair<int,int>(0,0));
		gx = 2 * w - 2; gy = 2 * h - 2;
		while(que.size()){
			p = que.front(); que.pop();
			if(p.first == gx && p.second == gy)
				break;
			for(i = 0;i < 4;i++){
				nx = p.first + 2 * dx[i]; ny = p.second + 2 * dy[i];
				if(0 <= nx && nx < 2 * w - 1 && 0 <= ny && ny < 2 * h - 1 && sl[ny][nx] == INF && maze[p.second + dy[i]][p.first + dx[i]] == '0'){
					que.push(pair<int,int>(nx,ny));
					sl[ny][nx] = sl[p.second][p.first] + 1;
				}
			}
		}
		while(que.size())
			que.pop();
		if(sl[gy][gx] == INF)
			printf("0\n");
		else
			printf("%d\n",sl[gy][gx]);
		scanf("%d%d%*c",&w,&h);
	}
	return 0;
}

Measured memory_bytes: 1084
import numpy as np

s=input()
s=int(s)
lst=[]
judge=True
count=0
while lst.count(s)==0:
    lst.append(s)
    count+=1
    if s%2==0:
        s=s/2
    else:
        s = 3*s + 1
    
print(count+1)

Measured memory_bytes: 21800
#include <iostream>
#include<string>

using namespace std;
int main(void) {

	string s;
	cin >> s;
	int counter = 700;
	if (s[0] == 'o') counter = counter + 100;
	if (s[1] == 'o') counter = counter + 100;
	if (s[2] == 'o') counter = counter + 100;
	
	cout << counter << endl;

}

Measured memory_bytes: 256
K=int(input())
def snuke(N):
    S=list(str(N))
    SN=0
    for i in S:
        SN+=int(i)
    return N/SN
def X(D,n):
    temp=(n+10**(D+1))//(10**(D+1))
    return 10**(D+1)*temp-1
L=[1]
k=1
for i in range(1,K):
    N=L[k-1]+1
    x=X(0,N)
    tmp=snuke(N)
    ans=N
    for d in range(len(str(N))):
        x=X(d,N)
        if snuke(x)<tmp:
            tmp=snuke(x)
            ans=x
    L.append(ans)
    k+=1
for i in L:
    print(i)


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<array>
using namespace std;
//Strongly Connected Components
#include<vector>
struct SCC{
	int n;
	vector<int>comp,order;
	vector<bool>used;
	vector<vector<int> >G,RG;
	SCC(int _n=0):n(_n),comp(_n,-1),used(_n,false),G(_n),RG(_n){}
	void add_edge(int from,int to)
	{
		G[from].push_back(to);
		RG[to].push_back(from);
	}
	void copy(const vector<vector<int> >&H)
	{
		for(int i=0;i<H.size();i++)
		{
			for(int j=0;j<H[i].size();j++)
			{
				G[i].push_back(H[i][j]);
				RG[H[i][j]].push_back(i);
			}
		}
	}
	int operator[](int u){return comp[u];}
	void dfs(int u)
	{
		used[u]=true;
		for(int i=0;i<G[u].size();i++)if(!used[G[u][i]])dfs(G[u][i]);
		order.push_back(u);
	}
	void rdfs(int u,int cnt)
	{
		comp[u]=cnt;
		for(int i=0;i<RG[u].size();i++)if(comp[RG[u][i]]==-1)rdfs(RG[u][i],cnt);
	}
	int build()
	{
		for(int i=0;i<n;i++)if(!used[i])dfs(i);
		int cnt=0;
		for(int i=n-1;i>=0;i--)if(comp[order[i]]==-1)rdfs(order[i],cnt++);
		return cnt;
	}
	int build(vector<vector<int> >&H)
	{
		int ret=build();
		H.assign(ret,vector<int>());
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<G[i].size();j++)
			{
				if(comp[i]!=comp[G[i][j]])
					H[comp[i]].push_back(comp[G[i][j]]);
			}
		}
		return ret;
	}
};
int N,M;
int x[2<<17],y[2<<17],z[2<<17];
int calc(int a,int b)
{
	return abs((long long)x[a]-x[b])+abs((long long)y[a]-y[b])+abs((long long)z[a]-z[b]);
}
bool vis[2<<17];
int A[8][2<<17],B[8][2<<17];
vector<int>ids[2<<17];
int ans[2<<17];
void dfs(int u,vector<vector<int> >&H)
{
	vis[u]=true;
	bool flag=true;
	for(int a:ids[u])
	{
		if(flag)
		{
			flag=false;
			for(int i=0;i<8;i++)
			{
				A[i][u]=B[i][u]=a;
			}
		}
		else
		{
			for(int i=0;i<8;i++)
			{
				long long xx=i%2?-1:1;
				long long yy=i/2%2?-1:1;
				long long zz=i/4%2?-1:1;
				int I=A[i][u];
				if(x[I]*xx+y[I]*yy+z[I]*zz<
					x[a]*xx+y[a]*yy+z[a]*zz)
				{
					A[i][u]=a;
				}
				I=B[i][u];
				if(x[I]*xx+y[I]*yy+z[I]*zz>
					x[a]*xx+y[a]*yy+z[a]*zz)
				{
					B[i][u]=a;
				}
			}
		}
	}
	for(int v:H[u])
	{
		if(!vis[v])dfs(v,H);
		for(int i=0;i<8;i++)
		{
			long long xx=i%2?-1:1;
			long long yy=i/2%2?-1:1;
			long long zz=i/4%2?-1:1;
			int I=A[i][u];
			int id=A[i][v];
			if(x[I]*xx+y[I]*yy+z[I]*zz<
					x[id]*xx+y[id]*yy+z[id]*zz)
			{
				A[i][u]=id;
			}
			I=B[i][u];
			if(x[I]*xx+y[I]*yy+z[I]*zz>
					x[id]*xx+y[id]*yy+z[id]*zz)
			{
				B[i][u]=id;
			}
		}
	}
	for(int id:ids[u])
	{
		for(int i=0;i<8;i++)
		{
			ans[id]=max(ans[id],calc(A[i][u],id));
			ans[id]=max(ans[id],calc(B[i][u],id));
		}
	}
}
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)scanf("%d%d%d",&x[i],&y[i],&z[i]);
	SCC P(N);
	for(int i=0;i<M;i++)
	{
		int u,v;scanf("%d%d",&u,&v);
		u--,v--;
		P.add_edge(u,v);
	}
	vector<vector<int> >H;
	int n=P.build(H);
	for(int i=0;i<N;i++)ids[P[i]].push_back(i);
	for(int i=0;i<n;i++)
	{
		if(!vis[i])dfs(i,H);
	}
	for(int i=0;i<N;i++)cout<<ans[i]<<endl;
}



Measured memory_bytes: 89652
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	string A, B;
	cin >> A >> B;
	int n = A.length();
	int m = B.length();

	vector< vector<int> > ff(n + 2);
	for(int i = 0; i < n + 2; i++) {
		ff[i].resize(m + 2, -1);
	}
	
	function<int(int, int)> LCS = [&](int i, int j) {
		if( i == n or j == m ) return 0;
		if( ff[i][j] != -1 ) return ff[i][j];

		if( A[i] == B[j] ) {
			return ff[i][j] = 1 + LCS( i + 1, j + 1 );
		}
		else {
			return ff[i][j] = max(LCS( i, j + 1 ), LCS(i + 1, j ));
		}
	};

	LCS( 0, 0 );

	string path = "";
	function<void(int, int)> dfs = [&](int i, int j) {
		if( i == n or j == m ) {
			cout << path << "\n";
			return;
		}

		if( A[i] == B[j] ) {
			path.push_back(A[i]);
			dfs( i + 1, j + 1 );
		}
		else {
			if( LCS( i + 1, j ) > LCS( i, j + 1 ) ) {
				dfs( i + 1, j );
			}
			else {
				dfs( i, j + 1 );
			}
		}
	};

	dfs( 0, 0 );
}

Measured memory_bytes: 36224
#conding utf-8
N = int(input())
A = input().split()
ans = 0
t = 0
for i in range(N):
  A[i] = int(A[i])
for i in range(N):
  if A[i] == 0:
    for j in range(N):
      if A[j]<0:
        A[j] = -A[j]
    ans = sum(A)
    break
for j in range(N):
  if A[j]<0:
    t +=1
if t%2 == 0:
  for j in range(N):
    if A[j]<0:
      A[j] = -A[j]
  ans = sum(A)
else:
  for j in range(N):
    if A[j]<0:
      A[j] = -A[j]
  A[A.index(min(A))] = -A[A.index(min(A))]
  ans = sum(A)
      
print(ans)

Measured memory_bytes: 13260
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N;
    io.read(N);
    auto a = io.read_vec<int>(N);
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = N - 1; i >= 0; i -= 2){
        ans += a[i];
    }
    for(int i = N - 2; i >= 0; i -= 2){
        ans -= a[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn = 2e3+100;
const ll mod=998244353;
pll a[maxn];
ll c[maxn];
ll f[maxn];
ll dp[maxn][maxn];
map<ll,ll> mp;
ll val[maxn];
ll mx=0;


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("test.txt", "r", stdin);
    if (fopen("pump.in","r"))
    {
        freopen("pump.in","r", stdin);
        freopen("pump.out", "w",stdout);
    }
ll a, b, c, d;
cin>>a>>b>>c>>d;
ll p=-1e15;
ll h= max(a*c,max(b*c,max(a*d,b*d)));
 if (a<=0&&b>=0)
 {
       cout <<max(h,0ll);
       return 0;
 }
 if (c<=0&&d>=0)
 {
       cout <<max(h,0ll);
       return 0;
 }
cout <<max(a*c,max(b*c,max(a*d,b*d)));








}


Measured memory_bytes: 3652
n = int(input())

g = [[-1 for j in range(n)] for i in range(n)]

for i in range(n):
	a = int(input())
	for _ in range(a):
		x, y = map(int, input().split())
		g[i][x-1] = y

ans = 0
for s in range(2**n):
	ok = True
	for i in range(n):
		if (s>>i&1) == 1:
			for j in range(n):
				if g[i][j] != -1 and (s>>j&1) != g[i][j]:
					ok = False
	if ok:
		ans = max(ans, bin(s).count("1"))

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

ll N = 1e6 + 5;
vl fact(N, 0);
vl ifact(N, 0);

void pre(){
    fact[0] = 1;
    ifact[0] = 1;
    rep1(i, N){
        fact[i] = (i*fact[i-1])%MOD;
        ifact[i] = inverse(fact[i]);
    }
}

ll f(ll n, ll r){
    if(r > n)   return 0;
    return (((fact[n]*ifact[n-r])%MOD))%MOD;
}

ll ans = 1;
ll n, k;

void dfs(vvl& graph, ll u, ll par){
    ll cur = k-1, r = s(graph[u]);
    if(par != -1)   cur--, r--;
    ans *= f(cur, r);
    ans %= MOD;
    for(ll v : graph[u]){
        if(v != par)    dfs(graph, v, u);
    }
}


int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    pre();
    while(t--){
        cin>>n>>k;
        vvl graph(n);
        ingraph(graph, n-1);
        ans = k;
        dfs(graph, 0, -1);
        cout<<ans;
    }
}

Measured memory_bytes: 27708
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long ans = n - 1;
    for(long i = 2; (i * i) <= n; i++) {
      if((n % i) == 0) {
        long t = n / i;
        ans = Math.min(ans, i + t - 2);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
from collections import Counter, deque

(N,) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

freqA = Counter(A)
freqB = Counter(B)
for k in freqA.keys() & freqB.keys():
    if freqA[k] + freqB[k] > N:
        print("No")
        exit()

B = deque(B)
while True:
    rotate = 0
    for i in range(N):
        while A[(i + rotate) % N] == B[i]:
            rotate += 1
    bad = False
    B.rotate(rotate)
    for a, b in zip(A, B):
        if a == b:
            bad = True
    if not bad:
        break

print("Yes")
print(" ".join(map(str, B)))



Measured memory_bytes: 172460
N = int(input())
A = [0] * N

for i in range(N):
  A[i] = int(input())

B = [0] * N
for i in range(N):
  B[i] = A[i]

B.sort()
A0 = B[-1]
A1 = B[-2]

for i in A:
  if i == A0:
    print(A1)
  else:
    print(A0)

Measured memory_bytes: 58584
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
using namespace std;
using ll=long long;
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }
#define mod 1000000007

int main(){
    ll a;
    double b;
    cin>>a>>b;

    ll c=b*100+0.01;
    ll ans=(a*c)/100;

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<queue>
#include<vector>
#define f first
#define s second
using namespace std;
vector<int>v[500005];
int visit[3][500005];
queue<int>q;
int n,a,b;
inline void BFS(int k,int o){
	q.push(k);
	q.push(1);
	while(!q.empty()){
		int x=q.front();q.pop();
		int t=q.front();q.pop();
		visit[o][x]=t;
		for(int i=0;i<v[x].size();i++){
			if(visit[o][v[x][i]]==0)
			q.push(v[x][i]),q.push(t+1);
		}
	}
}
int main(){
	cin>>n;
	int m=n-1;
	while(m--){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	BFS(1,1);
	BFS(n,2);
	int x1,x2;
	x1=x2=0;
	for(int i=1;i<=n;i++){
	//	cout<<visit[1][i]<<' '<<visit[2][i]<<endl;
		if(visit[1][i]<=visit[2][i])x1++;
		else x2++;
	}
	if(x1>x2)cout<<"Fennec\n";
	else cout<<"Snuke\n";
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  double sum = 0;
  for (int i=0; i<N; i++){
    int a;
    cin >> a;
    sum += 1.0/a;
  }
  double ans = 1/sum;
  cout << setprecision(15) << ans << endl;
}


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

int main() {
    cout << fixed << setprecision(5);
    int N;
    cin >> N;
    vector<double>x(N);
    vector<string>u(N);
    double sum=0;
    for(int i=0;i<N;i++){
        cin >> x.at(i);
        cin >> u.at(i);
        if(u.at(i)=="JPY")sum+=x.at(i);
        else sum+=x.at(i)*380000;
    }
    cout << sum << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INFTY 1<<21
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[MAX][MAX];
int prim(){
  int u,minv,i,v;
  int d[MAX],p[MAX],color[MAX];
  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
}
  d[0]=0;
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  int sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }
  return sum;
}
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      int e;
      scanf("%d",&e);
      M[i][j]=(e==-1)? INFTY:e;
    }
  }
  printf("%d",prim());
  printf("\n");
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int n,l,s;
	int i,j,temp;
	int a[5];
	int cnt;
	
	scanf("%d",&n);
	while(n!=0000){
		cnt=0;
		while(n!=6174){
			if(n%1111==0){
				printf("NA\n");
				break;
			}
			else{
				for(i=0;i<4;i++){
					a[i]=n%10;
					n=n/10;
				}
				for(i=0;i<3;i++){
					for(j=i+1;j<4;j++){
						if(a[i]<a[j]){
							temp=a[i];
							a[i]=a[j];
							a[j]=temp;
						}
					}
				}
				l=a[0]*1000+a[1]*100+a[2]*10+a[3];
				s=a[3]*1000+a[2]*100+a[1]*10+a[0];
				n=l-s;
				cnt++;
			}
		}
		if(n%1111!=0){
			printf("%d\n",cnt);
		}
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 608
package main

import "fmt"

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func digits(x int64) int {
	s := 0
	for x > 0 {
		s++
		x /= 10
	}
	return s
}

func f(a, b int64) int {
	return max(digits(a), digits(b))
}

func main() {
	n := int64(0)
	fmt.Scan(&n)
	ans := 11
	for a := int64(1); a*a <= n; a++ {
		if n%a > 0 {
			continue
		}
		b := n / a
		ans = min(ans, f(a, b))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
c1 = [int(i) for i in input().split()]
c2 = [int(i) for i in input().split()]
c3 = [int(i) for i in input().split()]
flag = 0
for i in range(2):
    if not (c1[i+1] - c1[i] == c2[i+1] - c2[i] == c3[i+1] - c3[i]):
        flag = 1
print('Yes' if flag == 0 else 'No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std; 
#define rep(i, N) for (int i = 0; i < (int)N; i++)

int main(){
int x,y,z;
cin>>x>>y>>z;
swap(x,y);
swap(x,z);
cout <<x<<' '<<y<<' ' <<z<<endl;
}

Measured memory_bytes: 256
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <math.h>
#include <iomanip>
#define int long long
#define ll long long
#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	// 10^18 = 1000000000000000000

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	int a, b;
	//int m;
	//int k;
	//string s;
	//string t;
	//int m1, m2;
	//int a, b, c, k;
	int x, y;

	//int box[1000000000000000000];
	//int box;
	//int box2;
	//int x[5];

	//long double aaa;

	//int k, d;
	int all = 0;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	//int box[10000] = { 0 };

	//bool flag = true;
	bool flag = false;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	//cin >> n;
	//cin >> a >> b;
	cin >> x >> y;

	for (int i = 0; i < x; i++)
	{
		if (i == 0)
		{
			if (y % 2 != 0)
			{
				flag = false;
				break;
			}

			if (x * 4 < y)
			{
				flag = false;
				break;
			}

			if (x > y)
			{
				flag = false;
				break;
			}
		}

		y -= 2;
	}

	if (y == 0)
	{
		flag = true;
	}

	for (int i = 0; i < x; i++)
	{
		y -= 2;

		if (y == 0)
		{
			flag = true;
			break;
		}
	}

	//n = t.length();

	//cout << b << "\n";

	if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}

	//cout << fixed << setprecision(111) << all;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll MRINF = 5000000000000000;

int main() {

  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N)cin >> A[i];

  // ll start = 1;
  // REP(i, K){
  //   start *= A[i];
  // }
  // ll prev = start;
  // ll res = start;
  // cout << res / A[0] << endl;
  for(ll i = 1; i+K-1 < N; i++){
    // res = (res / A[i-1]) * A[i+K-1];
    // cout << (res / A[i-1]) << " " << prev << endl;
    if(A[i+K-1] > A[i-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    // prev = res;
  }



}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 4788
N = int(input())
T, c1, c2, c3 = 0, 0, 0, 0
for i in range(N):
    S = input()
    T += S.count('AB')
    if S[0] == 'B' and S[-1] == 'A':
        c1 += 1
    elif S[-1] == 'A':
        c2 += 1
    elif S[0] == 'B':
        c3 += 1
if c2 == 0 and c3 == 0:
    print(T + max(c1 - 1, 0))
else:
    print(T + c1 + min(c2, c3))

Measured memory_bytes: 9112
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin


from collections import Counter


Num = int(stdin.readline().rstrip())
data = []
for el in range(Num):
    data.append(stdin.readline().rstrip())
data.sort()

counter = Counter(data)

count = 0
check = 0
res = []
for el in counter.most_common():
    if count == 0:
        res.append(el[0])
        check = el[1]
        count = 1
        continue
    if check == el[1]:
        res.append(el[0])
res.sort()
for el in res:
    print(el)


Measured memory_bytes: 111532
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string s, a="CODEFESTIVAL2016";
  cin >> s;
  int c=0;
  rep(i,0,16){
    if(s.at(i)!=a.at(i)) c++;
  }
  co(c);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define long long ll
#define MAXN 100000

using namespace std;


inline int gcd(int a, int b) {
    int r;
    while(b > 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int v[MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, ans, x, k;
    ios::sync_with_stdio(false);
    cin >> n >> k;
    cin >> ans;
    v[1] = ans;
    for(i = 2; i <= n; i++) {
        cin >> x;
        ans = gcd(ans, x);
        v[i] = x;
    }
        for(i = 1; i <= n; i++) {
            if(v[i] >= k && (v[i] - k) % ans == 0) {
                cout << "POSSIBLE";
                return 0;
            }
        }
         cout << "IMPOSSIBLE";
    //cin.close();
    //cout.close();
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    string s; cin >> s;
    int N = s.size();
    if(!(s[0]=='1' && s[N-2]=='1' && s[N-1]=='0')){
        cout << -1 << endl;
        return 0;
    }
    REP(i,N-1){
        if(s[i]=='1' && s[N-2-i]=='0'){
            cout << -1 << endl;
            return 0;
        }
    }
    VI edge[N];
    queue<int> q; q.push(0);
    REP(i,N-1){
        if(s[i+1] == '0') q.push(i+1);
        else{
            while(!q.empty()){
                edge[i+1].push_back(q.front());
                q.pop();
            }
            q.push(i+1);
        }
    }
    edge[N-2].push_back(N-1);
    REP(i,N){
        REP(j,edge[i].size()) cout << i+1 << " " << edge[i][j]+1 << en;
    }
    return 0;
}

Measured memory_bytes: 6912
import sys
import math
N = int(sys.stdin.readline())
# import decimal


odd = []
oddness = []


for i in range(N):
    j = i + 1
    if j % 2 != 0:
        odd.append(j)

# decimal.getcontext().prec = 7
# print(decimal.Decimal(len(odd)) / decimal.Decimal(j))
answer = float(len(odd)) / float(j)
print(answer)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define ull unsigned ll
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP1(i,n) for (int i=1; i<=(n); i++)
#define f first
#define s second
#define pii pair<int,int>
#define SQ(x) (x)*(x);
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define endl '\n'
using namespace std;

main(){
   int n; cin>>n;
   vector<int> vc(n);
   REP(i,n) cin>>vc[i];
   int ocount=0;
   REP(i,n) if (vc[i]%2) ocount++;
   if (!(ocount%2)) cout<<"YES\n";
   else cout<<"NO\n"; 
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)


N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N % 2 == 0:
    min_x = (A[N//2] + A[(N//2)-1]) / 2
    max_x = (B[N//2] + B[(N//2)-1]) / 2
    # print(min_x, max_x)
    ans = (max_x - min_x)*2 + 1
else:
    min_x = A[N//2]
    max_x = B[N//2]
    # print(min_x, max_x)
    ans = max_x - min_x + 1

print(int(ans))


Measured memory_bytes: 91252
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

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

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a,b,m,c[100010],d[100010],mia = INF,mib = INF;
	cin >> a >> b >> m;
	for(int i = 0;i < a;i++) cin >> c[i];
	for(int i = 0;i < b;i++) cin >> d[i];
	for(int i = 0;i < a;i++) chmin(mia,c[i]);
	for(int i = 0;i < b;i++) chmin(mib,d[i]);
	int ans = mia + mib;
	for(int i = 0;i < m;i++){
		int x,y,z;
		cin >> x >> y >> z; x--;y--;
		chmin(ans,c[x] + d[y] - z);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 06/08/2017 13:15:57
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	
	int n;
	cin>>n;
	
	int x, two = 0, four = 0;
	for(int i = 0; i < n; i++){
		cin>>x;
		if(x % 4 == 0) four ++;
		else if(x % 2 == 0) two ++;
	}
	if(two >= 2) n -= two;
	n -= four * 2;
	if(two < 2 && four != 0) n--;
	if(n > 0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 384
using System;

namespace _0506
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                string s = Console.ReadLine();
                for (int z = 0; z < n; z++)
                {
                    string after = "";
                    char back = s[0]; int count = 1;
                    for (int i = 1; i < s.Length; i++)
                    {
                        if (s[i] == back) count++;
                        else
                        {
                            after += count.ToString() + back.ToString();
                            back = s[i]; count = 1;
                        }
                    }
                    after += count.ToString() + back.ToString();
                    s = after;
                }
                Console.WriteLine(s);
            }
        }
    }
}



Measured memory_bytes: 31564
N=int(input())
seq=0
rngs=[]
for i,p in enumerate(map(int, input().split())):
	if i+1 == p:
		seq += 1
	elif seq > 0:
		rngs.append(seq)
		seq = 0
if seq > 0:
	rngs.append(seq)

print(sum([r // 2 + r % 2 for r in rngs]))


Measured memory_bytes: 10420
//To debug :  g++ -g file.cpp -o code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807;
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000;
#define mp make_pair
#define mt make_tuple
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
	FAST

	int n,i;

	cin>>n;

	int arr[n+1],ans[n+1]={0};

	rep(i,1,n+1)
		cin>>arr[i];

	arr[0] = INT_MAX;

	ans[0] = 0;
	ans[1] = 0;

	rep(i,2,n+1)
	{
		ans[i] = min(ans[i-1]+abs(arr[i]-arr[i-1]),ans[i-2]+abs(arr[i]-arr[i-2]));
	}


	cout<<ans[n]<<"\n";





	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a,b ;
	cin >> b;
	int sum = 0; 
	a = b ;
	while(a)
	{
		sum = sum + a % 10;
		a /= 10 ;
	}
	if(b % sum == 0)
		cout << "Yes" << endl;
	else if(b % sum != 0)
		cout << "No"<< endl;
	return 0;
}

Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	for {
		a := nextInt()
		o := nextLine()
		b := nextInt()
		switch o {
		case "+":
			fmt.Println(a + b)
		case "-":
			fmt.Println(a - b)
		case "*":
			fmt.Println(a * b)
		case "/":
			fmt.Println(a / b)
		default:
			return
		}
	}
}



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

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

  

    ll n; cin >> n;
    string s; cin >> s;
    ll ans=0;
    int i=0;int j=n-1;
    while(i<j){
        while(s[j]=='W' && j>=0) j--;
        while(s[i]=='R' && i<n) i++;
        if(i<j)
        ans++;
        i++,j--;
    }
    cout << ans << endl;
}






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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	vector<vector<int>> dp(n + 1, vector<int>(3));
	for (int i = 1; i <= n; i++) {
		dp[i][0] = max(dp[i - 1][1] + b[i - 1], dp[i - 1][2] + c[i - 1]);
		dp[i][1] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][2] + c[i - 1]);
		dp[i][2] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][1] + b[i - 1]);
	}
	cout << max({ dp[n][0], dp[n][1],dp[n][2] }) << endl;

	return 0;
}

Measured memory_bytes: 9856
from bisect import bisect_right

N = int(input())
A = [int(s) for s in input().split()]
r = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
c = [0] * 9
for a in A:
    i = bisect_right(r, a)
    c[i] += 1
ans = 8 - c[:-1].count(0)
print(max(1, ans), ans + c[8])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bs binary_search
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpl vector<pair<ll,ll> >
#define mll map<ll,ll>
#define mcl map<char,ll>
#define pqll priority_queue<ll>
#define mpl map<pair<ll,ll>,ll >
#define msl map<string,ll>
#define mset(a,k) memset(a,k,sizeof(a));
#define len length()
#define fr(a,b,c) for(ll a=b;a<c;a++)
void in(ll *a,ll n){fr(i,1,n+1){cin>>a[i];}}
void out(ll *a,ll n){fr(i,1,n+1){cout<<a[i]<<" ";}}
void out(vl v){fr(i,0,(ll)v.size())cout<<v[i]<<" ";}
void out(ll a){cout<<a;}
void out(string s){cout<<s;}
void fast(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}


int main(){
	fast();
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll co=0;
	fr(i,0,(n-2)){
		string d="";
		d=d+s[i];
		d=d+s[i+1];
		d=d+s[i+2];
		if(d=="ABC"){
			co++;
		}
	}
	cout<<co;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn get_first(i: u32) -> u32 {
    i.to_string().chars().nth(0).unwrap().to_digit(10).unwrap()
}

fn get_last(i: u32) -> u32 {
    i % 10
}

fn count(first: u32, last: u32, n: u32) -> u32 {
    let mut count = 0;

    // 1桁の場合
    if first == last && first <= n {
        count += 1;
    }

    // 2桁の場合
    if 10 * first + last <= n {
        count += 1;
    }

    // 3桁以上の場合
    let mut d = 1;
    loop {
        let mut m = first * 10u32.pow(d + 1) + last;
        for x in 1..d + 1 {
            m += 9 * 10u32.pow(x);
        }

        if m > n {
            let x = first * 10u32.pow(d + 1) + last;
            if x < n {
                count += (n - x) / 10 + 1;
            }
            break;
        }

        count += 10u32.pow(d);
        d += 1;
    }

    count
}

fn main() {
    let n: u32 = read();

    let mut ans = 0;
    for a in 1..n + 1 {
        let first = get_first(a);
        let last = get_last(a);
        if last == 0 {
            continue;
        }
        ans += count(last, first, n);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
X, Y, Z, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

AB = []
for a in A:
  for b in B:
    AB.append(a+b)
    
AB.sort(reverse = True)

AB = AB[0:K]

C = list(map(int, input().split()))
ABC = []
for ab in AB:
  for c in C:
    ABC.append(ab+c)
    
ABC.sort(reverse = True)

for i in range(K):
  print(ABC[i])
  

Measured memory_bytes: 217720
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define repr(i,a,b) for (int i = a; i > b; --i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)
 
#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
ll dp[200000];
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 	
	//freopen ("test.txt","r",stdin);
	ll n,w;
	cin>>n>>w;
	for (int i = 0; i < 200000; ++i)
	{
		dp[i] = 1000000007;
	}
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
	{

		ll wi,vi;
		cin>>wi>>vi;

		for(int j=100000 ; j>=vi; j--)
		{
			dp[j] = min(dp[j] , dp[j - vi] + wi);
		}

	}
	ll ans ;
	for (int i = 0; i <= 100000; ++i)
	{
		if(dp[i] <= w)
		{
			ans = i;
		}
	}

	cout<<ans;
	
}

Measured memory_bytes: 1792