akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    ll N,K; cin>>N>>K;
    cout<<min(N%K,K-N%K)<<endl;
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(1);
#endif
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a[52][52]={0};
int main()
{
	int m,n,i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		getchar();
		for(j=1;j<=m;j++)
		{
			char c;
			scanf("%c",&c);
			if(c=='#')
				a[i][j]=1;
		}
	}
	for(i=1;i<n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(a[i][j]==1&&a[i-1][j]==0&&a[i+1][j]==0&&a[i][j-1]==0&&a[i][j+1]==0)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
} 

Measured memory_bytes: 256
import collections as c

n = int(input())
co = c.Counter(list(map(int, input().split())))
cm = sorted(co.items(), key=lambda x:x[0], reverse=True)
a = 0
b = 0
for v,m in cm:
  if m >= 4:
    if a == 0:
      a = b = v
    else:
      b = v
    break
  elif m >= 2 and a == 0:
    a = v
  elif m >= 2 and a != 0:
    b = v
    break
print(a*b)

Measured memory_bytes: 21540
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int digitsum(int N) {
    int ret = 0;
    while(N > 0) {
        ret += N % 10;
        N /= 10;
    }
    return ret;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    REP(i, 1, N) {
        int d = digitsum(i);
        if (A <= d && d <= B) ans += i;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  n = n%10;
  n = n%10;
  if(n == 3) cout << "bon" << endl;
  else if(n==0||n==1||n==6||n==8) cout << "pon" << endl;
  else cout << "hon" << endl;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  ll n;
  cin >> n;
  queue<string> q;
  q.push("3");
  q.push("5");
  q.push("7");


  int ans = 0;
  while(true) {
    string s = q.front(); q.pop();
    if(stoll(s) > n) break;
    set<char> st;
    for(auto c : s) st.insert(c);
    if(st.find('3') != st.end() && st.find('5') != st.end() && st.find('7') != st.end()) ++ans;
    q.push(s+'3');
    q.push(s+'5');
    q.push(s+'7');
  }
  cout << ans << endl;
}


Measured memory_bytes: 5584
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

class Flow {
	struct edge {
		int to, cap, rev;
		edge(int to_, int cap_, int rev_) : to(to_), cap(cap_), rev(rev_) {};
	};

	int V;
	vector<vector<edge>> G;
	vector<int> level;
	vector<int> iter;

	void BFS(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (size_t i = 0; i < G[v].size(); i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}

	int DFS(int v, int t, int f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < (int)G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				int d = DFS(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

public:
	Flow(int _V) : V(_V), G(_V), level(_V), iter(_V) {}
	void add(int from, int to, int cap) {
		G[from].push_back(edge(to, cap, G[to].size()));
		G[to].push_back(edge(from, 0, G[from].size() - 1));
	}
	int Dinic(int s, int t) {
		int flow = 0;
		while (true) {
			BFS(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			int f;
			while ((f = DFS(s, t, INF)) > 0) {
				flow += f;
			}
		}
	}
};

int main()
{
	int V, E;
	cin >> V >> E;
	Flow fl(V);
	for (int i = 0, u, v, c; i < E; i++) {
		cin >> u >> v >> c;
		fl.add(u, v, c);
	}
	cout << fl.Dinic(0, V - 1) << endl;
	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// struct UnionFind {
//     vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//     UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//         for(int i = 0; i < N; i++) par[i] = i;
//     }
//
//     int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//         if (par[x] == x) return x;
//         return par[x] = root(par[x]);
//     }
//
//     void unite(int x, int y) { // xとyの木を併合
//         int rx = root(x); //xの根をrx
//         int ry = root(y); //yの根をry
//         if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//         par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//     }
//
//     bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };
//
// vint divisor(ll n){ // nの約数
//   vint ret;
//   for(ll i=1;i*i<=n;i++){
//     if(n%i == 0){
//       ret.pb(i);
//       if(i*i!=n) ret.pb(n/i);
//     }
//   }
//   vsort(ret);
//   return ret;
// }
//
// ll get_digits_num(ll n){
//   ll ret=0;
//   while(n){
//     n/=10;
//     ret++;
//   }
//   return ret;
// }



int main() {
  cout<<fixed<<setprecision(10);

  ll N,M;
  cin>>N>>M;

  ll ans = 1;
  for(ll i=M/N;i>=1;i--){
    if((M-i*N)%N==0 || (M-i*N)%i==0){
      ans = i;
      break;
    }
  }
  cout << ans << endl;


}

















//


Measured memory_bytes: 256
#include<stdio.h>    
int main()    
{    
 int n1=0,n2=1,n3,i;
 int n;    
   
 scanf("%d",&n);    
 for(i=0;i<n;++i)
 {    
  n3=n1+n2;    
  n1=n2;    
  n2=n3;    
 }  
   printf("%d",n3);   
   printf("\n");
  return 0;  
 }  


Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleTest
{
    class Program
    {
        
        static void Main(string[] args)
        {
            int[] kn = MyIo.Ints();
            int k = kn[0];
            int n = kn[1];
            int[] a = MyIo.Ints();
            int[] df = new int[a.Length];
            for(int i=0; i < n-1; ++i)
            {
                df[i] = a[i + 1] - a[i];
            }
            df[n - 1] = k + a[0] - a[n - 1];
            int maxDf = df.Max();
            int result = k - maxDf;
            Console.WriteLine(result);

           
        }

    }
    static class MyIo
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }
        public static int[] Ints()
        {
            return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        }
        public static int[][] MultiInts(int num)
        {
            var result = new int[num][];
            for(int i = 0; i < num; ++i)
            {
                result[i] = Ints();
            }
            return result;
        }
        public static T[] MultiItems<T>(int num, Func<string,T> parser)
        {
            var result = new T[num];
            for(int i =0; i < num; ++i)
            {
                result[i] = parser(Console.ReadLine());
            }
            return result;
        }
    }
}


Measured memory_bytes: 34788
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <complex>
using namespace std;


int main() {
	int N;
	vector<int> d(100);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	sort(d.rbegin(), d.rend());
	int tall = 101;
	int tall_c = 0;
	for (int i = 0; i < N; i++) {
		tall > d[i] ? tall_c++ : 1;
		tall = d[i];
	}
	cout << tall_c << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st a, b, c;
  ci(a, b, c);
  int x = 0, y = 0, z = 0;
  char k = 'a';
  wh(true){
    if(k == 'a'){
      if(x == sz(a)){
        co('A');
        rt;
      }
      k = a.at(x);
      x++;
    }
    else if(k == 'b'){
      if(y == sz(b)){
        co('B');
        rt;
      }
      k = b.at(y);
      y++;
    }
    else{
      if(z == sz(c)){
        co('C');
        rt;
      }
      k = c.at(z);
      z++;
    }    
  }
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class AtCoder
{
    const int MOD = 1000000007;
    
    public void Slove()
    {
        var n = int.Parse(Console.ReadLine());
        var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var ans = 
            Enumerable.Range(1, n - 2)            
            .Count(i => array[i - 1] < array[i] ^ array[i + 1] < array[i]);
        System.Console.WriteLine(ans);
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

Measured memory_bytes: 13396
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N){
  vector<ll> v(N);
  ll s;
  
  for(ll i=1; i<=N; i++) {
    v[i] = v[i-1]+i;
    if(v[i]>=N) {
      s = i;
      break;
    }
  }
  // std::cout << v << std::endl;
  std::cout << s << std::endl;
  N-=s;
  while(N!=0) {
    auto i = lower_bound(v.begin(), v.begin()+s, N);
    std::cout << i-v.begin() << std::endl;
    N-=(i-v.begin());
  }

  // std::cout << i-v.begin() << std::endl;
  // N-=(i-v.begin());
  // i = lower_bound(v.begin(), v.begin()+s, N);
  // std::cout << i-v.begin() << std::endl;
  // N-=(i-v.begin());
  // std::cout << N << std::endl;
  // std::cout << *i << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}



Measured memory_bytes: 78336
#include <iostream>

#define P 998244353

using namespace std;

long comb[4001][4001];
long pow[4001];

int main(){
    int N, K;
    cin >> K >> N;
    pow[0] = 1;
    for(int i = 1; i <= 4000; i++){
        pow[i] = (pow[i-1]*2)%P;
    }
    for(int i = 0; i <= 4000; i++){
        comb[i][0] = 1;
        comb[i][i] = 1;
        for(int j = 1; j < i; j++){
            comb[i][j] = (comb[i-1][j-1]+comb[i-1][j])%P;
        }
    }
    for(int i = 2; i <= 2*K; i++){
        long ans = 0;
        if(i%2 == 1){
            if(i <= K+1){
                for(int p = 0; p <= (i-1)/2 && p <= N; p++){
                    ans = (ans+((comb[(i-1)/2][p]*pow[p]%P)*comb[N+K-i][N-p])%P)%P;
                }
            }else{
                int l = 2*K+2-i;
                for(int p = 0; p <= (l-1)/2 && p <= N; p++){
                    ans = (ans+((comb[(l-1)/2][p]*pow[p]%P)*comb[N+K-l][N-p])%P)%P;
                }
            }
        }else{
            if(i <= K+1){
                for(int p = 0; p <= i/2-1 && p <= N; p++){
                    ans = (ans+((comb[i/2-1][p]*pow[p]%P)*comb[N+K-i-1][N-p-1])%P)%P;
                    ans = (ans+((comb[i/2-1][p]*pow[p]%P)*comb[N+K-i][N-p])%P)%P;
                }
            }else{
                int l = 2*K+2-i;
                for(int p = 0; p <= l/2-1 && p <= N; p++){
                    ans = (ans+((comb[l/2-1][p]*pow[p]%P)*comb[N+K-l-1][N-p-1])%P)%P;
                    ans = (ans+((comb[l/2-1][p]*pow[p]%P)*comb[N+K-l][N-p])%P)%P;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 123648
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	vector<LL> A(7);
	for(int i=0;i<7;++i){
		cin >> A[i];
	}
	LL ans1 = 0;
	LL ans2 = 0;
	{
		LL res = 0;
		res += (LL)2*(A[1]);
		res += (LL)4*(A[0]/2);
		res += (LL)4*(A[3]/2);
		res += (LL)4*(A[4]/2);
		ans1 = res;
	}
	{
		LL res = 0;
		if( A[0] && A[3] && A[4] ){
			res += 6;
			A[0]--;A[3]--;A[4]--;

			res += (LL)2*A[1];
			res += (LL)4*(A[0]/2);
			res += (LL)4*(A[3]/2);
			res += (LL)4*(A[4]/2);
		}
		ans2 = res;
	}

	cout << max(ans1,ans2)/2 << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


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

int main(){
  int n;
  cin >> n;
  int d[n];
  for(int i = 0; i < n; i++){
    cin >> d[i]; 
  }
  sort(d,d+n,greater<int>());
  int x = 0;

  for(int i = 0; i < n; i++){
    if(d[i] == d[i + 1])
      x++;
  }
  
  cout << n - x << endl;

  return 0;
}
   
      


Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct stick {
  int a;
  int b;
};

int w, n;

int main() {
  int i;
  cin >> w;
  cin >> n;
  stick s[n];
  char split;

  for(i = 0; i < n; i++)
    cin >> s[i].a >> split >> s[i].b;

  for(i = 1; i <= w; i++) {
    int start = i;
    int j;

    for(j = n - 1; 0 <= j; j--) {
      int flag = start;
      if(start == s[j].a)
	flag = s[j].b;
      if(start == s[j].b)
	flag = s[j].a;
      start = flag;
    }
    cout << start << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1160
#include <algorithm>
#include <climits>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define DEBUG(x) cerr << #x << ": " << x << "\n"

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 100000, MAX_V = 100000;
    int n, v[MAX_N];
    cin >> n;
    REP(i, n) {
        cin >> v[i];
    }
    int s1[MAX_V + 1], s2[MAX_V + 1];
    memset(s1, 0, sizeof(s1));
    memset(s2, 0, sizeof(s2));
    REP(i, n) {
        if (i % 2 == 0) {
            s1[v[i]]++;
        } else {
            s2[v[i]]++;
        }
    }
    int m1 = 0, m2 = 0, m3 = 0, m4 = 0;
    int E1, E2, O1, O2;
    REP(i, MAX_V + 1) {
        if (s1[i] > m1) {
            m2 = m1;
            E2 = E1;
            m1 = s1[i];
            E1 = i;
        } else if (s1[i] > m2) {
            m2 = s1[i];
            E2 = i;
        }
        if (s2[i] > m3) {
            m4 = m3;
            O2 = O1;
            m3 = s2[i];
            O1 = i;
        } else if (s2[i] > m4) {
            m4 = s2[i];
            O2 = i;
        }
    }
    if (E1 != O1) {
        cout << n - m1 - m3 << endl;
        return 0;
    }
    int res1 = 0, res2 = 0;
    REP(i, n) {
        if (i % 2 == 0 && v[i] != E1) {
            res1++;
        } else if (i % 2 == 1 && v[i] != O2) {
            res1++;
        }
    }
    REP(i, n) {
        if (i % 2 == 0 && v[i] != E2) {
            res2++;
        } else if (i % 2 == 1 && v[i] != O1) {
            res2++;
        }
    }
    cout << min(res1, res2) << endl;
    return 0;
}


Measured memory_bytes: 1408
/*
AizuOnline A0040
Affine Cipher
*/
#include <stdio.h>
#include <string.h>

unsigned char ango[257];
unsigned char ango2[257];
#define AZ_dif ('Z'-'A'+1) 
#define DELIM " .\n"
int alpha,beta;

int devmod(char x,char y,int m)
{
  int i,s,r;
  //printf("xym %d %d \n",x,y);
  for(i=0,s=x;i<m;i++,s+=m)
    if(((s % y)==0))
      {
	r=s/y;
	if(r<0)r+=m;
	//printf("dm%d %d %d\n",x,y,s/y);
	return(r);
      }
  return(0);
}

int calc_alpha(char c1,char c2,char c3,char c4)
{
  //printf("CA %c %c %c %c\n",c1,c2,c3,c4);
return(devmod(c1-c2,c3-c4, AZ_dif));
}
int check_alpha(char c1,char c2,char c3,char c4,int alpha)
{
  int x1,x2;
  x1 = (c1-c2);
  x2 = (c3-c4) * alpha;
  if(((x1-x2) % AZ_dif)==0)
    return(-1);
  else
    return(0);
} 
main()
{
  int i;
  char *p;
  int a1,a2,a3,a21,a31;
  int n;
  int loop;

  scanf("%d ",&n);
  for(loop=0;loop<n;loop++)
    {
      //printf("gyo=%d\n",n);
      fgets(ango,256,stdin);
	
      strcpy(ango2,ango);
      beta=-99;
      
      p=strtok(ango2,DELIM);
      do
	{
	  if(strlen(p)!=4)
	    continue;
	  a1=calc_alpha(p[0],p[2],'t','i'); 
	  a2=calc_alpha(p[2],p[1],'i','h');
	  //a3=calc_alpha(p[2],p[3],'i','s');
	  a21=calc_alpha(p[1],p[2],'h','a');
	  a31=calc_alpha(p[3],p[2],'t','a');
	  //printf("a:%d %d %d %d\n",a1,a2,a21,a31);
	
	  if(a1==a2 && !islower(p[4])) 
	    {
	      alpha=a1;
	      if(!check_alpha(p[0],p[3],'t','s',a1))
		continue;
	      if((alpha % 2)==0 ||(alpha % 13)==0)
		continue;
	      beta= ((p[0]-'a')-('t'-'a')*alpha) % AZ_dif;
	      if(beta < 0)beta+=AZ_dif;
	      break;
	    }
	  else if(a21==a31 && !isalpha(p[4])) 
	    {
	      alpha=a21;
	      if(p[0]!=p[3])
		continue;
	      if((alpha % 2)==0 ||(alpha % 13)==0)
		continue;
	      beta= ((p[0]-'a')-('t'-'a')*alpha) % AZ_dif;
	      if(beta < 0)beta+=AZ_dif;
	      break;
	    }
      }  while(p=strtok(NULL,DELIM));
#ifdef DEBUG      
      printf("ab %d %d\n",alpha,beta);
#endif      
      if(beta != -99)
	{
	  for(i=0;ango[i];i++)
	    if(isalpha(ango[i]))
	      {
		ango[i] -= 'a';
		ango[i] -= beta;
		    ango[i] = devmod(ango[i],alpha,AZ_dif);
		    ango[i] += 'a';
	      }
	  printf("%s",ango);
	  //printf("%d\n",devmod(255,alpha,AZ_dif));
	}
    }
  return(0);
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define p 500
#define q 100
#define r 50
int main() {
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int n=0;
  rep(i,x/p+1){
    if(i>a)break;
    rep(j,(x-p*i)/q+1){
      if(j>b)break;
      rep(k,(x-p*i-q*j)/r+1){
        if(k>c)break;
        if(p*i+q*j+r*k!=x){
          continue;
          }
       // cout<<p*i+q*j+r*k<<"("<<i<<" "<<j<<" "<<k<<")"<<endl;
        n++;
        }
      }
    }
  cout<<n<<endl;
    
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto n = s[0];
    auto q = s[1];
    auto st = new SegmentTree!(int, min, (1<<31)-1)(n);

    while (q--) {
        s = readln.split.map!(to!int);
        auto t = s[0];
        auto x = s[1];
        auto y = s[2];
        if (t == 0) {
            st.assign(x, y);
        } else {
            st.query(x, y).writeln;
        }
    }
}

class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    void add(int pos, T val) {
        pos += offset;
        table[pos] += val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}



Measured memory_bytes: 4260
#include <cstdio>

using namespace std;

int N, M;
int occurences[100005];

int main()
{
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++)
  {
    int a, b; scanf("%d%d", &a, &b);
    occurences[a]++; occurences[b]++;
  }
  for (int i = 1; i <= N; i++)
  {
    if (occurences[i] % 2 == 1) {printf("NO\n"); return 0;}
  }
  printf("YES\n");
  return 0;
}

Measured memory_bytes: 512
n = gets.chomp.to_i
s = []
n.times do
  s << gets.chomp.to_s
end

s_bunrui = s.group_by(&:itself)
ac = s_bunrui["AC"] ? s_bunrui["AC"].count : 0
wa = s_bunrui["WA"] ? s_bunrui["WA"].count : 0
tle = s_bunrui["TLE"] ? s_bunrui["TLE"].count : 0
re = s_bunrui["RE"] ? s_bunrui["RE"].count : 0

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[2][101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[0][i];
	FOR(i,N) cin>>A[1][i];
	int ma=0;
	FOR(i,N) {
		int tot=0;
		FOR(j,i+1) tot+=A[0][j];
		for(j=i;j<N;j++) tot+=A[1][j];
		ma=max(ma,tot);
		
	}
	cout<<ma<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <cstdio>

#define exit() { printf("-1"); return 0; }

typedef long long ll;

ll a[222222];

int main(void)
{
	ll n, i;

	scanf("%lld" ,&n);
	for (i = 1; i <= n; i++)
		scanf("%lld" ,&a[i]);

	if (a[1] != 0)
		exit();

	for (i = 1; i < n; i++)
		if (a[i + 1] != 1 && a[i] + 1 < a[i + 1])
			exit();

	ll ans = 0;
	for (i = 1; i <= n + 1; i++)
		if (a[i] <= a[i - 1])
			ans += a[i - 1];

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

Measured memory_bytes: 1664
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = 2* (10**5) +2 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


n, m, k = map(int, input().split())
r = m
x = [m]
for i in range(n-1):
    r = (r*(m-1))%p
    x.append(r)
z = n//2

for i in range(1, k+1):
    r = (r + x[-i-1]*cmb(n-1,i,p))%p
print(r)

Measured memory_bytes: 126332
#include<iostream>
using namespace std;
int main(){
  int pa,ju,most=10000,ans;
  for(int i=0;i<3;i++){
    cin >> pa;
    if(pa<most){
      most=pa;
    }
  }
  ans=most;
  most=10000;
  for(int i=0;i<2;i++){
    cin >> ju;
    if(ju<most){
      most=ju;
    }
  }
  ans+=most;
  ans-=50;
  cout << ans << endl;
  return (0);
}

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

int main() {
	
	int n, a, b;
	cin >> n >> a >> b;
	
	cout << min(a*n, b) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int big_mod(int b, int p, int m)
{
   long long s = 1;
   long long d;

   d = b % m;
   while (p > 0) {
      if (p & 1) s = (s * d) % m;
      p >>= 1;
      d = (d * d) % m;
   }
   return (int)s;
}


int main()
{
	int m, n;

	scanf("%d%d", &m, &n);
	printf("%d\n", big_mod(m, n, 1000000007));
	return 0;
}



Measured memory_bytes: 2104
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};

ll disit(ll N){
  ll res = 0;
  while(N > 0){
    res += N % 10;
    N /= 10;
  }
  return res;
}

int main(){
  ll Q, H, S, D;
  cin >> Q >> H >> S >> D;
  ll N;
  cin >> N;
  ll a = N % 2;
  vector<ll> x(4);
  x[0] = 8 * Q;
  x[1] = 4 * H;
  x[2] = 2 * S;
  x[3] = D;
  sort(x.begin(), x.end());
  ll ans = N/2 * x[0];
  ans += a * min(S, min(H * 2, Q * 4));
  cout << ans << endl;
}


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long


signed main()
{
    int n;
    while(cin>>n, n) {
        vector<int> v(n);
        for(int i=0; i<n; ++i) cin >> v[i];
        string s;
        cin >> s;

        string ans = "";
        int cnt = 0;
        for(int i=0; i<s.size(); ++i) {
            char c = s[i];
            if(cnt>=v.size()) cnt = 0;
            for(int j=0; j<v[cnt]; ++j) {
                if(c=='a') c = 'Z';
                else if(c=='A') c = 'z';
                else c--;
            }
            ans += c;
            cnt++;
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;	cin>>n;
	int a[n+1],i,j,p1,p2;
	ll s1[n+1],s2[n+2];

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

	s1[0]=0,s2[n+1]=0;
	for(i=1;i<=n;i++){
		s1[i]=s1[i-1]+a[i];	s2[n+1-i]=s2[n+2-i]+a[n+1-i];
	}

	p1=2,p2=4;

	ll ans=s1[n];

	for(i=3;i<=n-1;i++){
		while(p1<i-1){
			if(abs(s1[i-1]-2*s1[p1-1]) >= abs(s1[i-1]-2*s1[p1]))	p1++;
			else	break;
		}
		p2=max(p2,i+1);
		while(p2<n){
			if(abs(s2[i]-2*s2[p2]) >= abs(s2[i]-2*s2[p2+1]))	p2++;
			else	break;
		}
		ll maxi=max(max(s1[p1-1],s1[i-1]-s1[p1-1]),max(s2[p2],s2[i]-s2[p2]));
		ll mini=min(min(s1[p1-1],s1[i-1]-s1[p1-1]),min(s2[p2],s2[i]-s2[p2]));
		ans=min(ans,maxi-mini);
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 4224
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N;
		while((N = scan.nextInt()) != 0) {
			int[] S = new int[N];
			for(int i = 0; i < N; i++) {
				S[i] = scan.nextInt();
			}
			int n = 0;
			int[] prev = S;
			int[] now = new int[N];
			for( ; !Arrays.equals(prev, now);) {
				n++;
				if(n >= 2){
					prev = now;
				}
				now = new int[N];
				Map<Integer,Integer> mset = new HashMap<Integer,Integer>();
				for(int i = 0; i < N; i++) {
					if(mset.containsKey(prev[i])) {
						mset.put(prev[i],mset.get(prev[i]).intValue()+1);
					} else {
						mset.put(prev[i], 1);
					}
				}
				for(int i = 0; i < N; i++) {
					now[i] = mset.get(prev[i]).intValue();
				}
			}
			System.out.println(n-1);
			for(int i = 0; i < N; i++) {
				if(i > 0){
					System.out.print(" ");
				}
				System.out.print(now[i]);
			}
			System.out.println();
		}
		scan.close();
	}

}

Measured memory_bytes: 23696
# -*- coding: utf-8 -*-
s = input()
# print(s)
# print(len(s))
for i in range(len(s)):
    c=s[i:i+1]
    if i % 2 !=0:
        if c == 'R':
            # print(i,c,'No')
            print('No')
            exit(0)
    else:
        if c == 'L':
            # print(i,c,'No')
            print('No')
            exit(0)
print('Yes')

Measured memory_bytes: 2940
main = getContents >>= mapM_ (putStrLn . fout . simple_calculator . fin) . takeWhile (notElem '?') . lines
fin = words
fout = show
simple_calculator [a,op,b] = calc (read a) (read b)
 where calc = case op of {"+" -> (+); "-" -> (-); "*" -> (*); "/" -> div}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int count = 0;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);

  for (int i = 0; i < N; i++){
    if(i%2 == 0){
      if(a.at(i)%2 != 0){
        count ++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace C_ABC132
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {
            n = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            var sl = s.ToList();
            sl.Sort();
            int mid = n[0] / 2;
            int ans = 0;
            if (n[0] % 2 == 1)
            {
                WriteLine(ans);
                return;
            }
            if (sl[mid] == sl[mid - 1])
            {
                WriteLine(ans);
                return;
            }
            else
            {
                ans = sl[mid] - sl[mid - 1];
                WriteLine(ans);
                return;
            }

        }
    }
}


Measured memory_bytes: 20192
#include <iostream>

using namespace std;

int insertionSort(int a[1000], int n) {
    for (int i = 0; i < n; i++) {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;

        for (int u = 0; u < n; u++) {
            if (u == n - 1) {
                cout << a[u];
            } else {
                cout << a[u] << " ";
            }
        }
        cout << endl;
    }
}

int main() {
    int n;
    int a[1000];

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

    insertionSort(a, n);
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	vector<string> S(3);
	for(int i = 0; i < 3; i++) cin >> S[i];

	int i = 0;

	while(S[i].size()){
		char r = S[i][0];
		S[i].erase(S[i].begin());
		i = r - 'a';
	}

	cout << (char)(i + 'A') << endl;

	return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn];
int b[maxn];
int c[maxn];
map<int ,int>ma;
int main()
{
    int n,k=0,z=0;

 cin>>n;
 int x;
int flag=0;
 for(int i=0;i<n;i++){
    cin>>a[i];
    flag=flag^a[i];
}
 if(flag==0)
    printf("Yes\n");
    else
 puts("No");


    return 0;
}


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

using namespace std;

inline void solve ()
{
  int n, l;
  cin >> n >> l;
  auto ans = l * n + n * (n - 1) / 2;
  if (l <= -n)
  {
    ans -= l + n - 1;
  }
  else if (l > 0)
  {
    ans -= l;
  }
  cout << ans << endl;
}

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);
  cout << fixed << boolalpha;
  cerr << fixed << boolalpha;
  solve ();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using namespace std;

int main(){
  mp::int128_t a,b,c;
  cin >> a >> b >> c;
  if(c-a-b<0) cout << "No" << endl;
  else if(2*a*b - a*a < b*b+c*c-2*b*c-2*c*a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

ls = list(map(int,input().split()))

ans = [None]*n

acm = 0

for i in range(0,n-2,2):
  acm ^= ls[i]^ls[i+1]
  
ans[-1] = ~ls[-2]^(~acm)  

for i in range(n-1):
  ans[i] = ~ans[-1]^(~(ls[-1]^ls[i]))

s = ""
for a in ans:
  s += str(a)+" "
  
print(s)

Measured memory_bytes: 31448
//二叉搜索树的插入 
#include<iostream>
#include<cstdlib>
using namespace std;
struct node{
	int key;
	node *p,*l,*r;
};
node *root,*nil;
void Insert(int key)
{
	node *tt=(node*)malloc(sizeof(node));
	tt->key=key;
	tt->l=nil;
	tt->r=nil;
	node *t=root;   //  x
	node *y=nil; 
	while(t!=nil)
	{
		y=t;
		if(tt->key<t->key)
			t=t->l;
		else
			t=t->r;
	}
	tt->p=y;
	if(y==nil)
		root=tt;
	else
	{
		if(tt->key<y->key)
		{
			y->l=tt;
		}
		else
			y->r=tt;
	}
}

void Preorder(node* u)
{
	if(u==nil)
		return;
	cout<<" "<<u->key;
	Preorder(u->l);
	Preorder(u->r);
}

void Inorder(node* u)
{
	if(u==nil)
		return;
	Inorder(u->l);
	cout<<" "<<u->key;
	Inorder(u->r); 
}
bool find(int key)
{
	node *tt=root;
	while(tt!=nil&&tt->key!=key)
	{
		if(tt->key<key)
			tt=tt->r;
		else
			tt=tt->l;
	}	
	if(tt!=nil)
		return 1;
	else 
		return 0;
		
} 
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		string s;
		cin>>s;
		if(s[0]=='i')
		{
			int num;
			cin>>num;
			Insert(num);
		}
		else if(s[0]=='f')
		{
			int nn;
			cin>>nn;
			if(find(nn))
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}
		else{
			Inorder(root);
			cout<<endl;
			Preorder(root);
			cout<<endl;
		}	
	} 
	return 0;
}


Measured memory_bytes: 21932
#include<bits/stdc++.h>
#include<boost/range/irange.hpp>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/algorithm/string/classification.hpp>
#include<boost/algorithm/string/split.hpp>
#include<boost/algorithm/string/join.hpp>
#include<boost/algorithm/string/replace.hpp>
#include<boost/math/tools/minima.hpp>
#include<boost/pending/disjoint_sets.hpp>
using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;
using boost::algorithm::split;
using boost::is_any_of;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::math::tools::brent_find_minima;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
    int h, w;
    cin >> h >> w;
    vector<string>s(h);
    for(auto& in: s){
        cin >> in;
    }
    for(auto out: s){
        cout << out << endl << out << endl;
    }
}   



Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int N;
double p[3000];
double dp[3000][3000];

int main(void){
	cin >> N;
	for(int i = 0; i < N; i++) cin >> p[i];
	dp[0][0] = 1.0;
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= 3000; j++){
			dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1.0 - p[i-1]);
		}
	}
	double ans = 0;
	for(int i = N / 2 + 1; i < 3000; i++){
		ans += dp[N][i];
	}
	cout << fixed << setprecision(10) << ans << endl;

}


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

//read_kaisetsu
int main() {
    int n,k;cin>>n>>k;
    ll ans = 0;
    int cc1 = 0;
    int cc2 = 0;
    
    for(int i=1;i<=n;++i){
        if(i%k==0)++cc1;
        if(k%2==0 && i%k==(k/2))++cc2;
    }
    
    if(cc1==1)ans+=1;
    else ans+=pow(cc1,3);

    if(cc2>0)ans+=pow(cc2,3);
    
//    cout<<cc1<<endl;
//    cout<<cc2<<endl;  

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

Measured memory_bytes: 4032
#include <stdio.h>

int main(int argc, char *argv[]){
        int heights[10];
        int i;
        for(i = 0 ; i < 10 ; i++){
                scanf("%d",heights+i);
        }   
        for(i = 0 ; i < 3 ; i++){
                printf("%d\n", max(heights));
        }   
        return 0;
}
int max(int nums[]){
        int i;
        int tmp;
        int tmp2;
        tmp = 0;
        tmp2 = 0;
        for(i = 0 ; i < 10 ; i++){
                if(tmp < nums[i]){
                        tmp = nums[i];
                        tmp2 = i;
                }   
        }   
        nums[tmp2] = 0;
        return tmp;
}

Measured memory_bytes: 0